@plitzi/sdk-shared 0.38.14 → 0.38.16

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,168 @@
1
1
  # @plitzi/sdk-shared
2
2
 
3
+ ## 0.38.16
4
+
5
+ ### Patch Changes
6
+
7
+ - 9cfdccb: ## Security
8
+
9
+ - **A site's credential reads nothing of the space over MCP** (`@plitzi/sdk-mcp`): the `render` token every published
10
+ page embeds — and a self-hosting `host` key — resolved to a grant naming the space, and the MCP served every read
11
+ under it: the unpublished draft, the change history with who made each change and every value before and after, the
12
+ functions' source, the space's private data, its action documents and connectors. Only an `agent` grant attaches a
13
+ space now; any other is a connection with no space (`plitzi_render` and the public guides), told so in the words
14
+ `NO_SPACE_ATTACHED` already uses. A deployment whose `getGrant` answered other scopes for reading must issue agent
15
+ grants for them.
16
+
17
+ ## Agents
18
+ - **`plitzi space watch`** (`@plitzi/cli`): the space read again on every save of `src/space/`, `src/plugins/`,
19
+ `src/data/` or `public/data/`, and only what changed said — what the save did to the space element by element, the
20
+ findings and warnings it brought and fixed (one that only moved down its file is the same one), a save that changed
21
+ nothing, or that the space stopped authoring and why. `--json` is one event a line (`ready`, `pass`, `refused`,
22
+ `error`), for an agent to run in the background instead of `author` and `space lint` after every edit. Each pass reads
23
+ the space in a process of its own (`space watch-pass`, hidden). `space lint`'s reading is `spaceFindings`, shared.
24
+ - **A space's activity, followed** (`@plitzi/sdk-shared`, `@plitzi/sdk-mcp`, `@plitzi/cli`): what happened on a space
25
+ after a cursor — its draft changed (a person in the builder, an agent, the autofix), a version went out, a server
26
+ action failed or was refused — and, with nothing yet, waited for, up to 50 s. One vocabulary,
27
+ `@plitzi/sdk-shared/activity` (`SpaceActivity`, `SpaceActivityPage`, `activityLine`, `isSpaceActivityPage`, the
28
+ limits); the reader's own writes left out and counted (`skippedMine`), `mine` keeps them.
29
+ - **`plitzi_activity { after, wait, limit, mine }`** (`@plitzi/sdk-mcp`), on the new `getActivity` adapter
30
+ (`SSRAdapters`). The listing budget is 78k (was 77k) for it.
31
+ - **`plitzi space activity [--follow] [--after <cursor>] [--mine] [--limit <n>] [--json]`** (`@plitzi/cli`), over
32
+ the platform's `GET /spaces/:spaceId/activity`; `--follow` stays, one page a line with `--json`, and asks again
33
+ when the platform does not answer.
34
+ - **The people in the builder see the agent work** (`@plitzi/sdk-server`, `@plitzi/sdk-shared`, `@plitzi/sdk-mcp`,
35
+ `@plitzi/plitzi-builder`): an agent grant carries the application the member connected (`Grant.client`,
36
+ `StoredSpaceToken.client`, `SSRGrant.client`), and every MCP write `SSRWriteContext.client` — the history's
37
+ `client` for an agent, which was never set. A collaborator may be an agent (`SubscriptionCollaborator.agent`): the
38
+ builder draws it as a robot, names it `Claude · for ana` (`collaboratorTitle`) in the header, on the canvas and in
39
+ its notices. The deployment announces it — Plitzi's joins it on a write, selects what it changed, and lets it go
40
+ after a minute of nothing. `activityLine` names it the same way (`Claude for ana over the MCP, …`), so
41
+ `plitzi space activity` says which application wrote.
42
+ - A tool may declare `documents: false` (`ToolSpec`): the host loads none of the space for it, and passes the call's
43
+ abort signal through `ToolContext.activity`.
44
+
45
+ ## Authoring
46
+ - **A file that does not parse is said at its line under any loader** (`@plitzi/sdk-authoring`): `moduleProblem` read
47
+ the first line of the error, and an esbuild transform (tsx, vitest) puts only `Transform failed with 1 error:` there
48
+ — the file, line and what is wrong are on the next. A line of the message that points at a file of the project is
49
+ now the problem (`src/space/hero.ts:139: Expected "}" but found ";"`), the project's root matched as given and as it
50
+ is on disk (`/var/…` and `/private/var/…` on macOS).
51
+
52
+ ## Testing
53
+ - **`unusedPort` is chosen where the system never hands one out** (`@plitzi/sdk-server`): it answered a port the system
54
+ had just handed out (`listen(0)`), from the ephemeral range every outgoing connection takes its local port from — so
55
+ another worker's request could take it before the test listened, and CI failed `runtime.test.ts` with `EADDRINUSE`
56
+ (the page server then ends the process). It is a free port below that range now, at random, checked first.
57
+
58
+ ## Docs
59
+ - **A self-hosted runtime's endpoints go in `data`**, as 0.38.15 moved them: `docs/en/runtimes.md`, the
60
+ `10-runtime` example and the website still put `served.stage` in `preAuth`, before the cross-site guard.
61
+ - New: `docs/en/activity.md`; `space watch` in `docs/en/agent-tooling.md`'s loop; the CLI README, the CLI skill, the
62
+ generated project's `AGENTS.md`, the MCP guide and README.
63
+
64
+ ## 0.38.15
65
+
66
+ ### Patch Changes
67
+
68
+ - 6cdd5cf: ## Security
69
+
70
+ - **A write another site caused is refused, cookie or none** (`@plitzi/sdk-server`, `@plitzi/sdk-shared`): the page
71
+ server guarded nothing it answers past `/auth` — a server action (`/_action`), a realtime publish, a space's `/fn/`
72
+ route, its runtime's endpoints, the deployment's own `data` stages, the adapter-only `loginPath`, `logoutPath` and
73
+ `exchangePath`. A plain `text/plain` POST from any page open in the same browser ran them, with the visitor's session
74
+ cookie when there was one (`SameSite=None` off this machine) and, in a project nobody signs in to, as whoever holds
75
+ the server's own credentials. Every unsafe request a browser says another site caused (`Sec-Fetch-Site: cross-site`,
76
+ or a foreign `Origin`) is now refused `403 reason: 'foreign'`, saying how to allow it: `crossSiteWrites.origins`
77
+ (with `auth`, `identity.platformOrigins` too) and `crossSiteWrites.paths` for a form other sites post to by design.
78
+ `Authorization`, and callers that are not browsers — webhooks, scripts — pass as before. One rule for this and the
79
+ sign-in check (`crossSiteRequest`, `csrf.ts`). A self-hosted runtime's endpoints now sit where the platform forwards a
80
+ space's — after the auth chain and this guard (`data`, was `preAuth`).
81
+
82
+ ## Testing
83
+ - **`page check` and `page shot` anywhere the project is served** (`@plitzi/cli`): `--url <origin>` for a second server
84
+ of it, staging or a deploy, instead of `npm start`'s port; `page check --space <module>` holds the pages to that space
85
+ instead of the project's — an agent's page — authored with `authorIsolated`.
86
+ - **A route with a query is checked as its page** (`@plitzi/cli`): `page check "/?v=2"` matched the query as part of
87
+ the path, found no page, and checked the space's "not found" page in its place.
88
+
89
+ - **What an element that chooses its children draws is checked** (`@plitzi/sdk-authoring`, `@plitzi/cli`): with
90
+ `choosesChildren`, the page checks owed none of its children — and checked none of them either: a dashboard drawing
91
+ three panels reported `checked: 1`. Each child it may draw, and what is inside one under no condition of its own,
92
+ now carries `shownWith` (the child it comes with) on its handle: once that child is on screen it and everything
93
+ named in it are owed like the rest of the page, and `checked` counts them. `onScreenIfChosen(handles, page)` lists
94
+ them.
95
+ - **A page that met a server error is looked at once more** (`@plitzi/cli`): `page check` and `verify` failed a page
96
+ for a `500` from somebody else's service having a bad second (`/fn/<space>/weather`), and passed on the next run with
97
+ nothing changed. A page whose requests got a `5xx` is checked again once; its report is the second look, and says
98
+ what failed the first time (`retriedAfter`). A `4xx` fails the same way twice, and is never retried.
99
+
100
+ ## Plugins
101
+ - **`useNotify`** (`@plitzi/plitzi-sdk`): a plugin shows the page's notifications — `notify('Deleted 79 recordings', {
102
+ appearance: 'danger' })` — the same toasts an `addNotification` step shows, in the space's theme and `notifications`
103
+ look, with no trigger, flow or `window` event of the space's to wire. The step's vocabulary (`NOTIFICATION_PLACEMENTS`,
104
+ `NOTIFICATION_APPEARANCES`, `NOTIFICATION_DEFAULTS`) is one list in `@plitzi/sdk-shared`, read by both.
105
+ - **`appearance: 'danger'` looks like one** (`@plitzi/plitzi-sdk`): it reached the toast library as a type it does not
106
+ know, so a danger notification showed neither the error icon nor the colour `notifications.danger` sets.
107
+ A value a notification does not take — from a flow, or a plugin in plain JavaScript — is set aside by name and said
108
+ in the console, rather than shown as the default in silence (`readNotificationOptions`, `@plitzi/sdk-shared`).
109
+ - **`useServerAction`** (`@plitzi/plitzi-sdk`, `@plitzi/sdk-authoring`, `@plitzi/sdk-interactions`,
110
+ `@plitzi/sdk-server`): a plugin runs one of the space's server actions, awaited —
111
+ `useServerAction<typeof habitDone>('habits-done')({ id })` answers `{ ok, output }` or `{ ok: false, reason, error }`
112
+ — through the `runServerAction` step itself: the same access, refusals, session handling and dev-tools entry.
113
+ `defineAction` keeps the literal types of its `call` way in, so the input is typed by the fields it declares (the
114
+ required ones required); `taskAction` types both ends from the task's `run`, and `FunctionTask<T, R>` takes what
115
+ `run` answers. `CallInputOf` / `CallOutputOf` read them. One operation is one action, never a `case` in one route.
116
+ What a run answers is typed (`ServerActionStatus`): a status the server never uses reads as a run that did not
117
+ complete, never as one that did.
118
+ The key those types ride under (`CALL_TYPES`) is exported, by `@plitzi/sdk-shared` and `@plitzi/sdk-authoring` with
119
+ `TypedActionEntry`, `CallInputOf` and `CallOutputOf`: a package that emits declarations could not write the type of an
120
+ action it exports (`TS4023` on every `export const actions = [defineAction(…)]`).
121
+ - **A plugin is drawn on the server first** (docs): a preference per device belongs in kept state (`keepState`,
122
+ `paintedState`) as a bound prop, never read from `localStorage` while rendering — React discards the whole tree on the
123
+ mismatch, and only in the browser of whoever saved something. `@plitzi/plitzi-ui` is not the page's: a plugin
124
+ importing it bundles its own copy, with its own contexts and its own look. The authoring skill's `plugin-reach.md`
125
+ says what a plugin says and to whom: a notification, another element (an event and the space's flow), a server
126
+ action, shared state, other pages.
127
+
128
+ ## Realtime
129
+ - **A channel that retains** (`@plitzi/sdk-shared`, `@plitzi/sdk-server`, `@plitzi/sdk-elements`): declared
130
+ `retain: true` (with `publish: 'server'`, which authoring requires), the server keeps the latest message of each type
131
+ on a topic — said by `ctx.publish` or a flow's `realtime.publish` — and hands them to every page that joins, marked
132
+ `retained`. A page reads them as `<channel>.retained.<type>`, a plugin as `useChannel(topic).retained`, the newest of
133
+ a type holding whichever order they arrive in; `null` forgets a type. Kept in the store the actions' `kv` uses (beside
134
+ the grants, by compare-and-swap), so every replica hands out the same; a topic keeps at most 64 types and 512 KB, and
135
+ a publish past that is refused before anything is sent. State every screen shares is one publish and one binding —
136
+ no kv key, initial read or copy in `state` of the project's own. The fleet store `realtime.grants` is now
137
+ `realtime.kv`.
138
+ - **The MCP writes every field a channel takes** (`@plitzi/sdk-mcp`): `patchSettings`'s channel had no `grant` — which
139
+ the guide taught — nor `retain` or the limits, so an agent could not declare a private channel at all. All are there
140
+ now, and the guide says what `retain` is for and that `channel_<id>.retained` holds it.
141
+
142
+ ## Authoring
143
+ - **`plitzi explain` knows every `@plitzi` package installed** (`@plitzi/cli`): a name that was not
144
+ `@plitzi/sdk-authoring`'s (`createServer`, `createJsonAdapters`, `useChannel`) was answered as the project's own code,
145
+ to `grep` in `src/`. It is read from the published types of every one installed, through their re-exports and entry
146
+ points (`@plitzi/sdk-server/handlers`), and a name two packages export — `createServer` is sdk-server's and sdk-mcp's
147
+ — is answered with both.
148
+
149
+ - **A space module somebody else wrote, authored where it reaches nothing** (`@plitzi/sdk-authoring`):
150
+ `authorIsolated(file, { timeoutMs })` of `@plitzi/sdk-authoring/node` runs `authorSpace` on it in a process Node's
151
+ permission model holds to reading the module's folder and its packages — no file written, no process started, no
152
+ variable of the caller's environment — kills one that runs too long, and validates what it answers again, so a forged
153
+ answer gains nothing. A refusal comes back as `authorSpace` says it, with the problems as data.
154
+ - **Pages an agent writes, served** (`@plitzi/sdk-server`): `createAuthoringHost({ dir, frameAncestors })` serves each
155
+ space it is handed at an address of its own (`put(space, { id }) → /?__pt=<id>`) as a draft of its one space, kept in
156
+ `dir` across restarts; `drop(id)` forgets one, and anything else answers `404` saying where the pages are.
157
+ - **A space is chosen by host or credential** (`@plitzi/sdk-server`, docs): `getSpaceDeployment` is asked on every
158
+ request, and what a page fetches after it carries nothing of its address but the host — a space chosen by the page's
159
+ query or path lost everything it asked for, and `/_plitzi/space/<hash>.json` answered a bare `404`. The contract and
160
+ the README say so (the README offered "by path prefix"), and that `404` says why.
161
+
162
+ - **`plitzi explain on` says how to read what a trigger carries** (`@plitzi/sdk-authoring`): its doc sat above a
163
+ helper, so `explain` printed only the signature. It now leads with `[named('picked', on('onPick')), …('{{ picked.seat
164
+ }}')]`, and the CLI skill's plugin section says the same.
165
+
3
166
  ## 0.38.14
4
167
 
5
168
  ### Patch Changes
@@ -0,0 +1,6 @@
1
+ import { SpaceActivity } from './types';
2
+ /**
3
+ * One activity, in a line a person scans: who did what, and where — the same words the builder's history and activity
4
+ * use. Its time is the reader's to add, in the zone it shows times in.
5
+ */
6
+ export declare const activityLine: (activity: SpaceActivity) => string;
@@ -0,0 +1,22 @@
1
+ //#region src/activity/describe.ts
2
+ var e = {
3
+ builder: "in the builder",
4
+ mcp: "over the MCP",
5
+ autofix: "by the autofix",
6
+ api: "through the API",
7
+ system: "by the platform"
8
+ }, t = (e) => e || "somebody", n = (e) => {
9
+ let t = e.split("\n").filter((e) => e.trim() !== "");
10
+ return t.length === 0 ? "changed it" : t.length === 1 ? t[0] : `${t[0]} (+${String(t.length - 1)} more)`;
11
+ }, r = (r) => {
12
+ switch (r.kind) {
13
+ case "change": return `${r.origin === "mcp" && r.client ? `${r.client} for ${t(r.author.name)}` : t(r.author.name)} ${e[r.origin] ?? r.origin}, ${r.document} #${String(r.seq)}: ${n(r.summary)}`;
14
+ case "publish": return r.message;
15
+ case "action": {
16
+ let e = r.reason ?? r.error;
17
+ return `action ${r.actionId} (${r.trigger}) ${r.status}${e ? `: ${e}` : ""}`;
18
+ }
19
+ }
20
+ };
21
+ //#endregion
22
+ export { r as activityLine };
@@ -0,0 +1,6 @@
1
+ import { SpaceActivityPage } from './types';
2
+ /**
3
+ * Whether a reply is a page of activity — what a client checks the platform's answer against before reading it, an
4
+ * answer from a server of another version included.
5
+ */
6
+ export declare const isSpaceActivityPage: (value: unknown) => value is SpaceActivityPage;
@@ -0,0 +1,13 @@
1
+ import { isRecord as e } from "../helpers/isRecord.mjs";
2
+ //#region src/activity/guard.ts
3
+ var t = (t) => {
4
+ if (!e(t) || typeof t.at != "number") return !1;
5
+ switch (t.kind) {
6
+ case "change": return typeof t.seq == "number" && typeof t.summary == "string" && typeof t.origin == "string" && e(t.author) && Array.isArray(t.touched);
7
+ case "publish": return typeof t.message == "string" && e(t.author);
8
+ case "action": return typeof t.actionId == "string" && typeof t.status == "string";
9
+ default: return !1;
10
+ }
11
+ }, n = (n) => e(n) && Array.isArray(n.activity) && n.activity.every(t) && typeof n.cursor == "string" && typeof n.more == "boolean" && typeof n.waitedMs == "number" && typeof n.skippedMine == "number";
12
+ //#endregion
13
+ export { n as isSpaceActivityPage };
@@ -0,0 +1,3 @@
1
+ export * from './describe';
2
+ export * from './guard';
3
+ export * from './types';
@@ -0,0 +1,4 @@
1
+ import { activityLine as e } from "./describe.mjs";
2
+ import { isSpaceActivityPage as t } from "./guard.mjs";
3
+ import { ACTIVITY_LIMIT_DEFAULT as n, ACTIVITY_LIMIT_MAX as r, ACTIVITY_TOUCHED_MAX as i, ACTIVITY_WAIT_DEFAULT_SECONDS as a, ACTIVITY_WAIT_MAX_SECONDS as o } from "./types.mjs";
4
+ export { n as ACTIVITY_LIMIT_DEFAULT, r as ACTIVITY_LIMIT_MAX, i as ACTIVITY_TOUCHED_MAX, a as ACTIVITY_WAIT_DEFAULT_SECONDS, o as ACTIVITY_WAIT_MAX_SECONDS, e as activityLine, t as isSpaceActivityPage };
@@ -0,0 +1,94 @@
1
+ import { ChangeAuthor, ChangeDocument, ChangeOrigin } from '../history/types';
2
+ /**
3
+ * What happened on a space, as an agent or a person following it reads it: the draft changed, a version went out, an
4
+ * action failed. One vocabulary for the three surfaces that read it — the MCP's `plitzi_activity`, the CLI's
5
+ * `plitzi space activity` and the platform's `GET /spaces/:spaceId/activity` — so none of them describes it again.
6
+ *
7
+ * Each kind is read off a record the platform already keeps — the change history, the space's log, the action runs —
8
+ * so the activity is never a second copy that could disagree with them.
9
+ */
10
+ /** The draft changed: one save, by whoever made it, through whichever channel. */
11
+ export type ChangeActivity = {
12
+ kind: 'change';
13
+ /** Milliseconds, UTC. */
14
+ at: number;
15
+ /** Its place in the draft's change history: what `plitzi://changes/main/{seq}` reads whole. */
16
+ seq: number;
17
+ document: ChangeDocument;
18
+ author: ChangeAuthor;
19
+ origin: ChangeOrigin;
20
+ /** The MCP client's name, or the builder tab's instance id. */
21
+ client?: string;
22
+ /** One line per thing it did, as the builder's history says it. */
23
+ summary: string;
24
+ /** What it touched, by id — elements, selectors, tokens, files — at most {@link ACTIVITY_TOUCHED_MAX}. */
25
+ touched: string[];
26
+ /** How many more it touched than `touched` lists. */
27
+ moreTouched?: number;
28
+ };
29
+ /** A version of the space went out: published to an environment, its flags published, or deployed. */
30
+ export type PublishActivity = {
31
+ kind: 'publish';
32
+ at: number;
33
+ author: ChangeAuthor;
34
+ /** `publish` — a version or its flags — or `deployment`, to a CDN. */
35
+ what: 'publish' | 'deployment';
36
+ environment?: string;
37
+ /** The space's log line, as the builder's activity shows it. */
38
+ message: string;
39
+ };
40
+ /** A server action did not complete, or a call to one was refused. A run that completed is not news. */
41
+ export type ActionActivity = {
42
+ kind: 'action';
43
+ at: number;
44
+ actionId: string;
45
+ trigger: string;
46
+ /** `refused`, or how a run that did not complete ended. */
47
+ status: string;
48
+ environment?: string;
49
+ /** The run, for `GET /spaces/:spaceId/actions/runs/:runId`. Absent on a refusal. */
50
+ runId?: string;
51
+ /** Why it failed, or the refusal's detail — redacted before it was recorded. */
52
+ error?: string;
53
+ /** Why it was refused. */
54
+ reason?: string;
55
+ };
56
+ export type SpaceActivity = ChangeActivity | PublishActivity | ActionActivity;
57
+ export type SpaceActivityKind = SpaceActivity['kind'];
58
+ /** What to read: everything after a cursor, waiting for it when there is nothing yet. */
59
+ export type SpaceActivityQuery = {
60
+ /**
61
+ * The `cursor` of the last page read. Left out: the latest activity, and the cursor to follow it from — never a
62
+ * wait, since there is nothing yet to wait after.
63
+ */
64
+ after?: string;
65
+ /** How long to wait for something when nothing is there yet, in seconds, up to {@link ACTIVITY_WAIT_MAX_SECONDS}. */
66
+ wait?: number;
67
+ /** At most this many, up to {@link ACTIVITY_LIMIT_MAX}. */
68
+ limit?: number;
69
+ /** Include the reader's own changes: those made by the same person through the channel it reads from. */
70
+ mine?: boolean;
71
+ };
72
+ /** Who reads, so their own writes can be told apart: the person, and the channel their writes are recorded under. */
73
+ export type ActivityReader = {
74
+ userId?: number;
75
+ origin: ChangeOrigin;
76
+ };
77
+ /** A page of activity, oldest first. */
78
+ export type SpaceActivityPage = {
79
+ activity: SpaceActivity[];
80
+ /** Pass as `after` to read what comes next. It moves past what was left out too. */
81
+ cursor: string;
82
+ /** More was there than one page holds: read again at once. */
83
+ more: boolean;
84
+ /** How long it waited before answering, in milliseconds: 0 when something was already there. */
85
+ waitedMs: number;
86
+ /** The reader's own changes it left out (`mine` includes them), so leaving them out is never silent. */
87
+ skippedMine: number;
88
+ };
89
+ /** Long enough to be worth a call, short enough for every client and gateway in between: most cut a request at 60 s. */
90
+ export declare const ACTIVITY_WAIT_MAX_SECONDS = 50;
91
+ export declare const ACTIVITY_WAIT_DEFAULT_SECONDS = 45;
92
+ export declare const ACTIVITY_LIMIT_DEFAULT = 20;
93
+ export declare const ACTIVITY_LIMIT_MAX = 100;
94
+ export declare const ACTIVITY_TOUCHED_MAX = 20;
@@ -0,0 +1,4 @@
1
+ //#region src/activity/types.ts
2
+ var e = 50, t = 45, n = 20, r = 100, i = 20;
3
+ //#endregion
4
+ export { n as ACTIVITY_LIMIT_DEFAULT, r as ACTIVITY_LIMIT_MAX, i as ACTIVITY_TOUCHED_MAX, t as ACTIVITY_WAIT_DEFAULT_SECONDS, e as ACTIVITY_WAIT_MAX_SECONDS };
@@ -71,7 +71,8 @@ export interface ElementDeclarationData {
71
71
  /**
72
72
  * Whether the element shows only some of the children put inside it, chosen as it runs — a dashboard showing the
73
73
  * panels of the layout saved for this device, a wizard its current step. Read by the page checks, which then owe none
74
- * of them on screen; what it draws is still read by the checks of the whole page — images, overflow, legibility.
74
+ * of them on screen; the ones it draws are checked like the rest of the page — there, visible, and what is named
75
+ * inside them too.
75
76
  */
76
77
  choosesChildren?: boolean;
77
78
  /**
@@ -2,5 +2,5 @@ import { toBuilderParams as e, toInteractionCallback as t, toInteractionCallback
2
2
  import { definePlugin as r, elementDeclaration as i, valuesOf as a } from "./declare.mjs";
3
3
  import { BUILTIN_PARAM_TYPES as o, hiddenParams as s, invalidParams as c, missingRequiredParams as l, reconcileParams as u } from "./paramSpec.mjs";
4
4
  import { BUILTIN_ELEMENT_CALLBACKS as d, SCROLL_CALLBACKS as f, applyElementCallback as p, getElementCallback as m } from "./elementCallbacks.mjs";
5
- import { spaceCallbacks as h } from "./spaceCallbacks.mjs";
6
- export { d as BUILTIN_ELEMENT_CALLBACKS, o as BUILTIN_PARAM_TYPES, f as SCROLL_CALLBACKS, p as applyElementCallback, r as definePlugin, i as elementDeclaration, m as getElementCallback, s as hiddenParams, c as invalidParams, l as missingRequiredParams, u as reconcileParams, h as spaceCallbacks, e as toBuilderParams, t as toInteractionCallback, n as toInteractionCallbacks, a as valuesOf };
5
+ import { NOTIFICATION_APPEARANCES as h, NOTIFICATION_DEFAULTS as g, NOTIFICATION_PLACEMENTS as _, readNotificationOptions as v, spaceCallbacks as y } from "./spaceCallbacks.mjs";
6
+ export { d as BUILTIN_ELEMENT_CALLBACKS, o as BUILTIN_PARAM_TYPES, h as NOTIFICATION_APPEARANCES, g as NOTIFICATION_DEFAULTS, _ as NOTIFICATION_PLACEMENTS, f as SCROLL_CALLBACKS, p as applyElementCallback, r as definePlugin, i as elementDeclaration, m as getElementCallback, s as hiddenParams, c as invalidParams, l as missingRequiredParams, v as readNotificationOptions, u as reconcileParams, y as spaceCallbacks, e as toBuilderParams, t as toInteractionCallback, n as toInteractionCallbacks, a as valuesOf };
@@ -1,4 +1,33 @@
1
1
  import { BuiltinGlobalCallback } from './builder';
2
+ /** Where a notification may appear: the `addNotification` step's `placement`, and `useNotify`'s. */
3
+ export declare const NOTIFICATION_PLACEMENTS: readonly ["top-right", "top-center", "top-left", "bottom-right", "bottom-center", "bottom-left"];
4
+ export type NotificationPlacement = (typeof NOTIFICATION_PLACEMENTS)[number];
5
+ /** How a notification looks: the `addNotification` step's `appearance`, and `useNotify`'s. */
6
+ export declare const NOTIFICATION_APPEARANCES: readonly ["success", "danger", "warning", "info"];
7
+ export type NotificationAppearance = (typeof NOTIFICATION_APPEARANCES)[number];
8
+ /** What a notification takes besides its text — every one with the default the `addNotification` step has. */
9
+ export type NotificationOptions = {
10
+ placement?: NotificationPlacement;
11
+ appearance?: NotificationAppearance;
12
+ autoDismiss?: boolean;
13
+ /** Milliseconds before it dismisses itself, with `autoDismiss`. */
14
+ autoDismissTimeout?: number;
15
+ };
16
+ /**
17
+ * What a notification was handed, kept to what it takes — a flow's values arrive as written, and a plugin may be plain
18
+ * JavaScript — with each field set aside named, so the caller says so rather than showing the default in silence.
19
+ */
20
+ export declare const readNotificationOptions: (given: Readonly<Record<string, unknown>>) => {
21
+ options: NotificationOptions;
22
+ ignored: string[];
23
+ };
24
+ /** The defaults of a notification, the step's and the hook's alike. */
25
+ export declare const NOTIFICATION_DEFAULTS: {
26
+ readonly placement: "top-right";
27
+ readonly appearance: "success";
28
+ readonly autoDismiss: true;
29
+ readonly autoDismissTimeout: 5000;
30
+ };
2
31
  /**
3
32
  * The `space` source, which the SDK application registers rather than this package.
4
33
  *
@@ -1,5 +1,38 @@
1
1
  //#region src/authoring/spaceCallbacks.ts
2
- var e = { addNotification: {
2
+ var e = [
3
+ "top-right",
4
+ "top-center",
5
+ "top-left",
6
+ "bottom-right",
7
+ "bottom-center",
8
+ "bottom-left"
9
+ ], t = [
10
+ "success",
11
+ "danger",
12
+ "warning",
13
+ "info"
14
+ ], n = (n) => {
15
+ let r = e.find((e) => e === n.placement), i = t.find((e) => e === n.appearance), { autoDismiss: a, autoDismissTimeout: o } = n, s = typeof o == "number" && Number.isFinite(o) && o > 0 ? o : void 0, c = {
16
+ placement: r !== void 0,
17
+ appearance: i !== void 0,
18
+ autoDismiss: typeof a == "boolean",
19
+ autoDismissTimeout: s !== void 0
20
+ };
21
+ return {
22
+ options: {
23
+ ...r === void 0 ? {} : { placement: r },
24
+ ...i === void 0 ? {} : { appearance: i },
25
+ ...typeof a == "boolean" ? { autoDismiss: a } : {},
26
+ ...s === void 0 ? {} : { autoDismissTimeout: s }
27
+ },
28
+ ignored: Object.entries(c).filter(([e, t]) => !t && n[e] !== void 0).map(([e]) => e)
29
+ };
30
+ }, r = {
31
+ placement: "top-right",
32
+ appearance: "success",
33
+ autoDismiss: !0,
34
+ autoDismissTimeout: 5e3
35
+ }, i = { addNotification: {
3
36
  source: "space",
4
37
  title: "Add Notification",
5
38
  strictParams: !0,
@@ -12,40 +45,28 @@ var e = { addNotification: {
12
45
  placement: {
13
46
  type: "select",
14
47
  description: "Where the toast appears on screen.",
15
- default: "top-right",
16
- options: [
17
- "top-right",
18
- "top-center",
19
- "top-left",
20
- "bottom-right",
21
- "bottom-center",
22
- "bottom-left"
23
- ]
48
+ default: r.placement,
49
+ options: [...e]
24
50
  },
25
51
  appearance: {
26
52
  type: "select",
27
53
  description: "Visual style of the notification: success, danger, warning or info.",
28
- default: "success",
29
- options: [
30
- "success",
31
- "danger",
32
- "warning",
33
- "info"
34
- ]
54
+ default: r.appearance,
55
+ options: [...t]
35
56
  },
36
57
  autoDismiss: {
37
58
  type: "boolean",
38
59
  description: "Whether the notification dismisses itself after a timeout.",
39
- default: !0,
60
+ default: r.autoDismiss,
40
61
  canBind: !1
41
62
  },
42
63
  autoDismissTimeout: {
43
64
  type: "number",
44
65
  description: "Milliseconds before auto-dismiss. Only applies when autoDismiss is true.",
45
- default: 5e3,
66
+ default: r.autoDismissTimeout,
46
67
  when: (e) => e.autoDismiss === !0
47
68
  }
48
69
  }
49
70
  } };
50
71
  //#endregion
51
- export { e as spaceCallbacks };
72
+ export { t as NOTIFICATION_APPEARANCES, r as NOTIFICATION_DEFAULTS, e as NOTIFICATION_PLACEMENTS, n as readNotificationOptions, i as spaceCallbacks };
package/dist/index.d.ts CHANGED
@@ -16,4 +16,5 @@ export * from './theme';
16
16
  export * from './server';
17
17
  export * from './state';
18
18
  export * from './history';
19
+ export * from './activity';
19
20
  export * from './flags';