create-nisc 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.
- package/LICENSE +202 -0
- package/README.md +72 -0
- package/bin/create-nisc.js +5 -0
- package/dist/chunk-A4727PE2.js +174 -0
- package/dist/chunk-A4727PE2.js.map +1 -0
- package/dist/chunk-TEYNNEJA.js +173 -0
- package/dist/chunk-TEYNNEJA.js.map +1 -0
- package/dist/cli.js +113 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/package.json +54 -0
- package/templates/moss-dom/.turbo/turbo-build.log +32 -0
- package/templates/moss-dom/.turbo/turbo-test.log +15 -0
- package/templates/moss-dom/.turbo/turbo-typecheck.log +4 -0
- package/templates/moss-dom/README.md +15 -0
- package/templates/moss-dom/index.html +12 -0
- package/templates/moss-dom/nisc.config.ts +19 -0
- package/templates/moss-dom/package.json +39 -0
- package/templates/moss-dom/src/app/action-catalog.ts +8 -0
- package/templates/moss-dom/src/app/actions/surfaces/welcome.action.ts +13 -0
- package/templates/moss-dom/src/app/actions/surfaces/welcome.layout.ts +27 -0
- package/templates/moss-dom/src/app/app.ts +10 -0
- package/templates/moss-dom/src/app/charter/assignments.ts +3 -0
- package/templates/moss-dom/src/app/charter/charter.ts +8 -0
- package/templates/moss-dom/src/app/shell/frame.layout.ts +5 -0
- package/templates/moss-dom/src/app/shell/shell.ts +10 -0
- package/templates/moss-dom/src/dev/all-checks.ts +20 -0
- package/templates/moss-dom/src/dev/artifacts-check.ts +56 -0
- package/templates/moss-dom/src/dev/strata.ts +28 -0
- package/templates/moss-dom/src/dev/welcome-check.ts +43 -0
- package/templates/moss-dom/src/main.ts +22 -0
- package/templates/moss-dom/src/server/boot.ts +9 -0
- package/templates/moss-dom/src/server/document.ts +15 -0
- package/templates/moss-dom/src/server/runtime.ts +21 -0
- package/templates/moss-dom/src/ui/kit.css +42 -0
- package/templates/moss-dom/src/ui/kit.ts +41 -0
- package/templates/moss-dom/src/ui/registry.ts +16 -0
- package/templates/moss-dom/strata.lock.json +6 -0
- package/templates/moss-dom/tsconfig.json +27 -0
- package/templates/moss-dom/vite.config.ts +8 -0
- package/templates/moss-react/.turbo/turbo-build.log +32 -0
- package/templates/moss-react/.turbo/turbo-test.log +15 -0
- package/templates/moss-react/.turbo/turbo-typecheck.log +4 -0
- package/templates/moss-react/README.md +15 -0
- package/templates/moss-react/index.html +12 -0
- package/templates/moss-react/nisc.config.ts +19 -0
- package/templates/moss-react/package.json +42 -0
- package/templates/moss-react/src/app/action-catalog.ts +8 -0
- package/templates/moss-react/src/app/actions/surfaces/welcome.action.ts +13 -0
- package/templates/moss-react/src/app/actions/surfaces/welcome.layout.ts +27 -0
- package/templates/moss-react/src/app/app.ts +10 -0
- package/templates/moss-react/src/app/charter/assignments.ts +3 -0
- package/templates/moss-react/src/app/charter/charter.ts +8 -0
- package/templates/moss-react/src/app/shell/frame.layout.ts +5 -0
- package/templates/moss-react/src/app/shell/shell.ts +10 -0
- package/templates/moss-react/src/dev/all-checks.ts +20 -0
- package/templates/moss-react/src/dev/artifacts-check.ts +56 -0
- package/templates/moss-react/src/dev/strata.ts +28 -0
- package/templates/moss-react/src/dev/welcome-check.ts +43 -0
- package/templates/moss-react/src/main.tsx +20 -0
- package/templates/moss-react/src/server/boot.ts +9 -0
- package/templates/moss-react/src/server/document.ts +12 -0
- package/templates/moss-react/src/server/runtime.ts +21 -0
- package/templates/moss-react/src/ui/kit.css +42 -0
- package/templates/moss-react/src/ui/kit.tsx +49 -0
- package/templates/moss-react/src/ui/registry.ts +14 -0
- package/templates/moss-react/strata.lock.json +6 -0
- package/templates/moss-react/tsconfig.json +17 -0
- package/templates/moss-react/vite.config.ts +11 -0
- package/templates/shell-dom/.turbo/turbo-build.log +31 -0
- package/templates/shell-dom/.turbo/turbo-test.log +12 -0
- package/templates/shell-dom/.turbo/turbo-typecheck.log +4 -0
- package/templates/shell-dom/README.md +16 -0
- package/templates/shell-dom/index.html +12 -0
- package/templates/shell-dom/nisc.config.ts +19 -0
- package/templates/shell-dom/package.json +35 -0
- package/templates/shell-dom/src/app/action-catalog.ts +8 -0
- package/templates/shell-dom/src/app/actions/surfaces/welcome.action.ts +12 -0
- package/templates/shell-dom/src/app/actions/surfaces/welcome.layout.ts +27 -0
- package/templates/shell-dom/src/app/shell/frame.layout.ts +5 -0
- package/templates/shell-dom/src/app/shell/shell.ts +10 -0
- package/templates/shell-dom/src/boot.ts +18 -0
- package/templates/shell-dom/src/dev/all-checks.ts +20 -0
- package/templates/shell-dom/src/dev/artifacts-check.ts +52 -0
- package/templates/shell-dom/src/dev/strata.ts +28 -0
- package/templates/shell-dom/src/dev/welcome-check.ts +26 -0
- package/templates/shell-dom/src/main.ts +14 -0
- package/templates/shell-dom/src/ui/kit.css +42 -0
- package/templates/shell-dom/src/ui/kit.ts +41 -0
- package/templates/shell-dom/src/ui/registry.ts +16 -0
- package/templates/shell-dom/src/ui/screen.ts +16 -0
- package/templates/shell-dom/strata.lock.json +6 -0
- package/templates/shell-dom/tsconfig.json +27 -0
- package/templates/shell-dom/vite.config.ts +6 -0
- package/templates/shell-react/.turbo/turbo-build.log +31 -0
- package/templates/shell-react/.turbo/turbo-test.log +12 -0
- package/templates/shell-react/.turbo/turbo-typecheck.log +4 -0
- package/templates/shell-react/README.md +16 -0
- package/templates/shell-react/index.html +12 -0
- package/templates/shell-react/nisc.config.ts +19 -0
- package/templates/shell-react/package.json +40 -0
- package/templates/shell-react/src/app/action-catalog.ts +8 -0
- package/templates/shell-react/src/app/actions/surfaces/welcome.action.ts +12 -0
- package/templates/shell-react/src/app/actions/surfaces/welcome.layout.ts +27 -0
- package/templates/shell-react/src/app/shell/frame.layout.ts +5 -0
- package/templates/shell-react/src/app/shell/shell.ts +10 -0
- package/templates/shell-react/src/boot.ts +18 -0
- package/templates/shell-react/src/dev/all-checks.ts +20 -0
- package/templates/shell-react/src/dev/artifacts-check.ts +52 -0
- package/templates/shell-react/src/dev/strata.ts +28 -0
- package/templates/shell-react/src/dev/welcome-check.ts +26 -0
- package/templates/shell-react/src/main.tsx +25 -0
- package/templates/shell-react/src/ui/kit.css +42 -0
- package/templates/shell-react/src/ui/kit.tsx +49 -0
- package/templates/shell-react/src/ui/registry.ts +14 -0
- package/templates/shell-react/src/ui/screen.tsx +15 -0
- package/templates/shell-react/strata.lock.json +6 -0
- package/templates/shell-react/tsconfig.json +28 -0
- package/templates/shell-react/vite.config.ts +9 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CanvasConfig, LayoutNode } from '@niscorp/nova';
|
|
2
|
+
import { frameLayout } from './frame.layout';
|
|
3
|
+
|
|
4
|
+
// The shell, as data: one canvas, the action it opens with, and the frame
|
|
5
|
+
// around it. Shells host canvases, canvases host action instances, actions
|
|
6
|
+
// render JSON layouts. src/boot.ts builds the shell from this.
|
|
7
|
+
export const shell: { canvases: CanvasConfig[]; canvasLayout: LayoutNode } = {
|
|
8
|
+
canvases: [{ id: 'main', initial: 'welcome' }],
|
|
9
|
+
canvasLayout: frameLayout,
|
|
10
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createShell } from '@niscorp/nova';
|
|
2
|
+
import type { Shell } from '@niscorp/nova';
|
|
3
|
+
import { actions } from './app/action-catalog';
|
|
4
|
+
import { shell } from './app/shell/shell';
|
|
5
|
+
import { buildRegistry } from './ui/registry';
|
|
6
|
+
|
|
7
|
+
// The shell factory (AGENTS.md, "The client-degrade path"): the app's
|
|
8
|
+
// artifacts, plus everything environmental injected here — a fetch for
|
|
9
|
+
// endpoints, the app's "today", a Prism transform — once it has any.
|
|
10
|
+
//
|
|
11
|
+
// A FRESH shell on every call: the page boots one, and a build boots more than
|
|
12
|
+
// one (it draws the first screen from one and checks it against others), so
|
|
13
|
+
// nothing may be shared between calls. Instance ids are counted, not random, so
|
|
14
|
+
// two boots draw the same markup.
|
|
15
|
+
export const boot = (): Shell => {
|
|
16
|
+
let minted = 0;
|
|
17
|
+
return createShell({ ...shell, actions, registry: buildRegistry(), instanceIdFn: () => `i${(minted += 1)}` });
|
|
18
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
|
|
3
|
+
// Every check, each in its own process: a check ships the app a
|
|
4
|
+
// history, and a shared one would make the order of the suite part of its
|
|
5
|
+
// meaning. `nisc check` runs this. A new feature adds its check here.
|
|
6
|
+
const CHECKS: readonly (readonly [name: string, what: string, args?: readonly string[]])[] = [
|
|
7
|
+
['artifacts-check', 'src/app is data: pure JSON, and every artifact parses its schema'],
|
|
8
|
+
['strata', 'the source is written at the installed grammars (strata.lock.json)', ['status', '--check']],
|
|
9
|
+
['welcome-check', 'the welcome screen: whole, and pressed'],
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
let failed = 0;
|
|
13
|
+
for (const [name, what, args = []] of CHECKS) {
|
|
14
|
+
console.log(`\n── ${name} — ${what}`);
|
|
15
|
+
const run = spawnSync(process.execPath, ['--import', 'tsx', `src/dev/${name}.ts`, ...args], { stdio: 'inherit' });
|
|
16
|
+
if (run.status !== 0) failed += 1;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
console.log(failed === 0 ? `\nAll ${CHECKS.length} checks pass.` : `\n${failed} of ${CHECKS.length} checks failed.`);
|
|
20
|
+
process.exit(failed === 0 ? 0 : 1);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// The artifacts check — what makes `src/app/` a tree of DATA: everything in it
|
|
2
|
+
// is pure JSON (no function, no Date, no undefined, no class instance) and
|
|
3
|
+
// parses through its own schema, so a code file cannot pass for an artifact
|
|
4
|
+
// (AGENTS.md, review item 6a). It also holds rule 14: an action's `input`
|
|
5
|
+
// declares only keys its `data` has.
|
|
6
|
+
import { ActionDefinitionSchema, LayoutNodeSchema } from '@niscorp/nova';
|
|
7
|
+
import { actions } from '../app/action-catalog';
|
|
8
|
+
import { shell } from '../app/shell/shell';
|
|
9
|
+
|
|
10
|
+
let failures = 0;
|
|
11
|
+
const check = (name: string, passed: boolean, detail = ''): void => {
|
|
12
|
+
console.log(`${passed ? '[pass]' : '[fail]'} ${name}${!passed && detail !== '' ? ` — ${detail}` : ''}`);
|
|
13
|
+
if (!passed) failures += 1;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// The first thing in a value that is not JSON, as a path — or '' when all of it is.
|
|
17
|
+
const impurity = (value: unknown, path: string): string => {
|
|
18
|
+
if (value === null || typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') return '';
|
|
19
|
+
if (Array.isArray(value)) return value.map((item, at) => impurity(item, `${path}[${at}]`)).find((found) => found !== '') ?? '';
|
|
20
|
+
if (typeof value !== 'object') return `${path} is a ${typeof value}`;
|
|
21
|
+
if (Object.getPrototypeOf(value) !== Object.prototype) return `${path} is not a plain object`;
|
|
22
|
+
return Object.entries(value).map(([key, inner]) => impurity(inner, path === '' ? key : `${path}.${key}`)).find((found) => found !== '') ?? '';
|
|
23
|
+
};
|
|
24
|
+
const pure = (name: string, value: unknown): void => {
|
|
25
|
+
const found = impurity(value, '');
|
|
26
|
+
check(`${name} is pure JSON`, found === '', found);
|
|
27
|
+
};
|
|
28
|
+
const parses = (name: string, parse: () => unknown): void => {
|
|
29
|
+
try {
|
|
30
|
+
parse();
|
|
31
|
+
check(`${name} parses its schema`, true);
|
|
32
|
+
} catch (error) {
|
|
33
|
+
check(`${name} parses its schema`, false, error instanceof Error ? error.message.slice(0, 300) : String(error));
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const isRecord = (value: unknown): value is Record<string, unknown> => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
37
|
+
|
|
38
|
+
pure('the action catalog', actions);
|
|
39
|
+
pure('the shell', shell);
|
|
40
|
+
parses('the shell’s frame', () => LayoutNodeSchema.parse(shell.canvasLayout));
|
|
41
|
+
|
|
42
|
+
for (const [id, definition] of Object.entries(actions)) {
|
|
43
|
+
check(`action "${id}" is catalogued under its own id`, definition.id === id, `its id is "${definition.id}"`);
|
|
44
|
+
parses(`action "${id}"`, () => ActionDefinitionSchema.parse(definition));
|
|
45
|
+
// rule 14: what an opener may seed is a subset of the action's data
|
|
46
|
+
const properties = isRecord(definition.input) && isRecord(definition.input['properties']) ? Object.keys(definition.input['properties']) : [];
|
|
47
|
+
const unknown = properties.filter((key) => !(key in (definition.data ?? {})));
|
|
48
|
+
check(`action "${id}" declares only inputs its data has`, unknown.length === 0, unknown.join(', '));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
console.log(failures === 0 ? '[pass] artifacts: all checks passed' : `[fail] artifacts: ${failures} check(s) failed`);
|
|
52
|
+
process.exit(failures === 0 ? 0 : 1);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// strata for this app's SOURCE artifacts — which version of each grammar
|
|
2
|
+
// (nova's, Prism's) the actions in src/app are written in, recorded in
|
|
3
|
+
// strata.lock.json, and how they are brought forward when a grammar moves
|
|
4
|
+
// (AGENTS.md rule 20).
|
|
5
|
+
//
|
|
6
|
+
// npm run strata status where the source stands (`-- --check` to fail when behind)
|
|
7
|
+
// npm run strata upgrade the exact expected JSON + a report of what to edit
|
|
8
|
+
// npm run strata verify holds the edit to that JSON, then moves the lock
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
10
|
+
import { NOVA_SCHEMAS, NOVA_SEQUENCE } from '@niscorp/nova/migrations';
|
|
11
|
+
import { PRISM_SCHEMAS, PRISM_SEQUENCE, prismTransform } from '@niscorp/prism/migrations';
|
|
12
|
+
import { runSourceUpgrade } from '@niscorp/strata/node';
|
|
13
|
+
import { actions } from '../app/action-catalog';
|
|
14
|
+
|
|
15
|
+
const root = fileURLToPath(new URL('../..', import.meta.url));
|
|
16
|
+
|
|
17
|
+
process.exit(
|
|
18
|
+
await runSourceUpgrade(
|
|
19
|
+
{
|
|
20
|
+
root,
|
|
21
|
+
grammars: [NOVA_SEQUENCE, PRISM_SEQUENCE],
|
|
22
|
+
transform: prismTransform,
|
|
23
|
+
schemas: { ...NOVA_SCHEMAS, ...PRISM_SCHEMAS },
|
|
24
|
+
documents: async () => Object.values(actions).map((document) => ({ kind: 'nisc.nova/action', id: document.id, document })),
|
|
25
|
+
},
|
|
26
|
+
process.argv.slice(2),
|
|
27
|
+
),
|
|
28
|
+
);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { shellSettled } from '@niscorp/nova';
|
|
2
|
+
import { boot } from '../boot';
|
|
3
|
+
|
|
4
|
+
// The welcome screen, with no browser: the app's own boot, its first screen
|
|
5
|
+
// whole, and a press reaching the shell. One `[pass]`/`[fail]` line per
|
|
6
|
+
// assertion; any failure exits non-zero (AGENTS.md, "Verification"). Whether
|
|
7
|
+
// the screen draws and is picked up in a page is `nisc build`'s to check.
|
|
8
|
+
|
|
9
|
+
let failures = 0;
|
|
10
|
+
const check = (name: string, passed: boolean, detail = ''): void => {
|
|
11
|
+
console.log(`${passed ? '[pass]' : '[fail]'} ${name}${!passed && detail !== '' ? ` — ${detail}` : ''}`);
|
|
12
|
+
if (!passed) failures += 1;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const shell = boot();
|
|
16
|
+
check('the first screen is whole', await shellSettled(shell));
|
|
17
|
+
const active = shell.getState().canvases['main']?.active;
|
|
18
|
+
check('the welcome action opens on the main canvas', active?.definitionId === 'welcome', String(active?.definitionId));
|
|
19
|
+
|
|
20
|
+
shell.dispatch({ type: 'ui:click', ref: 'press', ...(active !== undefined ? { origin: active.id } : {}) });
|
|
21
|
+
await new Promise((done) => setTimeout(done, 20));
|
|
22
|
+
const presses = shell.getRuntime(active?.id ?? '')?.getData()['presses'];
|
|
23
|
+
check('a press reaches the shell', presses === 1, `presses is ${String(presses)}`);
|
|
24
|
+
|
|
25
|
+
console.log(failures === 0 ? '[pass] welcome: all checks passed' : `[fail] welcome: ${failures} check(s) failed`);
|
|
26
|
+
process.exit(failures === 0 ? 0 : 1);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { shellSettled } from '@niscorp/nova';
|
|
2
|
+
import { boot } from './boot';
|
|
3
|
+
import { adopt } from './ui/screen';
|
|
4
|
+
import './ui/kit.css';
|
|
5
|
+
|
|
6
|
+
// The entry: boot the shell, let it reach its first screen, and mount it — over
|
|
7
|
+
// the screen that arrived drawn (`nisc export` or `nisc start` wrote it), or
|
|
8
|
+
// into an empty root (dev). The shell is this page's own from here on.
|
|
9
|
+
const root = document.getElementById('root');
|
|
10
|
+
if (root === null) throw new Error('index.html has no #root');
|
|
11
|
+
|
|
12
|
+
const shell = boot();
|
|
13
|
+
await shellSettled(shell, { waitMs: 10_000 });
|
|
14
|
+
adopt(root, shell);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* The look — the only place it lives. A different look is a different
|
|
2
|
+
stylesheet over the same layouts. */
|
|
3
|
+
|
|
4
|
+
:root {
|
|
5
|
+
--k-bg: #f6f4ef;
|
|
6
|
+
--k-ink: #1d1d1f;
|
|
7
|
+
--k-muted: #6b6a66;
|
|
8
|
+
--k-accent: #2f5bea;
|
|
9
|
+
--k-accent-ink: #ffffff;
|
|
10
|
+
--k-radius: 10px;
|
|
11
|
+
font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
|
|
12
|
+
color: var(--k-ink);
|
|
13
|
+
background: var(--k-bg);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
html, body, #root { margin: 0; min-height: 100%; }
|
|
17
|
+
|
|
18
|
+
.k-page {
|
|
19
|
+
max-width: 640px;
|
|
20
|
+
margin: 0 auto;
|
|
21
|
+
padding: 64px 24px;
|
|
22
|
+
display: flex;
|
|
23
|
+
flex-direction: column;
|
|
24
|
+
gap: 16px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.k-row { display: flex; align-items: center; gap: 16px; }
|
|
28
|
+
.k-heading { margin: 0; font-size: 32px; letter-spacing: -0.01em; }
|
|
29
|
+
.k-text { margin: 0; line-height: 1.55; }
|
|
30
|
+
.k-muted { color: var(--k-muted); }
|
|
31
|
+
|
|
32
|
+
.k-button {
|
|
33
|
+
border: 0;
|
|
34
|
+
border-radius: var(--k-radius);
|
|
35
|
+
padding: 10px 18px;
|
|
36
|
+
font: inherit;
|
|
37
|
+
font-weight: 600;
|
|
38
|
+
background: var(--k-accent);
|
|
39
|
+
color: var(--k-accent-ink);
|
|
40
|
+
cursor: pointer;
|
|
41
|
+
}
|
|
42
|
+
.k-button:active { transform: translateY(1px); }
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { DomComponent } from '@niscorp/nova/adapters/dom';
|
|
3
|
+
|
|
4
|
+
// ═══════════════════════════════════════════════════════════
|
|
5
|
+
// The kit: domain-blind primitives, as plain DOM — no framework in the page.
|
|
6
|
+
// Props in, an element out; nova's DOM adapter wires a `ref`'d element's clicks
|
|
7
|
+
// by convention, so a button is just a button. Each one is CONFIGURED, never
|
|
8
|
+
// styled: it reads what a thing is (a tone) from a closed set of names, and
|
|
9
|
+
// anything it does not know falls back to the default. The look lives in
|
|
10
|
+
// kit.css alone.
|
|
11
|
+
// ═══════════════════════════════════════════════════════════
|
|
12
|
+
|
|
13
|
+
const parsed = <T>(schema: z.ZodType<T>, props: unknown, fallback: T): T => {
|
|
14
|
+
const result = schema.safeParse(props);
|
|
15
|
+
return result.success ? result.data : fallback;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const element = (tag: string, className: string, children: Node[]): HTMLElement => {
|
|
19
|
+
const el = document.createElement(tag);
|
|
20
|
+
el.className = className;
|
|
21
|
+
el.append(...children);
|
|
22
|
+
return el;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const Page: DomComponent = ({ children }) => element('main', 'k-page', children);
|
|
26
|
+
export const Row: DomComponent = ({ children }) => element('div', 'k-row', children);
|
|
27
|
+
export const Heading: DomComponent = ({ children }) => element('h1', 'k-heading', children);
|
|
28
|
+
|
|
29
|
+
const TextProps = z.object({ tone: z.enum(['default', 'muted']).optional() });
|
|
30
|
+
export const Text: DomComponent = ({ props, children }) => {
|
|
31
|
+
const { tone } = parsed(TextProps, props, {});
|
|
32
|
+
return element('p', tone === 'muted' ? 'k-text k-muted' : 'k-text', children);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const ButtonProps = z.object({ label: z.string().optional() });
|
|
36
|
+
export const Button: DomComponent = ({ props, children }) => {
|
|
37
|
+
const { label } = parsed(ButtonProps, props, {});
|
|
38
|
+
const button = element('button', 'k-button', label !== undefined ? [document.createTextNode(label)] : children);
|
|
39
|
+
button.setAttribute('type', 'button');
|
|
40
|
+
return button;
|
|
41
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createComponentRegistry, ACTION_SLOT_NAME, CANVAS_SLOT_NAME } from '@niscorp/nova';
|
|
2
|
+
import type { ComponentRegistry } from '@niscorp/nova';
|
|
3
|
+
import type { DomComponent } from '@niscorp/nova/adapters/dom';
|
|
4
|
+
import { fallback } from '@niscorp/nova/adapters/dom/components';
|
|
5
|
+
import { Button, Heading, Page, Row, Text } from './kit';
|
|
6
|
+
|
|
7
|
+
// The one registry, assembled once (rule 2): the kit, and nova's two slot
|
|
8
|
+
// markers (the adapter resolves a canvas slot itself; an action slot is a plain
|
|
9
|
+
// wrapper). Every component a layout may name is here, and nothing else is.
|
|
10
|
+
export const buildRegistry = (): ComponentRegistry<DomComponent> => {
|
|
11
|
+
const registry = createComponentRegistry<DomComponent>();
|
|
12
|
+
registry.register(CANVAS_SLOT_NAME, fallback);
|
|
13
|
+
registry.register(ACTION_SLOT_NAME, fallback);
|
|
14
|
+
registry.registerAll({ Page, Row, Heading, Text, Button });
|
|
15
|
+
return registry;
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { renderToString } from '@niscorp/nova/adapters/dom/server';
|
|
2
|
+
import { shellView } from '@niscorp/nova';
|
|
3
|
+
import { mountShell } from '@niscorp/nova/adapters/dom';
|
|
4
|
+
import type { Shell } from '@niscorp/nova';
|
|
5
|
+
import { fallback } from '@niscorp/nova/adapters/dom/components';
|
|
6
|
+
import { buildRegistry } from './registry';
|
|
7
|
+
|
|
8
|
+
// The screen, with nova's DOM adapter — no framework in the page. Drawn to
|
|
9
|
+
// markup at build (`draw`, handed a DOM to build in), and mounted in the page
|
|
10
|
+
// over what was drawn (`adopt`): the adapter rebuilds its root with the same
|
|
11
|
+
// elements, and from then on it is the shell's.
|
|
12
|
+
export const draw = (shell: Shell, window: object): string => renderToString(buildRegistry(), shellView(shell).api, { window, fallback });
|
|
13
|
+
|
|
14
|
+
export const adopt = (root: HTMLElement, shell: Shell): void => {
|
|
15
|
+
mountShell(root, buildRegistry(), shell, { fallback });
|
|
16
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "Bundler",
|
|
6
|
+
"lib": [
|
|
7
|
+
"DOM",
|
|
8
|
+
"DOM.Iterable",
|
|
9
|
+
"ES2022"
|
|
10
|
+
],
|
|
11
|
+
"strict": true,
|
|
12
|
+
"noUncheckedIndexedAccess": true,
|
|
13
|
+
"verbatimModuleSyntax": true,
|
|
14
|
+
"isolatedModules": true,
|
|
15
|
+
"skipLibCheck": true,
|
|
16
|
+
"noEmit": true,
|
|
17
|
+
"types": [
|
|
18
|
+
"node",
|
|
19
|
+
"vite/client"
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
"include": [
|
|
23
|
+
"src",
|
|
24
|
+
"nisc.config.ts",
|
|
25
|
+
"vite.config.ts"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// A default export, which the style guide otherwise bans: vite reads its config
|
|
2
|
+
// from one, so this file has to match vite's shape (AGENTS.md rule 16, a shim).
|
|
3
|
+
import { defineConfig } from 'vite';
|
|
4
|
+
|
|
5
|
+
// The bundle IS the app: the shell, its actions and its kit all run in the page.
|
|
6
|
+
export default defineConfig({});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
> nisc-template-shell-react@0.0.0 build /Users/max/Development/niscorp/.claude/worktrees/prerender/packages/create-nisc/templates/shell-react
|
|
3
|
+
> tsc --noEmit && nisc build
|
|
4
|
+
|
|
5
|
+
vite v7.3.2 building client environment for production...
|
|
6
|
+
transforming...
|
|
7
|
+
../../../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/regexes.js (74:0): A comment
|
|
8
|
+
|
|
9
|
+
"/** Anchors a pattern source. The interpolation lives here rather than at the call site because
|
|
10
|
+
* esbuild will not drop a `@__PURE__` call whose own argument interpolates a variable, but it
|
|
11
|
+
* will drop `anchor(dateSource)`. Keeping it inline pinned `date` into every bundle. */"
|
|
12
|
+
|
|
13
|
+
in "../../../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/regexes.js" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.
|
|
14
|
+
../../../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/util.js (400:0): A comment
|
|
15
|
+
|
|
16
|
+
"// Wrapped in a `@__PURE__` IIFE: esbuild never tree-shakes a top-level initializer that contains a member access on `Number`, so the bare object literal survived into every bundle."
|
|
17
|
+
|
|
18
|
+
in "../../../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/util.js" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.
|
|
19
|
+
✓ 164 modules transformed.
|
|
20
|
+
rendering chunks...
|
|
21
|
+
computing gzip size...
|
|
22
|
+
dist/index.html 0.41 kB │ gzip: 0.28 kB
|
|
23
|
+
dist/assets/index-DALMMv7I.css 0.74 kB │ gzip: 0.43 kB
|
|
24
|
+
dist/assets/index-B7o5cB3b.js 426.35 kB │ gzip: 131.56 kB
|
|
25
|
+
✓ built in 8.56s
|
|
26
|
+
|
|
27
|
+
Route First screen
|
|
28
|
+
○ / drawn · whole · same twice · adopted (welcome)
|
|
29
|
+
|
|
30
|
+
○ a file: the first screen, drawn for nobody in particular; the page’s own shell picks it up
|
|
31
|
+
✗ not written: a check did not hold
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
> nisc-template-shell-react@0.0.0 test /Users/max/Development/niscorp/.claude/worktrees/prerender/packages/create-nisc/templates/shell-react
|
|
3
|
+
> nisc check
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
── welcome-check — the welcome screen: whole, and pressed
|
|
7
|
+
[pass] the first screen is whole
|
|
8
|
+
[pass] the welcome action opens on the main canvas
|
|
9
|
+
[pass] a press reaches the shell
|
|
10
|
+
[pass] welcome: all checks passed
|
|
11
|
+
|
|
12
|
+
All 1 checks pass.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# nisc-template-shell-react
|
|
2
|
+
|
|
3
|
+
A [nisc](https://github.com/moccadroid/niscorp) application with its own shell — it runs in the page, with no server.
|
|
4
|
+
|
|
5
|
+
| | |
|
|
6
|
+
|---|---|
|
|
7
|
+
| `npm run dev` | the app, in vite |
|
|
8
|
+
| `npm run build` | typecheck, bundle, draw every path and say how it is served |
|
|
9
|
+
| `npm run export` | write the site as a folder (`out/`) — any static host serves it |
|
|
10
|
+
| `npm start` | serve the built app, each first screen drawn per request |
|
|
11
|
+
| `npm run check` | the checks in `src/dev/` |
|
|
12
|
+
| `npm run strata status` | which grammar versions the source is written at |
|
|
13
|
+
|
|
14
|
+
**Before building anything:** [PLAN.md](PLAN.md) — what was decided when this app
|
|
15
|
+
was made and what is still open — and [AGENTS.md](AGENTS.md), which says where
|
|
16
|
+
the rules are.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>nisc-template-shell-react</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="root"></div>
|
|
10
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createElement } from 'react';
|
|
2
|
+
import { renderToString } from 'react-dom/server';
|
|
3
|
+
import type { NiscShellProject } from '@niscorp/cli';
|
|
4
|
+
import { boot } from './src/boot';
|
|
5
|
+
import { Screen, adopt } from './src/ui/screen';
|
|
6
|
+
|
|
7
|
+
// What this app tells the `nisc` command. It has no server: the shell runs in
|
|
8
|
+
// the page. So it hands over its own boot (the one src/main.tsx runs) and the
|
|
9
|
+
// two ends of a drawn screen — drawn to markup at build, picked up in the page.
|
|
10
|
+
//
|
|
11
|
+
// npm run dev the app in vite
|
|
12
|
+
// npm run build bundle, draw every path, and check what was drawn
|
|
13
|
+
// npm run export …and write each path as a file: the site as a folder
|
|
14
|
+
// npm run check the checks in src/dev
|
|
15
|
+
export const project: NiscShellProject = {
|
|
16
|
+
shell: async () => ({ shell: boot() }),
|
|
17
|
+
draw: (shell) => renderToString(createElement(Screen, { shell })),
|
|
18
|
+
adopt,
|
|
19
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nisc-template-shell-react",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=22.12"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"dev": "nisc dev",
|
|
11
|
+
"build": "tsc --noEmit && nisc build",
|
|
12
|
+
"export": "nisc export",
|
|
13
|
+
"start": "nisc start",
|
|
14
|
+
"check": "nisc check",
|
|
15
|
+
"test": "nisc check",
|
|
16
|
+
"typecheck": "tsc --noEmit",
|
|
17
|
+
"strata": "tsx src/dev/strata.ts"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@niscorp/nova": "workspace:^",
|
|
21
|
+
"@niscorp/prism": "workspace:^",
|
|
22
|
+
"@niscorp/strata": "workspace:^",
|
|
23
|
+
"react": "^19.2.4",
|
|
24
|
+
"react-dom": "^19.2.4",
|
|
25
|
+
"zod": "^4.6.5"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@niscorp/cli": "workspace:^",
|
|
29
|
+
"@niscorp/nisc": "workspace:^",
|
|
30
|
+
"@types/jsdom": "^30.0.0",
|
|
31
|
+
"@types/node": "^26.6.4",
|
|
32
|
+
"@types/react": "^19.2.14",
|
|
33
|
+
"@types/react-dom": "^19.2.3",
|
|
34
|
+
"@vitejs/plugin-react": "^5.0.4",
|
|
35
|
+
"jsdom": "^25.0.1",
|
|
36
|
+
"tsx": "^4.23.1",
|
|
37
|
+
"typescript": "^6.0.2",
|
|
38
|
+
"vite": "^7.1.12"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ActionDefinition } from '@niscorp/nova';
|
|
2
|
+
import { welcomeAction } from './actions/surfaces/welcome.action';
|
|
3
|
+
|
|
4
|
+
// Ring 1: every action the app ships, by id. Which of them exist for a given
|
|
5
|
+
// principal is the charter's answer, not this file's.
|
|
6
|
+
export const actions: Record<string, ActionDefinition> = {
|
|
7
|
+
[welcomeAction.id]: welcomeAction,
|
|
8
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ActionDefinition } from '@niscorp/nova';
|
|
2
|
+
import { welcomeLayout } from './welcome.layout';
|
|
3
|
+
|
|
4
|
+
// The first action: data with defaults, a JSON layout, and one trigger. The
|
|
5
|
+
// press is counted in the shell — which lives in this page, with no server.
|
|
6
|
+
export const welcomeAction: ActionDefinition = {
|
|
7
|
+
id: 'welcome',
|
|
8
|
+
title: 'Welcome',
|
|
9
|
+
data: { name: 'nisc-template-shell-react', presses: 0 },
|
|
10
|
+
layout: welcomeLayout,
|
|
11
|
+
triggers: [{ event: 'ui:click', ref: 'press', do: [{ increment: 'presses' }] }],
|
|
12
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { LayoutNode } from '@niscorp/nova';
|
|
2
|
+
|
|
3
|
+
// JSON, bound to the action's data. Every component name is one the kit in
|
|
4
|
+
// src/ui registers; `ref` is what the action's trigger catches.
|
|
5
|
+
export const welcomeLayout: LayoutNode = {
|
|
6
|
+
component: 'Page',
|
|
7
|
+
children: [
|
|
8
|
+
{ component: 'Heading', children: '{{$.name}}' },
|
|
9
|
+
{
|
|
10
|
+
component: 'Text',
|
|
11
|
+
props: { tone: 'muted' },
|
|
12
|
+
children: 'A nisc app with its own shell — no server. This screen is an action on a canvas; the page arrived drawn (nisc export wrote it), and the shell in this page picked it up.',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
component: 'Row',
|
|
16
|
+
children: [
|
|
17
|
+
{ component: 'Button', ref: 'press', props: { label: 'Press' } },
|
|
18
|
+
{ component: 'Text', children: 'Presses: {{$.presses}}' },
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
component: 'Text',
|
|
23
|
+
props: { tone: 'muted' },
|
|
24
|
+
children: 'Start in PLAN.md. The rules this app is built by are in AGENTS.md.',
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { LayoutNode } from '@niscorp/nova';
|
|
2
|
+
|
|
3
|
+
// The frame around the canvases — chrome lives here, as layout, never as a
|
|
4
|
+
// wrapper component. One canvas for now: `main`, drawn where its slot is.
|
|
5
|
+
export const frameLayout: LayoutNode = { component: 'CanvasSlot', props: { canvasId: 'main' } };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CanvasConfig, LayoutNode } from '@niscorp/nova';
|
|
2
|
+
import { frameLayout } from './frame.layout';
|
|
3
|
+
|
|
4
|
+
// The shell, as data: one canvas, the action it opens with, and the frame
|
|
5
|
+
// around it. Shells host canvases, canvases host action instances, actions
|
|
6
|
+
// render JSON layouts. src/boot.ts builds the shell from this.
|
|
7
|
+
export const shell: { canvases: CanvasConfig[]; canvasLayout: LayoutNode } = {
|
|
8
|
+
canvases: [{ id: 'main', initial: 'welcome' }],
|
|
9
|
+
canvasLayout: frameLayout,
|
|
10
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createShell } from '@niscorp/nova';
|
|
2
|
+
import type { Shell } from '@niscorp/nova';
|
|
3
|
+
import { actions } from './app/action-catalog';
|
|
4
|
+
import { shell } from './app/shell/shell';
|
|
5
|
+
import { buildRegistry } from './ui/registry';
|
|
6
|
+
|
|
7
|
+
// The shell factory (AGENTS.md, "The client-degrade path"): the app's
|
|
8
|
+
// artifacts, plus everything environmental injected here — a fetch for
|
|
9
|
+
// endpoints, the app's "today", a Prism transform — once it has any.
|
|
10
|
+
//
|
|
11
|
+
// A FRESH shell on every call: the page boots one, and a build boots more than
|
|
12
|
+
// one (it draws the first screen from one and checks it against others), so
|
|
13
|
+
// nothing may be shared between calls. Instance ids are counted, not random, so
|
|
14
|
+
// two boots draw the same markup.
|
|
15
|
+
export const boot = (): Shell => {
|
|
16
|
+
let minted = 0;
|
|
17
|
+
return createShell({ ...shell, actions, registry: buildRegistry(), instanceIdFn: () => `i${(minted += 1)}` });
|
|
18
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
|
|
3
|
+
// Every check, each in its own process: a check ships the app a
|
|
4
|
+
// history, and a shared one would make the order of the suite part of its
|
|
5
|
+
// meaning. `nisc check` runs this. A new feature adds its check here.
|
|
6
|
+
const CHECKS: readonly (readonly [name: string, what: string, args?: readonly string[]])[] = [
|
|
7
|
+
['artifacts-check', 'src/app is data: pure JSON, and every artifact parses its schema'],
|
|
8
|
+
['strata', 'the source is written at the installed grammars (strata.lock.json)', ['status', '--check']],
|
|
9
|
+
['welcome-check', 'the welcome screen: whole, and pressed'],
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
let failed = 0;
|
|
13
|
+
for (const [name, what, args = []] of CHECKS) {
|
|
14
|
+
console.log(`\n── ${name} — ${what}`);
|
|
15
|
+
const run = spawnSync(process.execPath, ['--import', 'tsx', `src/dev/${name}.ts`, ...args], { stdio: 'inherit' });
|
|
16
|
+
if (run.status !== 0) failed += 1;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
console.log(failed === 0 ? `\nAll ${CHECKS.length} checks pass.` : `\n${failed} of ${CHECKS.length} checks failed.`);
|
|
20
|
+
process.exit(failed === 0 ? 0 : 1);
|