@niscorp/nova 0.2.1 → 0.2.2
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 +13 -0
- package/dist/adapters/dom/components/index.cjs +4 -51
- package/dist/adapters/dom/components/index.cjs.map +1 -1
- package/dist/adapters/dom/index.cjs +22 -686
- package/dist/adapters/dom/index.cjs.map +1 -1
- package/dist/adapters/dom/server.cjs +14 -411
- package/dist/adapters/dom/server.cjs.map +1 -1
- package/dist/adapters/react/components/index.cjs +87 -562
- package/dist/adapters/react/components/index.cjs.map +1 -1
- package/dist/adapters/react/components/index.d.cts +2 -2
- package/dist/adapters/react/components/index.d.ts +2 -2
- package/dist/adapters/react/index.cjs +97 -1815
- package/dist/adapters/react/index.cjs.map +1 -1
- package/dist/adapters/tty/components/index.cjs +3 -44
- package/dist/adapters/tty/components/index.cjs.map +1 -1
- package/dist/adapters/tty/index.cjs +13 -5
- package/dist/adapters/tty/index.cjs.map +1 -1
- package/dist/adapters/vue/components/index.cjs +88 -639
- package/dist/adapters/vue/components/index.cjs.map +1 -1
- package/dist/adapters/vue/components/index.d.cts +10 -10
- package/dist/adapters/vue/components/index.d.ts +10 -10
- package/dist/adapters/vue/index.cjs +96 -962
- package/dist/adapters/vue/index.cjs.map +1 -1
- package/dist/agent/index.cjs +13 -151
- package/dist/agent/index.cjs.map +1 -1
- package/dist/chunk-3IPM5QBT.cjs +436 -0
- package/dist/chunk-3IPM5QBT.cjs.map +1 -0
- package/dist/chunk-5AF72LOE.cjs +97 -0
- package/dist/chunk-5AF72LOE.cjs.map +1 -0
- package/dist/chunk-5YQIAS4V.cjs +184 -0
- package/dist/chunk-5YQIAS4V.cjs.map +1 -0
- package/dist/chunk-D4PUWBN6.cjs +72 -0
- package/dist/chunk-D4PUWBN6.cjs.map +1 -0
- package/dist/chunk-FSUMCJAR.cjs +646 -0
- package/dist/chunk-FSUMCJAR.cjs.map +1 -0
- package/dist/chunk-GV7UC3SS.cjs +33 -0
- package/dist/chunk-GV7UC3SS.cjs.map +1 -0
- package/dist/chunk-IZ2UU5UL.cjs +808 -0
- package/dist/chunk-IZ2UU5UL.cjs.map +1 -0
- package/dist/chunk-KOYRJXTI.cjs +123 -0
- package/dist/chunk-KOYRJXTI.cjs.map +1 -0
- package/dist/chunk-KW34ZKF5.cjs +12 -0
- package/dist/chunk-KW34ZKF5.cjs.map +1 -0
- package/dist/chunk-OE527MXF.cjs +49 -0
- package/dist/chunk-OE527MXF.cjs.map +1 -0
- package/dist/chunk-OO247V4J.cjs +2117 -0
- package/dist/chunk-OO247V4J.cjs.map +1 -0
- package/dist/chunk-PMKWYOOX.cjs +64 -0
- package/dist/chunk-PMKWYOOX.cjs.map +1 -0
- package/dist/chunk-PNQY6OFB.cjs +132 -0
- package/dist/chunk-PNQY6OFB.cjs.map +1 -0
- package/dist/chunk-Q7SFCCGT.cjs +11 -0
- package/dist/chunk-Q7SFCCGT.cjs.map +1 -0
- package/dist/chunk-TMLNVU5W.cjs +318 -0
- package/dist/chunk-TMLNVU5W.cjs.map +1 -0
- package/dist/chunk-TRJYDVWK.cjs +623 -0
- package/dist/chunk-TRJYDVWK.cjs.map +1 -0
- package/dist/chunk-UGG7MCX4.cjs +34 -0
- package/dist/chunk-UGG7MCX4.cjs.map +1 -0
- package/dist/chunk-WGPFR7MN.cjs +808 -0
- package/dist/chunk-WGPFR7MN.cjs.map +1 -0
- package/dist/chunk-WGZZKCJQ.cjs +157 -0
- package/dist/chunk-WGZZKCJQ.cjs.map +1 -0
- package/dist/devtools/index.cjs +13 -697
- package/dist/devtools/index.cjs.map +1 -1
- package/dist/document/index.cjs +56 -301
- package/dist/document/index.cjs.map +1 -1
- package/dist/examples/index.cjs +6 -31
- package/dist/examples/index.cjs.map +1 -1
- package/dist/i18n/index.cjs +44 -292
- package/dist/i18n/index.cjs.map +1 -1
- package/dist/index.cjs +335 -3954
- package/dist/index.cjs.map +1 -1
- package/dist/migrations/index.cjs +7 -590
- package/dist/migrations/index.cjs.map +1 -1
- package/dist/reflect/index.cjs +85 -994
- package/dist/reflect/index.cjs.map +1 -1
- package/package.json +5 -5
- package/dist/{primitive-props-CGoJvmcH.d.cts → primitive-props-Cl5jiC8g.d.cts} +5 -5
- package/dist/{primitive-props-CGoJvmcH.d.ts → primitive-props-Cl5jiC8g.d.ts} +5 -5
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkWGZZKCJQ_cjs = require('./chunk-WGZZKCJQ.cjs');
|
|
4
|
+
var chunkOO247V4J_cjs = require('./chunk-OO247V4J.cjs');
|
|
5
|
+
var chunkPNQY6OFB_cjs = require('./chunk-PNQY6OFB.cjs');
|
|
6
|
+
var zod = require('zod');
|
|
7
|
+
|
|
8
|
+
var StackPropsSchema = zod.z.object({
|
|
9
|
+
direction: zod.z.enum(["row", "column"]).optional().describe("Flex direction. Default: column."),
|
|
10
|
+
gap: zod.z.number().int().min(0).optional().describe("Gap between children in pixels. Default: 0."),
|
|
11
|
+
align: zod.z.enum(["start", "center", "end", "stretch"]).optional().describe("Cross-axis alignment. Default: stretch."),
|
|
12
|
+
justify: zod.z.enum(["start", "center", "end", "between", "around"]).optional().describe("Main-axis justification. Default: start."),
|
|
13
|
+
padding: zod.z.number().int().min(0).optional().describe("Inner padding in pixels. Default: 0."),
|
|
14
|
+
wrap: zod.z.boolean().optional().describe("Whether children wrap to a new line. Default: false.")
|
|
15
|
+
}).strict().describe("Flex container that arranges children in a row or column.");
|
|
16
|
+
var TextPropsSchema = zod.z.object({
|
|
17
|
+
as: zod.z.enum(["span", "p", "h1", "h2", "h3", "h4"]).optional().describe("HTML element to render. Default: span."),
|
|
18
|
+
size: zod.z.enum(["sm", "md", "lg", "xl", "2xl"]).optional().describe("Font size token. Default: md."),
|
|
19
|
+
weight: zod.z.enum(["normal", "medium", "bold"]).optional().describe("Font weight token. Default: normal."),
|
|
20
|
+
color: zod.z.string().optional().describe("CSS color string (open set). Default: inherit.")
|
|
21
|
+
}).strict().describe("Text element with semantic typography props.");
|
|
22
|
+
var InputPropsSchema = zod.z.object({
|
|
23
|
+
type: zod.z.enum(["text", "number", "email", "password"]).optional().describe("Input type. Default: text."),
|
|
24
|
+
placeholder: zod.z.string().optional().describe("Placeholder text shown when empty."),
|
|
25
|
+
disabled: zod.z.boolean().optional().describe("Whether the input is disabled. Default: false."),
|
|
26
|
+
value: zod.z.string().optional().describe("Current value. Typically supplied via model binding."),
|
|
27
|
+
debounce: zod.z.number().optional().describe("Milliseconds to coalesce keystrokes before dispatching ui:model. Default: 0 (every keystroke). Set it when the shell is remote to cut round-trips.")
|
|
28
|
+
}).strict().describe("Text input bound to data via the `model` field on the layout node.");
|
|
29
|
+
var ButtonPropsSchema = zod.z.object({
|
|
30
|
+
label: zod.z.string().optional().describe("Button label. If absent, children are used."),
|
|
31
|
+
variant: zod.z.enum(["primary", "secondary", "ghost"]).optional().describe("Visual variant. Default: primary."),
|
|
32
|
+
disabled: zod.z.boolean().optional().describe("Whether the button is disabled. Default: false.")
|
|
33
|
+
}).strict().describe("Clickable button. Click events fire as `ui:click` with the layout node's ref.");
|
|
34
|
+
var BoxPropsSchema = zod.z.object({
|
|
35
|
+
padding: zod.z.number().int().min(0).optional().describe("Inner padding in pixels. Default: 0."),
|
|
36
|
+
background: zod.z.string().optional().describe("CSS background color or value."),
|
|
37
|
+
border: zod.z.boolean().optional().describe("Whether to show a 1px border. Default: false."),
|
|
38
|
+
radius: zod.z.number().int().min(0).optional().describe("Border radius in pixels. Default: 0.")
|
|
39
|
+
}).strict().describe("Generic container with basic styling props. Use Stack for layout, Box for visual wrapping.");
|
|
40
|
+
var PanelPropsSchema = zod.z.object({
|
|
41
|
+
title: zod.z.string().optional().describe("Optional header title."),
|
|
42
|
+
backRef: zod.z.string().optional().describe("When set, the header grows a \u2190 (before the title) that fires ui:click with this ref."),
|
|
43
|
+
closeRef: zod.z.string().optional().describe("When set, the header grows a \u2715 that fires ui:click with this ref.")
|
|
44
|
+
}).strict().describe("A framed, elevated surface with an optional title.");
|
|
45
|
+
var JsonTreePropsSchema = zod.z.object({
|
|
46
|
+
value: zod.z.unknown().optional().describe("The value to render."),
|
|
47
|
+
label: zod.z.string().optional().describe("A name for the root node.")
|
|
48
|
+
}).strict().describe("A collapsible view of any JSON value.");
|
|
49
|
+
var CanvasSlotPropsSchema = zod.z.object({
|
|
50
|
+
canvasId: zod.z.string().optional().describe('Id of the canvas to render. Usually bound from a loop, e.g. "$.c.id".')
|
|
51
|
+
}).strict().describe("Renders a canvas by id, recursing into its actionLayout. Resolves to nothing when canvasId is missing.");
|
|
52
|
+
var ActionSlotPropsSchema = zod.z.object({
|
|
53
|
+
instanceId: zod.z.string().optional().describe('Id of the action instance to render. Usually bound from canvas scope, e.g. "$.active.id" or "$.i.id".')
|
|
54
|
+
}).strict().describe("Renders an action instance by id. Resolves to nothing when instanceId is missing.");
|
|
55
|
+
|
|
56
|
+
// src/document/shell-head.ts
|
|
57
|
+
var createShellHead = (shell) => {
|
|
58
|
+
const view = chunkOO247V4J_cjs.shellView(shell);
|
|
59
|
+
let present = 0;
|
|
60
|
+
let keep;
|
|
61
|
+
let queued = false;
|
|
62
|
+
const read = () => {
|
|
63
|
+
if (queued || typeof document === "undefined") return;
|
|
64
|
+
queued = true;
|
|
65
|
+
queueMicrotask(() => {
|
|
66
|
+
queued = false;
|
|
67
|
+
keep ??= chunkWGZZKCJQ_cjs.createHeadKeeper(document);
|
|
68
|
+
keep(present > 0 ? chunkPNQY6OFB_cjs.headOf(view.api)?.elements : void 0);
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
return {
|
|
72
|
+
enter: () => {
|
|
73
|
+
present += 1;
|
|
74
|
+
read();
|
|
75
|
+
},
|
|
76
|
+
leave: () => {
|
|
77
|
+
present -= 1;
|
|
78
|
+
read();
|
|
79
|
+
},
|
|
80
|
+
watch: () => view.subscribe(() => {
|
|
81
|
+
if (present > 0) read();
|
|
82
|
+
})
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
exports.ActionSlotPropsSchema = ActionSlotPropsSchema;
|
|
87
|
+
exports.BoxPropsSchema = BoxPropsSchema;
|
|
88
|
+
exports.ButtonPropsSchema = ButtonPropsSchema;
|
|
89
|
+
exports.CanvasSlotPropsSchema = CanvasSlotPropsSchema;
|
|
90
|
+
exports.InputPropsSchema = InputPropsSchema;
|
|
91
|
+
exports.JsonTreePropsSchema = JsonTreePropsSchema;
|
|
92
|
+
exports.PanelPropsSchema = PanelPropsSchema;
|
|
93
|
+
exports.StackPropsSchema = StackPropsSchema;
|
|
94
|
+
exports.TextPropsSchema = TextPropsSchema;
|
|
95
|
+
exports.createShellHead = createShellHead;
|
|
96
|
+
//# sourceMappingURL=chunk-5AF72LOE.cjs.map
|
|
97
|
+
//# sourceMappingURL=chunk-5AF72LOE.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/adapters/primitive-props.ts","../src/document/shell-head.ts"],"names":["z","shellView","createHeadKeeper","headOf"],"mappings":";;;;;;;AAWO,IAAM,gBAAA,GAAmBA,MAC7B,MAAA,CAAO;AAAA,EACN,SAAA,EAAWA,KAAA,CACR,IAAA,CAAK,CAAC,KAAA,EAAO,QAAQ,CAAC,CAAA,CACtB,QAAA,EAAS,CACT,QAAA,CAAS,kCAAkC,CAAA;AAAA,EAC9C,GAAA,EAAKA,KAAA,CACF,MAAA,EAAO,CACP,GAAA,EAAI,CACJ,GAAA,CAAI,CAAC,CAAA,CACL,QAAA,EAAS,CACT,QAAA,CAAS,6CAA6C,CAAA;AAAA,EACzD,KAAA,EAAOA,KAAA,CACJ,IAAA,CAAK,CAAC,OAAA,EAAS,QAAA,EAAU,KAAA,EAAO,SAAS,CAAC,CAAA,CAC1C,QAAA,EAAS,CACT,SAAS,yCAAyC,CAAA;AAAA,EACrD,OAAA,EAASA,KAAA,CACN,IAAA,CAAK,CAAC,SAAS,QAAA,EAAU,KAA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KAAA;AAEb,EAAA,MAAM,OAAO,MAAY;AAEvB,IAAA,IAAI,MAAA,IAAU,OAAO,QAAA,KAAa,WAAA,EAAa;AAC/C,IAAA,MAAA,GAAS,IAAA;AACT,IAAA,cAAA,CAAe,MAAM;AACnB,MAAA,MAAA,GAAS,KAAA;AACT,MAAA,IAAA,KAASC,mCAAiB,QAAQ,CAAA;AAClC,MAAA,IAAA,CAAK,UAAU,CAAA,GAAIC,wBAAA,CAAO,KAAK,GAAG,CAAA,EAAG,WAAW,MAAS,CAAA;AAAA,IAC3D,CAAC,CAAA;AAAA,EACH,CAAA;AACA,EAAA,OAAO;AAAA,IACL,OAAO,MAAM;AACX,MAAA,OAAA,IAAW,CAAA;AACX,MAAA,IAAA,EAAK;AAAA,IACP,CAAA;AAAA,IACA,OAAO,MAAM;AACX,MAAA,OAAA,IAAW,CAAA;AACX,MAAA,IAAA,EAAK;AAAA,IACP,CAAA;AAAA,IACA,KAAA,EAAO,MACL,IAAA,CAAK,SAAA,CAAU,MAAM;AACnB,MAAA,IAAI,OAAA,GAAU,GAAG,IAAA,EAAK;AAAA,IACxB,CAAC;AAAA,GACL;AACF","file":"chunk-5AF72LOE.cjs","sourcesContent":["import { z } from 'zod';\n\n// ═══════════════════════════════════════════════════════════\n// The headless primitive vocabulary's AUTHORING contracts — one Zod props\n// schema per primitive, framework-free, shared by every adapter kit that ships\n// the vocabulary (react, vue). A schema is what a layout node may set; the\n// kits differ in how they paint, never in what they accept, so the schema\n// lives once, here, and each kit's component carries it as its static `meta`.\n// ═══════════════════════════════════════════════════════════\n\n// ─── Stack ───\nexport const StackPropsSchema = z\n .object({\n direction: z\n .enum(['row', 'column'])\n .optional()\n .describe('Flex direction. Default: column.'),\n gap: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe('Gap between children in pixels. Default: 0.'),\n align: z\n .enum(['start', 'center', 'end', 'stretch'])\n .optional()\n .describe('Cross-axis alignment. Default: stretch.'),\n justify: z\n .enum(['start', 'center', 'end', 'between', 'around'])\n .optional()\n .describe('Main-axis justification. Default: start.'),\n padding: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe('Inner padding in pixels. Default: 0.'),\n wrap: z\n .boolean()\n .optional()\n .describe('Whether children wrap to a new line. Default: false.'),\n })\n .strict()\n .describe('Flex container that arranges children in a row or column.');\n\nexport type StackProps = z.infer<typeof StackPropsSchema>;\n\n// ─── Text ───\nexport const TextPropsSchema = z\n .object({\n as: z\n .enum(['span', 'p', 'h1', 'h2', 'h3', 'h4'])\n .optional()\n .describe('HTML element to render. Default: span.'),\n size: z\n .enum(['sm', 'md', 'lg', 'xl', '2xl'])\n .optional()\n .describe('Font size token. Default: md.'),\n weight: z\n .enum(['normal', 'medium', 'bold'])\n .optional()\n .describe('Font weight token. Default: normal.'),\n color: z\n .string()\n .optional()\n .describe('CSS color string (open set). Default: inherit.'),\n })\n .strict()\n .describe('Text element with semantic typography props.');\n\nexport type TextProps = z.infer<typeof TextPropsSchema>;\n\n// ─── Input ───\nexport const InputPropsSchema = z\n .object({\n type: z\n .enum(['text', 'number', 'email', 'password'])\n .optional()\n .describe('Input type. Default: text.'),\n placeholder: z\n .string()\n .optional()\n .describe('Placeholder text shown when empty.'),\n disabled: z\n .boolean()\n .optional()\n .describe('Whether the input is disabled. Default: false.'),\n value: z\n .string()\n .optional()\n .describe('Current value. Typically supplied via model binding.'),\n debounce: z\n .number()\n .optional()\n .describe('Milliseconds to coalesce keystrokes before dispatching ui:model. Default: 0 (every keystroke). Set it when the shell is remote to cut round-trips.'),\n })\n .strict()\n .describe('Text input bound to data via the `model` field on the layout node.');\n\nexport type InputProps = z.infer<typeof InputPropsSchema>;\n\n// ─── Button ───\nexport const ButtonPropsSchema = z\n .object({\n label: z\n .string()\n .optional()\n .describe('Button label. If absent, children are used.'),\n variant: z\n .enum(['primary', 'secondary', 'ghost'])\n .optional()\n .describe('Visual variant. Default: primary.'),\n disabled: z\n .boolean()\n .optional()\n .describe('Whether the button is disabled. Default: false.'),\n })\n .strict()\n .describe(\"Clickable button. Click events fire as `ui:click` with the layout node's ref.\");\n\nexport type ButtonProps = z.infer<typeof ButtonPropsSchema>;\n\n// ─── Box ───\nexport const BoxPropsSchema = z\n .object({\n padding: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe('Inner padding in pixels. Default: 0.'),\n background: z\n .string()\n .optional()\n .describe('CSS background color or value.'),\n border: z\n .boolean()\n .optional()\n .describe('Whether to show a 1px border. Default: false.'),\n radius: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe('Border radius in pixels. Default: 0.'),\n })\n .strict()\n .describe('Generic container with basic styling props. Use Stack for layout, Box for visual wrapping.');\n\nexport type BoxProps = z.infer<typeof BoxPropsSchema>;\n\n// ─── Panel ───\nexport const PanelPropsSchema = z\n .object({\n title: z.string().optional().describe('Optional header title.'),\n backRef: z.string().optional().describe('When set, the header grows a ← (before the title) that fires ui:click with this ref.'),\n closeRef: z.string().optional().describe('When set, the header grows a ✕ that fires ui:click with this ref.'),\n })\n .strict()\n .describe('A framed, elevated surface with an optional title.');\n\nexport type PanelProps = z.infer<typeof PanelPropsSchema>;\n\n// ─── JsonTree ───\nexport const JsonTreePropsSchema = z\n .object({\n value: z.unknown().optional().describe('The value to render.'),\n label: z.string().optional().describe('A name for the root node.'),\n })\n .strict()\n .describe('A collapsible view of any JSON value.');\n\nexport type JsonTreeProps = z.infer<typeof JsonTreePropsSchema>;\n\n// ─── CanvasSlot ───\nexport const CanvasSlotPropsSchema = z\n .object({\n canvasId: z\n .string()\n .optional()\n .describe('Id of the canvas to render. Usually bound from a loop, e.g. \"$.c.id\".'),\n })\n .strict()\n .describe('Renders a canvas by id, recursing into its actionLayout. Resolves to nothing when canvasId is missing.');\n\nexport type CanvasSlotProps = z.infer<typeof CanvasSlotPropsSchema>;\n\n// ─── ActionSlot ───\n// The AUTHORING contract: what a layout node may set on an ActionSlot —\n// instanceId only, strict. The identity props flattenRenderTree stamps on a\n// served marker (canvasId / definitionId) are runtime OUTPUT, never authored;\n// widening this schema would advertise them to the layout agent's palette.\nexport const ActionSlotPropsSchema = z\n .object({\n instanceId: z\n .string()\n .optional()\n .describe('Id of the action instance to render. Usually bound from canvas scope, e.g. \"$.active.id\" or \"$.i.id\".'),\n })\n .strict()\n .describe('Renders an action instance by id. Resolves to nothing when instanceId is missing.');\n\nexport type ActionSlotProps = z.infer<typeof ActionSlotPropsSchema>;\n\n","import { headOf, shellView } from '../shell';\nimport type { Shell } from '../shell';\nimport { createHeadKeeper } from './head-keeper';\nimport type { HeadKeeper } from './head-keeper';\n\n// ═══════════════════════════════════════════════════════════\n// The page's head, for an adapter that draws a shell living in its own page\n// through a framework (react, vue).\n//\n// Such an adapter reads the shell's trees through its own subscriptions, so\n// there is no one render to read the head off: reading it means rendering the\n// shell's trees once more. That is worth doing only while a head is on the\n// screen. So a head node says when it arrives and when it goes (`enter`,\n// `leave`), and the shell is only read between the two.\n// ═══════════════════════════════════════════════════════════\n\nexport type ShellHead = {\n enter: () => void;\n leave: () => void;\n // follow the shell's changes; returns the stop\n watch: () => () => void;\n};\n\nexport const createShellHead = (shell: Shell): ShellHead => {\n const view = shellView(shell);\n let present = 0;\n let keep: HeadKeeper | undefined;\n let queued = false;\n // once a turn, however many heads came and went in it\n const read = (): void => {\n // nothing to keep where a screen is drawn to a string\n if (queued || typeof document === 'undefined') return;\n queued = true;\n queueMicrotask(() => {\n queued = false;\n keep ??= createHeadKeeper(document);\n keep(present > 0 ? headOf(view.api)?.elements : undefined);\n });\n };\n return {\n enter: () => {\n present += 1;\n read();\n },\n leave: () => {\n present -= 1;\n read();\n },\n watch: () =>\n view.subscribe(() => {\n if (present > 0) read();\n }),\n };\n};\n"]}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkKOYRJXTI_cjs = require('./chunk-KOYRJXTI.cjs');
|
|
4
|
+
var chunkKW34ZKF5_cjs = require('./chunk-KW34ZKF5.cjs');
|
|
5
|
+
|
|
6
|
+
// src/i18n/translate.ts
|
|
7
|
+
var walkNode = (node, where, pass) => {
|
|
8
|
+
if (node.type === "text") {
|
|
9
|
+
if (!pass.text) return node;
|
|
10
|
+
const value = chunkKOYRJXTI_cjs.swap(node.value, where, pass);
|
|
11
|
+
return value === node.value ? node : { ...node, value };
|
|
12
|
+
}
|
|
13
|
+
if (node.type === "fragment") {
|
|
14
|
+
const children2 = walkNodes(node.children, where, pass);
|
|
15
|
+
return children2 === node.children ? node : { ...node, children: children2 };
|
|
16
|
+
}
|
|
17
|
+
if (node.type === "error") return node;
|
|
18
|
+
const at = node.ref === void 0 ? `${where}/${node.name}` : `${where}/${node.name}#${node.ref}`;
|
|
19
|
+
let props = node.props;
|
|
20
|
+
let propsChanged = false;
|
|
21
|
+
const nextProps = {};
|
|
22
|
+
for (const [key, value] of Object.entries(node.props)) {
|
|
23
|
+
const next = chunkKOYRJXTI_cjs.walkValue(value, pass.isProse(key), `${at}.${key}`, pass);
|
|
24
|
+
if (next !== value) propsChanged = true;
|
|
25
|
+
nextProps[key] = next;
|
|
26
|
+
}
|
|
27
|
+
if (propsChanged) props = nextProps;
|
|
28
|
+
const children = walkNodes(node.children, at, pass);
|
|
29
|
+
if (!propsChanged && children === node.children) return node;
|
|
30
|
+
return { ...node, props, children };
|
|
31
|
+
};
|
|
32
|
+
var walkNodes = (nodes, where, pass) => {
|
|
33
|
+
let changed = false;
|
|
34
|
+
const out = nodes.map((node) => {
|
|
35
|
+
const next = walkNode(node, where, pass);
|
|
36
|
+
if (next !== node) changed = true;
|
|
37
|
+
return next;
|
|
38
|
+
});
|
|
39
|
+
return changed ? out : nodes;
|
|
40
|
+
};
|
|
41
|
+
var translateRenderTree = (tree, options) => {
|
|
42
|
+
if (Object.keys(options.phrases).length === 0) return tree;
|
|
43
|
+
const pass = chunkKOYRJXTI_cjs.passFor({
|
|
44
|
+
phrases: options.phrases,
|
|
45
|
+
...options.keys === void 0 ? {} : { keys: options.keys },
|
|
46
|
+
...options.onMiss === void 0 ? {} : { onMiss: options.onMiss }
|
|
47
|
+
});
|
|
48
|
+
if (pass === void 0) return tree;
|
|
49
|
+
return walkNodes(tree, "", pass);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// src/i18n/harvest.ts
|
|
53
|
+
var sinkInto = (found, keys) => {
|
|
54
|
+
const matcher = chunkKOYRJXTI_cjs.matcherFor(keys);
|
|
55
|
+
return {
|
|
56
|
+
add: (phrase, where) => {
|
|
57
|
+
const trimmed = phrase.trim();
|
|
58
|
+
if (!chunkKOYRJXTI_cjs.isPhrase(trimmed)) return;
|
|
59
|
+
const sites = found.get(trimmed);
|
|
60
|
+
if (sites === void 0) found.set(trimmed, /* @__PURE__ */ new Set([where]));
|
|
61
|
+
else sites.add(where);
|
|
62
|
+
},
|
|
63
|
+
isProse: matcher.isProse,
|
|
64
|
+
text: matcher.text
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
var harvestWithin = (value, where, sink) => {
|
|
68
|
+
if (typeof value === "string") {
|
|
69
|
+
sink.add(value, where);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (chunkKW34ZKF5_cjs.isArray(value)) {
|
|
73
|
+
value.forEach((entry, index) => harvestWithin(entry, `${where}[${String(index)}]`, sink));
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (chunkKW34ZKF5_cjs.isObject(value)) {
|
|
77
|
+
for (const [key, entry] of Object.entries(value)) harvestWithin(entry, `${where}.${key}`, sink);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
var harvestProps = (props, where, sink) => {
|
|
81
|
+
for (const [key, value] of Object.entries(props)) {
|
|
82
|
+
if (sink.isProse(key)) {
|
|
83
|
+
harvestWithin(value, `${where}.${key}`, sink);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (chunkKW34ZKF5_cjs.isObject(value) || chunkKW34ZKF5_cjs.isArray(value)) harvestNested(value, `${where}.${key}`, sink);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
var harvestNested = (value, where, sink) => {
|
|
90
|
+
if (chunkKW34ZKF5_cjs.isArray(value)) {
|
|
91
|
+
value.forEach((entry, index) => harvestNested(entry, `${where}[${String(index)}]`, sink));
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (!chunkKW34ZKF5_cjs.isObject(value)) return;
|
|
95
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
96
|
+
if (sink.isProse(key)) harvestWithin(entry, `${where}.${key}`, sink);
|
|
97
|
+
else harvestNested(entry, `${where}.${key}`, sink);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
var harvestNode = (node, where, sink) => {
|
|
101
|
+
if (node === null || node === void 0) return;
|
|
102
|
+
if (typeof node === "string") {
|
|
103
|
+
if (sink.text) sink.add(node, where);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (typeof node === "number" || typeof node === "boolean") return;
|
|
107
|
+
if (chunkKW34ZKF5_cjs.isArray(node)) {
|
|
108
|
+
node.forEach((child, index) => harvestNode(child, `${where}[${String(index)}]`, sink));
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (!chunkKW34ZKF5_cjs.isObject(node)) return;
|
|
112
|
+
const component = node["component"];
|
|
113
|
+
if (component === void 0) {
|
|
114
|
+
if ("ref" in node || "slot" in node) return;
|
|
115
|
+
if ("if" in node) {
|
|
116
|
+
harvestNode(node["then"], `${where}.then`, sink);
|
|
117
|
+
harvestNode(node["else"], `${where}.else`, sink);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if ("for" in node && "do" in node) {
|
|
121
|
+
harvestNode(node["do"], `${where}.do`, sink);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const at = `${where}/${String(component)}`;
|
|
127
|
+
const props = node["props"];
|
|
128
|
+
if (chunkKW34ZKF5_cjs.isObject(props)) harvestProps(props, at, sink);
|
|
129
|
+
harvestNode(node["children"], `${at}.children`, sink);
|
|
130
|
+
};
|
|
131
|
+
var toList = (found) => [...found.entries()].map(([phrase, sites]) => ({ phrase, where: [...sites].sort() })).sort((a, b) => a.phrase.localeCompare(b.phrase));
|
|
132
|
+
var harvestLayout = (layout, keys) => {
|
|
133
|
+
const found = /* @__PURE__ */ new Map();
|
|
134
|
+
harvestNode(layout, "", sinkInto(found, keys));
|
|
135
|
+
return toList(found);
|
|
136
|
+
};
|
|
137
|
+
var harvestSteps = (value, where, sink) => {
|
|
138
|
+
if (chunkKW34ZKF5_cjs.isArray(value)) {
|
|
139
|
+
value.forEach((entry, index) => harvestSteps(entry, `${where}[${String(index)}]`, sink));
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (!chunkKW34ZKF5_cjs.isObject(value)) return;
|
|
143
|
+
const target = value["set"];
|
|
144
|
+
const written = value["value"];
|
|
145
|
+
if (typeof target === "string" && typeof written === "string") sink.add(written, `${where}.set:${target}`);
|
|
146
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
147
|
+
if (key === "set" || key === "value") continue;
|
|
148
|
+
harvestSteps(entry, `${where}.${key}`, sink);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
var harvestDefinition = (definition, keys) => {
|
|
152
|
+
const found = /* @__PURE__ */ new Map();
|
|
153
|
+
const sink = sinkInto(found, keys);
|
|
154
|
+
const id = definition.id;
|
|
155
|
+
if (typeof definition.title === "string") sink.add(definition.title, `${id}.title`);
|
|
156
|
+
for (const [key, value] of Object.entries(definition.data ?? {})) {
|
|
157
|
+
if (typeof value === "string") sink.add(value, `${id}.data.${key}`);
|
|
158
|
+
else if (chunkKW34ZKF5_cjs.isObject(value) || chunkKW34ZKF5_cjs.isArray(value)) harvestNested(value, `${id}.data.${key}`, sink);
|
|
159
|
+
}
|
|
160
|
+
if (definition.layout !== void 0) harvestNode(definition.layout, id, sink);
|
|
161
|
+
if (definition.triggers !== void 0) harvestSteps(definition.triggers, `${id}.triggers`, sink);
|
|
162
|
+
if (definition.lifecycle !== void 0) harvestSteps(definition.lifecycle, `${id}.lifecycle`, sink);
|
|
163
|
+
return toList(found);
|
|
164
|
+
};
|
|
165
|
+
var harvestDefinitions = (definitions, keys) => {
|
|
166
|
+
const found = /* @__PURE__ */ new Map();
|
|
167
|
+
for (const definition of Object.values(definitions)) {
|
|
168
|
+
for (const entry of harvestDefinition(definition, keys)) {
|
|
169
|
+
const sites = found.get(entry.phrase);
|
|
170
|
+
if (sites === void 0) found.set(entry.phrase, new Set(entry.where));
|
|
171
|
+
else for (const site of entry.where) sites.add(site);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return toList(found);
|
|
175
|
+
};
|
|
176
|
+
var missingFrom = (harvested, phrases) => harvested.filter((entry) => phrases[entry.phrase] === void 0);
|
|
177
|
+
|
|
178
|
+
exports.harvestDefinition = harvestDefinition;
|
|
179
|
+
exports.harvestDefinitions = harvestDefinitions;
|
|
180
|
+
exports.harvestLayout = harvestLayout;
|
|
181
|
+
exports.missingFrom = missingFrom;
|
|
182
|
+
exports.translateRenderTree = translateRenderTree;
|
|
183
|
+
//# sourceMappingURL=chunk-5YQIAS4V.cjs.map
|
|
184
|
+
//# sourceMappingURL=chunk-5YQIAS4V.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/i18n/translate.ts","../src/i18n/harvest.ts"],"names":["swap","children","walkValue","passFor","matcherFor","isPhrase","isArray","isObject"],"mappings":";;;;;;AAoCA,IAAM,QAAA,GAAW,CAAC,IAAA,EAAkB,KAAA,EAAe,IAAA,KAA2B;AAC5E,EAAA,IAAI,IAAA,CAAK,SAAS,MAAA,EAAQ;AACxB,IAAA,IAAI,CAAC,IAAA,CAAK,IAAA,EAAM,OAAO,IAAA;AACvB,IAAA,MAAM,KAAA,GAAQA,sBAAA,CAAK,IAAA,CAAK,KAAA,EAAO,OAAO,IAAI,CAAA;AAC1C,IAAA,OAAO,UAAU,IAAA,CAAK,KA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AACA,EAAA,OAAO,OAAO,KAAK,CAAA;AACrB;AAGO,IAAM,WAAA,GAAc,CACzB,SAAA,EACA,OAAA,KACsB,SAAA,CAAU,MAAA,CAAO,CAAC,KAAA,KAAU,OAAA,CAAQ,KAAA,CAAM,MAAM,CAAA,KAAM,MAAS","file":"chunk-5YQIAS4V.cjs","sourcesContent":["import type { RenderNode } from '../layout';\nimport { passFor, swap, walkValue } from './swap';\nimport type { Pass } from './swap';\nimport type { PhraseKeys, Phrasebook } from './phrases';\n\n// ═══════════════════════════════════════════════════════════\n// translateRenderTree — the late pass, for whoever holds a tree they did not\n// render.\n//\n// NOT the main road any more. Since the swap moved into the renderer\n// (`layout/renderer.ts`), a tree that came out of a nova shell is already in\n// the reader's language and this pass would find nothing to do. What is left\n// for it is every tree that arrived from somewhere else: a frame replayed from\n// a cache, an exporter's fixture, a test that builds nodes by hand.\n//\n// Structure in, same structure out, with prose swapped. A phrase with no entry\n// passes through unchanged — the only sane failure, since a missing\n// translation should show the source language, never an empty box and never a\n// key. `onMiss` is how a check turns those into a list.\n//\n// One deliberate difference from the renderer: an EMPTY book short-circuits\n// here and returns the very same tree, patterns included. The renderer fills\n// patterns even with no book, because a source-language session has nobody\n// else to do it; a tree-holder with no book has nothing to say about a tree it\n// did not make.\n// ═══════════════════════════════════════════════════════════\n\nexport type TranslateOptions = {\n phrases: Phrasebook;\n keys?: PhraseKeys;\n // Called once per untranslated phrase, with where it was found. For a dev\n // check that has to answer \"what did we forget\" without a human reading every\n // screen. Never call it from a hot path — it is a reporting seam.\n onMiss?: (phrase: string, where: string) => void;\n};\n\nconst walkNode = (node: RenderNode, where: string, pass: Pass): RenderNode => {\n if (node.type === 'text') {\n if (!pass.text) return node;\n const value = swap(node.value, where, pass);\n return value === node.value ? node : { ...node, value };\n }\n\n if (node.type === 'fragment') {\n const children = walkNodes(node.children, where, pass);\n return children === node.children ? node : { ...node, children };\n }\n\n // An error node's message is a diagnostic for whoever is on call, not product\n // copy — left in the language the stack throws in, deliberately.\n if (node.type === 'error') return node;\n\n const at = node.ref === undefined ? `${where}/${node.name}` : `${where}/${node.name}#${node.ref}`;\n let props = node.props;\n let propsChanged = false;\n const nextProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(node.props)) {\n const next = walkValue(value, pass.isProse(key), `${at}.${key}`, pass);\n if (next !== value) propsChanged = true;\n nextProps[key] = next;\n }\n if (propsChanged) props = nextProps;\n\n const children = walkNodes(node.children, at, pass);\n if (!propsChanged && children === node.children) return node;\n return { ...node, props, children };\n};\n\n// Identity is returned when nothing under a node changed. Not an optimisation\n// for its own sake: an untranslated locale (the source language) must produce\n// the byte-identical frame it produced before this pass existed, or every\n// English session pays a delta rebuild for a walk that did nothing.\nconst walkNodes = (nodes: RenderNode[], where: string, pass: Pass): RenderNode[] => {\n let changed = false;\n const out = nodes.map((node) => {\n const next = walkNode(node, where, pass);\n if (next !== node) changed = true;\n return next;\n });\n return changed ? out : nodes;\n};\n\nexport const translateRenderTree = (tree: RenderNode[], options: TranslateOptions): RenderNode[] => {\n // An empty phrasebook is the source language. Skip the walk entirely rather\n // than doing it and finding nothing.\n if (Object.keys(options.phrases).length === 0) return tree;\n const pass = passFor({\n phrases: options.phrases,\n ...(options.keys === undefined ? {} : { keys: options.keys }),\n ...(options.onMiss === undefined ? {} : { onMiss: options.onMiss }),\n });\n if (pass === undefined) return tree;\n return walkNodes(tree, '', pass);\n};\n","import { isArray, isObject } from '../shared/common';\nimport type { ActionDefinition } from '../action';\nimport type { LayoutNode } from '../layout';\nimport { isPhrase, matcherFor } from './phrases';\nimport type { PhraseKeys } from './phrases';\n\n// ═══════════════════════════════════════════════════════════\n// harvest — read every phrase an action could put on a screen, without\n// running it.\n//\n// The other half of the late pass. Keying a dictionary on source strings only\n// works if there is a mechanical way to enumerate them; otherwise \"translate\n// the app\" means a human reading every layout, and the second language is\n// permanently 90% done.\n//\n// This walks the AUTHORED artifacts — definitions and layouts — not a rendered\n// tree, and that is the point: what comes back is exactly the set of strings a\n// person wrote, never a value that arrived from the database. A member called\n// \"Pass\" can therefore never enter the dictionary by being on screen the day\n// somebody ran the harvest.\n// ═══════════════════════════════════════════════════════════\n\nexport type HarvestedPhrase = {\n phrase: string;\n /** Every author site it came from — sorted, deduped. */\n where: readonly string[];\n};\n\ntype Sink = {\n add: (phrase: string, where: string) => void;\n isProse: (key: string) => boolean;\n text: boolean;\n};\n\nconst sinkInto = (found: Map<string, Set<string>>, keys: PhraseKeys | undefined): Sink => {\n const matcher = matcherFor(keys);\n return {\n add: (phrase, where) => {\n const trimmed = phrase.trim();\n if (!isPhrase(trimmed)) return;\n const sites = found.get(trimmed);\n if (sites === undefined) found.set(trimmed, new Set([where]));\n else sites.add(where);\n },\n isProse: matcher.isProse,\n text: matcher.text,\n };\n};\n\n// Inside an allowlisted prop, EVERY reachable literal is a phrase. A `label`\n// holding `{ $if: …, $then: 'Save', $else: 'Create' }` has two of them, and a\n// harvester that only accepted a direct string would silently drop the branch\n// nobody was looking at.\nconst harvestWithin = (value: unknown, where: string, sink: Sink): void => {\n if (typeof value === 'string') {\n sink.add(value, where);\n return;\n }\n if (isArray(value)) {\n value.forEach((entry, index) => harvestWithin(entry, `${where}[${String(index)}]`, sink));\n return;\n }\n if (isObject(value)) {\n for (const [key, entry] of Object.entries(value)) harvestWithin(entry, `${where}.${key}`, sink);\n }\n};\n\nconst harvestProps = (props: Record<string, unknown>, where: string, sink: Sink): void => {\n for (const [key, value] of Object.entries(props)) {\n if (sink.isProse(key)) {\n harvestWithin(value, `${where}.${key}`, sink);\n continue;\n }\n // Not a prose key itself — but a nested object under it may hold one\n // (`cell: { label }` inside a column spec). Keep descending; only the KEY\n // decides, never the depth.\n if (isObject(value) || isArray(value)) harvestNested(value, `${where}.${key}`, sink);\n }\n};\n\nconst harvestNested = (value: unknown, where: string, sink: Sink): void => {\n if (isArray(value)) {\n value.forEach((entry, index) => harvestNested(entry, `${where}[${String(index)}]`, sink));\n return;\n }\n if (!isObject(value)) return;\n for (const [key, entry] of Object.entries(value)) {\n if (sink.isProse(key)) harvestWithin(entry, `${where}.${key}`, sink);\n else harvestNested(entry, `${where}.${key}`, sink);\n }\n};\n\n// Takes `unknown` rather than `LayoutNode`: the walk discriminates the node\n// kinds structurally, and narrowing a union by `in` checks fights the compiler\n// for no benefit here — every branch reads what it needs and guards it.\nconst harvestNode = (node: unknown, where: string, sink: Sink): void => {\n if (node === null || node === undefined) return;\n if (typeof node === 'string') {\n // A text position: the layout's literal children.\n if (sink.text) sink.add(node, where);\n return;\n }\n if (typeof node === 'number' || typeof node === 'boolean') return;\n if (isArray(node)) {\n node.forEach((child, index) => harvestNode(child, `${where}[${String(index)}]`, sink));\n return;\n }\n if (!isObject(node)) return;\n\n const component = node['component'];\n if (component === undefined) {\n // A stored-layout reference and a fragment slot are ids, never words.\n if ('ref' in node || 'slot' in node) return;\n if ('if' in node) {\n harvestNode(node['then'], `${where}.then`, sink);\n harvestNode(node['else'], `${where}.else`, sink);\n return;\n }\n if ('for' in node && 'do' in node) {\n harvestNode(node['do'], `${where}.do`, sink);\n return;\n }\n return;\n }\n\n const at = `${where}/${String(component)}`;\n const props = node['props'];\n if (isObject(props)) harvestProps(props, at, sink);\n harvestNode(node['children'], `${at}.children`, sink);\n};\n\nconst toList = (found: Map<string, Set<string>>): HarvestedPhrase[] =>\n [...found.entries()]\n .map(([phrase, sites]) => ({ phrase, where: [...sites].sort() }))\n .sort((a, b) => a.phrase.localeCompare(b.phrase));\n\nexport const harvestLayout = (layout: LayoutNode, keys?: PhraseKeys): HarvestedPhrase[] => {\n const found = new Map<string, Set<string>>();\n harvestNode(layout, '', sinkInto(found, keys));\n return toList(found);\n};\n\n// A `{ set: '<key>', value: '<literal>' }` step writes words into data, and\n// data lands in props. An error message a trigger sets is as much product copy\n// as a heading, and is otherwise invisible to a harvester that only reads\n// layouts.\nconst harvestSteps = (value: unknown, where: string, sink: Sink): void => {\n if (isArray(value)) {\n value.forEach((entry, index) => harvestSteps(entry, `${where}[${String(index)}]`, sink));\n return;\n }\n if (!isObject(value)) return;\n const target = value['set'];\n const written = value['value'];\n if (typeof target === 'string' && typeof written === 'string') sink.add(written, `${where}.set:${target}`);\n for (const [key, entry] of Object.entries(value)) {\n if (key === 'set' || key === 'value') continue;\n harvestSteps(entry, `${where}.${key}`, sink);\n }\n};\n\nexport const harvestDefinition = (definition: ActionDefinition, keys?: PhraseKeys): HarvestedPhrase[] => {\n const found = new Map<string, Set<string>>();\n const sink = sinkInto(found, keys);\n const id = definition.id;\n\n // The title is chrome's words — a Sheet header, a catalog entry — and reaches\n // the tree as a prop rather than from the layout.\n if (typeof definition.title === 'string') sink.add(definition.title, `${id}.title`);\n\n // Defaulted data is a screen's opening text: the 'Stock' in a theme name, the\n // placeholder a list shows before its first read lands.\n //\n // TWO RULES, because `data` is two things at once.\n //\n // A top-level string is taken WHOLE, whatever its key. Where it lands decides\n // whether it is prose, and only the LAYOUT knows that: `runningHint` is not a\n // prose key and reaches the glass as a text child, so a matcher applied here\n // would drop a sentence the pass goes on to translate. The cost of taking\n // them all is enum values and ids in the report, which a host filters by name.\n //\n // Anything NESTED is walked by the matcher instead, and that is the rule that\n // reaches an options array — `views: [{ value: 'running', label: 'Running' }]`\n // yields `Running` and never `running`. Without it a tab strip built in data\n // is not merely untranslatable but UNCOUNTED, which is the worse half: the\n // harvest reports a full book while the words are missing from the screen.\n for (const [key, value] of Object.entries(definition.data ?? {})) {\n if (typeof value === 'string') sink.add(value, `${id}.data.${key}`);\n else if (isObject(value) || isArray(value)) harvestNested(value, `${id}.data.${key}`, sink);\n }\n\n if (definition.layout !== undefined) harvestNode(definition.layout, id, sink);\n if (definition.triggers !== undefined) harvestSteps(definition.triggers, `${id}.triggers`, sink);\n if (definition.lifecycle !== undefined) harvestSteps(definition.lifecycle, `${id}.lifecycle`, sink);\n\n return toList(found);\n};\n\nexport const harvestDefinitions = (\n definitions: Record<string, ActionDefinition>,\n keys?: PhraseKeys,\n): HarvestedPhrase[] => {\n const found = new Map<string, Set<string>>();\n for (const definition of Object.values(definitions)) {\n for (const entry of harvestDefinition(definition, keys)) {\n const sites = found.get(entry.phrase);\n if (sites === undefined) found.set(entry.phrase, new Set(entry.where));\n else for (const site of entry.where) sites.add(site);\n }\n }\n return toList(found);\n};\n\n/** Phrases with no entry in the book — what a language is still missing. */\nexport const missingFrom = (\n harvested: readonly HarvestedPhrase[],\n phrases: Readonly<Record<string, string>>,\n): HarvestedPhrase[] => harvested.filter((entry) => phrases[entry.phrase] === undefined);\n"]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var zod = require('zod');
|
|
4
|
+
|
|
5
|
+
// src/layout/schemas.ts
|
|
6
|
+
zod.z.object({
|
|
7
|
+
$if: zod.z.unknown().describe("Condition \u2014 resolved recursively, then checked for truthiness."),
|
|
8
|
+
$then: zod.z.unknown().describe("Value when condition is truthy \u2014 resolved recursively."),
|
|
9
|
+
$else: zod.z.unknown().optional().describe("Value when condition is falsy \u2014 resolved recursively.")
|
|
10
|
+
}).strict().describe("Conditional value directive. Resolved at bind time.");
|
|
11
|
+
var ResolvableSchema = zod.z.unknown().describe(
|
|
12
|
+
'Any value. Strings support {{}} templates and bare $-paths. The data ROOT is "$." \u2014 a data key is ALWAYS "$.key" ("{{$.rows.length}} found", "$.loading"); "$key" without the dot is INVALID. Loop variables (a `for` directive\'s `as`) are "$<name>.field" ("{{$row.title}}"). Objects may be directives like {$if,$then,$else}. Arrays and nested objects are walked recursively. Everything else is literal.'
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
// src/layout/schemas.ts
|
|
16
|
+
var LayoutPrimitiveSchema = zod.z.union([zod.z.string(), zod.z.number(), zod.z.boolean(), zod.z.null()]).describe("A primitive layout value rendered as text.");
|
|
17
|
+
var ComponentNodeSchema = zod.z.lazy(
|
|
18
|
+
() => zod.z.object({
|
|
19
|
+
component: zod.z.string().describe("The registry name of the component to render."),
|
|
20
|
+
props: zod.z.record(zod.z.string(), zod.z.unknown()).optional().describe("Component props; values may be bindings to be resolved at render time."),
|
|
21
|
+
children: zod.z.union([LayoutNodeSchema, zod.z.array(LayoutNodeSchema)]).optional().describe("Child layout content (a single node or an array of nodes)."),
|
|
22
|
+
ref: zod.z.string().optional().describe("A stable identifier used to target this component from event handlers."),
|
|
23
|
+
model: zod.z.string().optional().describe('A two-way binding path, e.g. "$.name".'),
|
|
24
|
+
events: zod.z.record(zod.z.string(), zod.z.unknown()).optional().describe("Map of event name to event configuration handled by the action runtime.")
|
|
25
|
+
}).strict().describe("A node that instantiates a component from the registry.")
|
|
26
|
+
);
|
|
27
|
+
var ConditionalNodeSchema = zod.z.lazy(
|
|
28
|
+
() => zod.z.object({
|
|
29
|
+
if: ResolvableSchema.describe("Resolvable value evaluated for truthiness."),
|
|
30
|
+
then: LayoutNodeSchema.describe("Layout to render when condition is truthy."),
|
|
31
|
+
else: LayoutNodeSchema.optional().describe("Layout to render when condition is falsy.")
|
|
32
|
+
}).strict().describe("A node that conditionally renders one of two branches.")
|
|
33
|
+
);
|
|
34
|
+
var LoopNodeSchema = zod.z.lazy(
|
|
35
|
+
() => zod.z.object({
|
|
36
|
+
for: ResolvableSchema.describe("Resolvable value that resolves to an iterable array."),
|
|
37
|
+
as: zod.z.string().describe("Name to bind each iterated item under in the inner scope."),
|
|
38
|
+
key: zod.z.string().optional().describe("Optional key path on each item used for stable identity."),
|
|
39
|
+
do: LayoutNodeSchema.describe("Layout rendered once per iterated item.")
|
|
40
|
+
}).strict().describe("A node that iterates an array binding and renders a layout for each item.")
|
|
41
|
+
);
|
|
42
|
+
var LayoutRefNodeSchema = zod.z.object({
|
|
43
|
+
ref: zod.z.string().describe("Identifier of a layout stored in the layout store to inline at this position.")
|
|
44
|
+
}).strict().describe("A reference to a stored layout, inlined during render.");
|
|
45
|
+
var SlotNodeSchema = zod.z.object({
|
|
46
|
+
slot: zod.z.string().describe(
|
|
47
|
+
"Name of a slot placeholder. When an ActionFragment is composed with an action (a push/replace `with`), the fragment's `{ slot: \"body\" }` node is replaced by the composing action's own layout. An unfilled slot renders nothing."
|
|
48
|
+
)
|
|
49
|
+
}).strict().describe(
|
|
50
|
+
"A placeholder that a fragment-merge fills with a composing action's layout. Only meaningful inside an ActionFragment's layout."
|
|
51
|
+
);
|
|
52
|
+
var LayoutNodeSchema = zod.z.lazy(
|
|
53
|
+
() => zod.z.union([
|
|
54
|
+
ComponentNodeSchema,
|
|
55
|
+
ConditionalNodeSchema,
|
|
56
|
+
LoopNodeSchema,
|
|
57
|
+
LayoutRefNodeSchema,
|
|
58
|
+
SlotNodeSchema,
|
|
59
|
+
zod.z.array(LayoutNodeSchema),
|
|
60
|
+
LayoutPrimitiveSchema
|
|
61
|
+
]).describe("Any layout node: component, conditional, loop, layout ref, slot, array of nodes, or a primitive text value.")
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
exports.ComponentNodeSchema = ComponentNodeSchema;
|
|
65
|
+
exports.ConditionalNodeSchema = ConditionalNodeSchema;
|
|
66
|
+
exports.LayoutNodeSchema = LayoutNodeSchema;
|
|
67
|
+
exports.LayoutPrimitiveSchema = LayoutPrimitiveSchema;
|
|
68
|
+
exports.LayoutRefNodeSchema = LayoutRefNodeSchema;
|
|
69
|
+
exports.LoopNodeSchema = LoopNodeSchema;
|
|
70
|
+
exports.SlotNodeSchema = SlotNodeSchema;
|
|
71
|
+
//# sourceMappingURL=chunk-D4PUWBN6.cjs.map
|
|
72
|
+
//# sourceMappingURL=chunk-D4PUWBN6.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/shared/bindings/schemas.ts","../src/layout/schemas.ts"],"names":["z"],"mappings":";;;;;AAEiCA,MAC9B,MAAA,CAAO;AAAA,EACN,GAAA,EAAKA,KAAA,CAAE,OAAA,EAAQ,CAAE,SAAS,qEAAgE,CAAA;AAAA,EAC1F,KAAA,EAAOA,KAAA,CAAE,OAAA,EAAQ,CAAE,SAAS,6DAAwD,CAAA;AAAA,EAC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L,mBAAA;AAAA,IACA,qBAAA;AAAA,IACA,cAAA;AAAA,IACA,mBAAA;AAAA,IACA,cAAA;AAAA,IACAA,KAAAA,CAAE,MAAM,gBAAgB,CAAA;AAAA,IACxB;AAAA,GACD,CAAA,CACA,QAAA,CAAS,6GAA6G;AAC3H","file":"chunk-D4PUWBN6.cjs","sourcesContent":["import { z } from 'zod';\n\nexport const IfDirectiveSchema = z\n .object({\n $if: z.unknown().describe('Condition — resolved recursively, then checked for truthiness.'),\n $then: z.unknown().describe('Value when condition is truthy — resolved recursively.'),\n $else: z\n .unknown()\n .optional()\n .describe('Value when condition is falsy — resolved recursively.'),\n })\n .strict()\n .describe('Conditional value directive. Resolved at bind time.');\n\nexport type IfDirective = z.infer<typeof IfDirectiveSchema>;\n\nexport const ResolvableSchema = z\n .unknown()\n .describe(\n 'Any value. Strings support {{}} templates and bare $-paths. The data ROOT is '\n + '\"$.\" — a data key is ALWAYS \"$.key\" (\"{{$.rows.length}} found\", \"$.loading\"); '\n + '\"$key\" without the dot is INVALID. Loop variables (a `for` directive\\'s `as`) '\n + 'are \"$<name>.field\" (\"{{$row.title}}\"). Objects may be directives like '\n + '{$if,$then,$else}. Arrays and nested objects are walked recursively. '\n + 'Everything else is literal.',\n );\n","import { z } from 'zod';\nimport { ResolvableSchema } from '../shared/bindings/schemas';\n\n// ═══════════════════════════════════════════════════════════\n// Layout node schemas\n// ═══════════════════════════════════════════════════════════\n\nexport const LayoutPrimitiveSchema = z\n .union([z.string(), z.number(), z.boolean(), z.null()])\n .describe('A primitive layout value rendered as text.');\n\nexport type LayoutPrimitive = z.infer<typeof LayoutPrimitiveSchema>;\n\nexport type ComponentNode = {\n component: string;\n props?: Record<string, unknown>;\n children?: LayoutNode | LayoutNode[];\n ref?: string;\n model?: string;\n events?: Record<string, unknown>;\n};\n\nexport const ComponentNodeSchema: z.ZodType<ComponentNode> = z.lazy(() =>\n z\n .object({\n component: z.string().describe('The registry name of the component to render.'),\n props: z\n .record(z.string(), z.unknown())\n .optional()\n .describe('Component props; values may be bindings to be resolved at render time.'),\n children: z\n .union([LayoutNodeSchema, z.array(LayoutNodeSchema)])\n .optional()\n .describe('Child layout content (a single node or an array of nodes).'),\n ref: z.string().optional().describe('A stable identifier used to target this component from event handlers.'),\n model: z.string().optional().describe('A two-way binding path, e.g. \"$.name\".'),\n events: z\n .record(z.string(), z.unknown())\n .optional()\n .describe('Map of event name to event configuration handled by the action runtime.'),\n })\n .strict()\n .describe('A node that instantiates a component from the registry.'),\n);\n\nexport type ConditionalNode = {\n if: unknown;\n then: LayoutNode;\n else?: LayoutNode;\n};\n\nexport const ConditionalNodeSchema: z.ZodType<ConditionalNode> = z.lazy(() =>\n z\n .object({\n if: ResolvableSchema.describe('Resolvable value evaluated for truthiness.'),\n then: LayoutNodeSchema.describe('Layout to render when condition is truthy.'),\n else: LayoutNodeSchema.optional().describe('Layout to render when condition is falsy.'),\n })\n .strict()\n .describe('A node that conditionally renders one of two branches.'),\n);\n\nexport type LoopNode = {\n for: unknown;\n as: string;\n key?: string;\n do: LayoutNode;\n};\n\nexport const LoopNodeSchema: z.ZodType<LoopNode> = z.lazy(() =>\n z\n .object({\n for: ResolvableSchema.describe('Resolvable value that resolves to an iterable array.'),\n as: z.string().describe('Name to bind each iterated item under in the inner scope.'),\n key: z.string().optional().describe('Optional key path on each item used for stable identity.'),\n do: LayoutNodeSchema.describe('Layout rendered once per iterated item.'),\n })\n .strict()\n .describe('A node that iterates an array binding and renders a layout for each item.'),\n);\n\nexport const LayoutRefNodeSchema = z\n .object({\n ref: z.string().describe('Identifier of a layout stored in the layout store to inline at this position.'),\n })\n .strict()\n .describe('A reference to a stored layout, inlined during render.');\n\nexport type LayoutRefNode = z.infer<typeof LayoutRefNodeSchema>;\n\nexport const SlotNodeSchema = z\n .object({\n slot: z\n .string()\n .describe(\n 'Name of a slot placeholder. When an ActionFragment is composed with an action ' +\n '(a push/replace `with`), the fragment\\'s `{ slot: \"body\" }` node is replaced by ' +\n 'the composing action\\'s own layout. An unfilled slot renders nothing.',\n ),\n })\n .strict()\n .describe(\n 'A placeholder that a fragment-merge fills with a composing action\\'s layout. ' +\n 'Only meaningful inside an ActionFragment\\'s layout.',\n );\n\nexport type SlotNode = z.infer<typeof SlotNodeSchema>;\n\nexport type LayoutNode =\n | ComponentNode\n | ConditionalNode\n | LoopNode\n | LayoutRefNode\n | SlotNode\n | LayoutNode[]\n | LayoutPrimitive;\n\nexport const LayoutNodeSchema: z.ZodType<LayoutNode> = z.lazy(() =>\n z\n .union([\n ComponentNodeSchema,\n ConditionalNodeSchema,\n LoopNodeSchema,\n LayoutRefNodeSchema,\n SlotNodeSchema,\n z.array(LayoutNodeSchema),\n LayoutPrimitiveSchema,\n ])\n .describe('Any layout node: component, conditional, loop, layout ref, slot, array of nodes, or a primitive text value.'),\n);\n"]}
|