395 Commits
Author SHA1 Message Date
Bogdan Chadkin 84fc906721 refactor: convert page meta fields into expressions (#2853)
Here added huge migration to convert page meta into expressions and
adapted the code to compute those.
2024-02-01 14:20:18 +07:00
Bogdan Chadkin 443fa5a50c feat: support social image url (#2845)
To integrate cms we need to be able to specify arbitary url as social
image instead of just asset.

Here added input which overrides selected asset. Hidden behind the flag.

<img width="538" alt="Screenshot 2024-01-30 at 21 27 40"
src="https://github.com/webstudio-is/webstudio/assets/5635476/e472028c-1cea-4e7d-9320-75d0cb9d2eff">
2024-01-30 23:39:40 +07:00
Bogdan Chadkin 35fbcb9fc4 refactor: generate page meta in loader (#2844)
Here refactored page meta with simpler type than full page data and
moved it into factory which is invoked lazily in loader.

This will let us support variables and resources in page settings later.
2024-01-30 21:24:55 +07:00
Bogdan Chadkin d0395d072e refactor: generalize generating components (#2816)
Ref https://github.com/webstudio-is/webstudio/issues/2791

Here renamed generatePageComponent to generateWebstudioComponent and
refactored to use it later for slots.

"Page Params" variable is now passed as parameter. Similar way we will
support parameters in design components.
2024-01-25 23:17:17 +07:00
Bogdan Chadkin a474d92069 refactor: inline actions into props (#2813)
Ref https://github.com/webstudio-is/webstudio/issues/2791

Here refactored actions generation and computing
to simplify rendering slots as components.

before

```ts
const onClick = () => {
variableName = 1
set$variableName(variableName)
}
...
<Box
data-ws-id="..."
data-ws-component="Box"
onClick={onClick}>
```

after

```ts
<Box
data-ws-id="..."
data-ws-component="Box"
onClick={() => {
variableName = 1
set$variableName(variableName)
}}>
```

Similar thing done in builder. Actions are generated and executed per
each prop when compute prop values instead of precomputing globally
along with variables.
2024-01-25 12:50:59 +07:00
Bogdan Chadkin f620e2e1f2 refactor: generalize transferrable fragments (#2780)
Here added two new types

WebstudioFragment - reusable fragment of webstudio data which can be
generated (markdown, embed template), transferred (copied or stored in
marketplace) and inserted.

WebstudioData - all available normalized data to allow composing
multiple operations within single transaction like delete instance and
then insert into other part of the page.
2024-01-19 22:24:59 +07:00
Bogdan Chadkin 8d073e598d refactor: pass resources to page with context (#2777)
Resources should not be part of component props.
Drilling resources to nested custom components
would be more complex so using context can
simplify this part and prepare for rendering
slots as separate components.
2024-01-18 23:33:54 +07:00
Oleg Isonen 8e2e07ea23 feat: Allow selecting a nested path for link href (#2773)
Ref https://github.com/webstudio-is/webstudio/issues/404

## Description

- can select a nested path for link pages
- can click in preview to get to the page

## Steps for reproduction

1. click button
2. expect xyz

## Code Review

- [ ] hi @TrySound , I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `builder/env-check.js` if mandatory
2024-01-17 19:02:41 +01:00
Oleg Isonen 65d0df8213 feat: Nested routes compiler (#2766)
Ref https://github.com/webstudio-is/webstudio/issues/404

## Description

- generate remix app with nested routes

## Steps for reproduction

1. create nested routes 
2.  generate app using cli

## Code Review

- [ ] hi @istarkov , I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `builder/env-check.js` if mandatory
2024-01-16 17:03:54 +01:00
Bogdan Chadkin c0702ba10a fix: polish collection component (#2767)
Ref https://github.com/webstudio-is/webstudio/issues/2532

- fixed collection icon color
- allow to specify expression in embed template children
- tweaked default collection template
- allow to specify variable aliases in embed template children
- renamed collectionItem variable to Collection Item
- moved collection component to "Data" category
- fix broken canvas when bind object to text content
- add better tooltips why cannot remove parameter and used variables
2024-01-16 15:13:18 +07:00
Oleg Isonen 5a5382c975 feat: Page folders (#2745)
Ref https://github.com/webstudio-is/webstudio/issues/404

## Description

Implement ablity to organize pages in folders, not a complete
implementation, only:

- Implements data structure for folders
- Allows to create folders and select a parent folder from a folder
- Reparents orphaned pages/folders for the future collaboration mode

## Steps for reproduction

1. open pages
2. add folders
3. nest folders
4. delete folders

## Code Review

- [ ] hi @kof, I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `builder/env-check.js` if mandatory
2024-01-13 16:39:57 +01:00
Bogdan Chadkin ed188ef215 feat: support binding in text content (#2756)
Ref https://github.com/webstudio-is/webstudio/issues/2532

- added new expression type to instance children
- added binding to text content setting
- prevented deleting variable bound to instance child
- rendered computed child in canvas and preview
- supported expression child in component generator

What's missing

- copy paste support (will add later)

<img width="880" alt="Screenshot 2024-01-13 at 09 59 58"
src="https://github.com/webstudio-is/webstudio/assets/5635476/1275d5b3-420b-4f97-9d72-407ff39932e5">
2024-01-13 16:50:08 +07:00
Bogdan Chadkin 8fa0d7590f feat: support editing text content in settings panel (#2754)
Ref https://github.com/webstudio-is/webstudio/issues/2532

Here added "Text Content" system prop to all elements which allows to
edit plain text content though settings panel.

It will be used to support instance content binding instead of using
HtmlEmbed with code binding.

<img width="879" alt="Screenshot 2024-01-12 at 11 51 39"
src="https://github.com/webstudio-is/webstudio/assets/5635476/d88e1d56-7f6b-4ec1-9ea3-04cd40baa618">
2024-01-12 20:33:08 +07:00
Oleg Isonen 692bc16590 fix: Escape user-provided class (#2721)
## Description

Realized that user can put in a quote that will break the rendering

We also need an actual validation in the UI for class name, because its
not just an arbitrary string.


## Code Review

- [ ] hi @TrySound , I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `builder/env-check.js` if mandatory
2023-12-31 21:00:17 +01:00
Oleg Isonen c6bdef5084 feat: CSS engine has now a Style Sheet rendering with atomic classes which will lead to a 10x smaller bundle size (#2713)
## Description

CSS engine has now a Style Sheet rendering with atomic classes which
will lead to a much smaller bundle size

## Steps for reproduction

1. click button
2. expect xyz

## Code Review

- [ ] hi @kof, I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `builder/env-check.js` if mandatory
2023-12-30 21:08:37 +01:00
Oleg Isonen 5930064678 feat: Rename Site to Project because we are not just building a site builder (#2718)
## Description

Site is too narrow name for things that are pssible with webstudio


## Code Review

- [ ] hi @TrySound , I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `builder/env-check.js` if mandatory
2023-12-30 10:40:09 +01:00
Bogdan Chadkin f0b7a41824 fix: improve generating resources (#2715)
Ref https://github.com/webstudio-is/webstudio/issues/2532

Here added resources fixture and fixed a few issues with it

- add optional chaining to collection?.map to safely skip iterating
missing data
- added any to resource responses to access remote data without type
errors
- always generate empty headers array
- skip empty body in generated resources
2023-12-27 23:42:50 +07:00
Bogdan Chadkin 842c017c11 refactor: make resources universal (#2710)
Refactored resources generator to use universal http resource which
cover most cases.
- loadResource is imported from sdk
- accepts url (expression), method, headers (value is expression) and
body (expression)
- all variables and page params parameter are available for loader
expressions
2023-12-24 01:03:44 +07:00
Bogdan Chadkin dcd989108e feat: generate resource loaders (#2701)
Ref https://github.com/webstudio-is/webstudio/issues/2532

Here added generation of server modules with resource loaders. These
loaders are invoked in remix loader and result is passed to page
component.

Check fixtures and tests.
2023-12-18 21:24:50 +07:00
Bogdan Chadkin 02534730de feat: support resources in schema and compiler (#2698)
Ref https://github.com/webstudio-is/webstudio/issues/2532

Here added new schema type "Resources" to contain configuration of
requests to services. Their first use case is referencing from variable
to store loaded data.

For now added only client side generation. Later add support for server
code generation as part of remix loaders.
2023-12-16 15:44:49 +07:00
Bogdan Chadkin 7fe4b770d6 feat: support page path params in site compiler (#2682)
Ref https://github.com/webstudio-is/webstudio/issues/2532

Here remix route params are adapted to URLPattern format and passed to
generate page component as prop.

For this added 2 remix specific utilities
- convert subset of url pattern to remix route
- generate utility to adapt remix params to URLPattern params for
example for `/*` `params['*']` is replaced with `params[0]` and for
`/:slug*` `params['*']` is replaced with `params['slug']`
2023-12-15 00:34:51 +07:00
Bogdan Chadkin 61d664fc87 refactor: support parameter data source for collection item (#2671)
Ref https://github.com/webstudio-is/webstudio/issues/2532

Here added dataSource.type = 'parameter' without initial value because
value is always provided by context. It let us fix a few issues with
variables without complicating logic.

- prevent deleting parameter variable (collection item) in variables
panel
- allow changing only name of parameter variable
- show only name in the list of variables
- fix removing expression from collection data
- hide item parameter from collection variable list
- prevent editing parameter value from props
- make collection unstylable
2023-12-08 11:42:18 +07:00
Bogdan Chadkin d361c9ecee feat: add collection component to builder (#2657)
Ref https://github.com/webstudio-is/webstudio/issues/2532

Here added a "core" collection component to support iterating over json
arrays.

There is a lot of room for unification of all this logic though would
require building reactive tree abstraction.

Canvas automatically renders stub component for collection to make it
droppable. We can do the same for slot component.

Slot and Fragment eventually will go to "core" components too.

Added json/parameter prop types to embed template to support collection.

Fixed loosing focus while typing in json prop.

## Steps for reproduction

1. Drop collection component
2. play with it
2023-11-29 17:07:28 +03:00
Bogdan Chadkin 33509db139 refactor: reimplement duplicating instances (#2663)
Part of https://github.com/webstudio-is/webstudio/issues/2516

Here added new copy implementation. There are 2 differences

- it does not change existing instances and not change their children,
we will need this to copy pages
- it handles cross-project copy of portals (slots) properly, now each
portal content is inserted separately if the root does not exist and
skips otherwise
- much better covered with tests

## Steps for reproduction

1. try duplicating form and change form state prop
2. try duplicating form error message and change form state prop
2023-11-29 13:45:09 +03:00
Bogdan Chadkin 3cfa10ae22 refactor: compute props contextually (#2628)
Ref https://github.com/webstudio-is/webstudio/issues/2532

Here refactored props values computing to reuse in both canvas and
settings panel and support future collections which need to provide
different values for same variables.

Grouped whole logic and covered with tests.

## Testing

- check image src is working
- check link switch page in preview
2023-11-18 20:54:51 +03:00
Bogdan Chadkin 130d21a307 fix: generate empty function for cleared actions (#2616)
Fixes
https://discord.com/channels/955905230107738152/1174291886878490656

Actions are cleared on copy paste though here we get runtime error
because output expects function to be defined.

Here always generate at least empty function.
2023-11-15 21:19:43 +03:00
Bogdan Chadkin 3c3a0c87c9 build: fix missing imports 2023-11-14 16:48:49 +03:00
Bogdan Chadkin f3a75d150a refactor: simplify text child rendering (#2611)
Remove responsibility for text rendering from webstudio component to
instances tree renderer. Will simplify future collection management.
2023-11-14 16:41:35 +03:00
Bogdan Chadkin 98f0c348e8 refactor: add remix body component (#2612)
Here replaced scripts injection with special body override which already
includes those scripts.
This would simplify the logic with collections support.
2023-11-14 16:06:20 +03:00
Bogdan Chadkin 12ff45a34b feat: support generating collection (#2605)
Ref https://github.com/webstudio-is/webstudio/issues/2532

Here first part for collection support. Collections are generated as

```tsx
list.map((item, index) => <Fragment key={index}></Fragment>)
```

Added new "parameter" prop type to represent "item" which always refers
to variable. "parameter" reflects same semantics as js functions where
in function call it is argument `fn(1, 2, 3)` and in function definition
it is parameter `function fn(a, b, c) {}`.

Collection children are always wrapped with fragment to let having more
than one child and always pass key to avoid react warnings.
2023-11-13 20:48:22 +03:00
Bogdan Chadkin c776356b53 feat: add json prop control (#2608)
Ref https://github.com/webstudio-is/webstudio/issues/2532

We need json control in settings panel to support editing current value
of variables for example for collection data.

Here tweaked props logic and fixed a few bugs related to switching prop
type based on variable type.

Testing:

- type something in body id
- add this expression to body id `{ id: 1 }`
- remove expression
- add variable with `{ id: 1 }`
- select variable
- remove expression
2023-11-13 20:43:01 +03:00
Bogdan Chadkin 4e9986d6e3 refactor: inline expressions into props (#2603)
Ref https://github.com/webstudio-is/webstudio/issues/2532

Collections will introduce nested scope within same component and some
expressions at component scope will not be able to access collection
item. For example

```ts
const PageComponent = () => {
  let [value, set$value] = useState('')
  let show = value === 'error'
  let arialabel = item + ' label'
  return <Form>
    <ErrorMessage data-ws-show={show}></ErrorMessage>
    {list.map(item =>
      <Button aria-label={arialabel}></Button>
    )}
  </Form>
}
```

So the easiest way to workaround it without complicated scope selecting
is just inline all expressions into props.

```ts
const PageComponent = () => {
  let [value, set$value] = useState('')
  return <Form>
    <ErrorMessage data-ws-show={value === 'error'}></ErrorMessage>
    {list.map(item =>
      <Button aria-label={item + ' label'}></Button>
    )}
  </Form>
}
```

## Steps for reproduction

1. Create `Form`
2. Try to change `state` prop
2023-11-12 13:07:14 +03:00
Bogdan Chadkin 6dd5b0687a refactor: drop legeacy data source prop support (#2600)
Ref https://github.com/webstudio-is/webstudio/issues/2532

We successfullly migrated prod to expression prop. Now we can safely
remove legacy data source prop
handling across codebase.
2023-11-11 18:07:17 +03:00
Bogdan Chadkin 052fe4e3ce refactor: add expression prop (#2582)
Ref https://github.com/webstudio-is/webstudio/issues/2532

On the last discussion about bindings we agreed expression are always
bound to single prop and cannot be reused.

Here added new prop.type = 'expression' as a replacement to
dataSource.type = 'expression'.

This will let us unify expression/variable reference and avoid deep
dependencies. Expressions and actions become similar.

For now both expression prop and legacy expression data source are
supported until we migrate completely in db.
2023-11-08 20:46:57 +03:00
Bogdan Chadkin 4f5883834e feat: add variables to settings panel (#2573)
Ref https://github.com/webstudio-is/webstudio/issues/2532

Here integrated variables into props. Now it can be tested considering
instances tree.

<img width="488" alt="Screenshot 2023-11-06 at 13 10 33"
src="https://github.com/webstudio-is/webstudio/assets/5635476/5615478a-c762-4324-9e24-745cbd452ad0">
2023-11-08 10:56:12 +03:00
Bogdan Chadkin fa06b7d495 feat: reuse variables on copy/paste within same tree (#2580)
Ref https://github.com/webstudio-is/webstudio/issues/2532

Here improved copy/paste behavior.

Before variables outside of copied tree were inlined. For example
ErrorMessage were loosing its expression when duplicated within same
form.

Now expressions and variables are preserved
and variables are inlined into expressions when paste target do not have
such variable. For example ErrorMessage get `"initial" == "error"`. With
upcoming UI it will be more obvious. The main idea here to not loose all
expressions but only references to unavailable variables.
2023-11-07 18:58:50 +03:00
Bogdan Chadkin d04beb7620 feat: support objects and member expressions (#2576)
Ref https://github.com/webstudio-is/webstudio/issues/2532

Objects are essential for cms. Here expression can specify objects and
access their properties.

All expressions are transpiled into optional chains before execution.
This will prevent user from seeing errors like "cannot access
"something" of undefined".

Added "json" type to variable values for objects and arrays.

<img width="283" alt="Screenshot 2023-11-06 at 19 59 42"
src="https://github.com/webstudio-is/webstudio/assets/5635476/0e0234b1-d194-4038-bcee-6b93a3e6e63b">
2023-11-07 16:26:44 +03:00
Bogdan Chadkin 0d735c2bf8 refactor: compile prop expressions (#2569)
Ref https://github.com/webstudio-is/webstudio/issues/2532

Here changed accessing expression from data source id to prop id in
builder and data source name to prop name in generated code.

This is another step to migrate expressions from data sources to props.

See generated output for clarification.

Note: review with hidden spaces
2023-11-06 13:14:34 +03:00
Bogdan Chadkin d4043922f0 refactor: move expressions to props in embed template (#2560)
Ref https://github.com/webstudio-is/webstudio/issues/2532

We decided to treat expressions as props bindings
so it makes sense to move expression data to props as well. This will
make expression and action simetrical and simplify data sources
management.

As you can see all expressions have same "expression" name now. In
another PR will change to prop name.
2023-11-05 16:31:27 +03:00
Ivan Starkov 50373db9c1 build: Cli support for meta tags (#2537)
## Description

- Added support of   "image/x-icon",  "image/ico", for upload
- changed local dev resize path
- fixed zod meta types
- added favicon, site_name og tags in route template
- added cache headers for html content

## Steps for reproduction

1. click button
2. expect xyz

## Code Review

- [ ] hi @kof, I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `builder/env-check.js` if mandatory
2023-10-31 15:51:17 +02:00
Ivan Starkov 6f3adf1cc4 feat: Add SiteSettings Dialog (#2527)
## Description

Dialogs and saving of Site Settings and Page Settings.

Bugs & Fixes
- [x] - Use page name on swap to set path i.e. `/home`


Next PRs.

- CLI support (generating head title links and metas)
- <img width="582" alt="image"
src="https://github.com/webstudio-is/webstudio/assets/5077042/ab348eb8-0be0-49fc-b15e-352f089812db">
- <img width="266" alt="image"
src="https://github.com/webstudio-is/webstudio/assets/5077042/6c272cf2-09d2-4f43-af9f-7460d84fa100">
- Not sure why we need upload button at all, anyway in next PRs <img
width="451" alt="image"
src="https://github.com/webstudio-is/webstudio/assets/5077042/a62d2a9d-8793-4d9b-a2c2-4992358f5b10">



---


<img width="173" alt="image"
src="https://github.com/webstudio-is/webstudio/assets/5077042/554f2310-579d-4326-8ca7-dd84a13a114a">

<img width="386" alt="image"
src="https://github.com/webstudio-is/webstudio/assets/5077042/f0cfb8be-49ab-4b7f-baa3-d68938a2125a">


<img width="375" alt="image"
src="https://github.com/webstudio-is/webstudio/assets/5077042/10dfd728-de87-4c91-bca0-0216ad7e5f96">


- [x] - Make homePage is not working


## Steps for reproduction

1. click button
2. expect xyz

## Code Review

- [ ] hi @kof, I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `builder/env-check.js` if mandatory
2023-10-30 12:18:35 +02:00
Bogdan Chadkin f08fe859bb refactor: bump change-case (#2428)
Ref https://github.com/blakeembrey/change-case/releases

Change case in last major merged many packages into one to simplify
maintaining and usage. A few packages like title-case are still separate
as more rare case.

- replaced no-case with change-case (merged into change-case)
- replaced param-case with change-case (merged into change-case and
renamed to kebab (finally))
- replaced camelcase with change-case (has own camelcase utility)
- bumped title-case
2023-10-08 01:03:59 +04:00
Giuseppe b3dd7f18c4 feat: AI Operations (#2391)
Implements an operation-based system to accomplish a number of edit
tasks on a JSX+CSS representation of a selected Webstudio tree.

Every JSX element has the instance id as data-ws-id and therefore the
LLM knows what to edit.

The idea is to create a number of operations (aiOperations)
specs/schemas with Zod describing unique edit tasks, make a
discriminated union, convert them to JSON Schema. We then inject this
information and the current JSX+CSS in the LLM prompt asking the model
to generate an array of operations.

The LLM responds with an array of operations (aiOperations) to fulfill
the user request. We then process these doing the necessary
transformations to convert these to a Webstudio-friendly format
(wsOperations) and send them to the client where we apply them (see
applyOperations).

Some of these operations are going to be "intermediate" operations for
now.

Generating quality user interfaces might be challenging with LLMs.

Having to do so within a generic operations framework like the one
described above makes it even more challenging.

For this reason when it comes to generating user interfaces, the
Operation chain instead offers an operation called
generateTemplatePrompt that provides information about insertion point
in the existing UI and a prompt, possibly enhanced.

Another chain can use these information and a more sophisticated prompt
and model to then generate the user interface and return a
generateInsertTemplate wsOperation. Webstudio does exactly this in a
rest endpoint, using the template-generator chain with gpt4 instead of
gpt-3.5-turbo.
2023-10-06 09:07:59 +02:00
Giuseppe 2ca3907988 feat: JSX utils (#2396)
Adds utils to work with JSX and transform it to Webstudio Embed Template
as well as converting Tailwind styles to Webstudio Embed Template style
declarations and a fake `<HeroIcon>` component to `HtmlEmbed` with
inline SVG taken from heroicons (we will need this for ai).
2023-10-01 12:17:43 +02:00
Bogdan Chadkin 5482ec414a perf: drop internal data from generated sites (#2362)
Internal data structures like instances, props, data sources, assets and
pages no longer necessary in generated sites. Nanostores not longer used
to store them.

Now we have less dependencies and smaller runtime.
2023-09-29 16:22:09 +04:00
Bogdan Chadkin 22a1067ed6 refactor: move props logic to canvas (#2361)
Moved canvas props logic from react-sdk to builder. Added new context to
pass props store, not global because depends on params.
2023-09-25 14:17:40 +04:00
Bogdan Chadkin d25e97fe65 perf: generate pages paths (#2360)
Here generated a list of pages paths. It is used in link component to
switch to remix link internally when the link is app route.

Providing whole pages list can bloat runtime when there are many pages
or when there are many seo data so having single page per route should
be enough.

The list is always empty in builder because links are managed with
global interceptor. Ideally frameworks should uses navigation api and
distinct routes from other paths so we would not need to generate
anything.
2023-09-25 12:20:08 +04:00
Bogdan Chadkin 5f93ecb228 perf: generate page prop for links (#2357)
Moved links resolve into props normalizing which is called for whole
project before rendering converting page prop into string.

Remix links now check only if provided path matches any page. Ideally it
should be handled with navigation api to remove all complexity from
links components.

This will let us stop rendering props and assets data in generated
pages.

Also fixed links with hashes.
2023-09-24 20:07:15 +04:00
Bogdan Chadkin 45585c0565 perf: generate asset prop for links and images (#2356)
Before links and images required logic to traverse raw props data and
assets to resolve href and src. This can potentially affect rendering
performance and requires additional data to be stored in runtime.

Here pregenerated props with "asset" type as a first step. Images still
have to be aware of asset base url to trim it from resolved src but no
longer access to assets store. Links now interpret it as string url.

See fixtures for examples.
2023-09-22 17:48:12 +04:00
Bogdan Chadkin 2dbb1597f0 refactor: remove legacy page renderer (#2352)
- dropped InstanceRoot component
- dropped WebstudioComponent component
- dropped sdk-size-test package
- measure size in fixture package
2023-09-22 10:09:19 +04:00