@niscorp/loom 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +118 -0
- package/DESIGN.md +38 -8
- package/README.md +28 -5
- package/dist/{chunk-LWY5TG7M.js → chunk-IZ5B6IMX.js} +7 -3
- package/dist/chunk-IZ5B6IMX.js.map +1 -0
- package/dist/{chunk-X7PCPONB.js → chunk-TCCN6LKV.js} +6 -4
- package/dist/chunk-TCCN6LKV.js.map +1 -0
- package/dist/index.cjs +4 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/{loom-editor-D5SBQ4_F.d.ts → loom-editor-Clohg49u.d.ts} +1 -1
- package/dist/{loom-editor-CQ_GI4IA.d.cts → loom-editor-MACwUjLC.d.cts} +1 -1
- package/dist/plugins/nova/index.d.cts +1 -1
- package/dist/plugins/nova/index.d.ts +1 -1
- package/dist/plugins/nova/react/index.d.cts +2 -2
- package/dist/plugins/nova/react/index.d.ts +2 -2
- package/dist/plugins/prism/index.d.cts +1 -1
- package/dist/plugins/prism/index.d.ts +1 -1
- package/dist/plugins/prism/react/index.cjs +2 -0
- package/dist/plugins/prism/react/index.cjs.map +1 -1
- package/dist/plugins/prism/react/index.d.cts +2 -2
- package/dist/plugins/prism/react/index.d.ts +2 -2
- package/dist/plugins/prism/react/index.js +2 -0
- package/dist/plugins/prism/react/index.js.map +1 -1
- package/dist/plugins/vex/index.d.cts +1 -1
- package/dist/plugins/vex/index.d.ts +1 -1
- package/dist/plugins/vex/react/index.d.cts +2 -2
- package/dist/plugins/vex/react/index.d.ts +2 -2
- package/dist/plugins/vex/react/index.js +1 -1
- package/dist/react/index.cjs +9 -3
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +3 -3
- package/dist/react/index.d.ts +3 -3
- package/dist/react/index.js +3 -3
- package/dist/{types-BonjN3CB.d.cts → types-l8sDxrMR.d.cts} +5 -1
- package/dist/{types-BonjN3CB.d.ts → types-l8sDxrMR.d.ts} +5 -1
- package/package.json +9 -8
- package/dist/chunk-LWY5TG7M.js.map +0 -1
- package/dist/chunk-X7PCPONB.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,123 @@
|
|
|
1
1
|
# @niscorp/loom
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f834f3f: `evaluate` checks a config object once and only evaluates it after that; `prismTransform` is gone. **Breaking.**
|
|
8
|
+
|
|
9
|
+
BREAKING — approved by moccadroid, 2026-10-09: replace `prismTransform` with `evaluate` (`transform: evaluate`), and pass limits as `{ limits: … }`.
|
|
10
|
+
|
|
11
|
+
Prism had three ways to run a config, and the one a host was told to hand to its seam (`prismTransform`) was the one that reported worst, while the hosts on a hot path each wrapped `evaluate`, which checked the config on every call. There are two now, with one job each.
|
|
12
|
+
|
|
13
|
+
**`evaluate(config, source, options?)`** — for a config a program holds.
|
|
14
|
+
- The first time it is handed a config object it checks it and keeps its tree; the second time it prepares the tree as `compile` would; from then on a call only evaluates. Four fields picked and renamed, the same config object again: 3.5 µs before, 0.4 µs now. A nested choice on two fields: 18 µs before, 0.7 µs now. A config that is a new object on every call costs what it did.
|
|
15
|
+
- It is kept **by the object**: a config changed in place after its first call is not read again. Hand over a new object.
|
|
16
|
+
- Both arguments are `unknown`, so it is what a host's transform seam takes: `createTide({ transform: evaluate })`, `createUpgrader(grammars, { transform: evaluate })`.
|
|
17
|
+
- The third argument is `{ limits?, check? }`. Limits were the third argument themselves: `evaluate(config, source, { maxSteps: 100 })` is now `evaluate(config, source, { limits: { maxSteps: 100 } })`.
|
|
18
|
+
- `check: 'always'` is for writing a config, for tests and for tools: nothing is kept, the config is checked on every call, and the source must be plain JSON (a source holding `undefined`, a function, a `Date` or a non-finite number is refused with `E_TYPE`).
|
|
19
|
+
- An invalid config is a `PrismError` (`E_SCHEMA`) naming the part that is wrong, however deep the config. `prismTransform` threw zod's own error, and a `RangeError` for a config nested far past the limit.
|
|
20
|
+
|
|
21
|
+
`evaluateSafe` takes the same arguments.
|
|
22
|
+
|
|
23
|
+
**`compile` and `execute`** — for a config that is stored. Unchanged.
|
|
24
|
+
|
|
25
|
+
**`prismTransform` is removed**, from `@niscorp/prism` and from `@niscorp/prism/migrations`. What it added over `evaluate` was a check that the source is plain JSON; that check is now `check: 'always'`, and a seam's source is taken as it is.
|
|
26
|
+
|
|
27
|
+
**moss, nova, vex, loom, nisc, create-nisc and the cli move with it.** Each has Prism as a peer or a dependency, or has one of those that do, and a Prism at 0.3 is outside the range their last versions accept: an app takes them together. Nothing in vex, loom or the cli changed beyond that range.
|
|
28
|
+
|
|
29
|
+
moss's shell and nova's `$prism` binding called `evaluate` on every use and so paid the check each time: an endpoint's request and response under moss, and a `$prism` value on each draw and for each row of a list, are 8 to 45 times faster for the configs measured. tide's and strata's documentation name `evaluate` where they named `prismTransform`.
|
|
30
|
+
|
|
31
|
+
**What to change**
|
|
32
|
+
- `import { prismTransform } from '@niscorp/prism'` or `'@niscorp/prism/migrations'` → `import { evaluate } from '@niscorp/prism'`, and `transform: prismTransform` → `transform: evaluate`. Every app made by `create-nisc` has this in `src/dev/strata.ts`; the app's typecheck and `npm run strata` both stop on that line until it is changed.
|
|
33
|
+
- A third argument of limits becomes `{ limits: … }`.
|
|
34
|
+
- A wrapper that parsed the config before calling `evaluate` (`evaluate(ConfigSchema.parse(config), …)`) makes a new object on every call and so is checked on every call: hand `evaluate` the config itself.
|
|
35
|
+
- Code that changes a config object in place and evaluates it again must hand over a new object, or pass `{ check: 'always' }`.
|
|
36
|
+
- A host that relied on `prismTransform` refusing a source that is not plain JSON checks it itself, or passes `{ check: 'always' }`.
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- 6512d91: Four additions to Prism, and its grammar is at version 3.
|
|
41
|
+
- **`$toNumber`** — a number from a number or from numeric text, as a form, a CSV or an API often sends it: `{ "$toNumber": { "value": { "$ref": "$.price" } } }`. Text is read when it is a number written in digits (`"42"`, `"-3.5"`, `".5"`, `" 1e3 "`). Anything else — `""`, `"12 kg"`, `"1,234"`, `true`, `null` — throws `E_TYPE`, or answers `fallback` where one is given. No other op converts: `$add` on `"4"` is still an error.
|
|
42
|
+
- **`$mod`** — the remainder of a division: `{ "$mod": [{ "$ref": "$.row" }, 2] }`. It takes the sign of the divisor, so with a positive divisor it is never negative (`[-1, 5]` is `4`, where JavaScript's `%` gives `-1`). Throws `E_DIVISION_BY_ZERO` for a zero divisor.
|
|
43
|
+
- **`$round` takes `mode`** — `"floor"` rounds down and `"ceil"` up, at the same `digits`. Without it, it rounds to the nearest, as before.
|
|
44
|
+
- **`$replace` takes `all`** — `all: true` replaces every occurrence. Without it, the first, as before. `search` is text, not a pattern.
|
|
45
|
+
|
|
46
|
+
`MAPPING_OPS` includes `$mod` and `$toNumber`, and loom's Prism editor lists both under Math.
|
|
47
|
+
|
|
48
|
+
**The grammar.** `nisc.prism` goes from 2 to 3 with one migration that rewrites nothing: these are additions, and a reader at 2 must refuse a config that uses them. The same entry records the narrowing made earlier in this release — a `$ref` path that is not keys and indexes is refused — which the JSON Schema does not show.
|
|
49
|
+
|
|
50
|
+
**What to change:** an app that keeps Prism configs in its source moves its stamp: `npm run strata upgrade`, then `npm run strata verify`. There is nothing to edit; `strata.lock.json` goes to `nisc.prism 3`. A config written before parses to exactly what it did, so a compiled IR's fingerprint does not move.
|
|
51
|
+
|
|
52
|
+
- Updated dependencies [023bcf9]
|
|
53
|
+
- Updated dependencies [1db6df4]
|
|
54
|
+
- Updated dependencies [6d098e4]
|
|
55
|
+
- Updated dependencies [8b4d97e]
|
|
56
|
+
- Updated dependencies [f834f3f]
|
|
57
|
+
- Updated dependencies [b084e30]
|
|
58
|
+
- Updated dependencies [663d724]
|
|
59
|
+
- Updated dependencies [6512d91]
|
|
60
|
+
- Updated dependencies [7d682b9]
|
|
61
|
+
- Updated dependencies [d2e9d22]
|
|
62
|
+
- Updated dependencies [e0e8abc]
|
|
63
|
+
- Updated dependencies [7fe1135]
|
|
64
|
+
- @niscorp/prism@0.3.0
|
|
65
|
+
- @niscorp/nova@0.3.0
|
|
66
|
+
- @niscorp/vex@0.3.0
|
|
67
|
+
|
|
68
|
+
## 0.2.2
|
|
69
|
+
|
|
70
|
+
### Patch Changes
|
|
71
|
+
|
|
72
|
+
- d5c9d58: README and DESIGN say what `_errors` and `validations` hold, and what the built-in select displays. They hold the messages a form shows, not the verdict on a document:
|
|
73
|
+
- They are written after a change. A new document, or a stored one just opened, has an empty `validations` until its first edit.
|
|
74
|
+
- A problem with no path is written nowhere: a `.refine()` on the whole object leaves `_errors` empty while the schema refuses the document. Given a `path`, its message lands at that field.
|
|
75
|
+
- A message on a container is dropped when a field inside it has one too.
|
|
76
|
+
- A field inside a list item or a recursive template binds no error slot: its message is in the tree and is not drawn at the field.
|
|
77
|
+
|
|
78
|
+
To decide whether a document may be kept, parse it: `schema.safeParse(editor.documents.<name>)`.
|
|
79
|
+
|
|
80
|
+
An enum with no `.default()` starts with no value in the document, and the built-in select displays its first option all the same; a `.default()` starts the two agreeing. The doc comment on `validations` says what it is, and tests hold each of these. No code changed.
|
|
81
|
+
|
|
82
|
+
**What to change:** nothing. A host that enables Save when `validations` is empty is not asking whether the document is valid.
|
|
83
|
+
|
|
84
|
+
- fa3f038: README and DESIGN say what a form guarantees. It gives every field the schema describes a control; it does not validate, so a new document and a document mid-edit can fail the schema: parse it before you keep it. Edits go to the Nova runtime's data, not to the `action.data` that `toNova` returned. A new document starts from each field's empty value (`''`, `0`, `false`, `[]`, the schema's default where it has one, `null` for a kind Loom does not model; a required enum with no default is left out), and `toNova`'s `empty` and `includeOptional` options change that. A self-reference that is not inside an array, and every kind Loom does not model, gets a raw JSON box. No code changed.
|
|
85
|
+
|
|
86
|
+
**What to change:** nothing.
|
|
87
|
+
|
|
88
|
+
- 659b81e: A document whose root is a list, a string, a number, a boolean or a tuple opens with its seed.
|
|
89
|
+
|
|
90
|
+
`createLoomEditor.open` passed a document's seed on only when it was an object. A seed its schema accepts but that is not one — `['stalls', 'circle']` for `z.array(z.string())`, `42` for `z.number()`, a string for a union with a string branch — was dropped, and the default opened in its place. `<LoomEditor>` reports its documents on mount, so a host that saves on change wrote that default over the stored document before any edit. The Prism plugin reached it too: a config that is a literal or a list of nodes (`7`, `[{ $ref: '$.a' }, …]`) opened as `{ "$ref": "" }`.
|
|
91
|
+
|
|
92
|
+
Such a seed is now what the editor opens with, reports, and draws.
|
|
93
|
+
|
|
94
|
+
Nothing else moves. A seed the schema refuses for one of these documents still opens the default, as before; an object document, and what it does with a seed that is or is not an object, is untouched; and no exported type changed — `CompileOptions.value` is as it was.
|
|
95
|
+
|
|
96
|
+
**What to change:** nothing.
|
|
97
|
+
|
|
98
|
+
- 3029c34: The kit's select writes the chosen option's own value, so an enum whose values are numbers can be set.
|
|
99
|
+
|
|
100
|
+
`LoomSelect` wrote the `<select>`'s text. For `z.enum({ stalls: 1, circle: 2 })` the options are offered as `"1"` and `"2"`, and choosing one wrote the string `"2"` — which the schema refuses (`Invalid option: expected one of 1|2`), so a document that was valid became invalid by picking a listed option, and no choice in the list could make it valid again.
|
|
101
|
+
|
|
102
|
+
It now writes the value of the option that was chosen: `2`. An enum of strings is written exactly as before, an enum of digit strings (`z.enum(['1', '2'])`) stays strings, and a mixed one (`{ a: 'x', b: 2 }`) writes each as it is.
|
|
103
|
+
|
|
104
|
+
**What to change:** nothing.
|
|
105
|
+
|
|
106
|
+
## 0.2.1
|
|
107
|
+
|
|
108
|
+
### Patch Changes
|
|
109
|
+
|
|
110
|
+
- fe30458: Every package exports its `package.json`, so an app can say which version of a package it runs by reading it from the package:
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
import prism from '@niscorp/prism/package.json' with { type: 'json' };
|
|
114
|
+
prism.version; // the version that is installed, not the range that asked for it
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Until now the `exports` map hid it, and the only way to the version was a path into `node_modules`. `check:packages` installs the tarballs and reads every package's version this way.
|
|
118
|
+
|
|
119
|
+
**What to change:** nothing. An app that read a version by path can read it by name.
|
|
120
|
+
|
|
3
121
|
## 0.2.0
|
|
4
122
|
|
|
5
123
|
### Minor Changes
|
package/DESIGN.md
CHANGED
|
@@ -52,8 +52,10 @@ described independently of how it is rendered.
|
|
|
52
52
|
Each field becomes a control bound to a path in the document by a *binding
|
|
53
53
|
expression*: `$.name` at the root, `$item` inside an array loop. Binding is how
|
|
54
54
|
Nova connects a control to a slot in the data — when the control changes, Nova
|
|
55
|
-
writes that slot
|
|
56
|
-
the document
|
|
55
|
+
writes that slot in the runtime's data (the `action.data` that `toNova` returned
|
|
56
|
+
is the starting document and is not written). The document is shaped from the
|
|
57
|
+
schema but not checked against it: an empty value can fail a constraint, and a
|
|
58
|
+
control can write a value the schema refuses.
|
|
57
59
|
|
|
58
60
|
`toNova` is the only part of Loom that speaks Nova. Everything Nova-specific
|
|
59
61
|
lives here.
|
|
@@ -126,9 +128,16 @@ not, so Loom follows the document, not the schema.
|
|
|
126
128
|
`parse` stops when it re-enters a type it is already inside and marks the
|
|
127
129
|
back-edge with a `self` node, yielding a finite model from an infinite schema.
|
|
128
130
|
`toNova` emits the recursive shape once as a named layout template authored
|
|
129
|
-
against `$item`;
|
|
130
|
-
resolves it per render against the live data. The form is
|
|
131
|
-
deep as the document, and growing or shrinking it is an
|
|
131
|
+
against `$item`; a `self` reference inside an array points back to that
|
|
132
|
+
template, and Nova resolves it per render against the live data. The form is
|
|
133
|
+
therefore exactly as deep as the document, and growing or shrinking it is an
|
|
134
|
+
ordinary list write.
|
|
135
|
+
|
|
136
|
+
This covers recursion through a list. A self-reference that is not inside an
|
|
137
|
+
array (`next: z.lazy(() => Stop).optional()`) has no list write to grow by: it
|
|
138
|
+
compiles to `loom:raw`, a raw JSON box, as does every kind outside the model
|
|
139
|
+
(records, literals, dates, transforms, intersections, a union no pattern tells
|
|
140
|
+
apart).
|
|
132
141
|
|
|
133
142
|
### Custom widgets
|
|
134
143
|
|
|
@@ -146,9 +155,30 @@ records which role a field uses.
|
|
|
146
155
|
|
|
147
156
|
Loom validates with the same schema it compiled from — there is no second source
|
|
148
157
|
of truth. `attachValidation` runs the schema's `safeParse` (refinements and all)
|
|
149
|
-
over the live document and writes
|
|
150
|
-
the data
|
|
151
|
-
`_errors` slot is stripped from the document
|
|
158
|
+
over the live document and writes the problems into a reserved `_errors` slot in
|
|
159
|
+
the data, as a tree shaped like the document: a problem at `venue.hall` is the
|
|
160
|
+
string at `_errors.venue.hall`. The `_errors` slot is stripped from the document
|
|
161
|
+
Loom reports out.
|
|
162
|
+
|
|
163
|
+
That tree, which `editor.validations` publishes per document, holds the messages
|
|
164
|
+
a form shows. It is not the verdict on the document:
|
|
165
|
+
|
|
166
|
+
- It is written after a change, not before one. A new document, or a stored one
|
|
167
|
+
just opened, has no `_errors` and an empty `validations` until its first edit,
|
|
168
|
+
whatever the schema would say of it.
|
|
169
|
+
- A problem with no path has no place in the tree and is written nowhere. A
|
|
170
|
+
`.refine()` on the whole object leaves `_errors` empty while the schema refuses
|
|
171
|
+
the document; give the refine a `path` and its message lands at that field.
|
|
172
|
+
- One slot holds one thing: a message on a container (`guests`) is dropped when
|
|
173
|
+
a field inside it has one too.
|
|
174
|
+
|
|
175
|
+
To decide whether a document may be kept, ask the schema:
|
|
176
|
+
`schema.safeParse(editor.documents.<name>)`.
|
|
177
|
+
|
|
178
|
+
A field at an absolute path (`$.venue.hall`) binds its own error slot, so its
|
|
179
|
+
message shows inline. A field inside a list item, or inside a recursive template,
|
|
180
|
+
binds none: its message is in the tree (`_errors.guests.1.name`) and is not drawn
|
|
181
|
+
at the field.
|
|
152
182
|
|
|
153
183
|
## The editor host
|
|
154
184
|
|
package/README.md
CHANGED
|
@@ -4,8 +4,10 @@ Loom builds editing UIs from schemas. Give it a [Zod](https://zod.dev) schema
|
|
|
4
4
|
and it produces a form that views, creates, and edits JSON matching that schema.
|
|
5
5
|
The form is built from the schema's structure — nested objects become nested
|
|
6
6
|
sections, arrays get add and remove controls, unions become a type picker plus
|
|
7
|
-
the fields for the chosen type — so
|
|
8
|
-
|
|
7
|
+
the fields for the chosen type — so the form has a control for every field the
|
|
8
|
+
schema describes. It does not validate for you: a new document, and a document
|
|
9
|
+
mid-edit, can fail the schema, so parse it before you keep it. There is no
|
|
10
|
+
hand-written form code; a shape Loom does not model gets a raw JSON box.
|
|
9
11
|
|
|
10
12
|
The forms render on [Nova](../nova), this stack's layout engine. Loom compiles a
|
|
11
13
|
schema into a Nova layout; Nova draws it and routes each edit back into the data.
|
|
@@ -42,11 +44,20 @@ const schema = z.object({
|
|
|
42
44
|
});
|
|
43
45
|
|
|
44
46
|
const { action, layouts } = toNova(parse(schema));
|
|
45
|
-
// `action.data` is the document
|
|
46
|
-
// to a Nova runtime to render the form.
|
|
47
|
-
//
|
|
47
|
+
// `action.data` is the document the form starts from; hand `action` and
|
|
48
|
+
// `layouts` to a Nova runtime to render the form. Edits go to the runtime's
|
|
49
|
+
// copy (`shell.getRuntime(id).getData()`), not to `action.data`, and the
|
|
50
|
+
// document can fail `schema` at any point: parse it before you keep it.
|
|
48
51
|
```
|
|
49
52
|
|
|
53
|
+
A new document starts from each field's empty value: `''`, `0`, `false`, `[]`,
|
|
54
|
+
the schema's default where it has one, and `null` for a kind Loom does not
|
|
55
|
+
model. A required enum with no default is left out. These can fail the schema
|
|
56
|
+
(`''` is not an email, `0` is not `min(1)`, `null` is not a record), and
|
|
57
|
+
optional fields get them too. `toNova(model, { empty, includeOptional })`
|
|
58
|
+
changes both: `empty` supplies a kind's starting value, `includeOptional: false`
|
|
59
|
+
leaves optional fields out.
|
|
60
|
+
|
|
50
61
|
This half is headless — no React, no DOM. Use it when you have your own Nova host
|
|
51
62
|
or only need the compiled output.
|
|
52
63
|
|
|
@@ -76,6 +87,18 @@ import { prism } from '@niscorp/loom/plugins/prism/react';
|
|
|
76
87
|
- `onChange` fires with the live document values on every edit.
|
|
77
88
|
- To switch to a different artifact, give the element a new React `key`.
|
|
78
89
|
|
|
90
|
+
Two things the built-in kit draws are worth knowing before you rely on them:
|
|
91
|
+
|
|
92
|
+
- **Messages follow edits.** The inline messages and the Validations pane show
|
|
93
|
+
what the schema said after the last edit. They are empty until the first one,
|
|
94
|
+
a problem with no field path (a `.refine()` on the whole object, without a
|
|
95
|
+
`path`) is shown nowhere, and a problem in a list row shows in the Validations
|
|
96
|
+
pane only. They are not the verdict on a document; the schema is
|
|
97
|
+
([DESIGN.md](./DESIGN.md), "Validation").
|
|
98
|
+
- **A select has no row for "none".** An enum with no `.default()` starts with no
|
|
99
|
+
value in the document, and the select displays its first option all the same.
|
|
100
|
+
Give the enum a `.default()` and the two start out agreeing.
|
|
101
|
+
|
|
79
102
|
A **plugin** wires one domain into the editor. It contributes the schemas to edit
|
|
80
103
|
(its *documents*), optional custom field widgets, and usually a preview. The three
|
|
81
104
|
reference plugins:
|
|
@@ -71,7 +71,11 @@ var LoomCheckbox = ({ value, novaModel }) => {
|
|
|
71
71
|
};
|
|
72
72
|
var LoomSelect = ({ value, options, novaModel }) => {
|
|
73
73
|
const set = useModelWrite(novaModel);
|
|
74
|
-
|
|
74
|
+
const choose = (text) => {
|
|
75
|
+
const chosen = (options ?? []).find((option) => String(option.value) === text);
|
|
76
|
+
set(chosen === void 0 ? text : chosen.value);
|
|
77
|
+
};
|
|
78
|
+
return /* @__PURE__ */ jsx("select", { value: String(value ?? ""), onChange: (event) => choose(event.target.value), style: inputStyle, children: (options ?? []).map((option) => /* @__PURE__ */ jsx("option", { value: String(option.value), children: option.label }, String(option.value))) });
|
|
75
79
|
};
|
|
76
80
|
var LoomRaw = ({ value, novaModel }) => {
|
|
77
81
|
const set = useModelWrite(novaModel);
|
|
@@ -204,5 +208,5 @@ var LoomDocumentContext = createContext(void 0);
|
|
|
204
208
|
var useLoomDocument = () => useContext(LoomDocumentContext);
|
|
205
209
|
|
|
206
210
|
export { LoomAppend, LoomArray, LoomArrayItem, LoomBox, LoomBranch, LoomCheckbox, LoomColumn, LoomDocumentContext, LoomField, LoomGroup, LoomNumber, LoomRaw, LoomRowMenu, LoomSelect, LoomText, LoomVariant, createLoomRegistry, loomComponents, useLoomDocument };
|
|
207
|
-
//# sourceMappingURL=chunk-
|
|
208
|
-
//# sourceMappingURL=chunk-
|
|
211
|
+
//# sourceMappingURL=chunk-IZ5B6IMX.js.map
|
|
212
|
+
//# sourceMappingURL=chunk-IZ5B6IMX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,CAAA,EAAG,KAAA,EAAO,SAAA,EAAU;AACrG,IAAM,UAAA,GAA4B,EAAE,OAAA,EAAS,MAAA,EAAQ,eAAe,QAAA,EAAU,GAAA,EAAK,CAAA,EAAG,YAAA,EAAc,EAAA,EAAG;AACvG,IAAM,aAA4B,EAAE,QAAA,EAAU,IAAI,UAAA,EAAY,GAAA,EAAK,OAAO,SAAA,EAAU;AACpF,IAAM,SAAA,GAA2B,EAAE,QAAA,EAAU,EAAA,EAAI,OAAO,SAAA,EAAU;AAE3D,IAAM,SAAA,GAA+C,CAAC,EAAE,KAAA,EAAO,UAAS,qBAC7E,IAAA,CAAC,KAAA,EAAA,EAAI,KAAA,EAAO,UAAA,EACT,QAAA,EAAA;AAAA,EAAA,KAAA,KAAU,yBAAY,GAAA,CAAC,KAAA,EAAA,EAAI,KAAA,EAAO,UAAA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W,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"]}
|
|
@@ -308,7 +308,8 @@ var createLoomEditor = (config) => {
|
|
|
308
308
|
const ir = parse(document);
|
|
309
309
|
const wrap = needsWrap(document);
|
|
310
310
|
if (wrap) wrappedDocs.add(name);
|
|
311
|
-
const
|
|
311
|
+
const seed = artifact.documents?.[name];
|
|
312
|
+
const value = seed ?? buildDocument(ir, {});
|
|
312
313
|
const built = toNova(ir, {
|
|
313
314
|
id: canvasId,
|
|
314
315
|
...wrap ? { rootKey: ROOT_KEY } : {},
|
|
@@ -316,7 +317,8 @@ var createLoomEditor = (config) => {
|
|
|
316
317
|
widgets: plugin.widgets ?? []
|
|
317
318
|
});
|
|
318
319
|
for (const [id, node] of Object.entries(built.layouts)) store.set(id, node);
|
|
319
|
-
|
|
320
|
+
const seedsRoot = wrap && seed !== void 0 && seed !== null && !isRecord(seed) && document.safeParse(seed).success;
|
|
321
|
+
action = seedsRoot ? { ...built.action, data: { [ROOT_KEY]: seed } } : built.action;
|
|
320
322
|
}
|
|
321
323
|
shell.registerAction(action);
|
|
322
324
|
shell.addCanvas({ id: canvasId, initial: action.id });
|
|
@@ -376,5 +378,5 @@ var createLoomEditor = (config) => {
|
|
|
376
378
|
};
|
|
377
379
|
|
|
378
380
|
export { ERROR_NAMESPACE, attachValidation, createLoomEditor, toNova };
|
|
379
|
-
//# sourceMappingURL=chunk-
|
|
380
|
-
//# sourceMappingURL=chunk-
|
|
381
|
+
//# sourceMappingURL=chunk-TCCN6LKV.js.map
|
|
382
|
+
//# sourceMappingURL=chunk-TCCN6LKV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/compile/to-nova.ts","../src/validate.ts","../src/editor/editor.ts"],"names":["stripErrors"],"mappings":";;;;;;AAqBO,IAAM,eAAA,GAAkB;AAK/B,IAAM,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,CAAA;AAClD,CAAA,CAAA;AAIA,IAAM,OAAA,GAAU,CAAC,GAAA,MAAmB,EAAE,MAAM,SAAA,EAAW,IAAA,EAAM,GAAA,CAAI,IAAA,KAAS,EAAA,GAAK,GAAA,GAAM,CAAA,EAAG,GAAA,CAAI,IAAI,CAAA,EAAA,CAAA,EAAK,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AA,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"]}
|
package/dist/index.cjs
CHANGED
|
@@ -552,7 +552,8 @@ var createLoomEditor = (config) => {
|
|
|
552
552
|
const ir = parse(document);
|
|
553
553
|
const wrap = needsWrap(document);
|
|
554
554
|
if (wrap) wrappedDocs.add(name);
|
|
555
|
-
const
|
|
555
|
+
const seed = artifact.documents?.[name];
|
|
556
|
+
const value = seed ?? buildDocument(ir, {});
|
|
556
557
|
const built = toNova(ir, {
|
|
557
558
|
id: canvasId,
|
|
558
559
|
...wrap ? { rootKey: ROOT_KEY } : {},
|
|
@@ -560,7 +561,8 @@ var createLoomEditor = (config) => {
|
|
|
560
561
|
widgets: plugin.widgets ?? []
|
|
561
562
|
});
|
|
562
563
|
for (const [id, node] of Object.entries(built.layouts)) store.set(id, node);
|
|
563
|
-
|
|
564
|
+
const seedsRoot = wrap && seed !== void 0 && seed !== null && !isRecord(seed) && document.safeParse(seed).success;
|
|
565
|
+
action = seedsRoot ? { ...built.action, data: { [ROOT_KEY]: seed } } : built.action;
|
|
564
566
|
}
|
|
565
567
|
shell.registerAction(action);
|
|
566
568
|
shell.addCanvas({ id: canvasId, initial: action.id });
|