@niscorp/nova 0.1.4 → 0.2.0

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.
Files changed (113) hide show
  1. package/ADAPTER.md +6 -6
  2. package/CHANGELOG.md +30 -0
  3. package/README.md +46 -21
  4. package/dist/adapters/dom/components/index.d.cts +2 -2
  5. package/dist/adapters/dom/components/index.d.ts +2 -2
  6. package/dist/adapters/dom/index.cjs +163 -34
  7. package/dist/adapters/dom/index.cjs.map +1 -1
  8. package/dist/adapters/dom/index.d.cts +2 -2
  9. package/dist/adapters/dom/index.d.ts +2 -2
  10. package/dist/adapters/dom/index.js +6 -6
  11. package/dist/adapters/dom/server.cjs +0 -2
  12. package/dist/adapters/dom/server.cjs.map +1 -1
  13. package/dist/adapters/dom/server.d.cts +2 -2
  14. package/dist/adapters/dom/server.d.ts +2 -2
  15. package/dist/adapters/dom/server.js +6 -6
  16. package/dist/adapters/react/components/index.cjs +6 -8
  17. package/dist/adapters/react/components/index.cjs.map +1 -1
  18. package/dist/adapters/react/components/index.d.cts +4 -4
  19. package/dist/adapters/react/components/index.d.ts +4 -4
  20. package/dist/adapters/react/components/index.js +7 -7
  21. package/dist/adapters/react/index.cjs +181 -51
  22. package/dist/adapters/react/index.cjs.map +1 -1
  23. package/dist/adapters/react/index.d.cts +4 -4
  24. package/dist/adapters/react/index.d.ts +4 -4
  25. package/dist/adapters/react/index.js +7 -7
  26. package/dist/adapters/tty/components/index.d.cts +2 -2
  27. package/dist/adapters/tty/components/index.d.ts +2 -2
  28. package/dist/adapters/tty/index.cjs +0 -2
  29. package/dist/adapters/tty/index.cjs.map +1 -1
  30. package/dist/adapters/tty/index.d.cts +2 -2
  31. package/dist/adapters/tty/index.d.ts +2 -2
  32. package/dist/adapters/tty/index.js +4 -4
  33. package/dist/adapters/tty/index.js.map +1 -1
  34. package/dist/adapters/vue/components/index.cjs +4 -6
  35. package/dist/adapters/vue/components/index.cjs.map +1 -1
  36. package/dist/adapters/vue/components/index.d.cts +9 -9
  37. package/dist/adapters/vue/components/index.d.ts +9 -9
  38. package/dist/adapters/vue/components/index.js +7 -7
  39. package/dist/adapters/vue/index.cjs +175 -46
  40. package/dist/adapters/vue/index.cjs.map +1 -1
  41. package/dist/adapters/vue/index.d.cts +4 -4
  42. package/dist/adapters/vue/index.d.ts +4 -4
  43. package/dist/adapters/vue/index.js +9 -9
  44. package/dist/adapters/vue/index.js.map +1 -1
  45. package/dist/agent/index.d.cts +2 -2
  46. package/dist/agent/index.d.ts +2 -2
  47. package/dist/{chunk-7PKS7UYL.js → chunk-3JRTELLC.js} +3 -3
  48. package/dist/{chunk-7PKS7UYL.js.map → chunk-3JRTELLC.js.map} +1 -1
  49. package/dist/{chunk-4I2PFMY7.js → chunk-MHW5VEIM.js} +8 -8
  50. package/dist/chunk-MHW5VEIM.js.map +1 -0
  51. package/dist/chunk-OE4E6IBD.js +25 -0
  52. package/dist/chunk-OE4E6IBD.js.map +1 -0
  53. package/dist/{chunk-KYQ4EAQH.js → chunk-QXQCPH33.js} +17 -17
  54. package/dist/chunk-QXQCPH33.js.map +1 -0
  55. package/dist/chunk-RFBIGRCI.js +127 -0
  56. package/dist/chunk-RFBIGRCI.js.map +1 -0
  57. package/dist/{chunk-WZVQ5PUB.js → chunk-RYIIIXDX.js} +4 -4
  58. package/dist/{chunk-WZVQ5PUB.js.map → chunk-RYIIIXDX.js.map} +1 -1
  59. package/dist/{chunk-4ERQYDF6.js → chunk-UDCXGDLQ.js} +10 -10
  60. package/dist/chunk-UDCXGDLQ.js.map +1 -0
  61. package/dist/chunk-V4BPFFFV.js +152 -0
  62. package/dist/chunk-V4BPFFFV.js.map +1 -0
  63. package/dist/{chunk-UUYXVOK2.js → chunk-VU6NNCEJ.js} +16 -16
  64. package/dist/chunk-VU6NNCEJ.js.map +1 -0
  65. package/dist/{chunk-RXECI7DE.js → chunk-Y6XVPRYH.js} +33 -17
  66. package/dist/chunk-Y6XVPRYH.js.map +1 -0
  67. package/dist/devtools/index.d.cts +2 -2
  68. package/dist/devtools/index.d.ts +2 -2
  69. package/dist/devtools/index.js +3 -3
  70. package/dist/document/index.cjs +228 -119
  71. package/dist/document/index.cjs.map +1 -1
  72. package/dist/document/index.d.cts +10 -8
  73. package/dist/document/index.d.ts +10 -8
  74. package/dist/document/index.js +3 -122
  75. package/dist/document/index.js.map +1 -1
  76. package/dist/head-CAzfTnpV.d.cts +25 -0
  77. package/dist/head-DRpbbj-l.d.ts +25 -0
  78. package/dist/i18n/index.d.cts +2 -2
  79. package/dist/i18n/index.d.ts +2 -2
  80. package/dist/index.cjs +151 -41
  81. package/dist/index.cjs.map +1 -1
  82. package/dist/index.d.cts +19 -31
  83. package/dist/index.d.ts +19 -31
  84. package/dist/index.js +4 -4
  85. package/dist/{palette-Mx7XHYC6.d.ts → palette-CIpPH90W.d.ts} +1 -1
  86. package/dist/{palette-wbJB_svk.d.cts → palette-CvwZZCkx.d.cts} +1 -1
  87. package/dist/reflect/index.d.cts +2 -2
  88. package/dist/reflect/index.d.ts +2 -2
  89. package/dist/reflect/index.js +3 -3
  90. package/dist/{types-B-rjaUX0.d.ts → types-BSKx5MXW.d.ts} +1 -1
  91. package/dist/{types-B_nOtkyt.d.ts → types-BWc-olbY.d.ts} +1 -1
  92. package/dist/{types-mRKXqZPX.d.cts → types-C9734_lJ.d.cts} +1 -1
  93. package/dist/{types-BB9RXel5.d.ts → types-D23TRvqe.d.ts} +1 -1
  94. package/dist/{types-uk19d6KC.d.cts → types-DsWNYc7R.d.cts} +1 -1
  95. package/dist/{types-BLVRduoz.d.cts → types-j290XhCn.d.cts} +1 -1
  96. package/dist/{types-PDXOkvtK.d.cts → types-qkzTfSye.d.cts} +1 -1
  97. package/dist/{types-DE77Jl2W.d.ts → types-qnKMx0_V.d.ts} +1 -1
  98. package/package.json +3 -3
  99. package/dist/chunk-4ERQYDF6.js.map +0 -1
  100. package/dist/chunk-4I2PFMY7.js.map +0 -1
  101. package/dist/chunk-EHHJJLRX.js +0 -16
  102. package/dist/chunk-EHHJJLRX.js.map +0 -1
  103. package/dist/chunk-KYQ4EAQH.js.map +0 -1
  104. package/dist/chunk-RXECI7DE.js.map +0 -1
  105. package/dist/chunk-UUYXVOK2.js.map +0 -1
  106. package/dist/chunk-UV5YGBHQ.js +0 -62
  107. package/dist/chunk-UV5YGBHQ.js.map +0 -1
  108. package/dist/chunk-X7SSNSQC.js +0 -6
  109. package/dist/chunk-X7SSNSQC.js.map +0 -1
  110. package/dist/head-BNj8GwPO.d.cts +0 -20
  111. package/dist/head-CS6X6ZKr.d.ts +0 -20
  112. package/dist/{primitive-props-Cl5jiC8g.d.cts → primitive-props-CGoJvmcH.d.cts} +5 -5
  113. 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 something the screen says, not something it shows: it is never looked
49
- up in the registry, and never handed to its parent component as a child (a
50
- kit that gives every child a cell would give it an empty one). An adapter
51
- for a surface with a title of its own keeps that title on `headOf(api)` and
52
- gives it back when the screen has no head.
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,35 @@
1
1
  # @niscorp/nova
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 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").
8
+
9
+ 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.
10
+ - **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.
11
+ - **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.
12
+ - **create-nisc** — the templates' sources are recorded at `nisc.prism` 2.
13
+
14
+ **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.
15
+
16
+ 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).
17
+
18
+ ### Patch Changes
19
+
20
+ - 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.
21
+
22
+ **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.
23
+ - **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`.
24
+ - **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.
25
+ - **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.
26
+ - **create-nisc** — the two own-shell templates write their welcome screen's head this way.
27
+
28
+ **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.
29
+
30
+ - Updated dependencies [f1cec45]
31
+ - @niscorp/prism@0.2.0
32
+
3
33
  ## 0.1.4
4
34
 
5
35
  ### Patch Changes
package/README.md CHANGED
@@ -231,31 +231,56 @@ effects emitted from action steps back into shell calls.
231
231
 
232
232
  ### The head
233
233
 
234
- What a screen says about itself — its title, a sentence describing it, the
235
- picture shown where a link to it is previewed — is a node in a layout, bound
236
- to the action's data like any other:
234
+ `nova:head` is the document's `<head>`, as a node in a layout. Its children
235
+ are the elements a head holds, named as HTML names them, and bound to the
236
+ action's data like anything else in the layout:
237
237
 
238
238
  ```typescript
239
- { component: 'nova:head', props: { title: '$.page.title', description: '$.page.lead', image: '$.page.cover', kind: 'article' } }
239
+ { component: 'nova:head', children: [
240
+ { component: 'nova:title', children: '{{$.page.title}} · the site' },
241
+ { component: 'nova:meta', props: { name: 'description', content: '$.page.lead' } },
242
+ { component: 'nova:meta', props: { property: 'og:image:alt', content: '$.page.title' } },
243
+ { component: 'nova:link', props: { rel: 'alternate', hreflang: 'de', href: '$.page.german' } },
244
+ { component: 'nova:script', props: { type: 'application/ld+json', data: '$.page.about' } },
245
+ ]}
240
246
  ```
241
247
 
242
- `nova:head` (`HEAD_NAME`) **draws nothing**: no adapter builds an element for
243
- it, no registry has to hold it, and a component is never handed one as a
244
- child. It rides in the render tree, so it reaches every place a screen does —
245
- a shell in the page, a snapshot a server drew, the trees on a wire.
246
- `headOf(api)` reads it off any of them (`{ head, action? }`); with more than
247
- one on the screen the last one speaks, whole.
248
-
249
- Its props are a closed set (`HeadPropsSchema`): `title`, `description`,
250
- `image`, `kind` (`website` | `article`) and `structured` (JSON-LD). They
251
- say what the screen *is*; how that is spelled in tags is the writer's. There is
252
- no prop for the page's own address — a layout never holds one.
253
-
254
- `@niscorp/nova/document` is the surface that has a `<head>`: `placeHead`
255
- writes a head into an HTML document being drawn to a string (what
256
- `@niscorp/cli` and moss's `renderDocument` call), and in the page the DOM,
257
- React and Vue adapters keep the tab's title on it. To offer the node to a
258
- layout agent, register the name with `HEAD_META` so the palette lists it.
248
+ **A child's props are that element's attributes, written as given.** Nova
249
+ keeps no list of them: any `name`, `property` or `rel` there is — or will be —
250
+ can be said without nova learning it. `nova:title`'s text is its children;
251
+ `nova:script` takes a `type` and its `data` (any JSON). Loops and conditions
252
+ work in a head as they do anywhere in a layout.
253
+
254
+ **Nothing in it is drawn on the screen.** No adapter builds an element for a
255
+ head or for what it holds, no registry has to have the names, and a component
256
+ is never handed a head as a child. It rides in the render tree, so it reaches
257
+ every place a screen does — a shell in the page, a snapshot a server drew, the
258
+ trees on a wire — and `headOf(api)` reads it off any of them:
259
+ `{ elements, actions, refused }`.
260
+
261
+ A screen can hold more than one head: the shell's chrome says what holds on
262
+ every screen, an action says its own, a dialog opens over a page. They are
263
+ read in the order the screen is drawn, and an element that says the same thing
264
+ as an earlier one — the title, a `<meta>` of that name or property, the
265
+ canonical address — takes its place. Anything else stands beside its like. An
266
+ element whose value is not answered yet (no `content`, no `href`, no text) is
267
+ left out.
268
+
269
+ **What a head does not hold is what runs or styles**: a script a browser would
270
+ execute (`nova:script` is a data block — a JSON `type`, never a `src`), a
271
+ stylesheet, `http-equiv`, a handler attribute. A layout is data, and data that
272
+ reaches every page must not be able to run. Such an element is left out and
273
+ named in `refused`. Those belong in the app's own `index.html`, which holds
274
+ anything, or in the kit component that needs them.
275
+
276
+ `@niscorp/nova/document` is the surface that has a `<head>`. `placeHead`
277
+ writes the elements into an HTML document being drawn to a string (what
278
+ `@niscorp/cli` and moss's `renderDocument` call): an element takes the place
279
+ of the tag that said the same thing, and anything else is added. In the page,
280
+ the DOM, React and Vue adapters keep `document.head` on the screen
281
+ (`createHeadKeeper`): its elements go in, the document's own tags give way to
282
+ them and come back when the screen stops saying them. To offer the names to a
283
+ layout agent, register them with `HEAD_META` so the palette lists them.
259
284
 
260
285
  ---
261
286
 
@@ -1,9 +1,9 @@
1
- import { C as ComponentRegistry } from '../../../types-BLVRduoz.cjs';
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-PDXOkvtK.cjs';
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-DE77Jl2W.js';
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-BB9RXel5.js';
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 said = (value) => typeof value === "string" && value.trim() !== "" ? value : void 0;
24
- var isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
25
- var structuredOf = (value) => {
26
- if (isObject(value)) return value;
27
- if (Array.isArray(value) && value.length > 0 && value.every(isObject)) return value;
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 headFrom = (props) => {
31
- const [title, description, image] = [said(props["title"]), said(props["description"]), said(props["image"])];
32
- const kind = props["kind"] === "website" || props["kind"] === "article" ? props["kind"] : void 0;
33
- const structured = structuredOf(props["structured"]);
34
- return {
35
- ...title !== void 0 ? { title } : {},
36
- ...description !== void 0 ? { description } : {},
37
- ...image !== void 0 ? { image } : {},
38
- ...kind !== void 0 ? { kind } : {},
39
- ...structured !== void 0 ? { structured } : {}
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
- const found = [];
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
- found.push({ props: node.props, action });
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
- const last = found[found.length - 1];
71
- if (last === void 0) return void 0;
72
- return { head: headFrom(last.props), ...last.action !== void 0 ? { action: last.action } : {} };
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/title.ts
123
- var createTitleKeeper = (doc) => {
124
- const own = doc.querySelector("title")?.getAttribute("data-own") ?? doc.title;
125
- let said2;
126
- return (head) => {
127
- const title = head?.title;
128
- if (title === said2) return;
129
- said2 = title;
130
- const next = title ?? own;
131
- if (doc.title !== next) doc.title = next;
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 keepTitle = createTitleKeeper(root.ownerDocument);
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) keepTitle(headOf(api)?.head);
677
+ if (root.isConnected) keepHead(headOf(api)?.elements);
549
678
  };
550
679
  render();
551
680
  const stop = view.subscribe(render);