@plitzi/sdk-interactions 0.38.10 → 0.38.12

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,294 @@
1
1
  # @plitzi/sdk-interactions
2
2
 
3
+ ## 0.38.12
4
+
5
+ ### Patch Changes
6
+
7
+ - 1301338: ## Builder
8
+
9
+ - **Icons in the canvas again** (`@plitzi/plitzi-builder`): the canvas inlined the SDK's Font Awesome sheet into its
10
+ `<style>`, where the sheet's `url(webfonts/…)` resolved against the editor's URL — a `srcdoc` frame takes it as its
11
+ base — so every icon was a 404 under `/spaces/<space>/webfonts/` and drew as an empty box. Only the Vite dev server,
12
+ which rewrites the URL, hid it. The canvas and the element preview now link the sheet from where the host serves it:
13
+ a new prop, `sdkIconsStylePath`, the one the host already gives the pages it renders
14
+ (`/sdk-assets/plitzi-sdk-icons.css` for sdk-server). Absent, the canvas links no icon sheet.
15
+
16
+ ## Plugins
17
+ - **A plugin's other elements, hosted by `custom`** (`@plitzi/sdk-elements`): `custom({ renderType: 'jamDisc' })` on a
18
+ space with a plugin installed whose main element is another (`plitzi plugin pack` of several folders: the first is the
19
+ plugin, the rest go in it) rendered "Custom Component jamDisc Not Found" — the page registers only the plugin's main
20
+ element, and a `custom` host looked nowhere else. It now loads the type from the installed plugin that packs it, as
21
+ an element of the type itself always did, so the two ways the docs give to place a plugin's element are the same
22
+ everywhere: in a project `plitzi create` wrote, and once the project is on Plitzi.
23
+ - **One way to place a plugin's element** (`@plitzi/sdk-authoring`, `@plitzi/cli`, docs): from its declaration,
24
+ `const seatPicker = defineElement(declaration)` then `seatPicker({ id, … })` — typed by what it
25
+ declares, and the element the builder adds when somebody drops it. The welcome space `plitzi create` writes, the
26
+ plugin package's preview, `plitzi plugin add` and `plitzi explain` all write it so (the template's
27
+ `PluginHostOptions` now takes the plugin's `type` and `declaration: { from, attributes? }`; `custom`/`element` hosting
28
+ is gone). `pluginFolders(folder)` (`@plitzi/sdk-authoring/node`) reads each plugin with the folder it is in;
29
+ `pluginDeclarations` is built on it. A `custom({ renderType })` naming a plugin the space was handed the declaration
30
+ of is offered the declaration instead — suggestion `plugin-custom-host`. `custom` stays for a component registered
31
+ by name with no declaration. The skills, the CLI README, the MCP guide, `docs/en` and the website say the same.
32
+ - **`definePlugin`** (`@plitzi/sdk-authoring/plugin`, a new entry of 3 KB with nothing else in it): a plugin's
33
+ declaration written from what only it can say —
34
+ `definePlugin<SeatPickerAttributes>()({ type, label, attributes, triggers, callbacks })` — and every other field
35
+ at the default all plugins share (the builder's gestures, the catalogue entry, each attribute bindable, an empty
36
+ style). It answers the whole declaration, branded with its attributes, so `defineElement(declaration)` is typed
37
+ without a generic. `plitzi plugin add` and `create --plugin` write declarations with it (about a third of the lines).
38
+ - **`usePluginTrigger(declaration)`** (`@plitzi/plitzi-sdk`): fires a plugin's declared event on its element — the
39
+ event name and what each hands a flow typed off the declaration's `preview` — on a live page only. The hook every
40
+ plugin wrote for itself (and `plugin add` generated as `use<Name>Events`) is gone from the scaffold.
41
+ - **Attributes as the types their defaults are** (`@plitzi/sdk-elements`): a plugin's attribute bound from text — a
42
+ state, a row, a channel message — reaches its component as the number or the flag its declared default is (`'112'`
43
+ as 112, `'true'` as true). A plugin no longer types its props `number | string` and parses them.
44
+
45
+ ## Server actions and functions
46
+ - **Task params with rules** (`@plitzi/sdk-server`, `@plitzi/sdk-shared`): a task declares `required`, a text's
47
+ `maxLength` and a number's `min`/`max`, and the runner refuses a call that breaks any of them — every rule broken at
48
+ once, in the words the page shows (`Title is required; Seconds is at most 300`) — before the code runs. A `text` param
49
+ bound to a number arrives as its digits. The manifest keeps the rules, so the platform's sandbox checks the same.
50
+ - **`taskAction(task, { trigger })`** (`@plitzi/sdk-authoring`): the action that runs one of the space's tasks and
51
+ answers its result, derived from the task — its id (`<namespace>-<action>`), name, description and input (the task's
52
+ params, once). An action of more than one step is still `defineAction`.
53
+ - **`ctx.rateLimit(bucket, { …, refuse })`**: past the limit the call is refused with those words instead of answering
54
+ `allowed: false` for the code to check — natively and in the sandbox.
55
+
56
+ ## Authoring
57
+ - **`runServerActionOrNotify(id, params, fallback)`**: a server action run and the notice the visitor reads when it
58
+ fails — the action's own refusal, or the fallback — as two steps to spread into a flow.
59
+ - **`repeated-shape` reads what copies bind**: copies whose bindings read their data in different forms (a count, a
60
+ total of a quota) and copies holding a provider resolved on the server (found by its own id) are no longer offered
61
+ as one component.
62
+ - **`element-color-inherited`** (suggestion): `elements` giving a heading, a text, a link… `color: inherit` or the
63
+ page's own colour. **A link inherits the page's colour** (`@plitzi/plitzi-sdk`, `@plitzi/sdk-elements`) rather than
64
+ holding the SDK's grey — the same by default, and the space's palette inside a card that is a link. The template
65
+ every space starts from writes its colours once, on the page.
66
+
67
+ ## Fixes
68
+ - **A dialog opened with an id** (`@plitzi/sdk-elements`): `openDialog('dialog', '{{ row.id }}')` reads the id as its
69
+ `content`, as `openModal` already did — a numeric id parsed as the number and the dialog's bindings read nothing.
70
+ - **A select's chevron** (`@plitzi/plitzi-sdk`): a drawn chevron in the field's own colour, sized by its type, in place
71
+ of the `▼` glyph — and laid out in the box, so it ends where the box's padding begins whatever that padding is, and
72
+ the chosen option stops short of it instead of running under it. A disabled select's is faded.
73
+ - **Every element has its settings** (`@plitzi/plitzi-builder`, `@plitzi/sdk-elements`): the builder found none for
74
+ `tabContainerHeader` (registered under a misspelt type), `themeToggle`, `dropdownPopup`, `loading` and `notFound`.
75
+ The theme toggle's panel sets its mode, its labels and whether it offers "System"; the registry is typed by element
76
+ type and must hold one for each.
77
+ - **A plugin's panel** (`@plitzi/cli`): `plitzi doctor` warns of a plugin with no `Settings.tsx`, or one its entry never
78
+ passes as `pluginSettings` (`plugin-settings-missing`); the example `create` writes has its panel, as every element
79
+ `plugin add` writes does, and the panels it generates are laid out as the project's Prettier lays them out.
80
+ - **A refused or failed run reaches `onFlowError` in every mode** (`@plitzi/sdk-interactions`): an awaited server
81
+ action the server refused fired no `onFlowError` on the element that started it, as `detached` and `stream` ones do
82
+ — a board rolling its edits back on a refusal never did; and a run answered `status: 'failed'` fired `onFlowEnd`
83
+ (detached) or nothing (awaited) rather than `onFlowError`.
84
+ - **A source renamed** (`@plitzi/sdk-shared`): the binding picker lists a provider, a form or a modal by the name its
85
+ element has now, not the one it had when it mounted.
86
+ - **A text's words in the builder** (`@plitzi/sdk-elements`): a `paragraph`, `text` or `heading` whose `content` is
87
+ `0` shows `0` while editing too, not its placeholder; one bound to nothing shows nothing rather than `null`.
88
+ - **Built-in declarations** (`@plitzi/sdk-shared`): `elementDeclaration` fills in what every element shares — the
89
+ builder's gestures, Plitzi's catalogue entry, a visible element with no bindings, its style named by its label —
90
+ from the defaults `definePlugin` uses; each element's declaration says only what is its own (a third of the lines).
91
+
92
+ ## Typed for plugins and hosts
93
+ - **`usePlitzi()` and `PlitziProvider`** (`@plitzi/sdk-shared/hooks/usePlitzi`, `@plitzi/plitzi-sdk`): what were
94
+ `usePlitziServiceContext()` and `PlitziServiceProvider` (and `PlitziServiceContextValue`, now `PlitziContextValue`),
95
+ holding only what the host rendering a space knows — `settings`, `root`, `utils`. Its `contexts` and
96
+ `customContexts` are gone: every context it carried is a shared one already, imported from its own module
97
+ (`@plitzi/sdk-interactions/InteractionsContext`, `@plitzi/sdk-shared/network/NetworkContext`…), and
98
+ `PluginsContext` moves to `@plitzi/sdk-shared/plugins/PluginsContext` beside the others.
99
+ - **`InteractionsManagerApi`** (`@plitzi/sdk-shared`): the interactions manager as everything outside
100
+ `@plitzi/sdk-interactions` reaches it, declared where every package can name it and implemented by
101
+ `InteractionsManager`, so `use(InteractionsContext)` is typed — `interactionTrigger`, `createChildManager`… — where it
102
+ was `any`.
103
+ - **`getPathsFromObject`** (`@plitzi/sdk-shared/helpers/utils`), spelt right; `getPathsFromObeject` is gone.
104
+ - **`ElementWords` places itself** (`@plitzi/sdk-elements`): `contentPlacement` and the element's children, so a button
105
+ and a link write their words once.
106
+
107
+ - Updated dependencies [1301338]
108
+ - @plitzi/sdk-auth@0.38.12
109
+ - @plitzi/sdk-event-bridge@0.38.12
110
+ - @plitzi/sdk-shared@0.38.12
111
+
112
+ ## 0.38.11
113
+
114
+ ### Patch Changes
115
+
116
+ - cadf70a: - **`server.cache.invalidate` drops what a page is rendered from** (`@plitzi/sdk-server`): the pages, the RSC answers
117
+ and the schema data they are rendered from go together. It dropped the pages alone, and the next request rendered
118
+ the same page again from the schema still cached under the same key — a publish that invalidated the space changed
119
+ nothing until the schema's TTL ran out. `clear()` and `size` cover the three. A filter on `hostname` drops the schema
120
+ data too, which belongs to no one host. `server.cache` is `null` only when nothing is cached (`cacheTtlMs: 0` and
121
+ `rsc.cacheTtlMs: 0`).
122
+
123
+ ## Style inspector
124
+ - **Finds a property** (`@plitzi/sdk-style`): a search above the categories narrows them to the ones that edit what was
125
+ typed — a CSS name in any order of its words (`border radius` finds the four corners), a category's title, or a
126
+ common word for it (`bg`, `rounded`) — opens them, and shows the advanced rows when the match lives there. Escape
127
+ clears it. The categories' properties live in one list (`categoryKeys.ts`) that the dots, the advanced hint and the
128
+ search all read.
129
+ - **Rows that fit**: a section with more than two controls puts its label above them and lays them out in as many
130
+ columns as the panel is wide, instead of one row where every label was cut (`Appearan…`, `Cell Spaci…`, the five
131
+ scroll-snap controls). A row's label column is 80px.
132
+ - **Where a value comes from, said quietly**: the label's tint keeps its four meanings — set here, from a token, bound
133
+ to data, inherited — without the solid blocks of colour; hovering says which (an inherited one names its selector and
134
+ breakpoint) and that a click resets it, the click shows it by striking the label through. The footer's info icon
135
+ holds the legend, and its arrow folds every category.
136
+ - **What is being edited**: an "Editing … › Hover" line under the pickers whenever the rules being written are not the
137
+ selector's plain ones, with a button back to them. Ancestor, pseudo-element and condition fold behind a toggle —
138
+ never while one is in use.
139
+ - The class being edited is the panel's one strong mark (violet), the element's type defaults a softer one; the tools'
140
+ tabs fit the panel and are reachable from the keyboard.
141
+
142
+ - **Lists edited in a popover, all alike**: box and text shadows, transforms, transitions and filters share one row
143
+ (the CSS it writes, a swatch, a remove button) and one popover (a title, a close button, Escape, the focus moved
144
+ into it). What none of them could read is now kept and edited as text instead of being replaced with a default — a
145
+ token for the whole value, `drop-shadow(…)`, `url(#…)`.
146
+ - **Values read the way CSS writes them**: a shadow with two, three or four lengths and its color on either end;
147
+ `rgba(…)` inside text shadows and filters no longer split; negative shadow offsets accepted; a transition with any
148
+ of its parts left out; brightness, contrast and saturation past 1. Transition presets are written as CSS — the
149
+ preset names (`easeInQuad`) made the browser drop the whole declaration — the curve can be dragged into one of your
150
+ own, and the preview stops with the editor. `font-color` (not CSS) became `color`.
151
+ - **Background layers keep what they hold**: a repeating gradient (now a switch), a radial gradient's explicit size, a
152
+ token or `image-set()` as a layer (a "Custom (CSS)" layer), a one-value position read as CSS reads it (`20%` is
153
+ `20% center`), lists shorter than the layers repeated as CSS repeats them, an unset repeat read as tiling, two-position
154
+ stops, negative angles — every one of them was rewritten on the next edit of any layer. Defaults are no longer
155
+ written back, and "Token values" no longer bakes resolved tokens into the layers.
156
+ - **A layer's editor in two halves** — what it draws, then where it goes (size, position, tile, attachment, clip,
157
+ which now offers `text`). The gradient's stops sit on one bar, each a handle that drags or moves with the arrow keys;
158
+ the stop's color and position below it. Previews and swatches resolve the space's tokens.
159
+ - Spacing tells margin (dashed, outside) from padding; Border's sides are labelled and readable in the dark theme; a
160
+ class's menu says what each action does to whom; the Style Manager opens at a size that holds both columns.
161
+
162
+ ## Builder
163
+ - **Shortcuts**: `?` shows every shortcut the builder answers to — the same list the "Nothing selected" card teaches
164
+ from — and ⌘\ / Ctrl+\ hides both side panels for the canvas alone and brings back the ones that were open. Both
165
+ work with the canvas focused.
166
+ - **Panels keep their width**: each side panel opens at the width it was left at; the right one starts at 380px.
167
+ - **Text no smaller than 11px** across the builder's panels (it went down to 10px in fifty places).
168
+
169
+ ## Realtime
170
+ - **A page hears what it sent when it asks to** (`@plitzi/sdk-shared`, `@plitzi/sdk-server`, `@plitzi/sdk-elements`):
171
+ `publishOn('room', 'react', data, { echo: true })`, `useChannel().publish(type, data, { echo: true })` and the
172
+ channel's `publish` callback (`echo`) hand the message back to the page that sent it too, once the server took it —
173
+ stamped like everyone's, with `echo: true`, its `from` the channel's `me`. Without it a page still never hears its
174
+ own messages, and the docs said "every page on its topic hears it": they now say every OTHER page. Presence never
175
+ echoes.
176
+ - **A topic is opened only once it names one** (`@plitzi/sdk-elements`): `useChannel` — and so the `channel` element —
177
+ opens a topic only when a channel of the space covers it, by the same `matchChannel` the server decides by. A topic
178
+ written from data that has not arrived (`room:` while its provider loads, or its template still as text) asked the
179
+ server for both, was refused with a 403 and a console error on every load, and is now waited for.
180
+ - **Pages that watch** (`@plitzi/sdk-server`, `@plitzi/cli`): a connection whose page carries the `plitzi-observer`
181
+ cookie hears its topics and says nothing on them — no `$join`, no presence, its publishes taken and dropped.
182
+ `page check`, `page shot` and `verify` load pages that way, so checking a live site is no longer a visitor walking
183
+ into a room (`X walked in`, a member more in every picture). `--presence` takes part as a visitor does.
184
+
185
+ ## Authoring
186
+ - **`template-in-value`** (refused): a `{{ }}` inside an attribute that is an object or a list — a provider's
187
+ `input`, a list's `items`, a plugin's settings — is never evaluated: only an attribute that is text is interpolated,
188
+ and the page server reads attributes as saved. A provider's `input` also replaced the route param of the same name
189
+ the action was already given, so `input: { room: '{{ navigation.routeParams.room }}' }` reached the task as `""` and
190
+ the page answered 404; its refusal says the action is handed the page's route and query params already. Anything
191
+ else is a binding on the attribute. `mockData`, a sample, is not held to it.
192
+ - **Rules on top of a class need no `id`** (`class: [card, { gap: '6px' }]`): they are named after the id the element
193
+ is given, written or not. `modifier-without-id` is gone; a one-off tweak no longer needs a name nothing reads.
194
+ - **Typed list rows have `inTemplate`**, as untyped ones do, and `bindTemplate`, `visibleWhen`, `hiddenWhen` and
195
+ `variantFrom` take a typed source's path as well as a name: turning a list typed broke every template of its rows.
196
+ - **`when({ field, operator: 'empty' })`** takes no `value` (nor `notEmpty`), as flows.md recommends; it did not
197
+ type-check.
198
+ - **Data-driven colours**: a style binding on a custom property (`{ to: '--who', category: 'style' }`) is written as
199
+ named — it was camel-cased into `who` — so a class reads `var(--who, var(--muted))`. A style binding's value carrying
200
+ `;` or braces is not written: the page server writes inline styles as text, and such a value added declarations of
201
+ its own. `binding-target-unknown` on `style` or a CSS property says to bind it in the `style` category.
202
+ - `unknown-attribute` for `decorative` on an `svg` or a `fontAwesome` says what it means: without a `label` it is
203
+ already hidden from screen readers.
204
+
205
+ - **A folder nobody declared says where to declare it**: `folder-undeclared` (a page, a layout, a folder's parent)
206
+ ends with `pageFolders: [{ id, name }]` on the space, and with the line of the `pageFamily` that wrote the page. A
207
+ folder starts its pages' addresses (`/docs/quickstart`), so a misspelt one is never declared on the author's behalf.
208
+ The skill's `pageFamily` example declares its folder.
209
+ - **A tag is an element**: a `subType` this element has not but another has — `container({ subType: 'ol' })` — names
210
+ that element (`list({ subType: 'ol' })`) instead of the value two letters away (`dl`). Read off the elements'
211
+ declarations, for every element and tag.
212
+ - **A `pageFamily`'s body is written once**: `repeated-shape` and `repeated-on-pages` no longer count the same part of
213
+ each page of one family as copies — they were offering a component for exactly what the docs recommend. Copies within
214
+ one page, or across pages written one by one, are still offered.
215
+ - **Colour emoji are not text to `page check`**: a character painted in its own colours (🎲, `❤️`, a keycap, a ZWJ
216
+ sequence) is left out of the contrast measure, which compared `color` with the tile behind it and failed `verify`
217
+ in the theme whose text colour was close to the tile. A symbol drawn as text (✓, ★) is still measured.
218
+
219
+ - **`declared-callback-target`** (refused): a value beside `on` in `declaredCallback(…, { on, date })` — written as
220
+ `openModal`'s target reads — was read nowhere, and the step ran without it. Refused, with the `params` it goes in
221
+ (`{ on: 'calendar', params: { date } }`) and whether it is one of the callback's declared params.
222
+ - The skill's list rows show the typed form beside the untyped one: with `items` typed by a sample, `r.item` is a path
223
+ (`from: r.item.title`), not text to put in a template string.
224
+ - **`slot-not-class`** (refused): rules written in place in a slot — `slots: { error: [fieldError, { color }] }`, past
225
+ the type in JavaScript or a spec rebuilt from JSON — were taken for a declaration with no rules, and `authorSpace`
226
+ failed later with `Cannot read properties of undefined (reading 'desktop')`, naming nothing. Refused where the slot
227
+ is written, naming the slot and the element, with the `styles()` declaration to hand instead.
228
+
229
+ ## CLI
230
+ - **`page shot --click` (and `--clip`, `--wait-for`, `--scroll-to`, `--steps`) takes any selector**: a value that is
231
+ not an element's name (letters, digits, `-`, `_`) is a selector, CSS or Playwright's own (`button:has-text("Orbit")`).
232
+ It was wrapped as a name, and an invalid selector ended the command with Playwright's stack trace; it is now refused
233
+ with the reason.
234
+
235
+ - **`plitzi functions add <package>`**: a package the functions use comes with them, as a function carries its
236
+ dependencies. Installed in the project, it is bundled (web APIs only, minified, its licence kept) into
237
+ `src/functions/vendor/<package>.js`, with a `.d.ts` re-exporting the installed package's types, imported as
238
+ `./vendor/<package>.js` and pushed, built and run with the rest — nothing is resolved anywhere else, so the builder,
239
+ the sandbox and the push are unchanged. A package that reaches Node (`fs`, `node:*`) is refused, naming what it
240
+ reached; one past the functions' 1 MB is too; one that reads `process`/`Buffer` is warned about. The build's refusal
241
+ of a package import now names the command.
242
+ - **`page shot` targets**: a bare word is an element's name, or — no element named so — a tag (`textarea`); resolved on
243
+ the loaded page for `--click`, `--clip`, `--scroll-to`, `--wait-for` and `--steps`. In `--steps`, `type` takes a
244
+ quoted element with spaces (`type ".panel textarea" hola`) — it was cut at its first space and typed the rest — and
245
+ fails when the click leaves no field focused, rather than sending the keys to the page's shortcuts.
246
+
247
+ ## Server
248
+ - **`server.listen()` resolves once the port answers** (`@plitzi/sdk-server`) — in a fleet, once the first worker
249
+ does. `serveProject` writes `tmp/dev-server.json` and says `pages on …` after it, not on the line after `listen`:
250
+ for about 0.4 s a tool trusting the line (CI, Playwright's `webServer`, `page check`) was refused. A port it cannot
251
+ take still ends the process, or goes to `onListenError`, and the promise is then never resolved.
252
+ - **Runs set for later** (`@plitzi/sdk-server`, `@plitzi/sdk-shared`, `@plitzi/sdk-authoring`, `@plitzi/plitzi-builder`):
253
+ a turn that runs out, a bot's move, a hold that lapses — one run starting one of the space's actions in N seconds,
254
+ whether or not a page is still open. The action says it may be with a **`later` trigger** (no access rule: the run
255
+ that set it was let in); a flow sets it with `flow.later { action, in, input, key }`, a function with
256
+ `ctx.later({ … })`, and `flow.cancelLater` / `ctx.cancelLater(key)` drops it. A `key` names it: set again under the
257
+ same key, the one still waiting is replaced — the newer of two set at once, on every replica — and a running one is
258
+ left. It is a job of the queue schedules use: due by the store's clock (0 s to 30 days, about a second late at most),
259
+ once across replicas, retried, shown in Automations → Queue. Refused before anything is queued, with why: no `later`
260
+ trigger, one switched off, a time out of range, a key that is not one, a server with no jobs. A plugin's functions
261
+ set none. `ActionJobQueue` gains `cancelPending({ spaceId, key, olderThan? })` and jobs a `key`: the memory, Mongo
262
+ and MySQL queues implement it, and the shared contract tests it. **MySQL**: `action_jobs` gains `job_key` (and the
263
+ `action_jobs_key` index), added on first use; with `createTables: false`, run that statement of
264
+ `mysqlJobSchemaUpgrades()`. A queue of a deployment's own implements `cancelPending` (`09-schedules` shows one).
265
+ - **A project's `kv` file has one holder** (`@plitzi/sdk-server`): `createFileKv` takes `<file>.lock` with its pid;
266
+ a second process — another `npm start`, a `--watch` left running — is refused, naming the first (`the server of
267
+ "orbita", on port 8080`) instead of both writing their whole map over each other's changes, and a lock whose process
268
+ is gone is taken over. `close()` writes what is pending and lets go. A server with `workers` opens the file once, in
269
+ the primary, and its workers reach it through the fleet (`fleetKv`): each used to open a copy of its own.
270
+ - **A self-hosted project's credentials** (`@plitzi/sdk-server`, `@plitzi/cli`): `serveProject` answers
271
+ `getCredential` from `PLITZI_CREDENTIALS` in `.env` — one JSON object, credential id → its keys — so
272
+ `ctx.fetch({ credential })`, a connector and an `http.request` step work on the project's own server, not only in
273
+ `functions dev`. The same variable for both (it was `PLITZI_FUNCTIONS_CREDENTIALS`, read by the CLI alone); a value
274
+ that is not that object is refused with how to write it, instead of every credential going missing.
275
+ - **`HOST` beyond loopback says where to open it**: with `HOST=0.0.0.0`, `serveProject` prints the machine's network
276
+ addresses — what a tablet on the same Wi-Fi opens — and that anyone on that network can. `.env.example` names `HOST`
277
+ and `PLITZI_CREDENTIALS`.
278
+
279
+ ## SDK
280
+ - **`useElementSize(ref)`** (`@plitzi/plitzi-sdk`): the size a plugin's own box is drawn at, followed as it changes —
281
+ what `useDisplayMode()` cannot say: a tablet held upright is `mobile` by the window and still a week wide by the
282
+ plugin's box. `undefined` until measured, so the server's page and the hydrated one agree. The breakpoints are
283
+ unchanged.
284
+ - The functions docs say how a task's `params` types (how the builder edits them: `codemirror-json`) and an action's
285
+ `input` types (what the value is: `json`) correspond.
286
+
287
+ - Updated dependencies [cadf70a]
288
+ - @plitzi/sdk-auth@0.38.11
289
+ - @plitzi/sdk-event-bridge@0.38.11
290
+ - @plitzi/sdk-shared@0.38.11
291
+
3
292
  ## 0.38.10
4
293
 
5
294
  ### Patch Changes
@@ -1,5 +1,5 @@
1
- import { default as InteractionsManager } from './InteractionsManager';
2
1
  import { InteractionsContextValue as InteractionsContextValueShared } from '@plitzi/sdk-shared';
3
- export type InteractionsContextValue = InteractionsContextValueShared<InstanceType<typeof InteractionsManager>>;
4
- declare const InteractionsContext: import('react').Context<InteractionsContextValue>;
2
+ /** The manager as its context holds it: the interface sdk-shared declares, which `InteractionsManager` implements. */
3
+ export type InteractionsContextValue = InteractionsContextValueShared;
4
+ declare const InteractionsContext: import('react').Context<InteractionsContextValueShared>;
5
5
  export default InteractionsContext;
@@ -1,28 +1,28 @@
1
1
  import e from "./InteractionsContext.mjs";
2
2
  import t from "./hooks/useInteractions.mjs";
3
3
  import n from "./InteractionsManager.mjs";
4
- import { useMemo as r } from "react";
5
- import { jsx as i } from "react/jsx-runtime";
4
+ import { useMemo as r, useState as i } from "react";
5
+ import { jsx as a } from "react/jsx-runtime";
6
6
  //#region src/InteractionsContextProvider.tsx
7
- var a = ({ children: a, currentPageId: o, routeParams: s, queryParams: c }) => {
8
- let l = r(() => new n(o, s, c), []);
9
- l.interactionsData = r(() => ({
10
- currentPageId: o,
11
- ...s,
12
- ...c
7
+ var o = ({ children: o, currentPageId: s, routeParams: c, queryParams: l }) => {
8
+ let [u] = i(() => new n(s, c, l));
9
+ u.interactionsData = r(() => ({
10
+ currentPageId: s,
11
+ ...c,
12
+ ...l
13
13
  }), [
14
- o,
15
14
  s,
16
- c
15
+ c,
16
+ l
17
17
  ]);
18
- let u = r(() => ({
19
- interactionsManager: l,
18
+ let d = r(() => ({
19
+ interactionsManager: u,
20
20
  useInteractions: t
21
- }), [l]);
22
- return /* @__PURE__ */ i(e, {
23
- value: u,
24
- children: a
21
+ }), [u]);
22
+ return /* @__PURE__ */ a(e, {
23
+ value: d,
24
+ children: o
25
25
  });
26
26
  };
27
27
  //#endregion
28
- export { a as default };
28
+ export { o as default };
@@ -1,7 +1,7 @@
1
1
  import { default as EventBridge } from '@plitzi/sdk-event-bridge';
2
- import { ElementInteraction, InteractionCallback, QueryParams, RouteParams, Subscriptor } from '@plitzi/sdk-shared';
2
+ import { ElementInteraction, InteractionCallback, InteractionsManagerApi, QueryParams, RouteParams, Subscriptor } from '@plitzi/sdk-shared';
3
3
  type InteractionUpdateListener = (timestamp: number) => void;
4
- declare class InteractionsManager {
4
+ declare class InteractionsManager implements InteractionsManagerApi {
5
5
  eventBridge: InstanceType<typeof EventBridge>;
6
6
  parentManager?: InteractionsManager;
7
7
  childManagers: InteractionsManager[];
@@ -49,7 +49,7 @@ declare class InteractionsManager {
49
49
  };
50
50
  interactionTrigger(subscriptorId: string | undefined, eventName: string, params?: Record<string, unknown>): Promise<unknown[]> | undefined;
51
51
  createChildManager: (routeParams?: Record<string, string>, queryParams?: Record<string, string>) => InteractionsManager;
52
- removeChildManager: (childManager: InteractionsManager) => void;
52
+ removeChildManager: (childManager: InteractionsManagerApi) => void;
53
53
  onUpdate(listener: InteractionUpdateListener): () => void;
54
54
  private touch;
55
55
  }
@@ -55,12 +55,24 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
55
55
  reason: r,
56
56
  url: n
57
57
  });
58
- }, T = ({ children: _ }) => {
59
- let { useInteractions: v, interactionsManager: T } = n(e), [E] = g("actions.endpoint"), [[D, O]] = g(["actions.catalog", "actions.available"]), k = r((e, t, n) => {
60
- e && T.interactionTrigger(e, t, n);
61
- }, [T]), A = r(async (e, t) => {
58
+ }, T = (e) => ({
59
+ status: "failed",
60
+ ...e.runId ? { runId: e.runId } : {},
61
+ ...e.reason ? { reason: e.reason } : {},
62
+ ...e.error ? { error: e.error } : {},
63
+ ...e.steps ? { steps: e.steps } : {},
64
+ ...e.trace ? { trace: e.trace } : {}
65
+ }), E = (e, t) => ({
66
+ actionId: e,
67
+ runId: t.runId ?? "",
68
+ error: t.error ?? "",
69
+ reason: t.reason ?? "failed"
70
+ }), D = ({ children: _ }) => {
71
+ let { useInteractions: v, interactionsManager: D } = n(e), [O] = g("actions.endpoint"), [[k, A]] = g(["actions.catalog", "actions.available"]), j = r((e, t, n) => {
72
+ e && D.interactionTrigger(e, t, n);
73
+ }, [D]), M = r(async (e, t) => {
62
74
  let { actionId: n, mode: r = "await", idempotencyKey: i } = e;
63
- if (!E) return a.warning("actions", /* @__PURE__ */ u("span", { children: [
75
+ if (!O) return a.warning("actions", /* @__PURE__ */ u("span", { children: [
64
76
  "Server action ",
65
77
  /* @__PURE__ */ l("b", { children: n }),
66
78
  " was skipped: this page is served without a Plitzi server"
@@ -85,21 +97,21 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
85
97
  actionId: n,
86
98
  mode: r,
87
99
  input: o
88
- }), _ = new AbortController(), v = "", T = () => {
100
+ }), _ = new AbortController(), v = "", D = () => {
89
101
  _.abort(), h(g, {
90
102
  status: "aborted",
91
103
  endedAt: Date.now(),
92
104
  cancellable: !1
93
- }), v && fetch(`${E}/run/${v}`, {
105
+ }), v && fetch(`${O}/run/${v}`, {
94
106
  method: "DELETE",
95
107
  credentials: "same-origin"
96
108
  }).catch(() => void 0);
97
109
  };
98
- p(g, T);
99
- let D = t?.signal;
100
- D?.addEventListener("abort", T, { once: !0 });
101
- let O = (t) => {
102
- D?.removeEventListener("abort", T), m(g), h(g, {
110
+ p(g, D);
111
+ let k = t?.signal;
112
+ k?.addEventListener("abort", D, { once: !0 });
113
+ let A = (t) => {
114
+ k?.removeEventListener("abort", D), m(g), h(g, {
103
115
  endedAt: Date.now(),
104
116
  cancellable: !1,
105
117
  ...t
@@ -117,7 +129,7 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
117
129
  actionId: n,
118
130
  mode: r,
119
131
  status: "accepted"
120
- }), fetch(E, {
132
+ }), fetch(O, {
121
133
  method: "POST",
122
134
  headers: { "Content-Type": "application/json" },
123
135
  credentials: "same-origin",
@@ -127,21 +139,24 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
127
139
  }).then(async (e) => {
128
140
  let i = await e.json().catch(() => ({}));
129
141
  if (!e.ok) {
130
- w(e.status, i, E), O({
131
- status: "failed",
132
- ...i.runId ? { runId: i.runId } : {},
133
- ...i.reason ? { reason: i.reason } : {},
134
- ...i.error ? { error: i.error } : {},
135
- ...i.steps ? { steps: i.steps } : {}
136
- }), k(t?.hostElementId, "onFlowError", {
142
+ w(e.status, i, O), A(T(i)), j(t?.hostElementId, "onFlowError", E(n, i));
143
+ return;
144
+ }
145
+ if (i.status === "failed") {
146
+ A(T(i)), a.warning("actions", /* @__PURE__ */ u("span", { children: [
147
+ "Server action ",
148
+ /* @__PURE__ */ l("b", { children: n }),
149
+ " failed"
150
+ ] }), {
137
151
  actionId: n,
138
- runId: i.runId ?? "",
139
- error: i.error ?? "",
140
- reason: i.reason ?? "failed"
141
- });
152
+ mode: r,
153
+ runId: i.runId,
154
+ reason: i.reason,
155
+ error: i.error
156
+ }), j(t?.hostElementId, "onFlowError", E(n, i));
142
157
  return;
143
158
  }
144
- O({
159
+ A({
145
160
  status: i.status === "completed" ? "completed" : "accepted",
146
161
  ...i.runId ? { runId: i.runId } : {},
147
162
  ...i.output ? { output: i.output } : {},
@@ -157,14 +172,14 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
157
172
  runId: i.runId,
158
173
  status: i.status,
159
174
  output: i.output
160
- }), k(t?.hostElementId, "onFlowEnd", {
175
+ }), j(t?.hostElementId, "onFlowEnd", {
161
176
  actionId: n,
162
177
  runId: i.runId ?? "",
163
178
  status: i.status ?? "completed",
164
179
  output: i.output ?? {}
165
180
  });
166
181
  }).catch((e) => {
167
- O(C(_, e)), a.warning("actions", /* @__PURE__ */ u("span", { children: [
182
+ A(C(_, e)), a.warning("actions", /* @__PURE__ */ u("span", { children: [
168
183
  "Server action ",
169
184
  /* @__PURE__ */ l("b", { children: n }),
170
185
  " could not be sent"
@@ -172,7 +187,7 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
172
187
  actionId: n,
173
188
  mode: r,
174
189
  error: e instanceof Error ? e.message : String(e)
175
- }), k(t?.hostElementId, "onFlowError", {
190
+ }), j(t?.hostElementId, "onFlowError", {
176
191
  actionId: n,
177
192
  runId: "",
178
193
  error: "",
@@ -196,7 +211,7 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
196
211
  });
197
212
  let e;
198
213
  try {
199
- e = await fetch(E, {
214
+ e = await fetch(O, {
200
215
  method: "POST",
201
216
  headers: {
202
217
  "Content-Type": "application/json",
@@ -207,7 +222,7 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
207
222
  body: s
208
223
  });
209
224
  } catch (e) {
210
- return O(C(_, e)), a.warning("actions", /* @__PURE__ */ u("span", { children: [
225
+ return A(C(_, e)), a.warning("actions", /* @__PURE__ */ u("span", { children: [
211
226
  "Server action ",
212
227
  /* @__PURE__ */ l("b", { children: n }),
213
228
  " could not be reached"
@@ -215,7 +230,7 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
215
230
  actionId: n,
216
231
  mode: r,
217
232
  error: e instanceof Error ? e.message : String(e)
218
- }), k(t?.hostElementId, "onFlowError", {
233
+ }), j(t?.hostElementId, "onFlowError", {
219
234
  actionId: n,
220
235
  runId: "",
221
236
  error: "",
@@ -224,18 +239,7 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
224
239
  }
225
240
  if (!e.ok || !e.body) {
226
241
  let r = await e.json().catch(() => ({}));
227
- return w(e.status, r, E), O({
228
- status: "failed",
229
- ...r.runId ? { runId: r.runId } : {},
230
- ...r.reason ? { reason: r.reason } : {},
231
- ...r.error ? { error: r.error } : {},
232
- ...r.steps ? { steps: r.steps } : {}
233
- }), k(t?.hostElementId, "onFlowError", {
234
- actionId: n,
235
- runId: r.runId ?? "",
236
- error: r.error ?? "",
237
- reason: r.reason ?? "failed"
238
- }), {
242
+ return w(e.status, r, O), A(T(r)), j(t?.hostElementId, "onFlowError", E(n, r)), {
239
243
  status: "failed",
240
244
  reason: r.reason ?? "failed",
241
245
  runId: "",
@@ -249,7 +253,7 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
249
253
  ...i ? { runId: i } : {}
250
254
  }), b(e.body, (e) => {
251
255
  if (e.event === "data") {
252
- d(g, e.data.chunk ?? e.data), k(t?.hostElementId, "onFlowProgress", {
256
+ d(g, e.data.chunk ?? e.data), j(t?.hostElementId, "onFlowProgress", {
253
257
  actionId: n,
254
258
  runId: i,
255
259
  ...e.data
@@ -258,12 +262,12 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
258
262
  }
259
263
  if (e.event === "error") {
260
264
  let r = y(e.data.steps);
261
- O({
265
+ A({
262
266
  status: "failed",
263
267
  ...typeof e.data.reason == "string" ? { reason: e.data.reason } : {},
264
268
  ...typeof e.data.error == "string" ? { error: e.data.error } : {},
265
269
  ...r ? { steps: r } : {}
266
- }), k(t?.hostElementId, "onFlowError", {
270
+ }), j(t?.hostElementId, "onFlowError", {
267
271
  actionId: n,
268
272
  runId: i,
269
273
  ...e.data
@@ -272,12 +276,12 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
272
276
  }
273
277
  if (e.event === "done") {
274
278
  let r = y(e.data.steps);
275
- O({
279
+ A({
276
280
  status: e.data.status === "completed" ? "completed" : "failed",
277
281
  ...e.data.output ? { output: e.data.output } : {},
278
282
  ...typeof e.data.error == "string" ? { error: e.data.error } : {},
279
283
  ...r ? { steps: r } : {}
280
- }), k(t?.hostElementId, "onFlowEnd", {
284
+ }), j(t?.hostElementId, "onFlowEnd", {
281
285
  actionId: n,
282
286
  runId: i,
283
287
  ...e.data
@@ -286,7 +290,7 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
286
290
  }).catch((e) => {
287
291
  if (_.signal.aborted) return;
288
292
  let o = e instanceof Error ? e.message : String(e);
289
- O({
293
+ A({
290
294
  status: "failed",
291
295
  error: o
292
296
  }), a.warning("actions", /* @__PURE__ */ u("span", { children: [
@@ -298,7 +302,7 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
298
302
  mode: r,
299
303
  runId: i,
300
304
  error: o
301
- }), k(t?.hostElementId, "onFlowError", {
305
+ }), j(t?.hostElementId, "onFlowError", {
302
306
  actionId: n,
303
307
  runId: i,
304
308
  error: o,
@@ -311,9 +315,9 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
311
315
  output: {}
312
316
  };
313
317
  }
314
- let A;
318
+ let M;
315
319
  try {
316
- A = await fetch(E, {
320
+ M = await fetch(O, {
317
321
  method: "POST",
318
322
  headers: { "Content-Type": "application/json" },
319
323
  credentials: "same-origin",
@@ -321,61 +325,55 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
321
325
  body: s
322
326
  });
323
327
  } catch (e) {
324
- return O(C(_, e)), a.warning("interactions", /* @__PURE__ */ u("span", { children: [
328
+ return A(C(_, e)), a.warning("interactions", /* @__PURE__ */ u("span", { children: [
325
329
  "Server action ",
326
330
  /* @__PURE__ */ l("b", { children: n }),
327
331
  " could not be reached"
328
332
  ] }), {
329
333
  actionId: n,
330
334
  error: e instanceof Error ? e.message : String(e)
331
- }), k(t?.hostElementId, "onFlowError", {
335
+ }), j(t?.hostElementId, "onFlowError", {
332
336
  actionId: n,
333
337
  runId: "",
334
338
  error: "",
335
339
  reason: "failed"
336
340
  }), S;
337
341
  }
338
- let j = await A.json().catch(() => ({}));
339
- return A.ok ? (O({
340
- status: j.status === "completed" ? "completed" : "failed",
341
- ...j.runId ? { runId: j.runId } : {},
342
- ...j.output ? { output: j.output } : {},
343
- ...j.error ? { error: j.error } : {},
344
- ...j.steps ? { steps: j.steps } : {},
345
- ...j.trace ? { trace: j.trace } : {}
346
- }), {
347
- status: j.status ?? "completed",
348
- runId: j.runId ?? "",
349
- output: j.output ?? {},
350
- ...j.error ? { error: j.error } : {}
351
- }) : (w(A.status, j, E), O({
352
- status: "failed",
353
- ...j.runId ? { runId: j.runId } : {},
354
- ...j.reason ? { reason: j.reason } : {},
355
- ...j.error ? { error: j.error } : {},
356
- ...j.steps ? { steps: j.steps } : {}
357
- }), a.warning("actions", /* @__PURE__ */ u("span", { children: [
342
+ let N = await M.json().catch(() => ({}));
343
+ return M.ok ? (A({
344
+ status: N.status === "completed" ? "completed" : "failed",
345
+ ...N.runId ? { runId: N.runId } : {},
346
+ ...N.output ? { output: N.output } : {},
347
+ ...N.error ? { error: N.error } : {},
348
+ ...N.steps ? { steps: N.steps } : {},
349
+ ...N.trace ? { trace: N.trace } : {}
350
+ }), N.status === "failed" && j(t?.hostElementId, "onFlowError", E(n, N)), {
351
+ status: N.status ?? "completed",
352
+ runId: N.runId ?? "",
353
+ output: N.output ?? {},
354
+ ...N.error ? { error: N.error } : {}
355
+ }) : (w(M.status, N, O), A(T(N)), j(t?.hostElementId, "onFlowError", E(n, N)), a.warning("actions", /* @__PURE__ */ u("span", { children: [
358
356
  "Server action ",
359
357
  /* @__PURE__ */ l("b", { children: n }),
360
358
  " was refused"
361
359
  ] }), {
362
360
  actionId: n,
363
361
  mode: r,
364
- runId: j.runId,
365
- reason: j.reason,
366
- error: j.error,
367
- status: String(A.status)
362
+ runId: N.runId,
363
+ reason: N.reason,
364
+ error: N.error,
365
+ status: String(M.status)
368
366
  }), {
369
367
  status: "failed",
370
- reason: j.reason ?? "failed",
371
- runId: j.runId ?? "",
368
+ reason: N.reason ?? "failed",
369
+ runId: N.runId ?? "",
372
370
  output: {},
373
- ...j.error ? { error: j.error } : {}
371
+ ...N.error ? { error: N.error } : {}
374
372
  });
375
- }, [E, k]), j = r(async (e) => {
376
- if (!E || !e.runId) return { cancelled: !1 };
373
+ }, [O, j]), N = r(async (e) => {
374
+ if (!O || !e.runId) return { cancelled: !1 };
377
375
  try {
378
- let t = (await fetch(`${E}/run/${e.runId}`, {
376
+ let t = (await fetch(`${O}/run/${e.runId}`, {
379
377
  method: "DELETE",
380
378
  credentials: "same-origin"
381
379
  })).status === 204;
@@ -393,25 +391,25 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
393
391
  } catch {
394
392
  return { cancelled: !1 };
395
393
  }
396
- }, [E]), M = i(() => (D ?? []).map((e) => ({
394
+ }, [O]), P = i(() => (k ?? []).map((e) => ({
397
395
  label: `${e.name} (${e.identifier})`,
398
396
  value: e.identifier
399
- })), [D]);
397
+ })), [k]);
400
398
  return v({
401
399
  id: "actions",
402
400
  callbacks: i(() => s(t, {
403
- cancelServerAction: j,
404
- runServerAction: A
401
+ cancelServerAction: N,
402
+ runServerAction: M
405
403
  }, { runServerAction: { params: (e) => {
406
- let n = o(t.runServerAction.params), r = (D ?? []).find((t) => t.identifier === e.actionId), i = Object.entries(r?.input ?? {});
404
+ let n = o(t.runServerAction.params), r = (k ?? []).find((t) => t.identifier === e.actionId), i = Object.entries(r?.input ?? {});
407
405
  return {
408
406
  ...n,
409
407
  actionId: {
410
408
  ...n.actionId,
411
- type: () => M.length > 0 ? "select" : "text",
409
+ type: () => P.length > 0 ? "select" : "text",
412
410
  canBind: !0,
413
- label: O === !1 ? "Action — this space has no server to run it" : "Action",
414
- options: M
411
+ label: A === !1 ? "Action — this space has no server to run it" : "Action",
412
+ options: P
415
413
  },
416
414
  input: {
417
415
  ...n.input,
@@ -420,13 +418,13 @@ var y = (e) => Array.isArray(e) ? e : void 0, b = async (e, t) => {
420
418
  }
421
419
  };
422
420
  } } }), [
423
- A,
424
- j,
425
421
  M,
426
- D,
427
- O
422
+ N,
423
+ P,
424
+ k,
425
+ A
428
426
  ])
429
427
  }), _;
430
428
  };
431
429
  //#endregion
432
- export { T as default };
430
+ export { D as default };
@@ -1,5 +1,5 @@
1
1
  import { processTwig as e } from "@plitzi/sdk-shared/helpers/twigWrapper";
2
- import { getPathsFromObeject as t } from "@plitzi/sdk-shared/helpers/utils";
2
+ import { getPathsFromObject as t } from "@plitzi/sdk-shared/helpers/utils";
3
3
  //#region src/utility/twigTemplate.ts
4
4
  var n = {
5
5
  action: "twigTemplate",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plitzi/sdk-interactions",
3
- "version": "0.38.10",
3
+ "version": "0.38.12",
4
4
  "license": "AGPL-3.0",
5
5
  "files": [
6
6
  "dist"
@@ -202,10 +202,10 @@
202
202
  "vitest": "^5.0.3"
203
203
  },
204
204
  "dependencies": {
205
- "@plitzi/plitzi-ui": "^1.6.32",
206
- "@plitzi/sdk-auth": "0.38.10",
207
- "@plitzi/sdk-event-bridge": "0.38.10",
208
- "@plitzi/sdk-shared": "0.38.10"
205
+ "@plitzi/plitzi-ui": "^1.6.33",
206
+ "@plitzi/sdk-auth": "0.38.12",
207
+ "@plitzi/sdk-event-bridge": "0.38.12",
208
+ "@plitzi/sdk-shared": "0.38.12"
209
209
  },
210
210
  "peerDependencies": {
211
211
  "react": "^19"