@plitzi/sdk-shared 0.38.13 → 0.38.14
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 +145 -0
- package/dist/authoring/declare.d.ts +6 -0
- package/dist/helpers/clipboard.d.ts +10 -0
- package/dist/helpers/clipboard.mjs +17 -0
- package/dist/helpers/enclosingSpace.d.ts +9 -0
- package/dist/helpers/enclosingSpace.mjs +5 -0
- package/dist/helpers/spaceRoot.d.ts +4 -0
- package/dist/helpers/spaceRoot.mjs +4 -0
- package/dist/project/network.d.ts +12 -0
- package/dist/project/network.mjs +4 -0
- package/dist/store/index.d.ts +33 -33
- package/dist/store/renderSettings.d.ts +1 -0
- package/dist/store/renderSettings.mjs +9 -5
- package/dist/types/StoreTypes.d.ts +8 -2
- package/package.json +17 -2
- package/setupTests.ts +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,150 @@
|
|
|
1
1
|
# @plitzi/sdk-shared
|
|
2
2
|
|
|
3
|
+
## 0.38.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 493955a: ## SDK
|
|
8
|
+
|
|
9
|
+
- **An embedded space leaves the page's theme alone** (`@plitzi/plitzi-sdk`, `@plitzi/plitzi-builder`): plitzi-ui's
|
|
10
|
+
`Provider` stamps `dark` on `<html>` by default — and, being `light`, takes it off — so every space mounted with
|
|
11
|
+
`themeScope: 'container'` turned the page around it light, and nothing put it back. The SDK and the builder now leave
|
|
12
|
+
the class to their own theme provider (`applyColorModeClass={false}`).
|
|
13
|
+
- **A space inside a space** (`@plitzi/plitzi-sdk`, `@plitzi/sdk-shared`): one drawn inside another — the `plitziSdk`
|
|
14
|
+
element, a plugin rendering one, the builder's canvas — knows it (`render.enclosed`). It is `container` unless it
|
|
15
|
+
says otherwise, wears its theme on its own root and starts from the page's when its own is `system`, keeps its
|
|
16
|
+
stylesheet to its own root (`@scope` — its `:root` palette and `.dark` rules repainted the outer page, its
|
|
17
|
+
`.plitzi-sdk` rule restyled the outer root), writes no `<title>` (`ownsHead`) and no `theme` cookie.
|
|
18
|
+
- **The `plitziSdk` element draws** (`@plitzi/plitzi-sdk`): it rendered in `widget` mode with no page to show, so it
|
|
19
|
+
drew nothing. A widget with no `currentPageId` now shows the page its home address would. And it takes a space's
|
|
20
|
+
documents as well as a key: `offlineData`, bound whole (an `apiContainer`'s answer, a runtime's route, what
|
|
21
|
+
`plitzi_render` returns) or as `offlineData.schema` and `offlineData.style` from two elements — waiting, without an
|
|
22
|
+
error, for the half that has not answered; one that cannot be drawn is said why, in the console and on the canvas.
|
|
23
|
+
- **`<PlitziSdk>` inside a plugin draws** (`@plitzi/plitzi-sdk`): it mounted a router of its own inside the page's, and
|
|
24
|
+
React Router refused it — `routing: 'memory'` or not. A space inside another is a widget: `raw` becomes `widget`
|
|
25
|
+
there, one page and no router (a frame of its own, `iframe` or `shadow`, is left as asked).
|
|
26
|
+
- **A space inside another is as tall as what it holds** (`@plitzi/plitzi-sdk`): its root was `min-h-screen`, as a
|
|
27
|
+
space that IS the page is, so a card of three lines drawn in a panel took the window's height.
|
|
28
|
+
- **`<PlitziSdk.Plugin component>` takes a component with its own props** (`@plitzi/plitzi-sdk`), as `render()`'s
|
|
29
|
+
plugins do: typed `ComponentPluginFC`, it refused any component that read its attributes.
|
|
30
|
+
- **An edited page keeps its address in step** (`@plitzi/plitzi-sdk`): the routes are built from the pages' own
|
|
31
|
+
elements, and those were read again only when the list of pages changed — an edit to one page (its slug, its flag)
|
|
32
|
+
leaves that list the same, and the routes kept its old address until something else rebuilt them.
|
|
33
|
+
- **Packages declare only what they use** (`@plitzi/sdk-dev-tools`, `@plitzi/sdk-shared`): `@plitzi/sdk-plugins`, which
|
|
34
|
+
the dev tools no longer import, and `terser`, which no build here runs, are no longer dependencies.
|
|
35
|
+
- **An edited page keeps its route up to date** (`@plitzi/plitzi-sdk`): the routes are built from the pages' own
|
|
36
|
+
elements, which were read again only when the list of pages changed — an edit to one page (its slug, its flag) left
|
|
37
|
+
the list the same and the route at the old address. They follow every edit to a page now, and stay the same object
|
|
38
|
+
while no page changes.
|
|
39
|
+
- **`@plitzi/sdk-dev-tools` no longer depends on `@plitzi/sdk-plugins`**, which nothing in it imports.
|
|
40
|
+
- **A dropdown's menu opens inside a card that lifts or clips** (`@plitzi/sdk-elements`, `@plitzi/sdk-shared`): drawn
|
|
41
|
+
inside the dropdown, an ancestor with a `transform` — a card lifting on hover — made itself the containing block of
|
|
42
|
+
the menu's `position: fixed`, and one with `overflow: hidden` cut it off: the menu opened and nobody saw it. The open
|
|
43
|
+
menu and its backdrop are drawn at the space's root (`spaceRootOf`, `@plitzi/sdk-shared/helpers/spaceRoot`); a
|
|
44
|
+
style written for the popup by an ancestor's selector no longer reaches it — its own classes do.
|
|
45
|
+
- **A copy button says when it could not copy** (`@plitzi/sdk-elements`, `@plitzi/sdk-shared`,
|
|
46
|
+
`@plitzi/sdk-interactions`, `@plitzi/sdk-variables`, `@plitzi/sdk-dev-tools`): a page not served over https has no
|
|
47
|
+
clipboard — a phone opening a development server by its address — and a code block's "Copy" threw there. It reads
|
|
48
|
+
"Not copied", and says why. `clipboardWriter` and `copyText` (`@plitzi/sdk-shared/helpers/clipboard`) are the one
|
|
49
|
+
check, the `copyToClipboard` step's too.
|
|
50
|
+
|
|
51
|
+
## Authoring
|
|
52
|
+
- **`plitziSdk` is authored like any element** (`@plitzi/sdk-authoring`, `@plitzi/sdk-elements`): its declaration moved
|
|
53
|
+
to `@plitzi/sdk-elements` beside the others, so it has a factory — `plitziSdk({ id, bind: { offlineData: 'view.data'
|
|
54
|
+
} })` —, its attributes typed, and `plitzi explain` knows it.
|
|
55
|
+
- **A binding may write part of an attribute** (`@plitzi/sdk-authoring`): `offlineData.schema` writes into
|
|
56
|
+
`offlineData`, as the runtime always did; authoring refused it as an attribute nothing reads.
|
|
57
|
+
- **`choosesChildren`** (`@plitzi/sdk-shared`, `@plitzi/sdk-authoring`): a plugin that shows only some of the elements
|
|
58
|
+
put inside it — a dashboard's panels, a wizard's step — says so in its declaration, and the page checks owe none of
|
|
59
|
+
them on screen; what it draws is still read by the checks of the whole page (images, sideways scroll, legibility).
|
|
60
|
+
`verify` was red on every such page.
|
|
61
|
+
|
|
62
|
+
- **A page says how the document scrolls** (`@plitzi/sdk-elements`, `@plitzi/sdk-authoring`, `@plitzi/sdk-mcp`):
|
|
63
|
+
`documentScroll: 'locked'` holds the document still while the page is open — a dashboard or a board used with a
|
|
64
|
+
finger, where the whole page was dragged and bounced back though nothing in it scrolls — and `'noBounce'` keeps the
|
|
65
|
+
scroll without the rubber band or pull-to-refresh. The page draws the rule itself, so it is in the server's HTML and
|
|
66
|
+
leaves with the page; never inside a widget, a space drawn in another, or the builder's canvas. A Settings select,
|
|
67
|
+
`PageSpec.documentScroll`, `upsertPage`'s `documentScroll` (`null` undoes it) and the page read; an unknown value is
|
|
68
|
+
refused (`attribute-value`). `upsertPage` is now held to the lint of the page it writes, as element writes are.
|
|
69
|
+
|
|
70
|
+
## MCP
|
|
71
|
+
- **`@plitzi/sdk-mcp/render`** (`@plitzi/sdk-mcp`): `plitzi_render`'s widget render on its own — no MCP server, no SSR,
|
|
72
|
+
no OAuth — for a project whose own agent draws in its own pages: `render`, `renderWidgetShape` to declare it as a
|
|
73
|
+
tool, `renderGuideText` for the agent. `base`, the style of the project's space, brings its tokens, classes and fonts
|
|
74
|
+
to the widget.
|
|
75
|
+
|
|
76
|
+
## Server
|
|
77
|
+
- **`publicUrl` says where people reach the server** (`@plitzi/sdk-server`): it was `http://127.0.0.1:<port>` whatever
|
|
78
|
+
the server was. It is `https` once `serverOptions.tls` gives it a certificate, and this machine's network address
|
|
79
|
+
with `HOST` open to the network (what a tablet opens, what an OAuth provider sends it back to); `PUBLIC_URL` still
|
|
80
|
+
wins. The network addresses it prints say `https` too.
|
|
81
|
+
- **A server serving TLS reaches itself** (`@plitzi/sdk-server`): with a local certificate (mkcert) Node trusts nothing
|
|
82
|
+
the browsers were told to, so a runtime calling its own MCP failed. Its requests to its own address now connect to its
|
|
83
|
+
listener and are taken when it presents exactly its certificate (`reachOwnServer`, exported from `/runtime`).
|
|
84
|
+
- **A runtime reads compressed answers again** (`@plitzi/sdk-server`): the dispatcher `reachOwnServer` (and the
|
|
85
|
+
platform's `reachSpaceInside`) installs reached every other host with an undici connector that offers HTTP/2, and an
|
|
86
|
+
answer that came back over h2 reached Node's `fetch` without its `content-encoding` — every API that compresses read
|
|
87
|
+
as Brotli bytes. Other hosts are reached over HTTP/1.1 now, as Node's own `fetch` reaches them.
|
|
88
|
+
- **A project's server serves HTTPS from `.env`** (`@plitzi/sdk-server`, `@plitzi/sdk-shared`): `TLS_CERT` and
|
|
89
|
+
`TLS_KEY`, the certificate's and the key's paths — what `plitzi cert` writes — with no code of the project's;
|
|
90
|
+
`serverOptions.tls` still wins. A network address the certificate does not name is said at boot, the machine's
|
|
91
|
+
`.local` name is printed among the addresses when it is named, and a server on loopback alone says how to open it to
|
|
92
|
+
the network.
|
|
93
|
+
- **A session survives a phone on the Wi-Fi** (`@plitzi/sdk-server`): a private network address (`192.168.…`, `10.…`,
|
|
94
|
+
Tailscale's `100.64/10`, IPv6 unique- and link-local) and a machine's mDNS name (`studio.local`) get the local
|
|
95
|
+
cookie profile — `SameSite=Lax`, no `Secure`, no `Domain`. They got `SameSite=None; Secure`, which a browser drops
|
|
96
|
+
over http: nobody could sign in from a tablet. A deployment's own `.local` sub-domains (`app.example.local`) keep the
|
|
97
|
+
strict profile.
|
|
98
|
+
- **Hiding the dev tools on a server over HTTPS hydrates** (`@plitzi/sdk-server`): a server with a certificate speaks
|
|
99
|
+
HTTP/2, which sends no `Host` — only `:authority` — and the cookies named for the origin's port (the dev tools'
|
|
100
|
+
`plitzi_debug_<port>`, forced flags, painted state) were looked for without it. Shift+F12 hid the dev tools in the
|
|
101
|
+
browser, the server rendered them back, and the page failed to hydrate. Every one is read off `requestAuthority`.
|
|
102
|
+
- **A rebuild of plugins says it finished** (`@plitzi/sdk-server`): bundles removed under a running server (`tmp/`
|
|
103
|
+
deleted) were each a warning, "rebuilding…", and their "ready" at a level a project's terminal does not show. It is
|
|
104
|
+
one episode now: said when noticed, and again when the last is built — how many, how long, which failed.
|
|
105
|
+
- **`tmp/dev-server.json` records the scheme** (`@plitzi/sdk-server`): `url` is `https` with a certificate, and the
|
|
106
|
+
file adds the network addresses and the `publicUrl`.
|
|
107
|
+
- **`public/` is asked about every time** (`@plitzi/sdk-server`): it was cached for an hour — a `.js` or `.css` in it
|
|
108
|
+
for a year, `immutable` — so a file a project rewrites while it runs arrived stale. It is `no-cache` now, answered
|
|
109
|
+
`304` by its `ETag` while unchanged; `immutable` stays for what is versioned (the SDK, the plugins).
|
|
110
|
+
|
|
111
|
+
## CLI
|
|
112
|
+
- **`check`, `shot`, `verify` and `visual` find a server on HTTPS** (`@plitzi/cli`): they rebuilt
|
|
113
|
+
`http://127.0.0.1:<port>`, so a project serving a certificate had no page checked. They read the URL `npm start`
|
|
114
|
+
recorded, and take a local certificate on this machine only. A project's `playwright.config.ts` comes from
|
|
115
|
+
`plitzi upgrade`.
|
|
116
|
+
- **`verify` runs the project's tests** (`@plitzi/cli`): a step `test`, after the lint, when `package.json` has a
|
|
117
|
+
`test` script.
|
|
118
|
+
- **`tsconfig.json` is the project's** (`@plitzi/cli`): the compiler options moved to `plitzi/tsconfig.base.json`, which
|
|
119
|
+
the CLI keeps up and `tsconfig.json` extends — so a folder of the project's own (`scripts/`, `tools/`) goes in its
|
|
120
|
+
`include` without changing a file of the CLI's. `plitzi doctor --fix` makes an older `tsconfig.json` extend it,
|
|
121
|
+
keeping only the options the project changed.
|
|
122
|
+
- **`doctor --fix` and `upgrade` write as the project's Prettier does** (`@plitzi/cli`): a repaired `tsconfig.json` or
|
|
123
|
+
`package.json` left `verify`'s format step red.
|
|
124
|
+
- **`upgrade` renames `usePlitziServiceContext`** (`@plitzi/cli`): with `PlitziServiceProvider` and
|
|
125
|
+
`PlitziServiceContextValue`, renamed in 0.38.12 with no alias — import, use and the module path that named it.
|
|
126
|
+
- **`skills update` compares every file** (`@plitzi/cli`): only `SKILL.md` was, so a change in a reference alone was
|
|
127
|
+
"up to date".
|
|
128
|
+
- **`NOTES.md`, the project's notes for agents** (`@plitzi/cli`): `AGENTS.md` and `CLAUDE.md` are the CLI's and
|
|
129
|
+
`upgrade` replaces them, so what a project's own sessions had to know had nowhere to live. `CLAUDE.md` imports
|
|
130
|
+
`NOTES.md`, `AGENTS.md` sends every agent to it, and nothing the CLI does touches it; `doctor --fix` writes one for
|
|
131
|
+
a project that has none.
|
|
132
|
+
|
|
133
|
+
- **`start:dev-inspect`** (`@plitzi/cli`): a server project's `start:dev` with Node's inspector open on
|
|
134
|
+
127.0.0.1:9229, so a debugger (VS Code, `chrome://inspect`) attaches to the server, and again after each restart.
|
|
135
|
+
`plitzi upgrade` adds it; `plitzi runtime add` has it restart on the runtime too.
|
|
136
|
+
- **`plitzi cert`** (`@plitzi/cli`): HTTPS while developing, for a phone or a tablet on the Wi-Fi — over http its
|
|
137
|
+
browser gives a page no microphone, camera or clipboard. A certificate from mkcert's local authority for this machine,
|
|
138
|
+
its network addresses and its `.local` name, in `tmp/tls/`, named in `.env`; what to install on the phone, said.
|
|
139
|
+
- **A browser project opens to the network** (`@plitzi/cli`): its `vite.config.ts` reads `HOST`, `TLS_CERT` and
|
|
140
|
+
`TLS_KEY` from `.env`, as a server project does, and writes `tmp/dev-server.json` — the port Vite took and the scheme
|
|
141
|
+
— so `page check`, `page shot` and `visual` find it on another port or over HTTPS. `plitzi upgrade` brings it.
|
|
142
|
+
|
|
143
|
+
## Docs
|
|
144
|
+
- **Two plugins share through `state`** (`@plitzi/sdk-authoring` skill): each plugin is a bundle of its own, so a module
|
|
145
|
+
both import is two copies, and what one keeps there the other never sees.
|
|
146
|
+
- **`verify --help`** names the project's tests among its steps.
|
|
147
|
+
|
|
3
148
|
## 0.38.13
|
|
4
149
|
|
|
5
150
|
### Patch Changes
|
|
@@ -68,6 +68,12 @@ export interface ElementDeclarationData {
|
|
|
68
68
|
* `plitzi page check`), which would otherwise wait for it to be on screen and report it hidden.
|
|
69
69
|
*/
|
|
70
70
|
drawsNothing?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Whether the element shows only some of the children put inside it, chosen as it runs — a dashboard showing the
|
|
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.
|
|
75
|
+
*/
|
|
76
|
+
choosesChildren?: boolean;
|
|
71
77
|
/**
|
|
72
78
|
* The attributes the page server evaluates against a context of its own, never where the element renders: a
|
|
73
79
|
* provider's `notFound`, read against its answer; a page's title and description, read against its server providers.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The clipboard's `writeText`, bound — or `undefined` where the browser offers none. Typed as always there, it is not:
|
|
3
|
+
* a page not served over https has none (a phone opening a development server by its network address), nor has the
|
|
4
|
+
* server. A copy button that called it straight threw on such a page.
|
|
5
|
+
*/
|
|
6
|
+
export declare const clipboardWriter: () => ((text: string) => Promise<void>) | undefined;
|
|
7
|
+
/** Copies `text`: whether it reached the clipboard — not where there is none, nor when the browser refuses it. */
|
|
8
|
+
export declare const copyText: (text: string) => Promise<boolean>;
|
|
9
|
+
/** What a copy button says when it could not copy, for its `title`. */
|
|
10
|
+
export declare const NOT_COPIED_REASON = "This page cannot reach the clipboard: it is not served over https, or the browser refused.";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/helpers/clipboard.ts
|
|
2
|
+
var e = () => {
|
|
3
|
+
let e = typeof navigator > "u" ? void 0 : Reflect.get(navigator, "clipboard"), t = typeof e == "object" && e ? Reflect.get(e, "writeText") : void 0;
|
|
4
|
+
if (typeof t == "function") return async (n) => {
|
|
5
|
+
await Reflect.apply(t, e, [n]);
|
|
6
|
+
};
|
|
7
|
+
}, t = async (t) => {
|
|
8
|
+
let n = e();
|
|
9
|
+
if (!n) return !1;
|
|
10
|
+
try {
|
|
11
|
+
return await n(t), !0;
|
|
12
|
+
} catch {
|
|
13
|
+
return !1;
|
|
14
|
+
}
|
|
15
|
+
}, n = "This page cannot reach the clipboard: it is not served over https, or the browser refused.";
|
|
16
|
+
//#endregion
|
|
17
|
+
export { n as NOT_COPIED_REASON, e as clipboardWriter, t as copyText };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* True under a space: what a space drawn inside it — the `plitziSdk` element, a plugin rendering a space of its own —
|
|
3
|
+
* reads to know the document is not its own. The space itself keeps the answer in `render.enclosed`, where everything
|
|
4
|
+
* in it reads it; this context is only how it learns it.
|
|
5
|
+
*
|
|
6
|
+
* Shared, because the space around may be another copy of the runtime: a plugin imports the SDK through the page's
|
|
7
|
+
* import map.
|
|
8
|
+
*/
|
|
9
|
+
export declare const EnclosingSpaceContext: import('react').Context<boolean>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** The class on a space's root element, where what floats above its page — a dropdown's open menu — is drawn. */
|
|
2
|
+
export declare const SPACE_ROOT_CLASS = "plitzi-sdk";
|
|
3
|
+
/** The root of the space `node` is drawn in: the nearest one, for a space drawn inside another. */
|
|
4
|
+
export declare const spaceRootOf: (node: Element | null | undefined) => HTMLElement | null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { NetworkInterfaceInfo } from 'node:os';
|
|
2
|
+
/**
|
|
3
|
+
* This machine as another device on its network reaches it — a phone on the same Wi-Fi opening the project's server —
|
|
4
|
+
* said once for the server, which prints where to open it, and the CLI, which makes a certificate naming it.
|
|
5
|
+
*/
|
|
6
|
+
/** Its IPv4 addresses on the network (`os.networkInterfaces()`): what a phone opens it by today. */
|
|
7
|
+
export declare const networkAddresses: (interfaces: NodeJS.Dict<NetworkInterfaceInfo[]>) => string[];
|
|
8
|
+
/**
|
|
9
|
+
* The name mDNS gives it (`os.hostname()` → `studio.local`), which outlives the address the router hands it: a
|
|
10
|
+
* certificate made for it still serves after the address changes.
|
|
11
|
+
*/
|
|
12
|
+
export declare const localNetworkName: (machine: string) => string;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region src/project/network.ts
|
|
2
|
+
var e = (e) => Object.values(e).flat().flatMap((e) => e && e.family === "IPv4" && !e.internal ? [e.address] : []), t = (e) => `${(e.split(".").at(0) ?? "").toLowerCase()}.local`;
|
|
3
|
+
//#endregion
|
|
4
|
+
export { t as localNetworkName, e as networkAddresses };
|