@niscorp/loom 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/DESIGN.md +253 -0
- package/LICENSE +202 -0
- package/README.md +101 -0
- package/dist/chunk-A3UOFGL4.js +29 -0
- package/dist/chunk-A3UOFGL4.js.map +1 -0
- package/dist/chunk-D743DI5J.js +17 -0
- package/dist/chunk-D743DI5J.js.map +1 -0
- package/dist/chunk-DWQWPBBV.js +63 -0
- package/dist/chunk-DWQWPBBV.js.map +1 -0
- package/dist/chunk-LWY5TG7M.js +208 -0
- package/dist/chunk-LWY5TG7M.js.map +1 -0
- package/dist/chunk-MIRMQPUE.js +132 -0
- package/dist/chunk-MIRMQPUE.js.map +1 -0
- package/dist/chunk-PTXRAWJX.js +58 -0
- package/dist/chunk-PTXRAWJX.js.map +1 -0
- package/dist/chunk-TV4U22MY.js +176 -0
- package/dist/chunk-TV4U22MY.js.map +1 -0
- package/dist/chunk-X7PCPONB.js +380 -0
- package/dist/chunk-X7PCPONB.js.map +1 -0
- package/dist/chunk-XTY7XO5C.js +61 -0
- package/dist/chunk-XTY7XO5C.js.map +1 -0
- package/dist/index.cjs +630 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +40 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/loom-editor-CQ_GI4IA.d.cts +27 -0
- package/dist/loom-editor-D5SBQ4_F.d.ts +27 -0
- package/dist/plugins/nova/index.cjs +81 -0
- package/dist/plugins/nova/index.cjs.map +1 -0
- package/dist/plugins/nova/index.d.cts +14 -0
- package/dist/plugins/nova/index.d.ts +14 -0
- package/dist/plugins/nova/index.js +5 -0
- package/dist/plugins/nova/index.js.map +1 -0
- package/dist/plugins/nova/react/index.cjs +107 -0
- package/dist/plugins/nova/react/index.cjs.map +1 -0
- package/dist/plugins/nova/react/index.d.cts +17 -0
- package/dist/plugins/nova/react/index.d.ts +17 -0
- package/dist/plugins/nova/react/index.js +36 -0
- package/dist/plugins/nova/react/index.js.map +1 -0
- package/dist/plugins/prism/index.cjs +48 -0
- package/dist/plugins/prism/index.cjs.map +1 -0
- package/dist/plugins/prism/index.d.cts +18 -0
- package/dist/plugins/prism/index.d.ts +18 -0
- package/dist/plugins/prism/index.js +4 -0
- package/dist/plugins/prism/index.js.map +1 -0
- package/dist/plugins/prism/react/index.cjs +744 -0
- package/dist/plugins/prism/react/index.cjs.map +1 -0
- package/dist/plugins/prism/react/index.d.cts +12 -0
- package/dist/plugins/prism/react/index.d.ts +12 -0
- package/dist/plugins/prism/react/index.js +419 -0
- package/dist/plugins/prism/react/index.js.map +1 -0
- package/dist/plugins/vex/index.cjs +67 -0
- package/dist/plugins/vex/index.cjs.map +1 -0
- package/dist/plugins/vex/index.d.cts +25 -0
- package/dist/plugins/vex/index.d.ts +25 -0
- package/dist/plugins/vex/index.js +4 -0
- package/dist/plugins/vex/index.js.map +1 -0
- package/dist/plugins/vex/react/index.cjs +432 -0
- package/dist/plugins/vex/react/index.cjs.map +1 -0
- package/dist/plugins/vex/react/index.d.cts +13 -0
- package/dist/plugins/vex/react/index.d.ts +13 -0
- package/dist/plugins/vex/react/index.js +296 -0
- package/dist/plugins/vex/react/index.js.map +1 -0
- package/dist/react/index.cjs +1076 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +82 -0
- package/dist/react/index.d.ts +82 -0
- package/dist/react/index.js +120 -0
- package/dist/react/index.js.map +1 -0
- package/dist/schema--OhtatTX.d.cts +10 -0
- package/dist/schema--OhtatTX.d.ts +10 -0
- package/dist/types-BonjN3CB.d.cts +144 -0
- package/dist/types-BonjN3CB.d.ts +144 -0
- package/package.json +144 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/compile/to-nova.ts","../src/validate.ts","../src/editor/editor.ts"],"names":["stripErrors"],"mappings":";;;;;;AAqBO,IAAM,eAAA,GAAkB;AAK/B,IAAM,I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AAEA,EAAA,MAAM,MAAA,GAAqB;AAAA,IACzB,IAAI,KAAA,GAAQ;AACV,MAAA,OAAO,KAAA;AAAA,IACT,CAAA;AAAA,IACA,IAAI,MAAA,GAAS;AACX,MAAA,OAAO,MAAA;AAAA,IACT,CAAA;AAAA,IACA,IAAI,SAAA,GAAY;AACd,MAAA,OAAO,SAAA;AAAA,IACT,CAAA;AAAA,IACA,IAAI,WAAA,GAAc;AAChB,MAAA,OAAO,WAAA;AAAA,IACT,CAAA;AAAA,IACA,UAAA,EAAY,CAAC,MAAA,KAAW;AACtB,MAAA,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAO,IAAA,EAAM,MAAM,CAAA;AAC/B,MAAA,MAAA,CAAO,QAAQ,MAAM,CAAA;AAAA,IACvB,CAAA;AAAA,IACA,IAAA;AAAA,IACA,EAAA,EAAI,CAAC,KAAA,EAAO,OAAA,KAAY;AACtB,MAAA,SAAA,CAAU,KAAK,CAAA,CAAE,GAAA,CAAI,OAAO,CAAA;AAC5B,MAAA,OAAO,MAAM,SAAA,CAAU,KAAK,CAAA,CAAE,OAAO,OAAO,CAAA;AAAA,IAC9C,CAAA;AAAA,IACA,SAAS,MAAM;AACb,MAAA,MAAA,CAAO,OAAA,CAAQ,CAAC,GAAA,KAAQ,GAAA,EAAK,CAAA;AAC7B,MAAA,MAAA,GAAS,EAAC;AACV,MAAA,KAAA,CAAM,OAAA,EAAQ;AAAA,IAChB;AAAA,GACF;AAEA,EAAA,OAAO,MAAA;AACT","file":"chunk-X7PCPONB.js","sourcesContent":["import type { ActionDefinition, ComponentNode, LayoutNode } from '@niscorp/nova';\nimport { buildDocument, isRecord, variantDefaults } from './parse.js';\nimport { Roles, type Role } from './roles.js';\nimport type { CompileOptions, Field, ObjectField, Pattern, Variant } from './types.js';\n\n// toNova — turn Loom's field model into a Nova editor: a layout + the document\n// it edits (+ any named templates a recursive schema needs). This is the\n// rendering half, and the only half that speaks Nova. The model (`parse`) knows\n// nothing about it. Every edit — including add / remove / reorder — is a model\n// write through Nova's `ui:model` pipeline; no action triggers are emitted.\n//\n// Field (IR) ──toNova──▶ { action, layouts }\n//\n// Fields bind to the document by a *binding expression* threaded through the\n// build: `$.name` at the root, `$item` inside an array loop. A recursive object\n// is emitted once as a named layout authored against `$item`; its `self`\n// reference points back to that layout, and Nova resolves it per render against\n// the live data — so the editor goes exactly as deep as the document does.\n\n// The reserved data namespace the editor writes validation errors into and each\n// field binds its error slot to. Excluded from the reported document.\nexport const ERROR_NAMESPACE = '_errors';\n\n// The loop variable an array binds each element under, plus the two other loop\n// bindings Nova exposes per iteration: the element's index, and `$items` — the\n// whole array — which the row controls write back to (remove / reorder).\nconst ITEM = 'item';\nconst INDEX = '$index';\nconst ITEM_EXPR = `$${ITEM}`;\nconst LIST_EXPR = '$items';\n\n// What Loom hands Nova: the action plus the named layouts it references. The\n// layouts are the recursive templates; for a non-recursive schema it's empty.\nexport type NovaEditor = { action: ActionDefinition; layouts: Record<string, LayoutNode> };\n\n// A container variant of a recursive union: one whose value can hold a list of\n// the same recursive type. `key` is the field that holds that list. Used to\n// wrap an element into one, and to recognize / unwrap an element that is one.\n// Purely structural — nothing here knows what the schema represents.\ntype Container = { label: string; pattern: Pattern; defaults: unknown; key: string };\n\n// A recursive template in scope while its object is built: the layout name a\n// `self` points back to, the default node an \"add\" appends, and (for a union)\n// the container variants its items can be wrapped into.\ntype Template = { name: string; defaultChild: unknown; containers: Container[] };\n\ntype BuildContext = {\n /** Register a named layout (a recursive object's reusable template). */\n register: (name: string, node: LayoutNode) => void;\n /** The recursive templates currently being built; `self` refs the innermost. */\n templates: Template[];\n /** A fresh, stable layout name for a recursion template. */\n name: () => string;\n /** The custom-widget role for a field at a path, if a plugin matcher claims it. */\n widgetRole: (field: Field, path: string) => string | undefined;\n options: CompileOptions;\n};\n\ntype Build<K extends Field['kind']> = (\n field: Extract<Field, { kind: K }>,\n loc: Loc,\n ctx: BuildContext,\n) => LayoutNode;\n\n// ─── Location: binding expression + structural path ──────────\n\n// Where a field sits: the binding expression Nova resolves at render (`$.from`,\n// `$item.eq`), and the structural path a widget matcher targets (`from`,\n// `fields.*`, `…eq`). They diverge inside a loop — the expression rebinds to\n// `$item`, losing the array key, but the path keeps it (`fields.*`), which is\n// exactly what tells the two list-item kinds apart.\ntype Loc = { expr: string; path: string };\n\nconst ROOT: Loc = { expr: '$', path: '' };\n\n// Extend to a child key: `$.a` + `b` → `$.a.b`; path `a` + `b` → `a.b`.\nconst child = (loc: Loc, key: string): Loc => ({\n expr: `${loc.expr}.${key}`,\n path: loc.path === '' ? key : `${loc.path}.${key}`,\n});\n\n// An array element: the loop rebinds the expression to `$item`; the path gains a\n// `*` segment (the index, resolved at render, is irrelevant to matching).\nconst itemLoc = (loc: Loc): Loc => ({ expr: ITEM_EXPR, path: loc.path === '' ? '*' : `${loc.path}.*` });\n\n// A recursive template is authored against `$item` and rooted afresh, so its\n// inner paths are scope-relative — a matcher's suffix (`endsWith('.eq')`) still\n// hits at any depth.\nconst TEMPLATE_ROOT: Loc = { expr: ITEM_EXPR, path: '' };\n\n// The error binding for a field, derived from its expression. Only absolute\n// (`$.`) expressions map to the error channel; loop-relative item paths\n// (`$item…`) carry an index resolved at render and are left for later.\nconst errorBinding = (expr: string): string | undefined =>\n expr.startsWith('$.') ? `$.${ERROR_NAMESPACE}.${expr.slice(2)}` : undefined;\n\n// ─── Node helpers ────────────────────────────────────────────\n\n// Attach `props` only when there is something to attach — keeps emitted layouts\n// free of empty `props: {}` noise.\nconst withProps = (node: ComponentNode, props: Record<string, unknown>): ComponentNode =>\n Object.keys(props).length > 0 ? { ...node, props } : node;\n\n// A leaf control bound to its expression. No explicit ref: the renderer derives\n// one from the resolved path, which is distinct per array element.\nconst control = (role: Role | string, expr: string, props: Record<string, unknown> = {}): ComponentNode =>\n withProps({ component: role, model: expr }, props);\n\n// Static JSON metadata a component reads (a variant's branches, a list's\n// containers, an \"add\" default) — not a binding. Nova resolves *every* prop as a\n// binding expression, so a value carrying `$`-prefixed data (a Prism op key, a\n// `$ref`) would be mangled, and a `$eq`/`$if`/`$exists` key would be evaluated as\n// a directive. Encoding it as a JSON string passes it through the resolver\n// untouched; the component decodes it (`decodeLiteral` in the kit).\nconst literal = (data: unknown): string | undefined => (data === undefined ? undefined : JSON.stringify(data));\n\n// An object property: a field wrapper (label / required / error chrome) around\n// the property's own layout. `loc` already points at the property.\nconst wrapField = (loc: Loc, prop: ObjectField, ctx: BuildContext): ComponentNode => {\n const error = errorBinding(loc.expr);\n return {\n component: Roles.field,\n props: {\n label: prop.field.title ?? prop.key,\n required: prop.required,\n ...(error !== undefined ? { error } : {}),\n ...(prop.field.description !== undefined ? { description: prop.field.description } : {}),\n },\n children: buildLayout(prop.field, loc, ctx),\n };\n};\n\n// A field's optional `title`, as props — shared by the title chrome of groups,\n// arrays, and the variant chooser.\nconst titleProps = (field: { title?: string }): Record<string, unknown> =>\n field.title !== undefined ? { title: field.title } : {};\n\nconst withTitle = (node: ComponentNode, field: { title?: string }): ComponentNode =>\n withProps(node, titleProps(field));\n\n// ─── Builds: IR → layout ─────────────────────────────────────\n\nconst stringBuild: Build<'string'> = (field, loc) =>\n control(Roles.text, loc.expr, field.format !== undefined ? { format: field.format } : {});\n\nconst numberBuild: Build<'number'> = (field, loc) =>\n control(Roles.number, loc.expr, field.integer ? { integer: true } : {});\n\nconst booleanBuild: Build<'boolean'> = (_field, loc) => control(Roles.checkbox, loc.expr);\n\nconst enumBuild: Build<'enum'> = (field, loc) => control(Roles.select, loc.expr, { options: field.options });\n\nconst unknownBuild: Build<'unknown'> = (_field, loc) => control(Roles.raw, loc.expr);\n\n// The group of wrapped fields an object renders as — shared by the inline\n// occurrence and the recursive template (same shape, different base loc).\nconst buildGroup = (field: Extract<Field, { kind: 'object' }>, loc: Loc, ctx: BuildContext): ComponentNode =>\n withTitle(\n {\n component: Roles.group,\n children: field.fields.map((prop) => wrapField(child(loc, prop.key), prop, ctx)),\n },\n field,\n );\n\nconst objectBuild: Build<'object'> = (field, loc, ctx) => {\n if (field.recursive !== true) return buildGroup(field, loc, ctx);\n // A recursive object: emit its group once as a named template authored\n // against the template root (so it binds correctly at any depth), keep it in\n // scope so the `self` inside refs it and an \"add\" knows the default node, then\n // render the object inline at its real loc. Both builds bottom out at `self`.\n const name = ctx.name();\n ctx.templates.push({ name, defaultChild: buildDocument(field, ctx.options), containers: [] });\n ctx.register(name, buildGroup(field, TEMPLATE_ROOT, ctx));\n const inline = buildGroup(field, loc, ctx);\n ctx.templates.pop();\n return inline;\n};\n\n// A tuple: one wrapped field per slot, bound to its numeric index (`$.x.0`).\n// Fixed-length, so no add / remove — the difference from an array.\nconst tupleBuild: Build<'tuple'> = (field, loc, ctx) =>\n withTitle(\n {\n component: Roles.group,\n children: field.items.map((item, index) =>\n wrapField(child(loc, String(index)), { key: String(index + 1), required: true, field: item }, ctx),\n ),\n },\n field,\n );\n\nconst selfBuild: Build<'self'> = (_field, loc, ctx) => {\n const template = ctx.templates[ctx.templates.length - 1];\n // Reached as an array item (the loop rebinds `$item` to the element), a\n // `self` becomes a reference to the enclosing template — Nova re-resolves it\n // per render against the live data, so depth follows the document. A `self`\n // anywhere else is a direct self-reference (a linked list); it has no loop to\n // rebind its scope, so it shows raw until that case lands.\n if (template !== undefined && loc.expr === ITEM_EXPR) return { ref: template.name };\n return control(Roles.raw, loc.expr);\n};\n\n// The default element an \"add\" appends: for a recursive list, the enclosing\n// template's default node; otherwise the item field's own default.\nconst defaultItem = (field: Extract<Field, { kind: 'array' }>, ctx: BuildContext): unknown =>\n field.item.kind === 'self'\n ? ctx.templates[ctx.templates.length - 1]?.defaultChild\n : buildDocument(field.item, ctx.options);\n\n// The key of a field's child-list, if it has one: an object property that is an\n// array of `self` (the same recursive type). This is the whole definition of a\n// \"container\" — structural, with no knowledge of the domain.\nconst childrenKey = (field: Field): string | undefined => {\n if (field.kind !== 'object') return undefined;\n return field.fields.find((f) => f.field.kind === 'array' && f.field.item.kind === 'self')?.key;\n};\n\n// A union's container variants: the ones whose branch holds a child-list.\nconst containersOf = (variants: Variant[]): Container[] =>\n variants.flatMap((variant) => {\n const key = childrenKey(variant.field);\n return key === undefined ? [] : [{ label: variant.label, pattern: variant.pattern, defaults: variantDefaults(variant), key }];\n });\n\n// A list editor: every element rendered (the recursive item is a `self` ref;\n// any other is its own editor), each in a row with an actions menu (✕ / ↑ / ↓,\n// and wrap / unwrap when the items are a recursive union with container\n// variants), plus an \"add\". The menu binds the loop's `$items` (the whole list)\n// and acts on its own `$index`; the add binds the list itself and appends a\n// default. Everything is a `ui:model` write — path resolution handles the\n// nesting, so a list edits at any depth with no static target and no triggers.\nconst arrayBuild: Build<'array'> = (field, loc, ctx) => {\n // Containers come from the recursive union the items belong to (when the item\n // is `self`); a plain list has none, so its menu is just move / remove.\n const containers = field.item.kind === 'self' ? ctx.templates[ctx.templates.length - 1]?.containers ?? [] : [];\n const itemRow: LayoutNode = {\n component: Roles.arrayItem,\n children: [\n { component: Roles.box, children: buildLayout(field.item, itemLoc(loc), ctx) }, // the editor cell — grows\n {\n component: Roles.rowMenu,\n model: LIST_EXPR,\n props: { index: INDEX, ...(containers.length > 0 ? { containers: literal(containers) } : {}) },\n },\n ],\n };\n return withTitle(\n {\n component: Roles.array,\n children: [\n { for: loc.expr, as: ITEM, do: itemRow },\n { component: Roles.append, model: loc.expr, props: { label: 'Add', child: literal(defaultItem(field, ctx)) } },\n ],\n },\n field,\n );\n};\n\n// A union is the variant widget bound to the value: it holds each branch's\n// pattern + label + default, and renders the branch editors as its children.\n// The widget reads the value, matches it to a branch (in JS), and shows that\n// child; on change it writes the chosen branch's default. No discrimination is\n// compiled into the layout — Nova never learns what a union is.\nconst buildVariant = (field: Extract<Field, { kind: 'union' }>, loc: Loc, ctx: BuildContext): ComponentNode =>\n withProps(\n {\n component: Roles.variant,\n model: loc.expr,\n // Each branch editor in its own `branch` wrapper, indexed; the widget shows\n // only the one whose index it matched. (Nova hands a component its children\n // as one tree, so the branches need to be individually addressable.) A\n // branch edits the same value, so it shares the union's loc.\n children: field.variants.map((variant: Variant, index) => ({\n component: Roles.branch,\n props: { index },\n children: buildLayout(variant.field, loc, ctx),\n })),\n },\n {\n // `childrenKey` lets the chooser carry children when switching between two\n // container variants (and warn before dropping them otherwise). Encoded as\n // a literal: the patterns and defaults carry `$`-bearing data Nova must not\n // resolve.\n branches: literal(\n field.variants.map((variant: Variant) => ({\n label: variant.label,\n pattern: variant.pattern,\n defaults: variantDefaults(variant),\n ...(childrenKey(variant.field) !== undefined ? { childrenKey: childrenKey(variant.field) } : {}),\n })),\n ),\n ...titleProps(field),\n },\n );\n\nconst variantBuild: Build<'union'> = (field, loc, ctx) => {\n if (field.recursive !== true) return buildVariant(field, loc, ctx);\n // A recursive union (a tree of typed nodes): emit the chooser once as a named\n // template authored against the template root, keep it in scope so the `self`\n // inside a branch's children refs it, then render the node inline. Same\n // machinery as a recursive object — the template is just a variant, not a group.\n const name = ctx.name();\n const first = field.variants[0];\n ctx.templates.push({ name, defaultChild: first !== undefined ? variantDefaults(first) : {}, containers: containersOf(field.variants) });\n ctx.register(name, buildVariant(field, TEMPLATE_ROOT, ctx));\n const inline = buildVariant(field, loc, ctx);\n ctx.templates.pop();\n return inline;\n};\n\n// Dispatch a field to its build. The switch narrows `field` per case, so each\n// build receives its own field type with no assertion; the union is closed, so\n// it is also exhaustive (a new kind won't compile until it is handled here).\nconst buildLayout = (field: Field, loc: Loc, ctx: BuildContext): LayoutNode => {\n // A plugin widget claims this field by where it sits (its structural path) —\n // render with the registered component instead of the type default. It binds\n // the value and a model like any control, so it can be a leaf editor or\n // replace a whole subtree.\n const role = ctx.widgetRole(field, loc.path);\n if (role !== undefined) return control(role, loc.expr);\n switch (field.kind) {\n case 'string':\n return stringBuild(field, loc, ctx);\n case 'number':\n return numberBuild(field, loc, ctx);\n case 'boolean':\n return booleanBuild(field, loc, ctx);\n case 'enum':\n return enumBuild(field, loc, ctx);\n case 'object':\n return objectBuild(field, loc, ctx);\n case 'array':\n return arrayBuild(field, loc, ctx);\n case 'tuple':\n return tupleBuild(field, loc, ctx);\n case 'union':\n return variantBuild(field, loc, ctx);\n case 'self':\n return selfBuild(field, loc, ctx);\n case 'unknown':\n return unknownBuild(field, loc, ctx);\n }\n};\n\n// ─── Public entry ────────────────────────────────────────────\n\nexport const toNova = (ir: Field, options: CompileOptions = {}): NovaEditor => {\n const layouts: Record<string, LayoutNode> = {};\n let counter = 0;\n const matchers = options.widgets ?? [];\n const ctx: BuildContext = {\n register: (name, node) => {\n layouts[name] = node;\n },\n templates: [],\n name: () => `loom:tree:${counter++}`,\n // Match on where the field sits (its structural path) plus its facts.\n widgetRole: (field, path) =>\n matchers.find((matcher) =>\n matcher.match({ kind: field.kind, path, title: field.title, description: field.description }),\n )?.role,\n options,\n };\n\n // A non-object root (a union, scalar, or array) is a single control that can't\n // bind the bare document root, so `rootKey` binds it one level in (`$.<key>`)\n // and the document wraps the value under that key. An object root binds `$` and\n // its leaves bind `$.<field>` as usual.\n const rootLoc: Loc = options.rootKey !== undefined ? { expr: `$.${options.rootKey}`, path: '' } : ROOT;\n const layout = buildLayout(ir, rootLoc, ctx);\n const value = options.value ?? buildDocument(ir, options);\n const document = options.rootKey !== undefined ? { [options.rootKey]: value } : value;\n // The action's data must be a record. An object root builds one directly; a\n // wrapped root is a record by construction. A bare scalar root with no key has\n // no record document.\n if (!isRecord(document)) {\n throw new Error('loom.toNova: the root document must be an object (or use rootKey).');\n }\n const action: ActionDefinition = {\n id: options.id ?? 'loom-form',\n data: document,\n layout,\n };\n return { action, layouts };\n};\n","import type { Shell } from '@niscorp/nova';\nimport type { ZodType } from 'zod';\nimport { ERROR_NAMESPACE } from './compile/to-nova.js';\n\n// Validate-on-edit. The Zod schema is the truth: on each change, the working\n// document (everything except the reserved error channel) is parsed, and a\n// nested error tree — mirroring the document, keyed by Zod's issue paths —\n// is written back under that channel for the fields to bind to. The document\n// itself stays clean; `onDocument` reports it without the error channel.\n\ntype Doc = Record<string, unknown>;\n\ntype Issue = { readonly path: ReadonlyArray<PropertyKey>; readonly message: string };\n\n// Place a message at a nested path, mirroring the document shape. First issue\n// per path wins (the most specific message Zod emits first).\nconst setPath = (root: Doc, path: ReadonlyArray<PropertyKey>, message: string): void => {\n let node = root;\n for (let i = 0; i < path.length - 1; i += 1) {\n const key = String(path[i]);\n const next = node[key];\n node = typeof next === 'object' && next !== null ? (next as Doc) : (node[key] = {});\n }\n const leaf = String(path[path.length - 1]);\n if (!(leaf in node)) node[leaf] = message;\n};\n\nconst errorTree = (issues: ReadonlyArray<Issue>): Doc => {\n const tree: Doc = {};\n for (const issue of issues) {\n if (issue.path.length > 0) setPath(tree, issue.path, issue.message);\n }\n return tree;\n};\n\nconst stripErrors = (data: Doc): Doc => {\n const { [ERROR_NAMESPACE]: _omit, ...document } = data;\n return document;\n};\n\nexport const attachValidation = (\n shell: Shell,\n instanceId: string,\n schema: ZodType,\n onDocument?: (document: Doc) => void,\n): (() => void) => {\n const runtime = shell.getRuntime(instanceId);\n if (runtime === undefined) return () => {};\n\n let lastDocument = '';\n const handle = (data: Doc): void => {\n const document = stripErrors(data);\n const fingerprint = JSON.stringify(document);\n if (fingerprint === lastDocument) return; // our own error write — not a real edit\n lastDocument = fingerprint;\n\n const result = schema.safeParse(document);\n const errors = result.success ? {} : errorTree(result.error.issues);\n runtime.setData({ ...document, [ERROR_NAMESPACE]: errors });\n onDocument?.(document);\n };\n\n return shell.onDataChange((change) => {\n if (change.instanceId === instanceId) handle(change.data);\n });\n};\n","import { z, type ZodType } from 'zod';\nimport { createLayoutStore, createShell, type ActionDefinition, type Shell } from '@niscorp/nova';\nimport { parse, buildDocument, isRecord } from '@compile/parse';\nimport { toNova, ERROR_NAMESPACE } from '@compile/to-nova';\nimport { attachValidation } from '../validate.js';\nimport { defaultCanvasLayout } from './default.layout.js';\nimport type { LoomArtifact, LoomEditor, LoomEditorConfig, LoomEvent, LoomPlugin } from './types.js';\n\nexport type { LoomArtifact, LoomEditor, LoomEditorConfig, LoomEvent, LoomPlugin, Document, DocumentLayout, WidgetBinding } from './types.js';\nexport { mountView } from './view.js';\n\n// The Loom Editor controller — framework-free. It owns one Nova shell, built\n// empty, and a plugin loader. Everything visible is plugin-contributed: domain\n// plugins (nova, vex) declare the documents that `open` compiles into form\n// canvases; default plugins (jsonviewer, validation) and previews mount their own\n// view canvases against the live shell. The controller only compiles forms and\n// publishes the live `documents` / `validations`; the React (or Vue) layer\n// supplies the component registry and renders the shell.\n\n// The canvas a document's form lives on.\nconst formCanvas = (document: string): string => `form:${document}`;\n\n// The key a non-object document (a union, scalar, or array) is wrapped under so\n// its single control has a bindable path. Internal: the editor wraps the value\n// before compiling and unwraps it before publishing, so it never reaches a\n// plugin or the reported document. A document key collides with nothing — it\n// holds the whole value, no sibling.\nconst ROOT_KEY = '$root';\n\n// A document whose schema's root is not an object needs wrapping; an object root\n// binds the document root directly.\nconst needsWrap = (document: ZodType): boolean => parse(document).kind !== 'object';\n\nconst stripErrors = (data: Record<string, unknown>): Record<string, unknown> => {\n const { [ERROR_NAMESPACE]: _omit, ...document } = data;\n return document;\n};\n\nexport const createLoomEditor = (config: LoomEditorConfig): LoomEditor => {\n const plugins = new Map<string, LoomPlugin>();\n const listeners: Record<LoomEvent, Set<() => void>> = { change: new Set(), open: new Set() };\n const emit = (event: LoomEvent): void => listeners[event].forEach((handler) => handler());\n\n // The shell exists from creation (empty), so plugins can mount onto it. With no\n // canvasLayout, Nova renders the canvases in creation order; a plugin can call\n // shell.setCanvasLayout to arrange them. Form recursion templates are written\n // into this shared store as documents compile.\n const store = createLayoutStore();\n const shell: Shell = createShell({\n canvases: [],\n registry: config.registry,\n actions: {},\n layoutStore: store,\n });\n\n let active: LoomPlugin | undefined;\n let formInstances: Record<string, string> = {};\n // Documents whose root was wrapped under ROOT_KEY (non-object roots): their\n // value is unwrapped before it is published or validated against the schema.\n let wrappedDocs = new Set<string>();\n let formCanvasIds: string[] = [];\n let documents: Record<string, unknown> = {};\n let validations: Record<string, unknown> = {};\n let detach: Array<() => void> = [];\n\n // Read every form's live value into `documents` / `validations`. View plugins\n // self-sync off the `change` event, so nothing is pushed to them here.\n const refresh = (): void => {\n const nextDocs: Record<string, unknown> = {};\n const nextProblems: Record<string, unknown> = {};\n for (const [name, instanceId] of Object.entries(formInstances)) {\n const data = shell.getRuntime(instanceId)?.getData() ?? {};\n const document = stripErrors(data);\n const problems = (data[ERROR_NAMESPACE] ?? {}) as Record<string, unknown>;\n // A wrapped document is published as its bare value (and its errors as that\n // value's subtree), so ROOT_KEY never surfaces to a view or a consumer.\n if (wrappedDocs.has(name)) {\n nextDocs[name] = document[ROOT_KEY];\n nextProblems[name] = problems[ROOT_KEY] ?? {};\n } else {\n nextDocs[name] = document;\n nextProblems[name] = problems;\n }\n }\n documents = nextDocs;\n validations = nextProblems;\n };\n\n // Drop the previous artifact's form canvases (the plugin canvases stay).\n const clearForms = (): void => {\n detach.forEach((off) => off());\n detach = [];\n for (const canvasId of formCanvasIds) shell.removeCanvas(canvasId);\n formCanvasIds = [];\n formInstances = {};\n wrappedDocs = new Set();\n };\n\n const open = (artifact: LoomArtifact): void => {\n const plugin = plugins.get(artifact.type);\n if (plugin === undefined) throw new Error(`loom editor: no plugin '${artifact.type}'`);\n clearForms();\n active = plugin;\n\n // Build each document's form action and add its canvas. A schema document is\n // compiled (toNova); a layout document (freeform, no schema) takes its layout\n // from the plugin. Either way the action's `data` is the document's value —\n // seeded from the artifact, tracked by `refresh`.\n for (const [name, document] of Object.entries(plugin.documents)) {\n const canvasId = formCanvas(name);\n let action: ActionDefinition;\n if (typeof document === 'function') {\n const value = artifact.documents?.[name];\n action = { id: canvasId, data: isRecord(value) ? value : {}, layout: document(value) };\n } else {\n const ir = parse(document);\n // A non-object root binds one level in, under ROOT_KEY (see `needsWrap`).\n const wrap = needsWrap(document);\n if (wrap) wrappedDocs.add(name);\n const value = artifact.documents?.[name] ?? buildDocument(ir, {});\n const built = toNova(ir, {\n id: canvasId,\n ...(wrap ? { rootKey: ROOT_KEY } : {}),\n ...(isRecord(value) ? { value } : {}),\n widgets: plugin.widgets ?? [],\n });\n for (const [id, node] of Object.entries(built.layouts)) store.set(id, node);\n action = built.action;\n }\n shell.registerAction(action);\n shell.addCanvas({ id: canvasId, initial: action.id });\n formCanvasIds.push(canvasId);\n const instanceId = shell.getCanvasState(canvasId).active?.id;\n if (instanceId !== undefined) formInstances[name] = instanceId;\n }\n\n // Validate only schema documents — a freeform layout document has no schema.\n for (const [name, instanceId] of Object.entries(formInstances)) {\n const document = plugin.documents[name];\n if (typeof document !== 'function' && document !== undefined) {\n // A wrapped document is validated against the same wrapper, so the data\n // and schema agree and the error tree keys under ROOT_KEY (matching the\n // field bindings).\n const schema = wrappedDocs.has(name) ? z.object({ [ROOT_KEY]: document }) : document;\n detach.push(attachValidation(shell, instanceId, schema));\n }\n }\n detach.push(\n shell.onDataChange((change) => {\n if (!Object.values(formInstances).includes(change.instanceId)) return;\n refresh();\n emit('change');\n }),\n );\n\n // Arrange the canvases: the forms as the main pane, each contributed view in\n // its own sized pane. View canvases come after the forms; the default JSON\n // panes (loom:*) sort last, so a domain preview sits next to the forms.\n const viewIds = Object.keys(shell.getState().canvases)\n .filter((id) => !formCanvasIds.includes(id))\n .sort((a, b) => Number(a.startsWith('loom:')) - Number(b.startsWith('loom:')));\n shell.setCanvasLayout(defaultCanvasLayout(formCanvasIds, viewIds));\n\n refresh();\n emit('open');\n // Prime the view plugins with the opened documents.\n emit('change');\n };\n\n const editor: LoomEditor = {\n get shell() {\n return shell;\n },\n get plugin() {\n return active;\n },\n get documents() {\n return documents;\n },\n get validations() {\n return validations;\n },\n loadPlugin: (plugin) => {\n plugins.set(plugin.name, plugin);\n plugin.mount?.(editor);\n },\n open,\n on: (event, handler) => {\n listeners[event].add(handler);\n return () => listeners[event].delete(handler);\n },\n dispose: () => {\n detach.forEach((off) => off());\n detach = [];\n shell.dispose();\n },\n };\n\n return editor;\n};\n"]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { mountView } from './chunk-D743DI5J.js';
|
|
2
|
+
import { QuerySchema } from '@niscorp/vex';
|
|
3
|
+
|
|
4
|
+
// src/plugins/vex/widgets.ts
|
|
5
|
+
var VEX_COMPARISON = "vex:comparison";
|
|
6
|
+
var VEX_FIELD_PATH = "vex:field-path";
|
|
7
|
+
var VEX_AGGREGATE = "vex:aggregate";
|
|
8
|
+
var VEX_COMPUTE = "vex:compute";
|
|
9
|
+
var COMPARISON_OPS = /* @__PURE__ */ new Set(["eq", "neq", "gt", "gte", "lt", "lte", "like", "ilike"]);
|
|
10
|
+
var FIELD_KEYS = /* @__PURE__ */ new Set(["field", "isNull", "isNotNull"]);
|
|
11
|
+
var leaf = (path) => path.slice(path.lastIndexOf(".") + 1);
|
|
12
|
+
var isColumnListItem = (path) => /(?:^|\.)(?:fields|groupBy)\.\*$/.test(path);
|
|
13
|
+
var vexWidgets = [
|
|
14
|
+
// A comparison `[left, right]`: a field-path picker + a typed operand.
|
|
15
|
+
{ role: VEX_COMPARISON, match: (field) => field.kind === "unknown" && COMPARISON_OPS.has(leaf(field.path)) },
|
|
16
|
+
// A standalone field path: a sort key, `isNull`/`isNotNull`, or a `fields` / `groupBy` item.
|
|
17
|
+
{ role: VEX_FIELD_PATH, match: (field) => field.kind === "string" && (FIELD_KEYS.has(leaf(field.path)) || isColumnListItem(field.path)) },
|
|
18
|
+
// `aggregate` / `compute` records (alias -> expression): keyed-entry editors.
|
|
19
|
+
{ role: VEX_AGGREGATE, match: (field) => field.kind === "unknown" && leaf(field.path) === "aggregate" },
|
|
20
|
+
{ role: VEX_COMPUTE, match: (field) => field.kind === "unknown" && leaf(field.path) === "compute" }
|
|
21
|
+
];
|
|
22
|
+
var catalogOf = (db) => {
|
|
23
|
+
const types = /* @__PURE__ */ new Map();
|
|
24
|
+
const columns = [];
|
|
25
|
+
for (const entity of db.entities) {
|
|
26
|
+
for (const field of entity.fields) {
|
|
27
|
+
const column = `${entity.name}.${field.name}`;
|
|
28
|
+
columns.push(column);
|
|
29
|
+
types.set(column, field.normalizedType);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return { columns, typeOf: (column) => types.get(column) };
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// src/plugins/vex/preview.layout.ts
|
|
36
|
+
var PREVIEW = "vex:preview";
|
|
37
|
+
var previewLayout = {
|
|
38
|
+
component: PREVIEW,
|
|
39
|
+
props: { query: "$.query" }
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// src/plugins/vex/preview.action.ts
|
|
43
|
+
var previewAction = {
|
|
44
|
+
id: PREVIEW,
|
|
45
|
+
layout: previewLayout,
|
|
46
|
+
data: { query: null }
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// src/plugins/vex/index.ts
|
|
50
|
+
var vexPlugin = (config) => ({
|
|
51
|
+
name: "vex",
|
|
52
|
+
documents: { query: config.schema ?? QuerySchema },
|
|
53
|
+
// Widgets only matter with a schema to scope columns against; without `db` the
|
|
54
|
+
// query edits as plain inputs.
|
|
55
|
+
...config.db !== void 0 ? { widgets: vexWidgets } : {},
|
|
56
|
+
mount: (editor) => mountView(editor, previewAction, (e) => ({ query: e.documents["query"] }))
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
export { PREVIEW, VEX_AGGREGATE, VEX_COMPARISON, VEX_COMPUTE, VEX_FIELD_PATH, catalogOf, vexPlugin };
|
|
60
|
+
//# sourceMappingURL=chunk-XTY7XO5C.js.map
|
|
61
|
+
//# sourceMappingURL=chunk-XTY7XO5C.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/plugins/vex/widgets.ts","../src/plugins/vex/preview.layout.ts","../src/plugins/vex/preview.action.ts","../src/plugins/vex/index.ts"],"names":[],"mappings":";;;;AAQO,IAAM,cAAA,GAAiB;AACvB,IAAM,cAAA,GAAiB;AACvB,IAAM,aAAA,GAAgB;AACtB,IAAM,WAAA,GAAc;AAE3B,IAAM,cAAA,mBAAiB,IAAI,GAAA,C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ormalizedType } from '@niscorp/vex';\nimport type { WidgetBinding } from '@editor/types';\n\n// The vex widgets — framework-free. Each is a role (the component name its render\n// registers under) plus a matcher that claims fields by the tail of their path,\n// so a rule works at any depth (a comparison operand is `…eq` whether top-level or\n// nested). The render components live in ./react and close over the catalog.\n\nexport const VEX_COMPARISON = 'vex:comparison';\nexport const VEX_FIELD_PATH = 'vex:field-path';\nexport const VEX_AGGREGATE = 'vex:aggregate';\nexport const VEX_COMPUTE = 'vex:compute';\n\nconst COMPARISON_OPS = new Set(['eq', 'neq', 'gt', 'gte', 'lt', 'lte', 'like', 'ilike']);\nconst FIELD_KEYS = new Set(['field', 'isNull', 'isNotNull']);\n\nexport const leaf = (path: string): string => path.slice(path.lastIndexOf('.') + 1);\n// An item of the `fields` / `groupBy` arrays (path tail `fields.*` / `groupBy.*`).\nexport const isColumnListItem = (path: string): boolean => /(?:^|\\.)(?:fields|groupBy)\\.\\*$/.test(path);\n\n// The matchers, by where each field sits in the query. The compiler renders a\n// matched field with the role's component instead of the type default.\nexport const vexWidgets: WidgetBinding[] = [\n // A comparison `[left, right]`: a field-path picker + a typed operand.\n { role: VEX_COMPARISON, match: (field) => field.kind === 'unknown' && COMPARISON_OPS.has(leaf(field.path)) },\n // A standalone field path: a sort key, `isNull`/`isNotNull`, or a `fields` / `groupBy` item.\n { role: VEX_FIELD_PATH, match: (field) => field.kind === 'string' && (FIELD_KEYS.has(leaf(field.path)) || isColumnListItem(field.path)) },\n // `aggregate` / `compute` records (alias -> expression): keyed-entry editors.\n { role: VEX_AGGREGATE, match: (field) => field.kind === 'unknown' && leaf(field.path) === 'aggregate' },\n { role: VEX_COMPUTE, match: (field) => field.kind === 'unknown' && leaf(field.path) === 'compute' },\n];\n\n// The database's columns and their types, narrowed by the render widgets. Built\n// from the introspected schema; gives the field-path pickers their column list.\nexport type Catalog = { columns: string[]; typeOf: (column: string) => NormalizedType | undefined };\n\nexport const catalogOf = (db: DatabaseSchema): Catalog => {\n const types = new Map<string, NormalizedType>();\n const columns: string[] = [];\n for (const entity of db.entities) {\n for (const field of entity.fields) {\n const column = `${entity.name}.${field.name}`;\n columns.push(column);\n types.set(column, field.normalizedType);\n }\n }\n return { columns, typeOf: (column) => types.get(column) };\n};\n","import type { LayoutNode } from '@niscorp/nova';\n\n// The preview view's id — one string for one view: the name its component\n// registers under, the id of its action, and the id of its canvas. The plugin\n// owns it; the editor host defines no view ids of its own.\nexport const PREVIEW = 'vex:preview';\n\n// The preview layout: one component bound to the live `query` document. The\n// component runs the query and shows the rows.\nexport const previewLayout: LayoutNode = {\n component: PREVIEW,\n props: { query: '$.query' },\n};\n","import type { ActionDefinition } from '@niscorp/nova';\nimport { previewLayout, PREVIEW } from './preview.layout.js';\n\n// The preview canvas's action: the layout over a `query` slot the mount keeps\n// synced with the live query document. Canvas id equals the action id (PREVIEW).\nexport const previewAction: ActionDefinition = {\n id: PREVIEW,\n layout: previewLayout,\n data: { query: null },\n};\n","import type { ZodType } from 'zod';\nimport { QuerySchema, type DatabaseSchema, type Query } from '@niscorp/vex';\nimport { mountView } from '@editor/view';\nimport type { LoomPlugin } from '@editor/types';\nimport { vexWidgets } from './widgets.js';\nimport { previewAction } from './preview.action.js';\n\n// @niscorp/loom/plugins/vex — the Vex plugin (framework-free).\n//\n// Loom edits one document — a Vex query, from Vex's QuerySchema. The plugin\n// declares that document, contributes the preview canvas (which runs the query),\n// and — when given a database schema — the field-path widgets. The per-framework\n// surface (./react) supplies the preview component and the widget renders; this\n// core supplies the schema, the widget matchers, and the mount.\n\nexport { PREVIEW } from './preview.layout.js';\nexport type { Query };\n\nexport type VexRunResult = {\n rows: unknown[];\n warnings?: string[];\n errors?: string[];\n};\n\nexport type VexPluginConfig = {\n /** Run an edited query and return its rows (plus any warnings / errors). */\n run: (query: Query) => Promise<VexRunResult>;\n /** The introspected database schema — gives the field-path widgets their\n * column list. Omit to fall back to plain inputs. */\n db?: DatabaseSchema;\n /** Override the edited schema; defaults to Vex's `QuerySchema`. */\n schema?: ZodType;\n};\n\nexport const vexPlugin = (config: VexPluginConfig): LoomPlugin => ({\n name: 'vex',\n documents: { query: config.schema ?? (QuerySchema as ZodType) },\n // Widgets only matter with a schema to scope columns against; without `db` the\n // query edits as plain inputs.\n ...(config.db !== undefined ? { widgets: vexWidgets } : {}),\n mount: (editor) =>\n mountView(editor, previewAction, (e) => ({ query: (e.documents as Record<string, unknown>)['query'] })),\n});\n"]}
|