@plitzi/sdk-shared 0.38.4 → 0.38.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/CHANGELOG.md +342 -0
  2. package/dist/actions/functions.d.ts +10 -0
  3. package/dist/actions/functions.mjs +10 -10
  4. package/dist/actions/index.d.ts +1 -1
  5. package/dist/actions/index.mjs +6 -6
  6. package/dist/helpers/twigWrapper/inspectTemplate.mjs +14 -7
  7. package/dist/helpers/twigWrapper/processTwig/processTwig.d.ts +4 -3
  8. package/dist/helpers/twigWrapper/processTwig/processTwig.mjs +32 -22
  9. package/dist/history/types.d.ts +4 -4
  10. package/dist/index.mjs +38 -37
  11. package/dist/network/graphql/builder/Mutations/Space/data/SpaceSaveDataMutation.d.ts +10 -0
  12. package/dist/network/graphql/builder/Mutations/Space/data/SpaceSaveDataMutation.mjs +4 -0
  13. package/dist/network/graphql/builder/Mutations/index.d.ts +2 -0
  14. package/dist/network/graphql/builder/Mutations/index.mjs +124 -122
  15. package/dist/network/graphql/builder/Queries/InitQuery.d.ts +1 -3
  16. package/dist/network/graphql/builder/Queries/InitQuery.mjs +1 -1
  17. package/dist/network/graphql/builder/Queries/Space/SpaceDataQuery.d.ts +6 -0
  18. package/dist/network/graphql/builder/Queries/Space/SpaceDataQuery.mjs +4 -0
  19. package/dist/network/graphql/builder/Queries/index.d.ts +2 -0
  20. package/dist/network/graphql/builder/Queries/index.mjs +22 -20
  21. package/dist/network/spaceEvents.d.ts +2 -2
  22. package/dist/plugins/bundle.d.ts +26 -0
  23. package/dist/plugins/bundle.mjs +62 -0
  24. package/dist/plugins/declaration.d.ts +12 -0
  25. package/dist/plugins/declaration.mjs +9 -0
  26. package/dist/queries/queryCache.d.ts +7 -0
  27. package/dist/queries/queryCache.mjs +14 -7
  28. package/dist/queries/useQuery.d.ts +2 -0
  29. package/dist/queries/useQuery.mjs +5 -2
  30. package/dist/schema/anchor.d.ts +11 -0
  31. package/dist/schema/anchor.mjs +6 -2
  32. package/dist/schema/index.mjs +6 -6
  33. package/dist/schema/markdownHeadings.d.ts +13 -0
  34. package/dist/schema/markdownHeadings.mjs +24 -0
  35. package/dist/schema/motion.mjs +1 -1
  36. package/dist/schema/pageElements.d.ts +12 -0
  37. package/dist/schema/pageElements.mjs +41 -0
  38. package/dist/server/index.mjs +4 -4
  39. package/dist/server/rsc/projectData.d.ts +6 -0
  40. package/dist/server/rsc/projectData.mjs +4 -0
  41. package/dist/server/rsc/refreshRsc.d.ts +18 -5
  42. package/dist/server/rsc/refreshRsc.mjs +80 -20
  43. package/dist/server/rsc/useRscSync.mjs +26 -15
  44. package/dist/server/usePluginRoute.d.ts +18 -0
  45. package/dist/server/usePluginRoute.mjs +14 -0
  46. package/dist/source/export.d.ts +13 -0
  47. package/dist/store/index.d.ts +45 -45
  48. package/dist/style/cssLayers.d.ts +18 -0
  49. package/dist/style/cssLayers.mjs +14 -0
  50. package/dist/style/index.d.ts +1 -0
  51. package/dist/style/index.mjs +11 -10
  52. package/dist/style/useDisplayMode.d.ts +11 -0
  53. package/dist/style/useDisplayMode.mjs +18 -0
  54. package/dist/types/ActionTypes.d.ts +3 -3
  55. package/dist/types/ComponentTypes.d.ts +13 -0
  56. package/dist/types/DataTypes.d.ts +36 -0
  57. package/dist/types/InteractionTypes.d.ts +16 -2
  58. package/dist/types/SchemaTypes.d.ts +3 -1
  59. package/dist/types/SchemaTypes.mjs +2 -1
  60. package/dist/types/ServerTypes.d.ts +58 -7
  61. package/dist/types/StoreTypes.d.ts +19 -6
  62. package/dist/types/index.d.ts +1 -2
  63. package/package.json +46 -28
  64. package/setupTests.ts +16 -13
  65. package/dist/types/AITypes.d.ts +0 -80
  66. package/dist/types/McpTypes/index.d.ts +0 -56
  67. package/dist/types/McpTypes/index.mjs +0 -0
  68. /package/dist/types/{AITypes.mjs → DataTypes.mjs} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,347 @@
1
1
  # @plitzi/sdk-shared
2
2
 
3
+ ## 0.38.6
4
+
5
+ ### Patch Changes
6
+
7
+ - 3bce653: ## Fixes
8
+
9
+ - **The dev tools draw their icons again.** The panel lives in a shadow root of its own, which the page's stylesheets
10
+ never reach, and Font Awesome moved to a sheet of its own in 0.38.5 (`plitzi-sdk-icons.css`): the badge and every tab
11
+ lost their icons. The panel now links that sheet inside its root, beside its own. Where it is served is the SDK's
12
+ new `sdkIconsStylePath` — the page server sends `/sdk-assets/plitzi-sdk-icons.css`, the same sheet the document
13
+ links — which the `iframe` and `shadow` render modes read too: they had `/plitzi-sdk-icons.css` hard-coded, a path a
14
+ page server does not serve.
15
+
16
+ ## 0.38.5
17
+
18
+ ### Patch Changes
19
+
20
+ - 3bce653: ## Agents work through the MCP: the builder's AI chat is gone
21
+
22
+ An agent reaches a space through the MCP, from whatever harness the person already uses; Plitzi no longer runs one of
23
+ its own inside the builder. **Breaking** for whoever imported what that chat was built on:
24
+
25
+ - **The builder's Assistant panel is removed**, with its conversations, attachments, previews and provider settings.
26
+ - **`@plitzi/sdk-mcp` no longer exports the in-process AI engine**: `AIEngine`, `toolResponseOk`, `toolResponseErr`,
27
+ `zodToJsonSchema`, `getAllowedModes`, `bindTools`, `isToolActive`, `resolveToolHandler`, `isCallToolResult`,
28
+ `toolResponseFromResult` and `buildAgentGuide`. The MCP server, its tools and `@plitzi/sdk-mcp/server` are unchanged;
29
+ the tool functions are still exported to run in-process.
30
+ - **`@plitzi/sdk-shared` drops the chat's types** — `AITypes` (`AiContext`, `AiMode`, `AiMessageAttachment`,
31
+ `AiUsage`, …) and `McpTypes` (`McpTool`, `McpToolHandler`, `McpContent`, …), with their `./types/AITypes` and
32
+ `./types/McpTypes/index` subpaths — and no longer depends on `@modelcontextprotocol/sdk`.
33
+ - **A change's `origin` is never `coworker`**: `ChangeOrigin` is `builder`, `mcp`, `autofix`, `api` or `system`, and
34
+ the History panel's filter follows.
35
+ - **The builder's platform flags are gone**: `PlatformFlags` is no longer part of the builder's first query, nor
36
+ `platformFlags` of its store — `assistanceAI` was the only one.
37
+ - **Plitzi's own deployment no longer offers the `ai.complete` task** to flows.
38
+ - **Each MCP tool says whether it only reads** (`readOnlyHint`, from the tool's `access`), so a host can run a read
39
+ without asking and ask before a write. Until now `access` was read only by the builder's chat.
40
+ - **The MCP works over the JSON adapters.** `createJsonAdapters` offers `getSchema` and `getStyle`, and — for a space
41
+ read from a path — `saveSchema` and `saveStyle`, each writing its document back into the file. **Breaking**:
42
+ `saveOfflineData` is gone from `SSRAdapters`; nothing called it, and it was the JSON adapters' only write, so an MCP
43
+ over them could neither read nor save.
44
+
45
+ ## Lighter pages: icons on their own
46
+ - **Font Awesome is a stylesheet of its own**, `plitzi-sdk-icons.css`, with its fonts as files beside it
47
+ (`webfonts/`) instead of base64 inside `plitzi-sdk.css` — which drops from 287 KB to 103 KB. A page fetches a face
48
+ only when it shows an icon of that style, and a new SDK version no longer downloads the fonts again. The page server
49
+ links it after `plitzi-sdk.css` (`SSRTemplateProps.iconsCssPath`), the SDK's iframe and shadow modes load it beside
50
+ the stylesheet, and the package exports it: **a project that imports `@plitzi/plitzi-sdk/plitzi-sdk.css` imports
51
+ `@plitzi/plitzi-sdk/plitzi-sdk-icons.css` too** — `plitzi upgrade` adds it to `src/main.ts`, and a new project has
52
+ it. The MCP's rendered widgets inline the sheet, fonts and all, only for a widget that draws an icon.
53
+ - **Material Icons is no longer loaded.** Nothing in Plitzi used it; every page paid a request to Google for it.
54
+ - **A page loads only the plugins it draws.** The page server sends the rest as their declaration
55
+ (`PluginEntry.deferred`, `pluginDeclarationOf` in `@plitzi/sdk-shared/plugins/declaration`); the SDK registers each
56
+ as a stand-in that knows its types from the start, and loads its code and stylesheet the first time one of its
57
+ elements is drawn — on a page reached by navigating too, with no server involved. What a page draws is
58
+ `pageElementTypes` (`@plitzi/sdk-shared/schema/pageElements`): the page, its layouts, the components and references
59
+ it holds. `render()` takes a plugin as `{ load, css, declaration }` beside `{ component }`.
60
+ - **The space travels beside the page, not inside it.** The page names it (`<link id="plitzi-space">`,
61
+ `SSRTemplateProps.spaceDocumentPath`), the browser fetches it while the scripts load, and the page server answers
62
+ `/_plitzi/space/<hash>.json` behind the same gates as its pages — `immutable`, since the name is its content's hash:
63
+ one download for every page and every visit until the space changes. The website's docs page went from 2.6 MB to
64
+ 0.5 MB. Still the whole space, so every navigation after the first page stays in the browser. A draft preview and a
65
+ deployment's own `templateFn` keep it inline.
66
+ - **An arrival on screen plays as the page arrives.** A `motion: { on: 'view' }` element already in view was held
67
+ invisible until the SDK hydrated — the page's content, and a page rendered `ssrOnly` forever. The page server's
68
+ document now sees it as soon as it is parsed, and hands over to the SDK once the page is live.
69
+
70
+ ## Server data: one request per question, the newest winning, and a way to stop
71
+ - **A link asks for its page's server data once.** The navigation's prefetch already brought it; the route change that
72
+ followed asked again — two renders per click. `useRscSync` now asks only for a location the store does not hold.
73
+ - **Answers land in the order they were asked.** `refreshRsc` joins a refresh already in flight for the same URL and
74
+ aborts one a newer refresh would overwrite (a whole payload asked again, an element asked again); a whole payload
75
+ keeps what an element asked for after it. A slow answer no longer paints a page the visitor has left.
76
+ - **Stopping.** `cancelRsc(store, ids)`, an `apiContainer`'s `cancelQuery` callback (`cancelApi(id)` in authoring) and
77
+ `queryCache.cancel(key)` for a browser provider: the request is dropped and what is shown stays. The server hears it:
78
+ `SSRRscContext.signal` aborts when the browser hangs up, and the default `getRscData` stops every element still
79
+ resolving — a shared render run only once nobody is waiting on it.
80
+ - **Pending.** A server provider's `isLoading` is true while it is asked again (`rsc.refreshing`). The `navigation`
81
+ source says `pending` and `pendingLocation` while a link waits for its destination's data; a second link clicked
82
+ before the first went supersedes it, and the first never goes.
83
+ - **A bound `input` asks again.** An `apiContainer`'s `input` is a prop now: bound to state, every change refetches a
84
+ server provider. What a refresh asks for (`req.ctx.rscParams`) wins over the `input` the element was saved with.
85
+ - **A section cut by its budget says how to give it more** (`rsc.elementTimeoutMs`).
86
+
87
+ ## Flows
88
+ - **`whileRunning('latest')`**: a new firing stops the run in progress — no further step; its `runServerAction` is
89
+ cancelled (request and server run) and its `webHook` aborted — and runs. A search as you type. The step's context
90
+ carries the `signal`. Offered in the builder and the MCP.
91
+ - `onApiSuccess` / `onApiError` fire once per answer: a cancelled request or a loading flag that came and went no
92
+ longer runs the flow again.
93
+ - **A debounce is `whileRunning('latest')` and a `delay` first**: `delayTime` ends its wait the moment its run is
94
+ superseded, so only the last firing gets past it. Its `time` is a number.
95
+
96
+ ## Server actions
97
+ - **The request budget is never silent.** A task that caught the refused fetch hid `maxRequests`; the step that ran
98
+ into it now logs it, and the server logs it once, naming `createServer({ action: { limits: { maxRequests } } })`.
99
+ - **`invalid_input` says what the value was and which type takes it** — `windows (text, got a list; declare the field
100
+ \`json\` to take it)`. The templates reference documents that a param that is only `|json_encode` is the value it
101
+ encodes.
102
+ - **`kv` survives a restart with no database.** `createFileKv({ file })` (`@plitzi/sdk-server/actions`) keeps the
103
+ in-process store in one JSON file, written whole as soon as anything changes — for one process.
104
+ `createSqliteKv({ file } | { db })` (`@plitzi/sdk-server/sqlite`, new entry) is a table in a SQLite file over
105
+ `node:sqlite`, every operation one statement, shared safely by every process on the file. Both pass the adapter
106
+ contract every store is held to. The `09-schedules` example uses it rather than its own copy, whose counters read
107
+ `22.0`.
108
+
109
+ ## Authoring
110
+ - **What a space declares and never uses** is suggested now: `unused-class`, `unused-token`, `unused-component`, and
111
+ `literal-colour` — a class painted from the palette typing out a scheme token's light value. A suggestion about
112
+ declarations names them in `subjects`, so the MCP says one a batch left unused beside the ones the space had.
113
+ `unusedDeclarations(schema, style)` is the rule itself, for anything else that says "unused" (the builder does).
114
+ - **`pageFamily(shape, entries)`** writes pages of one shape from data: each page its id, slug, titles, folder and
115
+ layout, and its body built inside `scope(entry.id, …)` so two pages never give one id.
116
+ - **`action-output-path`** (warned): `.data` read on a provider fed by a server action, which publishes its output at
117
+ the root. **`actionSource(id, sample)`** types such a provider by a sample of its output.
118
+ - A value template (`returns: 'value'`, a computed, a step param) may name its parts with `{% set %}` before its one
119
+ expression, and is still that expression's value.
120
+ - `abs()`, `floor()`, `ceil()`, `clamp()` are refused with how they are written here (`x|abs`,
121
+ `x|round(0, 'floor')`, `min(max(x, low), high)`).
122
+ - An unknown attribute is reported against the element's props, not as "'id' does not exist in type ElementSpec[]".
123
+ - `explain` answers a builder's name (`reloadApi`, `cancelApi`) with its step, and knows `whileRunning`.
124
+ - A component's instance takes `quiet`, like any element — `component(id, { quiet: ['repeated-shape'] })`: instances
125
+ whose slots are filled alike on purpose stop being offered as a repeat, and an exported instance that carries one
126
+ typechecks.
127
+ - `container` and `text` take a `title`. A trigger's `preview` may hold numbers, flags, lists and `null`.
128
+ - **A Markdown element's headings are sections a link can name.** Each renders with the anchor its words read as
129
+ (`## Server data` → `#server-data`, numbered when repeated), and a link's `hash` may name one: `anchor-missing` counts
130
+ them, so a table of contents built from the Markdown is checked like any other link.
131
+ - `answerAction(page, actionId, output)` (testing): a test that would save something answers that server action in
132
+ the browser — the server's `kv`, and what the developer kept, are never written. A stream step gets its `done` frame.
133
+
134
+ ## Plugins
135
+ - **A plugin's stylesheet sits below the space's.** The cascade order is now `… utilities, plitzi-sdk-plugin,
136
+ plitzi-sdk-runtime`, and whatever builds a plugin writes its CSS into `plitzi-sdk-plugin` (`inPluginLayer` from
137
+ `@plitzi/sdk-shared/style`): `plitzi pack plugin`, a server compiling one (`action: 'compile'`), and the stylesheet a
138
+ server copies or downloads for one. A space's classes and `customCss` now win over what the plugin's author shipped,
139
+ whatever the specificity — as they do over a built-in element. A plugin packed before this ships unlayered and still
140
+ wins until it is packed again.
141
+ - **Declared param types reach the callback.** A param declared `number` (new, a text box in the builder) or `boolean`
142
+ is handed over as one — written `5000`, or bound to text that says it; an empty number as nothing, so the component's
143
+ default applies.
144
+ - **`useElementVisible(id)`** (`@plitzi/plitzi-sdk`): whether another element is on the page — its own `visible`, every
145
+ container around it, the breakpoint — kept current while the plugin is mounted, at that plugin's cost alone.
146
+ - **A page open on a development server loads again when the server restarts** (`devReload`): `start:dev` restarting
147
+ on a change to the server's code reached the open page only when somebody reloaded it.
148
+ - **A saved plugin is swapped into the open page** (`devReload`, server mode): the page server rebuilds the plugin
149
+ whose source changed and the page renders the new component in place, keeping its state — no restart, no reload. A
150
+ change to its declaration (what the builder and the linter know of it) still reloads the page. `render()` takes
151
+ `{ hotPlugins: true }` and answers `{ unmount, replacePlugin }`; `PluginManager.rebuild(name)` and `onSources`. A new
152
+ folder in `src/plugins` is registered without a restart (`server.plugins.register`), from `create` and `create --from` alike.
153
+ - **A plugin brings its own server half.** `functions/index.ts` beside the component — the `defineFunctions` a
154
+ space's functions use — answers routes under `/fn/plugins/<type>/` and runs steps named `<type>.<action>` (origin
155
+ `'plugin'`, the builder's **Plugins** group). It runs with a narrower `ctx`: its own `kv` (prefixed
156
+ `plugin:<type>:`, its `rateLimit` and `sign` too), none of the space's credentials, no realtime publishing or grants;
157
+ its routes and tasks outside its namespace are refused, as are a space's routes under `/fn/plugins/`. The component
158
+ reaches its routes with `usePluginRoute(type)` (`@plitzi/plitzi-sdk`; `undefined` where no server runs code).
159
+ A page server takes them as `functions.plugins` (`{ [type]: FunctionsDefinition }`), swaps one with
160
+ `server.functions.setPlugin`, and asks a cloud adapter with `actionLookups.getPluginFunctions(spaceId, version)`.
161
+ `plitzi pack plugin` carries the source in the zip as `functions.source.json` (`PLUGIN_FUNCTIONS_SOURCE`, named by
162
+ the manifest's `functions`; `loadFunctionsSource` builds it) — kept privately by the platform, never published.
163
+ - **A plugin lays out the space's elements it holds.** `elementChildren(children)` (`@plitzi/plitzi-sdk`) hands
164
+ over each child element with the id it was authored under, for a dock, tabs or a masonry to place in boxes of its
165
+ own — instead of writing styles onto elements it does not render.
166
+ - **`useDisplayMode()`** (`@plitzi/plitzi-sdk`): `desktop`, `tablet` or `mobile`, at the widths the space's styles are
167
+ compiled at — not a breakpoint of the plugin's own.
168
+ - **A file a library needs whole travels inside the bundle**, imported as Vite imports it: `worker.js?raw` (its text — a
169
+ worker from a Blob), `engine.wasm?inline` (a base64 data URI). `plitzi pack` and a server compiling a plugin share
170
+ one build (`@plitzi/sdk-shared/plugins/bundle`), so a server now inlines `.avif`, `.ttf` and `.otf` as `pack` did.
171
+
172
+ ## CLI and page checks
173
+ - **`plitzi lint`** reads a local space's source the way eslint reads code, for what the document cannot show:
174
+ `file-too-long`, `pages-in-one-file`, `inline-records` (rows of data written in code → `src/data/`), `repeated-css`,
175
+ `special-case-in-map`, `colour-not-token`, `positional-id`, `unused-file` — each at file:line with what to write
176
+ instead — and authoring's suggestions at the line that wrote them. `--json`, `--strict`, `--max-warnings <n>`;
177
+ `// plitzi-lint-disable-next-line <code> -- why` for a departure on purpose. Projects get `npm run lint:space`
178
+ (`upgrade` adds it to older ones). `doctor` stays the project's and never reads the space.
179
+ - **`--template blank`** starts with only the colours its page uses: a token declared and read by nothing is one
180
+ authoring now points out.
181
+ - **The welcome space is written as a folder**, not one 800-line file: `src/space/index.ts` (the page), `tokens.ts`,
182
+ `theme.ts`, `content.ts` — the shape a space keeps as it grows, and clean under `plitzi lint`. **Breaking** for
183
+ whoever called it: `blankSpaceSource()` is now `blankTemplateFiles({ name, dir, plugin })`, which returns the files by
184
+ path; `toPortableSource` keeps imports of the files beside it. A plugin package's preview space is
185
+ `preview/space/index.ts`.
186
+ - **`check`, `shot` and the generated visual tests settle instead of waiting for `networkidle`**, which never came on a
187
+ page with a realtime channel: `openPage` (`@plitzi/sdk-authoring`) waits for load, then quiet, counting no stream
188
+ that stays open.
189
+ - **The server is the project's in `src/config/serverOptions.ts`; `src/main.ts` stays the CLI's.** `create` writes
190
+ `src/config/serverOptions.ts` (handed to `createServer`, typed from `ServerConfig`, now exported by
191
+ `@plitzi/sdk-server`) and, with `--source local`, `src/actions/index.ts` (the space’s server actions), which `main.ts` wires
192
+ for calls, renders and schedules. What `main.ts` wires itself (the space's adapters, the plugins, `public/`,
193
+ `src/data/`, `src/functions/`, the actions' lookups) is left out of `serverOptions`' type and comes after it, so no option unwires it.
194
+ `upgrade` writes either file into a project that has none — only when the `main.ts` reading it is the CLI's — and
195
+ never replaces it; `create --from` projects read `serverOptions.ts` too.
196
+ - **`upgrade packages` brings up the scripts the CLI wrote and nobody changed** (`.plitzi/scaffold.json` now records
197
+ them); a script the project changed is left and said, as before.
198
+ - `start:dev` restarts on a change to the server's code — `src/main.ts`, `src/config/`, `src/actions/` and
199
+ `src/functions/` (there from the start, kept by a `.gitkeep`); a plugin is swapped in the open page instead, and its
200
+ `functions/` set again, without a restart. A function imports its siblings with `.ts`, as `src/`.
201
+ - `add plugin --server` writes the plugin's server half (`functions/index.ts`, a `GET`/`POST /state` example on its
202
+ `kv`); a package gets `@plitzi/sdk-server` as a devDependency for its types. Refused in a client-mode project.
203
+ - `add plugin`: `--prop rows:list` and `--prop meta:json` for data a binding fills; `--headless` writes
204
+ `drawsNothing: true`; the generated events hook never fires on the builder's canvas.
205
+ - A `channel` with no tag is boxless to a page check, like a provider; an empty list is said to have no rows, with what
206
+ to do, instead of "no size (0×0)".
207
+ - **A server-mode project keeps its `kv` in `state/kv.json`** (`createFileKv`; ignored by git): what the space's actions
208
+ save outlives a restart, `start:dev`'s included. `action.kv` in `src/config/serverOptions.ts` names another store.
209
+ - A server-mode project types what its plugins import besides code (`plitzi/assets.d.ts`): a stylesheet, an image,
210
+ `?raw`, `?inline` — a client-mode one has them from `vite/client`.
211
+ - **A project made from a space runs the server `create` writes.** It has the same `src/main.ts` as any project: it
212
+ now takes a free port and writes `tmp/dev-server.json` (which `check`, `shot` and the visual tests read), answers
213
+ `/health`, and re-authors its pages on save instead of waiting for a restart. Its actions are `src/actions/` and its
214
+ connectors `src/connectors/`, both there from the start, and `start:dev` restarts on them; `src/actions/index.ts`
215
+ exports `actions` and `connectors`, as a `create` project's does (`push` reads that). Before, `upgrade` showed its
216
+ `main.ts` as the project's own, and `--take all` would have put `create`'s server in place of the space's.
217
+ - **A `--source cloud` server project starts.** Its key is in `.env`, which nothing read: `npm start` stopped on "Set
218
+ PLITZI_HOST_KEY". Every server project's `src/main.ts` now reads `.env` itself (`process.loadEnvFile`), and every
219
+ one is given a signing key there (`PLITZI_SIGNING_SECRET`, made for it by `create`) — `ctx.sign` refused in a project
220
+ `create` wrote, a plugin's server half included. `PORT` is no longer written into `.env`, where it pinned 8080. A
221
+ cloud project keeps its `kv` in `state/kv.json` too.
222
+ - **`upgrade` keeps the package manager a project was written for** (`.plitzi/scaffold.json`) when it has no lockfile
223
+ of its own yet: a yarn or pnpm project not installed (`--no-install`), or sitting in a monorepo folder, was taken for
224
+ npm and its `AGENTS.md`, Playwright config and `.gitignore` replaced with npm's commands.
225
+ - `author`, `check`, `fix` and `push` know the element types of a project's built-only plugins
226
+ (`vendor/plugins/*/plugin-manifest.json`, every element each provides), as its server does.
227
+ - **`import` reaches Plitzi only when told to.** A site not served from this machine needs `--account` — ask the
228
+ person's Plitzi account whether one of their spaces verified its domain, signing in — and without it is refused,
229
+ saying so, before any request: an agent running `import` in a local project opened a sign-in nobody asked for. The
230
+ CLI skill and the generated `AGENTS.md` say to run `import` only when the user asks, and to ask before `--account`.
231
+ - **A server project's data is no longer on the internet.** It was `public/data/*.json`, served to anyone as a file;
232
+ it is `src/data/*.json`, which the server reads and never serves (`dataDir`, new in `createServer`): a provider with
233
+ `runtime: 'server'` and `query: '/data/<file>'` reads it, and the page arrives with it. `projectData`
234
+ (`@plitzi/sdk-authoring/node`) and `authorSpace`'s `serverData` hold bindings to those files, and a provider asking
235
+ for `/data/…` from the browser is refused (`server-data-in-browser`): nothing would answer it. What a provider reads
236
+ is still in the page it renders — data a page must not carry is a server action's to read. A client-mode project
237
+ keeps `public/data/`, which the browser has to fetch. The catalog template follows the mode
238
+ (`catalogTemplateFiles({ mode })`). `public/` holds only what is meant for everyone.
239
+ - **The project's own server code is `src/functions/`**, with the rest of its source — typechecked with it, left out of
240
+ `tsconfig.build.json` (the server builds it at boot). `functions pull`/`push`/`dev`, `push`, `pull` and `create
241
+ --from` follow. The `kv` folder is `state/` (it was `data/`, beside a data folder that was something else).
242
+ - **What is the CLI's is in `plitzi/`, apart from `src/`.** `plitzi/author.ts`, `plitzi/assets.d.ts` (server mode) or
243
+ `plitzi/preflight.css` (client mode), and `plitzi/README.md` — which says what each folder of `src/` is, instead of a
244
+ README in every one. `src/main.ts` stays where an entry point is looked for, the CLI's all the same.
245
+ `src/plugins/declarations.ts` is gone: a plugin is declared by its folder's `declaration.ts`, found by the server,
246
+ `author`, `check`, `fix`, `push` and the visual test alike (`pluginDeclarations` from `@plitzi/sdk-authoring/node`;
247
+ Vite's `import.meta.glob` in client mode).
248
+ - `functions.plugins` is in `SSRServerConfig`'s type and checked as the server starts: a project passing its plugins'
249
+ server halves did not typecheck.
250
+ - **A project's source is folders that grow.** The space is `src/space/` — its `index.ts` exports it as `space` and
251
+ assembles the rest (the catalog template's `src/site/` is `src/space/` now; `create --from` writes the space's own
252
+ `index.ts` there, exported as `space` too). The server actions are `src/actions/` — `index.ts` lists them, one action
253
+ a file, as `create --from` already had them — and what the server does besides serving the space is
254
+ `src/config/serverOptions.ts`. `start:dev` watches `src/config` and `src/actions` whole.
255
+ - **One server for every project, kept by `upgrade`.** `src/main.ts` runs what a project holds from where it lands — a
256
+ runtime in `src/runtime/` (or built only, `vendor/runtime.bundle`), plugins built only (`vendor/plugins/`), the
257
+ actions' connectors — so `create --from` writes no `main.ts` or `.prettierignore` of its own any more, and `upgrade`
258
+ keeps both current in projects made from a space too. `loadRuntimeModule` (`@plitzi/sdk-server/runtime`): a project's
259
+ runtime module, or nothing when it has none.
260
+ - **`plitzi add runtime`** writes `src/runtime/index.ts` — run by the project's server (`npm start` answers its
261
+ endpoints) and sent by `plitzi runtime push`, whose default entry it is now — and has `start:dev` restart on it. A
262
+ space taken out with a runtime gets `src/runtime/index.ts` handing over the module its source starts at.
263
+ - **`push` sends the space's files back as their CDN addresses.** `create --from` and `pull` write each CDN address as
264
+ the project's path (`/assets/a.png`, served from `public/assets/`); `push` sent those paths as they were, and the
265
+ space's pictures and data pointed at nothing on Plitzi. It also says, before sending, what Plitzi would not have: a
266
+ provider reading a file `src/data/` does not hold, and a file the space names that is not on its CDN.
267
+ - **`push` sends a project's data and its files.** Two new parts: `data` — `src/data/` whole, kept by Plitzi as the
268
+ space's own data (private, frozen with each publish, read by the page server of the version it renders; refused when
269
+ the space's copy changed since the project last had it, unless `--force`) — and `files` — each changed file of
270
+ `public/assets/`, put at the same path under the space's `assets/` on its CDN, so a pull brings it back where it was.
271
+ `create --from` and `pull` write the space's data into `src/data/`. `getData` joins the action lookups
272
+ (`ActionLookupsConfig`), and the page server resolves `/data/<file>` through it when there is no `dataDir`.
273
+ - **A space's data is edited in the builder and by agents.** The builder's Server view has a **Data** tab: the JSON
274
+ files the space's server providers read (`/data/<file>`), a file list and a JSON editor, saved whole against the
275
+ copy it read (⌘S; a newer copy is refused, a broken file named). The MCP reads it as `plitzi://data/{env}` and writes
276
+ it with `upsertDataFile` / `deleteDataFile` (`getData` / `saveData` among the adapters; a file that is not JSON is
277
+ refused as it is written), and the guide has a Data section. One write path for the builder, agents and `plitzi push`
278
+ (`SpaceData` / `SpaceSaveData` over GraphQL, under `spaceManage`), one history. `DataDraft` / `DataSaveResult` are
279
+ in `@plitzi/sdk-shared`. The builder's file list is shared by Functions and Data (`modules/FileTree`).
280
+ - **`plitzi doctor`**: whether the project the CLI set up is whole, checked against what it is now — a developer may
281
+ change any file. Packages (declared, installed at versions that agree, one copy of the SDK and of React), the CLI's
282
+ files and scripts (as `upgrade` sees them, one planner for both), the file each Node script starts and every folder
283
+ `start:dev` watches, the TypeScript configs, `.gitignore` and `.env` (never in git; the signing secret as long as the
284
+ project's server wants it), the code Node runs as written (relative imports with their extension, JSON with its
285
+ attribute, no JSX, every package declared — walked with esbuild), each plugin folder against its declaration, the data
286
+ files, `src/functions/` built by the project's own sdk-server, `.plitzi/` and the skills. Each finding has an area, a
287
+ code, the file and its fix; `--json`, `--strict`; exit 1 on an error. It never checks the space — `npm run author`
288
+ and `check` do — and every report says so. A layout an older CLI left (`src/space.ts`, `src/author.ts`,
289
+ `functions/` at the root…) is its own area, checked first and alone. `--fix` repairs what is simple and safe —
290
+ that layout moved with every import, URL and script following (and the scaffold record with it), dead files,
291
+ `.gitignore`, `"type": "module"`, a watched folder, a signing secret — then checks again; `--dry-run` says what.
292
+ Each report ends with what to run next. `upgrade` writes no file over an older layout, and says `doctor --fix`.
293
+ `buildFunctions` and `FunctionsBuildError` are exported from
294
+ `@plitzi/sdk-server/functions-runner`, `MIN_SIGNING_SECRET_LENGTH` from `@plitzi/sdk-server/actions`.
295
+ - **`--dry-run`** on every command that writes or sends — `create`, `add plugin`, `add runtime`, `pull`, `push`,
296
+ `pack plugin`, `source`, `import`, `upload plugin`, `functions pull`/`push`, `runtime push`/`start`/`stop`/`size`/
297
+ `vars`, `skills update`, `doctor --fix`: each file it would write (`+` new, `~` replaced, `-` removed), what it would install or run, what it would
298
+ send and where, and none of it done. It still reads what it needs to say so.
299
+ - **A new project is formatted from the start**, every template and mode: its first `format` changes nothing. The CLI's
300
+ own files are in its `.prettierignore`, so formatting never turns one into a file `upgrade` believes was changed.
301
+
302
+ ## Builder
303
+ - **The pages panel keeps its folders as you left them** — open or closed, per space, across reloads — the way the
304
+ style inspector keeps its sections. A folder starts closed.
305
+ - **Usages**, a panel beside Layers: where each component, class, token, space variable and data source is used,
306
+ page by page — what reads it and which elements — and which nothing uses, by authoring's own rule. A click selects
307
+ the element, inside a component too.
308
+ - **Revealing an element inside a component opens the component** (the Usages panel, ⌘P, the issues and the history all
309
+ reveal through it); before, the selection was dropped. **Panels stay open** when a component opens or closes.
310
+ - **The canvas dims a page's layout around its body again when the layout or its slot draws no box**
311
+ (`display: contents`, which the efficiency guide recommends): the hole was measured as a rect of zeros and the whole
312
+ page was dimmed. A box-less element is measured by what it holds, and the mask by the box that positions it.
313
+ - **Elements is one category at a time.** A row of chips — each category with its count, and the space's components as
314
+ one more — picks what the panel shows, remembered between sessions, so the panel stays the same height however many
315
+ elements plugins add. A search looks through every category and the components at once. Each element is a tile: its
316
+ icon, its whole name, and what it is on hover. Container, Button, Form, Form Control, Dropdown Popup, List Item, Rich
317
+ Text, Dialog Container and Tab Container Item have icons of their own (`sdk-elements`), none shared with another
318
+ element or with the component and snippet icons.
319
+ - **Layers reads as a tree and is driven from the keyboard.** A guide per depth, a chevron that turns, the component's
320
+ name beside an element that is one, and the selected row kept in view. ↑/↓, Home/End, → to open or go in, ← to close
321
+ or go up. A row under a closed ancestor is no longer shown. (plitzi-ui's `Tree`.)
322
+ - **Motion and preview no longer share an icon.** Playing the page's motion is a wand, which pulses while it plays;
323
+ preview is an eye, and a pen to go back to editing.
324
+ - **A component's settings fit their modal, however many props it has.** The modal is wider; the name and folder
325
+ share a line, and each prop is one compact row — its name, its kind, required, remove — with what a binding writes to
326
+ read it (`{{ props.<name> }}`) or what is wrong with it, and what it is for, beneath. The fields scroll and the buttons
327
+ stay in view. Props and slots are titled sections, and a slot shows its id.
328
+
329
+ ## Packages
330
+ - **`GET /auth/continue` takes `?fallback=`**: where to go when `redirect` is refused, vetted by the same check. A sign-in
331
+ screen's way back sends its site there, so leaving without signing in never lands on "you are signed in".
332
+ - **Markdown renders headings you can link to and code you can copy.** A heading carries its anchor and a `#` link to
333
+ itself; a fenced block a header with its language and a **Copy** button. The anchor is `@plitzi/sdk-shared`'s:
334
+ `anchorOf`, `uniqueAnchor` and `markdownHeadings` (`schema/anchor`, `schema/markdownHeadings`) — what the element
335
+ renders, what authoring checks a link against and what a table of contents is built from are one function. Needs
336
+ `@plitzi/plitzi-ui` 1.6.31 (its `Markdown` takes `headingAnchor`).
337
+ - **Every package declares what it imports, and nothing more.** `react` is a peer of `sdk-auth`, `sdk-event-bridge`,
338
+ `sdk-interactions`, `sdk-style` and `sdk-variables`; `sdk-schema` depends on `immer`, `sdk-elements` on
339
+ `@dr.pogodin/react-helmet`, `sdk-plugins` on `@plitzi/plitzi-ui`, `sdk-style` on `@plitzi/sdk-event-bridge` and
340
+ `sdk-dev-tools` on `@plitzi/sdk-plugins` — each worked only because `@plitzi/plitzi-sdk` brought them, and failed
341
+ installed alone or under a strict linker. `prop-types` and the `@plitzi/*` dependencies nothing imported are gone:
342
+ `sdk-mcp` no longer declares `@plitzi/sdk-elements`, which its code does not import — it still arrives through
343
+ `@plitzi/plitzi-sdk`.
344
+
3
345
  ## 0.38.4
4
346
 
5
347
  ### Patch Changes
@@ -4,6 +4,16 @@
4
4
  * are its own to name, and `api` is a slug a site wants for a page about its API.
5
5
  */
6
6
  export declare const FUNCTION_ROUTES_PREFIX = "/fn";
7
+ /** The segment under `/fn` where plugins answer — `/fn/plugins/<type>/…` — and nobody else's routes may. */
8
+ export declare const PLUGIN_ROUTES_SEGMENT = "plugins";
9
+ /**
10
+ * A plugin's server half as its package carries it: the source of its \`functions/\`, by path, in this file beside the
11
+ * bundle (\`plugin-manifest.json\` names it under \`functions\`). Built by whatever runs the plugin — the platform when it
12
+ * is uploaded, a server of one's own when it loads the packed plugin.
13
+ */
14
+ export declare const PLUGIN_FUNCTIONS_SOURCE = "functions.source.json";
15
+ /** Where a plugin's route answers: `pluginRoutePath('board', '/layout')` is `/fn/plugins/board/layout`. */
16
+ export declare const pluginRoutePath: (plugin: string, path?: string) => string;
7
17
  /**
8
18
  * The CPU and time an invocation gets when its task asks for none: what the server runs it with, and what the builder
9
19
  * shows as "default". A task asks for more in its `limits`, up to what its deployment allows.
@@ -1,21 +1,21 @@
1
1
  //#region src/actions/functions.ts
2
- var e = "/fn", t = {
2
+ var e = "/fn", t = "plugins", n = "functions.source.json", r = (e, n = "/") => `/fn/${t}/${encodeURIComponent(e)}${n.startsWith("/") ? n : `/${n}`}`, i = {
3
3
  cpuMs: 100,
4
4
  wallMs: 1e4
5
- }, n = (e) => e === "/fn" || e.startsWith("/fn/"), r = (e) => /^[A-Za-z0-9_][A-Za-z0-9_./-]*\.(ts|js|mjs|json)$/.test(e) && !e.split("/").some((e) => e === ".." || e === "." || e === ""), i = async (e, t) => {
6
- let n = {}, i = async (a) => {
7
- let o;
5
+ }, a = (e) => e === "/fn" || e.startsWith("/fn/"), o = (e) => /^[A-Za-z0-9_][A-Za-z0-9_./-]*\.(ts|js|mjs|json)$/.test(e) && !e.split("/").some((e) => e === ".." || e === "." || e === ""), s = async (e, t) => {
6
+ let n = {}, r = async (i) => {
7
+ let a;
8
8
  try {
9
- o = await t.list(a ? `${e}/${a}` : e);
9
+ a = await t.list(i ? `${e}/${i}` : e);
10
10
  } catch {
11
11
  return;
12
12
  }
13
- for (let s of o) {
14
- let o = a ? `${a}/${s.name}` : s.name;
15
- s.directory ? s.name !== "node_modules" && !s.name.startsWith(".") && await i(o) : r(o) && (n[o] = await t.read(`${e}/${o}`));
13
+ for (let s of a) {
14
+ let a = i ? `${i}/${s.name}` : s.name;
15
+ s.directory ? s.name !== "node_modules" && !s.name.startsWith(".") && await r(a) : o(a) && (n[a] = await t.read(`${e}/${a}`));
16
16
  }
17
17
  };
18
- return await i(""), n;
18
+ return await r(""), n;
19
19
  };
20
20
  //#endregion
21
- export { t as DEFAULT_FUNCTION_TIME_LIMITS, e as FUNCTION_ROUTES_PREFIX, n as isFunctionRoutePath, r as isFunctionsSourcePath, i as readFunctionsSource };
21
+ export { i as DEFAULT_FUNCTION_TIME_LIMITS, e as FUNCTION_ROUTES_PREFIX, n as PLUGIN_FUNCTIONS_SOURCE, t as PLUGIN_ROUTES_SEGMENT, a as isFunctionRoutePath, o as isFunctionsSourcePath, r as pluginRoutePath, s as readFunctionsSource };
@@ -1,7 +1,7 @@
1
1
  export { accessRefusal } from './access';
2
2
  export { cronFiresBetween, cronMatches, cronNextFire, isKnownTimeZone, parseCron, zonedClock } from './cron';
3
3
  export { FAILURE_HANDLER_TASK } from './failureHandler';
4
- export { DEFAULT_FUNCTION_TIME_LIMITS, FUNCTION_ROUTES_PREFIX, isFunctionRoutePath, isFunctionsSourcePath, readFunctionsSource } from './functions';
4
+ export { DEFAULT_FUNCTION_TIME_LIMITS, FUNCTION_ROUTES_PREFIX, isFunctionRoutePath, isFunctionsSourcePath, PLUGIN_FUNCTIONS_SOURCE, PLUGIN_ROUTES_SEGMENT, pluginRoutePath, readFunctionsSource } from './functions';
5
5
  export { triggerAccess, triggerCacheMs, triggerHasStaleVerify, triggerInput, triggerVerify } from './triggerParams';
6
6
  export { actionName, actionTriggers, isActionEnabled } from './triggers';
7
7
  export { isActionDocument, validateActionDocument } from './validateDocument';
@@ -1,9 +1,9 @@
1
1
  import { accessRefusal as e } from "./access.mjs";
2
2
  import { cronFiresBetween as t, cronMatches as n, cronNextFire as r, isKnownTimeZone as i, parseCron as a, zonedClock as o } from "./cron.mjs";
3
3
  import { FAILURE_HANDLER_TASK as s } from "./failureHandler.mjs";
4
- import { DEFAULT_FUNCTION_TIME_LIMITS as c, FUNCTION_ROUTES_PREFIX as l, isFunctionRoutePath as u, isFunctionsSourcePath as d, readFunctionsSource as f } from "./functions.mjs";
5
- import { triggerAccess as p, triggerCacheMs as m, triggerHasStaleVerify as h, triggerInput as g, triggerVerify as _ } from "./triggerParams.mjs";
6
- import { actionName as v, actionTriggers as y, isActionEnabled as b } from "./triggers.mjs";
7
- import { isActionDocument as x, validateActionDocument as S } from "./validateDocument.mjs";
8
- import { SMTP_CREDENTIAL_KEYS as C, isSingleEmailAddress as w, readSmtpCredential as T } from "./smtp.mjs";
9
- export { c as DEFAULT_FUNCTION_TIME_LIMITS, s as FAILURE_HANDLER_TASK, l as FUNCTION_ROUTES_PREFIX, C as SMTP_CREDENTIAL_KEYS, e as accessRefusal, v as actionName, y as actionTriggers, t as cronFiresBetween, n as cronMatches, r as cronNextFire, x as isActionDocument, b as isActionEnabled, u as isFunctionRoutePath, d as isFunctionsSourcePath, i as isKnownTimeZone, w as isSingleEmailAddress, a as parseCron, f as readFunctionsSource, T as readSmtpCredential, p as triggerAccess, m as triggerCacheMs, h as triggerHasStaleVerify, g as triggerInput, _ as triggerVerify, S as validateActionDocument, o as zonedClock };
4
+ import { DEFAULT_FUNCTION_TIME_LIMITS as c, FUNCTION_ROUTES_PREFIX as l, PLUGIN_FUNCTIONS_SOURCE as u, PLUGIN_ROUTES_SEGMENT as d, isFunctionRoutePath as f, isFunctionsSourcePath as p, pluginRoutePath as m, readFunctionsSource as h } from "./functions.mjs";
5
+ import { triggerAccess as g, triggerCacheMs as _, triggerHasStaleVerify as v, triggerInput as y, triggerVerify as b } from "./triggerParams.mjs";
6
+ import { actionName as x, actionTriggers as S, isActionEnabled as C } from "./triggers.mjs";
7
+ import { isActionDocument as w, validateActionDocument as T } from "./validateDocument.mjs";
8
+ import { SMTP_CREDENTIAL_KEYS as E, isSingleEmailAddress as D, readSmtpCredential as O } from "./smtp.mjs";
9
+ export { c as DEFAULT_FUNCTION_TIME_LIMITS, s as FAILURE_HANDLER_TASK, l as FUNCTION_ROUTES_PREFIX, u as PLUGIN_FUNCTIONS_SOURCE, d as PLUGIN_ROUTES_SEGMENT, E as SMTP_CREDENTIAL_KEYS, e as accessRefusal, x as actionName, S as actionTriggers, t as cronFiresBetween, n as cronMatches, r as cronNextFire, w as isActionDocument, C as isActionEnabled, f as isFunctionRoutePath, p as isFunctionsSourcePath, i as isKnownTimeZone, D as isSingleEmailAddress, a as parseCron, m as pluginRoutePath, h as readFunctionsSource, O as readSmtpCredential, g as triggerAccess, _ as triggerCacheMs, v as triggerHasStaleVerify, y as triggerInput, b as triggerVerify, T as validateActionDocument, o as zonedClock };
@@ -7,7 +7,14 @@ var r = /* @__PURE__ */ new Set([
7
7
  "max",
8
8
  "min",
9
9
  "range"
10
- ]), i = "loop", a = class {
10
+ ]), i = (e) => `value|round(0, '${e}')`, a = {
11
+ floor: i("floor"),
12
+ ceil: i("ceil"),
13
+ clamp: "min(max(value, low), high)"
14
+ }, o = (t) => {
15
+ let n = Object.hasOwn(e, t) ? `value|${t}` : a[t];
16
+ return `Unknown function "${t}()"${n ? ` — write \`${n}\`` : ""}: the functions are ${[...r].join(", ")}`;
17
+ }, s = "loop", c = class {
11
18
  issues = [];
12
19
  freeNames = /* @__PURE__ */ new Set();
13
20
  nodes(e, t) {
@@ -29,7 +36,7 @@ var r = /* @__PURE__ */ new Set([
29
36
  let e = /* @__PURE__ */ new Set([
30
37
  ...n,
31
38
  t.valueVar,
32
- i,
39
+ s,
33
40
  ...t.keyVar ? [t.keyVar] : []
34
41
  ]);
35
42
  this.nodes(t.body, e), n = /* @__PURE__ */ new Set([...n, ...this.setsIn(t.body)]), t.elseBody && this.nodes(t.elseBody, n);
@@ -70,7 +77,7 @@ var r = /* @__PURE__ */ new Set([
70
77
  this.expression(e.object, t), this.expression(e.index, t);
71
78
  return;
72
79
  case "function":
73
- r.has(e.name) || this.issues.push(`Unknown function "${e.name}()": the functions are ${[...r].join(", ")}`), e.args.forEach((e) => this.expression(e, t));
80
+ r.has(e.name) || this.issues.push(o(e.name)), e.args.forEach((e) => this.expression(e, t));
74
81
  return;
75
82
  case "filter":
76
83
  this.expression(e.subject, t), this.filterNames(e.filters.map((e) => e.name));
@@ -94,17 +101,17 @@ var r = /* @__PURE__ */ new Set([
94
101
  case "arrow": this.expression(e.body, /* @__PURE__ */ new Set([...t, ...e.params]));
95
102
  }
96
103
  }
97
- }, o = (e) => {
104
+ }, l = (e) => {
98
105
  let r = t(e);
99
106
  if (r.error) return {
100
107
  issues: [r.error],
101
108
  freeNames: []
102
109
  };
103
- let i = new a(), { nodes: o, error: s } = n(r.tokens, !1, i.issues);
104
- return s && i.issues.push(s), i.nodes(o, /* @__PURE__ */ new Set()), {
110
+ let i = new c(), { nodes: a, error: o } = n(r.tokens, !1, i.issues);
111
+ return o && i.issues.push(o), i.nodes(a, /* @__PURE__ */ new Set()), {
105
112
  issues: [...new Set(i.issues)],
106
113
  freeNames: [...i.freeNames]
107
114
  };
108
115
  };
109
116
  //#endregion
110
- export { o as inspectTemplate };
117
+ export { l as inspectTemplate };
@@ -5,7 +5,8 @@ export declare const processTwig: (template: string, variables?: Record<string,
5
5
  * boolean, `{{ total }}` the number it holds.
6
6
  *
7
7
  * A template that is one `{{ expression }}` and nothing else (surrounding whitespace aside) answers that expression's
8
- * value untouched. Anything with text around it, or tags, is text by nature and renders as {@link processTwig}.
8
+ * value untouched — and so does one whose `{% set %}` name the parts of that expression first. Anything with text
9
+ * around it, or other tags, is text by nature and renders as {@link processTwig}.
9
10
  *
10
11
  * Unlike `processTwig`'s `asRaw`, nothing goes through JSON on the way: `0`, `false` and `null` come back as
11
12
  * themselves, and a string that looks like a number stays a string.
@@ -14,8 +15,8 @@ export declare const processTwigValue: (template: string, variables?: Record<str
14
15
  /**
15
16
  * A flow step's param — in the browser's flows and in a server action's — as the value the step is handed.
16
17
  *
17
- * A param that is one `{{ expression }}` is that expression's value, exactly: a string stays a string however it
18
- * looks. The type is the VALUE's, never guessed from its text — which is what the step params used to do, rendering
18
+ * A param that is one `{{ expression }}` (after any `{% set %}` naming its parts) is that expression's value, exactly:
19
+ * a string stays a string however it looks. The type is the VALUE's, never guessed from its text — which is what the step params used to do, rendering
19
20
  * the value to text and reading the text back as JSON: a password typed as `1234` reached the server as a number, and
20
21
  * a text field declared `text` on the far side then saw no password at all. What a param should be converted to is
21
22
  * the business of whoever declares its type — `setState`'s `type`, an action's input fields — not of the resolver.
@@ -32,21 +32,31 @@ var s = (i, s = {}, c = !1, l = !1) => {
32
32
  } catch {
33
33
  return;
34
34
  }
35
- }, u = (e, n = {}) => {
35
+ }, u = (e) => {
36
+ let t = e?.filter((e) => e.type !== "text" || e.value.trim() !== "") ?? [], n = t.at(-1), r = t.slice(0, -1);
37
+ if (n?.type === "variable" && r.every((e) => e.type === "set")) return {
38
+ statements: r,
39
+ expression: n.expression
40
+ };
41
+ }, d = ({ statements: e, expression: n }, a) => {
42
+ let o = "variables" in a ? t(a) : a;
43
+ if (e.length === 0) return i(n, o);
44
+ let { variables: s } = r(e, o);
45
+ return Object.assign(a, s), i(n, s);
46
+ }, f = (e, t = {}) => {
36
47
  if (typeof e != "string") return e;
37
- let r = o(e), a = (r ? r.nodes ?? r.nodesWithSource : null)?.filter((e) => e.type !== "text" || e.value.trim() !== "");
38
- if (a?.length !== 1 || a[0].type !== "variable") return s(e, n);
48
+ let n = o(e), r = u(n ? n.nodes ?? n.nodesWithSource : null);
49
+ if (!r) return s(e, t);
39
50
  try {
40
- let e = "variables" in n ? t(n) : n;
41
- return i(a[0].expression, e);
51
+ return d(r, t);
42
52
  } catch {
43
53
  return e;
44
54
  }
45
- }, d = /* @__PURE__ */ new Set([
55
+ }, p = /* @__PURE__ */ new Set([
46
56
  "json_encode",
47
57
  "to_json",
48
58
  "object_as_json"
49
- ]), f = (e) => e.type === "filter" && d.has(e.filters[e.filters.length - 1]?.name ?? ""), p = (e) => {
59
+ ]), m = (e) => e.type === "filter" && p.has(e.filters[e.filters.length - 1]?.name ?? ""), h = (e) => {
50
60
  let t = e.trim();
51
61
  if (!t.startsWith("{") && !t.startsWith("[")) return e;
52
62
  try {
@@ -54,28 +64,28 @@ var s = (i, s = {}, c = !1, l = !1) => {
54
64
  } catch {
55
65
  return e;
56
66
  }
57
- }, m = (e, n = {}) => {
67
+ }, g = (e, t = {}) => {
58
68
  if (typeof e != "string") return e;
59
- let r = o(e), a = (r ? r.nodes ?? r.nodesWithSource : null)?.filter((e) => e.type !== "text" || e.value.trim() !== "");
60
- if (a?.length !== 1 || a[0].type !== "variable") {
61
- let t = e.includes("\"") ? l(e, n) : void 0;
62
- if (t !== void 0) return t;
63
- let r = s(e, n);
64
- return typeof r == "string" ? p(r) : r;
69
+ let n = o(e), r = u(n ? n.nodes ?? n.nodesWithSource : null);
70
+ if (!r) {
71
+ let n = e.includes("\"") ? l(e, t) : void 0;
72
+ if (n !== void 0) return n;
73
+ let r = s(e, t);
74
+ return typeof r == "string" ? h(r) : r;
65
75
  }
66
- let { expression: c } = a[0];
76
+ let { expression: i } = r;
67
77
  try {
68
- let e = "variables" in n ? t(n) : n, r = i(c, e);
69
- if (r === void 0) return "";
70
- if (typeof r == "string" && f(c)) try {
71
- return JSON.parse(r);
78
+ let e = d(r, t);
79
+ if (e === void 0) return "";
80
+ if (typeof e == "string" && m(i)) try {
81
+ return JSON.parse(e);
72
82
  } catch {
73
- return r;
83
+ return e;
74
84
  }
75
- return r;
85
+ return e;
76
86
  } catch {
77
87
  return e;
78
88
  }
79
89
  };
80
90
  //#endregion
81
- export { s as processTwig, m as processTwigParam, u as processTwigValue };
91
+ export { s as processTwig, g as processTwigParam, f as processTwigValue };
@@ -1,10 +1,10 @@
1
1
  /** Which of a space's documents a change was made to: its schema, its style, or its functions' source. */
2
- export type ChangeDocument = 'schema' | 'style' | 'functions';
2
+ export type ChangeDocument = 'schema' | 'style' | 'functions' | 'data';
3
3
  /**
4
- * Where a change came from: a person in the builder, an agent over MCP, the builder's co-worker, the autofix, a GraphQL
5
- * client that is not a person, or a writer with nothing to say (a seed, a script).
4
+ * Where a change came from: a person in the builder, an agent over MCP, the autofix, a GraphQL client that is not a
5
+ * person, or a writer with nothing to say (a seed, a script).
6
6
  */
7
- export type ChangeOrigin = 'builder' | 'mcp' | 'coworker' | 'autofix' | 'api' | 'system';
7
+ export type ChangeOrigin = 'builder' | 'mcp' | 'autofix' | 'api' | 'system';
8
8
  /**
9
9
  * What one entry is about. Schema: an element (pages and layouts are elements too), a page folder, a schema variable,
10
10
  * a setting (`settings.<key>`, `definition.<key>`, the page order `pages`). Style: a class selector, a global style