@niscorp/loom 0.3.0 → 0.3.1

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.
Files changed (78) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/DESIGN.md +33 -6
  3. package/README.md +24 -3
  4. package/dist/{chunk-D743DI5J.js → chunk-27OMOR7I.js} +2 -2
  5. package/dist/chunk-27OMOR7I.js.map +1 -0
  6. package/dist/{chunk-PTXRAWJX.js → chunk-67D727GH.js} +2 -13
  7. package/dist/chunk-67D727GH.js.map +1 -0
  8. package/dist/{chunk-MIRMQPUE.js → chunk-BU5TULRP.js} +3 -3
  9. package/dist/chunk-BU5TULRP.js.map +1 -0
  10. package/dist/{chunk-TV4U22MY.js → chunk-DEZGKUTO.js} +4 -10
  11. package/dist/chunk-DEZGKUTO.js.map +1 -0
  12. package/dist/{chunk-DWQWPBBV.js → chunk-HHPSU7IA.js} +4 -8
  13. package/dist/chunk-HHPSU7IA.js.map +1 -0
  14. package/dist/{chunk-TCCN6LKV.js → chunk-IQMWPPHW.js} +4 -14
  15. package/dist/chunk-IQMWPPHW.js.map +1 -0
  16. package/dist/{chunk-A3UOFGL4.js → chunk-LVDY6FUH.js} +3 -3
  17. package/dist/chunk-LVDY6FUH.js.map +1 -0
  18. package/dist/{chunk-IZ5B6IMX.js → chunk-OFKHIREC.js} +5 -5
  19. package/dist/chunk-OFKHIREC.js.map +1 -0
  20. package/dist/{chunk-XTY7XO5C.js → chunk-VMOYMYMV.js} +3 -8
  21. package/dist/chunk-VMOYMYMV.js.map +1 -0
  22. package/dist/index.cjs +2 -29
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +2 -2
  25. package/dist/index.d.ts +2 -2
  26. package/dist/index.js +4 -4
  27. package/dist/{loom-editor-Clohg49u.d.ts → loom-editor-BthwIGIZ.d.cts} +1 -4
  28. package/dist/{loom-editor-MACwUjLC.d.cts → loom-editor-CHtjjiBp.d.ts} +1 -4
  29. package/dist/plugins/nova/index.cjs +0 -4
  30. package/dist/plugins/nova/index.cjs.map +1 -1
  31. package/dist/plugins/nova/index.d.cts +1 -1
  32. package/dist/plugins/nova/index.d.ts +1 -1
  33. package/dist/plugins/nova/index.js +3 -3
  34. package/dist/plugins/nova/react/index.cjs +0 -4
  35. package/dist/plugins/nova/react/index.cjs.map +1 -1
  36. package/dist/plugins/nova/react/index.d.cts +2 -2
  37. package/dist/plugins/nova/react/index.d.ts +2 -2
  38. package/dist/plugins/nova/react/index.js +3 -3
  39. package/dist/plugins/nova/react/index.js.map +1 -1
  40. package/dist/plugins/prism/index.cjs.map +1 -1
  41. package/dist/plugins/prism/index.d.cts +1 -3
  42. package/dist/plugins/prism/index.d.ts +1 -3
  43. package/dist/plugins/prism/index.js +2 -2
  44. package/dist/plugins/prism/react/index.cjs +6 -16
  45. package/dist/plugins/prism/react/index.cjs.map +1 -1
  46. package/dist/plugins/prism/react/index.d.cts +2 -2
  47. package/dist/plugins/prism/react/index.d.ts +2 -2
  48. package/dist/plugins/prism/react/index.js +8 -12
  49. package/dist/plugins/prism/react/index.js.map +1 -1
  50. package/dist/plugins/vex/index.cjs +0 -5
  51. package/dist/plugins/vex/index.cjs.map +1 -1
  52. package/dist/plugins/vex/index.d.cts +1 -5
  53. package/dist/plugins/vex/index.d.ts +1 -5
  54. package/dist/plugins/vex/index.js +2 -2
  55. package/dist/plugins/vex/react/index.cjs +0 -5
  56. package/dist/plugins/vex/react/index.cjs.map +1 -1
  57. package/dist/plugins/vex/react/index.d.cts +2 -2
  58. package/dist/plugins/vex/react/index.d.ts +2 -2
  59. package/dist/plugins/vex/react/index.js +6 -6
  60. package/dist/plugins/vex/react/index.js.map +1 -1
  61. package/dist/react/index.cjs +2 -29
  62. package/dist/react/index.cjs.map +1 -1
  63. package/dist/react/index.d.cts +3 -3
  64. package/dist/react/index.d.ts +3 -3
  65. package/dist/react/index.js +7 -7
  66. package/dist/react/index.js.map +1 -1
  67. package/dist/{types-l8sDxrMR.d.cts → types-V5kJWZJn.d.cts} +2 -27
  68. package/dist/{types-l8sDxrMR.d.ts → types-V5kJWZJn.d.ts} +2 -27
  69. package/package.json +7 -7
  70. package/dist/chunk-A3UOFGL4.js.map +0 -1
  71. package/dist/chunk-D743DI5J.js.map +0 -1
  72. package/dist/chunk-DWQWPBBV.js.map +0 -1
  73. package/dist/chunk-IZ5B6IMX.js.map +0 -1
  74. package/dist/chunk-MIRMQPUE.js.map +0 -1
  75. package/dist/chunk-PTXRAWJX.js.map +0 -1
  76. package/dist/chunk-TCCN6LKV.js.map +0 -1
  77. package/dist/chunk-TV4U22MY.js.map +0 -1
  78. package/dist/chunk-XTY7XO5C.js.map +0 -1
@@ -1,7 +1,7 @@
1
- import { L as LoomEditorPlugin } from '../loom-editor-MACwUjLC.cjs';
2
- export { a as LoomEditor, b as LoomEditorProps } from '../loom-editor-MACwUjLC.cjs';
1
+ import { L as LoomEditorPlugin } from '../loom-editor-BthwIGIZ.cjs';
2
+ export { a as LoomEditor, b as LoomEditorProps } from '../loom-editor-BthwIGIZ.cjs';
3
3
  import { NovaModelBinding, NovaComponent } from '@niscorp/nova/adapters/react';
4
- export { i as FieldContext } from '../types-l8sDxrMR.cjs';
4
+ export { i as FieldContext } from '../types-V5kJWZJn.cjs';
5
5
  import { ComponentRegistry } from '@niscorp/nova';
6
6
  import { FC } from 'react';
7
7
  import 'zod';
@@ -1,7 +1,7 @@
1
- import { L as LoomEditorPlugin } from '../loom-editor-Clohg49u.js';
2
- export { a as LoomEditor, b as LoomEditorProps } from '../loom-editor-Clohg49u.js';
1
+ import { L as LoomEditorPlugin } from '../loom-editor-CHtjjiBp.js';
2
+ export { a as LoomEditor, b as LoomEditorProps } from '../loom-editor-CHtjjiBp.js';
3
3
  import { NovaModelBinding, NovaComponent } from '@niscorp/nova/adapters/react';
4
- export { i as FieldContext } from '../types-l8sDxrMR.js';
4
+ export { i as FieldContext } from '../types-V5kJWZJn.js';
5
5
  import { ComponentRegistry } from '@niscorp/nova';
6
6
  import { FC } from 'react';
7
7
  import 'zod';
@@ -1,10 +1,10 @@
1
- import { createLoomEditor } from '../chunk-TCCN6LKV.js';
2
- import { createLoomRegistry, LoomDocumentContext } from '../chunk-IZ5B6IMX.js';
3
- export { LoomAppend, LoomArray, LoomArrayItem, LoomBox, LoomBranch, LoomCheckbox, LoomColumn, LoomField, LoomGroup, LoomNumber, LoomRaw, LoomRowMenu, LoomSelect, LoomText, LoomVariant, createLoomRegistry, loomComponents, useLoomDocument } from '../chunk-IZ5B6IMX.js';
4
- import '../chunk-PTXRAWJX.js';
5
- export { JsonEditor, useModelWrite } from '../chunk-MIRMQPUE.js';
6
- import '../chunk-TV4U22MY.js';
7
- import { mountView } from '../chunk-D743DI5J.js';
1
+ import { createLoomEditor } from '../chunk-IQMWPPHW.js';
2
+ import { createLoomRegistry, LoomDocumentContext } from '../chunk-OFKHIREC.js';
3
+ export { LoomAppend, LoomArray, LoomArrayItem, LoomBox, LoomBranch, LoomCheckbox, LoomColumn, LoomField, LoomGroup, LoomNumber, LoomRaw, LoomRowMenu, LoomSelect, LoomText, LoomVariant, createLoomRegistry, loomComponents, useLoomDocument } from '../chunk-OFKHIREC.js';
4
+ import '../chunk-67D727GH.js';
5
+ export { JsonEditor, useModelWrite } from '../chunk-BU5TULRP.js';
6
+ import '../chunk-DEZGKUTO.js';
7
+ import { mountView } from '../chunk-27OMOR7I.js';
8
8
  import { useState, useEffect } from 'react';
9
9
  import { NovaShell } from '@niscorp/nova/adapters/react';
10
10
  import { jsx, jsxs } from 'react/jsx-runtime';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/react/editor/loom-editor.tsx","../../src/plugins/jsonviewer/jsonviewer.layout.ts","../../src/plugins/jsonviewer/jsonviewer.action.ts","../../src/plugins/jsonviewer/index.ts","../../src/plugins/jsonviewer/react/jsonviewer.tsx","../../src/plugins/jsonviewer/react/index.ts","../../src/plugins/validation/validation.layout.ts","../../src/plugins/validation/validation.action.ts","../../src/plugins/validation/index.ts","../../src/plugins/validation/react/validation.tsx","../../src/plugins/validation/react/index.ts","../../src/react/editor/defaults.ts"],"names":["jsx","panel","head","pre","jsxs"],"mappings":";;;;;;;;;;;AAwCO,IAAM,aAAkC,CAAC,EAAE,OAAA,EAAS,QAAA,EAAU,UAAS,KAAM;AAClF,EAAA,MAAM,CAAC,GAAA,EAAK,MAAM,CAAA,GAAI,SAA+B,IAAI,CAAA;AACzD,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,CAAA,GAAI,QAAA,CAAkC,EAAE,CAAA;AAEtE,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,WAAW,kBAAA,EAAmB;AACpC,IAAA,KAAA,MAAW,UAAU,OAAA,EAAS;AAC5B,MAAA,KAAA,MAAW,CAAC,IAAA,EAAM,SAAS,CAAA,IAAK,OAAO,OAAA,CAAQ,MAAA,CAAO,UAAA,IAAc,EAAE,CAAA,EAAG,QAAA,CAAS,QAAA,CAAS,MAAM,SAAS,CAAA;AAAA,IAC5G;AAEA,IAAA,MAAM,MAAA,GAAS,gBAAA,CAAiB,EAAE,QAAA,EAAyC,CAAA;AAC3E,IAAA,KAAA,MAAW,UAAU,OAAA,EAAS;AAC5B,MAAA,MAAA,CAAO,UAAA,CAAW;AAAA,QAChB,MAAM,MAAA,CAAO,IAAA;AAAA,QACb,WAAW,MAAA,CAAO,SAAA;AAAA,QAClB,GAAI,OAAO,OAAA,GAAU,EAAE,SAAS,MAAA,CAAO,OAAA,CAAQ,IAAI,CAAC,CAAA,MAAO,EAAE,IAAA,EAAM,CAAA,CAAE,MAAM,KAAA,EAAO,CAAA,CAAE,OAAM,CAAE,CAAA,KAAM,EAAC;AAAA,QACnG,GAAI,OAAO,KAAA,GAAQ,EAAE,OAAO,MAAA,CAAO,KAAA,KAAU;AAAC,OAC/C,CAAA;AAAA,IACH;AACA,IAAA,MAAA,CAAO,KAAK,QAAQ,CAAA;AACpB,IAAA,MAAA,CAAO,MAAM,CAAA;AACb,IAAA,YAAA,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AA,EAAM,QAAA,EAAA,IAAA,CAAK,SAAA,CAAU,KAAA,IAAS,EAAC,EAAG,IAAA,EAAM,CAAC,CAAA,EAAE;AAAA,CAAA,EACzD,CAAA;;;ACTK,IAAM,aAAa,MAAwB;AAChD,EAAA,MAAM,EAAE,IAAA,EAAM,SAAA,EAAW,KAAA,KAAU,gBAAA,EAAiB;AACpD,EAAA,OAAO,EAAE,IAAA,EAAM,SAAA,EAAW,KAAA,EAAO,UAAA,EAAY,EAAE,CAAC,UAAU,GAAG,UAAA,EAAW,EAAE;AAC5E,CAAA;;;ACDO,IAAM,iBAAiB,MAA0B,CAAC,UAAA,EAAW,EAAG,YAAY","file":"index.js","sourcesContent":["import { useEffect, useState, type FC } from 'react';\nimport type { ZodType } from 'zod';\nimport type { ComponentRegistry, LayoutNode } from '@niscorp/nova';\nimport { NovaShell, type NovaComponent } from '@niscorp/nova/adapters/react';\nimport { createLoomEditor, type LoomArtifact, type LoomEditor as LoomEditorApi } from '@editor/editor';\nimport type { FieldContext } from '@compile/types';\nimport { createLoomRegistry } from '../kit/index.js';\nimport { LoomDocumentContext } from '../hooks/document.js';\n\n// <LoomEditor> — the integrated editing surface and the package's main export.\n// It builds the editor controller (an empty Nova shell + a plugin loader) and\n// renders it. Everything visible is plugin-contributed; the component is agnostic\n// about which plugins those are — it loads exactly `plugins`, in order, so a later\n// one can override or remove an earlier one. (Apps that want the JSON / validation\n// views spread `defaultPlugins()` at the front.) The controller is framework-free;\n// this component supplies the kit and renders the shell. Give the element a new\n// `key` to open a different artifact.\n\n// A renderer plugin: the core descriptor plus the components it registers.\n// `mount` and `documents` drive the controller; `widgets` are the compiler\n// matchers (role + match) that upgrade form fields. `components` (keyed by role)\n// supply every render — the views a mount references AND the widget renders. A\n// role names a component; `components` provides it.\nexport type LoomEditorPlugin = {\n name: string;\n documents: Record<string, ZodType | ((value: unknown) => LayoutNode)>;\n components?: Record<string, NovaComponent>;\n widgets?: { role: string; match: (field: FieldContext) => boolean }[];\n mount?: (editor: LoomEditorApi) => void;\n};\n\nexport type LoomEditorProps = {\n /** The loaded plugins (capabilities). Read once on mount. */\n plugins: LoomEditorPlugin[];\n /** The artifact to open. Read once on mount; give a new `key` to switch. */\n artifact: LoomArtifact;\n /** Called with the live documents whenever they change. */\n onChange?: (documents: Record<string, unknown>) => void;\n};\n\nexport const LoomEditor: FC<LoomEditorProps> = ({ plugins, artifact, onChange }) => {\n const [api, setApi] = useState<LoomEditorApi | null>(null);\n const [documents, setDocuments] = useState<Record<string, unknown>>({});\n\n useEffect(() => {\n const registry = createLoomRegistry();\n for (const plugin of plugins) {\n for (const [role, component] of Object.entries(plugin.components ?? {})) registry.register(role, component);\n }\n\n const editor = createLoomEditor({ registry: registry as ComponentRegistry });\n for (const plugin of plugins) {\n editor.loadPlugin({\n name: plugin.name,\n documents: plugin.documents,\n ...(plugin.widgets ? { widgets: plugin.widgets.map((w) => ({ role: w.role, match: w.match })) } : {}),\n ...(plugin.mount ? { mount: plugin.mount } : {}),\n });\n }\n editor.open(artifact);\n setApi(editor);\n setDocuments(editor.documents);\n onChange?.(editor.documents);\n const off = editor.on('change', () => {\n setDocuments(editor.documents);\n onChange?.(editor.documents);\n });\n return () => {\n off();\n editor.dispose();\n setApi(null);\n };\n // Mount-only; a new `key` re-opens.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const shell = api?.shell;\n return shell === undefined || shell === null ? null : (\n <LoomDocumentContext.Provider value={documents}>\n <NovaShell shell={shell} />\n </LoomDocumentContext.Provider>\n );\n};\n","import type { LayoutNode } from '@niscorp/nova';\n\n// The view's id — one string for one view: the name its component registers\n// under, the id of its action, and the id of its canvas. The plugin owns it; the\n// editor host defines no view ids of its own.\nexport const JSONVIEWER = 'loom:jsonviewer';\n\n// A read-only JSON pane titled \"Data\", bound to the `value` the mount syncs (the\n// editor's live documents).\nexport const jsonviewerLayout: LayoutNode = {\n component: JSONVIEWER,\n props: { title: 'Data', value: '$.value' },\n};\n","import type { ActionDefinition } from '@niscorp/nova';\nimport { jsonviewerLayout, JSONVIEWER } from './jsonviewer.layout.js';\n\n// The jsonviewer canvas's action: the layout over a `value` slot the mount keeps\n// synced. Canvas id equals the action id (JSONVIEWER).\nexport const jsonviewerAction: ActionDefinition = {\n id: JSONVIEWER,\n layout: jsonviewerLayout,\n data: { value: {} },\n};\n","import { mountView } from '@editor/view';\nimport type { LoomPlugin } from '@editor/types';\nimport { jsonviewerAction } from './jsonviewer.action.js';\n\n// @niscorp/loom/plugins/jsonviewer — a default plugin (framework-free).\n//\n// A read-only JSON view of the editor's live documents. Loaded first, so a domain\n// plugin (nova, vex) loaded later can remove its canvas or re-arrange the shell.\n// Contributes no documents — it edits nothing, it mirrors what the forms hold.\n\nexport { JSONVIEWER } from './jsonviewer.layout.js';\n\nexport const jsonviewerPlugin = (): LoomPlugin => ({\n name: 'loom:jsonviewer',\n documents: {},\n mount: (editor) => mountView(editor, jsonviewerAction, (e) => ({ value: e.documents })),\n});\n","import type { CSSProperties } from 'react';\nimport type { NovaComponent } from '@niscorp/nova/adapters/react';\n\n// The jsonviewer's view component: a read-only JSON pane with a title. The plugin\n// binds `value` to the editor's live documents and registers this under JSONVIEWER.\n\nconst panel: CSSProperties = { border: '1px solid #e5e7eb', borderRadius: 8, overflow: 'hidden' };\nconst head: CSSProperties = { padding: '6px 12px', borderBottom: '1px solid #e5e7eb', background: '#f9fafb', fontSize: 12, fontWeight: 600, color: '#374151' };\nconst pre: CSSProperties = { margin: 0, padding: 12, fontSize: 12, fontFamily: 'ui-monospace, Menlo, monospace', whiteSpace: 'pre-wrap', wordBreak: 'break-word', maxHeight: 320, overflow: 'auto' };\n\nexport const JsonViewer: NovaComponent<{ title?: string; value?: unknown }> = ({ title, value }) => (\n <div style={panel}>\n {title !== undefined ? <div style={head}>{title}</div> : null}\n <pre style={pre}>{JSON.stringify(value ?? {}, null, 2)}</pre>\n </div>\n);\n","import type { LoomEditorPlugin } from '@react';\nimport { jsonviewerPlugin, JSONVIEWER } from '../index.js';\nimport { JsonViewer } from './jsonviewer.js';\n\n// @niscorp/loom/plugins/jsonviewer/react — the React surface: the plugin assembled\n// with its own view component, registered under the plugin's view id.\nexport const jsonviewer = (): LoomEditorPlugin => {\n const { name, documents, mount } = jsonviewerPlugin();\n return { name, documents, mount, components: { [JSONVIEWER]: JsonViewer } };\n};\n","import type { LayoutNode } from '@niscorp/nova';\n\n// The view's id — one string for one view: the name its component registers\n// under, the id of its action, and the id of its canvas. The plugin owns it; the\n// editor host defines no view ids of its own.\nexport const VALIDATION = 'loom:validation';\n\n// A read-only JSON pane titled \"Validations\", bound to the `value` the mount\n// syncs (the editor's per-document validation problems).\nexport const validationLayout: LayoutNode = {\n component: VALIDATION,\n props: { title: 'Validations', value: '$.value' },\n};\n","import type { ActionDefinition } from '@niscorp/nova';\nimport { validationLayout, VALIDATION } from './validation.layout.js';\n\n// The validation canvas's action: the layout over a `value` slot the mount keeps\n// synced. Canvas id equals the action id (VALIDATION).\nexport const validationAction: ActionDefinition = {\n id: VALIDATION,\n layout: validationLayout,\n data: { value: {} },\n};\n","import { mountView } from '@editor/view';\nimport type { LoomPlugin } from '@editor/types';\nimport { validationAction } from './validation.action.js';\n\n// @niscorp/loom/plugins/validation — a default plugin (framework-free).\n//\n// A read-only JSON view of the editor's validation problems (per document, keyed\n// the same as `documents`). Loaded first; overridable like any default.\n// Contributes no documents — it mirrors the forms' validation state.\n\nexport { VALIDATION } from './validation.layout.js';\n\nexport const validationPlugin = (): LoomPlugin => ({\n name: 'loom:validation',\n documents: {},\n mount: (editor) => mountView(editor, validationAction, (e) => ({ value: e.validations })),\n});\n","import type { CSSProperties } from 'react';\nimport type { NovaComponent } from '@niscorp/nova/adapters/react';\n\n// The validation plugin's view component: a read-only JSON pane with a title. The\n// plugin binds `value` to the editor's validation problems and registers this\n// under VALIDATION.\n\nconst panel: CSSProperties = { border: '1px solid #e5e7eb', borderRadius: 8, overflow: 'hidden' };\nconst head: CSSProperties = { padding: '6px 12px', borderBottom: '1px solid #e5e7eb', background: '#f9fafb', fontSize: 12, fontWeight: 600, color: '#374151' };\nconst pre: CSSProperties = { margin: 0, padding: 12, fontSize: 12, fontFamily: 'ui-monospace, Menlo, monospace', whiteSpace: 'pre-wrap', wordBreak: 'break-word', maxHeight: 320, overflow: 'auto' };\n\nexport const Validation: NovaComponent<{ title?: string; value?: unknown }> = ({ title, value }) => (\n <div style={panel}>\n {title !== undefined ? <div style={head}>{title}</div> : null}\n <pre style={pre}>{JSON.stringify(value ?? {}, null, 2)}</pre>\n </div>\n);\n","import type { LoomEditorPlugin } from '@react';\nimport { validationPlugin, VALIDATION } from '../index.js';\nimport { Validation } from './validation.js';\n\n// @niscorp/loom/plugins/validation/react — the React surface: the plugin assembled\n// with its own view component, registered under the plugin's view id.\nexport const validation = (): LoomEditorPlugin => {\n const { name, documents, mount } = validationPlugin();\n return { name, documents, mount, components: { [VALIDATION]: Validation } };\n};\n","import { jsonviewer } from '@plugins/jsonviewer/react';\nimport { validation } from '@plugins/validation/react';\nimport type { LoomEditorPlugin } from './loom-editor.js';\n\n// The default view plugins, as a preset. <LoomEditor> bakes in nothing — an app\n// that wants the live Data / Validations JSON panes spreads these at the FRONT of\n// its `plugins` list, so domain plugins (nova, vex) load after and can override or\n// remove them. Omit it for a bare editor.\nexport const defaultPlugins = (): LoomEditorPlugin[] => [jsonviewer(), validation()];\n"]}
1
+ {"version":3,"sources":["../../src/react/editor/loom-editor.tsx","../../src/plugins/jsonviewer/jsonviewer.layout.ts","../../src/plugins/jsonviewer/jsonviewer.action.ts","../../src/plugins/jsonviewer/index.ts","../../src/plugins/jsonviewer/react/jsonviewer.tsx","../../src/plugins/jsonviewer/react/index.ts","../../src/plugins/validation/validation.layout.ts","../../src/plugins/validation/validation.action.ts","../../src/plugins/validation/index.ts","../../src/plugins/validation/react/validation.tsx","../../src/plugins/validation/react/index.ts","../../src/react/editor/defaults.ts"],"names":["jsx","panel","head","pre","jsxs"],"mappings":";;;;;;;;;;;AAuBO,IAA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;;;ACPK,IAAM,aAAa,MAAwB;AAChD,EAAA,MAAM,EAAE,IAAA,EAAM,SAAA,EAAW,KAAA,KAAU,gBAAA,EAAiB;AACpD,EAAA,OAAO,EAAE,IAAA,EAAM,SAAA,EAAW,KAAA,EAAO,UAAA,EAAY,EAAE,CAAC,UAAU,GAAG,UAAA,EAAW,EAAE;AAC5E,CAAA;;;ACHO,IAAM,iBAAiB,MAA0B,CAAC,UAAA,EAAW,EAAG,YAAY","file":"index.js","sourcesContent":["import { useEffect, useState, type FC } from 'react';\nimport type { ZodType } from 'zod';\nimport type { ComponentRegistry, LayoutNode } from '@niscorp/nova';\nimport { NovaShell, type NovaComponent } from '@niscorp/nova/adapters/react';\nimport { createLoomEditor, type LoomArtifact, type LoomEditor as LoomEditorApi } from '@editor/editor';\nimport type { FieldContext } from '@compile/types';\nimport { createLoomRegistry } from '../kit/index.js';\nimport { LoomDocumentContext } from '../hooks/document.js';\n\nexport type LoomEditorPlugin = {\n name: string;\n documents: Record<string, ZodType | ((value: unknown) => LayoutNode)>;\n components?: Record<string, NovaComponent>;\n widgets?: { role: string; match: (field: FieldContext) => boolean }[];\n mount?: (editor: LoomEditorApi) => void;\n};\n\nexport type LoomEditorProps = {\n plugins: LoomEditorPlugin[];\n artifact: LoomArtifact;\n onChange?: (documents: Record<string, unknown>) => void;\n};\n\nexport const LoomEditor: FC<LoomEditorProps> = ({ plugins, artifact, onChange }) => {\n const [api, setApi] = useState<LoomEditorApi | null>(null);\n const [documents, setDocuments] = useState<Record<string, unknown>>({});\n\n useEffect(() => {\n const registry = createLoomRegistry();\n for (const plugin of plugins) {\n for (const [role, component] of Object.entries(plugin.components ?? {})) registry.register(role, component);\n }\n\n const editor = createLoomEditor({ registry: registry as ComponentRegistry });\n for (const plugin of plugins) {\n editor.loadPlugin({\n name: plugin.name,\n documents: plugin.documents,\n ...(plugin.widgets ? { widgets: plugin.widgets.map((w) => ({ role: w.role, match: w.match })) } : {}),\n ...(plugin.mount ? { mount: plugin.mount } : {}),\n });\n }\n editor.open(artifact);\n setApi(editor);\n setDocuments(editor.documents);\n onChange?.(editor.documents);\n const off = editor.on('change', () => {\n setDocuments(editor.documents);\n onChange?.(editor.documents);\n });\n return () => {\n off();\n editor.dispose();\n setApi(null);\n };\n // Mount-only: `plugins` and `artifact` are read once; a new `key` re-opens.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const shell = api?.shell;\n return shell === undefined || shell === null ? null : (\n <LoomDocumentContext.Provider value={documents}>\n <NovaShell shell={shell} />\n </LoomDocumentContext.Provider>\n );\n};\n","import type { LayoutNode } from '@niscorp/nova';\n\nexport const JSONVIEWER = 'loom:jsonviewer';\n\nexport const jsonviewerLayout: LayoutNode = {\n component: JSONVIEWER,\n props: { title: 'Data', value: '$.value' },\n};\n","import type { ActionDefinition } from '@niscorp/nova';\nimport { jsonviewerLayout, JSONVIEWER } from './jsonviewer.layout.js';\n\nexport const jsonviewerAction: ActionDefinition = {\n id: JSONVIEWER,\n layout: jsonviewerLayout,\n data: { value: {} },\n};\n","import { mountView } from '@editor/view';\nimport type { LoomPlugin } from '@editor/types';\nimport { jsonviewerAction } from './jsonviewer.action.js';\n\nexport { JSONVIEWER } from './jsonviewer.layout.js';\n\nexport const jsonviewerPlugin = (): LoomPlugin => ({\n name: 'loom:jsonviewer',\n documents: {},\n mount: (editor) => mountView(editor, jsonviewerAction, (e) => ({ value: e.documents })),\n});\n","import type { CSSProperties } from 'react';\nimport type { NovaComponent } from '@niscorp/nova/adapters/react';\n\nconst panel: CSSProperties = { border: '1px solid #e5e7eb', borderRadius: 8, overflow: 'hidden' };\nconst head: CSSProperties = { padding: '6px 12px', borderBottom: '1px solid #e5e7eb', background: '#f9fafb', fontSize: 12, fontWeight: 600, color: '#374151' };\nconst pre: CSSProperties = { margin: 0, padding: 12, fontSize: 12, fontFamily: 'ui-monospace, Menlo, monospace', whiteSpace: 'pre-wrap', wordBreak: 'break-word', maxHeight: 320, overflow: 'auto' };\n\nexport const JsonViewer: NovaComponent<{ title?: string; value?: unknown }> = ({ title, value }) => (\n <div style={panel}>\n {title !== undefined ? <div style={head}>{title}</div> : null}\n <pre style={pre}>{JSON.stringify(value ?? {}, null, 2)}</pre>\n </div>\n);\n","import type { LoomEditorPlugin } from '@react';\nimport { jsonviewerPlugin, JSONVIEWER } from '../index.js';\nimport { JsonViewer } from './jsonviewer.js';\n\nexport const jsonviewer = (): LoomEditorPlugin => {\n const { name, documents, mount } = jsonviewerPlugin();\n return { name, documents, mount, components: { [JSONVIEWER]: JsonViewer } };\n};\n","import type { LayoutNode } from '@niscorp/nova';\n\nexport const VALIDATION = 'loom:validation';\n\nexport const validationLayout: LayoutNode = {\n component: VALIDATION,\n props: { title: 'Validations', value: '$.value' },\n};\n","import type { ActionDefinition } from '@niscorp/nova';\nimport { validationLayout, VALIDATION } from './validation.layout.js';\n\nexport const validationAction: ActionDefinition = {\n id: VALIDATION,\n layout: validationLayout,\n data: { value: {} },\n};\n","import { mountView } from '@editor/view';\nimport type { LoomPlugin } from '@editor/types';\nimport { validationAction } from './validation.action.js';\n\nexport { VALIDATION } from './validation.layout.js';\n\nexport const validationPlugin = (): LoomPlugin => ({\n name: 'loom:validation',\n documents: {},\n mount: (editor) => mountView(editor, validationAction, (e) => ({ value: e.validations })),\n});\n","import type { CSSProperties } from 'react';\nimport type { NovaComponent } from '@niscorp/nova/adapters/react';\n\nconst panel: CSSProperties = { border: '1px solid #e5e7eb', borderRadius: 8, overflow: 'hidden' };\nconst head: CSSProperties = { padding: '6px 12px', borderBottom: '1px solid #e5e7eb', background: '#f9fafb', fontSize: 12, fontWeight: 600, color: '#374151' };\nconst pre: CSSProperties = { margin: 0, padding: 12, fontSize: 12, fontFamily: 'ui-monospace, Menlo, monospace', whiteSpace: 'pre-wrap', wordBreak: 'break-word', maxHeight: 320, overflow: 'auto' };\n\nexport const Validation: NovaComponent<{ title?: string; value?: unknown }> = ({ title, value }) => (\n <div style={panel}>\n {title !== undefined ? <div style={head}>{title}</div> : null}\n <pre style={pre}>{JSON.stringify(value ?? {}, null, 2)}</pre>\n </div>\n);\n","import type { LoomEditorPlugin } from '@react';\nimport { validationPlugin, VALIDATION } from '../index.js';\nimport { Validation } from './validation.js';\n\nexport const validation = (): LoomEditorPlugin => {\n const { name, documents, mount } = validationPlugin();\n return { name, documents, mount, components: { [VALIDATION]: Validation } };\n};\n","import { jsonviewer } from '@plugins/jsonviewer/react';\nimport { validation } from '@plugins/validation/react';\nimport type { LoomEditorPlugin } from './loom-editor.js';\n\nexport const defaultPlugins = (): LoomEditorPlugin[] => [jsonviewer(), validation()];\n"]}
@@ -77,29 +77,11 @@ type WidgetMatcher = {
77
77
  };
78
78
  type EmptyValue = (field: Field, options: CompileOptions) => unknown;
79
79
  type CompileOptions = {
80
- /** Definition id for the emitted action. Defaults to `'loom-form'`. */
81
80
  id?: string;
82
- /** Initial document to edit. Derived from the schema when omitted. */
83
81
  value?: Record<string, unknown>;
84
- /**
85
- * Bind the root field under this key instead of at the bare document root. A
86
- * non-object root (a union, scalar, or array) compiles to a single control,
87
- * which can't bind the document root (`$` resolves to no readable/writable
88
- * value); wrapping it under a key gives it a real path. The document is shaped
89
- * as `{ [rootKey]: value }`; callers that want the raw value unwrap the key.
90
- */
91
82
  rootKey?: string;
92
- /**
93
- * Give optional (non-required) object properties their defaults too. When
94
- * false, optional properties start absent. Defaults to true.
95
- */
96
83
  includeOptional?: boolean;
97
- /** Per-kind overrides for the empty value of a field that has no schema default. */
98
84
  empty?: Partial<Record<FieldKind, EmptyValue>>;
99
- /**
100
- * Custom widgets: the first whose `match` accepts a field replaces its default
101
- * editor with the component registered under `role`. Used by plugins.
102
- */
103
85
  widgets?: WidgetMatcher[];
104
86
  };
105
87
 
@@ -121,27 +103,20 @@ type LoomArtifact = {
121
103
  };
122
104
  type LoomEvent = 'change' | 'open';
123
105
  type LoomEditor = {
124
- /** The live Nova shell. Built empty at creation; plugins mount onto it. */
125
106
  readonly shell: Shell;
126
- /** Register a plugin (a capability). Calls its `mount` against the live shell. */
127
107
  loadPlugin: (plugin: LoomPlugin) => void;
128
- /** Open an artifact — compiles its plugin's documents into form canvases. */
129
108
  open: (artifact: LoomArtifact) => void;
130
- /** The plugin whose artifact is currently open. */
131
109
  readonly plugin: LoomPlugin | undefined;
132
- /** The live document values, keyed by document name. */
133
110
  readonly documents: Record<string, unknown>;
134
111
  /**
135
- * The messages each form shows, per document: `{ [document]: errorTree }`.
136
- * Written after an edit, so empty at open, and a problem with no path is not
137
- * in it. Not the verdict on a document: for that, parse it with its schema.
112
+ * Not the verdict on a document: written after an edit, so empty at open, and
113
+ * a problem with no path is not in it. For the verdict, parse with the schema.
138
114
  */
139
115
  readonly validations: Record<string, unknown>;
140
116
  on: (event: LoomEvent, handler: () => void) => () => void;
141
117
  dispose: () => void;
142
118
  };
143
119
  type LoomEditorConfig = {
144
- /** The component registry (the renderer's kit). The shell renders through it. */
145
120
  registry: ComponentRegistry;
146
121
  };
147
122
 
@@ -77,29 +77,11 @@ type WidgetMatcher = {
77
77
  };
78
78
  type EmptyValue = (field: Field, options: CompileOptions) => unknown;
79
79
  type CompileOptions = {
80
- /** Definition id for the emitted action. Defaults to `'loom-form'`. */
81
80
  id?: string;
82
- /** Initial document to edit. Derived from the schema when omitted. */
83
81
  value?: Record<string, unknown>;
84
- /**
85
- * Bind the root field under this key instead of at the bare document root. A
86
- * non-object root (a union, scalar, or array) compiles to a single control,
87
- * which can't bind the document root (`$` resolves to no readable/writable
88
- * value); wrapping it under a key gives it a real path. The document is shaped
89
- * as `{ [rootKey]: value }`; callers that want the raw value unwrap the key.
90
- */
91
82
  rootKey?: string;
92
- /**
93
- * Give optional (non-required) object properties their defaults too. When
94
- * false, optional properties start absent. Defaults to true.
95
- */
96
83
  includeOptional?: boolean;
97
- /** Per-kind overrides for the empty value of a field that has no schema default. */
98
84
  empty?: Partial<Record<FieldKind, EmptyValue>>;
99
- /**
100
- * Custom widgets: the first whose `match` accepts a field replaces its default
101
- * editor with the component registered under `role`. Used by plugins.
102
- */
103
85
  widgets?: WidgetMatcher[];
104
86
  };
105
87
 
@@ -121,27 +103,20 @@ type LoomArtifact = {
121
103
  };
122
104
  type LoomEvent = 'change' | 'open';
123
105
  type LoomEditor = {
124
- /** The live Nova shell. Built empty at creation; plugins mount onto it. */
125
106
  readonly shell: Shell;
126
- /** Register a plugin (a capability). Calls its `mount` against the live shell. */
127
107
  loadPlugin: (plugin: LoomPlugin) => void;
128
- /** Open an artifact — compiles its plugin's documents into form canvases. */
129
108
  open: (artifact: LoomArtifact) => void;
130
- /** The plugin whose artifact is currently open. */
131
109
  readonly plugin: LoomPlugin | undefined;
132
- /** The live document values, keyed by document name. */
133
110
  readonly documents: Record<string, unknown>;
134
111
  /**
135
- * The messages each form shows, per document: `{ [document]: errorTree }`.
136
- * Written after an edit, so empty at open, and a problem with no path is not
137
- * in it. Not the verdict on a document: for that, parse it with its schema.
112
+ * Not the verdict on a document: written after an edit, so empty at open, and
113
+ * a problem with no path is not in it. For the verdict, parse with the schema.
138
114
  */
139
115
  readonly validations: Record<string, unknown>;
140
116
  on: (event: LoomEvent, handler: () => void) => () => void;
141
117
  dispose: () => void;
142
118
  };
143
119
  type LoomEditorConfig = {
144
- /** The component registry (the renderer's kit). The shell renders through it. */
145
120
  registry: ComponentRegistry;
146
121
  };
147
122
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@niscorp/loom",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Schema-driven editors that run on Nova — turn any schema into an editing UI",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -114,16 +114,16 @@
114
114
  "tsup": "^8.5.1",
115
115
  "vitest": "^4.1.2",
116
116
  "zod": "^4.6.5",
117
- "@niscorp/prism": "^0.3.0",
118
- "@niscorp/vex": "^0.3.0",
119
- "@niscorp/nova": "^0.3.0"
117
+ "@niscorp/nova": "^0.3.1",
118
+ "@niscorp/vex": "^0.3.1",
119
+ "@niscorp/prism": "^0.3.1"
120
120
  },
121
121
  "peerDependencies": {
122
122
  "react": "^19.2.4",
123
123
  "zod": "^4.2.0",
124
- "@niscorp/nova": "^0.3.0",
125
- "@niscorp/prism": "^0.3.0",
126
- "@niscorp/vex": "^0.3.0"
124
+ "@niscorp/nova": "^0.3.1",
125
+ "@niscorp/prism": "^0.3.1",
126
+ "@niscorp/vex": "^0.3.1"
127
127
  },
128
128
  "peerDependenciesMeta": {
129
129
  "@niscorp/prism": {
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/plugins/prism/preview.layout.ts","../src/plugins/prism/preview.action.ts","../src/plugins/prism/index.ts"],"names":[],"mappings":";;;;AAKO,IAAM,OAAA,GAAU;AAIhB,IAAM,aAAA,GAA4B;AAAA,EACvC,SAAA,EAAW,OAAA;AAAA,EACX,KAAA,EAAO,EAAE,MAAA,EAAQ,UAAA;AACnB,CAAA;;;ACPO,IAAM,aAAA,GAAkC;AAAA,EAC7C,EAAA,EAAI,OAAA;AAAA,EACJ,MAAA,EAAQ,aAAA;AAAA,EACR,IAAA,EAAM,EAAE,MAAA,EAAQ,IAAA;AAClB,CAAA;;;ACiBO,IAAM,IAAA,GAAO;AASb,IAAM,WAAA,GAAc,CAAC,OAAA,MAA6C;AAAA,EACvE,IAAA,EAAM,OAAA;AAAA,EACN,SAAA,EAAW,EAAE,MAAA,EAAQ,OAAA,CAAQ,UAAW,UAAA,EAAuB;AAAA,EAC/D,OAAA,EAAS,CAAC,EAAE,IAAA,EAAM,MAAM,KAAA,EAAO,CAAC,KAAA,KAAU,KAAA,CAAM,IAAA,KAAS,OAAA,IAAW,KAAA,CAAM,IAAA,KAAS,IAAI,CAAA;AAAA,EACvF,KAAA,EAAO,CAAC,MAAA,KACN,SAAA,CAAU,QAAQ,aAAA,EAAe,CAAC,CAAA,MAAO,EAAE,MAAA,EAAS,CAAA,CAAE,SAAA,CAAsC,QAAQ,GAAE,CAAE;AAC5G,CAAA","file":"chunk-A3UOFGL4.js","sourcesContent":["import type { LayoutNode } from '@niscorp/nova';\n\n// The preview view's id, one string for one view: the component name, the action\n// id, and the canvas id. The framework surface registers the component under it;\n// the core's mount references it.\nexport const PREVIEW = 'prism:preview';\n\n// The preview layout: one component bound to the live `config` document. The\n// component applies the config to a sample input and shows the output.\nexport const previewLayout: LayoutNode = {\n component: PREVIEW,\n props: { config: '$.config' },\n};\n","import type { ActionDefinition } from '@niscorp/nova';\nimport { previewLayout, PREVIEW } from './preview.layout.js';\n\n// The preview canvas's action: the preview layout over a `config` slot the mount\n// keeps in sync with the live config document. Canvas id equals the action id.\nexport const previewAction: ActionDefinition = {\n id: PREVIEW,\n layout: previewLayout,\n data: { config: null },\n};\n","import type { ZodType } from 'zod';\nimport { NodeSchema, type Config, type JsonObject, type JsonValue } from '@niscorp/prism';\nimport { mountView } from '@editor/view';\nimport type { LoomPlugin } from '@editor/types';\nimport { previewAction } from './preview.action.js';\n\n// @niscorp/loom/plugins/prism — the Prism plugin (framework-free).\n//\n// Loom edits one document, a Prism config (a recursive union of transform\n// operations). The plugin declares it and contributes a preview canvas that\n// applies the config to a sample input and shows the output. The per-framework\n// surface (./react) supplies the preview component; this core supplies the\n// schema and the mount.\n//\n// The edited schema is Prism's `NodeSchema`, not `ConfigSchema`. The two are\n// equivalent (`ConfigSchema = NodeSchema.describe(...)`), but `NodeSchema` is the\n// stable lazy the recursive fields point back to, so it compiles to a single\n// recursive union instead of unrolling one redundant level.\n\nexport { PREVIEW } from './preview.layout.js';\nexport type { Config, JsonObject, JsonValue };\n\n// The role the recursive node editor renders under. The match is framework-free\n// (it lives here); the React surface supplies the component. It claims the\n// document root: the whole config is one Prism node, edited by one recursive\n// widget rather than Loom's static field compilation.\nexport const NODE = 'prism:node';\n\nexport type PrismPluginOptions = {\n /** Sample source data the edited config is applied to in the preview. */\n input: JsonObject;\n /** Override the edited schema; defaults to Prism's `NodeSchema`. */\n schema?: ZodType;\n};\n\nexport const prismPlugin = (options: PrismPluginOptions): LoomPlugin => ({\n name: 'prism',\n documents: { config: options.schema ?? (NodeSchema as ZodType) },\n widgets: [{ role: NODE, match: (field) => field.kind === 'union' && field.path === '' }],\n mount: (editor) =>\n mountView(editor, previewAction, (e) => ({ config: (e.documents as Record<string, unknown>)['config'] })),\n});\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/editor/view.ts"],"names":[],"mappings":";AAQO,IAAM,SAAA,GAAY,CACvB,MAAA,EACA,MAAA,EACA,IAAA,KACS;AACT,EAAA,MAAM,EAAE,OAAM,GAAI,MAAA;AAClB,EAAA,KAAA,CAAM,eAAe,MAAM,CAAA;AAC3B,EAAA,KAAA,CAAM,SAAA,CAAU,EAAE,EAAA,EAAI,MAAA,CAAO,IAAI,OAAA,EAAS,MAAA,CAAO,IAAI,CAAA;AACrD,EAAA,MAAM,WAAW,KAAA,CAAM,cAAA,CAAe,MAAA,CAAO,EAAE,EAAE,MAAA,EAAQ,EAAA;AACzD,EAAA,IAAI,aAAa,MAAA,EAAW;AAC5B,EAAA,MAAM,OAAO,MAAY;AACvB,IAAA,KAAA,CAAM,WAAW,QAAQ,CAAA,EAAG,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;AAAA,EAClD,CAAA;AACA,EAAA,MAAA,CAAO,EAAA,CAAG,UAAU,IAAI,CAAA;AACxB,EAAA,IAAA,EAAK;AACP","file":"chunk-D743DI5J.js","sourcesContent":["import type { ActionDefinition } from '@niscorp/nova';\nimport type { LoomEditor } from './types.js';\n\n// Mount a view canvas: register `action`, add a canvas that renders it, and keep\n// its data in sync with the editor's live state — `read(editor)` is pushed onto\n// the canvas on every `change`. The canvas id is the action id. Used by the\n// default plugins (jsonviewer, validation) and any domain preview; the contributor\n// owns the canvas, so a later plugin can `shell.removeCanvas(action.id)` to drop it.\nexport const mountView = (\n editor: LoomEditor,\n action: ActionDefinition,\n read: (editor: LoomEditor) => Record<string, unknown>,\n): void => {\n const { shell } = editor;\n shell.registerAction(action);\n shell.addCanvas({ id: action.id, initial: action.id });\n const instance = shell.getCanvasState(action.id).active?.id;\n if (instance === undefined) return;\n const sync = (): void => {\n shell.getRuntime(instance)?.setData(read(editor));\n };\n editor.on('change', sync);\n sync();\n};\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/plugins/nova/schema.ts","../src/plugins/nova/data.layout.ts","../src/plugins/nova/preview.layout.ts","../src/plugins/nova/preview.action.ts","../src/plugins/nova/index.ts"],"names":[],"mappings":";;;;AAWO,IAAM,YAAA,GAAe,CAAC,QAAA,KAAqD;AAChF,EAAA,MAAM,CAAC,KAAA,EAAO,GAAG,IAAI,CAAA,GAAI,QAAA;AACzB,EAAA,IAAI,KAAA,KAAU,MAAA,EAAW,MAAM,IAAI,MAAM,oCAAoC,CAAA;AAE7E,EAAA,MAAM,KAAA,GAAiB,CAAA,CAAE,IAAA,CAAK,MAAM,UAAU,CAAA;AAC9C,EAAA,MAAM,MAAA,GAAS,CAAC,SAAA,KACd,CAAA,CAAE,MAAA,CAAO;AAAA,IACP,SAAA,EAAW,CAAA,CAAE,OAAA,CAAQ,SAAA,CAAU,IAAI,CAAA;AAAA,IACnC,OAAO,SAAA,CAAU,KAAA;AAAA,IACjB,GAAI,SAAA,CAAU,SAAA,KAAc,IAAA,GAAO,EAAE,QAAA,EAAU,CAAA,CAAE,KAAA,CAAM,KAAK,CAAA,EAAE,GAAI;AAAC,GACpE,CAAA;AAEH,EAAA,MAAM,UAAA,GAAa,CAAA,CAAE,kBAAA,CAAmB,WAAA,EAAa,CAAC,MAAA,CAAO,KAAK,CAAA,EAAG,GAAG,IAAA,CAAK,GAAA,CAAI,MAAM,CAAC,CAAC,CAAA;AACzF,EAAA,OAAO,UAAA;AACT;;;AClBA,IAAM,QAAA,GAAW,CAAC,GAAA,EAAa,KAAA,MAAgC;AAAA,EAC7D,SAAA,EAAW,YAAA;AAAA,EACX,KAAA,EAAO,EAAE,KAAA,EAAO,GAAA,EAAI;AAAA,EACpB,QAAA,EAAU,CAAC,EAAE,SAAA,EAA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ZodType } from 'zod';\n\n// The framework-free shape of one component in the manifest: its name, the schema\n// for its props, and whether it nests children. The render function (React, Vue,\n// …) lives in the per-framework surface, not here.\nexport type NovaComponentShape = { name: string; props: ZodType; container?: boolean };\n\n// Build the layout document's schema. Each component becomes a branch\n// discriminated by its `component` literal, carrying its prop schema; containers\n// recurse through `children`. This is the shape of a Nova ComponentNode, so the\n// edited `layout` document is itself a layout.\nexport const layoutSchema = (manifest: readonly NovaComponentShape[]): ZodType => {\n const [first, ...rest] = manifest;\n if (first === undefined) throw new Error('nova plugin: the manifest is empty');\n\n const recur: ZodType = z.lazy(() => layoutNode);\n const branch = (component: NovaComponentShape) =>\n z.object({\n component: z.literal(component.name),\n props: component.props,\n ...(component.container === true ? { children: z.array(recur) } : {}),\n });\n\n const layoutNode = z.discriminatedUnion('component', [branch(first), ...rest.map(branch)]);\n return layoutNode;\n};\n","import type { LayoutNode } from '@niscorp/nova';\nimport { isRecord } from '@compile/parse';\n\n// The data document's editing layout — the nova plugin builds it from the data's\n// own keys (the freeform key→value map the layout binds to). One field per key,\n// each control bound to `$.<key>`, a writable path (the bare root `$` is not). A\n// string value edits as a text input; anything else as a JSON editor.\nconst fieldFor = (key: string, value: unknown): LayoutNode => ({\n component: 'loom:field',\n props: { label: key },\n children: [{ component: typeof value === 'string' ? 'loom:text' : 'loom:raw', model: `$.${key}` }],\n});\n\nexport const dataLayout = (value: unknown): LayoutNode => {\n const data = isRecord(value) ? value : {};\n return {\n component: 'Stack',\n props: { direction: 'column', gap: 12 },\n children: Object.keys(data).map((key) => fieldFor(key, data[key])),\n };\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 framework\n// surface registers the component under it; the core's mount references it.\nexport const PREVIEW = 'nova:preview';\n\n// The preview layout: one component bound to the editor's live documents (the\n// layout + its data). The component renders the layout against the data with Nova.\nexport const previewLayout: LayoutNode = {\n component: PREVIEW,\n props: { documents: '$.documents' },\n};\n","import type { ActionDefinition } from '@niscorp/nova';\nimport { previewLayout, PREVIEW } from './preview.layout.js';\n\n// The preview action: the preview layout over a `documents` data slot the mount\n// keeps in sync. Canvas id equals the action id (PREVIEW).\nexport const previewAction: ActionDefinition = {\n id: PREVIEW,\n layout: previewLayout,\n data: { documents: {} },\n};\n","import { mountView } from '@editor/view';\nimport type { LoomPlugin } from '@editor/types';\nimport { layoutSchema, type NovaComponentShape } from './schema.js';\nimport { dataLayout } from './data.layout.js';\nimport { previewAction } from './preview.action.js';\n\n// @niscorp/loom/plugins/nova — the Nova plugin (framework-free).\n//\n// A Nova layout has two documents: the `layout` (a component tree, its schema\n// derived from the component manifest) and the `data` its bindings (`$.x`)\n// resolve against. The plugin declares both and contributes the preview canvas;\n// the per-framework surface (./react) supplies the preview component.\n\nexport { PREVIEW } from './preview.layout.js';\nexport { layoutSchema, type NovaComponentShape } from './schema.js';\n\nexport type NovaPluginConfig = { manifest: readonly NovaComponentShape[] };\n\nexport const novaPlugin = (config: NovaPluginConfig): LoomPlugin => ({\n name: 'nova',\n documents: {\n layout: layoutSchema(config.manifest),\n // `data` is freeform (its shape follows the layout's bindings), so it has no\n // schema. The plugin builds its editing layout from the data's keys instead.\n data: dataLayout,\n },\n // The preview is a Nova concept, not a Loom one, so the plugin contributes it:\n // a view canvas rendering the preview component bound to the live documents.\n mount: (editor) => mountView(editor, previewAction, (e) => ({ documents: e.documents })),\n});\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/react/kit/fields.tsx","../src/react/kit/controls.tsx","../src/react/kit/variant.tsx","../src/react/kit/array.tsx","../src/react/kit/index.ts","../src/react/hooks/document.ts"],"names":["jsx","jsxs","createContext","useContext"],"mappings":";;;;;;;AAMA,IAAM,UAAA,GAA4B,EAAE,OAAA,EAAS,MAAA,EAAQ,eAAe,QAAA,EAAS;AAC7E,IAAM,UAAA,GAA4B,EAAE,QAAA,EAAU,EAAA,EAAI,YAAY,GAAA,EAAK,YAAA,EAAc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A,CAAM,OAAO,GAAG,WAAA;AAAA,EACjB,CAAC,KAAA,CAAM,IAAI,GAAG,QAAA;AAAA,EACd,CAAC,KAAA,CAAM,MAAM,GAAG,UAAA;AAAA,EAChB,CAAC,KAAA,CAAM,QAAQ,GAAG,YAAA;AAAA,EAClB,CAAC,KAAA,CAAM,MAAM,GAAG,UAAA;AAAA,EAChB,CAAC,KAAA,CAAM,GAAG,GAAG,OAAA;AAAA,EACb,CAAC,WAAW,GAAG;AACjB;AAEO,IAAM,qBAAqB,MAAwC;AACxE,EAAA,MAAM,WAAW,uBAAA,EAAuC;AACxD,EAAA,QAAA,CAAS,YAAY,cAAc,CAAA;AACnC,EAAA,OAAO,QAAA;AACT;ACnCO,IAAM,mBAAA,GAAsBE,cAA4B,MAAS;AAEjE,IAAM,eAAA,GAAkB,MAAoBC,UAAAA,CAAW,mBAAmB","file":"chunk-IZ5B6IMX.js","sourcesContent":["import type { CSSProperties } from 'react';\nimport type { NovaComponent } from '@niscorp/nova/adapters/react';\n\n// The layout + field shells: the group heading and the per-field wrapper\n// (label / description / required marker / error) around one control.\n\nconst groupStyle: CSSProperties = { display: 'flex', flexDirection: 'column' };\nconst titleStyle: CSSProperties = { fontSize: 15, fontWeight: 700, marginBottom: 8, color: '#111827' };\nconst fieldStyle: CSSProperties = { display: 'flex', flexDirection: 'column', gap: 4, marginBottom: 12 };\nconst labelStyle: CSSProperties = { fontSize: 13, fontWeight: 600, color: '#374151' };\nconst hintStyle: CSSProperties = { fontSize: 12, color: '#6b7280' };\n\nexport const LoomGroup: NovaComponent<{ title?: string }> = ({ title, children }) => (\n <div style={groupStyle}>\n {title !== undefined ? <div style={titleStyle}>{title}</div> : null}\n {children}\n </div>\n);\n\nexport const LoomField: NovaComponent<{\n label?: string;\n description?: string;\n required?: boolean;\n // Resolved from the error channel: a string at a leaf path, the error\n // sub-tree at a container path (rendered only when it's a string).\n error?: unknown;\n // A plain <div>, not a <label>: a field can wrap composite content (an\n // object group, an array with its own buttons), and a <label> would\n // capture every control inside it as its target.\n}> = ({ label, description, required, error, children }) => (\n <div style={fieldStyle}>\n <span style={labelStyle}>\n {label}\n {required ? <span style={{ color: '#dc2626' }}> *</span> : null}\n </span>\n {description !== undefined ? <span style={hintStyle}>{description}</span> : null}\n {children}\n {typeof error === 'string' ? <span style={{ ...hintStyle, color: '#dc2626' }}>{error}</span> : null}\n </div>\n);\n","import type { NovaComponent } from '@niscorp/nova/adapters/react';\nimport { useModelWrite } from '../hooks/model.js';\nimport { inputStyle } from './shared.js';\nimport { JsonEditor } from './json-editor.js';\n\n// The leaf controls: each reads its value from the auto-bound `value` prop and\n// writes back through `useModelWrite`.\n\nconst HTML_INPUT_TYPE: Record<string, string> = { email: 'email', uri: 'url', date: 'date' };\n\nexport const LoomText: NovaComponent<{ value?: unknown; format?: string; placeholder?: string }> = ({\n value,\n format,\n placeholder,\n novaModel,\n}) => {\n const set = useModelWrite(novaModel);\n return (\n <input\n type={HTML_INPUT_TYPE[format ?? ''] ?? 'text'}\n placeholder={placeholder}\n value={String(value ?? '')}\n onChange={(event) => set(event.target.value)}\n style={inputStyle}\n />\n );\n};\n\nexport const LoomNumber: NovaComponent<{ value?: unknown }> = ({ value, novaModel }) => {\n const set = useModelWrite(novaModel);\n return (\n <input\n type=\"number\"\n value={Number.isFinite(value) ? (value as number) : ''}\n onChange={(event) => {\n const raw = event.target.value;\n set(raw ? Number(raw) : null);\n }}\n style={inputStyle}\n />\n );\n};\n\nexport const LoomCheckbox: NovaComponent<{ value?: unknown }> = ({ value, novaModel }) => {\n const set = useModelWrite(novaModel);\n return (\n <input\n type=\"checkbox\"\n checked={Boolean(value)}\n onChange={(event) => set(event.target.checked)}\n style={{ width: 16, height: 16 }}\n />\n );\n};\n\nexport const LoomSelect: NovaComponent<{\n value?: unknown;\n options?: { value: unknown; label: string }[];\n}> = ({ value, options, novaModel }) => {\n const set = useModelWrite(novaModel);\n // A <select> speaks strings: an option is offered as its text and the choice\n // comes back as that text. What is written is the option's OWN value — an\n // enum's values may be numbers, and its schema refuses \"2\" where it means 2.\n const choose = (text: string): void => {\n const chosen = (options ?? []).find((option) => String(option.value) === text);\n set(chosen === undefined ? text : chosen.value);\n };\n return (\n <select value={String(value ?? '')} onChange={(event) => choose(event.target.value)} style={inputStyle}>\n {(options ?? []).map((option) => (\n <option key={String(option.value)} value={String(option.value)}>\n {option.label}\n </option>\n ))}\n </select>\n );\n};\n\n// The raw role: JsonEditor wired to the model.\nexport const LoomRaw: NovaComponent<{ value?: unknown }> = ({ value, novaModel }) => {\n const set = useModelWrite(novaModel);\n return <JsonEditor value={value} onChange={set} />;\n};\n","import { createContext, useContext, type CSSProperties } from 'react';\nimport type { NovaComponent } from '@niscorp/nova/adapters/react';\nimport { isRecord } from '@compile/parse';\nimport type { Pattern } from '@compile/types';\nimport { useModelWrite } from '../hooks/model.js';\nimport { decodeLiteral, inputStyle, matches } from './shared.js';\n\n// The union editor and its branch wrappers.\n\nconst variantStyle: CSSProperties = { display: 'flex', flexDirection: 'column', gap: 12 };\n\ntype Branch = { label: string; pattern: Pattern; defaults: unknown; childrenKey?: string };\n\n// The active branch index, shared from the variant down to its branch wrappers.\nconst ActiveBranch = createContext(0);\n\n// One branch of a variant — renders its editor only when it is the active one.\nexport const LoomBranch: NovaComponent<{ index?: number }> = ({ index, children }) =>\n useContext(ActiveBranch) === index ? <>{children}</> : null;\n\n// A union editor: a type chooser plus the active branch. It matches the current\n// value to a branch in JS, tells the branches which is active (via context), and\n// each shows or hides itself; on change it writes the chosen branch's default,\n// reshaping the value. Tagged, structural, and mixed unions are the same code —\n// only the pattern differs.\nexport const LoomVariant: NovaComponent<{ value?: unknown; branches?: unknown }> = ({\n value,\n branches,\n children,\n novaModel,\n}) => {\n const set = useModelWrite(novaModel);\n const options = decodeLiteral<Branch[]>(branches) ?? [];\n // The first branch whose pattern matches the value; failing that, the open\n // `fallback` branch (which never matches positively), else the first branch.\n const matched = options.findIndex((branch) => matches(value, branch.pattern));\n const fallback = options.findIndex((branch) => branch.pattern.kind === 'fallback');\n const active = matched >= 0 ? matched : Math.max(0, fallback);\n // Switching between two container variants carries the children over; switching\n // to one without a child-list drops them (after a confirm).\n const switchTo = (chosen: Branch): void => {\n const activeKey = options[active]?.childrenKey;\n const oldChildren = activeKey !== undefined && isRecord(value) ? value[activeKey] : undefined;\n if (chosen.childrenKey !== undefined && Array.isArray(oldChildren)) {\n set({ ...(isRecord(chosen.defaults) ? chosen.defaults : {}), [chosen.childrenKey]: oldChildren });\n return;\n }\n if (Array.isArray(oldChildren) && oldChildren.length > 0 && !window.confirm('This type has no children. Discard them?')) return;\n set(chosen.defaults);\n };\n return (\n <div style={variantStyle}>\n <select\n value={active}\n onChange={(event) => {\n const chosen = options[Number(event.target.value)];\n if (chosen !== undefined) switchTo(chosen);\n }}\n style={inputStyle}\n >\n {options.map((branch, index) => (\n <option key={index} value={index}>\n {branch.label}\n </option>\n ))}\n </select>\n <ActiveBranch.Provider value={active}>{children}</ActiveBranch.Provider>\n </div>\n );\n};\n","import type { CSSProperties } from 'react';\nimport type { NovaComponent } from '@niscorp/nova/adapters/react';\nimport { isRecord } from '@compile/parse';\nimport type { Pattern } from '@compile/types';\nimport { LOOM_COLUMN } from '@editor/default.layout';\nimport { useModelWrite } from '../hooks/model.js';\nimport { decodeLiteral, inputStyle, matches } from './shared.js';\nimport { ActionMenu, MenuItem, SubMenu } from './menu.js';\n\n// The array container, its item cells, the editor's canvas column, and the\n// list-mutating actions (append + the per-row menu).\n\nconst arrayStyle: CSSProperties = { display: 'flex', flexDirection: 'column', gap: 8, padding: 12, border: '1px dashed #d1d5db', borderRadius: 6 };\nconst arrayItemStyle: CSSProperties = { display: 'flex', gap: 6, alignItems: 'flex-start' };\nconst itemEditorStyle: CSSProperties = { flex: 1, minWidth: 0 };\nconst addButtonStyle: CSSProperties = { ...inputStyle, alignSelf: 'flex-start', cursor: 'pointer', background: '#f3f4f6' };\n\n// Holds the rendered items (the compiled loop) plus the add button.\nexport const LoomArray: NovaComponent = ({ children }) => <div style={arrayStyle}>{children}</div>;\n\n// One item's row, laid out left-to-right: the editor cell (a `box`, which grows)\n// then the actions menu. The compiler wraps the editor in the box, so this is a\n// plain flex row — no splitting of children (Nova hands them as one tree).\nexport const LoomArrayItem: NovaComponent = ({ children }) => <div style={arrayItemStyle}>{children}</div>;\n\n// A flexible cell that grows to fill its row — the array item's editor lives in one.\nexport const LoomBox: NovaComponent = ({ children }) => <div style={itemEditorStyle}>{children}</div>;\n\n// A sized column for the editor's canvasLayout: grows to share the row but won't\n// shrink below `min`, so columns don't squish. The one layout primitive no Nova\n// builtin provides (Stack/Box can't size a child).\nexport const LoomColumn: NovaComponent<{ grow?: number; min?: number }> = ({ grow, min, children }) => {\n const style: CSSProperties = { flexGrow: grow ?? 1, flexShrink: 1, flexBasis: min ?? 320, minWidth: min ?? 320 };\n return <div style={style}>{children}</div>;\n};\n\n// Grows a recursive list: bound to the list as its model, it appends a default\n// `child` and writes the new array back through `ui:model` — the same pipeline a\n// control edit uses, so the resolved path is correct at any depth. This is how a\n// node deeper in a tree gains a child without a static push target.\nexport const LoomAppend: NovaComponent<{ label?: string; value?: unknown; child?: unknown }> = ({\n label,\n value,\n child,\n novaModel,\n}) => {\n const set = useModelWrite(novaModel);\n const onClick = (): void => {\n const current = Array.isArray(value) ? value : [];\n set([...current, decodeLiteral(child)]);\n };\n return (\n <button type=\"button\" onClick={onClick} style={addButtonStyle}>\n {label ?? 'Add'}\n </button>\n );\n};\n\n// Move `from` to `to`, clamped — out-of-range (past either end) is a no-op.\nconst reorder = (list: readonly unknown[], from: number, to: number): unknown[] => {\n if (to < 0 || to >= list.length) return [...list];\n const next = [...list];\n const [moved] = next.splice(from, 1);\n next.splice(to, 0, moved);\n return next;\n};\n\n// A container variant the menu can wrap an element into, or recognize for\n// unwrap. `key` holds the child-list. Mirror of the compiler's `Container`.\ntype RowContainer = { label: string; pattern: Pattern; defaults: unknown; key: string };\n\n// The per-row actions menu. Bound to the loop's `$items` (the whole list), so\n// `value` is the list and a write replaces it; `index` is this row. Move and\n// remove always; wrap (into each container variant) and unwrap (when this row is\n// a container) appear only when `containers` is non-empty. All are array writes.\nexport const LoomRowMenu: NovaComponent<{\n index?: unknown;\n containers?: unknown;\n value?: unknown;\n}> = ({ index, containers, value, novaModel }) => {\n const set = useModelWrite(novaModel);\n const i = Number(index);\n const list = Array.isArray(value) ? value : undefined;\n if (list === undefined || !Number.isInteger(i)) return null;\n\n const element = list[i];\n const targets = decodeLiteral<RowContainer[]>(containers) ?? [];\n const unwrapTarget = targets.find((container) => matches(element, container.pattern));\n const wrapInto = (container: RowContainer): unknown[] => [\n ...list.slice(0, i),\n { ...(isRecord(container.defaults) ? container.defaults : {}), [container.key]: [element] },\n ...list.slice(i + 1),\n ];\n\n return (\n <ActionMenu>\n <MenuItem label=\"↑ Move up\" onSelect={() => set(reorder(list, i, i - 1))} disabled={i === 0} />\n <MenuItem label=\"↓ Move down\" onSelect={() => set(reorder(list, i, i + 1))} disabled={i === list.length - 1} />\n {targets.length > 0 ? (\n <SubMenu label=\"⧉ Wrap in\">\n {targets.map((container, k) => (\n <MenuItem key={k} label={container.label} onSelect={() => set(wrapInto(container))} />\n ))}\n </SubMenu>\n ) : null}\n {unwrapTarget !== undefined ? (\n <MenuItem\n label=\"⇲ Unwrap\"\n onSelect={() => {\n const children = isRecord(element) && Array.isArray(element[unwrapTarget.key]) ? (element[unwrapTarget.key] as unknown[]) : [];\n set([...list.slice(0, i), ...children, ...list.slice(i + 1)]);\n }}\n />\n ) : null}\n <MenuItem label=\"✕ Remove\" onSelect={() => set(list.filter((_, j) => j !== i))} />\n </ActionMenu>\n );\n};\n\nexport { LOOM_COLUMN };\n","import { createComponentRegistry, type ComponentRegistry } from '@niscorp/nova';\nimport type { NovaComponent } from '@niscorp/nova/adapters/react';\nimport { Roles } from '@compile/roles';\nimport { LOOM_COLUMN } from '@editor/default.layout';\nimport { LoomGroup, LoomField } from './fields.js';\nimport { LoomText, LoomNumber, LoomCheckbox, LoomSelect, LoomRaw } from './controls.js';\nimport { LoomBranch, LoomVariant } from './variant.js';\nimport { LoomArray, LoomArrayItem, LoomBox, LoomColumn, LoomAppend, LoomRowMenu } from './array.js';\n\n// The default Loom widget kit: one React component per role the compiler emits,\n// plus the editor's `loom:column`. Swapping the kit = registering different\n// components under the same role names.\n\nexport { LoomGroup, LoomField } from './fields.js';\nexport { LoomText, LoomNumber, LoomCheckbox, LoomSelect, LoomRaw } from './controls.js';\nexport { LoomBranch, LoomVariant } from './variant.js';\nexport { LoomArray, LoomArrayItem, LoomBox, LoomColumn, LoomAppend, LoomRowMenu } from './array.js';\nexport { JsonEditor } from './json-editor.js';\nexport { ActionMenu, MenuItem, SubMenu } from './menu.js';\n\n// Role → component. Keyed by the `Roles` constants, so the kit and the compiler\n// can never disagree on a name.\nexport const loomComponents: Record<string, NovaComponent> = {\n [Roles.group]: LoomGroup,\n [Roles.field]: LoomField,\n [Roles.box]: LoomBox,\n [Roles.array]: LoomArray,\n [Roles.arrayItem]: LoomArrayItem,\n [Roles.variant]: LoomVariant,\n [Roles.branch]: LoomBranch,\n [Roles.append]: LoomAppend,\n [Roles.rowMenu]: LoomRowMenu,\n [Roles.text]: LoomText,\n [Roles.number]: LoomNumber,\n [Roles.checkbox]: LoomCheckbox,\n [Roles.select]: LoomSelect,\n [Roles.raw]: LoomRaw,\n [LOOM_COLUMN]: LoomColumn,\n};\n\nexport const createLoomRegistry = (): ComponentRegistry<NovaComponent> => {\n const registry = createComponentRegistry<NovaComponent>();\n registry.registerAll(loomComponents);\n return registry;\n};\n","import { createContext, useContext } from 'react';\n\n// The document the editor is currently editing, available to widgets. A widget\n// gets its own field value as a prop; useLoomDocument gives it the whole\n// document, for widgets that need other fields (e.g. a Vex field-path picker\n// reading the query's `from`).\n\nexport type LoomDocument = Record<string, unknown> | undefined;\n\nexport const LoomDocumentContext = createContext<LoomDocument>(undefined);\n\nexport const useLoomDocument = (): LoomDocument => useContext(LoomDocumentContext);\n"]}
@@ -1 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EAAA,EAAM,iBAAM,CAAA,GAAU;AAAA;AAAA,GACtD;AAEJ;AAGO,IAAM,OAAA,GAAyD,CAAC,EAAE,KAAA,EAAO,UAAS,KAAM;AAC7F,EAAA,MAAM,EAAE,MAAA,EAAO,GAAI,UAAA,CAAW,WAAW,CAAA;AACzC,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAID,SAAS,KAAK,CAAA;AACtC,EAAA,4BACG,KAAA,EAAA,EAAI,KAAA,EAAO,EAAE,QAAA,EAAU,YAAW,EAAG,YAAA,EAAc,MAAM,OAAA,CAAQ,IAAI,CAAA,EAAG,YAAA,EAAc,MAAM,OAAA,CAAQ,KAAK,CAAA,EACxG,QAAA,EAAA;AAAA,oBAAA,IAAA,CAAC,QAAA,EAAA,EAAO,IAAA,EAAK,QAAA,EAAS,SAAA,EAAU,kBAAiB,OAAA,EAAS,MAAM,OAAA,CAAQ,CAAC,GAAA,KAAQ,CAAC,GAAG,CAAA,EAAG,OAAO,SAAA,EAC7F,QAAA,EAAA;AAAA,sBAAAC,GAAAA,CAAC,UAAM,QAAA,EAAA,KAAA,EAAM,CAAA;AAAA,sBACbA,GAAAA,CAAC,MAAA,EAAA,EAAK,QAAA,EAAA,QAAA,EAAC;AAAA,KAAA,EACT,CAAA;AAAA,IACC,IAAA,mBAAOA,GAAAA,CAAC,KAAA,EAAA,EAAI,KAAA,EAAO,WAAW,OAAA,GAAU,OAAA,GAAU,QAAA,EAAW,QAAA,EAAS,CAAA,GAAS;AAAA,GAAA,EAClF,CAAA;AAEJ","file":"chunk-MIRMQPUE.js","sourcesContent":["import { useNovaDispatch, type NovaModelBinding } from '@niscorp/nova/adapters/react';\n\n// Returns a function that writes a new value to the field's bound path, through\n// the same `ui:model` pipeline the built-in controls use. A control or a plugin\n// widget calls it with its edited value.\nexport const useModelWrite = (model: NovaModelBinding | undefined): ((value: unknown) => void) => {\n const dispatch = useNovaDispatch();\n return (value) => {\n if (model !== undefined) dispatch({ type: 'ui:model', ref: model.ref, payload: value });\n };\n};\n","import type { CSSProperties } from 'react';\nimport { isRecord } from '@compile/parse';\nimport type { Pattern } from '@compile/types';\n\n// Shared by the kit's controls and structural editors.\n\nexport const inputStyle: CSSProperties = { padding: '6px 10px', border: '1px solid #d1d5db', borderRadius: 6, fontSize: 14, width: '100%', boxSizing: 'border-box' };\n\n// The value's own JS type, in the vocabulary the compiler's patterns use.\nexport const jsType = (value: unknown): string =>\n Array.isArray(value) ? 'array' : value === null ? 'null' : typeof value;\n\n// Decode a JSON-encoded literal prop (see `literal` in to-nova). The compiler\n// passes static `$`-bearing metadata (a variant's branches, a list's containers,\n// an \"add\" default) as a JSON string so Nova's resolver leaves it intact; the\n// component parses it back. Tolerates an already-decoded value or absence.\nexport const decodeLiteral = <T>(value: unknown): T | undefined =>\n typeof value === 'string' ? (JSON.parse(value) as T) : (value as T | undefined);\n\n// Does a value belong to a branch? `===` for a tag, `in` for a key, `typeof`\n// for a type — the whole of union discrimination, in plain JS. A `fallback`\n// branch never matches positively; the widget selects it only when nothing else\n// does, so it answers false here.\nexport const matches = (value: unknown, pattern: Pattern): boolean => {\n if (pattern.kind === 'tag') return isRecord(value) && value[pattern.key] === pattern.value;\n if (pattern.kind === 'key') return isRecord(value) && pattern.key in value;\n if (pattern.kind === 'type') return jsType(value) === pattern.type;\n return false;\n};\n","import { useEffect, useState, type CSSProperties, type FC } from 'react';\nimport { inputStyle } from './shared.js';\n\n// A controlled JSON editor: a textarea with pretty-printed JSON that commits only\n// when the text parses, so mid-edit invalid JSON doesn't fight the keystrokes. An\n// external change to the value reloads the buffer; the serialized-value dep makes\n// that fire on real content changes only, not on our own commits. Exported so\n// plugins can reuse it as the fallback editor for values they don't structure.\n\nconst rawStyle: CSSProperties = {\n ...inputStyle,\n margin: 0,\n fontFamily: 'ui-monospace, SFMono-Regular, Menlo, monospace',\n fontSize: 13,\n minHeight: 64,\n resize: 'vertical',\n width: '100%',\n boxSizing: 'border-box',\n};\n\nconst showJson = (value: unknown): string => JSON.stringify(value ?? null, null, 2);\n\nexport const JsonEditor: FC<{ value: unknown; onChange: (value: unknown) => void }> = ({ value, onChange }) => {\n const [text, setText] = useState(() => showJson(value));\n const [valid, setValid] = useState(true);\n const serialized = JSON.stringify(value ?? null);\n\n useEffect(() => {\n // Adopt the value only when it differs from what the buffer already holds,\n // so an external edit reloads it but our own committed edits don't churn it.\n let mine: unknown;\n try {\n mine = JSON.parse(text);\n } catch {\n setText(showJson(value));\n setValid(true);\n return;\n }\n if (JSON.stringify(mine ?? null) !== serialized) {\n setText(showJson(value));\n setValid(true);\n }\n // Keyed on the serialized value: runs only when the value's content changes.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [serialized]);\n\n return (\n <textarea\n value={text}\n spellCheck={false}\n onChange={(event) => {\n const next = event.target.value;\n setText(next);\n try {\n const parsed: unknown = JSON.parse(next);\n setValid(true);\n onChange(parsed);\n } catch {\n setValid(false);\n }\n }}\n style={valid ? rawStyle : { ...rawStyle, borderColor: '#dc2626', background: '#fef2f2' }}\n />\n );\n};\n","import { createContext, useContext, useState, type CSSProperties, type FC, type ReactNode } from 'react';\n\n// A small actions-menu primitive: a `⋯` trigger that opens a popover of items,\n// with optional fly-out submenus. Shared by the array row menu and the Prism\n// node editor so both look and behave the same. Presentational only — callers\n// supply the items and what they do.\n\nconst trigger: CSSProperties = { padding: '4px 8px', border: '1px solid #d1d5db', borderRadius: 6, background: '#fff', cursor: 'pointer', fontSize: 13, lineHeight: 1 };\nconst base: CSSProperties = { position: 'absolute', zIndex: 30, minWidth: 170, display: 'flex', flexDirection: 'column', background: '#fff', border: '1px solid #d1d5db', borderRadius: 6, boxShadow: '0 6px 16px rgba(0,0,0,0.12)', padding: 4 };\nconst menuRight: CSSProperties = { ...base, top: '100%', right: 0, marginTop: 4 };\nconst menuLeft: CSSProperties = { ...base, top: '100%', left: 0, marginTop: 4 };\n// A submenu flies away from the menu's anchored edge (and scrolls): out to the\n// left for a right-anchored menu, out to the right for a left-anchored one. No\n// gap (flush `100%`) so the pointer can cross into it without leaving the row.\nconst flyLeft: CSSProperties = { ...base, top: 0, right: '100%', maxHeight: 280, overflowY: 'auto' };\nconst flyRight: CSSProperties = { ...base, top: 0, left: '100%', maxHeight: 280, overflowY: 'auto' };\nconst itemStyle: CSSProperties = { width: '100%', boxSizing: 'border-box', textAlign: 'left', padding: '6px 10px', cursor: 'pointer', fontSize: 13, borderRadius: 4, whiteSpace: 'nowrap', display: 'flex', justifyContent: 'space-between', gap: 12 };\nconst itemDisabled: CSSProperties = { ...itemStyle, color: '#9ca3af', cursor: 'default' };\n// Hover highlight (inline styles can't express `:hover`); the class is on every\n// item, the rule injected once with the open menu.\nconst MENU_CSS = '.loom-menu-item{background:transparent;border:none;}.loom-menu-item:hover:not(:disabled){background:#f3f4f6;}';\n\ntype Anchor = 'left' | 'right';\nconst MenuContext = createContext<{ close: () => void; anchor: Anchor }>({ close: () => {}, anchor: 'right' });\n\n// The trigger plus the popover. `anchor` is which edge the popover and its\n// submenus hang from. Children are `MenuItem` / `SubMenu`.\nexport const ActionMenu: FC<{ label?: ReactNode; ariaLabel?: string; anchor?: Anchor; children: ReactNode }> = ({\n label = '⋯',\n ariaLabel = 'Actions',\n anchor = 'right',\n children,\n}) => {\n const [open, setOpen] = useState(false);\n return (\n <div style={{ position: 'relative' }}>\n <button type=\"button\" aria-label={ariaLabel} onClick={() => setOpen((was) => !was)} style={trigger}>\n {label}\n </button>\n {open ? (\n <>\n <div onMouseDown={() => setOpen(false)} style={{ position: 'fixed', inset: 0, zIndex: 29 }} />\n <div style={anchor === 'right' ? menuRight : menuLeft}>\n <style>{MENU_CSS}</style>\n <MenuContext.Provider value={{ close: () => setOpen(false), anchor }}>{children}</MenuContext.Provider>\n </div>\n </>\n ) : null}\n </div>\n );\n};\n\n// A menu row: runs its action then closes the whole menu.\nexport const MenuItem: FC<{ label: ReactNode; onSelect: () => void; disabled?: boolean }> = ({ label, onSelect, disabled }) => {\n const { close } = useContext(MenuContext);\n return (\n <button\n type=\"button\"\n className=\"loom-menu-item\"\n disabled={disabled}\n onClick={() => {\n onSelect();\n close();\n }}\n style={disabled ? itemDisabled : itemStyle}\n >\n {typeof label === 'string' ? <span>{label}</span> : label}\n </button>\n );\n};\n\n// A row that flies out a submenu of its children on hover.\nexport const SubMenu: FC<{ label: ReactNode; children: ReactNode }> = ({ label, children }) => {\n const { anchor } = useContext(MenuContext);\n const [open, setOpen] = useState(false);\n return (\n <div style={{ position: 'relative' }} onMouseEnter={() => setOpen(true)} onMouseLeave={() => setOpen(false)}>\n <button type=\"button\" className=\"loom-menu-item\" onClick={() => setOpen((was) => !was)} style={itemStyle}>\n <span>{label}</span>\n <span>▸</span>\n </button>\n {open ? <div style={anchor === 'right' ? flyLeft : flyRight}>{children}</div> : null}\n </div>\n );\n};\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/compile/roles.ts","../src/editor/default.layout.ts"],"names":[],"mappings":";AAQO,IAAM,KAAA,GAAQ;AAAA;AAAA,EAEnB,GAAA,EAAK,UAAA;AAAA;AAAA,EACL,KAAA,EAAO,YAAA;AAAA,EACP,KAAA,EAAO,YAAA;AAAA,EACP,SAAA,EAAW,iBAAA;AAAA,EACX,OAAA,EAAS,cAAA;AAAA;AAAA;AAAA,EAGT,MAAA,EAAQ,aAAA;AAAA;AAAA,EAGR,KAAA,EAAO,YAAA;AAAA;AAAA,EAGP,IAAA,EAAM,WAAA;AAAA,EACN,MAAA,EAAQ,aAAA;AAAA,EACR,QAAA,EAAU,eAAA;AAAA,EACV,MAAA,EAAQ,aAAA;AAAA,EACR,GAAA,EAAK,UAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOL,MAAA,EAAQ,aAAA;AAAA,EACR,OAAA,EAAS;AACX;;;AC3BO,IAAM,WAAA,GAAc;AAE3B,IAAM,IAAA,GAAO,CAAC,QAAA,MAAkC,EAAE,WAAW,YAAA,EAAc,KAAA,EAAO,EAAE,QAAA,EAAS,EAAE,CAAA;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AAI,OAAA,CAAQ,MAAA,GAAS,CAAA,GAAI,CAAC,MAAA,CAAO,CAAA,EAAG,GAAA,EAAK,OAAA,CAAQ,GAAA,CAAI,IAAI,CAAC,CAAC,IAAI;AAAC;AAEpE,CAAA","file":"chunk-PTXRAWJX.js","sourcesContent":["// The widget vocabulary the compiler emits as Nova component names. Each is\n// an abstract role; a kit registers a concrete component under the name, so\n// swapping the kit swaps the pixels without touching the compiler. Small and\n// stable on purpose — sub-variants ride as props, not new roles.\n//\n// Structural shapes (objects, arrays, unions) are compiled compositions of\n// these roles, not roles of their own.\n\nexport const Roles = {\n // Layout primitives — arrange other nodes.\n box: 'loom:box', // a flexible cell that grows to fill its row (an array item's editor)\n group: 'loom:group',\n array: 'loom:array',\n arrayItem: 'loom:array-item',\n variant: 'loom:variant',\n // One branch of a variant — shows itself only when it's the active branch\n // (the widget matches the value to a branch in JS and tells it through context).\n branch: 'loom:branch',\n\n // Field wrapper — label, description, error, and required marker around one control.\n field: 'loom:field',\n\n // Controls — edit a value; emit `ui:model`.\n text: 'loom:text',\n number: 'loom:number',\n checkbox: 'loom:checkbox',\n select: 'loom:select',\n raw: 'loom:raw',\n\n // List actions — model writes to the bound array (no triggers). `append` adds\n // a default element to the list it binds. `rowMenu` is the per-row actions menu\n // (move / remove, and wrap / unwrap when the list's items are a recursive union\n // with container variants); it reads `$items` and `$index` and writes the new\n // array. Both work at any depth, since the bound path resolves per render.\n append: 'loom:append',\n rowMenu: 'loom:row-menu',\n} as const;\n\nexport type Role = (typeof Roles)[keyof typeof Roles];\n","import type { LayoutNode } from '@niscorp/nova';\n\n// The editor's default canvasLayout — a plain Nova layout. The forms are the main\n// column (each in a titled, bordered panel); every other canvas (preview, JSON\n// views) stacks in a side column (those already render their own panel). No Nova\n// primitive can size a flex child, so the columns use Loom's `loom:column` (a Loom\n// component, registered with the kit). A plugin can replace the whole arrangement\n// with shell.setCanvasLayout.\n\nexport const LOOM_COLUMN = 'loom:column';\n\nconst slot = (canvasId: string): LayoutNode => ({ component: 'CanvasSlot', props: { canvasId } });\n\n// `form:data` -> `Data`. A form canvas's title is its document name.\nconst titleOf = (formId: string): string => {\n const name = formId.replace(/^form:/, '');\n return name.charAt(0).toUpperCase() + name.slice(1);\n};\n\n// A form sits in a bordered panel headed by its document name.\nconst formPanel = (formId: string): LayoutNode => ({\n component: 'Box',\n props: { border: true, radius: 8, padding: 16 },\n children: [{ component: 'loom:group', props: { title: titleOf(formId) }, children: [slot(formId)] }],\n});\n\nconst column = (grow: number, min: number, children: LayoutNode[]): LayoutNode => ({\n component: LOOM_COLUMN,\n props: { grow, min },\n children: [{ component: 'Stack', props: { direction: 'column', gap: 16 }, children }],\n});\n\nexport const defaultCanvasLayout = (formIds: string[], viewIds: string[]): LayoutNode => ({\n component: 'Stack',\n props: { direction: 'row', gap: 16, align: 'start' },\n children: [\n ...(formIds.length > 0 ? [column(2, 420, formIds.map(formPanel))] : []),\n ...(viewIds.length > 0 ? [column(1, 340, viewIds.map(slot))] : []),\n ],\n});\n"]}
@@ -1 +0,0 @@
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,IAAA,GAAO,MAAA;AACb,IAAM,KAAA,GAAQ,QAAA;AACd,IAAM,SAAA,GAAY,IAAI,IAAI,CAAA,CAAA;AAC1B,IAAM,SAAA,GAAY,QAAA;AA4ClB,IAAM,IAAA,GAAY,EAAE,IAAA,EAAM,GAAA,EAAK,MAAM,EAAA,EAAG;AAGxC,IAAM,KAAA,GAAQ,CAAC,GAAA,EAAU,GAAA,MAAsB;AAAA,EAC7C,IAAA,EAAM,CAAA,EAAG,GAAA,CAAI,IAAI,IAAI,GAAG,CAAA,CAAA;AAAA,EACxB,IAAA,EAAM,IAAI,IAAA,KAAS,EAAA,GAAK,MAAM,CAAA,EAAG,GAAA,CAAI,IAAI,CAAA,CAAA,EAAI,GAAG,C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,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-TCCN6LKV.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 seed = artifact.documents?.[name];\n const value = seed ?? 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 // A wrapped document's value need not be an object — a list, a string, a\n // number — and the compiler's `value` takes objects. Such a seed goes\n // under ROOT_KEY here, where the wrapping is the editor's own; without\n // this it was dropped and the default opened in its place. One the schema\n // refuses is still left out, and the default opens as it always did.\n const seedsRoot = wrap && seed !== undefined && seed !== null && !isRecord(seed) && document.safeParse(seed).success;\n action = seedsRoot ? { ...built.action, data: { [ROOT_KEY]: seed } } : 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"]}