@metamesh/generator-sdk 0.5.1 → 0.6.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 +21 -0
- package/README.md +146 -147
- package/dist/authoring.d.ts +57 -0
- package/dist/authoring.d.ts.map +1 -0
- package/dist/authoring.js +33 -0
- package/dist/authoring.js.map +1 -0
- package/dist/contracts.d.ts +31 -99
- package/dist/contracts.d.ts.map +1 -1
- package/dist/execute-generator.d.ts +22 -28
- package/dist/execute-generator.d.ts.map +1 -1
- package/dist/execute-generator.js +27 -32
- package/dist/execute-generator.js.map +1 -1
- package/dist/generated-parts.d.ts +1 -2
- package/dist/generated-parts.d.ts.map +1 -1
- package/dist/generated-parts.js +17 -32
- package/dist/generated-parts.js.map +1 -1
- package/dist/generator-module.d.ts +18 -40
- package/dist/generator-module.d.ts.map +1 -1
- package/dist/generator-module.js +4 -111
- package/dist/generator-module.js.map +1 -1
- package/dist/generator-package/constants.d.ts +2 -2
- package/dist/generator-package/constants.js +2 -2
- package/dist/generator-package/schemas/definition.schema.d.ts +3 -0
- package/dist/generator-package/schemas/definition.schema.d.ts.map +1 -1
- package/dist/generator-package/schemas/manifest.schema.d.ts +5 -8422
- package/dist/generator-package/schemas/manifest.schema.d.ts.map +1 -1
- package/dist/generator-package/schemas/parameter.schema.d.ts +7 -0
- package/dist/generator-package/schemas/parameter.schema.d.ts.map +1 -1
- package/dist/generator-package/schemas/parameter.schema.js +2 -0
- package/dist/generator-package/schemas/parameter.schema.js.map +1 -1
- package/dist/generator-package/schemas/preset.schema.d.ts +2 -13
- package/dist/generator-package/schemas/preset.schema.d.ts.map +1 -1
- package/dist/generator-package/schemas/preset.schema.js.map +1 -1
- package/dist/generator-package/validate-definition.d.ts.map +1 -1
- package/dist/generator-package/validate-definition.js +18 -0
- package/dist/generator-package/validate-definition.js.map +1 -1
- package/dist/generator-package/validate-manifest.d.ts.map +1 -1
- package/dist/generator-package/validate-manifest.js +2 -13
- package/dist/generator-package/validate-manifest.js.map +1 -1
- package/dist/generator-services.d.ts +1 -1
- package/dist/generator-services.d.ts.map +1 -1
- package/dist/index.d.ts +8 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -6
- package/dist/index.js.map +1 -1
- package/dist/parameter-contracts.d.ts +121 -0
- package/dist/parameter-contracts.d.ts.map +1 -0
- package/dist/parameter-contracts.js +2 -0
- package/dist/parameter-contracts.js.map +1 -0
- package/dist/parameters/issues.d.ts +14 -0
- package/dist/parameters/issues.d.ts.map +1 -0
- package/dist/parameters/issues.js +262 -0
- package/dist/parameters/issues.js.map +1 -0
- package/dist/parameters/preparation.d.ts +13 -0
- package/dist/parameters/preparation.d.ts.map +1 -0
- package/dist/parameters/preparation.js +35 -0
- package/dist/parameters/preparation.js.map +1 -0
- package/dist/parameters/recovery.d.ts +10 -0
- package/dist/parameters/recovery.d.ts.map +1 -0
- package/dist/parameters/recovery.js +124 -0
- package/dist/parameters/recovery.js.map +1 -0
- package/dist/parameters/strict.d.ts +30 -0
- package/dist/parameters/strict.d.ts.map +1 -0
- package/dist/parameters/strict.js +116 -0
- package/dist/parameters/strict.js.map +1 -0
- package/dist/parameters/values.d.ts +13 -0
- package/dist/parameters/values.d.ts.map +1 -0
- package/dist/parameters/values.js +73 -0
- package/dist/parameters/values.js.map +1 -0
- package/dist/parameters.d.ts +7 -68
- package/dist/parameters.d.ts.map +1 -1
- package/dist/parameters.js +5 -566
- package/dist/parameters.js.map +1 -1
- package/dist/parse-generator-module.d.ts +29 -0
- package/dist/parse-generator-module.d.ts.map +1 -0
- package/dist/parse-generator-module.js +137 -0
- package/dist/parse-generator-module.js.map +1 -0
- package/dist/runtime.d.ts +10 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +5 -0
- package/dist/runtime.js.map +1 -0
- package/dist/worker-contracts.d.ts +80 -0
- package/dist/worker-contracts.d.ts.map +1 -0
- package/dist/worker-contracts.js +12 -0
- package/dist/worker-contracts.js.map +1 -0
- package/package.json +14 -1
- package/dist/prepared-generator-module.d.ts +0 -24
- package/dist/prepared-generator-module.d.ts.map +0 -1
- package/dist/prepared-generator-module.js +0 -124
- package/dist/prepared-generator-module.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @metamesh/generator-sdk
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Replace format-1 validation/generation with exact format-2 prepare/build modules targeting runtime 2.0.0. Add opaque one-use preparation capture, lean authoring and host subpaths, integer numeric declarations, and canonical manufacturing output without normals.
|
|
8
|
+
|
|
9
|
+
## 0.5.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 02a1692: Keep validation errors visible when aggregate issues exceed the reporting limit, reject generated
|
|
14
|
+
part array accessors and inherited entries, and reject region islands that touch or cross a hole
|
|
15
|
+
boundary. Correct bevel and miter stroke joins, including SVG import and miter-limit fallback.
|
|
16
|
+
|
|
17
|
+
Reject asynchronous results from synchronous WASM ownership scopes and consume later native
|
|
18
|
+
Promise rejections during cleanup. Prevent nonfinite Float32 loft/revolve meshes, overflowing
|
|
19
|
+
derived tolerances, and invalid anchor normalization. Validate finite legacy path and helix
|
|
20
|
+
sampling before returning invalid geometry or allocating unrepresentable arrays. Preserve path
|
|
21
|
+
distribution and helix sampling for large finite dimensions without intermediate arithmetic
|
|
22
|
+
overflow.
|
|
23
|
+
|
|
3
24
|
## 0.5.1
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,51 +1,43 @@
|
|
|
1
1
|
# `@metamesh/generator-sdk`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Runtime-neutral contracts and helpers for Generators, hosts, and workers.
|
|
4
4
|
|
|
5
|
-
> **Preview:** `0.x` releases may
|
|
6
|
-
>
|
|
7
|
-
> after an explicit `1.0.0` review.
|
|
5
|
+
> **Preview:** `0.x` minor releases may break compatibility. Patches remain compatible within the
|
|
6
|
+
> same minor line. Stable support requires an explicit `1.0.0` review.
|
|
8
7
|
|
|
9
|
-
Install
|
|
8
|
+
Install a published release from npm:
|
|
10
9
|
|
|
11
10
|
```bash
|
|
12
11
|
pnpm add @metamesh/generator-sdk
|
|
13
12
|
```
|
|
14
13
|
|
|
15
|
-
The
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
The root contains lightweight authoring contracts and helpers. Public interfaces are explicit
|
|
15
|
+
TypeScript types and the root has no Zod, modeling, renderer, browser, or Worker dependencies.
|
|
16
|
+
Use the supported subpaths for host responsibilities:
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
| Entry | Responsibility |
|
|
19
|
+
| ------------- | ------------------------------------------------------------------------------- |
|
|
20
|
+
| Root | Definitions, presets, preparation/module authoring, parameter and service types |
|
|
21
|
+
| `/parameters` | Defaults, normalization, strict codecs, schema issues |
|
|
22
|
+
| `/runtime` | Evaluated module parsing, execution, mesh DTO parsing, Worker envelopes |
|
|
23
|
+
| `/packages` | Package, catalog and installation trust parsing |
|
|
24
|
+
| `/fonts` | Standalone font selection contract |
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
change package generation contracts. Omitted overrides preserve generated colors.
|
|
27
|
-
|
|
28
|
-
Zod is the only runtime dependency. The [public entry point](https://github.com/JasonKoolman/metamesh/blob/main/packages/generator-sdk/src/index.ts) owns exact exports;
|
|
29
|
-
strict schemas own accepted boundary data. Hosts own package delivery and execution.
|
|
26
|
+
Definitions remain callback-free and serializable. Preparation/build state is local to execution;
|
|
27
|
+
Studio owns persistence and the Modeling engine owns modeling and manufacturing finalization.
|
|
30
28
|
|
|
31
29
|
## Parameter definitions
|
|
32
30
|
|
|
33
|
-
|
|
34
|
-
`
|
|
35
|
-
|
|
36
|
-
`
|
|
37
|
-
equality/inequality, numeric comparisons, and `choice-set` membership through `contains`.
|
|
31
|
+
Parameters use a `type` discriminant: `number`, `slider`, `boolean`, `select`, `choice-set`, `color`,
|
|
32
|
+
`text`, `font`, `svg`, `profile`, or homogeneous `array`. Sliders require `min`, `max`, and `step`;
|
|
33
|
+
numbers may omit them. Visibility uses serializable `ConditionExpression` values with `all`, `any`,
|
|
34
|
+
`not`, equality/inequality, numeric comparisons, and choice-set membership (`contains`).
|
|
38
35
|
|
|
39
36
|
Define controls once, then normalize saved values or strictly parse boundary values:
|
|
40
37
|
|
|
41
38
|
```ts
|
|
42
|
-
import {
|
|
43
|
-
|
|
44
|
-
defineGenerator,
|
|
45
|
-
EMPTY_SVG_PARAMETER_DEFAULT,
|
|
46
|
-
prepareParameters,
|
|
47
|
-
type GeneratorParams,
|
|
48
|
-
} from "@metamesh/generator-sdk";
|
|
39
|
+
import { defineGenerator, type GeneratorParams } from "@metamesh/generator-sdk";
|
|
40
|
+
import { createParamCodec, prepareParameters } from "@metamesh/generator-sdk/parameters";
|
|
49
41
|
|
|
50
42
|
const definition = defineGenerator({
|
|
51
43
|
id: "sleeve",
|
|
@@ -65,14 +57,15 @@ const workerValues: unknown = { outerDiameter: 24, boreDiameter: 10 };
|
|
|
65
57
|
const strictParameters = createParamCodec(definition).parse(workerValues);
|
|
66
58
|
```
|
|
67
59
|
|
|
68
|
-
Normalization drops unknown
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
standard strings and are limited to 256 KiB each and 512 KiB per normalized project.
|
|
60
|
+
Normalization drops unknown keys, restores missing or invalid values from declared defaults,
|
|
61
|
+
clamps numbers, and returns a fresh frozen map. Strict codecs reject missing, unknown, invalid, or
|
|
62
|
+
noncanonical values and return cloned frozen structured values. `prepareParameters()` normalizes once and returns the map with schema issues. The execution
|
|
63
|
+
seam aggregates Generator preparation issues separately. Definitions accept only
|
|
64
|
+
canonical types. SVG values are strings limited to 256 KiB each and 512 KiB per normalized Project.
|
|
74
65
|
|
|
75
66
|
```ts
|
|
67
|
+
import { EMPTY_SVG_PARAMETER_DEFAULT } from "@metamesh/generator-sdk/parameters";
|
|
68
|
+
|
|
76
69
|
const profile = {
|
|
77
70
|
id: "profile",
|
|
78
71
|
label: "Profile",
|
|
@@ -81,11 +74,12 @@ const profile = {
|
|
|
81
74
|
} as const;
|
|
82
75
|
```
|
|
83
76
|
|
|
84
|
-
Choice
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
`
|
|
88
|
-
|
|
77
|
+
### Choice sets and arrays
|
|
78
|
+
|
|
79
|
+
Choice sets have uniquely valued options and a default selection array. `minSelections` and
|
|
80
|
+
`maxSelections` optionally bound its size. Normalization orders valid selections by option
|
|
81
|
+
declaration; duplicate or invalid selections recover to the canonical default. `{ param: "outputs", contains: "nut" }`
|
|
82
|
+
must reference a choice set and one of its declared options.
|
|
89
83
|
|
|
90
84
|
Array definitions declare `items.type` as `number` or `string`. They may constrain `minItems` and
|
|
91
85
|
`maxItems`; number items may also declare `min`, `max`, `step`, and `unit`. Array-valued controls are
|
|
@@ -106,43 +100,36 @@ const points = {
|
|
|
106
100
|
Groups are ordered sections with stable IDs, user-facing labels, optional descriptions, and an
|
|
107
101
|
optional `collapsed` default. Parameters without a group render in Studio's General section.
|
|
108
102
|
|
|
103
|
+
### Fonts and text
|
|
104
|
+
|
|
109
105
|
Font parameters use a `FontSelection` default with immutable `faceId`, SHA-256 `revision`, and
|
|
110
106
|
integer `weight`. Structural validation does not require the font to be available locally. Valid
|
|
111
|
-
unavailable references survive codecs, presets, and persistence. Studio prepares the
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
`withTextFonts(services.text, callback)` binds these services for `textContours()` and
|
|
116
|
-
`textMetrics()` in compiled code. The SDK and Geometry keep their small structural text contracts
|
|
117
|
-
compatible without importing each other's runtime. Font parameters and prepared text services require
|
|
118
|
-
runtime `1.2.0` or later. Package format remains 1.
|
|
119
|
-
|
|
120
|
-
`GeneratorDefinition` is callback-free, JSON-safe metadata used by forms, manifests, persistence,
|
|
121
|
-
and normalization. Its `min`, `max`, options, and other field constraints are portable
|
|
122
|
-
data. `defineGenerator()` preserves literal IDs and select options so `GeneratorParams`,
|
|
123
|
-
`GeneratorParamId`, `GeneratorIssue`, validators, defaults, and presets derive from the definition.
|
|
124
|
-
Keep derived-value, cross-parameter, warning, and geometry checks in a separate TypeScript
|
|
125
|
-
validator:
|
|
107
|
+
unavailable references survive codecs, presets, and persistence. Studio prepares declared fonts before the Generator's `prepare(parameters, services)` callback.
|
|
108
|
+
`services.text.layout(text, { font, fontSize })` returns exact vector paths and measurements in
|
|
109
|
+
millimetres. Keep that layout in the preparation value when checks and construction both need it;
|
|
110
|
+
Imported `textSection(layout)` consumes it during build. No ambient font provider is bound.
|
|
126
111
|
|
|
127
|
-
|
|
128
|
-
import { defineValidator } from "@metamesh/generator-sdk";
|
|
112
|
+
### Validation and bounds
|
|
129
113
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
: [];
|
|
134
|
-
});
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
`defineValidator()` preserves the callback's signature. Pass a parameter-only validator directly
|
|
138
|
-
to `prepareParameters()` or `validateParameters()`. For a validator that needs runtime services,
|
|
139
|
-
bind the prepared services explicitly: `(parameters) => validate(parameters, services)`. Use
|
|
114
|
+
`GeneratorDefinition` is callback-free, JSON-safe metadata for forms, manifests, persistence, and
|
|
115
|
+
normalization. `defineGenerator()` preserves literal IDs/options; `GeneratorParams` and
|
|
116
|
+
`GeneratorIssue` derive exact parameter types and issue IDs from that definition. Use
|
|
140
117
|
`definePresets(definition, presets)` to require complete definition-derived preset values.
|
|
141
118
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
119
|
+
Per-field constraints belong in the definition. Cross-parameter, warning, manufacturing and geometry
|
|
120
|
+
constraints belong in `prepare`, alongside the dimensions and samples that `build` will consume.
|
|
121
|
+
A successful result is `{ ok: true, value, issues }`; an invalid result is `{ ok: false, issues }`.
|
|
122
|
+
Successful preparation may contain warnings but no errors. Invalid preparation requires an error,
|
|
123
|
+
and prevents build and native shape construction.
|
|
124
|
+
|
|
125
|
+
Numeric parameters and numeric array items may declare `integer: true`. Their defaults and supplied
|
|
126
|
+
bounds must be integers. Strict codecs reject fractions; saved fractions recover to the declared
|
|
127
|
+
default. Numeric array recovery replaces the invalid array with its default. `step` only describes
|
|
128
|
+
the control increment and does not imply integer values.
|
|
129
|
+
|
|
130
|
+
Schema editors receive only the definition and never rewrite validators. Manifests remain
|
|
131
|
+
callback-free. Preparation receives normalized, frozen parameters; malformed issue output is a runtime error. Combined validation retains at most 100 issues, prioritizing errors over warnings
|
|
132
|
+
and preserving retained order. The reporting limit cannot hide a blocking error.
|
|
146
133
|
|
|
147
134
|
Use `getDefaultParameters(definition)` to derive a fresh frozen defaults map. IDs are bounded safe keys; package
|
|
148
135
|
manifests, definitions, descriptors, conditions, and nested parameter objects reject unknown fields.
|
|
@@ -151,11 +138,10 @@ presets to 256, and condition composition to 8 levels with 32 children per node.
|
|
|
151
138
|
|
|
152
139
|
### Editable side profiles
|
|
153
140
|
|
|
154
|
-
A `profile` declares an open side outline as a versioned `ProfileValue`.
|
|
155
|
-
|
|
156
|
-
`
|
|
157
|
-
|
|
158
|
-
shape; hosts must write resolved tangents into the controls when editing automatic points.
|
|
141
|
+
A `profile` declares an open side outline as a versioned `ProfileValue`. Start/end anchors carry
|
|
142
|
+
normalized `radius` and upward `height` coordinates, plus editing `mode` (`auto`, `smooth`, or
|
|
143
|
+
`corner`). Segments are `line` or `cubic`, with cubic `control1` and `control2` points. Coordinates
|
|
144
|
+
define the shape; hosts must resolve automatic tangents into those control points.
|
|
159
145
|
|
|
160
146
|
```ts
|
|
161
147
|
const sideProfile = {
|
|
@@ -195,8 +181,7 @@ bindings leaves the editor in normalized coordinates.
|
|
|
195
181
|
`cloneProfileValue()` returns a fresh deeply frozen value, and `profileValuesEqual()` compares both
|
|
196
182
|
shape and editing intent. Normalization, strict codecs, defaults, and presets clone every nested
|
|
197
183
|
profile object. Invalid saved profiles recover to the declared default; strict boundaries reject
|
|
198
|
-
them. Profiles cannot be condition operands.
|
|
199
|
-
package format remains `1`.
|
|
184
|
+
them. Profiles cannot be condition operands. All executable packages use format `2` and runtime major `2`.
|
|
200
185
|
|
|
201
186
|
### Curve resolution
|
|
202
187
|
|
|
@@ -219,88 +204,102 @@ const curveDeviation = {
|
|
|
219
204
|
} as const;
|
|
220
205
|
```
|
|
221
206
|
|
|
222
|
-
Multiple controls
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
affects, including shared curves across several parts. Studio does not infer part overrides from
|
|
229
|
-
mesh IDs. Resolution requests exceeding model complexity
|
|
230
|
-
limits must fail explicitly instead of silently coarsening geometry.
|
|
207
|
+
Multiple controls may have this role. Each requires `unit: "mm"`, a positive `default`, and an
|
|
208
|
+
explicit positive `min`; numeric bounds and step rules still apply. Lower values request closer
|
|
209
|
+
approximation through the Generator's `GeometryResolution` policy; exact counts remain available
|
|
210
|
+
for matched topology. Hosts show authored labels in definition order and edit the saved parameters
|
|
211
|
+
used by both preview and manufacturing. Generators determine affected curves and parts; Studio
|
|
212
|
+
does not infer overrides from mesh IDs. Requests beyond complexity limits must fail explicitly.
|
|
231
213
|
|
|
232
|
-
Packages
|
|
233
|
-
existing five module exports. Definitions without the role retain their existing behavior.
|
|
214
|
+
Packages use format `2` and runtime major `2`, including definitions with this role.
|
|
234
215
|
|
|
235
216
|
## Compiled module and output boundary
|
|
236
217
|
|
|
237
|
-
`defineGeneratorModule()`
|
|
238
|
-
|
|
218
|
+
`defineGeneratorModule()` creates the five-field format-2 surface. Preparation resolves the model
|
|
219
|
+
once; build receives that exact value. Imported modeling helpers bind to the host's synchronous build:
|
|
239
220
|
|
|
240
221
|
```ts
|
|
241
|
-
|
|
222
|
+
import { defineGeneratorModule, definePreparation, prepared } from "@metamesh/generator-sdk";
|
|
223
|
+
import { tube } from "@metamesh/modeling";
|
|
224
|
+
|
|
225
|
+
const prepareSleeve = definePreparation(definition, (parameters, { invalid }) => {
|
|
226
|
+
if (parameters.boreDiameter >= parameters.outerDiameter)
|
|
227
|
+
return invalid("boreDiameter", "The bore must be smaller than the outside diameter.");
|
|
228
|
+
return prepared({
|
|
229
|
+
outerRadius: parameters.outerDiameter / 2,
|
|
230
|
+
innerRadius: parameters.boreDiameter / 2,
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
const runtime = defineGeneratorModule({
|
|
242
234
|
definition,
|
|
243
|
-
|
|
244
|
-
|
|
235
|
+
prepare: prepareSleeve,
|
|
236
|
+
build: (dimensions) => tube({ ...dimensions, height: 20 }),
|
|
245
237
|
});
|
|
246
238
|
|
|
247
|
-
export const { formatVersion,
|
|
239
|
+
export const { formatVersion, generatorId, version, prepare, build } = runtime;
|
|
248
240
|
```
|
|
249
241
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
`
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
242
|
+
`definePreparation(definition, callback)` infers readonly parameter values, prepared data and
|
|
243
|
+
`PreparationServices<typeof definition>`. Its second callback argument retains `services.text`
|
|
244
|
+
and adds `invalid(parameterId, message)` and `invalid(issue)`, with allowed IDs checked directly at
|
|
245
|
+
each argument. Destructure `{ invalid }` or call `services.invalid(...)`. A warning alone cannot
|
|
246
|
+
produce failed preparation.
|
|
247
|
+
|
|
248
|
+
The helper returns a preparation wrapper that accepts parameters and optional host `GeneratorServices`.
|
|
249
|
+
Omitting services uses `UNPREPARED_GENERATOR_SERVICES` for direct parameter-only probes; requesting
|
|
250
|
+
text through that provider fails explicitly. Hosts pass their prepared services.
|
|
251
|
+
It adds the scoped helper for each callback invocation, preserving the exact callback result and
|
|
252
|
+
prepared value without traversal or freezing. The callback itself is not returned unchanged.
|
|
253
|
+
`prepared(value)` remains the successful-value helper. Standalone global `invalid` accepts literal
|
|
254
|
+
IDs or existing error issues; the host checks their IDs against the definition at the runtime
|
|
255
|
+
boundary.
|
|
256
|
+
|
|
257
|
+
The root helper has no decoder or Modeling runtime dependency. Modeling owns `ModelingContext`
|
|
258
|
+
and `BuildOutput`; SDK context/output generics preserve author typing without importing them.
|
|
259
|
+
Prepared values are opaque local data: the SDK does not traverse, clone, serialize or freeze them.
|
|
260
|
+
Preparation must not acquire live modeling resources. It is never persisted, transferred to the UI,
|
|
261
|
+
or reused between requests.
|
|
262
|
+
|
|
263
|
+
Hosts import `parseGeneratorModule`, `prepareGenerator` and `executeGenerator` from `/runtime`.
|
|
264
|
+
The parser requires exactly the five exports above and matching manifest identity. Evaluated
|
|
265
|
+
preparation captures an opaque value in a one-use build closure; there is no raw prepared-value
|
|
266
|
+
invocation lane. Callback results must be synchronous. The host checks the own-data preparation
|
|
267
|
+
wrapper and bounded structured issues while leaving the value opaque.
|
|
268
|
+
|
|
269
|
+
Studio's authored source surface accepts `build` and optional `prepare`. Its compiler supplies
|
|
270
|
+
identity and `prepareIdentity(definition)` when preparation is omitted, then passes the resulting
|
|
271
|
+
five-field module through this same parser and executor. Compiled packages always include `prepare`.
|
|
272
|
+
|
|
273
|
+
`prepareGenerator` normalizes once and either returns `invalid` or a prepared result containing
|
|
274
|
+
`build(context)`. Use that closure inside `engine.build()` so one engine owns modeling, mesh
|
|
275
|
+
validation, limits, measurements and cleanup. `executeGenerator` accepts a context directly and
|
|
276
|
+
returns abstract build output; it does not finalize geometry. Hosts preparing asynchronous services
|
|
277
|
+
first may supply their `/parameters` `PreparedParameters` result as `parameterState` to reuse it.
|
|
278
|
+
|
|
279
|
+
`parseGeneratedParts(parts, limits)` strictly checks the final transferable DTO. The host supplies
|
|
280
|
+
its complete limits; the SDK does not own a duplicate default resource policy. Canonical parts have
|
|
281
|
+
unique IDs, Float32 positions, Uint32 indices and optional six-digit colors. Normals belong to
|
|
282
|
+
viewport presentation. Geometric/manufacturing validation belongs to the shared engine.
|
|
283
|
+
|
|
284
|
+
Package format `1`, runtime major `1`, retired `validate/generate` module exports and extra exports
|
|
285
|
+
reject explicitly. No compatibility adapter or preparation cache remains.
|
|
292
286
|
|
|
293
287
|
## Worker boundary
|
|
294
288
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
289
|
+
Worker requests/responses are `/runtime` contracts containing structured data and transferable
|
|
290
|
+
arrays, never live modeling handles. Validation issues are normal outcomes; callback, Worker and
|
|
291
|
+
exporter exceptions use error envelopes. Finalized previews carry revision identity, bounds,
|
|
292
|
+
warnings and optional statistics. Manufacturing exports serialize the requested finalized revision,
|
|
293
|
+
including appearance overrides, without running preparation/build again.
|
|
294
|
+
|
|
295
|
+
Successful generation envelopes include `sentAt`, the sender's high-resolution epoch milliseconds
|
|
296
|
+
captured immediately before transfer. Hosts use `/runtime` `parseGenerationSentAt()` to reject
|
|
297
|
+
missing, inherited, accessor, or nonfinite timestamps before measuring transfer latency. Worker
|
|
298
|
+
clock construction and receiver timings belong to the host.
|
|
299
|
+
|
|
300
|
+
`MeshTopologyMode` is host policy rather than a Generator parameter. Both compiled and authored
|
|
301
|
+
models use the same engine finalization and limits. Studio's runtime contract owns request lifecycle,
|
|
302
|
+
revision retention and export recovery.
|
|
304
303
|
|
|
305
304
|
## Development
|
|
306
305
|
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { GeneratorDefinition, GeneratorIssue, GeneratorParams, GeneratorPreset, ParameterIssue } from "./contracts.js";
|
|
2
|
+
import type { Preparation } from "./generator-module.js";
|
|
3
|
+
import { type GeneratorServices } from "./generator-services.js";
|
|
4
|
+
/** Captures literal IDs and options; the host validates serializable metadata. */
|
|
5
|
+
export declare function defineGenerator<const D extends GeneratorDefinition>(definition: D): D;
|
|
6
|
+
/** Contextually types complete presets from the same definition as the controls. */
|
|
7
|
+
export declare function definePresets<const D extends GeneratorDefinition, const Presets extends readonly GeneratorPreset<NoInfer<D>>[]>(_definition: D, presets: Presets): Presets;
|
|
8
|
+
/** Successful worker-local preparation. The value is never cloned or inspected. */
|
|
9
|
+
export declare function prepared<P>(value: P): {
|
|
10
|
+
readonly ok: true;
|
|
11
|
+
readonly value: P;
|
|
12
|
+
readonly issues: readonly [];
|
|
13
|
+
};
|
|
14
|
+
/** Failed preparation attributed to a literal parameter ID or an existing error issue. */
|
|
15
|
+
export declare function invalid<const Id extends string>(parameterId: Id, message: string): {
|
|
16
|
+
readonly ok: false;
|
|
17
|
+
readonly issues: readonly [
|
|
18
|
+
{
|
|
19
|
+
readonly severity: "error";
|
|
20
|
+
readonly parameterId: Id;
|
|
21
|
+
readonly message: string;
|
|
22
|
+
}
|
|
23
|
+
];
|
|
24
|
+
};
|
|
25
|
+
export declare function invalid<const Issue extends ParameterIssue & {
|
|
26
|
+
readonly severity: "error";
|
|
27
|
+
}>(issue: Issue): {
|
|
28
|
+
readonly ok: false;
|
|
29
|
+
readonly issues: readonly [Issue];
|
|
30
|
+
};
|
|
31
|
+
/** Definition-bound error reporting plus the host's unchanged text service. */
|
|
32
|
+
export interface PreparationServices<D extends GeneratorDefinition> extends GeneratorServices {
|
|
33
|
+
/** Reports one error using a declared parameter ID or an existing definition-bound issue. */
|
|
34
|
+
readonly invalid: {
|
|
35
|
+
<const Id extends D["parameters"][number]["id"]>(parameterId: Id, message: string): {
|
|
36
|
+
readonly ok: false;
|
|
37
|
+
readonly issues: readonly [
|
|
38
|
+
{
|
|
39
|
+
readonly severity: "error";
|
|
40
|
+
readonly parameterId: Id;
|
|
41
|
+
readonly message: string;
|
|
42
|
+
}
|
|
43
|
+
];
|
|
44
|
+
};
|
|
45
|
+
<const Issue extends GeneratorIssue<D> & {
|
|
46
|
+
readonly severity: "error";
|
|
47
|
+
}>(issue: Issue): {
|
|
48
|
+
readonly ok: false;
|
|
49
|
+
readonly issues: readonly [Issue];
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** Wraps preparation with definition-bound services while preserving its exact result and value. */
|
|
54
|
+
export declare function definePreparation<const D extends GeneratorDefinition, Result extends Preparation<NoInfer<D>, unknown>>(_definition: D, callback: (parameters: GeneratorParams<NoInfer<D>>, services: PreparationServices<NoInfer<D>>) => Result): (parameters: GeneratorParams<D>, services?: GeneratorServices) => Result;
|
|
55
|
+
/** Parameter-only preparation is useful for models with no derived dimensions. */
|
|
56
|
+
export declare function prepareIdentity<const D extends GeneratorDefinition>(_definition: D): (parameters: GeneratorParams<D>) => ReturnType<typeof prepared<GeneratorParams<D>>>;
|
|
57
|
+
//# sourceMappingURL=authoring.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authoring.d.ts","sourceRoot":"","sources":["../src/authoring.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,eAAe,EACf,cAAc,EACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAiC,KAAK,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEhG,kFAAkF;AAClF,wBAAgB,eAAe,CAAC,KAAK,CAAC,CAAC,SAAS,mBAAmB,EAAE,UAAU,EAAE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eAAe,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,OAAO,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAGrF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { UNPREPARED_GENERATOR_SERVICES } from "./generator-services.js";
|
|
2
|
+
/** Captures literal IDs and options; the host validates serializable metadata. */
|
|
3
|
+
export function defineGenerator(definition) {
|
|
4
|
+
return definition;
|
|
5
|
+
}
|
|
6
|
+
/** Contextually types complete presets from the same definition as the controls. */
|
|
7
|
+
export function definePresets(_definition, presets) {
|
|
8
|
+
return presets;
|
|
9
|
+
}
|
|
10
|
+
/** Successful worker-local preparation. The value is never cloned or inspected. */
|
|
11
|
+
export function prepared(value) {
|
|
12
|
+
return { ok: true, value, issues: [] };
|
|
13
|
+
}
|
|
14
|
+
export function invalid(issueOrId, message) {
|
|
15
|
+
if (typeof issueOrId === "string") {
|
|
16
|
+
if (typeof message !== "string")
|
|
17
|
+
throw new TypeError("Invalid preparation needs an error message.");
|
|
18
|
+
return { ok: false, issues: [{ severity: "error", parameterId: issueOrId, message }] };
|
|
19
|
+
}
|
|
20
|
+
if (issueOrId === null || typeof issueOrId !== "object" || issueOrId.severity !== "error")
|
|
21
|
+
throw new TypeError("Invalid preparation requires an error issue.");
|
|
22
|
+
return { ok: false, issues: [issueOrId] };
|
|
23
|
+
}
|
|
24
|
+
/** Wraps preparation with definition-bound services while preserving its exact result and value. */
|
|
25
|
+
export function definePreparation(_definition, callback) {
|
|
26
|
+
return (parameters, services = UNPREPARED_GENERATOR_SERVICES) => callback(parameters, { ...services, invalid });
|
|
27
|
+
}
|
|
28
|
+
/** Parameter-only preparation is useful for models with no derived dimensions. */
|
|
29
|
+
export function prepareIdentity(_definition) {
|
|
30
|
+
void _definition;
|
|
31
|
+
return prepared;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=authoring.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authoring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