@niscorp/nova 0.1.3 → 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/ADAPTER.md +6 -0
- package/CHANGELOG.md +44 -0
- package/README.md +53 -0
- package/dist/adapters/dom/components/index.d.cts +2 -2
- package/dist/adapters/dom/components/index.d.ts +2 -2
- package/dist/adapters/dom/index.cjs +227 -4
- package/dist/adapters/dom/index.cjs.map +1 -1
- package/dist/adapters/dom/index.d.cts +2 -2
- package/dist/adapters/dom/index.d.ts +2 -2
- package/dist/adapters/dom/index.js +7 -7
- package/dist/adapters/dom/server.cjs +10 -1
- package/dist/adapters/dom/server.cjs.map +1 -1
- package/dist/adapters/dom/server.d.cts +2 -2
- package/dist/adapters/dom/server.d.ts +2 -2
- package/dist/adapters/dom/server.js +7 -7
- package/dist/adapters/react/components/index.cjs +30 -10
- package/dist/adapters/react/components/index.cjs.map +1 -1
- package/dist/adapters/react/components/index.d.cts +4 -4
- package/dist/adapters/react/components/index.d.ts +4 -4
- package/dist/adapters/react/components/index.js +9 -5
- package/dist/adapters/react/index.cjs +400 -99
- package/dist/adapters/react/index.cjs.map +1 -1
- package/dist/adapters/react/index.d.cts +4 -4
- package/dist/adapters/react/index.d.ts +4 -4
- package/dist/adapters/react/index.js +9 -5
- package/dist/adapters/tty/components/index.d.cts +2 -2
- package/dist/adapters/tty/components/index.d.ts +2 -2
- package/dist/adapters/tty/index.cjs +6 -1
- package/dist/adapters/tty/index.cjs.map +1 -1
- package/dist/adapters/tty/index.d.cts +2 -2
- package/dist/adapters/tty/index.d.ts +2 -2
- package/dist/adapters/tty/index.js +12 -1
- package/dist/adapters/tty/index.js.map +1 -1
- package/dist/adapters/vue/components/index.cjs +30 -1
- package/dist/adapters/vue/components/index.cjs.map +1 -1
- package/dist/adapters/vue/components/index.d.cts +9 -9
- package/dist/adapters/vue/components/index.d.ts +9 -9
- package/dist/adapters/vue/components/index.js +9 -5
- package/dist/adapters/vue/index.cjs +347 -23
- package/dist/adapters/vue/index.cjs.map +1 -1
- package/dist/adapters/vue/index.d.cts +4 -4
- package/dist/adapters/vue/index.d.ts +4 -4
- package/dist/adapters/vue/index.js +10 -9
- package/dist/adapters/vue/index.js.map +1 -1
- package/dist/agent/index.d.cts +2 -2
- package/dist/agent/index.d.ts +2 -2
- package/dist/{chunk-IGLCWXQ3.js → chunk-3JRTELLC.js} +3 -3
- package/dist/{chunk-IGLCWXQ3.js.map → chunk-3JRTELLC.js.map} +1 -1
- package/dist/{chunk-GVBBL36G.js → chunk-DIFE573X.js} +196 -4
- package/dist/chunk-DIFE573X.js.map +1 -0
- package/dist/{chunk-FQAJ24KA.js → chunk-MHW5VEIM.js} +33 -8
- package/dist/chunk-MHW5VEIM.js.map +1 -0
- package/dist/chunk-OE4E6IBD.js +25 -0
- package/dist/chunk-OE4E6IBD.js.map +1 -0
- package/dist/{chunk-3HGE3VWK.js → chunk-QXQCPH33.js} +33 -11
- package/dist/chunk-QXQCPH33.js.map +1 -0
- package/dist/chunk-RFBIGRCI.js +127 -0
- package/dist/chunk-RFBIGRCI.js.map +1 -0
- package/dist/{chunk-6N4WRC5V.js → chunk-RYIIIXDX.js} +85 -12
- package/dist/chunk-RYIIIXDX.js.map +1 -0
- package/dist/{chunk-7S5BNPUS.js → chunk-UDCXGDLQ.js} +36 -4
- package/dist/chunk-UDCXGDLQ.js.map +1 -0
- package/dist/chunk-V4BPFFFV.js +152 -0
- package/dist/chunk-V4BPFFFV.js.map +1 -0
- package/dist/{chunk-4ZID7UX5.js → chunk-VU6NNCEJ.js} +52 -8
- package/dist/{chunk-4ZID7UX5.js.map → chunk-VU6NNCEJ.js.map} +1 -1
- package/dist/{chunk-V32EVEVM.js → chunk-Y6XVPRYH.js} +316 -5
- package/dist/chunk-Y6XVPRYH.js.map +1 -0
- package/dist/devtools/index.d.cts +2 -2
- package/dist/devtools/index.d.ts +2 -2
- package/dist/devtools/index.js +4 -5
- package/dist/devtools/index.js.map +1 -1
- package/dist/document/index.cjs +308 -0
- package/dist/document/index.cjs.map +1 -0
- package/dist/document/index.d.cts +22 -0
- package/dist/document/index.d.ts +22 -0
- package/dist/document/index.js +6 -0
- package/dist/document/index.js.map +1 -0
- package/dist/head-CAzfTnpV.d.cts +25 -0
- package/dist/head-DRpbbj-l.d.ts +25 -0
- package/dist/i18n/index.d.cts +2 -2
- package/dist/i18n/index.d.ts +2 -2
- package/dist/index.cjs +191 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -6
- package/dist/index.d.ts +20 -6
- package/dist/index.js +5 -6
- package/dist/migrations/index.js +1 -2
- package/dist/migrations/index.js.map +1 -1
- package/dist/{palette-Mx7XHYC6.d.ts → palette-CIpPH90W.d.ts} +1 -1
- package/dist/{palette-wbJB_svk.d.cts → palette-CvwZZCkx.d.cts} +1 -1
- package/dist/reflect/index.d.cts +2 -2
- package/dist/reflect/index.d.ts +2 -2
- package/dist/reflect/index.js +4 -5
- package/dist/{types-B-rjaUX0.d.ts → types-BSKx5MXW.d.ts} +1 -1
- package/dist/{types-B_nOtkyt.d.ts → types-BWc-olbY.d.ts} +1 -1
- package/dist/{types-mRKXqZPX.d.cts → types-C9734_lJ.d.cts} +1 -1
- package/dist/{types-BB9RXel5.d.ts → types-D23TRvqe.d.ts} +1 -1
- package/dist/{types-uk19d6KC.d.cts → types-DsWNYc7R.d.cts} +1 -1
- package/dist/{types-BLVRduoz.d.cts → types-j290XhCn.d.cts} +1 -1
- package/dist/{types-PDXOkvtK.d.cts → types-qkzTfSye.d.cts} +1 -1
- package/dist/{types-DE77Jl2W.d.ts → types-qnKMx0_V.d.ts} +1 -1
- package/package.json +13 -3
- package/dist/chunk-3HGE3VWK.js.map +0 -1
- package/dist/chunk-6N4WRC5V.js.map +0 -1
- package/dist/chunk-7S5BNPUS.js.map +0 -1
- package/dist/chunk-FQAJ24KA.js.map +0 -1
- package/dist/chunk-GVBBL36G.js.map +0 -1
- package/dist/chunk-PF4OJTYU.js +0 -199
- package/dist/chunk-PF4OJTYU.js.map +0 -1
- package/dist/chunk-RQB4PRPV.js +0 -285
- package/dist/chunk-RQB4PRPV.js.map +0 -1
- package/dist/chunk-V32EVEVM.js.map +0 -1
- package/dist/chunk-ZITHBBF3.js +0 -85
- package/dist/chunk-ZITHBBF3.js.map +0 -1
- package/dist/{primitive-props-BH_EJWIe.d.ts → primitive-props-CGoJvmcH.d.cts} +4 -4
- package/dist/{primitive-props-BH_EJWIe.d.cts → primitive-props-CGoJvmcH.d.ts} +4 -4
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { f as HeadElement } from '../head-CAzfTnpV.cjs';
|
|
2
|
+
export { H as HEAD_LINK_NAME, a as HEAD_META_NAME, b as HEAD_NAME, c as HEAD_NAMES, d as HEAD_SCRIPT_NAME, e as HEAD_TITLE_NAME, S as ScreenHead, h as headKeyOf, g as headOf, i as isHeadNode } from '../head-CAzfTnpV.cjs';
|
|
3
|
+
import '../types-j290XhCn.cjs';
|
|
4
|
+
import 'zod';
|
|
5
|
+
import '../schemas-DPdeFlCT.cjs';
|
|
6
|
+
import '../types-qkzTfSye.cjs';
|
|
7
|
+
import '../index-caZoXSwr.cjs';
|
|
8
|
+
import '../effects-CndX9K7D.cjs';
|
|
9
|
+
import '../schemas-pMyyuXV7.cjs';
|
|
10
|
+
|
|
11
|
+
type HeadPlace = {
|
|
12
|
+
site?: string;
|
|
13
|
+
path?: string;
|
|
14
|
+
};
|
|
15
|
+
declare const HEAD_MARK = "data-nova-head";
|
|
16
|
+
declare const OWN_MARK = "data-nova-own";
|
|
17
|
+
declare const placeHead: (html: string, elements: readonly HeadElement[] | undefined, place?: HeadPlace) => string;
|
|
18
|
+
|
|
19
|
+
type HeadKeeper = (elements: readonly HeadElement[] | undefined) => void;
|
|
20
|
+
declare const createHeadKeeper: (doc: Document) => HeadKeeper;
|
|
21
|
+
|
|
22
|
+
export { HEAD_MARK, HeadElement, type HeadKeeper, type HeadPlace, OWN_MARK, createHeadKeeper, placeHead };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { f as HeadElement } from '../head-DRpbbj-l.js';
|
|
2
|
+
export { H as HEAD_LINK_NAME, a as HEAD_META_NAME, b as HEAD_NAME, c as HEAD_NAMES, d as HEAD_SCRIPT_NAME, e as HEAD_TITLE_NAME, S as ScreenHead, h as headKeyOf, g as headOf, i as isHeadNode } from '../head-DRpbbj-l.js';
|
|
3
|
+
import '../types-qnKMx0_V.js';
|
|
4
|
+
import 'zod';
|
|
5
|
+
import '../schemas-DPdeFlCT.js';
|
|
6
|
+
import '../types-D23TRvqe.js';
|
|
7
|
+
import '../index-CNfzSBe2.js';
|
|
8
|
+
import '../effects-CndX9K7D.js';
|
|
9
|
+
import '../schemas-pMyyuXV7.js';
|
|
10
|
+
|
|
11
|
+
type HeadPlace = {
|
|
12
|
+
site?: string;
|
|
13
|
+
path?: string;
|
|
14
|
+
};
|
|
15
|
+
declare const HEAD_MARK = "data-nova-head";
|
|
16
|
+
declare const OWN_MARK = "data-nova-own";
|
|
17
|
+
declare const placeHead: (html: string, elements: readonly HeadElement[] | undefined, place?: HeadPlace) => string;
|
|
18
|
+
|
|
19
|
+
type HeadKeeper = (elements: readonly HeadElement[] | undefined) => void;
|
|
20
|
+
declare const createHeadKeeper: (doc: Document) => HeadKeeper;
|
|
21
|
+
|
|
22
|
+
export { HEAD_MARK, HeadElement, type HeadKeeper, type HeadPlace, OWN_MARK, createHeadKeeper, placeHead };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { HEAD_MARK, OWN_MARK, createHeadKeeper, placeHead } from '../chunk-V4BPFFFV.js';
|
|
2
|
+
export { headOf, isHeadNode } from '../chunk-RFBIGRCI.js';
|
|
3
|
+
export { HEAD_LINK_NAME, HEAD_META_NAME, HEAD_NAME, HEAD_NAMES, HEAD_SCRIPT_NAME, HEAD_TITLE_NAME, headKeyOf } from '../chunk-OE4E6IBD.js';
|
|
4
|
+
import '../chunk-PZ5AY32C.js';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { b as RenderNode } from './types-j290XhCn.cjs';
|
|
2
|
+
import { R as RenderApi } from './types-qkzTfSye.cjs';
|
|
3
|
+
|
|
4
|
+
declare const HEAD_NAME = "nova:head";
|
|
5
|
+
declare const HEAD_TITLE_NAME = "nova:title";
|
|
6
|
+
declare const HEAD_META_NAME = "nova:meta";
|
|
7
|
+
declare const HEAD_LINK_NAME = "nova:link";
|
|
8
|
+
declare const HEAD_SCRIPT_NAME = "nova:script";
|
|
9
|
+
declare const HEAD_NAMES: readonly string[];
|
|
10
|
+
type HeadElement = {
|
|
11
|
+
tag: 'title' | 'meta' | 'link' | 'script';
|
|
12
|
+
attributes: Record<string, string>;
|
|
13
|
+
text?: string;
|
|
14
|
+
};
|
|
15
|
+
declare const headKeyOf: (element: Pick<HeadElement, "tag" | "attributes">) => string | undefined;
|
|
16
|
+
|
|
17
|
+
type ScreenHead = {
|
|
18
|
+
elements: HeadElement[];
|
|
19
|
+
actions: string[];
|
|
20
|
+
refused: string[];
|
|
21
|
+
};
|
|
22
|
+
declare const isHeadNode: (node: RenderNode) => boolean;
|
|
23
|
+
declare const headOf: (api: Pick<RenderApi, "frame" | "canvasTree">) => ScreenHead | undefined;
|
|
24
|
+
|
|
25
|
+
export { HEAD_LINK_NAME as H, type ScreenHead as S, HEAD_META_NAME as a, HEAD_NAME as b, HEAD_NAMES as c, HEAD_SCRIPT_NAME as d, HEAD_TITLE_NAME as e, type HeadElement as f, headOf as g, headKeyOf as h, isHeadNode as i };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { b as RenderNode } from './types-qnKMx0_V.js';
|
|
2
|
+
import { R as RenderApi } from './types-D23TRvqe.js';
|
|
3
|
+
|
|
4
|
+
declare const HEAD_NAME = "nova:head";
|
|
5
|
+
declare const HEAD_TITLE_NAME = "nova:title";
|
|
6
|
+
declare const HEAD_META_NAME = "nova:meta";
|
|
7
|
+
declare const HEAD_LINK_NAME = "nova:link";
|
|
8
|
+
declare const HEAD_SCRIPT_NAME = "nova:script";
|
|
9
|
+
declare const HEAD_NAMES: readonly string[];
|
|
10
|
+
type HeadElement = {
|
|
11
|
+
tag: 'title' | 'meta' | 'link' | 'script';
|
|
12
|
+
attributes: Record<string, string>;
|
|
13
|
+
text?: string;
|
|
14
|
+
};
|
|
15
|
+
declare const headKeyOf: (element: Pick<HeadElement, "tag" | "attributes">) => string | undefined;
|
|
16
|
+
|
|
17
|
+
type ScreenHead = {
|
|
18
|
+
elements: HeadElement[];
|
|
19
|
+
actions: string[];
|
|
20
|
+
refused: string[];
|
|
21
|
+
};
|
|
22
|
+
declare const isHeadNode: (node: RenderNode) => boolean;
|
|
23
|
+
declare const headOf: (api: Pick<RenderApi, "frame" | "canvasTree">) => ScreenHead | undefined;
|
|
24
|
+
|
|
25
|
+
export { HEAD_LINK_NAME as H, type ScreenHead as S, HEAD_META_NAME as a, HEAD_NAME as b, HEAD_NAMES as c, HEAD_SCRIPT_NAME as d, HEAD_TITLE_NAME as e, type HeadElement as f, headOf as g, headKeyOf as h, isHeadNode as i };
|
package/dist/i18n/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as Phrasebook, H as PhraseKeys, b as RenderNode } from '../types-
|
|
2
|
-
export { I as DEFAULT_PHRASE_KEYS, J as PhraseKeyMatcher, K as isBinding, O as isPhrase, Q as matcherFor } from '../types-
|
|
1
|
+
import { P as Phrasebook, H as PhraseKeys, b as RenderNode } from '../types-j290XhCn.cjs';
|
|
2
|
+
export { I as DEFAULT_PHRASE_KEYS, J as PhraseKeyMatcher, K as isBinding, O as isPhrase, Q as matcherFor } from '../types-j290XhCn.cjs';
|
|
3
3
|
import { A as ActionDefinition } from '../index-caZoXSwr.cjs';
|
|
4
4
|
import { L as LayoutNode } from '../schemas-DPdeFlCT.cjs';
|
|
5
5
|
import 'zod';
|
package/dist/i18n/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as Phrasebook, H as PhraseKeys, b as RenderNode } from '../types-
|
|
2
|
-
export { I as DEFAULT_PHRASE_KEYS, J as PhraseKeyMatcher, K as isBinding, O as isPhrase, Q as matcherFor } from '../types-
|
|
1
|
+
import { P as Phrasebook, H as PhraseKeys, b as RenderNode } from '../types-qnKMx0_V.js';
|
|
2
|
+
export { I as DEFAULT_PHRASE_KEYS, J as PhraseKeyMatcher, K as isBinding, O as isPhrase, Q as matcherFor } from '../types-qnKMx0_V.js';
|
|
3
3
|
import { A as ActionDefinition } from '../index-CNfzSBe2.js';
|
|
4
4
|
import { L as LayoutNode } from '../schemas-DPdeFlCT.js';
|
|
5
5
|
import 'zod';
|
package/dist/index.cjs
CHANGED
|
@@ -686,6 +686,28 @@ var walkValue = (value, prose, where, pass) => {
|
|
|
686
686
|
return value;
|
|
687
687
|
};
|
|
688
688
|
|
|
689
|
+
// src/layout/head.ts
|
|
690
|
+
var HEAD_NAME = "nova:head";
|
|
691
|
+
var HEAD_TITLE_NAME = "nova:title";
|
|
692
|
+
var HEAD_META_NAME = "nova:meta";
|
|
693
|
+
var HEAD_LINK_NAME = "nova:link";
|
|
694
|
+
var HEAD_SCRIPT_NAME = "nova:script";
|
|
695
|
+
var HEAD_NAMES = [HEAD_NAME, HEAD_TITLE_NAME, HEAD_META_NAME, HEAD_LINK_NAME, HEAD_SCRIPT_NAME];
|
|
696
|
+
var headKeyOf = (element) => {
|
|
697
|
+
const said = (name) => {
|
|
698
|
+
const found = Object.entries(element.attributes).find(([key]) => key.toLowerCase() === name)?.[1].trim().toLowerCase();
|
|
699
|
+
return found === void 0 || found === "" ? void 0 : found;
|
|
700
|
+
};
|
|
701
|
+
if (element.tag === "title") return "title";
|
|
702
|
+
if (element.tag === "meta") {
|
|
703
|
+
const [name, property] = [said("name"), said("property")];
|
|
704
|
+
if (name !== void 0) return `meta name ${name}`;
|
|
705
|
+
return property === void 0 ? void 0 : `meta property ${property}`;
|
|
706
|
+
}
|
|
707
|
+
if (element.tag === "link") return (said("rel") ?? "").split(/\s+/).includes("canonical") ? "link canonical" : void 0;
|
|
708
|
+
return void 0;
|
|
709
|
+
};
|
|
710
|
+
|
|
689
711
|
// src/layout/renderer.ts
|
|
690
712
|
var noopOnError = (_error) => {
|
|
691
713
|
};
|
|
@@ -781,7 +803,7 @@ var renderNode = (node, chain, ctx) => {
|
|
|
781
803
|
return [];
|
|
782
804
|
};
|
|
783
805
|
var renderComponent = (node, chain, ctx) => {
|
|
784
|
-
if (!ctx.registry.has(node.component)) {
|
|
806
|
+
if (!HEAD_NAMES.includes(node.component) && !ctx.registry.has(node.component)) {
|
|
785
807
|
throw new ComponentNotFoundError(
|
|
786
808
|
`Component not found in registry: ${node.component}`,
|
|
787
809
|
{ name: node.component }
|
|
@@ -1012,9 +1034,39 @@ var createComponentRegistry = () => {
|
|
|
1012
1034
|
}
|
|
1013
1035
|
};
|
|
1014
1036
|
const get = (name) => entries.get(name);
|
|
1015
|
-
const
|
|
1037
|
+
const has2 = (name) => entries.has(name);
|
|
1016
1038
|
const list = () => Array.from(entries.keys());
|
|
1017
|
-
return { register, registerAll, get, has, list };
|
|
1039
|
+
return { register, registerAll, get, has: has2, list };
|
|
1040
|
+
};
|
|
1041
|
+
var REFUSED_ATTRIBUTES = "an attribute whose name starts with `on`, or a prop whose name is not an attribute\u2019s name";
|
|
1042
|
+
var AttributeSchema = zod.z.union([zod.z.string(), zod.z.number(), zod.z.boolean()]).describe(
|
|
1043
|
+
"An attribute\u2019s value. Text is written as given, a number as text. `true` writes the attribute with no value. `false`, an empty or blank string, and anything that is none of these (a binding not answered yet, an object, a list) leave the attribute out."
|
|
1044
|
+
);
|
|
1045
|
+
var HeadPropsSchema = zod.z.object({}).strict().describe(
|
|
1046
|
+
"The document\u2019s <head>. Takes no props. Its children are the elements the head holds \u2014 `nova:title`, `nova:meta`, `nova:link`, `nova:script` \u2014 placed directly or through loops and conditions; any other component among them is refused and left out, and the rest stand. Draws nothing on the screen. Elements are read in the order written, and where a screen holds several heads, in the order the screen is drawn. A later element takes an earlier one\u2019s place when both are the title, both are a `nova:meta` of the same `name` or `property`, or both are a `nova:link` whose `rel` includes `canonical`. Any other two stand side by side."
|
|
1047
|
+
);
|
|
1048
|
+
var HeadTitlePropsSchema = zod.z.object({}).strict().describe(
|
|
1049
|
+
"The document\u2019s <title>, inside `nova:head`. Takes no props. Its text is given as its children: a text string, which may hold bindings \u2014 not components. A title with no text is left out."
|
|
1050
|
+
);
|
|
1051
|
+
var HeadMetaPropsSchema = zod.z.record(zod.z.string(), AttributeSchema).describe(
|
|
1052
|
+
`A <meta> element, inside \`nova:head\`. Its props are the element\u2019s attributes, written as given: \`name\` or \`property\` to say what it is, \`content\` for its value. Left out while it has no \`content\`. A later one with the same \`name\` or \`property\` takes an earlier one\u2019s place (compared without regard to case; \`name\` decides when both are set), and one with neither stands beside the rest. The whole element is refused and left out if it has \`http-equiv\`, which instructs the browser rather than describing the document, ${REFUSED_ATTRIBUTES}.`
|
|
1053
|
+
);
|
|
1054
|
+
var HeadLinkPropsSchema = zod.z.record(zod.z.string(), AttributeSchema).describe(
|
|
1055
|
+
`A <link> element, inside \`nova:head\`. Its props are the element\u2019s attributes, written as given: \`rel\` to say what the link is, \`href\` for its address, and any other the element takes (\`type\`, \`hreflang\`, \`sizes\`, \`media\`). Left out while it has no \`href\`. A later one whose \`rel\` includes \`canonical\` takes an earlier canonical\u2019s place; all other links stand side by side. The whole element is refused and left out if its \`rel\` includes \`stylesheet\`, which styles the page, or it has ${REFUSED_ATTRIBUTES}.`
|
|
1056
|
+
);
|
|
1057
|
+
var HeadScriptPropsSchema = zod.z.object({
|
|
1058
|
+
type: zod.z.string().describe("The kind of data the block holds. Only a JSON type is accepted: `application/json`, or one ending in `+json` such as `application/ld+json`. Any other type, or none, is refused."),
|
|
1059
|
+
data: zod.z.unknown().describe("What the block holds: the value itself \u2014 an object, a list, a number, text \u2014 which is serialised as JSON. Not JSON already written as text. Nothing, `null` or an empty string counts as no data.")
|
|
1060
|
+
}).catchall(AttributeSchema).describe(
|
|
1061
|
+
`A <script> element that holds data, inside \`nova:head\`: \`type\`, \`data\`, and any other attribute the element takes. Left out while it has no \`data\`. Data blocks never take one another\u2019s place. It never runs: the whole element is refused and left out unless its \`type\` is a JSON type, and if it has a \`src\` or ${REFUSED_ATTRIBUTES}.`
|
|
1062
|
+
);
|
|
1063
|
+
var described = (schema) => ({ description: schema.description ?? "", propsSchema: schema });
|
|
1064
|
+
var HEAD_META = {
|
|
1065
|
+
[HEAD_NAME]: described(HeadPropsSchema),
|
|
1066
|
+
[HEAD_TITLE_NAME]: described(HeadTitlePropsSchema),
|
|
1067
|
+
[HEAD_META_NAME]: described(HeadMetaPropsSchema),
|
|
1068
|
+
[HEAD_LINK_NAME]: described(HeadLinkPropsSchema),
|
|
1069
|
+
[HEAD_SCRIPT_NAME]: described(HeadScriptPropsSchema)
|
|
1018
1070
|
};
|
|
1019
1071
|
|
|
1020
1072
|
// src/agent/palette.ts
|
|
@@ -3519,7 +3571,7 @@ var createShell = (config) => {
|
|
|
3519
3571
|
}
|
|
3520
3572
|
return renderLayoutOrRef(canvasLayout ?? DEFAULT_SHELL_LAYOUT, { canvases: canvasList });
|
|
3521
3573
|
};
|
|
3522
|
-
const
|
|
3574
|
+
const titleOf2 = (instance) => {
|
|
3523
3575
|
const def = registry.get(instance.id)?.definition ?? actions[instance.definitionId];
|
|
3524
3576
|
if (def?.title !== void 0) {
|
|
3525
3577
|
const resolved = resolve(def.title, createScopeChain(instance.data));
|
|
@@ -3530,7 +3582,7 @@ var createShell = (config) => {
|
|
|
3530
3582
|
const getCanvasRenderTree = (canvasId) => {
|
|
3531
3583
|
const canvas = canvases.get(canvasId);
|
|
3532
3584
|
const state = canvas === void 0 ? { stack: []} : snapshotCanvas(canvas);
|
|
3533
|
-
const instances = state.stack.map((i) => ({ ...i, title:
|
|
3585
|
+
const instances = state.stack.map((i) => ({ ...i, title: titleOf2(i) }));
|
|
3534
3586
|
const scope = {
|
|
3535
3587
|
instances,
|
|
3536
3588
|
active: instances.length === 0 ? void 0 : instances[instances.length - 1],
|
|
@@ -3584,11 +3636,130 @@ var createShell = (config) => {
|
|
|
3584
3636
|
return shell;
|
|
3585
3637
|
};
|
|
3586
3638
|
|
|
3639
|
+
// src/shell/head.ts
|
|
3640
|
+
var ATTRIBUTE_NAME = /^[A-Za-z][A-Za-z0-9:._-]*$/;
|
|
3641
|
+
var DATA_TYPE = /^application\/([a-z0-9.-]+\+)?json$/i;
|
|
3642
|
+
var written = (value) => {
|
|
3643
|
+
if (typeof value === "string") return value.trim() === "" ? void 0 : value;
|
|
3644
|
+
if (typeof value === "number") return String(value);
|
|
3645
|
+
return value === true ? "" : void 0;
|
|
3646
|
+
};
|
|
3647
|
+
var attributesOf = (what, props, skip = []) => {
|
|
3648
|
+
const attributes = {};
|
|
3649
|
+
for (const [name, value] of Object.entries(props)) {
|
|
3650
|
+
if (skip.includes(name)) continue;
|
|
3651
|
+
if (!ATTRIBUTE_NAME.test(name)) return { refused: `${what}: "${name}" is not an attribute\u2019s name` };
|
|
3652
|
+
if (/^on/i.test(name)) return { refused: `${what}: \`${name}\` is a handler, and a layout does not run` };
|
|
3653
|
+
const text = written(value);
|
|
3654
|
+
if (text !== void 0) attributes[name] = text;
|
|
3655
|
+
}
|
|
3656
|
+
return { attributes };
|
|
3657
|
+
};
|
|
3658
|
+
var has = (attributes, name) => Object.keys(attributes).some((key) => key.toLowerCase() === name);
|
|
3659
|
+
var valueOf = (attributes, name) => Object.entries(attributes).find(([key]) => key.toLowerCase() === name)?.[1] ?? "";
|
|
3660
|
+
var textOf = (nodes) => nodes.map((node) => node.type === "text" ? node.value : node.type === "fragment" ? textOf(node.children) : "").join("");
|
|
3661
|
+
var titleOf = (node) => {
|
|
3662
|
+
const text = textOf(node.children).trim();
|
|
3663
|
+
return text === "" ? void 0 : { element: { tag: "title", attributes: {}, text } };
|
|
3664
|
+
};
|
|
3665
|
+
var metaOf = (node) => {
|
|
3666
|
+
const read = attributesOf(HEAD_META_NAME, node.props);
|
|
3667
|
+
if ("refused" in read) return read;
|
|
3668
|
+
if (has(read.attributes, "http-equiv")) return { refused: `${HEAD_META_NAME}: \`http-equiv\` instructs the browser, and a layout does not` };
|
|
3669
|
+
return has(read.attributes, "content") ? { element: { tag: "meta", attributes: read.attributes } } : void 0;
|
|
3670
|
+
};
|
|
3671
|
+
var linkOf = (node) => {
|
|
3672
|
+
const read = attributesOf(HEAD_LINK_NAME, node.props);
|
|
3673
|
+
if ("refused" in read) return read;
|
|
3674
|
+
if (valueOf(read.attributes, "rel").toLowerCase().split(/\s+/).includes("stylesheet")) return { refused: `${HEAD_LINK_NAME}: a stylesheet styles the page, and a layout does not` };
|
|
3675
|
+
return has(read.attributes, "href") ? { element: { tag: "link", attributes: read.attributes } } : void 0;
|
|
3676
|
+
};
|
|
3677
|
+
var scriptOf = (node) => {
|
|
3678
|
+
const read = attributesOf(HEAD_SCRIPT_NAME, node.props, ["data"]);
|
|
3679
|
+
if ("refused" in read) return read;
|
|
3680
|
+
if (has(read.attributes, "src")) return { refused: `${HEAD_SCRIPT_NAME}: a script with a \`src\` runs, and a layout does not` };
|
|
3681
|
+
const type = valueOf(read.attributes, "type");
|
|
3682
|
+
if (!DATA_TYPE.test(type)) return { refused: `${HEAD_SCRIPT_NAME}: only a data block may be written (a JSON \`type\`), and "${type}" is not one` };
|
|
3683
|
+
const data = node.props["data"];
|
|
3684
|
+
if (data === void 0 || data === null || data === "") return void 0;
|
|
3685
|
+
return { element: { tag: "script", attributes: read.attributes, text: JSON.stringify(data) } };
|
|
3686
|
+
};
|
|
3687
|
+
var READERS = {
|
|
3688
|
+
[HEAD_TITLE_NAME]: titleOf,
|
|
3689
|
+
[HEAD_META_NAME]: metaOf,
|
|
3690
|
+
[HEAD_LINK_NAME]: linkOf,
|
|
3691
|
+
[HEAD_SCRIPT_NAME]: scriptOf
|
|
3692
|
+
};
|
|
3693
|
+
var isHeadNode = (node) => node.type === "component" && node.name === HEAD_NAME;
|
|
3694
|
+
var headOf = (api) => {
|
|
3695
|
+
let heads = 0;
|
|
3696
|
+
const said = [];
|
|
3697
|
+
const refused = [];
|
|
3698
|
+
const open = /* @__PURE__ */ new Set();
|
|
3699
|
+
const hold = (nodes, action) => {
|
|
3700
|
+
for (const node of nodes) {
|
|
3701
|
+
if (node.type === "fragment") {
|
|
3702
|
+
hold(node.children, action);
|
|
3703
|
+
continue;
|
|
3704
|
+
}
|
|
3705
|
+
if (node.type === "error") {
|
|
3706
|
+
refused.push(`${HEAD_NAME}: ${node.message}`);
|
|
3707
|
+
continue;
|
|
3708
|
+
}
|
|
3709
|
+
if (node.type !== "component") continue;
|
|
3710
|
+
const read = READERS[node.name];
|
|
3711
|
+
if (read === void 0) {
|
|
3712
|
+
refused.push(`${HEAD_NAME}: "${node.name}" is not something a head holds`);
|
|
3713
|
+
continue;
|
|
3714
|
+
}
|
|
3715
|
+
const found = read(node);
|
|
3716
|
+
if (found === void 0) continue;
|
|
3717
|
+
if ("refused" in found) {
|
|
3718
|
+
refused.push(found.refused);
|
|
3719
|
+
continue;
|
|
3720
|
+
}
|
|
3721
|
+
const key = headKeyOf(found.element);
|
|
3722
|
+
const earlier = key === void 0 ? -1 : said.findIndex((other) => headKeyOf(other.element) === key);
|
|
3723
|
+
if (earlier >= 0) said.splice(earlier, 1);
|
|
3724
|
+
said.push({ element: found.element, action });
|
|
3725
|
+
}
|
|
3726
|
+
};
|
|
3727
|
+
const walk2 = (nodes, action) => {
|
|
3728
|
+
for (const node of nodes) {
|
|
3729
|
+
if (node.type === "fragment") {
|
|
3730
|
+
walk2(node.children, action);
|
|
3731
|
+
continue;
|
|
3732
|
+
}
|
|
3733
|
+
if (node.type !== "component") continue;
|
|
3734
|
+
if (node.name === HEAD_NAME) {
|
|
3735
|
+
heads += 1;
|
|
3736
|
+
hold(node.children, action);
|
|
3737
|
+
continue;
|
|
3738
|
+
}
|
|
3739
|
+
if (node.name === CANVAS_SLOT_NAME) {
|
|
3740
|
+
const canvasId = node.props["canvasId"];
|
|
3741
|
+
if (typeof canvasId !== "string" || canvasId === "" || open.has(canvasId)) continue;
|
|
3742
|
+
open.add(canvasId);
|
|
3743
|
+
walk2(api.canvasTree(canvasId), void 0);
|
|
3744
|
+
open.delete(canvasId);
|
|
3745
|
+
continue;
|
|
3746
|
+
}
|
|
3747
|
+
const definitionId = node.name === ACTION_SLOT_NAME ? node.props["definitionId"] : void 0;
|
|
3748
|
+
walk2(node.children, typeof definitionId === "string" ? definitionId : action);
|
|
3749
|
+
}
|
|
3750
|
+
};
|
|
3751
|
+
walk2(api.frame(), void 0);
|
|
3752
|
+
if (heads === 0) return void 0;
|
|
3753
|
+
const actions = [...new Set(said.flatMap((one) => one.action === void 0 ? [] : [one.action]))];
|
|
3754
|
+
return { elements: said.map((one) => one.element), actions, refused };
|
|
3755
|
+
};
|
|
3756
|
+
|
|
3587
3757
|
// src/shell/view.ts
|
|
3588
3758
|
var hasVisibleContent = (nodes) => nodes.some((node) => {
|
|
3589
3759
|
if (node.type === "text") return node.value !== "";
|
|
3590
3760
|
if (node.type === "fragment") return hasVisibleContent(node.children);
|
|
3591
3761
|
if (node.type === "component" && node.name === ACTION_SLOT_NAME) return hasVisibleContent(node.children);
|
|
3762
|
+
if (isHeadNode(node)) return false;
|
|
3592
3763
|
return true;
|
|
3593
3764
|
});
|
|
3594
3765
|
var canvasTreeOf = (shell, canvasId) => {
|
|
@@ -3674,6 +3845,18 @@ exports.DefinitionValidationError = DefinitionValidationError;
|
|
|
3674
3845
|
exports.EffectSchema = EffectSchema;
|
|
3675
3846
|
exports.EndpointConfigSchema = EndpointConfigSchema;
|
|
3676
3847
|
exports.ErrorCodes = ErrorCodes;
|
|
3848
|
+
exports.HEAD_LINK_NAME = HEAD_LINK_NAME;
|
|
3849
|
+
exports.HEAD_META = HEAD_META;
|
|
3850
|
+
exports.HEAD_META_NAME = HEAD_META_NAME;
|
|
3851
|
+
exports.HEAD_NAME = HEAD_NAME;
|
|
3852
|
+
exports.HEAD_NAMES = HEAD_NAMES;
|
|
3853
|
+
exports.HEAD_SCRIPT_NAME = HEAD_SCRIPT_NAME;
|
|
3854
|
+
exports.HEAD_TITLE_NAME = HEAD_TITLE_NAME;
|
|
3855
|
+
exports.HeadLinkPropsSchema = HeadLinkPropsSchema;
|
|
3856
|
+
exports.HeadMetaPropsSchema = HeadMetaPropsSchema;
|
|
3857
|
+
exports.HeadPropsSchema = HeadPropsSchema;
|
|
3858
|
+
exports.HeadScriptPropsSchema = HeadScriptPropsSchema;
|
|
3859
|
+
exports.HeadTitlePropsSchema = HeadTitlePropsSchema;
|
|
3677
3860
|
exports.LayoutNodeSchema = LayoutNodeSchema;
|
|
3678
3861
|
exports.LayoutPrimitiveSchema = LayoutPrimitiveSchema;
|
|
3679
3862
|
exports.LayoutRefNodeSchema = LayoutRefNodeSchema;
|
|
@@ -3707,8 +3890,11 @@ exports.createShell = createShell;
|
|
|
3707
3890
|
exports.fillSlots = fillSlots;
|
|
3708
3891
|
exports.getPath = getPath;
|
|
3709
3892
|
exports.hasVisibleContent = hasVisibleContent;
|
|
3893
|
+
exports.headKeyOf = headKeyOf;
|
|
3894
|
+
exports.headOf = headOf;
|
|
3710
3895
|
exports.isComponentNode = isComponentNode;
|
|
3711
3896
|
exports.isConditionalNode = isConditionalNode;
|
|
3897
|
+
exports.isHeadNode = isHeadNode;
|
|
3712
3898
|
exports.isLayoutNode = isLayoutNode;
|
|
3713
3899
|
exports.isLayoutPrimitive = isLayoutPrimitive;
|
|
3714
3900
|
exports.isLayoutRefNode = isLayoutRefNode;
|