@niscorp/cli 0.2.3 → 0.3.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/CHANGELOG.md +47 -0
- package/README.md +39 -26
- package/dist/adopt.js +1 -1
- package/dist/{chunk-DFB5BOHX.js → chunk-DTDMQJAO.js} +2 -2
- package/dist/{chunk-DFB5BOHX.js.map → chunk-DTDMQJAO.js.map} +1 -1
- package/dist/cli.js +9 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +6 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/project-O5OEDRXN.js +3 -0
- package/dist/{project-RTSKTGE3.js.map → project-O5OEDRXN.js.map} +1 -1
- package/package.json +7 -6
- package/dist/project-RTSKTGE3.js +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
# @niscorp/cli
|
|
2
2
|
|
|
3
|
+
## 0.3.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
|
+
## 0.3.0
|
|
19
|
+
|
|
20
|
+
### Minor Changes
|
|
21
|
+
|
|
22
|
+
- 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").
|
|
23
|
+
|
|
24
|
+
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.
|
|
25
|
+
- **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.
|
|
26
|
+
- **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.
|
|
27
|
+
- **create-nisc** — the templates' sources are recorded at `nisc.prism` 2.
|
|
28
|
+
|
|
29
|
+
**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.
|
|
30
|
+
|
|
31
|
+
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).
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- 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.
|
|
36
|
+
|
|
37
|
+
**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.
|
|
38
|
+
- **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`.
|
|
39
|
+
- **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.
|
|
40
|
+
- **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.
|
|
41
|
+
- **create-nisc** — the two own-shell templates write their welcome screen's head this way.
|
|
42
|
+
|
|
43
|
+
**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.
|
|
44
|
+
|
|
45
|
+
- Updated dependencies [de6d980]
|
|
46
|
+
- Updated dependencies [f1cec45]
|
|
47
|
+
- @niscorp/nova@0.2.0
|
|
48
|
+
- @niscorp/moss@0.3.0
|
|
49
|
+
|
|
3
50
|
## 0.2.3
|
|
4
51
|
|
|
5
52
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -125,36 +125,49 @@ the app.
|
|
|
125
125
|
|
|
126
126
|
### The head of each page
|
|
127
127
|
|
|
128
|
-
Either kind. A page's
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
screen. Nova's `nova:head` draws nothing:
|
|
128
|
+
Either kind. A page's `<head>` is a node in a layout — nova's `nova:head` —
|
|
129
|
+
and its children are the elements a head holds, bound to the action's data
|
|
130
|
+
like everything else on the screen:
|
|
132
131
|
|
|
133
132
|
```typescript
|
|
134
|
-
{ component: 'nova:head',
|
|
133
|
+
{ component: 'nova:head', children: [
|
|
134
|
+
{ component: 'nova:title', children: '{{$.page.title}} · the site' },
|
|
135
|
+
{ component: 'nova:meta', props: { name: 'description', content: '$.page.lead' } },
|
|
136
|
+
{ component: 'nova:meta', props: { property: 'og:image', content: '$.page.card' } },
|
|
137
|
+
{ component: 'nova:link', props: { rel: 'alternate', type: 'application/rss+xml', href: '/feed.xml' } },
|
|
138
|
+
{ component: 'nova:script', props: { type: 'application/ld+json', data: '$.page.about' } },
|
|
139
|
+
]}
|
|
135
140
|
```
|
|
136
141
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
and
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
142
|
+
A child's props are that element's attributes, written as given — any `name`,
|
|
143
|
+
`property` or `rel`; nova keeps no list. Nothing in a head is drawn on the
|
|
144
|
+
screen, nothing is registered, and no code is written.
|
|
145
|
+
|
|
146
|
+
`build`, `export` and `start` read the elements off the screen they drew and
|
|
147
|
+
write them into the built `index.html`'s `<head>`. An element takes the place
|
|
148
|
+
of the tag that said the same thing — the `<title>`, a `<meta>` of that name or
|
|
149
|
+
property, the canonical address — where that tag stood; anything else is added
|
|
150
|
+
after what is there. Everything the screen does not speak of is left as
|
|
151
|
+
`index.html` has it. A path whose screen has no head goes out with
|
|
152
|
+
`index.html`'s own, and a build of an app that has one somewhere says which is
|
|
153
|
+
which.
|
|
154
|
+
|
|
155
|
+
Two things in a written file are for the page itself, which goes on living
|
|
156
|
+
after the file is read: what the screen said is marked (`data-nova-head`), and
|
|
157
|
+
a tag that gave up its place is kept, inert, in a `<template data-nova-own>`.
|
|
158
|
+
When the screen moves on to one that no longer says it, the document's own
|
|
159
|
+
comes back.
|
|
160
|
+
|
|
161
|
+
**What a head may not hold fails the build.** A layout is data: a script a
|
|
162
|
+
browser would run, a stylesheet, `http-equiv`, a handler attribute are refused,
|
|
163
|
+
and the path is not written. Those go in `index.html` — the app's own file,
|
|
164
|
+
which holds anything — or in the kit component that needs them.
|
|
165
|
+
|
|
166
|
+
**Where a page lives.** `site` in the config is the address the site is served
|
|
167
|
+
at. With it, every path's document says its own canonical address
|
|
168
|
+
(`<link rel="canonical">` and `og:url`), head or no head. Without it,
|
|
169
|
+
`index.html`'s canonical tag goes out in every file as it is — which, for every
|
|
170
|
+
path but one, names another page. A build with more than one path says so.
|
|
158
171
|
|
|
159
172
|
An app with no head node and no `site` is built exactly as it was before
|
|
160
173
|
either existed.
|
package/dist/adopt.js
CHANGED
|
@@ -30,7 +30,7 @@ var main = async () => {
|
|
|
30
30
|
const [root, asked, answered] = process.argv.slice(2);
|
|
31
31
|
if (root === void 0 || asked === void 0 || answered === void 0) throw new Error("usage: adopt <root> <pages.json> <answer.json>");
|
|
32
32
|
standDom(root);
|
|
33
|
-
const { isShellProject, loadProject } = await import('./project-
|
|
33
|
+
const { isShellProject, loadProject } = await import('./project-O5OEDRXN.js');
|
|
34
34
|
const project = await loadProject(root);
|
|
35
35
|
if (!isShellProject(project)) throw new Error("nisc: this app has no shell of its own to adopt with.");
|
|
36
36
|
const pages = JSON.parse(readFileSync(asked, "utf8"));
|
|
@@ -42,5 +42,5 @@ var loadProject = async (root) => {
|
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
export { configFileOf, isProject, isShellProject, loadProject };
|
|
45
|
-
//# sourceMappingURL=chunk-
|
|
46
|
-
//# sourceMappingURL=chunk-
|
|
45
|
+
//# sourceMappingURL=chunk-DTDMQJAO.js.map
|
|
46
|
+
//# sourceMappingURL=chunk-DTDMQJAO.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/project.ts"],"names":[],"mappings":";;;;;AA6GA,IAAM,YAAA,GAAe,CAAC,gBAAA,EAAkB,iBAAA,EAAmB,kBAAkB,iBAAiB,CAAA;AAE9F,IAAM,GAAA,GAAM,CAAC,KAAA,EAAe,GAAA,KAAyB,OAAO,OAAA,CAAQ,GAAA,CAAI,KAAA,EAAO,GAAG,CAAA,KAAM,UAAA;AAEjF,IAAM,cAAA,GAAiB,CAAC,OAAA,KAAsD,OAAA,IAAW;AAEzF,IAAM,SAAA,GAAY,CAAC,KAAA,KAAyC;AACjE,EAAA,IAAI,KAAA,KAAU,IAAA,IAAQ,OAAO,KAAA,KA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AAM,MAAA,GAAkB,MAAM,QAAA,CAAS,aAAA,CAAc,IAAI,CAAA,CAAE,IAAA,EAAM,EAAE,SAAA,EAAW,MAAA,CAAA,IAAA,CAAY,KAAK,GAAI,UAAA,CAAW,QAAQ,CAAA,GAAI,EAAE,UAAS,GAAI,IAAK,CAAA;AAC9I,EAAA,MAAM,OAAA,GAAmB,MAAA,KAAW,IAAA,IAAQ,OAAO,MAAA,KAAW,WAAW,OAAA,CAAQ,GAAA,CAAI,MAAA,EAAQ,SAAS,CAAA,GAAI,MAAA;AAC1G,EAAA,IAAI,CAAC,SAAA,CAAU,OAAO,CAAA,EAAG;AACvB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,SAAS,IAAI,CAAA,kLAAA;AAAA,KACf;AAAA,EACF;AACA,EAAA,IAAI,QAAQ,IAAA,KAAS,MAAA,IAAa,CAAC,MAAA,CAAO,OAAA,CAAQ,IAAI,CAAA,EAAG;AACvD,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,MAAA,EAAS,IAAI,CAAA,mBAAA,EAAsB,KAAK,SAAA,CAAU,OAAA,CAAQ,IAAI,CAAC,CAAA,8EAAA,CAA2E,CAAA;AAAA,EAC5J;AACA,EAAA,OAAO,OAAA;AACT","file":"chunk-DFB5BOHX.js","sourcesContent":["import { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { DocumentConfig, MossServer } from '@niscorp/moss';\nimport type { Shell } from '@niscorp/nova';\n\n// ═══════════════════════════════════════════════════════════════\n// WHAT AN APP SAYS ABOUT ITSELF — `nisc.config.ts`, at the app's root, exporting\n// `project`. What only the app knows: how it stands up, and how one of its\n// screens is drawn. Everything the command does is derived from those.\n//\n// An app is one of two things, and its config says which by what it hands over.\n//\n// BEHIND MOSS — the shell lives on the server. The config hands over the\n// server; which paths exist and what each needs is read off its manifest.\n//\n// export const project: NiscProject = {\n// boot: async () => ({ server: (await boot()).server }),\n// draw: (snapshot) => renderSnapshot({ snapshot, registry, slotWrapper }),\n// };\n//\n// ITS OWN SHELL — the shell lives in the page (AGENTS.md, \"the client-degrade\n// path\"). The config hands over the app's own boot, the SAME one its browser\n// entry runs. A build runs it where there is no browser, draws the screen to\n// markup, and the page's boot picks that markup up.\n//\n// export const project: NiscShellProject = {\n// shell: async () => ({ shell: (await boot()).shell }),\n// draw: (shell) => renderToString(createElement(Screen, { shell })),\n// adopt: (root, shell) => { hydrateRoot(root, createElement(Screen, { shell })); },\n// };\n// ═══════════════════════════════════════════════════════════════\n\ntype Common = {\n // Where the bundler writes the terminal (default `dist`), relative to the root.\n dist?: string;\n // Where the built page's stylesheet goes. `page` (the default): written into\n // index.html as a <style>, so the first response paints the screen. `file`:\n // left as the bundler linked it — what a Content-Security-Policy that forbids\n // inline styles needs.\n stylesheet?: 'page' | 'file';\n // The app's check suite, for `nisc check` (default `src/dev/all-checks.ts`).\n checks?: string;\n // The address the site is served at (\"https://example.com\"). With it, every\n // path's document says its own canonical address, and a picture a screen's\n // head names is given a whole one. Without it, where a document lives is left\n // as index.html says — for every path alike.\n site?: string;\n};\n\nexport type NiscMossProject = Common & {\n // Stand the app up: the moss server, and how to let it go again. The same boot\n // the app's dev server and its checks run.\n boot: () => Promise<{ server: MossServer; close?: () => void | Promise<void> }>;\n // A terminal that draws one screen to a string — the app's kit bound to one of\n // moss's server targets (`@niscorp/moss/terminal/react/server`, …).\n draw: DocumentConfig['draw'];\n // What the kit would put on <html> from an effect (a palette, a scheme).\n htmlAttributes?: DocumentConfig['htmlAttributes'];\n // The wire's token key, when it is not `nisc.token`.\n tokenKey?: string;\n // The paths to build. Default: `/`, and every page whose path has no\n // parameter. A page with parameters (\"/docs/:slug\") has as many paths as there\n // are rows, and only the app knows them — list them here (`server.executeAs`\n // runs a seeded read as a charter role).\n paths?: (server: MossServer) => readonly string[] | Promise<readonly string[]>;\n // Routes of the app's own that a served site needs before the catch-all — a\n // sign-in handoff, a webhook. `nisc start` registers them first.\n routes?: (server: MossServer) => void | Promise<void>;\n // What only `nisc dev` uses.\n dev?: {\n // A signed-in URL in development: `/dev/as/<who>` stores the token this\n // mints and goes to `/`. `null` is nobody of that name. It exists in the\n // dev server and nowhere else.\n signIn?: (server: MossServer, who: string) => string | null | Promise<string | null>;\n };\n};\n\nexport type NiscShellProject = Common & {\n // One fresh copy of the app's shell, for one path — the boot the browser entry\n // runs. It is handed the path and NOTHING ELSE: there is no credential to pass\n // and no way to pass one, so what a build draws is the screen as nobody in\n // particular sees it. Called more than once per path (the build boots twice\n // to compare, and once more inside a DOM to adopt), so it must not memoize.\n shell: (request: { path: string }) => Promise<{ shell: Shell; close?: () => void | Promise<void> }>;\n // Draw a shell to markup where there is no browser: the app's kit through an\n // adapter's string target (`react-dom/server`, `vue/server-renderer`,\n // `@niscorp/nova/adapters/dom/server`).\n draw: (shell: Shell) => string | Promise<string>;\n // Pick the markup up: `root` already holds it, `shell` is the page's own. The\n // SAME call the browser entry makes (`hydrateRoot`, `createSSRApp().mount`,\n // nova's `mountShell`). A build runs it inside a DOM and fails on anything it\n // complains about.\n adopt: (root: HTMLElement, shell: Shell) => void | Promise<void>;\n // What the kit would put on <html> from an effect (a palette, a scheme).\n htmlAttributes?: (shell: Shell) => Record<string, string>;\n // The paths to build (default: `/`). An app that maps paths to actions lists\n // its own — only it knows them.\n paths?: () => readonly string[] | Promise<readonly string[]>;\n // How long a build waits for a screen to be whole (default 5000ms). Past it\n // the build FAILS: a file that says \"loading\" is not the page.\n waitMs?: number;\n};\n\n// What a config exports. Written against one of the two names above, a config's\n// callbacks are typed for it (`draw`'s argument is a snapshot in one and a shell\n// in the other).\nexport type NiscProject = NiscMossProject | NiscShellProject;\n\nconst CONFIG_NAMES = ['nisc.config.ts', 'nisc.config.mts', 'nisc.config.js', 'nisc.config.mjs'];\n\nconst has = (value: object, key: string): boolean => typeof Reflect.get(value, key) === 'function';\n\nexport const isShellProject = (project: NiscProject): project is NiscShellProject => 'shell' in project;\n\nexport const isProject = (value: unknown): value is NiscProject => {\n if (value === null || typeof value !== 'object' || !has(value, 'draw')) return false;\n const [moss, own] = [has(value, 'boot'), has(value, 'shell')];\n // one or the other — a config that hands over both has not said which it is\n return moss !== own && (moss || has(value, 'adopt'));\n};\n\n// An address a document can be said to live at: http or https, and whole.\nconst isSite = (value: unknown): boolean => {\n if (typeof value !== 'string') return false;\n try {\n return ['http:', 'https:'].includes(new URL(value).protocol);\n } catch {\n return false;\n }\n};\n\n// The config's file name, if the app has one.\nexport const configFileOf = (root: string): string | undefined => CONFIG_NAMES.find((name) => existsSync(join(root, name)));\n\n// Load the app's config through tsx, so it is TypeScript with the app's own\n// tsconfig (its path aliases included) — the way the app's checks already run.\nexport const loadProject = async (root: string): Promise<NiscProject> => {\n const name = configFileOf(root);\n const file = name === undefined ? undefined : join(root, name);\n if (file === undefined) {\n throw new Error(`nisc: no nisc.config.ts in ${root}. It exports \\`project\\`: how the app boots, and how one of its screens is drawn.`);\n }\n const { tsImport } = await import('tsx/esm/api');\n const tsconfig = join(root, 'tsconfig.json');\n const loaded: unknown = await tsImport(pathToFileURL(file).href, { parentURL: import.meta.url, ...(existsSync(tsconfig) ? { tsconfig } : {}) });\n const project: unknown = loaded !== null && typeof loaded === 'object' ? Reflect.get(loaded, 'project') : undefined;\n if (!isProject(project)) {\n throw new Error(\n `nisc: ${file} does not export a \\`project\\` the command can run. It hands over EITHER \\`boot\\` + \\`draw\\` (an app behind moss) OR \\`shell\\` + \\`draw\\` + \\`adopt\\` (an app with its own shell).`,\n );\n }\n if (project.site !== undefined && !isSite(project.site)) {\n throw new Error(`nisc: ${file} gives \\`site\\` as ${JSON.stringify(project.site)} — it is the address the site is served at, whole: \"https://example.com\".`);\n }\n return project;\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/project.ts"],"names":[],"mappings":";;;;;AA4GA,IAAM,YAAA,GAAe,CAAC,gBAAA,EAAkB,iBAAA,EAAmB,kBAAkB,iBAAiB,CAAA;AAE9F,IAAM,GAAA,GAAM,CAAC,KAA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;AACtB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,2BAAA,EAA8B,IAAI,CAAA,iFAAA,CAAmF,CAAA;AAAA,EACvI;AACA,EAAA,MAAM,EAAE,QAAA,EAAS,GAAI,MAAM,OAAO,aAAa,CAAA;AAC/C,EAAA,MAAM,QAAA,GAAW,IAAA,CAAK,IAAA,EAAM,eAAe,CAAA;AAC3C,EAAA,MAAM,MAAA,GAAkB,MAAM,QAAA,CAAS,aAAA,CAAc,IAAI,CAAA,CAAE,IAAA,EAAM,EAAE,SAAA,EAAW,MAAA,CAAA,IAAA,CAAY,KAAK,GAAI,UAAA,CAAW,QAAQ,CAAA,GAAI,EAAE,UAAS,GAAI,IAAK,CAAA;AAC9I,EAAA,MAAM,OAAA,GAAmB,MAAA,KAAW,IAAA,IAAQ,OAAO,MAAA,KAAW,WAAW,OAAA,CAAQ,GAAA,CAAI,MAAA,EAAQ,SAAS,CAAA,GAAI,MAAA;AAC1G,EAAA,IAAI,CAAC,SAAA,CAAU,OAAO,CAAA,EAAG;AACvB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,SAAS,IAAI,CAAA,kLAAA;AAAA,KACf;AAAA,EACF;AACA,EAAA,IAAI,QAAQ,IAAA,KAAS,MAAA,IAAa,CAAC,MAAA,CAAO,OAAA,CAAQ,IAAI,CAAA,EAAG;AACvD,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,MAAA,EAAS,IAAI,CAAA,mBAAA,EAAsB,KAAK,SAAA,CAAU,OAAA,CAAQ,IAAI,CAAC,CAAA,8EAAA,CAA2E,CAAA;AAAA,EAC5J;AACA,EAAA,OAAO,OAAA;AACT","file":"chunk-DTDMQJAO.js","sourcesContent":["import { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { DocumentConfig, MossServer } from '@niscorp/moss';\nimport type { Shell } from '@niscorp/nova';\n\n// ═══════════════════════════════════════════════════════════════\n// WHAT AN APP SAYS ABOUT ITSELF — `nisc.config.ts`, at the app's root, exporting\n// `project`. What only the app knows: how it stands up, and how one of its\n// screens is drawn. Everything the command does is derived from those.\n//\n// An app is one of two things, and its config says which by what it hands over.\n//\n// BEHIND MOSS — the shell lives on the server. The config hands over the\n// server; which paths exist and what each needs is read off its manifest.\n//\n// export const project: NiscProject = {\n// boot: async () => ({ server: (await boot()).server }),\n// draw: (snapshot) => renderSnapshot({ snapshot, registry, slotWrapper }),\n// };\n//\n// ITS OWN SHELL — the shell lives in the page (AGENTS.md, \"the client-degrade\n// path\"). The config hands over the app's own boot, the SAME one its browser\n// entry runs. A build runs it where there is no browser, draws the screen to\n// markup, and the page's boot picks that markup up.\n//\n// export const project: NiscShellProject = {\n// shell: async () => ({ shell: (await boot()).shell }),\n// draw: (shell) => renderToString(createElement(Screen, { shell })),\n// adopt: (root, shell) => { hydrateRoot(root, createElement(Screen, { shell })); },\n// };\n// ═══════════════════════════════════════════════════════════════\n\ntype Common = {\n // Where the bundler writes the terminal (default `dist`), relative to the root.\n dist?: string;\n // Where the built page's stylesheet goes. `page` (the default): written into\n // index.html as a <style>, so the first response paints the screen. `file`:\n // left as the bundler linked it — what a Content-Security-Policy that forbids\n // inline styles needs.\n stylesheet?: 'page' | 'file';\n // The app's check suite, for `nisc check` (default `src/dev/all-checks.ts`).\n checks?: string;\n // The address the site is served at (\"https://example.com\"). With it, every\n // path's document says its own canonical address. Without it, where a\n // document lives is left as index.html says — for every path alike.\n site?: string;\n};\n\nexport type NiscMossProject = Common & {\n // Stand the app up: the moss server, and how to let it go again. The same boot\n // the app's dev server and its checks run.\n boot: () => Promise<{ server: MossServer; close?: () => void | Promise<void> }>;\n // A terminal that draws one screen to a string — the app's kit bound to one of\n // moss's server targets (`@niscorp/moss/terminal/react/server`, …).\n draw: DocumentConfig['draw'];\n // What the kit would put on <html> from an effect (a palette, a scheme).\n htmlAttributes?: DocumentConfig['htmlAttributes'];\n // The wire's token key, when it is not `nisc.token`.\n tokenKey?: string;\n // The paths to build. Default: `/`, and every page whose path has no\n // parameter. A page with parameters (\"/docs/:slug\") has as many paths as there\n // are rows, and only the app knows them — list them here (`server.executeAs`\n // runs a seeded read as a charter role).\n paths?: (server: MossServer) => readonly string[] | Promise<readonly string[]>;\n // Routes of the app's own that a served site needs before the catch-all — a\n // sign-in handoff, a webhook. `nisc start` registers them first.\n routes?: (server: MossServer) => void | Promise<void>;\n // What only `nisc dev` uses.\n dev?: {\n // A signed-in URL in development: `/dev/as/<who>` stores the token this\n // mints and goes to `/`. `null` is nobody of that name. It exists in the\n // dev server and nowhere else.\n signIn?: (server: MossServer, who: string) => string | null | Promise<string | null>;\n };\n};\n\nexport type NiscShellProject = Common & {\n // One fresh copy of the app's shell, for one path — the boot the browser entry\n // runs. It is handed the path and NOTHING ELSE: there is no credential to pass\n // and no way to pass one, so what a build draws is the screen as nobody in\n // particular sees it. Called more than once per path (the build boots twice\n // to compare, and once more inside a DOM to adopt), so it must not memoize.\n shell: (request: { path: string }) => Promise<{ shell: Shell; close?: () => void | Promise<void> }>;\n // Draw a shell to markup where there is no browser: the app's kit through an\n // adapter's string target (`react-dom/server`, `vue/server-renderer`,\n // `@niscorp/nova/adapters/dom/server`).\n draw: (shell: Shell) => string | Promise<string>;\n // Pick the markup up: `root` already holds it, `shell` is the page's own. The\n // SAME call the browser entry makes (`hydrateRoot`, `createSSRApp().mount`,\n // nova's `mountShell`). A build runs it inside a DOM and fails on anything it\n // complains about.\n adopt: (root: HTMLElement, shell: Shell) => void | Promise<void>;\n // What the kit would put on <html> from an effect (a palette, a scheme).\n htmlAttributes?: (shell: Shell) => Record<string, string>;\n // The paths to build (default: `/`). An app that maps paths to actions lists\n // its own — only it knows them.\n paths?: () => readonly string[] | Promise<readonly string[]>;\n // How long a build waits for a screen to be whole (default 5000ms). Past it\n // the build FAILS: a file that says \"loading\" is not the page.\n waitMs?: number;\n};\n\n// What a config exports. Written against one of the two names above, a config's\n// callbacks are typed for it (`draw`'s argument is a snapshot in one and a shell\n// in the other).\nexport type NiscProject = NiscMossProject | NiscShellProject;\n\nconst CONFIG_NAMES = ['nisc.config.ts', 'nisc.config.mts', 'nisc.config.js', 'nisc.config.mjs'];\n\nconst has = (value: object, key: string): boolean => typeof Reflect.get(value, key) === 'function';\n\nexport const isShellProject = (project: NiscProject): project is NiscShellProject => 'shell' in project;\n\nexport const isProject = (value: unknown): value is NiscProject => {\n if (value === null || typeof value !== 'object' || !has(value, 'draw')) return false;\n const [moss, own] = [has(value, 'boot'), has(value, 'shell')];\n // one or the other — a config that hands over both has not said which it is\n return moss !== own && (moss || has(value, 'adopt'));\n};\n\n// An address a document can be said to live at: http or https, and whole.\nconst isSite = (value: unknown): boolean => {\n if (typeof value !== 'string') return false;\n try {\n return ['http:', 'https:'].includes(new URL(value).protocol);\n } catch {\n return false;\n }\n};\n\n// The config's file name, if the app has one.\nexport const configFileOf = (root: string): string | undefined => CONFIG_NAMES.find((name) => existsSync(join(root, name)));\n\n// Load the app's config through tsx, so it is TypeScript with the app's own\n// tsconfig (its path aliases included) — the way the app's checks already run.\nexport const loadProject = async (root: string): Promise<NiscProject> => {\n const name = configFileOf(root);\n const file = name === undefined ? undefined : join(root, name);\n if (file === undefined) {\n throw new Error(`nisc: no nisc.config.ts in ${root}. It exports \\`project\\`: how the app boots, and how one of its screens is drawn.`);\n }\n const { tsImport } = await import('tsx/esm/api');\n const tsconfig = join(root, 'tsconfig.json');\n const loaded: unknown = await tsImport(pathToFileURL(file).href, { parentURL: import.meta.url, ...(existsSync(tsconfig) ? { tsconfig } : {}) });\n const project: unknown = loaded !== null && typeof loaded === 'object' ? Reflect.get(loaded, 'project') : undefined;\n if (!isProject(project)) {\n throw new Error(\n `nisc: ${file} does not export a \\`project\\` the command can run. It hands over EITHER \\`boot\\` + \\`draw\\` (an app behind moss) OR \\`shell\\` + \\`draw\\` + \\`adopt\\` (an app with its own shell).`,\n );\n }\n if (project.site !== undefined && !isSite(project.site)) {\n throw new Error(`nisc: ${file} gives \\`site\\` as ${JSON.stringify(project.site)} — it is the address the site is served at, whole: \"https://example.com\".`);\n }\n return project;\n};\n"]}
|
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { loadProject, isShellProject, configFileOf, isProject } from './chunk-
|
|
1
|
+
import { loadProject, isShellProject, configFileOf, isProject } from './chunk-DTDMQJAO.js';
|
|
2
2
|
import { resolve, join, sep, extname, dirname } from 'path';
|
|
3
3
|
import { spawn, spawnSync } from 'child_process';
|
|
4
4
|
import { existsSync, statSync, readFileSync, rmSync, cpSync, mkdirSync, writeFileSync, mkdtempSync } from 'fs';
|
|
@@ -72,7 +72,8 @@ var fileOf = (path) => {
|
|
|
72
72
|
};
|
|
73
73
|
var pad = (text, width) => text + " ".repeat(Math.max(0, width - text.length));
|
|
74
74
|
var routeTable = (routes) => {
|
|
75
|
-
const
|
|
75
|
+
const says = (route) => (route.head?.elements.length ?? 0) > 0;
|
|
76
|
+
const headed = routes.some(says);
|
|
76
77
|
const rows = routes.map((route) => {
|
|
77
78
|
const mark = !route.drawn ? "\u2717" : route.live ? "\u25CF" : "\u25CB";
|
|
78
79
|
const what = route.page === void 0 ? "the app" : `page ${route.page}`;
|
|
@@ -82,7 +83,7 @@ var routeTable = (routes) => {
|
|
|
82
83
|
...route.drawn && !route.settled ? ["it was still loading when the wait ran out \u2014 drawn with what it had"] : [],
|
|
83
84
|
...route.drawnWith.length > 0 ? [`drawn with ${route.drawnWith.join(", ")} \u2014 as it answered at build`] : []
|
|
84
85
|
];
|
|
85
|
-
const head = headed && route.drawn ? [route
|
|
86
|
+
const head = headed && route.drawn ? [says(route) ? `head: its own, said by ${route.head?.actions.join(", ") || "the shell\u2019s chrome"}` : "head: the template\u2019s own"] : [];
|
|
86
87
|
return { mark, path: route.path, what, served, notes, head };
|
|
87
88
|
});
|
|
88
89
|
const widths = {
|
|
@@ -128,7 +129,7 @@ var factsOf = (shell) => {
|
|
|
128
129
|
const sorted = (set) => [...set].sort();
|
|
129
130
|
return { actions: sorted(actions), opensWith: sorted(opensWith), callsLater: sorted(callsLater), listens: sorted(listens) };
|
|
130
131
|
};
|
|
131
|
-
var documentOf = (project, template, path, drawn) => placeHead(placeScreen(template, drawn.screen, drawn.attributes), drawn.head?.
|
|
132
|
+
var documentOf = (project, template, path, drawn) => placeHead(placeScreen(template, drawn.screen, drawn.attributes), drawn.head?.elements, { ...project.site !== void 0 ? { site: project.site } : {}, path });
|
|
132
133
|
var drawOnce = async (project, path) => {
|
|
133
134
|
const booted = await project.shell({ path });
|
|
134
135
|
try {
|
|
@@ -175,6 +176,7 @@ var surveyShell = async (root, project, template) => {
|
|
|
175
176
|
drawn = await drawOnce(project, path);
|
|
176
177
|
if (drawn.screen.trim() === "") problems.push("drawn: it drew to nothing");
|
|
177
178
|
if (!drawn.whole) problems.push(`whole: it was still loading after ${project.waitMs ?? DEFAULT_BUILD_WAIT_MS}ms`);
|
|
179
|
+
for (const why of drawn.head?.refused ?? []) problems.push(`head: ${why}`);
|
|
178
180
|
const again = await drawOnce(project, path);
|
|
179
181
|
if (again.screen !== drawn.screen) problems.push(`same twice: a second boot drew different markup${differenceOf(drawn.screen, again.screen)}`);
|
|
180
182
|
const [head, headAgain] = [JSON.stringify(drawn.head ?? null), JSON.stringify(again.head ?? null)];
|
|
@@ -210,8 +212,9 @@ var shellRouteTable = (routes) => {
|
|
|
210
212
|
const width = Math.max(5, ...routes.map((route) => route.path.length)) + 2;
|
|
211
213
|
const lines = [` ${pad2("Route", width)}First screen`];
|
|
212
214
|
const indent = " ".repeat(width + 2);
|
|
213
|
-
const
|
|
214
|
-
const
|
|
215
|
+
const says = (route) => (route.head?.elements.length ?? 0) > 0;
|
|
216
|
+
const headed = routes.some(says);
|
|
217
|
+
const headNote = (route) => says(route) ? `head: its own, said by ${route.head?.actions.join(", ") || "the shell\u2019s chrome"}` : "head: the template\u2019s own";
|
|
215
218
|
for (const route of routes) {
|
|
216
219
|
const ok = route.problems.length === 0;
|
|
217
220
|
const notes = ok ? [
|