@niscorp/moss 0.2.3 → 0.3.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.
- package/CHANGELOG.md +47 -0
- package/DESIGN.md +10 -0
- package/DOCS.md +19 -3
- package/README.md +6 -0
- package/dist/{chunk-2AHJ6VDR.js → chunk-3CJCJKKY.js} +9 -5
- package/dist/chunk-3CJCJKKY.js.map +1 -0
- package/dist/{chunk-JBRD2TDQ.js → chunk-DPFWL7BS.js} +3 -3
- package/dist/{chunk-JBRD2TDQ.js.map → chunk-DPFWL7BS.js.map} +1 -1
- package/dist/{document-Dg1BZxCz.d.cts → document-Jhfii6kd.d.cts} +4 -0
- package/dist/{document-Dg1BZxCz.d.ts → document-Jhfii6kd.d.ts} +4 -0
- package/dist/index.cjs +7 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/node.cjs +6 -3
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.cts +3 -2
- package/dist/node.d.ts +3 -2
- package/dist/node.js +2 -2
- package/dist/terminal/index.cjs +10 -0
- package/dist/terminal/index.cjs.map +1 -1
- package/dist/terminal/index.js +10 -0
- package/dist/terminal/index.js.map +1 -1
- package/dist/vite.cjs +7 -3
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.cts +3 -1
- package/dist/vite.d.ts +3 -1
- package/dist/vite.js +3 -2
- package/dist/vite.js.map +1 -1
- package/package.json +9 -9
- package/dist/chunk-2AHJ6VDR.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
# @niscorp/moss
|
|
2
2
|
|
|
3
|
+
## 0.3.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 [de6d980]
|
|
31
|
+
- Updated dependencies [f1cec45]
|
|
32
|
+
- @niscorp/nova@0.2.0
|
|
33
|
+
- @niscorp/prism@0.2.0
|
|
34
|
+
- @niscorp/vex@0.2.0
|
|
35
|
+
|
|
36
|
+
## 0.2.4
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- af903c6: A page's head is its screen's own. `nisc export` wrote every path with the built `index.html`'s `<head>`, so a site with more than one page shipped each of them under the front page's title, description, preview card and canonical address.
|
|
41
|
+
|
|
42
|
+
What a screen says about itself is now a node in a layout: nova's `nova:head`, with `title`, `description`, `image`, `kind` and `structured` bound to the action's data like any other node's props. It draws nothing — no adapter builds an element for it, no registry has to hold it, and a component is never handed one as a child — and it rides in the render tree, so it reaches a shell in the page, a snapshot a server drew and the trees on a wire alike. `headOf(api)` reads it off any of them; with more than one on the screen the last one speaks.
|
|
43
|
+
- **nova** — `HEAD_NAME`, `HeadPropsSchema`, `HEAD_META`, `headOf`, `isHeadNode`; and `@niscorp/nova/document`: `placeHead` writes a head into an HTML document (the tag that said the same thing is replaced, a missing one is added before `</head>`, everything else is left as it was; values are escaped) and `createTitleKeeper` keeps a tab's title on it. The DOM, React and Vue adapters keep the title on the head as the screen moves, and give the page's own back when the screen has none.
|
|
44
|
+
- **cli** — `build`, `export` and `start` write each path's document with its screen's head. "Same twice" also fails a boot that says a different head the second time, and the route table says whose head each path goes out with once an app has one. New config field `site`: the address the site is served at. With it every path says its own canonical address (`<link rel="canonical">`, `og:url`) and a head's picture gets a whole address; a build with several paths, a canonical tag in `index.html` and no `site` says so.
|
|
45
|
+
- **moss** — `renderDocument` and `exportDocuments` do the same from the snapshot (`site` on the config, `head` on the result), and the terminal keeps the tab's title off the wire for every render target.
|
|
46
|
+
- **create-nisc** — the two own-shell templates say their welcome screen's head.
|
|
47
|
+
|
|
48
|
+
**What to change:** nothing. An app with no `nova:head` node and no `site` is built, served and drawn exactly as before. An app that rewrote its exported files to give each page a head can delete that step: put the node in the layout and set `site`.
|
|
49
|
+
|
|
3
50
|
## 0.2.3
|
|
4
51
|
|
|
5
52
|
### Patch Changes
|
package/DESIGN.md
CHANGED
|
@@ -361,6 +361,16 @@ drawing a signed-in screen to a string is 0.4–0.7 ms; a whole anonymous docume
|
|
|
361
361
|
— build a shell, read it, draw it — about 0.65 ms, some 1,500 a second. The
|
|
362
362
|
page carries its screen twice (markup and snapshot), 3–5 KB compressed.
|
|
363
363
|
|
|
364
|
+
**The head of the page is part of the screen.** A title, a description and a
|
|
365
|
+
preview card are facts about what the screen shows, so the page's `<head>` is a
|
|
366
|
+
node in a layout (nova's `nova:head`, holding the elements a head holds) and
|
|
367
|
+
rides in the same trees as everything else: `renderDocument` reads the
|
|
368
|
+
elements off the snapshot and writes them into the template's `<head>`, and the
|
|
369
|
+
terminal reads them off the wire to keep the page's head. Nothing was added to
|
|
370
|
+
the snapshot, the wire or the manifest for it. Where the page lives is known to
|
|
371
|
+
the writer without being told: the `site` plus the path the document was drawn
|
|
372
|
+
at.
|
|
373
|
+
|
|
364
374
|
Six things had to be true, and each is a small, separate decision:
|
|
365
375
|
|
|
366
376
|
- **The read does not disturb anybody.** A snapshot renders, and rendering can
|
package/DOCS.md
CHANGED
|
@@ -453,8 +453,9 @@ const page = await renderDocument({
|
|
|
453
453
|
request: { path, cookie }, // what the request named and carried
|
|
454
454
|
draw: (snapshot) => renderSnapshot({ snapshot, registry, slotWrapper }),
|
|
455
455
|
htmlAttributes: (snapshot) => ({ 'data-accent': … }), // optional
|
|
456
|
+
site: 'https://example.com', // optional
|
|
456
457
|
});
|
|
457
|
-
// → { html, headers, drawn, principal, page?, live?, why?, drawnWith?, settled? }
|
|
458
|
+
// → { html, headers, drawn, principal, page?, head?, live?, why?, drawnWith?, settled? }
|
|
458
459
|
```
|
|
459
460
|
|
|
460
461
|
- **Which shell**: the page `server.page(path)` names, else the app's.
|
|
@@ -469,6 +470,21 @@ const page = await renderDocument({
|
|
|
469
470
|
- **`htmlAttributes`** is for what a kit would otherwise set on `<html>` from an
|
|
470
471
|
effect, which never runs on a server: a palette, a colour scheme. Read it off
|
|
471
472
|
the same node the effect reads it from. Values are escaped.
|
|
473
|
+
- **The page's `<head>` is its screen's own.** It is a node in a layout —
|
|
474
|
+
nova's `nova:head`, whose children (`nova:title`, `nova:meta`, `nova:link`,
|
|
475
|
+
`nova:script`) are the elements a head holds, their props the elements'
|
|
476
|
+
attributes. It is in the snapshot's trees like everything else on the screen,
|
|
477
|
+
so the elements are read off them and written into the template's `<head>`:
|
|
478
|
+
one takes the place of the tag that said the same thing, anything else is
|
|
479
|
+
added, and the rest of the head is left as the template has it. `head` in the
|
|
480
|
+
result is what was read (`{ elements, actions, refused }`); absent, the
|
|
481
|
+
screen has no head and the page went out with the template's. What a head may
|
|
482
|
+
not hold — something that runs, or styles — is left out and logged. In the
|
|
483
|
+
browser the terminal keeps the page's head on the same node as the screen
|
|
484
|
+
moves, and the template's own tags come back when it stops saying them.
|
|
485
|
+
- **`site`** is the address the site is served at. With it, every path's
|
|
486
|
+
document says its own canonical address (`<link rel="canonical">`, `og:url`).
|
|
487
|
+
Without it the template's is left as it is.
|
|
472
488
|
- **`template`** must hold the empty root (`root`, default
|
|
473
489
|
`<div id="root"></div>`). The screen goes inside it, the snapshot element
|
|
474
490
|
straight after.
|
|
@@ -880,7 +896,7 @@ Correctness, which matters more than the saving:
|
|
|
880
896
|
the runtime's through for you, so only a host running its own listener (a
|
|
881
897
|
vite plugin, a dev check) ever needs it.
|
|
882
898
|
|
|
883
|
-
- `mountSite(server, { dist, draw, htmlAttributes?, tokenKey?, waitMs?, owned? })`
|
|
899
|
+
- `mountSite(server, { dist, draw, htmlAttributes?, site?, tokenKey?, waitMs?, owned? })`
|
|
884
900
|
— the built terminal, served by the same process as the app. Every GET that
|
|
885
901
|
nothing registered earlier answers is a file from `dist`, or a page:
|
|
886
902
|
`index.html` with the caller's screen drawn into it (`renderDocument`) — the
|
|
@@ -914,7 +930,7 @@ Requires the optional `vite` peer.
|
|
|
914
930
|
keeps it.
|
|
915
931
|
- `options.app(load): Promise<DevApp>` — stand the app up. `load` is vite's
|
|
916
932
|
`ssrLoadModule`. `DevApp = { server, close?, draw?, htmlAttributes?,
|
|
917
|
-
tokenKey?, signIn? }`; absent `draw`, pages go out undrawn.
|
|
933
|
+
site?, tokenKey?, signIn? }`; absent `draw`, pages go out undrawn.
|
|
918
934
|
- `signIn(who)` enables `/dev/as/<who>`: it stores the returned token (and
|
|
919
935
|
its cookie copy) and goes to `/`. `null` is nobody of that name.
|
|
920
936
|
- `watch?: RegExp` (default: `src/app`, `src/server`, `src/db`, `src/ui` and
|
package/README.md
CHANGED
|
@@ -85,6 +85,12 @@ Who may keep the page follows from who asked: drawn for nobody it is the same
|
|
|
85
85
|
for everybody; drawn for somebody it is `private, no-store`. A page that cannot
|
|
86
86
|
be drawn goes out undrawn.
|
|
87
87
|
|
|
88
|
+
The page's `<head>` is a node in a layout too — nova's `nova:head`, holding
|
|
89
|
+
the elements a head holds, bound to the action's data. It is read off the
|
|
90
|
+
snapshot and written into the template, and the terminal keeps the page's head
|
|
91
|
+
on it as the screen moves. With `site`, every path says its own canonical
|
|
92
|
+
address.
|
|
93
|
+
|
|
88
94
|
`pages` are the other thing a path can lead to: a shell manifest drawn for
|
|
89
95
|
whoever asks and then let go — a welcome, the docs. A page with nothing left to
|
|
90
96
|
happen opens no socket, and `exportDocuments` writes pages as files. See
|
|
@@ -15,6 +15,7 @@ import { Hono } from 'hono';
|
|
|
15
15
|
import { vex, VEX_LIVE_ENV } from '@niscorp/vex/hono';
|
|
16
16
|
import { NOVA_SEQUENCE } from '@niscorp/nova/migrations';
|
|
17
17
|
import { prismTransform, PRISM_SEQUENCE } from '@niscorp/prism/migrations';
|
|
18
|
+
import { headOf, placeHead } from '@niscorp/nova/document';
|
|
18
19
|
|
|
19
20
|
// src/runtime.ts
|
|
20
21
|
var mintDevToken = (sub, claims = {}) => btoa(JSON.stringify({ sub, ...claims, iat: Date.now() })).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
@@ -3224,8 +3225,6 @@ ${nextVariantErrors.map((e) => ` ${e}`).join("\n")}`);
|
|
|
3224
3225
|
...identities !== void 0 ? { identities: { list: identities.list, meter: identities.meter } } : {}
|
|
3225
3226
|
});
|
|
3226
3227
|
};
|
|
3227
|
-
|
|
3228
|
-
// src/document.ts
|
|
3229
3228
|
var SNAPSHOT_ELEMENT_ID = "nisc-snapshot";
|
|
3230
3229
|
var DEFAULT_TOKEN_KEY = "nisc.token";
|
|
3231
3230
|
var DEFAULT_ROOT = '<div id="root"></div>';
|
|
@@ -3269,9 +3268,13 @@ var renderDocument = async (config) => {
|
|
|
3269
3268
|
});
|
|
3270
3269
|
const screen = await draw(snapshot);
|
|
3271
3270
|
const attributes = Object.entries(config.htmlAttributes?.(snapshot) ?? {}).map(([name, value]) => ` ${name}="${escapeAttribute(value)}"`).join("");
|
|
3272
|
-
const
|
|
3271
|
+
const placed = template.replace(root, () => `${root.replace("></div>", () => `>${screen}</div>`)}${embedSnapshot(snapshot, principal, request.path)}`).replace(/<html([^>]*)>/, (whole, existing) => attributes === "" ? whole : `<html${existing}${attributes}>`);
|
|
3272
|
+
const head = headOf({ frame: () => snapshot.frame, canvasTree: (id) => snapshot.trees[id] ?? [] });
|
|
3273
|
+
for (const why of head?.refused ?? []) console.error(`[moss/document] "${request.path}" \u2014 ${why}`);
|
|
3274
|
+
const html = placeHead(placed, head?.elements, { ...config.site !== void 0 ? { site: config.site } : {}, path: request.path });
|
|
3273
3275
|
return {
|
|
3274
3276
|
html,
|
|
3277
|
+
...head !== void 0 ? { head } : {},
|
|
3275
3278
|
headers: {
|
|
3276
3279
|
...documentHeaders(principal),
|
|
3277
3280
|
...token !== null && principal === null ? { "set-cookie": `${encodeURIComponent(tokenKey)}=; Path=/; Max-Age=0; SameSite=Lax` } : {}
|
|
@@ -3298,6 +3301,7 @@ var exportDocuments = async (config) => {
|
|
|
3298
3301
|
path,
|
|
3299
3302
|
html: page.html,
|
|
3300
3303
|
...page.page !== void 0 ? { page: page.page } : {},
|
|
3304
|
+
...page.head !== void 0 ? { head: page.head } : {},
|
|
3301
3305
|
drawn: page.drawn,
|
|
3302
3306
|
// undrawn is not concluded finished
|
|
3303
3307
|
live: page.live ?? true,
|
|
@@ -3310,5 +3314,5 @@ var exportDocuments = async (config) => {
|
|
|
3310
3314
|
};
|
|
3311
3315
|
|
|
3312
3316
|
export { DEFAULT_GENERATION_POLL_MS, DEFAULT_IDENTITY_IDLE_MS, DEFAULT_IDENTITY_MAX, DEFAULT_IDLE_MS, GENERATION_DDL, MOSS_SEQUENCE, SESSIONS_SEQUENCE, SNAPSHOT_ELEMENT_ID, TIDE_DDL, TIDE_SEQUENCE, TIDE_TABLES, auditClosure, buildContract, callIntegrationWith, contractAsMarkdown, copyPress, createAssertionSigner, createDataLayer, createGeneration, createIdentityCache, createPageRouter, createServer, createShellHost, createTideStore, describePlacements, devSession, documentHeaders, embedSnapshot, exportDocuments, filterInstalled, hashIntegrationKey, initIntegrations, initSessions, integrationByKey, integrationOfAction, listAttachments, listIntegrations, listPlacements, loadIntegrationActions, memoKeyOf, mintDevToken, mintIntegrationKey, mintSession, mintWrites, renderDocument, resolveCatalog, resolveCatalogForRoles, resolvePolicy, resolvePolicyAtReach, resolvePolicyForRoles, resolveRoles, resolveVariants, resolveVariantsForRoles, revokeAllFor, revokeSession, runIntake, sessionOf, sessionVerifierOf, shellNeedOf, tokenFromCookie, verifyAssertion, verifyVariants, wearableOf, wireFabric };
|
|
3313
|
-
//# sourceMappingURL=chunk-
|
|
3314
|
-
//# sourceMappingURL=chunk-
|
|
3317
|
+
//# sourceMappingURL=chunk-3CJCJKKY.js.map
|
|
3318
|
+
//# sourceMappingURL=chunk-3CJCJKKY.js.map
|