@plitzi/plitzi-sdk 0.38.13 → 0.38.15

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,278 @@
1
1
  # @plitzi/plitzi-sdk
2
2
 
3
+ ## 0.38.15
4
+
5
+ ### Patch Changes
6
+
7
+ - 6cdd5cf: ## Security
8
+
9
+ - **A write another site caused is refused, cookie or none** (`@plitzi/sdk-server`, `@plitzi/sdk-shared`): the page
10
+ server guarded nothing it answers past `/auth` — a server action (`/_action`), a realtime publish, a space's `/fn/`
11
+ route, its runtime's endpoints, the deployment's own `data` stages, the adapter-only `loginPath`, `logoutPath` and
12
+ `exchangePath`. A plain `text/plain` POST from any page open in the same browser ran them, with the visitor's session
13
+ cookie when there was one (`SameSite=None` off this machine) and, in a project nobody signs in to, as whoever holds
14
+ the server's own credentials. Every unsafe request a browser says another site caused (`Sec-Fetch-Site: cross-site`,
15
+ or a foreign `Origin`) is now refused `403 reason: 'foreign'`, saying how to allow it: `crossSiteWrites.origins`
16
+ (with `auth`, `identity.platformOrigins` too) and `crossSiteWrites.paths` for a form other sites post to by design.
17
+ `Authorization`, and callers that are not browsers — webhooks, scripts — pass as before. One rule for this and the
18
+ sign-in check (`crossSiteRequest`, `csrf.ts`). A self-hosted runtime's endpoints now sit where the platform forwards a
19
+ space's — after the auth chain and this guard (`data`, was `preAuth`).
20
+
21
+ ## Testing
22
+ - **`page check` and `page shot` anywhere the project is served** (`@plitzi/cli`): `--url <origin>` for a second server
23
+ of it, staging or a deploy, instead of `npm start`'s port; `page check --space <module>` holds the pages to that space
24
+ instead of the project's — an agent's page — authored with `authorIsolated`.
25
+ - **A route with a query is checked as its page** (`@plitzi/cli`): `page check "/?v=2"` matched the query as part of
26
+ the path, found no page, and checked the space's "not found" page in its place.
27
+
28
+ - **What an element that chooses its children draws is checked** (`@plitzi/sdk-authoring`, `@plitzi/cli`): with
29
+ `choosesChildren`, the page checks owed none of its children — and checked none of them either: a dashboard drawing
30
+ three panels reported `checked: 1`. Each child it may draw, and what is inside one under no condition of its own,
31
+ now carries `shownWith` (the child it comes with) on its handle: once that child is on screen it and everything
32
+ named in it are owed like the rest of the page, and `checked` counts them. `onScreenIfChosen(handles, page)` lists
33
+ them.
34
+ - **A page that met a server error is looked at once more** (`@plitzi/cli`): `page check` and `verify` failed a page
35
+ for a `500` from somebody else's service having a bad second (`/fn/<space>/weather`), and passed on the next run with
36
+ nothing changed. A page whose requests got a `5xx` is checked again once; its report is the second look, and says
37
+ what failed the first time (`retriedAfter`). A `4xx` fails the same way twice, and is never retried.
38
+
39
+ ## Plugins
40
+ - **`useNotify`** (`@plitzi/plitzi-sdk`): a plugin shows the page's notifications — `notify('Deleted 79 recordings', {
41
+ appearance: 'danger' })` — the same toasts an `addNotification` step shows, in the space's theme and `notifications`
42
+ look, with no trigger, flow or `window` event of the space's to wire. The step's vocabulary (`NOTIFICATION_PLACEMENTS`,
43
+ `NOTIFICATION_APPEARANCES`, `NOTIFICATION_DEFAULTS`) is one list in `@plitzi/sdk-shared`, read by both.
44
+ - **`appearance: 'danger'` looks like one** (`@plitzi/plitzi-sdk`): it reached the toast library as a type it does not
45
+ know, so a danger notification showed neither the error icon nor the colour `notifications.danger` sets.
46
+ A value a notification does not take — from a flow, or a plugin in plain JavaScript — is set aside by name and said
47
+ in the console, rather than shown as the default in silence (`readNotificationOptions`, `@plitzi/sdk-shared`).
48
+ - **`useServerAction`** (`@plitzi/plitzi-sdk`, `@plitzi/sdk-authoring`, `@plitzi/sdk-interactions`,
49
+ `@plitzi/sdk-server`): a plugin runs one of the space's server actions, awaited —
50
+ `useServerAction<typeof habitDone>('habits-done')({ id })` answers `{ ok, output }` or `{ ok: false, reason, error }`
51
+ — through the `runServerAction` step itself: the same access, refusals, session handling and dev-tools entry.
52
+ `defineAction` keeps the literal types of its `call` way in, so the input is typed by the fields it declares (the
53
+ required ones required); `taskAction` types both ends from the task's `run`, and `FunctionTask<T, R>` takes what
54
+ `run` answers. `CallInputOf` / `CallOutputOf` read them. One operation is one action, never a `case` in one route.
55
+ What a run answers is typed (`ServerActionStatus`): a status the server never uses reads as a run that did not
56
+ complete, never as one that did.
57
+ The key those types ride under (`CALL_TYPES`) is exported, by `@plitzi/sdk-shared` and `@plitzi/sdk-authoring` with
58
+ `TypedActionEntry`, `CallInputOf` and `CallOutputOf`: a package that emits declarations could not write the type of an
59
+ action it exports (`TS4023` on every `export const actions = [defineAction(…)]`).
60
+ - **A plugin is drawn on the server first** (docs): a preference per device belongs in kept state (`keepState`,
61
+ `paintedState`) as a bound prop, never read from `localStorage` while rendering — React discards the whole tree on the
62
+ mismatch, and only in the browser of whoever saved something. `@plitzi/plitzi-ui` is not the page's: a plugin
63
+ importing it bundles its own copy, with its own contexts and its own look. The authoring skill's `plugin-reach.md`
64
+ says what a plugin says and to whom: a notification, another element (an event and the space's flow), a server
65
+ action, shared state, other pages.
66
+
67
+ ## Realtime
68
+ - **A channel that retains** (`@plitzi/sdk-shared`, `@plitzi/sdk-server`, `@plitzi/sdk-elements`): declared
69
+ `retain: true` (with `publish: 'server'`, which authoring requires), the server keeps the latest message of each type
70
+ on a topic — said by `ctx.publish` or a flow's `realtime.publish` — and hands them to every page that joins, marked
71
+ `retained`. A page reads them as `<channel>.retained.<type>`, a plugin as `useChannel(topic).retained`, the newest of
72
+ a type holding whichever order they arrive in; `null` forgets a type. Kept in the store the actions' `kv` uses (beside
73
+ the grants, by compare-and-swap), so every replica hands out the same; a topic keeps at most 64 types and 512 KB, and
74
+ a publish past that is refused before anything is sent. State every screen shares is one publish and one binding —
75
+ no kv key, initial read or copy in `state` of the project's own. The fleet store `realtime.grants` is now
76
+ `realtime.kv`.
77
+ - **The MCP writes every field a channel takes** (`@plitzi/sdk-mcp`): `patchSettings`'s channel had no `grant` — which
78
+ the guide taught — nor `retain` or the limits, so an agent could not declare a private channel at all. All are there
79
+ now, and the guide says what `retain` is for and that `channel_<id>.retained` holds it.
80
+
81
+ ## Authoring
82
+ - **`plitzi explain` knows every `@plitzi` package installed** (`@plitzi/cli`): a name that was not
83
+ `@plitzi/sdk-authoring`'s (`createServer`, `createJsonAdapters`, `useChannel`) was answered as the project's own code,
84
+ to `grep` in `src/`. It is read from the published types of every one installed, through their re-exports and entry
85
+ points (`@plitzi/sdk-server/handlers`), and a name two packages export — `createServer` is sdk-server's and sdk-mcp's
86
+ — is answered with both.
87
+
88
+ - **A space module somebody else wrote, authored where it reaches nothing** (`@plitzi/sdk-authoring`):
89
+ `authorIsolated(file, { timeoutMs })` of `@plitzi/sdk-authoring/node` runs `authorSpace` on it in a process Node's
90
+ permission model holds to reading the module's folder and its packages — no file written, no process started, no
91
+ variable of the caller's environment — kills one that runs too long, and validates what it answers again, so a forged
92
+ answer gains nothing. A refusal comes back as `authorSpace` says it, with the problems as data.
93
+ - **Pages an agent writes, served** (`@plitzi/sdk-server`): `createAuthoringHost({ dir, frameAncestors })` serves each
94
+ space it is handed at an address of its own (`put(space, { id }) → /?__pt=<id>`) as a draft of its one space, kept in
95
+ `dir` across restarts; `drop(id)` forgets one, and anything else answers `404` saying where the pages are.
96
+ - **A space is chosen by host or credential** (`@plitzi/sdk-server`, docs): `getSpaceDeployment` is asked on every
97
+ request, and what a page fetches after it carries nothing of its address but the host — a space chosen by the page's
98
+ query or path lost everything it asked for, and `/_plitzi/space/<hash>.json` answered a bare `404`. The contract and
99
+ the README say so (the README offered "by path prefix"), and that `404` says why.
100
+
101
+ - **`plitzi explain on` says how to read what a trigger carries** (`@plitzi/sdk-authoring`): its doc sat above a
102
+ helper, so `explain` printed only the signature. It now leads with `[named('picked', on('onPick')), …('{{ picked.seat
103
+ }}')]`, and the CLI skill's plugin section says the same.
104
+
105
+ - Updated dependencies [6cdd5cf]
106
+ - @plitzi/sdk-auth@0.38.15
107
+ - @plitzi/sdk-dev-tools@0.38.15
108
+ - @plitzi/sdk-elements@0.38.15
109
+ - @plitzi/sdk-event-bridge@0.38.15
110
+ - @plitzi/sdk-interactions@0.38.15
111
+ - @plitzi/sdk-navigation@0.38.15
112
+ - @plitzi/sdk-plugins@0.38.15
113
+ - @plitzi/sdk-schema@0.38.15
114
+ - @plitzi/sdk-shared@0.38.15
115
+ - @plitzi/sdk-style@0.38.15
116
+ - @plitzi/sdk-variables@0.38.15
117
+
118
+ ## 0.38.14
119
+
120
+ ### Patch Changes
121
+
122
+ - 493955a: ## SDK
123
+
124
+ - **An embedded space leaves the page's theme alone** (`@plitzi/plitzi-sdk`, `@plitzi/plitzi-builder`): plitzi-ui's
125
+ `Provider` stamps `dark` on `<html>` by default — and, being `light`, takes it off — so every space mounted with
126
+ `themeScope: 'container'` turned the page around it light, and nothing put it back. The SDK and the builder now leave
127
+ the class to their own theme provider (`applyColorModeClass={false}`).
128
+ - **A space inside a space** (`@plitzi/plitzi-sdk`, `@plitzi/sdk-shared`): one drawn inside another — the `plitziSdk`
129
+ element, a plugin rendering one, the builder's canvas — knows it (`render.enclosed`). It is `container` unless it
130
+ says otherwise, wears its theme on its own root and starts from the page's when its own is `system`, keeps its
131
+ stylesheet to its own root (`@scope` — its `:root` palette and `.dark` rules repainted the outer page, its
132
+ `.plitzi-sdk` rule restyled the outer root), writes no `<title>` (`ownsHead`) and no `theme` cookie.
133
+ - **The `plitziSdk` element draws** (`@plitzi/plitzi-sdk`): it rendered in `widget` mode with no page to show, so it
134
+ drew nothing. A widget with no `currentPageId` now shows the page its home address would. And it takes a space's
135
+ documents as well as a key: `offlineData`, bound whole (an `apiContainer`'s answer, a runtime's route, what
136
+ `plitzi_render` returns) or as `offlineData.schema` and `offlineData.style` from two elements — waiting, without an
137
+ error, for the half that has not answered; one that cannot be drawn is said why, in the console and on the canvas.
138
+ - **`<PlitziSdk>` inside a plugin draws** (`@plitzi/plitzi-sdk`): it mounted a router of its own inside the page's, and
139
+ React Router refused it — `routing: 'memory'` or not. A space inside another is a widget: `raw` becomes `widget`
140
+ there, one page and no router (a frame of its own, `iframe` or `shadow`, is left as asked).
141
+ - **A space inside another is as tall as what it holds** (`@plitzi/plitzi-sdk`): its root was `min-h-screen`, as a
142
+ space that IS the page is, so a card of three lines drawn in a panel took the window's height.
143
+ - **`<PlitziSdk.Plugin component>` takes a component with its own props** (`@plitzi/plitzi-sdk`), as `render()`'s
144
+ plugins do: typed `ComponentPluginFC`, it refused any component that read its attributes.
145
+ - **An edited page keeps its address in step** (`@plitzi/plitzi-sdk`): the routes are built from the pages' own
146
+ elements, and those were read again only when the list of pages changed — an edit to one page (its slug, its flag)
147
+ leaves that list the same, and the routes kept its old address until something else rebuilt them.
148
+ - **Packages declare only what they use** (`@plitzi/sdk-dev-tools`, `@plitzi/sdk-shared`): `@plitzi/sdk-plugins`, which
149
+ the dev tools no longer import, and `terser`, which no build here runs, are no longer dependencies.
150
+ - **An edited page keeps its route up to date** (`@plitzi/plitzi-sdk`): the routes are built from the pages' own
151
+ elements, which were read again only when the list of pages changed — an edit to one page (its slug, its flag) left
152
+ the list the same and the route at the old address. They follow every edit to a page now, and stay the same object
153
+ while no page changes.
154
+ - **`@plitzi/sdk-dev-tools` no longer depends on `@plitzi/sdk-plugins`**, which nothing in it imports.
155
+ - **A dropdown's menu opens inside a card that lifts or clips** (`@plitzi/sdk-elements`, `@plitzi/sdk-shared`): drawn
156
+ inside the dropdown, an ancestor with a `transform` — a card lifting on hover — made itself the containing block of
157
+ the menu's `position: fixed`, and one with `overflow: hidden` cut it off: the menu opened and nobody saw it. The open
158
+ menu and its backdrop are drawn at the space's root (`spaceRootOf`, `@plitzi/sdk-shared/helpers/spaceRoot`); a
159
+ style written for the popup by an ancestor's selector no longer reaches it — its own classes do.
160
+ - **A copy button says when it could not copy** (`@plitzi/sdk-elements`, `@plitzi/sdk-shared`,
161
+ `@plitzi/sdk-interactions`, `@plitzi/sdk-variables`, `@plitzi/sdk-dev-tools`): a page not served over https has no
162
+ clipboard — a phone opening a development server by its address — and a code block's "Copy" threw there. It reads
163
+ "Not copied", and says why. `clipboardWriter` and `copyText` (`@plitzi/sdk-shared/helpers/clipboard`) are the one
164
+ check, the `copyToClipboard` step's too.
165
+
166
+ ## Authoring
167
+ - **`plitziSdk` is authored like any element** (`@plitzi/sdk-authoring`, `@plitzi/sdk-elements`): its declaration moved
168
+ to `@plitzi/sdk-elements` beside the others, so it has a factory — `plitziSdk({ id, bind: { offlineData: 'view.data'
169
+ } })` —, its attributes typed, and `plitzi explain` knows it.
170
+ - **A binding may write part of an attribute** (`@plitzi/sdk-authoring`): `offlineData.schema` writes into
171
+ `offlineData`, as the runtime always did; authoring refused it as an attribute nothing reads.
172
+ - **`choosesChildren`** (`@plitzi/sdk-shared`, `@plitzi/sdk-authoring`): a plugin that shows only some of the elements
173
+ put inside it — a dashboard's panels, a wizard's step — says so in its declaration, and the page checks owe none of
174
+ them on screen; what it draws is still read by the checks of the whole page (images, sideways scroll, legibility).
175
+ `verify` was red on every such page.
176
+
177
+ - **A page says how the document scrolls** (`@plitzi/sdk-elements`, `@plitzi/sdk-authoring`, `@plitzi/sdk-mcp`):
178
+ `documentScroll: 'locked'` holds the document still while the page is open — a dashboard or a board used with a
179
+ finger, where the whole page was dragged and bounced back though nothing in it scrolls — and `'noBounce'` keeps the
180
+ scroll without the rubber band or pull-to-refresh. The page draws the rule itself, so it is in the server's HTML and
181
+ leaves with the page; never inside a widget, a space drawn in another, or the builder's canvas. A Settings select,
182
+ `PageSpec.documentScroll`, `upsertPage`'s `documentScroll` (`null` undoes it) and the page read; an unknown value is
183
+ refused (`attribute-value`). `upsertPage` is now held to the lint of the page it writes, as element writes are.
184
+
185
+ ## MCP
186
+ - **`@plitzi/sdk-mcp/render`** (`@plitzi/sdk-mcp`): `plitzi_render`'s widget render on its own — no MCP server, no SSR,
187
+ no OAuth — for a project whose own agent draws in its own pages: `render`, `renderWidgetShape` to declare it as a
188
+ tool, `renderGuideText` for the agent. `base`, the style of the project's space, brings its tokens, classes and fonts
189
+ to the widget.
190
+
191
+ ## Server
192
+ - **`publicUrl` says where people reach the server** (`@plitzi/sdk-server`): it was `http://127.0.0.1:<port>` whatever
193
+ the server was. It is `https` once `serverOptions.tls` gives it a certificate, and this machine's network address
194
+ with `HOST` open to the network (what a tablet opens, what an OAuth provider sends it back to); `PUBLIC_URL` still
195
+ wins. The network addresses it prints say `https` too.
196
+ - **A server serving TLS reaches itself** (`@plitzi/sdk-server`): with a local certificate (mkcert) Node trusts nothing
197
+ the browsers were told to, so a runtime calling its own MCP failed. Its requests to its own address now connect to its
198
+ listener and are taken when it presents exactly its certificate (`reachOwnServer`, exported from `/runtime`).
199
+ - **A runtime reads compressed answers again** (`@plitzi/sdk-server`): the dispatcher `reachOwnServer` (and the
200
+ platform's `reachSpaceInside`) installs reached every other host with an undici connector that offers HTTP/2, and an
201
+ answer that came back over h2 reached Node's `fetch` without its `content-encoding` — every API that compresses read
202
+ as Brotli bytes. Other hosts are reached over HTTP/1.1 now, as Node's own `fetch` reaches them.
203
+ - **A project's server serves HTTPS from `.env`** (`@plitzi/sdk-server`, `@plitzi/sdk-shared`): `TLS_CERT` and
204
+ `TLS_KEY`, the certificate's and the key's paths — what `plitzi cert` writes — with no code of the project's;
205
+ `serverOptions.tls` still wins. A network address the certificate does not name is said at boot, the machine's
206
+ `.local` name is printed among the addresses when it is named, and a server on loopback alone says how to open it to
207
+ the network.
208
+ - **A session survives a phone on the Wi-Fi** (`@plitzi/sdk-server`): a private network address (`192.168.…`, `10.…`,
209
+ Tailscale's `100.64/10`, IPv6 unique- and link-local) and a machine's mDNS name (`studio.local`) get the local
210
+ cookie profile — `SameSite=Lax`, no `Secure`, no `Domain`. They got `SameSite=None; Secure`, which a browser drops
211
+ over http: nobody could sign in from a tablet. A deployment's own `.local` sub-domains (`app.example.local`) keep the
212
+ strict profile.
213
+ - **Hiding the dev tools on a server over HTTPS hydrates** (`@plitzi/sdk-server`): a server with a certificate speaks
214
+ HTTP/2, which sends no `Host` — only `:authority` — and the cookies named for the origin's port (the dev tools'
215
+ `plitzi_debug_<port>`, forced flags, painted state) were looked for without it. Shift+F12 hid the dev tools in the
216
+ browser, the server rendered them back, and the page failed to hydrate. Every one is read off `requestAuthority`.
217
+ - **A rebuild of plugins says it finished** (`@plitzi/sdk-server`): bundles removed under a running server (`tmp/`
218
+ deleted) were each a warning, "rebuilding…", and their "ready" at a level a project's terminal does not show. It is
219
+ one episode now: said when noticed, and again when the last is built — how many, how long, which failed.
220
+ - **`tmp/dev-server.json` records the scheme** (`@plitzi/sdk-server`): `url` is `https` with a certificate, and the
221
+ file adds the network addresses and the `publicUrl`.
222
+ - **`public/` is asked about every time** (`@plitzi/sdk-server`): it was cached for an hour — a `.js` or `.css` in it
223
+ for a year, `immutable` — so a file a project rewrites while it runs arrived stale. It is `no-cache` now, answered
224
+ `304` by its `ETag` while unchanged; `immutable` stays for what is versioned (the SDK, the plugins).
225
+
226
+ ## CLI
227
+ - **`check`, `shot`, `verify` and `visual` find a server on HTTPS** (`@plitzi/cli`): they rebuilt
228
+ `http://127.0.0.1:<port>`, so a project serving a certificate had no page checked. They read the URL `npm start`
229
+ recorded, and take a local certificate on this machine only. A project's `playwright.config.ts` comes from
230
+ `plitzi upgrade`.
231
+ - **`verify` runs the project's tests** (`@plitzi/cli`): a step `test`, after the lint, when `package.json` has a
232
+ `test` script.
233
+ - **`tsconfig.json` is the project's** (`@plitzi/cli`): the compiler options moved to `plitzi/tsconfig.base.json`, which
234
+ the CLI keeps up and `tsconfig.json` extends — so a folder of the project's own (`scripts/`, `tools/`) goes in its
235
+ `include` without changing a file of the CLI's. `plitzi doctor --fix` makes an older `tsconfig.json` extend it,
236
+ keeping only the options the project changed.
237
+ - **`doctor --fix` and `upgrade` write as the project's Prettier does** (`@plitzi/cli`): a repaired `tsconfig.json` or
238
+ `package.json` left `verify`'s format step red.
239
+ - **`upgrade` renames `usePlitziServiceContext`** (`@plitzi/cli`): with `PlitziServiceProvider` and
240
+ `PlitziServiceContextValue`, renamed in 0.38.12 with no alias — import, use and the module path that named it.
241
+ - **`skills update` compares every file** (`@plitzi/cli`): only `SKILL.md` was, so a change in a reference alone was
242
+ "up to date".
243
+ - **`NOTES.md`, the project's notes for agents** (`@plitzi/cli`): `AGENTS.md` and `CLAUDE.md` are the CLI's and
244
+ `upgrade` replaces them, so what a project's own sessions had to know had nowhere to live. `CLAUDE.md` imports
245
+ `NOTES.md`, `AGENTS.md` sends every agent to it, and nothing the CLI does touches it; `doctor --fix` writes one for
246
+ a project that has none.
247
+
248
+ - **`start:dev-inspect`** (`@plitzi/cli`): a server project's `start:dev` with Node's inspector open on
249
+ 127.0.0.1:9229, so a debugger (VS Code, `chrome://inspect`) attaches to the server, and again after each restart.
250
+ `plitzi upgrade` adds it; `plitzi runtime add` has it restart on the runtime too.
251
+ - **`plitzi cert`** (`@plitzi/cli`): HTTPS while developing, for a phone or a tablet on the Wi-Fi — over http its
252
+ browser gives a page no microphone, camera or clipboard. A certificate from mkcert's local authority for this machine,
253
+ its network addresses and its `.local` name, in `tmp/tls/`, named in `.env`; what to install on the phone, said.
254
+ - **A browser project opens to the network** (`@plitzi/cli`): its `vite.config.ts` reads `HOST`, `TLS_CERT` and
255
+ `TLS_KEY` from `.env`, as a server project does, and writes `tmp/dev-server.json` — the port Vite took and the scheme
256
+ — so `page check`, `page shot` and `visual` find it on another port or over HTTPS. `plitzi upgrade` brings it.
257
+
258
+ ## Docs
259
+ - **Two plugins share through `state`** (`@plitzi/sdk-authoring` skill): each plugin is a bundle of its own, so a module
260
+ both import is two copies, and what one keeps there the other never sees.
261
+ - **`verify --help`** names the project's tests among its steps.
262
+
263
+ - Updated dependencies [493955a]
264
+ - @plitzi/sdk-auth@0.38.14
265
+ - @plitzi/sdk-dev-tools@0.38.14
266
+ - @plitzi/sdk-elements@0.38.14
267
+ - @plitzi/sdk-event-bridge@0.38.14
268
+ - @plitzi/sdk-interactions@0.38.14
269
+ - @plitzi/sdk-navigation@0.38.14
270
+ - @plitzi/sdk-plugins@0.38.14
271
+ - @plitzi/sdk-schema@0.38.14
272
+ - @plitzi/sdk-shared@0.38.14
273
+ - @plitzi/sdk-style@0.38.14
274
+ - @plitzi/sdk-variables@0.38.14
275
+
3
276
  ## 0.38.13
4
277
 
5
278
  ### Patch Changes
package/dist/App.d.ts CHANGED
@@ -39,6 +39,9 @@ export type AppProps = {
39
39
  * a theme of its own (the desktop window, a component mounted in a host): it wears the class on its own root and
40
40
  * keeps a theme store of its own, so toggling it never reaches the application around it, and two spaces in one
41
41
  * document do not answer for each other.
42
+ *
43
+ * Left out, it is `container` for a space drawn inside another (the `plitziSdk` element, a plugin rendering one) and
44
+ * `document` otherwise.
42
45
  */
43
46
  themeScope?: ThemeScope;
44
47
  /** The theme the host already settled — from the cookie a server read before it rendered the document. */
@@ -60,5 +63,5 @@ export type AppProps = {
60
63
  onInitStateManager?: (instance: RuntimeStateInstance) => void;
61
64
  onInitEventBridge?: (instance: EventBridgeContextValue) => void;
62
65
  };
63
- declare const App: ({ className, children, webKey, server, renderMode, routing, debugMode: debugModeProp, themeScope, theme, state, forcedFlags, ...sdkProps }: AppProps) => import('react').JSX.Element;
66
+ declare const App: ({ className: classNameProp, children, webKey, server, renderMode: renderModeProp, routing, debugMode: debugModeProp, themeScope: themeScopeProp, theme, state, forcedFlags, ...sdkProps }: AppProps) => import('react').JSX.Element;
64
67
  export default App;
package/dist/index.d.ts CHANGED
@@ -22,12 +22,15 @@ import { default as usePluginRoute } from '@plitzi/sdk-shared/server/usePluginRo
22
22
  import { useSdkStore } from '@plitzi/sdk-shared/store';
23
23
  import { default as useDisplayMode } from '@plitzi/sdk-shared/style/useDisplayMode';
24
24
  import { default as useElementSize } from '@plitzi/sdk-shared/style/useElementSize';
25
+ import { default as useServerAction, ServerActionOptions, ServerActionResult } from './modules/Actions/useServerAction';
25
26
  import { track } from './modules/Analytics';
27
+ import { default as useNotify, Notify } from './modules/Space/useNotify';
26
28
  import { DeferredPlugin, PluginComponent } from './modules/Sdk/deferredPlugins';
27
29
  import { ElementContextValue } from '@plitzi/sdk-elements/Element/ElementContext';
28
30
  import { EventBridgeContextValue } from '@plitzi/sdk-event-bridge';
29
31
  import { ActionRunSummary, AnalyticsConfig, Element, Schema, Style, ComponentPluginFC, ComponentPlugin, InteractionCallback, InteractionCallbackParamValues, Environment, HostActions, OfflineDataRaw, RenderMode, Server, RuntimeStateInstance, Theme, ThemeScope, PlitziContextValue, RealtimeMessage } from '@plitzi/sdk-shared';
30
32
  import { PluginDeclaration } from '@plitzi/sdk-shared/authoring/declare';
33
+ import { NotificationOptions } from '@plitzi/sdk-shared/authoring/spaceCallbacks';
31
34
  import { RealtimeMember } from '@plitzi/sdk-shared/realtime';
32
35
  import { ReactNode } from 'react';
33
36
  /**
@@ -144,11 +147,13 @@ export type PlitziSdkProps = {
144
147
  */
145
148
  hostActions?: HostActions;
146
149
  /**
147
- * Whose theme this space follows and repaints. `document` (the default) is a space that IS the page.
150
+ * Whose theme this space follows and repaints. `document` (the default for a space on its own) is a space that IS
151
+ * the page.
148
152
  *
149
153
  * `container` is a space EMBEDDED in an application with a theme of its own: it wears the class on its own root
150
154
  * and keeps a theme store of its own, so toggling it never reaches the application around it, and two spaces in
151
- * one document do not answer for each other.
155
+ * one document do not answer for each other. A space drawn inside another one — the `plitziSdk` element, a plugin
156
+ * rendering a space — is `container` unless it says otherwise.
152
157
  */
153
158
  themeScope?: ThemeScope;
154
159
  /** The theme the host already settled — from the cookie a server read before it rendered the document. */
@@ -158,8 +163,8 @@ declare const PlitziSdk: {
158
163
  ({ debugMode, isHydrating, children, webKey, environment, renderMode, ...otherProps }: PlitziSdkProps): import('react').JSX.Element;
159
164
  Plugin: (_props: import('./modules/Sdk/SdkPlugin').SdkPluginProps) => undefined;
160
165
  };
161
- export { track, useSdkStore as useStore, ComponentProvider, ComponentContext, PluginsContext, usePlitzi, PlitziProvider, RootElement, withElement, JsxManager, PluginManager, sdkComponents, PluginRemote, ReplicaProvider, useElement, useRscData, useElementVisible, usePluginTrigger, elementChildren, useDisplayMode, useElementSize, useRscRefresh, usePluginRoute, useChannel, useFlag, useAnimationFrame, useReducedMotion, useCanvas2d, useWebGL, useWebGL2, createShaderProgram, ShaderError };
162
- export type { AnalyticsConfig, ElementContextValue, Element, Schema, Style, ComponentPlugin, ComponentPluginFC, PlitziContextValue, OfflineDataRaw, InteractionCallback, InteractionCallbackParamValues, PluginDeclaration, PluginTriggerPayload, ChannelHandle, ElementChild, RealtimeMember, RealtimeMessage, CanvasHandle, CanvasOptions, CanvasSize, Frame };
166
+ export { track, useSdkStore as useStore, ComponentProvider, ComponentContext, PluginsContext, usePlitzi, PlitziProvider, RootElement, withElement, JsxManager, PluginManager, sdkComponents, PluginRemote, ReplicaProvider, useElement, useRscData, useElementVisible, usePluginTrigger, useNotify, useServerAction, elementChildren, useDisplayMode, useElementSize, useRscRefresh, usePluginRoute, useChannel, useFlag, useAnimationFrame, useReducedMotion, useCanvas2d, useWebGL, useWebGL2, createShaderProgram, ShaderError };
167
+ export type { AnalyticsConfig, ElementContextValue, Element, Schema, Style, ComponentPlugin, ComponentPluginFC, PlitziContextValue, OfflineDataRaw, InteractionCallback, InteractionCallbackParamValues, PluginDeclaration, PluginTriggerPayload, Notify, NotificationOptions, ServerActionOptions, ServerActionResult, ChannelHandle, ElementChild, RealtimeMember, RealtimeMessage, CanvasHandle, CanvasOptions, CanvasSize, Frame };
163
168
  export declare const version: string;
164
169
  export declare const getStateManager: () => RuntimeStateInstance;
165
170
  export declare const getEventBridge: () => EventBridgeContextValue;
@@ -0,0 +1,35 @@
1
+ import { CallInputOf, CallOutputOf } from '@plitzi/sdk-shared';
2
+ /** What a run answers a plugin: the action's output, or why there is none. */
3
+ export type ServerActionResult<Output> = {
4
+ ok: true;
5
+ runId: string;
6
+ output: Output;
7
+ } | {
8
+ ok: false;
9
+ runId: string;
10
+ /** The server's word — `forbidden`, `invalid_input`, `duplicate`… — or `skipped` where nothing runs actions. */
11
+ reason: string;
12
+ /** Said for the caller, by a step that refused with a reason written for them. */
13
+ error?: string;
14
+ };
15
+ export type ServerActionOptions = {
16
+ /** The same key twice runs once — a second click, a retry. */
17
+ idempotencyKey?: string;
18
+ /** `none` for an action that only reads: by default a completed run refreshes the page's cached requests. */
19
+ invalidateQueries?: 'all' | 'none';
20
+ };
21
+ /**
22
+ * Runs one of the space's server actions from a plugin, awaited — what a flow's `runServerAction` step does, with the
23
+ * same access, the same refusals and the same entry in the dev tools:
24
+ *
25
+ * ```ts
26
+ * import type { habitDone } from '../../space/actions'; // `taskAction(tasks.done, …)` or `defineAction(…)`
27
+ *
28
+ * const done = useServerAction<typeof habitDone>('habits-done');
29
+ * const result = await done({ id }); // the input its `call` way in declares; `result.output` what its task returns
30
+ * ```
31
+ *
32
+ * One operation is one action — a contract the server checks before any code runs — never a `case` in one route.
33
+ */
34
+ declare const useServerAction: <Action = unknown, Output = CallOutputOf<Action>>(actionId: string) => ((input: CallInputOf<Action>, options?: ServerActionOptions) => Promise<ServerActionResult<Output>>);
35
+ export default useServerAction;
@@ -1,12 +1,10 @@
1
- import { Environment } from '@plitzi/sdk-shared';
1
+ import { PlitziSdkAttributes } from '@plitzi/sdk-elements/elements/advanced/PlitziSdk/declaration';
2
2
  import { RefObject } from 'react';
3
- export type PlitziSdkProps = {
3
+ export type PlitziSdkProps = PlitziSdkAttributes & {
4
4
  ref?: RefObject<HTMLElement>;
5
5
  className?: string;
6
- spaceKey?: string;
7
- environment?: Environment;
8
6
  };
9
- declare const PlitziSdk: ({ ref, className, spaceKey, environment }: PlitziSdkProps) => import('react').JSX.Element;
7
+ declare const PlitziSdk: ({ ref, className, spaceKey, environment, offlineData }: PlitziSdkProps) => import('react').JSX.Element;
10
8
  declare const _default: {
11
9
  (props: import('@plitzi/sdk-elements/Element/hocs/withElement').WithElementProps<PlitziSdkProps>): import('react').JSX.Element;
12
10
  displayName: string;
@@ -18,6 +18,7 @@ declare const PlitziSdk: {
18
18
  };
19
19
  definition: {
20
20
  readonly label: "Plitzi Sdk";
21
+ readonly description: "Another space drawn inside this one, as a widget \u2014 its home page, no router of its own: by its key, or from its documents (`offlineData`), bound to UI generated on the fly.";
21
22
  } & {
22
23
  type: string;
23
24
  bindings: NonNullable<import('@plitzi/sdk-shared').ElementDefinition["bindings"]>;
@@ -40,9 +41,6 @@ declare const PlitziSdk: {
40
41
  settings: Record<string, string | number | boolean>;
41
42
  };
42
43
  type: "plitziSdk";
43
- __attributes: Partial<{
44
- environment?: import('@plitzi/sdk-shared').Environment | undefined;
45
- spaceKey?: string | undefined;
46
- }>;
44
+ __attributes: import('@plitzi/sdk-elements/elements/advanced/PlitziSdk/declaration').PlitziSdkAttributes;
47
45
  };
48
46
  export default PlitziSdk;
@@ -0,0 +1,18 @@
1
+ import { OfflineDataRaw } from '@plitzi/sdk-shared';
2
+ export type OfflineDocuments = {
3
+ documents: OfflineDataRaw;
4
+ }
5
+ /** Bound from two sources, one has not answered yet: nothing to draw, and nothing wrong. */
6
+ | {
7
+ waiting: ('schema' | 'style')[];
8
+ } | {
9
+ problem: string;
10
+ };
11
+ /**
12
+ * The documents a `plitziSdk` element was handed, whether they are still on their way, or why they cannot be drawn.
13
+ *
14
+ * They arrive from bindings as often as from an author — an `apiContainer`'s answer whole, or `schema` and `style` from
15
+ * two elements, one answering before the other — so anything may come in, and a half-built value fed to the SDK fails
16
+ * deep inside it, far from the element that was given it.
17
+ */
18
+ export declare const offlineDocuments: (value: unknown) => OfflineDocuments;
@@ -1,8 +1,10 @@
1
- import { Asset, ComponentDefinition, ComponentPluginFC } from '@plitzi/sdk-shared';
1
+ import { PluginComponent } from './deferredPlugins';
2
+ import { Asset, ComponentDefinition } from '@plitzi/sdk-shared';
2
3
  import { FC } from 'react';
3
4
  export type SdkPluginProps = {
4
5
  renderType: string;
5
- component: ComponentPluginFC;
6
+ /** The component, taking its element's attributes as props — as `render()`'s plugins do (see `RenderPlugins`). */
7
+ component: PluginComponent;
6
8
  settings?: FC<any>;
7
9
  definition?: ComponentDefinition;
8
10
  assets?: Asset[];
@@ -0,0 +1,11 @@
1
+ /**
2
+ * A space's stylesheet, kept to the space when it is drawn inside another one.
3
+ *
4
+ * Every space writes its palette on `:root` and its classes — `.dark`, `.plitzi-sdk`, its own — for the whole
5
+ * document, which is right for a space that IS the page and wrong for one inside it: the inner space's `:root` and
6
+ * `.dark` rules repainted the page around it, its `.plitzi-sdk` rule restyled the outer space's root.
7
+ *
8
+ * `@scope` with no prelude limits the rules to the element the `<style>` hangs from — the SDK's own root, which also
9
+ * wears the inner space's theme class — so `:root` is written `:scope` there, and `.dark` matches only inside.
10
+ */
11
+ export declare const scopeSpaceCss: (css: string) => string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import { NotificationOptions } from '@plitzi/sdk-shared/authoring/spaceCallbacks';
2
+ /** Shows a notification on the page, as the space's `addNotification` step does. */
3
+ export type Notify = (content: string, options?: NotificationOptions) => void;
4
+ export declare const NotifyContext: import('react').Context<Notify>;
5
+ /**
6
+ * The page's notifications, for a plugin: `notify('Deleted 79 recordings')` shows what an `addNotification` step
7
+ * shows — the same toasts, in the space's theme and with the look its `notifications` give them — with no event, flow
8
+ * or step of the space's to wire. `{ appearance: 'danger' }` and the rest take the step's defaults when left out.
9
+ *
10
+ * What the PAGE decides to say stays a flow (`on(…)` → `addNotification`); this is for what only the plugin knows.
11
+ */
12
+ declare const useNotify: () => Notify;
13
+ export default useNotify;