@niscorp/nova 0.1.4 → 0.2.1
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/ADAPTER.md +6 -6
- package/CHANGELOG.md +78 -0
- package/README.md +102 -34
- package/SHELL_DOCS.md +13 -4
- package/dist/adapters/dom/components/index.d.cts +2 -2
- package/dist/adapters/dom/components/index.d.ts +2 -2
- package/dist/adapters/dom/index.cjs +163 -34
- package/dist/adapters/dom/index.cjs.map +1 -1
- package/dist/adapters/dom/index.d.cts +2 -2
- package/dist/adapters/dom/index.d.ts +2 -2
- package/dist/adapters/dom/index.js +6 -6
- package/dist/adapters/dom/server.cjs +0 -2
- package/dist/adapters/dom/server.cjs.map +1 -1
- package/dist/adapters/dom/server.d.cts +2 -2
- package/dist/adapters/dom/server.d.ts +2 -2
- package/dist/adapters/dom/server.js +6 -6
- package/dist/adapters/react/components/index.cjs +6 -8
- package/dist/adapters/react/components/index.cjs.map +1 -1
- package/dist/adapters/react/components/index.d.cts +4 -4
- package/dist/adapters/react/components/index.d.ts +4 -4
- package/dist/adapters/react/components/index.js +7 -7
- package/dist/adapters/react/index.cjs +181 -51
- package/dist/adapters/react/index.cjs.map +1 -1
- package/dist/adapters/react/index.d.cts +4 -4
- package/dist/adapters/react/index.d.ts +4 -4
- package/dist/adapters/react/index.js +7 -7
- package/dist/adapters/tty/components/index.d.cts +2 -2
- package/dist/adapters/tty/components/index.d.ts +2 -2
- package/dist/adapters/tty/index.cjs +0 -2
- package/dist/adapters/tty/index.cjs.map +1 -1
- package/dist/adapters/tty/index.d.cts +2 -2
- package/dist/adapters/tty/index.d.ts +2 -2
- package/dist/adapters/tty/index.js +4 -4
- package/dist/adapters/tty/index.js.map +1 -1
- package/dist/adapters/vue/components/index.cjs +4 -6
- package/dist/adapters/vue/components/index.cjs.map +1 -1
- package/dist/adapters/vue/components/index.d.cts +9 -9
- package/dist/adapters/vue/components/index.d.ts +9 -9
- package/dist/adapters/vue/components/index.js +7 -7
- package/dist/adapters/vue/index.cjs +175 -46
- package/dist/adapters/vue/index.cjs.map +1 -1
- package/dist/adapters/vue/index.d.cts +4 -4
- package/dist/adapters/vue/index.d.ts +4 -4
- package/dist/adapters/vue/index.js +9 -9
- package/dist/adapters/vue/index.js.map +1 -1
- package/dist/agent/index.d.cts +2 -2
- package/dist/agent/index.d.ts +2 -2
- package/dist/{chunk-7PKS7UYL.js → chunk-3JRTELLC.js} +3 -3
- package/dist/{chunk-7PKS7UYL.js.map → chunk-3JRTELLC.js.map} +1 -1
- package/dist/{chunk-WZVQ5PUB.js → chunk-DU2VIJAF.js} +59 -17
- package/dist/chunk-DU2VIJAF.js.map +1 -0
- package/dist/{chunk-UUYXVOK2.js → chunk-F2H7WP6R.js} +16 -16
- package/dist/chunk-F2H7WP6R.js.map +1 -0
- package/dist/{chunk-KYQ4EAQH.js → chunk-G4LSLLGI.js} +17 -17
- package/dist/chunk-G4LSLLGI.js.map +1 -0
- package/dist/chunk-OE4E6IBD.js +25 -0
- package/dist/chunk-OE4E6IBD.js.map +1 -0
- package/dist/chunk-RFBIGRCI.js +127 -0
- package/dist/chunk-RFBIGRCI.js.map +1 -0
- package/dist/{chunk-4I2PFMY7.js → chunk-SVNK5NIK.js} +8 -8
- package/dist/chunk-SVNK5NIK.js.map +1 -0
- package/dist/chunk-V4BPFFFV.js +152 -0
- package/dist/chunk-V4BPFFFV.js.map +1 -0
- package/dist/{chunk-4ERQYDF6.js → chunk-VOD5JA4D.js} +10 -10
- package/dist/chunk-VOD5JA4D.js.map +1 -0
- package/dist/chunk-XQTI4Q4I.js +178 -0
- package/dist/chunk-XQTI4Q4I.js.map +1 -0
- package/dist/{chunk-RXECI7DE.js → chunk-Y6XVPRYH.js} +33 -17
- package/dist/chunk-Y6XVPRYH.js.map +1 -0
- package/dist/devtools/index.d.cts +2 -2
- package/dist/devtools/index.d.ts +2 -2
- package/dist/devtools/index.js +3 -3
- package/dist/document/index.cjs +228 -119
- package/dist/document/index.cjs.map +1 -1
- package/dist/document/index.d.cts +10 -8
- package/dist/document/index.d.ts +10 -8
- package/dist/document/index.js +3 -122
- package/dist/document/index.js.map +1 -1
- package/dist/examples/index.cjs +1186 -0
- package/dist/examples/index.cjs.map +1 -0
- package/dist/examples/index.d.cts +63 -0
- package/dist/examples/index.d.ts +63 -0
- package/dist/examples/index.js +1158 -0
- package/dist/examples/index.js.map +1 -0
- package/dist/head-CAzfTnpV.d.cts +25 -0
- package/dist/head-DRpbbj-l.d.ts +25 -0
- package/dist/i18n/index.d.cts +2 -2
- package/dist/i18n/index.d.ts +2 -2
- package/dist/i18n/index.js +2 -176
- package/dist/i18n/index.js.map +1 -1
- package/dist/index.cjs +206 -53
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -31
- package/dist/index.d.ts +23 -31
- package/dist/index.js +4 -4
- package/dist/{palette-Mx7XHYC6.d.ts → palette-CIpPH90W.d.ts} +1 -1
- package/dist/{palette-wbJB_svk.d.cts → palette-CvwZZCkx.d.cts} +1 -1
- package/dist/reflect/index.d.cts +2 -2
- package/dist/reflect/index.d.ts +2 -2
- package/dist/reflect/index.js +3 -3
- package/dist/{types-B-rjaUX0.d.ts → types-BSKx5MXW.d.ts} +1 -1
- package/dist/{types-B_nOtkyt.d.ts → types-BWc-olbY.d.ts} +1 -1
- package/dist/{types-mRKXqZPX.d.cts → types-C9734_lJ.d.cts} +1 -1
- package/dist/{types-BB9RXel5.d.ts → types-D23TRvqe.d.ts} +1 -1
- package/dist/{types-uk19d6KC.d.cts → types-DsWNYc7R.d.cts} +1 -1
- package/dist/{types-BLVRduoz.d.cts → types-j290XhCn.d.cts} +1 -1
- package/dist/{types-PDXOkvtK.d.cts → types-qkzTfSye.d.cts} +1 -1
- package/dist/{types-DE77Jl2W.d.ts → types-qnKMx0_V.d.ts} +1 -1
- package/package.json +19 -8
- package/dist/chunk-4ERQYDF6.js.map +0 -1
- package/dist/chunk-4I2PFMY7.js.map +0 -1
- package/dist/chunk-EHHJJLRX.js +0 -16
- package/dist/chunk-EHHJJLRX.js.map +0 -1
- package/dist/chunk-KYQ4EAQH.js.map +0 -1
- package/dist/chunk-RXECI7DE.js.map +0 -1
- package/dist/chunk-UUYXVOK2.js.map +0 -1
- package/dist/chunk-UV5YGBHQ.js +0 -62
- package/dist/chunk-UV5YGBHQ.js.map +0 -1
- package/dist/chunk-WZVQ5PUB.js.map +0 -1
- package/dist/chunk-X7SSNSQC.js +0 -6
- package/dist/chunk-X7SSNSQC.js.map +0 -1
- package/dist/head-BNj8GwPO.d.cts +0 -20
- package/dist/head-CS6X6ZKr.d.ts +0 -20
- package/dist/{primitive-props-Cl5jiC8g.d.cts → primitive-props-CGoJvmcH.d.cts} +5 -5
- package/dist/{primitive-props-Cl5jiC8g.d.ts → primitive-props-CGoJvmcH.d.ts} +5 -5
package/ADAPTER.md
CHANGED
|
@@ -44,12 +44,12 @@ Map `RenderNode[]` to framework elements:
|
|
|
44
44
|
adapter renders a `<span data-nova-error>`; match that convention).
|
|
45
45
|
- `component` → look the name up in the registry; unknown names render an
|
|
46
46
|
error marker with code `COMPONENT_NOT_FOUND`, never throw.
|
|
47
|
-
- a head (`isHeadNode(node)`, the component named `HEAD_NAME`) → **nothing
|
|
48
|
-
It is
|
|
49
|
-
up in the registry, and never handed to its parent component as
|
|
50
|
-
kit that gives every child a cell would give it an empty one). An
|
|
51
|
-
for a surface with a
|
|
52
|
-
|
|
47
|
+
- a head (`isHeadNode(node)`, the component named `HEAD_NAME`) → **nothing**,
|
|
48
|
+
and nothing for its children. It is the document's, not the screen's: it is
|
|
49
|
+
never looked up in the registry, and never handed to its parent component as
|
|
50
|
+
a child (a kit that gives every child a cell would give it an empty one). An
|
|
51
|
+
adapter for a surface with a head of its own keeps that head on
|
|
52
|
+
`headOf(api)` — in a page, `createHeadKeeper` from `@niscorp/nova/document`.
|
|
53
53
|
|
|
54
54
|
Inject framework props from the node using the core constants:
|
|
55
55
|
`node.model` → `NOVA_MODEL_PROP` (`{ ref, path }`), `node.ref` →
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,83 @@
|
|
|
1
1
|
# @niscorp/nova
|
|
2
2
|
|
|
3
|
+
## 0.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fe30458: Every package exports its `package.json`, so an app can say which version of a package it runs by reading it from the package:
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import prism from '@niscorp/prism/package.json' with { type: 'json' };
|
|
11
|
+
prism.version; // the version that is installed, not the range that asked for it
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Until now the `exports` map hid it, and the only way to the version was a path into `node_modules`. `check:packages` installs the tarballs and reads every package's version this way.
|
|
15
|
+
|
|
16
|
+
**What to change:** nothing. An app that read a version by path can read it by name.
|
|
17
|
+
|
|
18
|
+
- 353b3c3: `@niscorp/nova/examples` — the reference as data. `NOVA_EXAMPLES` is 42 examples, in six groups (`NOVA_EXAMPLE_GROUPS`): the layout grammar (12), actions at work (7), endpoints (5), composition with fragments (5), shells (8) and i18n (5).
|
|
19
|
+
|
|
20
|
+
An example is a small app, what is done to it, and what it must then say: `{ id, group, title, description, action | shell, fragments?, layouts?, replies?, fetches?, phrases?, phraseKeys?, stage?, presses, expected }`. `action` is one action alone on one canvas (an example of the layout grammar is an action with no triggers); `shell` is several actions on several canvases. `replies` and `fetches` say what its endpoints are answered, so an example comes to the same thing wherever it is run. `presses` is what is done: a press, something typed, or the host changing the language. `expected` is every piece of text the screen then holds (its text, and what stands in props at a prose key), the one action's data, which actions stand on each canvas, and what was sent to each URL.
|
|
21
|
+
|
|
22
|
+
Every id an example brings begins with its own, so a host can hold all of them in one shell. The examples a host puts on its stage name only the plain components every kit has (`Stack`, `Text`, `Button`, `Input`) and nova's two slots, with no prop about looks, so whoever shows them draws them with its own kit. An example with `stage: false` (the five on i18n) is shown as what it comes to. The package's tests run each one and hold it to its `expected`.
|
|
23
|
+
|
|
24
|
+
Not in it: the adapters' own seams (`slotWrapper`), the look of nova's default components, and the harvest functions of `@niscorp/nova/i18n`, which are called, not mounted.
|
|
25
|
+
|
|
26
|
+
**What to change:** nothing.
|
|
27
|
+
|
|
28
|
+
- 7222c7d: The README's quick example runs as written. It registered no components, so it printed an error node (`COMPONENT_NOT_FOUND: Component not found in registry: Box`) where its comment promised the tree — and with components registered, `console.log` would still have printed the tree's children as `[Object]`. It now takes the terminal kit (`defaultRegistry()` from `@niscorp/nova/adapters/tty/components`), writes its text as children, the way the kits draw it, sends one press, and prints the whole tree; what it prints is in the README. No code changed.
|
|
29
|
+
|
|
30
|
+
**What to change:** nothing.
|
|
31
|
+
|
|
32
|
+
- c8982c2: `shellIdle(shell, { waitMs?, stopped? })` — a wait for what a press set going.
|
|
33
|
+
|
|
34
|
+
`shellSettled` answers once nothing is mounting. That is the first screen being whole, and it says nothing about what happens afterwards: a trigger's steps run detached from the event that fired them, so after `dispatch` it can answer `true` while the call the press made is still out. Anything that pressed and then read the screen had to sleep.
|
|
35
|
+
|
|
36
|
+
`shellIdle` resolves `true` once nothing is mounting **and** no chain the shell started is still running: no trigger's steps, no `emit` on its way to its listeners and what they then call, no hook a navigation started — including the re-read of an action a `pop` reveals, which runs while that action is already `active`. It takes the options `shellSettled` takes, with the same default wait, and resolves `false` when the wait runs out.
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
shell.dispatch({ type: 'ui:click', ref: 'save', origin });
|
|
40
|
+
await shellIdle(shell, { waitMs: 5000 }); // the call has answered, and what it chained to has run
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
It is about the shell's own work. It does not wait for the next body of a read the shell is following (a reactive read answers again when somebody else writes; `shell.onDataChange` says when), nor for anything outside the shell that an endpoint set going. A call that never answers holds it until the call's own timeout fails it.
|
|
44
|
+
|
|
45
|
+
`shellSettled` is unchanged, and still asks about mounts alone: a page is read whenever it is asked for, also while a long call is out, and that read should not wait on it.
|
|
46
|
+
|
|
47
|
+
`ActionRuntimeConfig` gains an optional `onChain`, which is how a runtime reports what it starts and does not await; a shell made by `createShell` wires it.
|
|
48
|
+
|
|
49
|
+
**What to change:** nothing. A check that slept after a press can await `shellIdle` instead.
|
|
50
|
+
|
|
51
|
+
## 0.2.0
|
|
52
|
+
|
|
53
|
+
### Minor Changes
|
|
54
|
+
|
|
55
|
+
- f1cec45: A Prism config that validates no longer names an op Prism does not have. `validate` accepted `{ card: { $fetch: … } }` and `{ $eval: "…" }`: the plain-object branch refused only the names of ops that exist, so any other `$` key passed as a template key. Such a config could be stored — an endpoint request, a vex mapping, a strata migration — and then failed every time it was evaluated (`E_NODE_SHAPE`, "Unsupported node shape").
|
|
56
|
+
|
|
57
|
+
A key that starts with `$` is now an op's name and nothing else. The template branch refuses every `$` key — the rule the evaluator already held — so `validate` reports it with the key and where it is (`card.$fetch: Not a Prism op. A key that starts with "$" names an op; data with such a key goes in $const.`), and `evaluate` and `compile` fail with `E_SCHEMA` before anything runs. An op's name used as a template key keeps its own message. `E_NODE_SHAPE` is left for a tree that never went through the schema: an IR handed to `execute`. Adding an op no longer takes a key away from templates.
|
|
58
|
+
- **prism** — the change, and a grammar narrowing: `nisc.prism` 2, a marker with no document step (a key that never evaluated has nothing to be rewritten to). `$` keys that are data are untouched: a `$const` payload, `$with` names, `$renameKeys` and `$fromEntries` keys. The JSON Schema's template key pattern is `^(?!\$)` instead of a list of every op.
|
|
59
|
+
- **nova, vex, moss, loom, cli, nisc** — no change of their own. They depend on prism and are released with it, so the set installs together; the configs they hand to prism (endpoint `request` and `response`, `$prism` bindings, vex mappings) are held to the same rule.
|
|
60
|
+
- **create-nisc** — the templates' sources are recorded at `nisc.prism` 2.
|
|
61
|
+
|
|
62
|
+
**What to change:** in a config with a `$`-prefixed key that is not a Prism op, remove the key — or put the object in `$const` if it is literal data. An app that keeps a `strata.lock.json` runs `pnpm strata upgrade`, then `pnpm strata verify`; there is nothing to edit unless it has such a config. Everything else: nothing.
|
|
63
|
+
|
|
64
|
+
BREAKING — approved by moccadroid, 2026-10-04: a config with a `$`-prefixed key that is not a Prism op no longer validates, compiles or evaluates — also where evaluation never reached the key (an untaken `$case` branch, a short-circuited `$or`, a `$map` body over an empty array), which used to work. A vex seed mapping with one fails when it is seeded, at boot, instead of on each replay. Code that matched `E_NODE_SHAPE` from `evaluate` gets `E_SCHEMA`. The `@niscorp` packages that depend on prism move with it, so an app moves them together (`@niscorp/nisc` 0.3.0).
|
|
65
|
+
|
|
66
|
+
### Patch Changes
|
|
67
|
+
|
|
68
|
+
- de6d980: A fix for the last fix: `nova:head` is the document's `<head>`, and holds what a head holds. 0.1.4 gave it five props (`title`, `description`, `image`, `kind`, `structured`) and wrote tags from them, which closed a head to whatever nova had been taught: no `og:image:alt`, no `og:type` but two, no whole address inside structured data. That was wrong, and it is replaced, not extended. The maintainer withdrew 0.1.4's props on 2026-10-04; this ships as a patch on that decision.
|
|
69
|
+
|
|
70
|
+
**What to change** (only an app that used 0.1.4's props): a `nova:head` node no longer takes props. Write its children instead — `nova:title`, `nova:meta`, `nova:link`, `nova:script` — each with the element's attributes as its props. `{ title: X }` becomes `{ component: 'nova:title', children: X }`; `description` becomes `nova:meta` with `name: 'description'`; `image` and `kind` become `nova:meta` with `property: 'og:image'` and `property: 'og:type'`; `structured` becomes `nova:script` with `type: 'application/ld+json'` and `data`. `og:title` and `og:description` are no longer written from the title and description: say them if they are wanted. An address is written as given — a picture's is not made whole from `site`. Code that called `headOf`, `placeHead` or `createTitleKeeper`, or read `head` off `renderDocument`'s result or a route report, takes the new shapes below.
|
|
71
|
+
- **nova** — a head's children are the elements a head holds, named as HTML names them, and **a child's props are that element's attributes, written as given**: nova keeps no list of them, so any `name`, `property` or `rel` can be said. Nothing in a head is drawn on the screen and no name has to be registered. With more than one head on a screen they are read in the order the screen is drawn, and an element that says the same thing as an earlier one (the title, a `<meta>` of that name or property, the canonical address) takes its place; anything else stands beside its like. What runs or styles is refused, left out and named: a script a browser would execute (`nova:script` is a data block — a JSON `type`, never a `src`), a stylesheet, `http-equiv`, a handler attribute. `headOf(api)` returns `{ elements, actions, refused }`. In `@niscorp/nova/document`, `placeHead(html, elements, { site, path })` writes them — an element takes the place of the tag that said the same thing, where it stood; what it wrote is marked `data-nova-head`, and a tag that gave way is kept inert in a `<template data-nova-own>` — and `createHeadKeeper(document)` replaces `createTitleKeeper`: the whole head follows the screen in the page, and the document's own tags come back when the screen stops saying them. Removed: the five props, the `Head` and `HeadProps` types, `createTitleKeeper`.
|
|
72
|
+
- **cli** — `build`, `export` and `start` write each path's head from those elements. A head that holds what it may not fails the path, like any other check. `site` still gives every path its own canonical address and `og:url`; it no longer touches a picture's address.
|
|
73
|
+
- **moss** — `renderDocument` and `exportDocuments` do the same from the snapshot (`head` on the result is `{ elements, actions, refused }`; a refusal is logged and left out), and the terminal keeps the whole head off the wire.
|
|
74
|
+
- **create-nisc** — the two own-shell templates write their welcome screen's head this way.
|
|
75
|
+
|
|
76
|
+
**Where a script goes:** in the app's own `index.html`, which holds anything and from which every page is written, or in the kit component that needs it. A layout is data and does not carry one.
|
|
77
|
+
|
|
78
|
+
- Updated dependencies [f1cec45]
|
|
79
|
+
- @niscorp/prism@0.2.0
|
|
80
|
+
|
|
3
81
|
## 0.1.4
|
|
4
82
|
|
|
5
83
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -103,12 +103,8 @@ Explicitly out of scope right now:
|
|
|
103
103
|
## Quick example
|
|
104
104
|
|
|
105
105
|
```ts
|
|
106
|
-
import {
|
|
107
|
-
|
|
108
|
-
createComponentRegistry,
|
|
109
|
-
createLayoutStore,
|
|
110
|
-
type ActionDefinition,
|
|
111
|
-
} from '@niscorp/nova';
|
|
106
|
+
import { createShell, createLayoutStore, type ActionDefinition } from '@niscorp/nova';
|
|
107
|
+
import { defaultRegistry } from '@niscorp/nova/adapters/tty/components';
|
|
112
108
|
|
|
113
109
|
const counter: ActionDefinition = {
|
|
114
110
|
id: 'counter',
|
|
@@ -123,27 +119,57 @@ const counter: ActionDefinition = {
|
|
|
123
119
|
layout: {
|
|
124
120
|
component: 'Box',
|
|
125
121
|
children: [
|
|
126
|
-
{ component: 'Text',
|
|
127
|
-
{ component: 'Button', ref: 'inc',
|
|
122
|
+
{ component: 'Text', children: 'Count: {{$.count}}' },
|
|
123
|
+
{ component: 'Button', ref: 'inc', children: '+1' },
|
|
128
124
|
],
|
|
129
125
|
},
|
|
130
126
|
};
|
|
131
127
|
|
|
132
128
|
const shell = createShell({
|
|
133
129
|
canvases: [{ id: 'main' }],
|
|
134
|
-
registry:
|
|
130
|
+
registry: defaultRegistry(),
|
|
135
131
|
layoutStore: createLayoutStore(),
|
|
136
132
|
actions: { counter },
|
|
137
133
|
});
|
|
138
134
|
|
|
139
135
|
const id = shell.push('main', 'counter');
|
|
140
136
|
const runtime = shell.getRuntime(id);
|
|
141
|
-
|
|
142
|
-
|
|
137
|
+
shell.dispatch({ type: 'ui:click', ref: 'inc' });
|
|
138
|
+
console.dir(runtime?.render(), { depth: null });
|
|
143
139
|
```
|
|
144
140
|
|
|
145
|
-
|
|
146
|
-
|
|
141
|
+
It prints the `RenderNode[]` tree, after the press:
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
[
|
|
145
|
+
{
|
|
146
|
+
type: 'component',
|
|
147
|
+
name: 'Box',
|
|
148
|
+
props: {},
|
|
149
|
+
children: [
|
|
150
|
+
{
|
|
151
|
+
type: 'component',
|
|
152
|
+
name: 'Text',
|
|
153
|
+
props: {},
|
|
154
|
+
children: [ { type: 'text', value: 'Count: 1' } ]
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
type: 'component',
|
|
158
|
+
name: 'Button',
|
|
159
|
+
props: {},
|
|
160
|
+
children: [ { type: 'text', value: '+1' } ],
|
|
161
|
+
ref: 'inc'
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
]
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
There is no React in that example, and no browser. The registry is empty
|
|
169
|
+
until a kit is registered, and a layout that names a component it does not
|
|
170
|
+
hold renders an error node (`COMPONENT_NOT_FOUND`) in its place;
|
|
171
|
+
`defaultRegistry()` is the terminal kit. A framework adapter would consume the
|
|
172
|
+
same `RenderNode[]` and produce real elements.
|
|
147
173
|
|
|
148
174
|
---
|
|
149
175
|
|
|
@@ -231,31 +257,56 @@ effects emitted from action steps back into shell calls.
|
|
|
231
257
|
|
|
232
258
|
### The head
|
|
233
259
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
260
|
+
`nova:head` is the document's `<head>`, as a node in a layout. Its children
|
|
261
|
+
are the elements a head holds, named as HTML names them, and bound to the
|
|
262
|
+
action's data like anything else in the layout:
|
|
237
263
|
|
|
238
264
|
```typescript
|
|
239
|
-
{ component: 'nova:head',
|
|
265
|
+
{ component: 'nova:head', children: [
|
|
266
|
+
{ component: 'nova:title', children: '{{$.page.title}} · the site' },
|
|
267
|
+
{ component: 'nova:meta', props: { name: 'description', content: '$.page.lead' } },
|
|
268
|
+
{ component: 'nova:meta', props: { property: 'og:image:alt', content: '$.page.title' } },
|
|
269
|
+
{ component: 'nova:link', props: { rel: 'alternate', hreflang: 'de', href: '$.page.german' } },
|
|
270
|
+
{ component: 'nova:script', props: { type: 'application/ld+json', data: '$.page.about' } },
|
|
271
|
+
]}
|
|
240
272
|
```
|
|
241
273
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
274
|
+
**A child's props are that element's attributes, written as given.** Nova
|
|
275
|
+
keeps no list of them: any `name`, `property` or `rel` there is — or will be —
|
|
276
|
+
can be said without nova learning it. `nova:title`'s text is its children;
|
|
277
|
+
`nova:script` takes a `type` and its `data` (any JSON). Loops and conditions
|
|
278
|
+
work in a head as they do anywhere in a layout.
|
|
279
|
+
|
|
280
|
+
**Nothing in it is drawn on the screen.** No adapter builds an element for a
|
|
281
|
+
head or for what it holds, no registry has to have the names, and a component
|
|
282
|
+
is never handed a head as a child. It rides in the render tree, so it reaches
|
|
283
|
+
every place a screen does — a shell in the page, a snapshot a server drew, the
|
|
284
|
+
trees on a wire — and `headOf(api)` reads it off any of them:
|
|
285
|
+
`{ elements, actions, refused }`.
|
|
286
|
+
|
|
287
|
+
A screen can hold more than one head: the shell's chrome says what holds on
|
|
288
|
+
every screen, an action says its own, a dialog opens over a page. They are
|
|
289
|
+
read in the order the screen is drawn, and an element that says the same thing
|
|
290
|
+
as an earlier one — the title, a `<meta>` of that name or property, the
|
|
291
|
+
canonical address — takes its place. Anything else stands beside its like. An
|
|
292
|
+
element whose value is not answered yet (no `content`, no `href`, no text) is
|
|
293
|
+
left out.
|
|
294
|
+
|
|
295
|
+
**What a head does not hold is what runs or styles**: a script a browser would
|
|
296
|
+
execute (`nova:script` is a data block — a JSON `type`, never a `src`), a
|
|
297
|
+
stylesheet, `http-equiv`, a handler attribute. A layout is data, and data that
|
|
298
|
+
reaches every page must not be able to run. Such an element is left out and
|
|
299
|
+
named in `refused`. Those belong in the app's own `index.html`, which holds
|
|
300
|
+
anything, or in the kit component that needs them.
|
|
301
|
+
|
|
302
|
+
`@niscorp/nova/document` is the surface that has a `<head>`. `placeHead`
|
|
303
|
+
writes the elements into an HTML document being drawn to a string (what
|
|
304
|
+
`@niscorp/cli` and moss's `renderDocument` call): an element takes the place
|
|
305
|
+
of the tag that said the same thing, and anything else is added. In the page,
|
|
306
|
+
the DOM, React and Vue adapters keep `document.head` on the screen
|
|
307
|
+
(`createHeadKeeper`): its elements go in, the document's own tags give way to
|
|
308
|
+
them and come back when the screen stops saying them. To offer the names to a
|
|
309
|
+
layout agent, register them with `HEAD_META` so the palette lists them.
|
|
259
310
|
|
|
260
311
|
---
|
|
261
312
|
|
|
@@ -428,6 +479,23 @@ one, and checks every captured lab-app document still upgrades and parses.
|
|
|
428
479
|
|
|
429
480
|
---
|
|
430
481
|
|
|
482
|
+
## Examples
|
|
483
|
+
|
|
484
|
+
`@niscorp/nova/examples` exports the reference as data. `NOVA_EXAMPLES` is a list of small apps, each with what is done to it and what it must then say; `NOVA_EXAMPLE_GROUPS` names the groups they come in (layouts, actions, endpoints, composition, shells, i18n), in reading order.
|
|
485
|
+
|
|
486
|
+
```ts
|
|
487
|
+
import { NOVA_EXAMPLES } from '@niscorp/nova/examples';
|
|
488
|
+
|
|
489
|
+
const counter = NOVA_EXAMPLES.find((example) => example.id === 'counter');
|
|
490
|
+
// counter.action is an ActionDefinition: mount it in a shell and draw it with your own kit
|
|
491
|
+
// counter.presses: [{ ref: 'more' }, { ref: 'more' }, { ref: 'fewer' }]
|
|
492
|
+
// counter.expected: { data: { count: 1 }, says: ['Count: 1', 'One more', 'One fewer'] }
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
An example is one action alone on a canvas (`action`) or a small shell (`shell`: canvases, actions, and how the canvases are arranged). Beside either stand what it needs from its host: `fragments`, stored `layouts`, a phrase book (`phrases`, `phraseKeys`), and what its endpoints are answered (`replies` for `fn:`, `fetches` for a URL). Every id an example brings begins with the example's own, so a host can hold all of them in one shell.
|
|
496
|
+
|
|
497
|
+
The examples name only the plain components every kit has (`Stack`, `Text`, `Button`, `Input`) and nova's two slots, with no prop about looks. One that says `stage: false` (the ones on i18n) cannot simply be mounted beside a host's own screens, and is shown as what it comes to. The package's tests run each one, so what they say is what this version does.
|
|
498
|
+
|
|
431
499
|
## Building / dev
|
|
432
500
|
|
|
433
501
|
```bash
|
package/SHELL_DOCS.md
CHANGED
|
@@ -529,12 +529,12 @@ useEffect(() => {
|
|
|
529
529
|
|
|
530
530
|
Always dispose shells you create — they hold references to runtimes which hold references to event listeners.
|
|
531
531
|
|
|
532
|
-
### `shellView(shell)` and `
|
|
532
|
+
### `shellView(shell)`, `shellSettled(shell)` and `shellIdle(shell)`
|
|
533
533
|
|
|
534
|
-
|
|
534
|
+
Three helpers beside the shell: for anything that draws one, and for anything that presses something on one and reads what came of it.
|
|
535
535
|
|
|
536
536
|
```ts
|
|
537
|
-
import { shellView, shellSettled } from '@niscorp/nova';
|
|
537
|
+
import { shellView, shellSettled, shellIdle } from '@niscorp/nova';
|
|
538
538
|
|
|
539
539
|
const { api, subscribe } = shellView(shell); // the shell, as a RenderApi
|
|
540
540
|
api.frame(); // the shell layout's tree
|
|
@@ -543,12 +543,21 @@ api.dispatch('main', { type: 'ui:click', ref: 'save' }); // to the canvas's ac
|
|
|
543
543
|
const stop = subscribe(() => redraw()); // once per burst of changes
|
|
544
544
|
|
|
545
545
|
const whole = await shellSettled(shell, { waitMs: 300 }); // true: nothing is still mounting
|
|
546
|
+
|
|
547
|
+
api.dispatch('main', { type: 'ui:click', ref: 'save' });
|
|
548
|
+
const done = await shellIdle(shell, { waitMs: 5000 }); // true: what the press set going has finished
|
|
546
549
|
```
|
|
547
550
|
|
|
548
|
-
`api.dispatch` stamps an event that names no `origin` with the canvas's active instance; `api.publish(channel, payload?)` is `shell.publish`. `shellSettled` also
|
|
551
|
+
`api.dispatch` stamps an event that names no `origin` with the canvas's active instance; `api.publish(channel, payload?)` is `shell.publish`. `shellSettled` and `shellIdle` also take `stopped?: () => boolean` — once it answers `true` the wait ends with `false`.
|
|
549
552
|
|
|
550
553
|
`shellView` is what lets an adapter written against `RenderApi` (the DOM and TTY adapters, a moss terminal) draw a shell that lives beside it. `shellSettled` resolves `true` once no instance is `initializing` — every mount hook, and what it chained to, has been awaited — and `false` if `waitMs` (default 300) runs out first. It is the moment to draw a shell to markup, and the moment for the page's own shell to adopt it.
|
|
551
554
|
|
|
555
|
+
`shellSettled` asks about mounts and nothing else. A trigger's steps run detached from the event that fired them, so after a press it can answer `true` while the call the press made is still out. `shellIdle` is the wider question: nothing is mounting **and** no chain the shell started is still running — no trigger's steps, no `emit` on its way to its listeners (and what they then call), no re-read of an action a `pop` revealed. It is what a check awaits after `dispatch` instead of sleeping, and what anything that runs an action for somebody else awaits before it reads the screen. Same options, same default wait, `false` when the wait runs out.
|
|
556
|
+
|
|
557
|
+
Two things it does not wait for, because they are not this shell's work: the next body of a read the shell is **following** (a reactive read under moss answers again when somebody writes — wait for that with `shell.onDataChange`), and anything outside the shell that an endpoint set going. A call that never answers holds it until the call's own timeout fails it (30s by default; an endpoint's `timeoutMs` wins), so pass the `waitMs` you mean.
|
|
558
|
+
|
|
559
|
+
`shellSettled` is deliberately not widened to this. A page is read whenever it is asked for, also while a long call is out, and that read should not wait on it.
|
|
560
|
+
|
|
552
561
|
---
|
|
553
562
|
|
|
554
563
|
## Multi-canvas patterns
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { C as ComponentRegistry } from '../../../types-
|
|
1
|
+
import { C as ComponentRegistry } from '../../../types-j290XhCn.cjs';
|
|
2
2
|
import { DomComponent } from '../index.cjs';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import '../../../schemas-DPdeFlCT.cjs';
|
|
5
5
|
import '../../../schemas-pMyyuXV7.cjs';
|
|
6
|
-
import '../../../types-
|
|
6
|
+
import '../../../types-qkzTfSye.cjs';
|
|
7
7
|
import '../../../index-caZoXSwr.cjs';
|
|
8
8
|
import '../../../effects-CndX9K7D.cjs';
|
|
9
9
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { C as ComponentRegistry } from '../../../types-
|
|
1
|
+
import { C as ComponentRegistry } from '../../../types-qnKMx0_V.js';
|
|
2
2
|
import { DomComponent } from '../index.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import '../../../schemas-DPdeFlCT.js';
|
|
5
5
|
import '../../../schemas-pMyyuXV7.js';
|
|
6
|
-
import '../../../types-
|
|
6
|
+
import '../../../types-D23TRvqe.js';
|
|
7
7
|
import '../../../index-CNfzSBe2.js';
|
|
8
8
|
import '../../../effects-CndX9K7D.js';
|
|
9
9
|
|
|
@@ -14,35 +14,117 @@ var renderNodeKey = (node, index) => {
|
|
|
14
14
|
|
|
15
15
|
// src/layout/head.ts
|
|
16
16
|
var HEAD_NAME = "nova:head";
|
|
17
|
+
var HEAD_TITLE_NAME = "nova:title";
|
|
18
|
+
var HEAD_META_NAME = "nova:meta";
|
|
19
|
+
var HEAD_LINK_NAME = "nova:link";
|
|
20
|
+
var HEAD_SCRIPT_NAME = "nova:script";
|
|
21
|
+
var headKeyOf = (element) => {
|
|
22
|
+
const said = (name) => {
|
|
23
|
+
const found = Object.entries(element.attributes).find(([key]) => key.toLowerCase() === name)?.[1].trim().toLowerCase();
|
|
24
|
+
return found === void 0 || found === "" ? void 0 : found;
|
|
25
|
+
};
|
|
26
|
+
if (element.tag === "title") return "title";
|
|
27
|
+
if (element.tag === "meta") {
|
|
28
|
+
const [name, property] = [said("name"), said("property")];
|
|
29
|
+
if (name !== void 0) return `meta name ${name}`;
|
|
30
|
+
return property === void 0 ? void 0 : `meta property ${property}`;
|
|
31
|
+
}
|
|
32
|
+
if (element.tag === "link") return (said("rel") ?? "").split(/\s+/).includes("canonical") ? "link canonical" : void 0;
|
|
33
|
+
return void 0;
|
|
34
|
+
};
|
|
17
35
|
|
|
18
36
|
// src/shell/slot-names.ts
|
|
19
37
|
var CANVAS_SLOT_NAME = "CanvasSlot";
|
|
20
38
|
var ACTION_SLOT_NAME = "ActionSlot";
|
|
21
39
|
|
|
22
40
|
// src/shell/head.ts
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
if (
|
|
27
|
-
if (
|
|
28
|
-
return void 0;
|
|
41
|
+
var ATTRIBUTE_NAME = /^[A-Za-z][A-Za-z0-9:._-]*$/;
|
|
42
|
+
var DATA_TYPE = /^application\/([a-z0-9.-]+\+)?json$/i;
|
|
43
|
+
var written = (value) => {
|
|
44
|
+
if (typeof value === "string") return value.trim() === "" ? void 0 : value;
|
|
45
|
+
if (typeof value === "number") return String(value);
|
|
46
|
+
return value === true ? "" : void 0;
|
|
29
47
|
};
|
|
30
|
-
var
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
48
|
+
var attributesOf = (what, props, skip = []) => {
|
|
49
|
+
const attributes = {};
|
|
50
|
+
for (const [name, value] of Object.entries(props)) {
|
|
51
|
+
if (skip.includes(name)) continue;
|
|
52
|
+
if (!ATTRIBUTE_NAME.test(name)) return { refused: `${what}: "${name}" is not an attribute\u2019s name` };
|
|
53
|
+
if (/^on/i.test(name)) return { refused: `${what}: \`${name}\` is a handler, and a layout does not run` };
|
|
54
|
+
const text = written(value);
|
|
55
|
+
if (text !== void 0) attributes[name] = text;
|
|
56
|
+
}
|
|
57
|
+
return { attributes };
|
|
58
|
+
};
|
|
59
|
+
var has = (attributes, name) => Object.keys(attributes).some((key) => key.toLowerCase() === name);
|
|
60
|
+
var valueOf = (attributes, name) => Object.entries(attributes).find(([key]) => key.toLowerCase() === name)?.[1] ?? "";
|
|
61
|
+
var textOf = (nodes) => nodes.map((node) => node.type === "text" ? node.value : node.type === "fragment" ? textOf(node.children) : "").join("");
|
|
62
|
+
var titleOf = (node) => {
|
|
63
|
+
const text = textOf(node.children).trim();
|
|
64
|
+
return text === "" ? void 0 : { element: { tag: "title", attributes: {}, text } };
|
|
65
|
+
};
|
|
66
|
+
var metaOf = (node) => {
|
|
67
|
+
const read = attributesOf(HEAD_META_NAME, node.props);
|
|
68
|
+
if ("refused" in read) return read;
|
|
69
|
+
if (has(read.attributes, "http-equiv")) return { refused: `${HEAD_META_NAME}: \`http-equiv\` instructs the browser, and a layout does not` };
|
|
70
|
+
return has(read.attributes, "content") ? { element: { tag: "meta", attributes: read.attributes } } : void 0;
|
|
71
|
+
};
|
|
72
|
+
var linkOf = (node) => {
|
|
73
|
+
const read = attributesOf(HEAD_LINK_NAME, node.props);
|
|
74
|
+
if ("refused" in read) return read;
|
|
75
|
+
if (valueOf(read.attributes, "rel").toLowerCase().split(/\s+/).includes("stylesheet")) return { refused: `${HEAD_LINK_NAME}: a stylesheet styles the page, and a layout does not` };
|
|
76
|
+
return has(read.attributes, "href") ? { element: { tag: "link", attributes: read.attributes } } : void 0;
|
|
77
|
+
};
|
|
78
|
+
var scriptOf = (node) => {
|
|
79
|
+
const read = attributesOf(HEAD_SCRIPT_NAME, node.props, ["data"]);
|
|
80
|
+
if ("refused" in read) return read;
|
|
81
|
+
if (has(read.attributes, "src")) return { refused: `${HEAD_SCRIPT_NAME}: a script with a \`src\` runs, and a layout does not` };
|
|
82
|
+
const type = valueOf(read.attributes, "type");
|
|
83
|
+
if (!DATA_TYPE.test(type)) return { refused: `${HEAD_SCRIPT_NAME}: only a data block may be written (a JSON \`type\`), and "${type}" is not one` };
|
|
84
|
+
const data = node.props["data"];
|
|
85
|
+
if (data === void 0 || data === null || data === "") return void 0;
|
|
86
|
+
return { element: { tag: "script", attributes: read.attributes, text: JSON.stringify(data) } };
|
|
87
|
+
};
|
|
88
|
+
var READERS = {
|
|
89
|
+
[HEAD_TITLE_NAME]: titleOf,
|
|
90
|
+
[HEAD_META_NAME]: metaOf,
|
|
91
|
+
[HEAD_LINK_NAME]: linkOf,
|
|
92
|
+
[HEAD_SCRIPT_NAME]: scriptOf
|
|
41
93
|
};
|
|
42
94
|
var isHeadNode = (node) => node.type === "component" && node.name === HEAD_NAME;
|
|
43
95
|
var headOf = (api) => {
|
|
44
|
-
|
|
96
|
+
let heads = 0;
|
|
97
|
+
const said = [];
|
|
98
|
+
const refused = [];
|
|
45
99
|
const open = /* @__PURE__ */ new Set();
|
|
100
|
+
const hold = (nodes, action) => {
|
|
101
|
+
for (const node of nodes) {
|
|
102
|
+
if (node.type === "fragment") {
|
|
103
|
+
hold(node.children, action);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (node.type === "error") {
|
|
107
|
+
refused.push(`${HEAD_NAME}: ${node.message}`);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (node.type !== "component") continue;
|
|
111
|
+
const read = READERS[node.name];
|
|
112
|
+
if (read === void 0) {
|
|
113
|
+
refused.push(`${HEAD_NAME}: "${node.name}" is not something a head holds`);
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
const found = read(node);
|
|
117
|
+
if (found === void 0) continue;
|
|
118
|
+
if ("refused" in found) {
|
|
119
|
+
refused.push(found.refused);
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
const key = headKeyOf(found.element);
|
|
123
|
+
const earlier = key === void 0 ? -1 : said.findIndex((other) => headKeyOf(other.element) === key);
|
|
124
|
+
if (earlier >= 0) said.splice(earlier, 1);
|
|
125
|
+
said.push({ element: found.element, action });
|
|
126
|
+
}
|
|
127
|
+
};
|
|
46
128
|
const walk = (nodes, action) => {
|
|
47
129
|
for (const node of nodes) {
|
|
48
130
|
if (node.type === "fragment") {
|
|
@@ -51,7 +133,8 @@ var headOf = (api) => {
|
|
|
51
133
|
}
|
|
52
134
|
if (node.type !== "component") continue;
|
|
53
135
|
if (node.name === HEAD_NAME) {
|
|
54
|
-
|
|
136
|
+
heads += 1;
|
|
137
|
+
hold(node.children, action);
|
|
55
138
|
continue;
|
|
56
139
|
}
|
|
57
140
|
if (node.name === CANVAS_SLOT_NAME) {
|
|
@@ -67,9 +150,9 @@ var headOf = (api) => {
|
|
|
67
150
|
}
|
|
68
151
|
};
|
|
69
152
|
walk(api.frame(), void 0);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return {
|
|
153
|
+
if (heads === 0) return void 0;
|
|
154
|
+
const actions = [...new Set(said.flatMap((one) => one.action === void 0 ? [] : [one.action]))];
|
|
155
|
+
return { elements: said.map((one) => one.element), actions, refused };
|
|
73
156
|
};
|
|
74
157
|
|
|
75
158
|
// src/shell/view.ts
|
|
@@ -119,16 +202,62 @@ var shellView = (shell) => ({
|
|
|
119
202
|
}
|
|
120
203
|
});
|
|
121
204
|
|
|
122
|
-
// src/document/
|
|
123
|
-
var
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
205
|
+
// src/document/place-head.ts
|
|
206
|
+
var HEAD_MARK = "data-nova-head";
|
|
207
|
+
var OWN_MARK = "data-nova-own";
|
|
208
|
+
|
|
209
|
+
// src/document/head-keeper.ts
|
|
210
|
+
var TAGS2 = ["title", "meta", "link"];
|
|
211
|
+
var keyOfNode = (node) => {
|
|
212
|
+
const tag = TAGS2.find((name) => name === node.tagName.toLowerCase());
|
|
213
|
+
if (tag !== "title" && tag !== "meta" && tag !== "link") return void 0;
|
|
214
|
+
return headKeyOf({ tag, attributes: Object.fromEntries([...node.attributes].map((attribute) => [attribute.name, attribute.value])) });
|
|
215
|
+
};
|
|
216
|
+
var createHeadKeeper = (doc) => {
|
|
217
|
+
let mine = [];
|
|
218
|
+
let away = [];
|
|
219
|
+
let said;
|
|
220
|
+
const built = (element) => {
|
|
221
|
+
const node = doc.createElement(element.tag);
|
|
222
|
+
for (const [name, value] of Object.entries(element.attributes)) node.setAttribute(name, value);
|
|
223
|
+
node.setAttribute(HEAD_MARK, "");
|
|
224
|
+
if (element.text !== void 0) node.textContent = element.text;
|
|
225
|
+
return node;
|
|
226
|
+
};
|
|
227
|
+
const adopt = () => {
|
|
228
|
+
mine = [...doc.head.querySelectorAll(`[${HEAD_MARK}]`)];
|
|
229
|
+
const view = doc.defaultView;
|
|
230
|
+
for (const stash of doc.head.querySelectorAll(`template[${OWN_MARK}]`)) {
|
|
231
|
+
if (view === null || !(stash instanceof view.HTMLTemplateElement)) continue;
|
|
232
|
+
for (const child of [...stash.content.children]) {
|
|
233
|
+
const key = keyOfNode(child);
|
|
234
|
+
if (key !== void 0) away.push({ key, node: doc.importNode(child, true), before: null });
|
|
235
|
+
}
|
|
236
|
+
stash.remove();
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
return (elements) => {
|
|
240
|
+
const now = elements ?? [];
|
|
241
|
+
const next = JSON.stringify(now);
|
|
242
|
+
if (said === void 0) {
|
|
243
|
+
if (now.length === 0) return;
|
|
244
|
+
adopt();
|
|
245
|
+
}
|
|
246
|
+
if (next === said) return;
|
|
247
|
+
said = next;
|
|
248
|
+
for (const node of mine) node.remove();
|
|
249
|
+
mine = now.map(built);
|
|
250
|
+
const keys = new Set(now.flatMap((element) => headKeyOf(element) ?? []));
|
|
251
|
+
for (const node of [...doc.head.children]) {
|
|
252
|
+
const key = keyOfNode(node);
|
|
253
|
+
if (key === void 0 || !keys.has(key)) continue;
|
|
254
|
+
away.push({ key, node, before: node.nextSibling });
|
|
255
|
+
node.remove();
|
|
256
|
+
}
|
|
257
|
+
const [back, still] = [away.filter((gone) => !keys.has(gone.key)), away.filter((gone) => keys.has(gone.key))];
|
|
258
|
+
for (const gone of [...back].reverse()) doc.head.insertBefore(gone.node, gone.before !== null && gone.before.parentNode === doc.head ? gone.before : null);
|
|
259
|
+
away = still;
|
|
260
|
+
doc.head.append(...mine);
|
|
132
261
|
};
|
|
133
262
|
};
|
|
134
263
|
|
|
@@ -541,11 +670,11 @@ var mountShell = (root, registry, shell, options = {}) => {
|
|
|
541
670
|
}
|
|
542
671
|
};
|
|
543
672
|
const dom = createDomView(root, registry, api, options);
|
|
544
|
-
const
|
|
673
|
+
const keepHead = createHeadKeeper(root.ownerDocument);
|
|
545
674
|
const render = () => {
|
|
546
675
|
read = { trees: /* @__PURE__ */ new Map() };
|
|
547
676
|
dom.render();
|
|
548
|
-
if (root.isConnected)
|
|
677
|
+
if (root.isConnected) keepHead(headOf(api)?.elements);
|
|
549
678
|
};
|
|
550
679
|
render();
|
|
551
680
|
const stop = view.subscribe(render);
|