@metamesh/generator-sdk 0.8.0 → 0.10.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.
Files changed (84) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +46 -277
  3. package/dist/contours.d.ts +36 -0
  4. package/dist/contours.d.ts.map +1 -0
  5. package/dist/contours.js +150 -0
  6. package/dist/contours.js.map +1 -0
  7. package/dist/contracts.d.ts +15 -8
  8. package/dist/contracts.d.ts.map +1 -1
  9. package/dist/curve-data.d.ts +11 -0
  10. package/dist/curve-data.d.ts.map +1 -0
  11. package/dist/curve-data.js +53 -0
  12. package/dist/curve-data.js.map +1 -0
  13. package/dist/generator-package/constants.d.ts +2 -2
  14. package/dist/generator-package/constants.js +2 -2
  15. package/dist/generator-package/errors.d.ts +19 -1
  16. package/dist/generator-package/errors.d.ts.map +1 -1
  17. package/dist/generator-package/errors.js +58 -11
  18. package/dist/generator-package/errors.js.map +1 -1
  19. package/dist/generator-package/index.d.ts +7 -2
  20. package/dist/generator-package/index.d.ts.map +1 -1
  21. package/dist/generator-package/index.js +52 -9
  22. package/dist/generator-package/index.js.map +1 -1
  23. package/dist/generator-package/portable-data.d.ts +12 -0
  24. package/dist/generator-package/portable-data.d.ts.map +1 -0
  25. package/dist/generator-package/portable-data.js +102 -0
  26. package/dist/generator-package/portable-data.js.map +1 -0
  27. package/dist/generator-package/schemas/common.schema.d.ts.map +1 -1
  28. package/dist/generator-package/schemas/common.schema.js +4 -2
  29. package/dist/generator-package/schemas/common.schema.js.map +1 -1
  30. package/dist/generator-package/schemas/definition.schema.d.ts +456 -45
  31. package/dist/generator-package/schemas/definition.schema.d.ts.map +1 -1
  32. package/dist/generator-package/schemas/definition.schema.js +5 -2
  33. package/dist/generator-package/schemas/definition.schema.js.map +1 -1
  34. package/dist/generator-package/schemas/manifest.schema.d.ts +183 -50
  35. package/dist/generator-package/schemas/manifest.schema.d.ts.map +1 -1
  36. package/dist/generator-package/schemas/manifest.schema.js.map +1 -1
  37. package/dist/generator-package/schemas/parameter-document-json-schema.d.ts +4 -0
  38. package/dist/generator-package/schemas/parameter-document-json-schema.d.ts.map +1 -0
  39. package/dist/generator-package/schemas/parameter-document-json-schema.js +17 -0
  40. package/dist/generator-package/schemas/parameter-document-json-schema.js.map +1 -0
  41. package/dist/generator-package/schemas/parameter.schema.d.ts +178 -242
  42. package/dist/generator-package/schemas/parameter.schema.d.ts.map +1 -1
  43. package/dist/generator-package/schemas/parameter.schema.js +171 -70
  44. package/dist/generator-package/schemas/parameter.schema.js.map +1 -1
  45. package/dist/generator-package/schemas/preset.schema.d.ts.map +1 -1
  46. package/dist/generator-package/schemas/preset.schema.js +4 -2
  47. package/dist/generator-package/schemas/preset.schema.js.map +1 -1
  48. package/dist/generator-package/validate-definition.d.ts +4 -7
  49. package/dist/generator-package/validate-definition.d.ts.map +1 -1
  50. package/dist/generator-package/validate-definition.js +210 -263
  51. package/dist/generator-package/validate-definition.js.map +1 -1
  52. package/dist/generator-package/validate-manifest.d.ts.map +1 -1
  53. package/dist/generator-package/validate-manifest.js +5 -5
  54. package/dist/generator-package/validate-manifest.js.map +1 -1
  55. package/dist/index.d.ts +5 -3
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +2 -1
  58. package/dist/index.js.map +1 -1
  59. package/dist/parameter-contracts.d.ts +63 -31
  60. package/dist/parameter-contracts.d.ts.map +1 -1
  61. package/dist/parameters/issues.d.ts.map +1 -1
  62. package/dist/parameters/issues.js +17 -11
  63. package/dist/parameters/issues.js.map +1 -1
  64. package/dist/parameters/recovery.d.ts.map +1 -1
  65. package/dist/parameters/recovery.js +12 -8
  66. package/dist/parameters/recovery.js.map +1 -1
  67. package/dist/parameters/strict.d.ts.map +1 -1
  68. package/dist/parameters/strict.js +8 -7
  69. package/dist/parameters/strict.js.map +1 -1
  70. package/dist/parameters/values.d.ts +1 -0
  71. package/dist/parameters/values.d.ts.map +1 -1
  72. package/dist/parameters/values.js +8 -3
  73. package/dist/parameters/values.js.map +1 -1
  74. package/dist/parameters.schema.json +1757 -0
  75. package/dist/parse-generator-module.d.ts +1 -1
  76. package/dist/parse-generator-module.js +1 -1
  77. package/dist/side-profiles.d.ts +36 -0
  78. package/dist/side-profiles.d.ts.map +1 -0
  79. package/dist/{profiles.js → side-profiles.js} +21 -66
  80. package/dist/side-profiles.js.map +1 -0
  81. package/package.json +4 -3
  82. package/dist/profiles.d.ts +0 -41
  83. package/dist/profiles.d.ts.map +0 -1
  84. package/dist/profiles.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @metamesh/generator-sdk
2
2
 
3
+ ## 0.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 0eea1b4: Add one optional static `ui.hint` string per parameter with strict metadata validation. Short, essential instructions appear inline; descriptions provide supplementary help from the question-mark button. Control visibility remains conditional. Hints are part of the format 3/runtime 3 baseline.
8
+ - 9d7052c: Separate parameter values from local UI metadata, add strict parameter-document diagnostics and a generated JSON Schema, and rename the side-profile and contour APIs. Generator packages and modules now require format 3 and runtime 3.0.0.
9
+ - cf597bd: Add optional `ui.row` metadata for two adjacent number inputs, choice dropdowns, or text controls within a parameter group. Shared rows are part of the format 3/runtime 3 baseline.
10
+
11
+ ## 0.9.0
12
+
13
+ ### Minor Changes
14
+
15
+ - e405876: Add a bounded closed XY cross-section parameter with immutable values, strict validation,
16
+ normalization, presets, and runtime compatibility checks. Add `sampleCrossSection` for physical
17
+ curve sampling and validated closed-loop geometry. Existing side-profile values remain compatible.
18
+
3
19
  ## 0.8.0
4
20
 
5
21
  ### Minor Changes
package/README.md CHANGED
@@ -1,43 +1,30 @@
1
1
  # `@metamesh/generator-sdk`
2
2
 
3
- Runtime-neutral contracts and helpers for Generators, hosts, and workers.
3
+ Turn a parametric model into a MetaMesh Generator. Define its controls once, infer parameter
4
+ types, and use the same validation contract for forms, saved values, and execution.
4
5
 
5
6
  > **Preview:** `0.x` minor releases may break compatibility. Patches remain compatible within the
6
7
  > same minor line. Stable support requires an explicit `1.0.0` review.
7
8
 
8
- Install a published release from npm:
9
-
10
9
  ```bash
11
10
  pnpm add @metamesh/generator-sdk
12
11
  ```
13
12
 
14
- The root provides lightweight authoring contracts and helpers with explicit TypeScript interfaces.
15
- It has no Zod, modeling, renderer, browser, or Worker dependencies.
16
- Use the supported subpaths for host responsibilities:
17
-
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 |
25
-
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.
13
+ | Import | Use it for |
14
+ | ------------- | ---------------------------------------------------------- |
15
+ | Package root | Definitions, presets, and preparation/module authoring |
16
+ | `/parameters` | Defaults, recovering saved values, and strict codecs |
17
+ | `/runtime` | Module execution, generated mesh data, and Worker messages |
18
+ | `/packages` | Package, catalog, and installation parsing |
19
+ | `/fonts` | Font selection values |
28
20
 
29
- ## Parameter definitions
21
+ ## Define controls
30
22
 
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`).
35
-
36
- Define controls once, then normalize saved values or strictly parse boundary values:
23
+ A definition is serializable metadata. Capture its literal IDs and options to derive exact
24
+ parameter types:
37
25
 
38
26
  ```ts
39
27
  import { defineGenerator, type GeneratorParams } from "@metamesh/generator-sdk";
40
- import { createParamCodec, prepareParameters } from "@metamesh/generator-sdk/parameters";
41
28
 
42
29
  const definition = defineGenerator({
43
30
  id: "sleeve",
@@ -50,192 +37,28 @@ const definition = defineGenerator({
50
37
  ],
51
38
  });
52
39
  type Parameters = GeneratorParams<typeof definition>;
53
-
54
- const persistedValues: Readonly<Record<string, unknown>> = { outerDiameter: 24 };
55
- const { parameters, validation } = prepareParameters(definition, persistedValues);
56
- const workerValues: unknown = { outerDiameter: 24, boreDiameter: 10 };
57
- const strictParameters = createParamCodec(definition).parse(workerValues);
58
- ```
59
-
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
63
- once and returns the map with schema issues. Execution aggregates Generator preparation issues
64
- separately. Definitions accept only
65
- canonical types. SVG values are strings limited to 256 KiB each and 512 KiB per normalized Project.
66
- The same byte limits apply to defaults and presets. Definition parsing rejects defaults that exceed
67
- the aggregate Project budget; preset parsing uses each declared control's limits, so an SVG value
68
- may exceed the separate 64 Ki-character text limit.
69
-
70
- ```ts
71
- import { EMPTY_SVG_PARAMETER_DEFAULT } from "@metamesh/generator-sdk/parameters";
72
-
73
- const profile = {
74
- id: "profile",
75
- label: "Profile",
76
- type: "svg",
77
- default: EMPTY_SVG_PARAMETER_DEFAULT,
78
- } as const;
79
- ```
80
-
81
- ### Choice sets and arrays
82
-
83
- Choice sets have uniquely valued options and a default selection array. `minSelections` and
84
- `maxSelections` optionally bound its size. Normalization orders valid selections by option
85
- declaration; duplicate or invalid selections recover to the canonical default. `{ param: "outputs", contains: "nut" }`
86
- must reference a choice set and one of its declared options.
87
-
88
- Array definitions declare `items.type` as `number` or `string`. They may constrain `minItems` and
89
- `maxItems`; number items may also declare `min`, `max`, `step`, and `unit`. Array-valued controls are
90
- cloned at normalization and persistence boundaries. Conditions may compare scalar controls or test
91
- `choice-set` membership; arbitrary arrays cannot be condition operands.
92
-
93
- ```ts
94
- const points = {
95
- id: "points",
96
- label: "Point sizes",
97
- type: "array",
98
- default: [4, 8],
99
- minItems: 1,
100
- items: { type: "number", min: 0, unit: "mm" },
101
- } as const;
102
- ```
103
-
104
- Groups are ordered sections with stable IDs, user-facing labels, optional descriptions, and an
105
- optional `collapsed` default. Parameters without a group render in Studio's General section.
106
-
107
- ### Fonts and text
108
-
109
- Font parameters use a `FontSelection` default with immutable `faceId`, SHA-256 `revision`, and
110
- integer `weight`. Structural validation does not require the font to be available locally. Valid
111
- unavailable references survive codecs, presets, and persistence. Studio prepares declared fonts before the Generator's `prepare(parameters, services)` callback.
112
- `services.text.layout(text, { font, fontSize })` returns exact vector paths and measurements in
113
- millimetres. Keep that layout in the preparation value when checks and construction both need it.
114
- Imported `textSection(layout)` consumes it during build. No ambient font provider is bound.
115
-
116
- Text layout can use `baseline: { kind: "arc", radius, centerAngleDegrees, direction }` for a single circular line. Radius is in millimetres, the angle is counterclockwise from +X (default 90°), and direction defaults to clockwise. Alignment defaults to center for arcs; use clockwise at 90° for upright top text or counterclockwise at 270° for upright bottom text. Glyphs and attached marks rotate without distortion. Arc layout requires baseline vertical alignment and less than one full revolution; Generator preparation owns lettering size and face-fit checks. Packages using circular text require runtime `2.1.0` or newer.
117
-
118
- ### Validation and bounds
119
-
120
- `GeneratorDefinition` is callback-free, JSON-safe metadata for forms, manifests, persistence, and
121
- normalization. `defineGenerator()` preserves literal IDs/options; `GeneratorParams` and
122
- `GeneratorIssue` derive exact parameter types and issue IDs from that definition. Use
123
- `definePresets(definition, presets)` to require complete definition-derived preset values.
124
-
125
- Per-field constraints belong in the definition. Cross-parameter, warning, manufacturing and geometry
126
- constraints belong in `prepare`, alongside the dimensions and samples that `build` will consume.
127
- A successful result is `{ ok: true, value, issues }`; an invalid result is `{ ok: false, issues }`.
128
- Successful preparation may contain warnings but no errors. Invalid preparation requires an error,
129
- and prevents build and native shape construction.
130
-
131
- Numeric parameters and numeric array items may declare `integer: true`. Their defaults and supplied
132
- bounds must be integers. Strict codecs reject fractions; saved fractions recover to the declared
133
- default. Numeric array recovery replaces the invalid array with its default. `step` only describes
134
- the control increment and does not imply integer values.
135
-
136
- Schema editors receive only the definition and never rewrite validators. Manifests remain
137
- callback-free. Preparation receives normalized, frozen parameters; malformed issue output is a
138
- runtime error. Combined validation retains at most 100 issues, prioritizing errors over warnings
139
- and preserving retained order. The reporting limit cannot hide a blocking error.
140
-
141
- Issues may include an optional stable `code` and `path` relative to the parameter value, such as
142
- `{ code: "minimum", path: [2] }` for an array item or
143
- `{ code: "invalid", path: ["segments", 0, "control1", "height"] }` for a profile control.
144
- `ParameterIssueCode` defines the supported categories: `invalid`, `missing`, `type`, `unknown`,
145
- `minimum`, `maximum`, `integer`, `choice`, `duplicate`, `length`, `bytes`, and `structure`.
146
- Schema validation supplies codes and nested locations; strict decoder paths start with the
147
- parameter ID. Authored issues retain their optional metadata through preparation and transfer.
148
- Issue parsing clones and freezes paths, bounds them to 32 segments, accepts non-negative safe
149
- integer indices and non-empty field names of at most 120 characters, and never evaluates accessors.
150
- Both fields are optional; issues always retain their required severity and message.
151
-
152
- Use `getDefaultParameters(definition)` for a fresh frozen defaults map. IDs are bounded safe keys.
153
- Package manifests, definitions, descriptors, conditions, and nested parameter objects reject unknown fields.
154
- Definitions are bounded to 64 groups and 256 parameters, arrays to 1,024 items, options to 512,
155
- presets to 256, and condition composition to 8 levels with 32 children per node.
156
- `validateGeneratorPresets()` from `/packages` applies the same strict metadata and list bounds as
157
- manifest parsing before checking complete canonical parameter maps. Testkit and bundled registries
158
- use that shared validator.
159
-
160
- ### Editable side profiles
161
-
162
- A `profile` declares an open side outline as a versioned `ProfileValue`. Start/end anchors carry
163
- normalized `radius` and upward `height` coordinates, plus editing `mode` (`auto`, `smooth`, or
164
- `corner`). Segments are `line` or `cubic`, with cubic `control1` and `control2` points. Coordinates
165
- define the shape; hosts must resolve automatic tangents into those control points.
166
-
167
- ```ts
168
- const sideProfile = {
169
- id: "sideProfile",
170
- label: "Side profile",
171
- type: "profile",
172
- radiusScale: { parameterId: "diameter", factor: 0.5 },
173
- heightScale: { parameterId: "height", factor: 1 },
174
- default: {
175
- version: 1,
176
- start: { radius: 0.4, height: 0, mode: "corner" },
177
- segments: [
178
- {
179
- type: "cubic",
180
- control1: { radius: 0.4, height: 0.35 },
181
- control2: { radius: 1, height: 0.75 },
182
- end: { radius: 0.6, height: 1, mode: "auto" },
183
- },
184
- ],
185
- },
186
- } as const;
187
40
  ```
188
41
 
189
- Every coordinate is finite and lies in `[0, 1]`. The start height is `0`, the last height is `1`,
190
- and anchor heights increase strictly. Cubic control heights satisfy
191
- `start.height <= control1.height <= control2.height <= end.height`, keeping the curve upward.
192
- A profile has 1–31 segments. It has no SVG markup, sampled polygon, arbitrary closed paths, or
193
- holes; the Generator owns physical scaling, mounting features, closure, and manufacturing checks.
194
-
195
- Optional `radiusScale` and `heightScale` bindings describe physical measurements for host controls:
196
- each references a declared `number` or `slider` in millimetres with a positive default and explicit
197
- positive minimum, multiplied by a positive finite `factor`. Bindings do not transform saved profile
198
- values; Generators consume the same normalized outline when resolving their dimensions. Omitting
199
- bindings leaves the editor in normalized coordinates.
200
-
201
- `isProfileValue()` strictly checks the complete bounded shape without evaluating getters.
202
- `cloneProfileValue()` returns a fresh deeply frozen value, and `profileValuesEqual()` compares both
203
- shape and editing intent. Normalization, strict codecs, defaults, and presets clone every nested
204
- profile object. Invalid saved profiles recover to the declared default; strict boundaries reject
205
- them. Profiles cannot be condition operands. All executable packages use format `2` and runtime major `2`.
206
-
207
- ### Curve resolution
208
-
209
- A `number` or `slider` may declare `role: "curve-resolution"` to identify the model's maximum
210
- sampled curve deviation in millimetres. Hosts may present this input in a dedicated curve fidelity
211
- control. It remains an ordinary Generator parameter with the same saved values, presets,
212
- normalization, validation, and manufacturing exports.
42
+ For saved values, `/parameters` provides `normalizeParameters`: it drops unknown keys, restores
43
+ missing or invalid values from defaults, and clamps numbers. At a trust boundary,
44
+ `createParamCodec(definition)` rejects missing, unknown, invalid, or noncanonical values instead.
45
+ Both return fresh frozen parameter maps.
213
46
 
214
- ```ts
215
- const curveDeviation = {
216
- id: "curveDeviation",
217
- label: "Curve deviation",
218
- type: "number",
219
- role: "curve-resolution",
220
- unit: "mm",
221
- default: 0.05,
222
- min: 0.01,
223
- max: 0.2,
224
- step: 0.005,
225
- } as const;
226
- ```
47
+ Parameter types describe saved values. Optional local `ui` metadata owns group/row membership,
48
+ hints, visibility, editing increments, and physical editor scale bindings. Number inputs and
49
+ sliders both use `type: "number"`; sliders declare `ui.control: "slider"`, bounds, and `ui.step`.
50
+ Fixed choices use `choice`; geometric values use `side-profile` and `contour`.
227
51
 
228
- Multiple controls may have this role. Each requires `unit: "mm"`, a positive `default`, and an
229
- explicit positive `min`; numeric bounds and step rules still apply. Lower values request closer
230
- approximation through the Generator's `GeometryResolution` policy; exact counts remain available
231
- for matched topology. Hosts show authored labels in definition order and edit the saved parameters
232
- used by both preview and manufacturing. Generators determine affected curves and parts; Studio
233
- does not infer overrides from mesh IDs. Requests beyond complexity limits must fail explicitly.
52
+ The `/packages` entry point validates the editable `{ groups, parameters }` document with
53
+ `safeParseParameterDefinitionDocument`, returning structured issue paths and codes. Complete
54
+ Generator and package parsing uses the same rules. The package also ships
55
+ `@metamesh/generator-sdk/parameters.schema.json` for offline editor completion and structural
56
+ validation; the SDK additionally checks references, defaults, and cross-field invariants.
234
57
 
235
- ## Compiled module and output boundary
58
+ ## Prepare and build
236
59
 
237
- `defineGeneratorModule()` creates the five-field format-2 surface. Preparation resolves the model
238
- once; build receives that exact value. Imported modeling helpers bind to the host's synchronous build:
60
+ With [Modeling](https://github.com/JasonKoolman/metamesh/blob/main/packages/modeling/README.md)
61
+ installed, validate related dimensions and pass the prepared result into construction:
239
62
 
240
63
  ```ts
241
64
  import { defineGeneratorModule, definePreparation, prepared } from "@metamesh/generator-sdk";
@@ -258,83 +81,29 @@ const runtime = defineGeneratorModule({
258
81
  export const { formatVersion, generatorId, version, prepare, build } = runtime;
259
82
  ```
260
83
 
261
- `definePreparation(definition, callback)` infers readonly parameter values, prepared data and
262
- `PreparationServices<typeof definition>`. Its second callback argument retains `services.text`
263
- and adds `invalid(parameterId, message)` and `invalid(issue)`, with allowed IDs checked directly at
264
- each argument. Destructure `{ invalid }` or call `services.invalid(...)`. A warning alone cannot
265
- produce failed preparation.
266
-
267
- The helper returns a preparation wrapper that accepts parameters and optional host `GeneratorServices`.
268
- Omitting services uses `UNPREPARED_GENERATOR_SERVICES` for parameter-only probes; requesting
269
- text through that provider fails explicitly. Hosts pass their prepared services.
270
- It adds the scoped helper for each callback invocation, preserving the exact callback result and
271
- prepared value without traversal or freezing. The callback itself is not returned unchanged.
272
- `prepared(value)` remains the successful-value helper. Standalone global `invalid` accepts literal
273
- IDs or existing error issues; the host checks their IDs against the definition at the runtime
274
- boundary.
275
-
276
- The root helper has no decoder or Modeling runtime dependency. Modeling owns `ModelingContext`
277
- and `BuildOutput`; SDK context/output generics preserve author typing without importing them.
278
- Prepared values are opaque local data: the SDK does not traverse, clone, serialize or freeze them.
279
- Preparation must not acquire live modeling resources. Prepared values are never persisted,
280
- transferred to the UI, or reused between requests.
281
-
282
- Hosts import `parseGeneratorModule`, `prepareGenerator` and `executeGenerator` from `/runtime`.
283
- The parser requires exactly the five exports above and matching manifest identity. Evaluated
284
- preparation captures an opaque value in a one-use build closure; there is no raw prepared-value
285
- invocation lane. Callback results must be synchronous. The host checks the own-data preparation
286
- wrapper and bounded structured issues while leaving the value opaque.
287
-
288
- Studio's authored source surface accepts `build` and optional `prepare`. Its compiler supplies
289
- identity and `prepareIdentity(definition)` when preparation is omitted, then passes the resulting
290
- five-field module through this same parser and executor. Compiled packages always include `prepare`.
291
-
292
- `prepareGenerator` normalizes once and either returns `invalid` or a prepared result containing
293
- `build(context)`. Use that closure inside `engine.build()` so one engine owns modeling, mesh
294
- validation, limits, measurements and cleanup. `executeGenerator` accepts a context directly and
295
- returns abstract build output; it does not finalize geometry. Hosts preparing asynchronous services
296
- first may supply their `/parameters` `PreparedParameters` result as `parameterState` to reuse it.
297
-
298
- `parseGeneratedParts(parts, limits)` strictly checks the final transferable DTO. The host supplies
299
- its complete limits; the SDK does not own a duplicate default resource policy. Canonical parts have
300
- unique IDs, Float32 positions, Uint32 indices and optional six-digit colors. Normals belong to
301
- viewport presentation. Geometric/manufacturing validation belongs to the shared engine.
302
-
303
- Package format `1`, runtime major `1`, retired `validate/generate` module exports and extra exports
304
- reject explicitly. No compatibility adapter or preparation cache remains.
305
-
306
- Packages using the current modeling operations and Section overloads, `holeCutter()`, or optional
307
- issue `code`/`path` metadata must declare minimum runtime `2.1.0`. Package format and execution
308
- protocol major remain `2`. The manifest minimum must cover the host capabilities the package uses.
309
-
310
- ## Worker boundary
311
-
312
- Worker requests/responses are `/runtime` contracts containing structured data and transferable
313
- arrays, never live modeling handles. Validation issues are normal outcomes; callback, Worker and
314
- exporter exceptions use error envelopes. Finalized previews carry revision identity, bounds,
315
- warnings and optional statistics. Manufacturing exports serialize the requested finalized revision,
316
- including appearance overrides, without running preparation/build again.
84
+ Both callbacks are synchronous. Load assets beforehand; preparation computes ordinary data, and
85
+ build runs inside the host's Modeling engine. Prepared values stay local to one execution and
86
+ are never persisted or transferred. Studio owns persistence and Worker lifecycle; Modeling owns
87
+ geometry, finalization, and resource cleanup.
317
88
 
318
- Successful generation envelopes include `sentAt`, the sender's high-resolution epoch milliseconds
319
- captured immediately before transfer. Hosts use `/runtime` `parseGenerationSentAt()` to reject
320
- missing, inherited, accessor, or nonfinite timestamps before measuring transfer latency. Worker
321
- clock construction and receiver timings belong to the host.
89
+ ## Documentation
322
90
 
323
- `ModelTimings.prepareMs` measures Generator preparation; `viewportPrepareMs` measures host viewport
324
- preparation. `firstDrawMs` starts when viewport preparation ends and measures elapsed time through
325
- every part's first draw submission, including render scheduling and buffer upload. Viewport fields
326
- are optional until the host records completion. First draw does not measure GPU completion.
327
- `totalMs` is request-to-completion elapsed time, including scheduling between stages, rather than
328
- the sum of stage timings. Studio reports request-to-delivery time until viewport completion.
91
+ Read the [parameters guide](https://github.com/JasonKoolman/metamesh/blob/main/apps/web/content/docs/develop/parameters-and-validation.mdx)
92
+ for controls and validation, or [local authoring](https://github.com/JasonKoolman/metamesh/blob/main/apps/web/content/docs/create/author-locally.mdx)
93
+ for the current Generator workflow. The public documentation site is planned for `metamesh.studio/docs`.
329
94
 
330
- `MeshTopologyMode` is host policy rather than a Generator parameter. Both compiled and authored
331
- models use the same engine finalization and limits. Studio's runtime contract owns request lifecycle,
332
- revision retention and export recovery.
95
+ Exact SDK contracts live with their code:
333
96
 
334
- ## Development
97
+ - [Parameter definitions](https://github.com/JasonKoolman/metamesh/blob/main/packages/generator-sdk/src/parameter-contracts.ts),
98
+ [side profiles](https://github.com/JasonKoolman/metamesh/blob/main/packages/generator-sdk/src/side-profiles.ts), and
99
+ [contours](https://github.com/JasonKoolman/metamesh/blob/main/packages/generator-sdk/src/contours.ts).
100
+ - [Authoring helpers](https://github.com/JasonKoolman/metamesh/blob/main/packages/generator-sdk/src/authoring.ts),
101
+ [module contract](https://github.com/JasonKoolman/metamesh/blob/main/packages/generator-sdk/src/generator-module.ts), and
102
+ [runtime execution](https://github.com/JasonKoolman/metamesh/blob/main/packages/generator-sdk/src/execute-generator.ts).
335
103
 
336
- Keep this package independent of React, Zustand, Three.js, Manifold, DOM, and Web Worker APIs.
337
- The [workspace instructions](https://github.com/JasonKoolman/metamesh/blob/main/packages/generator-sdk/AGENTS.md) own contract review and required checks.
104
+ For maintainers, the [package contract](https://github.com/JasonKoolman/metamesh/blob/main/docs/generator-packages.md)
105
+ owns compatibility and trust; [workspace instructions](https://github.com/JasonKoolman/metamesh/blob/main/packages/generator-sdk/AGENTS.md)
106
+ own contract review and required checks.
338
107
 
339
108
  ## License
340
109
 
@@ -0,0 +1,36 @@
1
+ import { type CurveValueProblem } from "./curve-data.js";
2
+ /** Maximum number of straight or cubic segments in an editable closed cross section. */
3
+ export declare const MAX_CONTOUR_SEGMENTS = 32;
4
+ /** Normalized planar coordinates, with X rightward and Y upward, in the unit square. */
5
+ export interface ContourPoint {
6
+ readonly x: number;
7
+ readonly y: number;
8
+ }
9
+ /** Editing intent accompanies the explicit curve controls; no tangent is inferred at runtime. */
10
+ export interface ContourAnchor extends ContourPoint {
11
+ readonly mode: "smooth" | "corner";
12
+ }
13
+ export type ContourSegment = {
14
+ readonly type: "line";
15
+ readonly end: ContourAnchor;
16
+ } | {
17
+ readonly type: "cubic";
18
+ readonly control1: ContourPoint;
19
+ readonly control2: ContourPoint;
20
+ readonly end: ContourAnchor;
21
+ };
22
+ /** One explicitly closed planar contour. Generators own physical scaling and topology checks. */
23
+ export interface ContourValue {
24
+ readonly version: 1;
25
+ readonly start: ContourAnchor;
26
+ readonly segments: readonly ContourSegment[];
27
+ }
28
+ /** Internal diagnostics share the accessor-safe reader used by predicates and cloning. */
29
+ export declare function contourValueProblem(value: unknown): CurveValueProblem | undefined;
30
+ /** Checks portable data and explicit closure without evaluating getters or inspecting topology. */
31
+ export declare function isContourValue(value: unknown): value is ContourValue;
32
+ /** Returns a fresh, deeply frozen closed contour, including its editing intent. */
33
+ export declare function cloneContourValue(value: ContourValue): ContourValue;
34
+ /** Compares the serialized shape and editing intent rather than object identity. */
35
+ export declare function contourValuesEqual(previous: ContourValue, next: ContourValue): boolean;
36
+ //# sourceMappingURL=contours.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contours.d.ts","sourceRoot":"","sources":["../src/contours.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,iBAAiB,EAEvB,MAAM,iBAAiB,CAAC;AAEzB,wFAAwF;AACxF,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,wFAAwF;AACxF,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,iGAAiG;AACjG,MAAM,WAAW,aAAc,SAAQ,YAAY;IACjD,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;CACpC;AAED,MAAM,MAAM,cAAc,GACtB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAA;CAAE,GACtD;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAChC,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAC;CAC7B,CAAC;AAEN,iGAAiG;AACjG,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,CAAC;CAC9C;AAmGD,0FAA0F;AAC1F,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,iBAAiB,GAAG,SAAS,CAMjF;AAED,mGAAmG;AACnG,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAEpE;AAED,mFAAmF;AACnF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,GAAG,YAAY,CA0BnE;AAED,oFAAoF;AACpF,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CA4BtF"}
@@ -0,0 +1,150 @@
1
+ import { curveDataObject, curveSegmentCount, } from "./curve-data.js";
2
+ /** Maximum number of straight or cubic segments in an editable closed cross section. */
3
+ export const MAX_CONTOUR_SEGMENTS = 32;
4
+ function point(value, anchor, path, fail) {
5
+ const fields = curveDataObject(value, anchor ? ["x", "y", "mode"] : ["x", "y"], path, fail);
6
+ if (fields === undefined)
7
+ return undefined;
8
+ for (const coordinate of ["x", "y"]) {
9
+ const entry = fields[coordinate];
10
+ if (typeof entry !== "number" || !Number.isFinite(entry))
11
+ return fail([...path, coordinate], "type");
12
+ if (entry < 0)
13
+ return fail([...path, coordinate], "minimum");
14
+ if (entry > 1)
15
+ return fail([...path, coordinate], "maximum");
16
+ }
17
+ const coordinates = { x: fields.x, y: fields.y };
18
+ if (!anchor)
19
+ return coordinates;
20
+ if (fields.mode !== "smooth" && fields.mode !== "corner")
21
+ return fail([...path, "mode"], "choice");
22
+ return { ...coordinates, mode: fields.mode };
23
+ }
24
+ function readContourValue(value, report) {
25
+ const fail = (path, code) => {
26
+ report?.({ path, code });
27
+ return undefined;
28
+ };
29
+ try {
30
+ const fields = curveDataObject(value, ["version", "start", "segments"], [], fail);
31
+ if (fields === undefined)
32
+ return undefined;
33
+ if (fields.version !== 1)
34
+ return fail(["version"], "invalid");
35
+ const start = point(fields.start, true, ["start"], fail);
36
+ if (start === undefined)
37
+ return undefined;
38
+ if (!Array.isArray(fields.segments))
39
+ return fail(["segments"], "type");
40
+ const segments = fields.segments;
41
+ const length = curveSegmentCount(segments, 2, MAX_CONTOUR_SEGMENTS, fail);
42
+ if (length === undefined)
43
+ return undefined;
44
+ const parsedSegments = [];
45
+ for (let index = 0; index < length; index += 1) {
46
+ const segmentPath = ["segments", index];
47
+ const descriptor = Object.getOwnPropertyDescriptor(segments, String(index));
48
+ if (descriptor === undefined || !("value" in descriptor) || !descriptor.enumerable)
49
+ return fail(segmentPath, "structure");
50
+ const segment = descriptor.value;
51
+ if (typeof segment !== "object" || segment === null || Array.isArray(segment))
52
+ return fail(segmentPath, "type");
53
+ const typeDescriptor = Object.getOwnPropertyDescriptor(segment, "type");
54
+ if (typeDescriptor === undefined)
55
+ return fail([...segmentPath, "type"], "missing");
56
+ if (!("value" in typeDescriptor))
57
+ return fail([...segmentPath, "type"], "structure");
58
+ const type = typeDescriptor.value;
59
+ if (type !== "line" && type !== "cubic")
60
+ return fail([...segmentPath, "type"], "choice");
61
+ const segmentFields = curveDataObject(segment, type === "line" ? ["type", "end"] : ["type", "end", "control1", "control2"], segmentPath, fail);
62
+ if (segmentFields === undefined)
63
+ return undefined;
64
+ if (segmentFields.type !== type)
65
+ return fail([...segmentPath, "type"], "invalid");
66
+ const end = point(segmentFields.end, true, [...segmentPath, "end"], fail);
67
+ if (end === undefined)
68
+ return undefined;
69
+ if (index === length - 1) {
70
+ for (const key of ["x", "y", "mode"]) {
71
+ if (end[key] !== start[key])
72
+ return fail([...segmentPath, "end", key], "invalid");
73
+ }
74
+ }
75
+ if (type === "cubic") {
76
+ const control1 = point(segmentFields.control1, false, [...segmentPath, "control1"], fail);
77
+ if (control1 === undefined)
78
+ return undefined;
79
+ const control2 = point(segmentFields.control2, false, [...segmentPath, "control2"], fail);
80
+ if (control2 === undefined)
81
+ return undefined;
82
+ parsedSegments.push({ type, control1, control2, end });
83
+ }
84
+ else {
85
+ parsedSegments.push({ type, end });
86
+ }
87
+ }
88
+ return { version: 1, start, segments: parsedSegments };
89
+ }
90
+ catch {
91
+ return fail([], "structure");
92
+ }
93
+ }
94
+ /** Internal diagnostics share the accessor-safe reader used by predicates and cloning. */
95
+ export function contourValueProblem(value) {
96
+ let problem;
97
+ const parsed = readContourValue(value, (entry) => {
98
+ problem = entry;
99
+ });
100
+ return parsed === undefined ? (problem ?? { code: "structure", path: [] }) : undefined;
101
+ }
102
+ /** Checks portable data and explicit closure without evaluating getters or inspecting topology. */
103
+ export function isContourValue(value) {
104
+ return readContourValue(value) !== undefined;
105
+ }
106
+ /** Returns a fresh, deeply frozen closed contour, including its editing intent. */
107
+ export function cloneContourValue(value) {
108
+ const canonical = readContourValue(value);
109
+ if (canonical === undefined)
110
+ throw new TypeError("Cross section must be a bounded, normalized closed contour.");
111
+ const clonePoint = (entry) => Object.freeze({ x: entry.x, y: entry.y });
112
+ const cloneAnchor = (entry) => Object.freeze({ x: entry.x, y: entry.y, mode: entry.mode });
113
+ return Object.freeze({
114
+ version: 1,
115
+ start: cloneAnchor(canonical.start),
116
+ segments: Object.freeze(canonical.segments.map((segment) => Object.freeze(segment.type === "line"
117
+ ? { type: "line", end: cloneAnchor(segment.end) }
118
+ : {
119
+ type: "cubic",
120
+ control1: clonePoint(segment.control1),
121
+ control2: clonePoint(segment.control2),
122
+ end: cloneAnchor(segment.end),
123
+ }))),
124
+ });
125
+ }
126
+ /** Compares the serialized shape and editing intent rather than object identity. */
127
+ export function contourValuesEqual(previous, next) {
128
+ if (Object.is(previous, next))
129
+ return true;
130
+ const previousData = readContourValue(previous);
131
+ const nextData = readContourValue(next);
132
+ if (previousData === undefined || nextData === undefined)
133
+ return false;
134
+ const pointsEqual = (left, right) => Object.is(left.x, right.x) && Object.is(left.y, right.y);
135
+ const anchorsEqual = (left, right) => pointsEqual(left, right) && left.mode === right.mode;
136
+ return (anchorsEqual(previousData.start, nextData.start) &&
137
+ previousData.segments.length === nextData.segments.length &&
138
+ previousData.segments.every((segment, index) => {
139
+ const other = nextData.segments[index];
140
+ if (other === undefined ||
141
+ segment.type !== other.type ||
142
+ !anchorsEqual(segment.end, other.end))
143
+ return false;
144
+ return (segment.type === "line" ||
145
+ (other.type === "cubic" &&
146
+ pointsEqual(segment.control1, other.control1) &&
147
+ pointsEqual(segment.control2, other.control2)));
148
+ }));
149
+ }
150
+ //# sourceMappingURL=contours.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contours.js","sourceRoot":"","sources":["../src/contours.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,iBAAiB,GAGlB,MAAM,iBAAiB,CAAC;AAEzB,wFAAwF;AACxF,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAyCvC,SAAS,KAAK,CACZ,KAAc,EACd,MAAe,EACf,IAAkC,EAClC,IAAwB;IAExB,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,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