@niscorp/nova 0.1.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/ACTION_DOCS.md +552 -0
- package/ADAPTER.md +170 -0
- package/DESIGN.md +719 -0
- package/I18N_DOCS.md +224 -0
- package/LAYOUT_DOCS.md +505 -0
- package/LICENSE +202 -0
- package/REACT_DOCS.md +562 -0
- package/README.md +379 -0
- package/SHELL_DOCS.md +615 -0
- package/TERMINAL_DOCS.md +124 -0
- package/dist/adapters/dom/components/index.cjs +473 -0
- package/dist/adapters/dom/components/index.cjs.map +1 -0
- package/dist/adapters/dom/components/index.d.cts +48 -0
- package/dist/adapters/dom/components/index.d.ts +48 -0
- package/dist/adapters/dom/components/index.js +420 -0
- package/dist/adapters/dom/components/index.js.map +1 -0
- package/dist/adapters/dom/index.cjs +171 -0
- package/dist/adapters/dom/index.cjs.map +1 -0
- package/dist/adapters/dom/index.d.cts +29 -0
- package/dist/adapters/dom/index.d.ts +29 -0
- package/dist/adapters/dom/index.js +15 -0
- package/dist/adapters/dom/index.js.map +1 -0
- package/dist/adapters/dom/server.cjs +129 -0
- package/dist/adapters/dom/server.cjs.map +1 -0
- package/dist/adapters/dom/server.d.cts +15 -0
- package/dist/adapters/dom/server.d.ts +15 -0
- package/dist/adapters/dom/server.js +37 -0
- package/dist/adapters/dom/server.js.map +1 -0
- package/dist/adapters/ink/index.d.ts +75 -0
- package/dist/adapters/ink/index.js +472 -0
- package/dist/adapters/ink/index.js.map +1 -0
- package/dist/adapters/react/components/index.cjs +552 -0
- package/dist/adapters/react/components/index.cjs.map +1 -0
- package/dist/adapters/react/components/index.d.cts +30 -0
- package/dist/adapters/react/components/index.d.ts +30 -0
- package/dist/adapters/react/components/index.js +12 -0
- package/dist/adapters/react/components/index.js.map +1 -0
- package/dist/adapters/react/index.cjs +1526 -0
- package/dist/adapters/react/index.cjs.map +1 -0
- package/dist/adapters/react/index.d.cts +149 -0
- package/dist/adapters/react/index.d.ts +149 -0
- package/dist/adapters/react/index.js +12 -0
- package/dist/adapters/react/index.js.map +1 -0
- package/dist/adapters/tty/components/index.cjs +255 -0
- package/dist/adapters/tty/components/index.cjs.map +1 -0
- package/dist/adapters/tty/components/index.d.cts +40 -0
- package/dist/adapters/tty/components/index.d.ts +40 -0
- package/dist/adapters/tty/components/index.js +187 -0
- package/dist/adapters/tty/components/index.js.map +1 -0
- package/dist/adapters/tty/index.cjs +76 -0
- package/dist/adapters/tty/index.cjs.map +1 -0
- package/dist/adapters/tty/index.d.cts +47 -0
- package/dist/adapters/tty/index.d.ts +47 -0
- package/dist/adapters/tty/index.js +76 -0
- package/dist/adapters/tty/index.js.map +1 -0
- package/dist/adapters/vue/components/index.cjs +619 -0
- package/dist/adapters/vue/components/index.cjs.map +1 -0
- package/dist/adapters/vue/components/index.d.cts +224 -0
- package/dist/adapters/vue/components/index.d.ts +224 -0
- package/dist/adapters/vue/components/index.js +12 -0
- package/dist/adapters/vue/components/index.js.map +1 -0
- package/dist/adapters/vue/index.cjs +747 -0
- package/dist/adapters/vue/index.cjs.map +1 -0
- package/dist/adapters/vue/index.d.cts +98 -0
- package/dist/adapters/vue/index.d.ts +98 -0
- package/dist/adapters/vue/index.js +127 -0
- package/dist/adapters/vue/index.js.map +1 -0
- package/dist/agent/index.cjs +178 -0
- package/dist/agent/index.cjs.map +1 -0
- package/dist/agent/index.d.cts +28 -0
- package/dist/agent/index.d.ts +28 -0
- package/dist/agent/index.js +30 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/chunk-2MNLEL45.js +47 -0
- package/dist/chunk-2MNLEL45.js.map +1 -0
- package/dist/chunk-3HGE3VWK.js +753 -0
- package/dist/chunk-3HGE3VWK.js.map +1 -0
- package/dist/chunk-4ZID7UX5.js +549 -0
- package/dist/chunk-4ZID7UX5.js.map +1 -0
- package/dist/chunk-7B3RDENH.js +1982 -0
- package/dist/chunk-7B3RDENH.js.map +1 -0
- package/dist/chunk-7S5BNPUS.js +54 -0
- package/dist/chunk-7S5BNPUS.js.map +1 -0
- package/dist/chunk-7TS3YVQR.js +114 -0
- package/dist/chunk-7TS3YVQR.js.map +1 -0
- package/dist/chunk-EG2RUXJN.js +266 -0
- package/dist/chunk-EG2RUXJN.js.map +1 -0
- package/dist/chunk-GVBBL36G.js +429 -0
- package/dist/chunk-GVBBL36G.js.map +1 -0
- package/dist/chunk-I5D2R5UA.js +753 -0
- package/dist/chunk-I5D2R5UA.js.map +1 -0
- package/dist/chunk-IGLCWXQ3.js +304 -0
- package/dist/chunk-IGLCWXQ3.js.map +1 -0
- package/dist/chunk-JI7ZRESP.js +64 -0
- package/dist/chunk-JI7ZRESP.js.map +1 -0
- package/dist/chunk-L5223LLX.js +31 -0
- package/dist/chunk-L5223LLX.js.map +1 -0
- package/dist/chunk-LA3BSEMX.js +1905 -0
- package/dist/chunk-LA3BSEMX.js.map +1 -0
- package/dist/chunk-OAMC6R6E.js +121 -0
- package/dist/chunk-OAMC6R6E.js.map +1 -0
- package/dist/chunk-OGD5CCMZ.js +62 -0
- package/dist/chunk-OGD5CCMZ.js.map +1 -0
- package/dist/chunk-PF4OJTYU.js +199 -0
- package/dist/chunk-PF4OJTYU.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +9 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/chunk-RBU5PHN4.js +8 -0
- package/dist/chunk-RBU5PHN4.js.map +1 -0
- package/dist/chunk-RQB4PRPV.js +285 -0
- package/dist/chunk-RQB4PRPV.js.map +1 -0
- package/dist/chunk-V32EVEVM.js +464 -0
- package/dist/chunk-V32EVEVM.js.map +1 -0
- package/dist/chunk-ZITHBBF3.js +85 -0
- package/dist/chunk-ZITHBBF3.js.map +1 -0
- package/dist/devtools/index.cjs +1088 -0
- package/dist/devtools/index.cjs.map +1 -0
- package/dist/devtools/index.d.cts +33 -0
- package/dist/devtools/index.d.ts +33 -0
- package/dist/devtools/index.js +399 -0
- package/dist/devtools/index.js.map +1 -0
- package/dist/effects-CndX9K7D.d.cts +123 -0
- package/dist/effects-CndX9K7D.d.ts +123 -0
- package/dist/endpoints-CD-6Jl-H.d.ts +36 -0
- package/dist/endpoints-Dem-EdRx.d.cts +36 -0
- package/dist/i18n/index.cjs +299 -0
- package/dist/i18n/index.cjs.map +1 -0
- package/dist/i18n/index.d.cts +28 -0
- package/dist/i18n/index.d.ts +28 -0
- package/dist/i18n/index.js +180 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/index-CNfzSBe2.d.ts +93 -0
- package/dist/index-caZoXSwr.d.cts +93 -0
- package/dist/index.cjs +3723 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +144 -0
- package/dist/index.d.ts +144 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/migrations/index.cjs +635 -0
- package/dist/migrations/index.cjs.map +1 -0
- package/dist/migrations/index.d.cts +97 -0
- package/dist/migrations/index.d.ts +97 -0
- package/dist/migrations/index.js +50 -0
- package/dist/migrations/index.js.map +1 -0
- package/dist/palette-CP0wd3bE.d.ts +15 -0
- package/dist/palette-lm0bU9i5.d.cts +15 -0
- package/dist/primitive-props-BH_EJWIe.d.cts +100 -0
- package/dist/primitive-props-BH_EJWIe.d.ts +100 -0
- package/dist/primitive-props-CGoJvmcH.d.cts +100 -0
- package/dist/primitive-props-CGoJvmcH.d.ts +100 -0
- package/dist/reflect/index.cjs +998 -0
- package/dist/reflect/index.cjs.map +1 -0
- package/dist/reflect/index.d.cts +125 -0
- package/dist/reflect/index.d.ts +125 -0
- package/dist/reflect/index.js +13 -0
- package/dist/reflect/index.js.map +1 -0
- package/dist/schemas-DPdeFlCT.d.cts +38 -0
- package/dist/schemas-DPdeFlCT.d.ts +38 -0
- package/dist/schemas-pMyyuXV7.d.cts +47 -0
- package/dist/schemas-pMyyuXV7.d.ts +47 -0
- package/dist/types-Boh9ckdG.d.ts +194 -0
- package/dist/types-Brc7v_pS.d.ts +198 -0
- package/dist/types-ByNSwtUV.d.cts +20 -0
- package/dist/types-DdltMfw7.d.ts +20 -0
- package/dist/types-De0KpxfI.d.cts +198 -0
- package/dist/types-DhHL0twe.d.ts +20 -0
- package/dist/types-Dv6JLmgo.d.cts +194 -0
- package/dist/types-Q80YtOQt.d.cts +20 -0
- package/package.json +237 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// src/layout/schemas.ts
|
|
4
|
+
z.object({
|
|
5
|
+
$if: z.unknown().describe("Condition \u2014 resolved recursively, then checked for truthiness."),
|
|
6
|
+
$then: z.unknown().describe("Value when condition is truthy \u2014 resolved recursively."),
|
|
7
|
+
$else: z.unknown().optional().describe("Value when condition is falsy \u2014 resolved recursively.")
|
|
8
|
+
}).strict().describe("Conditional value directive. Resolved at bind time.");
|
|
9
|
+
var ResolvableSchema = z.unknown().describe(
|
|
10
|
+
'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.'
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
// src/layout/schemas.ts
|
|
14
|
+
var LayoutPrimitiveSchema = z.union([z.string(), z.number(), z.boolean(), z.null()]).describe("A primitive layout value rendered as text.");
|
|
15
|
+
var ComponentNodeSchema = z.lazy(
|
|
16
|
+
() => z.object({
|
|
17
|
+
component: z.string().describe("The registry name of the component to render."),
|
|
18
|
+
props: z.record(z.string(), z.unknown()).optional().describe("Component props; values may be bindings to be resolved at render time."),
|
|
19
|
+
children: z.union([LayoutNodeSchema, z.array(LayoutNodeSchema)]).optional().describe("Child layout content (a single node or an array of nodes)."),
|
|
20
|
+
ref: z.string().optional().describe("A stable identifier used to target this component from event handlers."),
|
|
21
|
+
model: z.string().optional().describe('A two-way binding path, e.g. "$.name".'),
|
|
22
|
+
events: z.record(z.string(), z.unknown()).optional().describe("Map of event name to event configuration handled by the action runtime.")
|
|
23
|
+
}).strict().describe("A node that instantiates a component from the registry.")
|
|
24
|
+
);
|
|
25
|
+
var ConditionalNodeSchema = z.lazy(
|
|
26
|
+
() => z.object({
|
|
27
|
+
if: ResolvableSchema.describe("Resolvable value evaluated for truthiness."),
|
|
28
|
+
then: LayoutNodeSchema.describe("Layout to render when condition is truthy."),
|
|
29
|
+
else: LayoutNodeSchema.optional().describe("Layout to render when condition is falsy.")
|
|
30
|
+
}).strict().describe("A node that conditionally renders one of two branches.")
|
|
31
|
+
);
|
|
32
|
+
var LoopNodeSchema = z.lazy(
|
|
33
|
+
() => z.object({
|
|
34
|
+
for: ResolvableSchema.describe("Resolvable value that resolves to an iterable array."),
|
|
35
|
+
as: z.string().describe("Name to bind each iterated item under in the inner scope."),
|
|
36
|
+
key: z.string().optional().describe("Optional key path on each item used for stable identity."),
|
|
37
|
+
do: LayoutNodeSchema.describe("Layout rendered once per iterated item.")
|
|
38
|
+
}).strict().describe("A node that iterates an array binding and renders a layout for each item.")
|
|
39
|
+
);
|
|
40
|
+
var LayoutRefNodeSchema = z.object({
|
|
41
|
+
ref: z.string().describe("Identifier of a layout stored in the layout store to inline at this position.")
|
|
42
|
+
}).strict().describe("A reference to a stored layout, inlined during render.");
|
|
43
|
+
var SlotNodeSchema = z.object({
|
|
44
|
+
slot: z.string().describe(
|
|
45
|
+
"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."
|
|
46
|
+
)
|
|
47
|
+
}).strict().describe(
|
|
48
|
+
"A placeholder that a fragment-merge fills with a composing action's layout. Only meaningful inside an ActionFragment's layout."
|
|
49
|
+
);
|
|
50
|
+
var LayoutNodeSchema = z.lazy(
|
|
51
|
+
() => z.union([
|
|
52
|
+
ComponentNodeSchema,
|
|
53
|
+
ConditionalNodeSchema,
|
|
54
|
+
LoopNodeSchema,
|
|
55
|
+
LayoutRefNodeSchema,
|
|
56
|
+
SlotNodeSchema,
|
|
57
|
+
z.array(LayoutNodeSchema),
|
|
58
|
+
LayoutPrimitiveSchema
|
|
59
|
+
]).describe("Any layout node: component, conditional, loop, layout ref, slot, array of nodes, or a primitive text value.")
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
export { ComponentNodeSchema, ConditionalNodeSchema, LayoutNodeSchema, LayoutPrimitiveSchema, LayoutRefNodeSchema, LoopNodeSchema, SlotNodeSchema };
|
|
63
|
+
//# sourceMappingURL=chunk-JI7ZRESP.js.map
|
|
64
|
+
//# sourceMappingURL=chunk-JI7ZRESP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/shared/bindings/schemas.ts","../src/layout/schemas.ts"],"names":["z"],"mappings":";;;AAEiC,EAC9B,MAAA,CAAO;AAAA,EACN,GAAA,EAAK,CAAA,CAAE,OAAA,EAAQ,CAAE,SAAS,qEAAgE,CAAA;AAAA,EAC1F,KAAA,EAAO,CAAA,CAAE,OAAA,EAAQ,CAAE,SAAS,6DAAwD,CAAA;AAAA,EACpF,OAAO,CAAA,CACJ,OAAA,GACA,QAAA,EAAS,CACT,SAAS,4DAAuD;AACrE,CAAC,CAAA,CACA,MAAA,EAAO,CACP,QAAA,CAAS,qDAAqD;AAI1D,IAAM,gBAAA,GAAmB,CAAA,CAC7B,OAAA,EAAQ,CACR,QAAA;AAAA,EACC;AAMF,CAAA;;;AClBK,IAAM,wBAAwBA,CAAAA,CAClC,KAAA,CAAM,CAACA,CAAAA,CAAE,MAAA,IAAUA,CAAAA,CAAE,MAAA,IAAUA,CAAAA,CAAE,OAAA,IAAWA,CAAAA,CAAE,IAAA,EAAM,CAAC,CAAA,CACrD,SAAS,4CAA4C;AAajD,IAAM,sBAAgDA,CAAAA,CAAE,IAAA;AAAA,EAAK,MAClEA,EACG,MAAA,CAAO;AAAA,IACN,SAAA,EAAWA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A;AAAA,IACrF,EAAA,EAAIA,CAAAA,CAAE,MAAA,EAAO,CAAE,SAAS,2DAA2D,CAAA;AAAA,IACnF,KAAKA,CAAAA,CAAE,MAAA,GAAS,QAAA,EAAS,CAAE,SAAS,0DAA0D,CAAA;AAAA,IAC9F,EAAA,EAAI,gBAAA,CAAiB,QAAA,CAAS,yCAAyC;AAAA,GACxE,CAAA,CACA,MAAA,EAAO,CACP,SAAS,2EAA2E;AACzF;AAEO,IAAM,mBAAA,GAAsBA,EAChC,MAAA,CAAO;AAAA,EACN,GAAA,EAAKA,CAAAA,CAAE,MAAA,EAAO,CAAE,SAAS,+EAA+E;AAC1G,CAAC,CAAA,CACA,MAAA,EAAO,CACP,QAAA,CAAS,wDAAwD;AAI7D,IAAM,cAAA,GAAiBA,EAC3B,MAAA,CAAO;AAAA,EACN,IAAA,EAAMA,CAAAA,CACH,MAAA,EAAO,CACP,QAAA;AAAA,IACC;AAAA;AAIN,CAAC,CAAA,CACA,QAAO,CACP,QAAA;AAAA,EACC;AAEF;AAaK,IAAM,mBAA0CA,CAAAA,CAAE,IAAA;AAAA,EAAK,MAC5DA,EACG,KAAA,CAAM;AAAA,IACL,mBAAA;AAAA,IACA,qBAAA;AAAA,IACA,cAAA;AAAA,IACA,mBAAA;AAAA,IACA,cAAA;AAAA,IACAA,CAAAA,CAAE,MAAM,gBAAgB,CAAA;AAAA,IACxB;AAAA,GACD,CAAA,CACA,QAAA,CAAS,6GAA6G;AAC3H","file":"chunk-JI7ZRESP.js","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"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/agent/palette.ts
|
|
2
|
+
var stripProps = (schema, omit) => {
|
|
3
|
+
const s = schema;
|
|
4
|
+
if (s.properties === void 0) return schema;
|
|
5
|
+
const properties = { ...s.properties };
|
|
6
|
+
for (const p of omit) delete properties[p];
|
|
7
|
+
const required = s.required?.filter((r) => !omit.includes(r));
|
|
8
|
+
return { ...s, properties, ...required !== void 0 ? { required } : {} };
|
|
9
|
+
};
|
|
10
|
+
var paletteEntryOf = (name, meta, omitProps) => {
|
|
11
|
+
let propsSchema;
|
|
12
|
+
if (meta.propsSchema !== void 0) {
|
|
13
|
+
const js = meta.propsSchema["~standard"].jsonSchema.output({ target: "draft-07" });
|
|
14
|
+
propsSchema = omitProps !== void 0 && omitProps.length > 0 ? stripProps(js, omitProps) : js;
|
|
15
|
+
}
|
|
16
|
+
return { name, description: meta.description ?? "", ...propsSchema === void 0 ? {} : { propsSchema } };
|
|
17
|
+
};
|
|
18
|
+
var paletteFromRegistry = (registry, options = {}) => {
|
|
19
|
+
const names = options.include ?? registry.list();
|
|
20
|
+
const out = [];
|
|
21
|
+
for (const name of names) {
|
|
22
|
+
const entry = registry.get(name);
|
|
23
|
+
if (entry === void 0) continue;
|
|
24
|
+
out.push(paletteEntryOf(name, entry.meta, options.omitProps));
|
|
25
|
+
}
|
|
26
|
+
return out;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { paletteEntryOf, paletteFromRegistry };
|
|
30
|
+
//# sourceMappingURL=chunk-L5223LLX.js.map
|
|
31
|
+
//# sourceMappingURL=chunk-L5223LLX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/agent/palette.ts"],"names":[],"mappings":";AA0BA,IAAM,UAAA,GAAa,CAAC,MAAA,EAAgB,IAAA,KAAoC;AACtE,EAAA,MAAM,CAAA,GAAI,MAAA;AACV,EAAA,IAAI,CAAA,CAAE,UAAA,KAAe,MAAA,EAAW,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AA,CAAS,GAAA,CAAI,IAAI,CAAA;AAC/B,IAAA,IAAI,UAAU,MAAA,EAAW;AACzB,IAAA,GAAA,CAAI,KAAK,cAAA,CAAe,IAAA,EAAM,MAAM,IAAA,EAAM,OAAA,CAAQ,SAAS,CAAC,CAAA;AAAA,EAC9D;AACA,EAAA,OAAO,GAAA;AACT","file":"chunk-L5223LLX.js","sourcesContent":["import type { ComponentRegistry, ComponentMeta } from '../layout/types';\n\n// ───────────────────────────────────────────────────────────\n// Derive a layout-agent palette from a ComponentRegistry.\n//\n// Reads each component's `meta.description` + `meta.propsSchema` straight off the\n// registry and hands the agent a JSON Schema derived from the same Zod schema the\n// renderer validates against — no drift. Component authors put what the agent\n// needs on the source schema via `.describe()`; fixes go there, not here.\n// ───────────────────────────────────────────────────────────\n\nexport type LayoutPaletteEntry = { name: string; description: string; propsSchema?: object };\n\nexport type PaletteFromRegistryOptions = {\n // Optional allowlist of component names. When omitted, every registered\n // component appears — pass a curated subset to keep the agent's vocabulary\n // tight (e.g. exclude shell slots / nav chrome).\n include?: readonly string[];\n // Prop names to strip from every component's schema. Use it to hide props the\n // agent must not set — e.g. presentational knobs (`bg`, `class`, `pad`) — so the\n // components can only render in their default style.\n omitProps?: readonly string[];\n};\n\n// Drop `omit` keys from a JSON Schema's `properties` (and `required`), so the\n// agent never sees them.\nconst stripProps = (schema: object, omit: readonly string[]): object => {\n const s = schema as { properties?: Record<string, unknown>; required?: string[] };\n if (s.properties === undefined) return schema;\n const properties = { ...s.properties };\n for (const p of omit) delete properties[p];\n const required = s.required?.filter((r) => !omit.includes(r));\n return { ...s, properties, ...(required !== undefined ? { required } : {}) };\n};\n\n// ONE PALETTE ENTRY, from a component's meta — the conversion at the heart of a\n// palette, factored out so a second caller derives an author's props from the\n// SAME Zod schema and the SAME JSON-Schema target, never a fork that drifts.\n// moss's integration contract calls this to answer \"what may I build against\"\n// for a person, which is the same question the layout agent asks of the palette;\n// `omitProps` and binding-awareness stay the caller's concern. A component with\n// no schema yields name + description alone, exactly as a bare registration does.\nexport const paletteEntryOf = (name: string, meta: ComponentMeta, omitProps?: readonly string[]): LayoutPaletteEntry => {\n let propsSchema: object | undefined;\n if (meta.propsSchema !== undefined) {\n // The app's schema converts itself (Standard JSON Schema): it may come from\n // the app's zod copy, and ours would read that copy's metadata through our registry.\n const js = meta.propsSchema['~standard'].jsonSchema.output({ target: 'draft-07' });\n propsSchema = omitProps !== undefined && omitProps.length > 0 ? stripProps(js, omitProps) : js;\n }\n return { name, description: meta.description ?? '', ...(propsSchema === undefined ? {} : { propsSchema }) };\n};\n\nexport const paletteFromRegistry = (\n registry: ComponentRegistry,\n options: PaletteFromRegistryOptions = {},\n): LayoutPaletteEntry[] => {\n const names = options.include ?? registry.list();\n const out: LayoutPaletteEntry[] = [];\n for (const name of names) {\n const entry = registry.get(name);\n if (entry === undefined) continue;\n out.push(paletteEntryOf(name, entry.meta, options.omitProps));\n }\n return out;\n};\n"]}
|