@plitzi/plitzi-sdk 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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,373 @@
1
1
  # @plitzi/plitzi-sdk
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
+ - Updated dependencies [3bce653]
17
+ - @plitzi/sdk-auth@0.38.6
18
+ - @plitzi/sdk-dev-tools@0.38.6
19
+ - @plitzi/sdk-elements@0.38.6
20
+ - @plitzi/sdk-event-bridge@0.38.6
21
+ - @plitzi/sdk-interactions@0.38.6
22
+ - @plitzi/sdk-navigation@0.38.6
23
+ - @plitzi/sdk-plugins@0.38.6
24
+ - @plitzi/sdk-schema@0.38.6
25
+ - @plitzi/sdk-shared@0.38.6
26
+ - @plitzi/sdk-style@0.38.6
27
+ - @plitzi/sdk-variables@0.38.6
28
+
29
+ ## 0.38.5
30
+
31
+ ### Patch Changes
32
+
33
+ - 3bce653: ## Agents work through the MCP: the builder's AI chat is gone
34
+
35
+ An agent reaches a space through the MCP, from whatever harness the person already uses; Plitzi no longer runs one of
36
+ its own inside the builder. **Breaking** for whoever imported what that chat was built on:
37
+
38
+ - **The builder's Assistant panel is removed**, with its conversations, attachments, previews and provider settings.
39
+ - **`@plitzi/sdk-mcp` no longer exports the in-process AI engine**: `AIEngine`, `toolResponseOk`, `toolResponseErr`,
40
+ `zodToJsonSchema`, `getAllowedModes`, `bindTools`, `isToolActive`, `resolveToolHandler`, `isCallToolResult`,
41
+ `toolResponseFromResult` and `buildAgentGuide`. The MCP server, its tools and `@plitzi/sdk-mcp/server` are unchanged;
42
+ the tool functions are still exported to run in-process.
43
+ - **`@plitzi/sdk-shared` drops the chat's types** — `AITypes` (`AiContext`, `AiMode`, `AiMessageAttachment`,
44
+ `AiUsage`, …) and `McpTypes` (`McpTool`, `McpToolHandler`, `McpContent`, …), with their `./types/AITypes` and
45
+ `./types/McpTypes/index` subpaths — and no longer depends on `@modelcontextprotocol/sdk`.
46
+ - **A change's `origin` is never `coworker`**: `ChangeOrigin` is `builder`, `mcp`, `autofix`, `api` or `system`, and
47
+ the History panel's filter follows.
48
+ - **The builder's platform flags are gone**: `PlatformFlags` is no longer part of the builder's first query, nor
49
+ `platformFlags` of its store — `assistanceAI` was the only one.
50
+ - **Plitzi's own deployment no longer offers the `ai.complete` task** to flows.
51
+ - **Each MCP tool says whether it only reads** (`readOnlyHint`, from the tool's `access`), so a host can run a read
52
+ without asking and ask before a write. Until now `access` was read only by the builder's chat.
53
+ - **The MCP works over the JSON adapters.** `createJsonAdapters` offers `getSchema` and `getStyle`, and — for a space
54
+ read from a path — `saveSchema` and `saveStyle`, each writing its document back into the file. **Breaking**:
55
+ `saveOfflineData` is gone from `SSRAdapters`; nothing called it, and it was the JSON adapters' only write, so an MCP
56
+ over them could neither read nor save.
57
+
58
+ ## Lighter pages: icons on their own
59
+ - **Font Awesome is a stylesheet of its own**, `plitzi-sdk-icons.css`, with its fonts as files beside it
60
+ (`webfonts/`) instead of base64 inside `plitzi-sdk.css` — which drops from 287 KB to 103 KB. A page fetches a face
61
+ only when it shows an icon of that style, and a new SDK version no longer downloads the fonts again. The page server
62
+ links it after `plitzi-sdk.css` (`SSRTemplateProps.iconsCssPath`), the SDK's iframe and shadow modes load it beside
63
+ the stylesheet, and the package exports it: **a project that imports `@plitzi/plitzi-sdk/plitzi-sdk.css` imports
64
+ `@plitzi/plitzi-sdk/plitzi-sdk-icons.css` too** — `plitzi upgrade` adds it to `src/main.ts`, and a new project has
65
+ it. The MCP's rendered widgets inline the sheet, fonts and all, only for a widget that draws an icon.
66
+ - **Material Icons is no longer loaded.** Nothing in Plitzi used it; every page paid a request to Google for it.
67
+ - **A page loads only the plugins it draws.** The page server sends the rest as their declaration
68
+ (`PluginEntry.deferred`, `pluginDeclarationOf` in `@plitzi/sdk-shared/plugins/declaration`); the SDK registers each
69
+ as a stand-in that knows its types from the start, and loads its code and stylesheet the first time one of its
70
+ elements is drawn — on a page reached by navigating too, with no server involved. What a page draws is
71
+ `pageElementTypes` (`@plitzi/sdk-shared/schema/pageElements`): the page, its layouts, the components and references
72
+ it holds. `render()` takes a plugin as `{ load, css, declaration }` beside `{ component }`.
73
+ - **The space travels beside the page, not inside it.** The page names it (`<link id="plitzi-space">`,
74
+ `SSRTemplateProps.spaceDocumentPath`), the browser fetches it while the scripts load, and the page server answers
75
+ `/_plitzi/space/<hash>.json` behind the same gates as its pages — `immutable`, since the name is its content's hash:
76
+ one download for every page and every visit until the space changes. The website's docs page went from 2.6 MB to
77
+ 0.5 MB. Still the whole space, so every navigation after the first page stays in the browser. A draft preview and a
78
+ deployment's own `templateFn` keep it inline.
79
+ - **An arrival on screen plays as the page arrives.** A `motion: { on: 'view' }` element already in view was held
80
+ invisible until the SDK hydrated — the page's content, and a page rendered `ssrOnly` forever. The page server's
81
+ document now sees it as soon as it is parsed, and hands over to the SDK once the page is live.
82
+
83
+ ## Server data: one request per question, the newest winning, and a way to stop
84
+ - **A link asks for its page's server data once.** The navigation's prefetch already brought it; the route change that
85
+ followed asked again — two renders per click. `useRscSync` now asks only for a location the store does not hold.
86
+ - **Answers land in the order they were asked.** `refreshRsc` joins a refresh already in flight for the same URL and
87
+ aborts one a newer refresh would overwrite (a whole payload asked again, an element asked again); a whole payload
88
+ keeps what an element asked for after it. A slow answer no longer paints a page the visitor has left.
89
+ - **Stopping.** `cancelRsc(store, ids)`, an `apiContainer`'s `cancelQuery` callback (`cancelApi(id)` in authoring) and
90
+ `queryCache.cancel(key)` for a browser provider: the request is dropped and what is shown stays. The server hears it:
91
+ `SSRRscContext.signal` aborts when the browser hangs up, and the default `getRscData` stops every element still
92
+ resolving — a shared render run only once nobody is waiting on it.
93
+ - **Pending.** A server provider's `isLoading` is true while it is asked again (`rsc.refreshing`). The `navigation`
94
+ source says `pending` and `pendingLocation` while a link waits for its destination's data; a second link clicked
95
+ before the first went supersedes it, and the first never goes.
96
+ - **A bound `input` asks again.** An `apiContainer`'s `input` is a prop now: bound to state, every change refetches a
97
+ server provider. What a refresh asks for (`req.ctx.rscParams`) wins over the `input` the element was saved with.
98
+ - **A section cut by its budget says how to give it more** (`rsc.elementTimeoutMs`).
99
+
100
+ ## Flows
101
+ - **`whileRunning('latest')`**: a new firing stops the run in progress — no further step; its `runServerAction` is
102
+ cancelled (request and server run) and its `webHook` aborted — and runs. A search as you type. The step's context
103
+ carries the `signal`. Offered in the builder and the MCP.
104
+ - `onApiSuccess` / `onApiError` fire once per answer: a cancelled request or a loading flag that came and went no
105
+ longer runs the flow again.
106
+ - **A debounce is `whileRunning('latest')` and a `delay` first**: `delayTime` ends its wait the moment its run is
107
+ superseded, so only the last firing gets past it. Its `time` is a number.
108
+
109
+ ## Server actions
110
+ - **The request budget is never silent.** A task that caught the refused fetch hid `maxRequests`; the step that ran
111
+ into it now logs it, and the server logs it once, naming `createServer({ action: { limits: { maxRequests } } })`.
112
+ - **`invalid_input` says what the value was and which type takes it** — `windows (text, got a list; declare the field
113
+ \`json\` to take it)`. The templates reference documents that a param that is only `|json_encode` is the value it
114
+ encodes.
115
+ - **`kv` survives a restart with no database.** `createFileKv({ file })` (`@plitzi/sdk-server/actions`) keeps the
116
+ in-process store in one JSON file, written whole as soon as anything changes — for one process.
117
+ `createSqliteKv({ file } | { db })` (`@plitzi/sdk-server/sqlite`, new entry) is a table in a SQLite file over
118
+ `node:sqlite`, every operation one statement, shared safely by every process on the file. Both pass the adapter
119
+ contract every store is held to. The `09-schedules` example uses it rather than its own copy, whose counters read
120
+ `22.0`.
121
+
122
+ ## Authoring
123
+ - **What a space declares and never uses** is suggested now: `unused-class`, `unused-token`, `unused-component`, and
124
+ `literal-colour` — a class painted from the palette typing out a scheme token's light value. A suggestion about
125
+ declarations names them in `subjects`, so the MCP says one a batch left unused beside the ones the space had.
126
+ `unusedDeclarations(schema, style)` is the rule itself, for anything else that says "unused" (the builder does).
127
+ - **`pageFamily(shape, entries)`** writes pages of one shape from data: each page its id, slug, titles, folder and
128
+ layout, and its body built inside `scope(entry.id, …)` so two pages never give one id.
129
+ - **`action-output-path`** (warned): `.data` read on a provider fed by a server action, which publishes its output at
130
+ the root. **`actionSource(id, sample)`** types such a provider by a sample of its output.
131
+ - A value template (`returns: 'value'`, a computed, a step param) may name its parts with `{% set %}` before its one
132
+ expression, and is still that expression's value.
133
+ - `abs()`, `floor()`, `ceil()`, `clamp()` are refused with how they are written here (`x|abs`,
134
+ `x|round(0, 'floor')`, `min(max(x, low), high)`).
135
+ - An unknown attribute is reported against the element's props, not as "'id' does not exist in type ElementSpec[]".
136
+ - `explain` answers a builder's name (`reloadApi`, `cancelApi`) with its step, and knows `whileRunning`.
137
+ - A component's instance takes `quiet`, like any element — `component(id, { quiet: ['repeated-shape'] })`: instances
138
+ whose slots are filled alike on purpose stop being offered as a repeat, and an exported instance that carries one
139
+ typechecks.
140
+ - `container` and `text` take a `title`. A trigger's `preview` may hold numbers, flags, lists and `null`.
141
+ - **A Markdown element's headings are sections a link can name.** Each renders with the anchor its words read as
142
+ (`## Server data` → `#server-data`, numbered when repeated), and a link's `hash` may name one: `anchor-missing` counts
143
+ them, so a table of contents built from the Markdown is checked like any other link.
144
+ - `answerAction(page, actionId, output)` (testing): a test that would save something answers that server action in
145
+ the browser — the server's `kv`, and what the developer kept, are never written. A stream step gets its `done` frame.
146
+
147
+ ## Plugins
148
+ - **A plugin's stylesheet sits below the space's.** The cascade order is now `… utilities, plitzi-sdk-plugin,
149
+ plitzi-sdk-runtime`, and whatever builds a plugin writes its CSS into `plitzi-sdk-plugin` (`inPluginLayer` from
150
+ `@plitzi/sdk-shared/style`): `plitzi pack plugin`, a server compiling one (`action: 'compile'`), and the stylesheet a
151
+ server copies or downloads for one. A space's classes and `customCss` now win over what the plugin's author shipped,
152
+ whatever the specificity — as they do over a built-in element. A plugin packed before this ships unlayered and still
153
+ wins until it is packed again.
154
+ - **Declared param types reach the callback.** A param declared `number` (new, a text box in the builder) or `boolean`
155
+ is handed over as one — written `5000`, or bound to text that says it; an empty number as nothing, so the component's
156
+ default applies.
157
+ - **`useElementVisible(id)`** (`@plitzi/plitzi-sdk`): whether another element is on the page — its own `visible`, every
158
+ container around it, the breakpoint — kept current while the plugin is mounted, at that plugin's cost alone.
159
+ - **A page open on a development server loads again when the server restarts** (`devReload`): `start:dev` restarting
160
+ on a change to the server's code reached the open page only when somebody reloaded it.
161
+ - **A saved plugin is swapped into the open page** (`devReload`, server mode): the page server rebuilds the plugin
162
+ whose source changed and the page renders the new component in place, keeping its state — no restart, no reload. A
163
+ change to its declaration (what the builder and the linter know of it) still reloads the page. `render()` takes
164
+ `{ hotPlugins: true }` and answers `{ unmount, replacePlugin }`; `PluginManager.rebuild(name)` and `onSources`. A new
165
+ folder in `src/plugins` is registered without a restart (`server.plugins.register`), from `create` and `create --from` alike.
166
+ - **A plugin brings its own server half.** `functions/index.ts` beside the component — the `defineFunctions` a
167
+ space's functions use — answers routes under `/fn/plugins/<type>/` and runs steps named `<type>.<action>` (origin
168
+ `'plugin'`, the builder's **Plugins** group). It runs with a narrower `ctx`: its own `kv` (prefixed
169
+ `plugin:<type>:`, its `rateLimit` and `sign` too), none of the space's credentials, no realtime publishing or grants;
170
+ its routes and tasks outside its namespace are refused, as are a space's routes under `/fn/plugins/`. The component
171
+ reaches its routes with `usePluginRoute(type)` (`@plitzi/plitzi-sdk`; `undefined` where no server runs code).
172
+ A page server takes them as `functions.plugins` (`{ [type]: FunctionsDefinition }`), swaps one with
173
+ `server.functions.setPlugin`, and asks a cloud adapter with `actionLookups.getPluginFunctions(spaceId, version)`.
174
+ `plitzi pack plugin` carries the source in the zip as `functions.source.json` (`PLUGIN_FUNCTIONS_SOURCE`, named by
175
+ the manifest's `functions`; `loadFunctionsSource` builds it) — kept privately by the platform, never published.
176
+ - **A plugin lays out the space's elements it holds.** `elementChildren(children)` (`@plitzi/plitzi-sdk`) hands
177
+ over each child element with the id it was authored under, for a dock, tabs or a masonry to place in boxes of its
178
+ own — instead of writing styles onto elements it does not render.
179
+ - **`useDisplayMode()`** (`@plitzi/plitzi-sdk`): `desktop`, `tablet` or `mobile`, at the widths the space's styles are
180
+ compiled at — not a breakpoint of the plugin's own.
181
+ - **A file a library needs whole travels inside the bundle**, imported as Vite imports it: `worker.js?raw` (its text — a
182
+ worker from a Blob), `engine.wasm?inline` (a base64 data URI). `plitzi pack` and a server compiling a plugin share
183
+ one build (`@plitzi/sdk-shared/plugins/bundle`), so a server now inlines `.avif`, `.ttf` and `.otf` as `pack` did.
184
+
185
+ ## CLI and page checks
186
+ - **`plitzi lint`** reads a local space's source the way eslint reads code, for what the document cannot show:
187
+ `file-too-long`, `pages-in-one-file`, `inline-records` (rows of data written in code → `src/data/`), `repeated-css`,
188
+ `special-case-in-map`, `colour-not-token`, `positional-id`, `unused-file` — each at file:line with what to write
189
+ instead — and authoring's suggestions at the line that wrote them. `--json`, `--strict`, `--max-warnings <n>`;
190
+ `// plitzi-lint-disable-next-line <code> -- why` for a departure on purpose. Projects get `npm run lint:space`
191
+ (`upgrade` adds it to older ones). `doctor` stays the project's and never reads the space.
192
+ - **`--template blank`** starts with only the colours its page uses: a token declared and read by nothing is one
193
+ authoring now points out.
194
+ - **The welcome space is written as a folder**, not one 800-line file: `src/space/index.ts` (the page), `tokens.ts`,
195
+ `theme.ts`, `content.ts` — the shape a space keeps as it grows, and clean under `plitzi lint`. **Breaking** for
196
+ whoever called it: `blankSpaceSource()` is now `blankTemplateFiles({ name, dir, plugin })`, which returns the files by
197
+ path; `toPortableSource` keeps imports of the files beside it. A plugin package's preview space is
198
+ `preview/space/index.ts`.
199
+ - **`check`, `shot` and the generated visual tests settle instead of waiting for `networkidle`**, which never came on a
200
+ page with a realtime channel: `openPage` (`@plitzi/sdk-authoring`) waits for load, then quiet, counting no stream
201
+ that stays open.
202
+ - **The server is the project's in `src/config/serverOptions.ts`; `src/main.ts` stays the CLI's.** `create` writes
203
+ `src/config/serverOptions.ts` (handed to `createServer`, typed from `ServerConfig`, now exported by
204
+ `@plitzi/sdk-server`) and, with `--source local`, `src/actions/index.ts` (the space’s server actions), which `main.ts` wires
205
+ for calls, renders and schedules. What `main.ts` wires itself (the space's adapters, the plugins, `public/`,
206
+ `src/data/`, `src/functions/`, the actions' lookups) is left out of `serverOptions`' type and comes after it, so no option unwires it.
207
+ `upgrade` writes either file into a project that has none — only when the `main.ts` reading it is the CLI's — and
208
+ never replaces it; `create --from` projects read `serverOptions.ts` too.
209
+ - **`upgrade packages` brings up the scripts the CLI wrote and nobody changed** (`.plitzi/scaffold.json` now records
210
+ them); a script the project changed is left and said, as before.
211
+ - `start:dev` restarts on a change to the server's code — `src/main.ts`, `src/config/`, `src/actions/` and
212
+ `src/functions/` (there from the start, kept by a `.gitkeep`); a plugin is swapped in the open page instead, and its
213
+ `functions/` set again, without a restart. A function imports its siblings with `.ts`, as `src/`.
214
+ - `add plugin --server` writes the plugin's server half (`functions/index.ts`, a `GET`/`POST /state` example on its
215
+ `kv`); a package gets `@plitzi/sdk-server` as a devDependency for its types. Refused in a client-mode project.
216
+ - `add plugin`: `--prop rows:list` and `--prop meta:json` for data a binding fills; `--headless` writes
217
+ `drawsNothing: true`; the generated events hook never fires on the builder's canvas.
218
+ - 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
219
+ to do, instead of "no size (0×0)".
220
+ - **A server-mode project keeps its `kv` in `state/kv.json`** (`createFileKv`; ignored by git): what the space's actions
221
+ save outlives a restart, `start:dev`'s included. `action.kv` in `src/config/serverOptions.ts` names another store.
222
+ - A server-mode project types what its plugins import besides code (`plitzi/assets.d.ts`): a stylesheet, an image,
223
+ `?raw`, `?inline` — a client-mode one has them from `vite/client`.
224
+ - **A project made from a space runs the server `create` writes.** It has the same `src/main.ts` as any project: it
225
+ now takes a free port and writes `tmp/dev-server.json` (which `check`, `shot` and the visual tests read), answers
226
+ `/health`, and re-authors its pages on save instead of waiting for a restart. Its actions are `src/actions/` and its
227
+ connectors `src/connectors/`, both there from the start, and `start:dev` restarts on them; `src/actions/index.ts`
228
+ exports `actions` and `connectors`, as a `create` project's does (`push` reads that). Before, `upgrade` showed its
229
+ `main.ts` as the project's own, and `--take all` would have put `create`'s server in place of the space's.
230
+ - **A `--source cloud` server project starts.** Its key is in `.env`, which nothing read: `npm start` stopped on "Set
231
+ PLITZI_HOST_KEY". Every server project's `src/main.ts` now reads `.env` itself (`process.loadEnvFile`), and every
232
+ one is given a signing key there (`PLITZI_SIGNING_SECRET`, made for it by `create`) — `ctx.sign` refused in a project
233
+ `create` wrote, a plugin's server half included. `PORT` is no longer written into `.env`, where it pinned 8080. A
234
+ cloud project keeps its `kv` in `state/kv.json` too.
235
+ - **`upgrade` keeps the package manager a project was written for** (`.plitzi/scaffold.json`) when it has no lockfile
236
+ of its own yet: a yarn or pnpm project not installed (`--no-install`), or sitting in a monorepo folder, was taken for
237
+ npm and its `AGENTS.md`, Playwright config and `.gitignore` replaced with npm's commands.
238
+ - `author`, `check`, `fix` and `push` know the element types of a project's built-only plugins
239
+ (`vendor/plugins/*/plugin-manifest.json`, every element each provides), as its server does.
240
+ - **`import` reaches Plitzi only when told to.** A site not served from this machine needs `--account` — ask the
241
+ person's Plitzi account whether one of their spaces verified its domain, signing in — and without it is refused,
242
+ saying so, before any request: an agent running `import` in a local project opened a sign-in nobody asked for. The
243
+ CLI skill and the generated `AGENTS.md` say to run `import` only when the user asks, and to ask before `--account`.
244
+ - **A server project's data is no longer on the internet.** It was `public/data/*.json`, served to anyone as a file;
245
+ it is `src/data/*.json`, which the server reads and never serves (`dataDir`, new in `createServer`): a provider with
246
+ `runtime: 'server'` and `query: '/data/<file>'` reads it, and the page arrives with it. `projectData`
247
+ (`@plitzi/sdk-authoring/node`) and `authorSpace`'s `serverData` hold bindings to those files, and a provider asking
248
+ for `/data/…` from the browser is refused (`server-data-in-browser`): nothing would answer it. What a provider reads
249
+ is still in the page it renders — data a page must not carry is a server action's to read. A client-mode project
250
+ keeps `public/data/`, which the browser has to fetch. The catalog template follows the mode
251
+ (`catalogTemplateFiles({ mode })`). `public/` holds only what is meant for everyone.
252
+ - **The project's own server code is `src/functions/`**, with the rest of its source — typechecked with it, left out of
253
+ `tsconfig.build.json` (the server builds it at boot). `functions pull`/`push`/`dev`, `push`, `pull` and `create
254
+ --from` follow. The `kv` folder is `state/` (it was `data/`, beside a data folder that was something else).
255
+ - **What is the CLI's is in `plitzi/`, apart from `src/`.** `plitzi/author.ts`, `plitzi/assets.d.ts` (server mode) or
256
+ `plitzi/preflight.css` (client mode), and `plitzi/README.md` — which says what each folder of `src/` is, instead of a
257
+ README in every one. `src/main.ts` stays where an entry point is looked for, the CLI's all the same.
258
+ `src/plugins/declarations.ts` is gone: a plugin is declared by its folder's `declaration.ts`, found by the server,
259
+ `author`, `check`, `fix`, `push` and the visual test alike (`pluginDeclarations` from `@plitzi/sdk-authoring/node`;
260
+ Vite's `import.meta.glob` in client mode).
261
+ - `functions.plugins` is in `SSRServerConfig`'s type and checked as the server starts: a project passing its plugins'
262
+ server halves did not typecheck.
263
+ - **A project's source is folders that grow.** The space is `src/space/` — its `index.ts` exports it as `space` and
264
+ assembles the rest (the catalog template's `src/site/` is `src/space/` now; `create --from` writes the space's own
265
+ `index.ts` there, exported as `space` too). The server actions are `src/actions/` — `index.ts` lists them, one action
266
+ a file, as `create --from` already had them — and what the server does besides serving the space is
267
+ `src/config/serverOptions.ts`. `start:dev` watches `src/config` and `src/actions` whole.
268
+ - **One server for every project, kept by `upgrade`.** `src/main.ts` runs what a project holds from where it lands — a
269
+ runtime in `src/runtime/` (or built only, `vendor/runtime.bundle`), plugins built only (`vendor/plugins/`), the
270
+ actions' connectors — so `create --from` writes no `main.ts` or `.prettierignore` of its own any more, and `upgrade`
271
+ keeps both current in projects made from a space too. `loadRuntimeModule` (`@plitzi/sdk-server/runtime`): a project's
272
+ runtime module, or nothing when it has none.
273
+ - **`plitzi add runtime`** writes `src/runtime/index.ts` — run by the project's server (`npm start` answers its
274
+ endpoints) and sent by `plitzi runtime push`, whose default entry it is now — and has `start:dev` restart on it. A
275
+ space taken out with a runtime gets `src/runtime/index.ts` handing over the module its source starts at.
276
+ - **`push` sends the space's files back as their CDN addresses.** `create --from` and `pull` write each CDN address as
277
+ the project's path (`/assets/a.png`, served from `public/assets/`); `push` sent those paths as they were, and the
278
+ space's pictures and data pointed at nothing on Plitzi. It also says, before sending, what Plitzi would not have: a
279
+ provider reading a file `src/data/` does not hold, and a file the space names that is not on its CDN.
280
+ - **`push` sends a project's data and its files.** Two new parts: `data` — `src/data/` whole, kept by Plitzi as the
281
+ space's own data (private, frozen with each publish, read by the page server of the version it renders; refused when
282
+ the space's copy changed since the project last had it, unless `--force`) — and `files` — each changed file of
283
+ `public/assets/`, put at the same path under the space's `assets/` on its CDN, so a pull brings it back where it was.
284
+ `create --from` and `pull` write the space's data into `src/data/`. `getData` joins the action lookups
285
+ (`ActionLookupsConfig`), and the page server resolves `/data/<file>` through it when there is no `dataDir`.
286
+ - **A space's data is edited in the builder and by agents.** The builder's Server view has a **Data** tab: the JSON
287
+ files the space's server providers read (`/data/<file>`), a file list and a JSON editor, saved whole against the
288
+ copy it read (⌘S; a newer copy is refused, a broken file named). The MCP reads it as `plitzi://data/{env}` and writes
289
+ it with `upsertDataFile` / `deleteDataFile` (`getData` / `saveData` among the adapters; a file that is not JSON is
290
+ refused as it is written), and the guide has a Data section. One write path for the builder, agents and `plitzi push`
291
+ (`SpaceData` / `SpaceSaveData` over GraphQL, under `spaceManage`), one history. `DataDraft` / `DataSaveResult` are
292
+ in `@plitzi/sdk-shared`. The builder's file list is shared by Functions and Data (`modules/FileTree`).
293
+ - **`plitzi doctor`**: whether the project the CLI set up is whole, checked against what it is now — a developer may
294
+ change any file. Packages (declared, installed at versions that agree, one copy of the SDK and of React), the CLI's
295
+ files and scripts (as `upgrade` sees them, one planner for both), the file each Node script starts and every folder
296
+ `start:dev` watches, the TypeScript configs, `.gitignore` and `.env` (never in git; the signing secret as long as the
297
+ project's server wants it), the code Node runs as written (relative imports with their extension, JSON with its
298
+ attribute, no JSX, every package declared — walked with esbuild), each plugin folder against its declaration, the data
299
+ files, `src/functions/` built by the project's own sdk-server, `.plitzi/` and the skills. Each finding has an area, a
300
+ code, the file and its fix; `--json`, `--strict`; exit 1 on an error. It never checks the space — `npm run author`
301
+ and `check` do — and every report says so. A layout an older CLI left (`src/space.ts`, `src/author.ts`,
302
+ `functions/` at the root…) is its own area, checked first and alone. `--fix` repairs what is simple and safe —
303
+ that layout moved with every import, URL and script following (and the scaffold record with it), dead files,
304
+ `.gitignore`, `"type": "module"`, a watched folder, a signing secret — then checks again; `--dry-run` says what.
305
+ Each report ends with what to run next. `upgrade` writes no file over an older layout, and says `doctor --fix`.
306
+ `buildFunctions` and `FunctionsBuildError` are exported from
307
+ `@plitzi/sdk-server/functions-runner`, `MIN_SIGNING_SECRET_LENGTH` from `@plitzi/sdk-server/actions`.
308
+ - **`--dry-run`** on every command that writes or sends — `create`, `add plugin`, `add runtime`, `pull`, `push`,
309
+ `pack plugin`, `source`, `import`, `upload plugin`, `functions pull`/`push`, `runtime push`/`start`/`stop`/`size`/
310
+ `vars`, `skills update`, `doctor --fix`: each file it would write (`+` new, `~` replaced, `-` removed), what it would install or run, what it would
311
+ send and where, and none of it done. It still reads what it needs to say so.
312
+ - **A new project is formatted from the start**, every template and mode: its first `format` changes nothing. The CLI's
313
+ own files are in its `.prettierignore`, so formatting never turns one into a file `upgrade` believes was changed.
314
+
315
+ ## Builder
316
+ - **The pages panel keeps its folders as you left them** — open or closed, per space, across reloads — the way the
317
+ style inspector keeps its sections. A folder starts closed.
318
+ - **Usages**, a panel beside Layers: where each component, class, token, space variable and data source is used,
319
+ page by page — what reads it and which elements — and which nothing uses, by authoring's own rule. A click selects
320
+ the element, inside a component too.
321
+ - **Revealing an element inside a component opens the component** (the Usages panel, ⌘P, the issues and the history all
322
+ reveal through it); before, the selection was dropped. **Panels stay open** when a component opens or closes.
323
+ - **The canvas dims a page's layout around its body again when the layout or its slot draws no box**
324
+ (`display: contents`, which the efficiency guide recommends): the hole was measured as a rect of zeros and the whole
325
+ page was dimmed. A box-less element is measured by what it holds, and the mask by the box that positions it.
326
+ - **Elements is one category at a time.** A row of chips — each category with its count, and the space's components as
327
+ one more — picks what the panel shows, remembered between sessions, so the panel stays the same height however many
328
+ elements plugins add. A search looks through every category and the components at once. Each element is a tile: its
329
+ icon, its whole name, and what it is on hover. Container, Button, Form, Form Control, Dropdown Popup, List Item, Rich
330
+ Text, Dialog Container and Tab Container Item have icons of their own (`sdk-elements`), none shared with another
331
+ element or with the component and snippet icons.
332
+ - **Layers reads as a tree and is driven from the keyboard.** A guide per depth, a chevron that turns, the component's
333
+ name beside an element that is one, and the selected row kept in view. ↑/↓, Home/End, → to open or go in, ← to close
334
+ or go up. A row under a closed ancestor is no longer shown. (plitzi-ui's `Tree`.)
335
+ - **Motion and preview no longer share an icon.** Playing the page's motion is a wand, which pulses while it plays;
336
+ preview is an eye, and a pen to go back to editing.
337
+ - **A component's settings fit their modal, however many props it has.** The modal is wider; the name and folder
338
+ share a line, and each prop is one compact row — its name, its kind, required, remove — with what a binding writes to
339
+ read it (`{{ props.<name> }}`) or what is wrong with it, and what it is for, beneath. The fields scroll and the buttons
340
+ stay in view. Props and slots are titled sections, and a slot shows its id.
341
+
342
+ ## Packages
343
+ - **`GET /auth/continue` takes `?fallback=`**: where to go when `redirect` is refused, vetted by the same check. A sign-in
344
+ screen's way back sends its site there, so leaving without signing in never lands on "you are signed in".
345
+ - **Markdown renders headings you can link to and code you can copy.** A heading carries its anchor and a `#` link to
346
+ itself; a fenced block a header with its language and a **Copy** button. The anchor is `@plitzi/sdk-shared`'s:
347
+ `anchorOf`, `uniqueAnchor` and `markdownHeadings` (`schema/anchor`, `schema/markdownHeadings`) — what the element
348
+ renders, what authoring checks a link against and what a table of contents is built from are one function. Needs
349
+ `@plitzi/plitzi-ui` 1.6.31 (its `Markdown` takes `headingAnchor`).
350
+ - **Every package declares what it imports, and nothing more.** `react` is a peer of `sdk-auth`, `sdk-event-bridge`,
351
+ `sdk-interactions`, `sdk-style` and `sdk-variables`; `sdk-schema` depends on `immer`, `sdk-elements` on
352
+ `@dr.pogodin/react-helmet`, `sdk-plugins` on `@plitzi/plitzi-ui`, `sdk-style` on `@plitzi/sdk-event-bridge` and
353
+ `sdk-dev-tools` on `@plitzi/sdk-plugins` — each worked only because `@plitzi/plitzi-sdk` brought them, and failed
354
+ installed alone or under a strict linker. `prop-types` and the `@plitzi/*` dependencies nothing imported are gone:
355
+ `sdk-mcp` no longer declares `@plitzi/sdk-elements`, which its code does not import — it still arrives through
356
+ `@plitzi/plitzi-sdk`.
357
+
358
+ - Updated dependencies [3bce653]
359
+ - @plitzi/sdk-auth@0.38.5
360
+ - @plitzi/sdk-dev-tools@0.38.5
361
+ - @plitzi/sdk-elements@0.38.5
362
+ - @plitzi/sdk-event-bridge@0.38.5
363
+ - @plitzi/sdk-interactions@0.38.5
364
+ - @plitzi/sdk-navigation@0.38.5
365
+ - @plitzi/sdk-plugins@0.38.5
366
+ - @plitzi/sdk-schema@0.38.5
367
+ - @plitzi/sdk-shared@0.38.5
368
+ - @plitzi/sdk-style@0.38.5
369
+ - @plitzi/sdk-variables@0.38.5
370
+
3
371
  ## 0.38.4
4
372
 
5
373
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -2,8 +2,10 @@ import { default as sdkComponents } from './modules/Element';
2
2
  import { createShaderProgram, ShaderError, useAnimationFrame, useCanvas2d, useReducedMotion, useWebGL, useWebGL2, CanvasHandle, CanvasOptions, CanvasSize, Frame } from '@plitzi/sdk-elements/canvas';
3
3
  import { default as ComponentProvider } from '@plitzi/sdk-elements/Component/ComponentProvider';
4
4
  import { default as useFlag } from '@plitzi/sdk-elements/dataSource/useFlag';
5
+ import { default as elementChildren, ElementChild } from '@plitzi/sdk-elements/Element/helpers/elementChildren';
5
6
  import { default as withElement } from '@plitzi/sdk-elements/Element/hocs/withElement';
6
7
  import { default as useElement } from '@plitzi/sdk-elements/Element/hooks/useElement';
8
+ import { default as useElementVisible } from '@plitzi/sdk-elements/Element/hooks/useElementVisible';
7
9
  import { default as useRscData } from '@plitzi/sdk-elements/Element/hooks/useRscData';
8
10
  import { default as JsxManager } from '@plitzi/sdk-elements/Element/JsxManager';
9
11
  import { default as PluginManager } from '@plitzi/sdk-elements/Element/PluginManager';
@@ -14,8 +16,11 @@ import { default as useChannel, ChannelHandle } from '@plitzi/sdk-elements/realt
14
16
  import { default as ComponentContext } from '@plitzi/sdk-shared/elements/ComponentContext';
15
17
  import { PlitziServiceProvider } from '@plitzi/sdk-shared/hooks/usePlitziServiceContext';
16
18
  import { default as useRscRefresh } from '@plitzi/sdk-shared/server/rsc/useRscRefresh';
19
+ import { default as usePluginRoute } from '@plitzi/sdk-shared/server/usePluginRoute';
17
20
  import { useSdkStore } from '@plitzi/sdk-shared/store';
21
+ import { default as useDisplayMode } from '@plitzi/sdk-shared/style/useDisplayMode';
18
22
  import { track } from './modules/Analytics';
23
+ import { DeferredPlugin, PluginComponent } from './modules/Sdk/deferredPlugins';
19
24
  import { ElementContextValue } from '@plitzi/sdk-elements/Element/ElementContext';
20
25
  import { default as EventBridge } from '@plitzi/sdk-event-bridge';
21
26
  import { default as InteractionsManager } from '@plitzi/sdk-interactions/InteractionsManager';
@@ -31,19 +36,35 @@ import { ReactNode } from 'react';
31
36
  * caller for it made the parameter impossible to satisfy without a cast: everybody registering a component of
32
37
  * their own has a React component and nothing else, which is also exactly what `<Sdk.Plugin component>` declares.
33
38
  */
34
- export type RenderPlugins = Record<string, {
39
+ type RenderPluginBase = {
40
+ props?: Record<string, unknown>;
41
+ clientOnly?: boolean;
42
+ };
43
+ export type RenderPlugins = Record<string, (RenderPluginBase & {
35
44
  /**
36
45
  * A plugin's props ARE the hosting element's attributes, which this package cannot know — so the parameter is
37
46
  * left open. Narrowed to `ComponentPluginFC` with its default `unknown`, it refuses every component anybody
38
47
  * actually writes: a component declaring `{ label?: string }` has nothing in common with the runtime-supplied
39
48
  * props alone, and TypeScript reads that as a mistake rather than as the intended widening.
40
49
  */
41
- component: ComponentPluginFC<any>;
42
- props?: Record<string, unknown>;
43
- clientOnly?: boolean;
44
- }>;
45
- export declare function render(widgetContainer: string, params?: PlitziSdkProps, plugins?: RenderPlugins, debugMode?: boolean, ssrMode?: boolean): {
50
+ component: PluginComponent;
51
+ })
52
+ /** One the page draws none of — see `deferredPlugin`. */
53
+ | (RenderPluginBase & DeferredPlugin)>;
54
+ export type RenderOptions = {
55
+ /**
56
+ * Development: the page's plugins can be swapped while it runs (`replacePlugin` on what `render` returns) — what a
57
+ * server rebuilding a plugin hands an open page, so an edit shows without loading the page again.
58
+ */
59
+ hotPlugins?: boolean;
60
+ };
61
+ export declare function render(widgetContainer: string, params?: PlitziSdkProps, renderPlugins?: RenderPlugins, debugMode?: boolean, ssrMode?: boolean, { hotPlugins }?: RenderOptions): {
46
62
  unmount: () => void;
63
+ /**
64
+ * Swaps a plugin where it is drawn, with `hotPlugins` on: `false` when it cannot be swapped in place — not
65
+ * registered by this page, or its declaration changed — and the page should load again.
66
+ */
67
+ replacePlugin: (key: string, component: PluginComponent) => boolean;
47
68
  } | undefined;
48
69
  declare global {
49
70
  interface Window {
@@ -98,6 +119,9 @@ export type PlitziSdkProps = {
98
119
  overQuota?: boolean;
99
120
  externalStyle?: string;
100
121
  sdkDevToolsStylePath?: string;
122
+ /** Where Font Awesome's sheet is served, for the panels the SDK draws in a root of their own (the dev tools, the
123
+ * `iframe` and `shadow` render modes). Defaults to `/plitzi-sdk-icons.css`, beside the SDK's own stylesheet. */
124
+ sdkIconsStylePath?: string;
101
125
  /** Where this render reports SPA navigations and interactions, and with what key. Injected by a server that
102
126
  * renders the page; derived from `server` + `webKey` for a client-side render; absent means report nothing. */
103
127
  analytics?: AnalyticsConfig;
@@ -134,8 +158,8 @@ declare const PlitziSdk: {
134
158
  };
135
159
  type PlitziServiceContextValue = BasePlitziServiceContextValue<InstanceType<typeof EventBridge>, InstanceType<typeof InteractionsManager>>;
136
160
  declare const usePlitziServiceContext: () => PlitziServiceContextValue;
137
- export { track, useSdkStore as useStore, ComponentProvider, ComponentContext, usePlitziServiceContext, PlitziServiceProvider, RootElement, withElement, JsxManager, PluginManager, sdkComponents, PluginRemote, ReplicaProvider, useElement, useRscData, useRscRefresh, useChannel, useFlag, useAnimationFrame, useReducedMotion, useCanvas2d, useWebGL, useWebGL2, createShaderProgram, ShaderError };
138
- export type { AnalyticsConfig, ElementContextValue, Element, Schema, Style, ComponentPlugin, ComponentPluginFC, PlitziServiceContextValue, OfflineDataRaw, InteractionCallback, InteractionCallbackParamValues, PluginDeclaration, ChannelHandle, RealtimeMember, RealtimeMessage, CanvasHandle, CanvasOptions, CanvasSize, Frame };
161
+ export { track, useSdkStore as useStore, ComponentProvider, ComponentContext, usePlitziServiceContext, PlitziServiceProvider, RootElement, withElement, JsxManager, PluginManager, sdkComponents, PluginRemote, ReplicaProvider, useElement, useRscData, useElementVisible, elementChildren, useDisplayMode, useRscRefresh, usePluginRoute, useChannel, useFlag, useAnimationFrame, useReducedMotion, useCanvas2d, useWebGL, useWebGL2, createShaderProgram, ShaderError };
162
+ export type { AnalyticsConfig, ElementContextValue, Element, Schema, Style, ComponentPlugin, ComponentPluginFC, PlitziServiceContextValue, OfflineDataRaw, InteractionCallback, InteractionCallbackParamValues, PluginDeclaration, ChannelHandle, ElementChild, RealtimeMember, RealtimeMessage, CanvasHandle, CanvasOptions, CanvasSize, Frame };
139
163
  export declare const version: string;
140
164
  export declare const getStateManager: () => RuntimeStateInstance;
141
165
  export declare const getEventBridge: () => EventBridgeContextValue;
package/dist/index.html CHANGED
@@ -30,21 +30,9 @@
30
30
  }
31
31
  </script>
32
32
 
33
- <link
34
- rel="preload"
35
- href="https://fonts.googleapis.com/icon?family=Material+Icons"
36
- as="style"
37
- onload="
38
- this.onload = null;
39
- this.rel = 'stylesheet';
40
- "
41
- />
42
- <noscript>
43
- <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
44
- </noscript>
45
-
46
33
  <link href="/plitzi-sdk.css" rel="preload" as="style" />
47
34
  <link href="/plitzi-sdk.css" rel="stylesheet" />
35
+ <link href="/plitzi-sdk-icons.css" rel="stylesheet" />
48
36
  </head>
49
37
 
50
38
  <body>
@@ -14,6 +14,7 @@ export type AppMainProps = {
14
14
  renderMode?: RenderMode;
15
15
  sdkStylePath?: string;
16
16
  sdkDevToolsStylePath?: string;
17
+ sdkIconsStylePath?: string;
17
18
  previewMode?: boolean;
18
19
  debugMode?: boolean;
19
20
  /** Set by the server that metered this render: the account behind this space is over its quota. */
@@ -33,5 +34,5 @@ export type AppMainProps = {
33
34
  onInitStateManager?: (instance: RuntimeStateInstance) => void;
34
35
  onInitEventBridge?: (instance: EventBridgeContextValue) => void;
35
36
  };
36
- declare const AppMain: ({ revision, webKey, webId, environment, currentPageId, server, isHydrating, offlineMode, offlineData, offlineDataType, instanceId, renderMode, sdkStylePath, sdkDevToolsStylePath, previewMode, debugMode, overQuota, analytics, onInitEventBridge, hostData, hostActions, flags, serverFlags, forcedFlags, onInitStateManager, ...sdkProps }: AppMainProps) => import('react').JSX.Element;
37
+ declare const AppMain: ({ revision, webKey, webId, environment, currentPageId, server, isHydrating, offlineMode, offlineData, offlineDataType, instanceId, renderMode, sdkStylePath, sdkDevToolsStylePath, sdkIconsStylePath, previewMode, debugMode, overQuota, analytics, onInitEventBridge, hostData, hostActions, flags, serverFlags, forcedFlags, onInitStateManager, ...sdkProps }: AppMainProps) => import('react').JSX.Element;
37
38
  export default AppMain;
@@ -3,6 +3,7 @@ export type PluginsContextProviderProps = {
3
3
  children: React.ReactNode;
4
4
  plugins?: Record<string, ComponentDefinition>;
5
5
  sdkStylePath?: string;
6
+ sdkIconsPath?: string;
6
7
  };
7
- declare const PluginsContextProvider: ({ children, plugins: pluginsProp, sdkStylePath }: PluginsContextProviderProps) => import('react').JSX.Element;
8
+ declare const PluginsContextProvider: ({ children, plugins: pluginsProp, sdkStylePath, sdkIconsPath }: PluginsContextProviderProps) => import('react').JSX.Element;
8
9
  export default PluginsContextProvider;
@@ -0,0 +1,21 @@
1
+ import { ComponentPluginFC, PluginDeclaration } from '@plitzi/sdk-shared';
2
+ export type PluginComponent = ComponentPluginFC<any> & {
3
+ plugins?: Record<string, PluginComponent>;
4
+ };
5
+ /** A plugin this page draws none of: what it declares now, its code and stylesheet when a page draws it. */
6
+ export type DeferredPlugin = {
7
+ load: () => Promise<{
8
+ default: PluginComponent;
9
+ }>;
10
+ css?: string | null;
11
+ declaration: PluginDeclaration;
12
+ };
13
+ /**
14
+ * The plugin registered as `key`, standing in for itself until it is drawn.
15
+ *
16
+ * It carries the declaration — the definition, the sub-plugins, each a stand-in of its own — so the space knows its
17
+ * types from the start. The first one drawn loads the code and the stylesheet, once, before anything of it mounts: the
18
+ * stylesheet first, or the plugin would paint unstyled for a frame. Its own `Suspense`, so only the element waits and
19
+ * not the page around it.
20
+ */
21
+ export declare const deferredPlugin: (key: string, { load, css, declaration }: DeferredPlugin) => PluginComponent;
@@ -0,0 +1,17 @@
1
+ import { ComponentPluginFC } from '@plitzi/sdk-shared';
2
+ type PluginComponent = ComponentPluginFC<any>;
3
+ /**
4
+ * Plugins a development page can swap while it runs: each one is registered as a proxy that never changes and
5
+ * renders whichever component is current, so swapping one re-mounts the elements of that type alone — the rest of the
6
+ * page, its state and its scroll, stays as it was. A plugin's own state starts again: it is a new component.
7
+ *
8
+ * The proxy carries the plugin's statics (its declaration, its settings panel) as the original did, so nothing that
9
+ * reads them can tell the difference.
10
+ */
11
+ export declare const createHotPlugins: <T extends {
12
+ component: PluginComponent;
13
+ }>(plugins: Record<string, T>) => {
14
+ plugins: Record<string, T>;
15
+ replace: (key: string, next: PluginComponent) => boolean;
16
+ };
17
+ export {};