@metamesh/generator-sdk 0.3.0 → 0.5.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 +33 -0
- package/README.md +140 -38
- package/dist/contracts.d.ts +9 -4
- package/dist/contracts.d.ts.map +1 -1
- package/dist/execute-generator.d.ts +46 -0
- package/dist/execute-generator.d.ts.map +1 -0
- package/dist/execute-generator.js +41 -0
- package/dist/execute-generator.js.map +1 -0
- package/dist/generator-package/constants.d.ts +1 -1
- package/dist/generator-package/constants.js +1 -1
- package/dist/generator-package/schemas/definition.schema.d.ts +19 -0
- package/dist/generator-package/schemas/definition.schema.d.ts.map +1 -1
- package/dist/generator-package/schemas/manifest.schema.d.ts +908 -59
- package/dist/generator-package/schemas/manifest.schema.d.ts.map +1 -1
- package/dist/generator-package/schemas/parameter.schema.d.ts +46 -0
- package/dist/generator-package/schemas/parameter.schema.d.ts.map +1 -1
- package/dist/generator-package/schemas/parameter.schema.js +17 -0
- package/dist/generator-package/schemas/parameter.schema.js.map +1 -1
- package/dist/generator-package/schemas/preset.schema.d.ts.map +1 -1
- package/dist/generator-package/schemas/preset.schema.js +2 -0
- 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 +56 -1
- 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 +9 -0
- package/dist/generator-package/validate-manifest.js.map +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/parameters.d.ts.map +1 -1
- package/dist/parameters.js +16 -1
- package/dist/parameters.js.map +1 -1
- package/dist/prepared-generator-module.d.ts +24 -0
- package/dist/prepared-generator-module.d.ts.map +1 -0
- package/dist/prepared-generator-module.js +124 -0
- package/dist/prepared-generator-module.js.map +1 -0
- package/dist/profiles.d.ts +33 -0
- package/dist/profiles.d.ts.map +1 -0
- package/dist/profiles.js +167 -0
- package/dist/profiles.js.map +1 -0
- package/package.json +6 -5
- package/dist/url-state.d.ts +0 -13
- package/dist/url-state.d.ts.map +0 -1
- package/dist/url-state.js +0 -149
- package/dist/url-state.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @metamesh/generator-sdk
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 0dc29c2: Add the portable numeric `curve-resolution` parameter role for model-owned physical curve
|
|
8
|
+
tolerance, with strict millimetre units, positive bounds, and one role per definition. Require
|
|
9
|
+
runtime 1.3.0 or later for packages declaring the role. Geometry and
|
|
10
|
+
Testkit follow the coordinated fixed Preview package release.
|
|
11
|
+
- 0dc29c2: Add a portable, versioned `profile` parameter for guided side outlines with line/cubic segments,
|
|
12
|
+
anchor editing modes, physical-dimension bindings, strict bounds, and deeply immutable defaults,
|
|
13
|
+
presets, and runtime values. Profile-capable packages require runtime 1.3.0 or later while retaining
|
|
14
|
+
package format 1.
|
|
15
|
+
|
|
16
|
+
Add Geometry's `sampleOpenProfile` operation to adaptively sample open radius/height curves with
|
|
17
|
+
physical scaling, chord-error limits, and explicit complexity failures. Expose it through the
|
|
18
|
+
compiled and Studio authoring APIs so profile parameters use the same geometry in preview and export.
|
|
19
|
+
|
|
20
|
+
## 0.4.0
|
|
21
|
+
|
|
22
|
+
### Minor Changes
|
|
23
|
+
|
|
24
|
+
- ad3bb49: Strengthen generator geometry with correct concave sweep caps, bounded region aggregation,
|
|
25
|
+
consistent finite input checks, protected copied-mesh scope exits, and shared primitive/extrusion
|
|
26
|
+
sampling. Add scoped hull, Minkowski sum, projection, slicing, and region revolution.
|
|
27
|
+
|
|
28
|
+
Compiled `MeshPart` now exposes `{ id, positions, indices, color? }`, directly compatible with SDK
|
|
29
|
+
`GeneratedPart`. Pass explicit `{ degrees }` or `{ radians }` to `rotationTransform3`, and rounded
|
|
30
|
+
rectangle sampling options as `{ segmentsPerCorner }` or `{ resolution }`.
|
|
31
|
+
|
|
32
|
+
Add `definePreparedGeneratorModule` for bounded, one-use validation/generation preparation while
|
|
33
|
+
preserving the five format-1 module exports. Authored `/v1` keeps its existing signatures and shares
|
|
34
|
+
the pure validation and sampling implementation with compiled modeling.
|
|
35
|
+
|
|
3
36
|
## 0.3.0
|
|
4
37
|
|
|
5
38
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -12,60 +12,65 @@ Install the public package from npm:
|
|
|
12
12
|
pnpm add @metamesh/generator-sdk
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
The package root exposes the
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
or Zod. Both exports remain available from the package root.
|
|
15
|
+
The package root exposes the Generator API. Use `@metamesh/generator-sdk/fonts` for only
|
|
16
|
+
`FontSelection` and `isFontSelection`, without loading Generator services or Zod. Both exports
|
|
17
|
+
remain available from the root.
|
|
19
18
|
|
|
20
19
|
The package owns parameter/group definitions, serializable conditions, default derivation and
|
|
21
20
|
normalization, structured validation, runtime envelopes, normalized generated-model results, and
|
|
22
21
|
serializable catalog/package/install contracts. Project persistence belongs to Studio;
|
|
23
22
|
release-state transitions belong to trusted database/tooling boundaries.
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
The optional `Export3mfRequest.partColors` map carries Project color overrides keyed by semantic
|
|
25
|
+
part ID. Studio validates and applies it during export; it does not enter Generator parameters or
|
|
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.
|
|
28
30
|
|
|
29
31
|
## Parameter definitions
|
|
30
32
|
|
|
31
33
|
Definitions use the `type` discriminant with `number`, `slider`, `boolean`, `select`, `choice-set`,
|
|
32
|
-
`color`, `text`, `font`, `svg`, and homogeneous `array` variants. A `slider` requires `min`, `max`, and
|
|
34
|
+
`color`, `text`, `font`, `svg`, `profile`, and homogeneous `array` variants. A `slider` requires `min`, `max`, and
|
|
33
35
|
`step`, while a `number` may omit any of those constraints. Visibility uses serializable
|
|
34
36
|
`ConditionExpression` values; `evaluateCondition` supports `all`, `any`, `not`,
|
|
35
37
|
equality/inequality, numeric comparisons, and `choice-set` membership through `contains`.
|
|
36
38
|
|
|
37
|
-
|
|
39
|
+
Define controls once, then normalize saved values or strictly parse boundary values:
|
|
38
40
|
|
|
39
41
|
```ts
|
|
40
42
|
import {
|
|
41
43
|
createParamCodec,
|
|
42
|
-
decodeParameterState,
|
|
43
44
|
defineGenerator,
|
|
44
45
|
EMPTY_SVG_PARAMETER_DEFAULT,
|
|
45
|
-
encodeParameterState,
|
|
46
46
|
prepareParameters,
|
|
47
47
|
type GeneratorParams,
|
|
48
48
|
} from "@metamesh/generator-sdk";
|
|
49
49
|
|
|
50
|
-
const definition = defineGenerator({
|
|
50
|
+
const definition = defineGenerator({
|
|
51
|
+
id: "sleeve",
|
|
52
|
+
version: "0.1.0",
|
|
53
|
+
title: "Sleeve",
|
|
54
|
+
groups: [],
|
|
55
|
+
parameters: [
|
|
56
|
+
{ id: "outerDiameter", label: "Outer diameter", type: "number", default: 20, min: 4 },
|
|
57
|
+
{ id: "boreDiameter", label: "Bore diameter", type: "number", default: 10, min: 1 },
|
|
58
|
+
],
|
|
59
|
+
});
|
|
51
60
|
type Parameters = GeneratorParams<typeof definition>;
|
|
52
61
|
|
|
62
|
+
const persistedValues: Readonly<Record<string, unknown>> = { outerDiameter: 24 };
|
|
53
63
|
const { parameters, validation } = prepareParameters(definition, persistedValues);
|
|
64
|
+
const workerValues: unknown = { outerDiameter: 24, boreDiameter: 10 };
|
|
54
65
|
const strictParameters = createParamCodec(definition).parse(workerValues);
|
|
55
|
-
const query = encodeParameterState(definition, parameters);
|
|
56
|
-
const restored = decodeParameterState(definition, query);
|
|
57
66
|
```
|
|
58
67
|
|
|
59
68
|
Normalization drops unknown parameter-value keys, fills missing or invalid values from each
|
|
60
69
|
parameter's declared `default`, clamps numbers, and returns a fresh frozen map. Strict codecs instead
|
|
61
|
-
reject missing, unknown, invalid, or noncanonical values and return cloned frozen
|
|
70
|
+
reject missing, unknown, invalid, or noncanonical values and return cloned frozen structured values.
|
|
62
71
|
`prepareParameters()` normalizes once and returns that same canonical map with the combined schema
|
|
63
|
-
and Generator-owned validation result. Definitions accept only canonical parameter types.
|
|
64
|
-
|
|
65
|
-
Malformed, obsolete, or invalid URL values safely fall back to defaults. SVG runtime values remain
|
|
66
|
-
standard strings, are limited to 256 KiB each and 512 KiB per normalized project, and are omitted
|
|
67
|
-
from parameter URLs. URL scalars overlay a host-supplied persisted base so device-local SVG values
|
|
68
|
-
are never erased by a shared URL.
|
|
72
|
+
and Generator-owned validation result. Definitions accept only canonical parameter types. SVG runtime values remain
|
|
73
|
+
standard strings and are limited to 256 KiB each and 512 KiB per normalized project.
|
|
69
74
|
|
|
70
75
|
```ts
|
|
71
76
|
const profile = {
|
|
@@ -84,8 +89,7 @@ option values.
|
|
|
84
89
|
|
|
85
90
|
Array definitions declare `items.type` as `number` or `string`. They may constrain `minItems` and
|
|
86
91
|
`maxItems`; number items may also declare `min`, `max`, `step`, and `unit`. Array-valued controls are
|
|
87
|
-
cloned at normalization and persistence boundaries
|
|
88
|
-
JSON without changing scalar URL encoding. Conditions may compare scalar controls or test
|
|
92
|
+
cloned at normalization and persistence boundaries. Conditions may compare scalar controls or test
|
|
89
93
|
`choice-set` membership; arbitrary arrays cannot be condition operands.
|
|
90
94
|
|
|
91
95
|
```ts
|
|
@@ -104,17 +108,17 @@ optional `collapsed` default. Parameters without a group render in Studio's Gene
|
|
|
104
108
|
|
|
105
109
|
Font parameters use a `FontSelection` default with immutable `faceId`, SHA-256 `revision`, and
|
|
106
110
|
integer `weight`. Structural validation does not require the font to be available locally. Valid
|
|
107
|
-
unavailable references survive codecs, presets,
|
|
111
|
+
unavailable references survive codecs, presets, and persistence. Studio prepares the
|
|
108
112
|
declared fonts before executable validation and generation. It supplies `GeneratorServices` as the
|
|
109
113
|
second validator argument and third generation argument. `services.text.layout(text, { font,
|
|
110
114
|
fontSize })` returns positioned vector curves and matching metrics in millimetres. Geometry's
|
|
111
115
|
`withTextFonts(services.text, callback)` binds these services for `textContours()` and
|
|
112
116
|
`textMetrics()` in compiled code. The SDK and Geometry keep their small structural text contracts
|
|
113
117
|
compatible without importing each other's runtime. Font parameters and prepared text services require
|
|
114
|
-
runtime `1.2.0` or later. Package format remains 1.
|
|
118
|
+
runtime `1.2.0` or later. Package format remains 1.
|
|
115
119
|
|
|
116
120
|
`GeneratorDefinition` is callback-free, JSON-safe metadata used by forms, manifests, persistence,
|
|
117
|
-
|
|
121
|
+
and normalization. Its `min`, `max`, options, and other field constraints are portable
|
|
118
122
|
data. `defineGenerator()` preserves literal IDs and select options so `GeneratorParams`,
|
|
119
123
|
`GeneratorParamId`, `GeneratorIssue`, validators, defaults, and presets derive from the definition.
|
|
120
124
|
Keep derived-value, cross-parameter, warning, and geometry checks in a separate TypeScript
|
|
@@ -140,13 +144,91 @@ Downloaded manifests remain callback-free and do not define a validation rules l
|
|
|
140
144
|
validation receives normalized, frozen values. Its issue array is strictly checked and bounded;
|
|
141
145
|
malformed output is a runtime error rather than a user-facing validation result.
|
|
142
146
|
|
|
143
|
-
|
|
144
|
-
to derive a fresh frozen value map from parameter definitions. IDs are bounded safe keys; package
|
|
147
|
+
Use `getDefaultParameters(definition)` to derive a fresh frozen defaults map. IDs are bounded safe keys; package
|
|
145
148
|
manifests, definitions, descriptors, conditions, and nested parameter objects reject unknown fields.
|
|
146
149
|
Definitions are bounded to 64 groups and 256 parameters, arrays to 1,024 items, options to 512,
|
|
147
|
-
presets to 256, and condition composition to 8 levels with 32 children per node.
|
|
148
|
-
|
|
149
|
-
|
|
150
|
+
presets to 256, and condition composition to 8 levels with 32 children per node.
|
|
151
|
+
|
|
152
|
+
### Editable side profiles
|
|
153
|
+
|
|
154
|
+
A `profile` declares an open side outline as a versioned `ProfileValue`. Its start and each segment
|
|
155
|
+
end are anchors with normalized `radius` and upward `height` coordinates, plus `mode` (`auto`,
|
|
156
|
+
`smooth`, or `corner`) to retain editing intent. A segment is either `line` or `cubic`; cubic
|
|
157
|
+
segments carry explicit `control1` and `control2` points. Explicit coordinates always define the
|
|
158
|
+
shape; hosts must write resolved tangents into the controls when editing automatic points.
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
const sideProfile = {
|
|
162
|
+
id: "sideProfile",
|
|
163
|
+
label: "Side profile",
|
|
164
|
+
type: "profile",
|
|
165
|
+
radiusScale: { parameterId: "diameter", factor: 0.5 },
|
|
166
|
+
heightScale: { parameterId: "height", factor: 1 },
|
|
167
|
+
default: {
|
|
168
|
+
version: 1,
|
|
169
|
+
start: { radius: 0.4, height: 0, mode: "corner" },
|
|
170
|
+
segments: [
|
|
171
|
+
{
|
|
172
|
+
type: "cubic",
|
|
173
|
+
control1: { radius: 0.4, height: 0.35 },
|
|
174
|
+
control2: { radius: 1, height: 0.75 },
|
|
175
|
+
end: { radius: 0.6, height: 1, mode: "auto" },
|
|
176
|
+
},
|
|
177
|
+
],
|
|
178
|
+
},
|
|
179
|
+
} as const;
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Every coordinate is finite and lies in `[0, 1]`. The start height is `0`, the last height is `1`,
|
|
183
|
+
and anchor heights increase strictly. Cubic control heights satisfy
|
|
184
|
+
`start.height <= control1.height <= control2.height <= end.height`, keeping the curve upward.
|
|
185
|
+
A profile has 1–31 segments. It has no SVG markup, sampled polygon, arbitrary closed paths, or
|
|
186
|
+
holes; the Generator owns physical scaling, mounting features, closure, and manufacturing checks.
|
|
187
|
+
|
|
188
|
+
Optional `radiusScale` and `heightScale` bindings describe physical measurements for host controls:
|
|
189
|
+
each references a declared `number` or `slider` in millimetres with a positive default and explicit
|
|
190
|
+
positive minimum, multiplied by a positive finite `factor`. Bindings do not transform saved profile
|
|
191
|
+
values; Generators consume the same normalized outline when resolving their dimensions. Omitting
|
|
192
|
+
bindings leaves the editor in normalized coordinates.
|
|
193
|
+
|
|
194
|
+
`isProfileValue()` strictly checks the complete bounded shape without evaluating getters.
|
|
195
|
+
`cloneProfileValue()` returns a fresh deeply frozen value, and `profileValuesEqual()` compares both
|
|
196
|
+
shape and editing intent. Normalization, strict codecs, defaults, and presets clone every nested
|
|
197
|
+
profile object. Invalid saved profiles recover to the declared default; strict boundaries reject
|
|
198
|
+
them. Profiles cannot be condition operands. Profile parameters require runtime `1.3.0` or later;
|
|
199
|
+
package format remains `1`.
|
|
200
|
+
|
|
201
|
+
### Curve resolution
|
|
202
|
+
|
|
203
|
+
A `number` or `slider` may declare `role: "curve-resolution"` to identify the model's maximum
|
|
204
|
+
sampled curve deviation in millimetres. Hosts may present this input in a dedicated curve fidelity
|
|
205
|
+
control. It remains an ordinary Generator parameter with the same saved values, presets,
|
|
206
|
+
normalization, validation, and manufacturing exports.
|
|
207
|
+
|
|
208
|
+
```ts
|
|
209
|
+
const curveDeviation = {
|
|
210
|
+
id: "curveDeviation",
|
|
211
|
+
label: "Curve deviation",
|
|
212
|
+
type: "number",
|
|
213
|
+
role: "curve-resolution",
|
|
214
|
+
unit: "mm",
|
|
215
|
+
default: 0.05,
|
|
216
|
+
min: 0.01,
|
|
217
|
+
max: 0.2,
|
|
218
|
+
step: 0.005,
|
|
219
|
+
} as const;
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Only one control per definition may have this role. It requires `unit: "mm"`, a positive `default`,
|
|
223
|
+
and an explicit positive `min`; existing numeric bounds and step rules still apply. Lower values
|
|
224
|
+
request closer curve approximation. The Generator consumes the value in its physical
|
|
225
|
+
`GeometryResolution` policy and retains local exact counts where topology requires them. Hosts
|
|
226
|
+
edit the saved parameter directly; preview and manufacturing use the same value. Part-specific
|
|
227
|
+
controls require a separate declared mapping. Resolution requests exceeding model complexity
|
|
228
|
+
limits must fail explicitly instead of silently coarsening geometry.
|
|
229
|
+
|
|
230
|
+
Packages declaring this role require runtime `1.3.0` or later and retain package format `1` and the
|
|
231
|
+
existing five module exports. Definitions without the role retain their existing behavior.
|
|
150
232
|
|
|
151
233
|
## Compiled module and output boundary
|
|
152
234
|
|
|
@@ -177,12 +259,35 @@ Hosts always invoke modules with `validate(parameters, services)` and
|
|
|
177
259
|
font-dependent hosts prepare and pass the selected fonts before executable validation. Author
|
|
178
260
|
callbacks may omit arguments they do not use.
|
|
179
261
|
|
|
262
|
+
Generators with expensive SVG import, font layout, encoding, or dimension resolution may use
|
|
263
|
+
`definePreparedGeneratorModule({ definition, prepare, generate })`. `prepare(parameters, services)`
|
|
264
|
+
returns `{ ok: true, value, issues }` or `{ ok: false, issues }`, with definition-derived structured
|
|
265
|
+
issues. Successful results may contain warnings but no errors; invalid results require an error.
|
|
266
|
+
The model callback receives `generate(parameters, context, services, preparedValue)`. The returned
|
|
267
|
+
module still exports exactly the same five fields and uses the unchanged host call signatures.
|
|
268
|
+
|
|
269
|
+
Preparation accepts finite scalar data, plain objects, and arrays, which the helper checks and
|
|
270
|
+
freezes. It rejects functions, accessors, cycles, promises, class instances, typed arrays, and live
|
|
271
|
+
WASM objects, with traversal bounded to 1,000,000 values and 64 levels.
|
|
272
|
+
|
|
273
|
+
The helper may reuse one successful validation result for the next generation when the exact
|
|
274
|
+
deeply frozen parameters and frozen services/provider objects match. Different or mutable objects
|
|
275
|
+
and direct generation prepare afresh; later calls and failures clear the retained result. Generators
|
|
276
|
+
still own geometry complexity limits. See the [helper source](https://github.com/JasonKoolman/metamesh/blob/main/packages/generator-sdk/src/prepared-generator-module.ts) for
|
|
277
|
+
the reuse checks.
|
|
278
|
+
|
|
180
279
|
Call `parseGeneratedParts()` on executable output before downstream mesh work. It accepts only
|
|
181
280
|
non-empty arrays of uniquely identified parts backed by transferable `Float32Array` and
|
|
182
281
|
`Uint32Array` storage, checks finite coordinates and valid indices, normalizes six-digit hex colors
|
|
183
282
|
to lowercase, and enforces aggregate part, vertex, triangle, and backing-buffer byte limits. Closed-solid,
|
|
184
283
|
manufacturing, and reconstruction checks remain Geometry or Generator responsibilities.
|
|
185
284
|
|
|
285
|
+
Hosts should use `executeGenerator()` as the single synchronous execution seam. It normalizes raw
|
|
286
|
+
values, runs schema and Generator validation, parses generated output, and returns either an explicit
|
|
287
|
+
`invalid` result or a `generated` result. Hosts that prepare asynchronous services first can pass the
|
|
288
|
+
`PreparedParameters` result to `executePreparedGenerator()`; malformed executable output remains a
|
|
289
|
+
thrown runtime failure.
|
|
290
|
+
|
|
186
291
|
## Worker boundary
|
|
187
292
|
|
|
188
293
|
`ValidateRequest`, `GenerateRequest`, `Export3mfRequest`, and the `WorkerResponse` union carry
|
|
@@ -190,18 +295,15 @@ monotonic request IDs. Validation errors are structured normal results; only act
|
|
|
190
295
|
validator, generator, or exporter exceptions use error envelopes. `GeneratedModel` contains only
|
|
191
296
|
structured data and transferable typed arrays—never live Manifold objects. A model can contain
|
|
192
297
|
multiple `GeneratedPart` entries and includes bounds, warnings, and optional statistics. Studio
|
|
193
|
-
supplies export filenames and the
|
|
298
|
+
supplies export filenames and the `MeshTopologyMode` selected in device preferences; generators supply semantic part
|
|
194
299
|
IDs and colors. `original` preserves the generated final triangles, while `optimized` permits
|
|
195
300
|
Studio's bounded planar-only topology pass after generation. This runtime choice is not a Generator
|
|
196
301
|
parameter, package field, or persisted Project contract.
|
|
197
302
|
|
|
198
|
-
##
|
|
303
|
+
## Development
|
|
199
304
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
transferable typed-array buffers.
|
|
203
|
-
- Conditions are data expressions, not callbacks.
|
|
204
|
-
- Validation returns structured issues rather than UI-ready strings or thrown user errors.
|
|
305
|
+
Keep this package independent of React, Zustand, Three.js, Manifold, DOM, and Web Worker APIs.
|
|
306
|
+
The [workspace instructions](https://github.com/JasonKoolman/metamesh/blob/main/packages/generator-sdk/AGENTS.md) own contract review and required checks.
|
|
205
307
|
|
|
206
308
|
## License
|
|
207
309
|
|
package/dist/contracts.d.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import type { FontSelection } from "./fonts.js";
|
|
2
2
|
import type { ParameterGroup, GeneratorDefinition as ParsedGeneratorDefinition } from "./generator-package/schemas/definition.schema.js";
|
|
3
|
-
import type { ArrayParameterDefinition, BooleanParameterDefinition, ChoiceSetParameterDefinition, ColorParameterDefinition, FontParameterDefinition, NumberArrayItemDefinition, NumberArrayParameterDefinition, NumberParameterDefinition, NumericParameterDefinition, ParameterDefinition, SelectOption, SelectParameterDefinition, SliderParameterDefinition, StringArrayItemDefinition, StringArrayParameterDefinition, SvgParameterDefinition, TextParameterDefinition } from "./generator-package/schemas/parameter.schema.js";
|
|
3
|
+
import type { ArrayParameterDefinition, BooleanParameterDefinition, ChoiceSetParameterDefinition, ColorParameterDefinition, FontParameterDefinition, NumberArrayItemDefinition, NumberArrayParameterDefinition, NumberParameterDefinition, NumericParameterDefinition, ParameterDefinition, ProfileParameterDefinition, ProfileScaleReference, SelectOption, SelectParameterDefinition, SliderParameterDefinition, StringArrayItemDefinition, StringArrayParameterDefinition, SvgParameterDefinition, TextParameterDefinition } from "./generator-package/schemas/parameter.schema.js";
|
|
4
4
|
import type { GeneratorRuntimeReference } from "./generator-packages.js";
|
|
5
5
|
import type { GeneratorServices } from "./generator-services.js";
|
|
6
|
-
|
|
6
|
+
import type { ProfileValue } from "./profiles.js";
|
|
7
|
+
export type { ArrayParameterDefinition, FontParameterDefinition, BooleanParameterDefinition, ChoiceSetParameterDefinition, ColorParameterDefinition, NumberArrayItemDefinition, NumberArrayParameterDefinition, NumberParameterDefinition, NumericParameterDefinition, ParameterDefinition, ParameterGroup, ProfileParameterDefinition, ProfileScaleReference, SelectOption, SelectParameterDefinition, StringArrayItemDefinition, StringArrayParameterDefinition, SvgParameterDefinition, SliderParameterDefinition, TextParameterDefinition, };
|
|
7
8
|
export type ScalarParameterValue = number | boolean | string;
|
|
8
|
-
export type ParameterValue = ScalarParameterValue | readonly number[] | readonly string[] | FontSelection;
|
|
9
|
+
export type ParameterValue = ScalarParameterValue | readonly number[] | readonly string[] | FontSelection | ProfileValue;
|
|
9
10
|
export type ParameterValues = Readonly<Record<string, ParameterValue>>;
|
|
10
11
|
type ParameterValueFor<Parameter extends ParameterDefinition> = Parameter extends {
|
|
11
12
|
readonly type: "font";
|
|
12
13
|
} ? FontSelection : Parameter extends {
|
|
14
|
+
readonly type: "profile";
|
|
15
|
+
} ? ProfileValue : Parameter extends {
|
|
13
16
|
readonly type: "number" | "slider";
|
|
14
17
|
} ? number : Parameter extends {
|
|
15
18
|
readonly type: "boolean";
|
|
@@ -55,7 +58,7 @@ export interface ParameterValidationResult {
|
|
|
55
58
|
/**
|
|
56
59
|
* JSON-safe generator identity and parameter metadata.
|
|
57
60
|
*
|
|
58
|
-
* This is the contract used by forms, persistence,
|
|
61
|
+
* This is the contract used by forms, persistence, and package
|
|
59
62
|
* manifests. Basic per-field constraints belong here; executable validation
|
|
60
63
|
* deliberately does not.
|
|
61
64
|
*/
|
|
@@ -105,6 +108,8 @@ export interface ValidateRequest {
|
|
|
105
108
|
readonly parameters: ParameterValues;
|
|
106
109
|
}
|
|
107
110
|
export interface Export3mfRequest {
|
|
111
|
+
/** Project appearance overrides keyed by semantic part ID; does not affect generation. */
|
|
112
|
+
readonly partColors?: Readonly<Record<string, string>>;
|
|
108
113
|
readonly type: "export-3mf";
|
|
109
114
|
readonly requestId: number;
|
|
110
115
|
readonly generatorId: string;
|
package/dist/contracts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EACV,cA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O,CAAC;CAChC;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;CAC9B;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;CAC9B;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;CAC9B;AAED,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG,eAAe,GAAG,gBAAgB,CAAC;AAEjF,MAAM,MAAM,cAAc,GACtB,iBAAiB,GACjB,iBAAiB,GACjB,iBAAiB,GACjB,aAAa,GACb,eAAe,GACf,eAAe,GACf,WAAW,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { GeneratedPart, GeneratorDefinition, GeneratorParams, ParameterValidationResult } from "./contracts.js";
|
|
2
|
+
import { type GeneratedPartsLimits } from "./generated-parts.js";
|
|
3
|
+
import type { GeneratorModule } from "./generator-module.js";
|
|
4
|
+
import type { GeneratorServices } from "./generator-services.js";
|
|
5
|
+
import type { PreparedParameters } from "./parameters.js";
|
|
6
|
+
/** The canonical callback surface required to execute a Generator module. */
|
|
7
|
+
export type GeneratorModuleCallbacks<D extends GeneratorDefinition = GeneratorDefinition, Context = unknown> = Pick<GeneratorModule<D, Context>, "validate" | "generate">;
|
|
8
|
+
export interface ExecuteGeneratorOptions<D extends GeneratorDefinition, Context> {
|
|
9
|
+
readonly definition: D;
|
|
10
|
+
readonly parameters: Readonly<Record<string, unknown>>;
|
|
11
|
+
readonly module: GeneratorModuleCallbacks<D, Context>;
|
|
12
|
+
readonly context: Context;
|
|
13
|
+
readonly services: GeneratorServices;
|
|
14
|
+
readonly limits?: Partial<GeneratedPartsLimits>;
|
|
15
|
+
}
|
|
16
|
+
export interface ExecutePreparedGeneratorOptions<D extends GeneratorDefinition, Context> {
|
|
17
|
+
readonly definition: D;
|
|
18
|
+
readonly prepared: PreparedParameters<D>;
|
|
19
|
+
readonly module: GeneratorModuleCallbacks<D, Context>;
|
|
20
|
+
readonly context: Context;
|
|
21
|
+
readonly services: GeneratorServices;
|
|
22
|
+
readonly limits?: Partial<GeneratedPartsLimits>;
|
|
23
|
+
}
|
|
24
|
+
export interface GeneratorExecutionInvalid<D extends GeneratorDefinition = GeneratorDefinition> {
|
|
25
|
+
readonly type: "invalid";
|
|
26
|
+
readonly parameters: GeneratorParams<D>;
|
|
27
|
+
readonly validation: ParameterValidationResult;
|
|
28
|
+
}
|
|
29
|
+
export interface GeneratorExecutionGenerated<D extends GeneratorDefinition> {
|
|
30
|
+
readonly type: "generated";
|
|
31
|
+
readonly parameters: GeneratorParams<D>;
|
|
32
|
+
readonly validation: ParameterValidationResult;
|
|
33
|
+
readonly parts: readonly GeneratedPart[];
|
|
34
|
+
}
|
|
35
|
+
export type GeneratorExecutionResult<D extends GeneratorDefinition> = GeneratorExecutionInvalid<D> | GeneratorExecutionGenerated<D>;
|
|
36
|
+
/**
|
|
37
|
+
* Executes a generator from an untrusted parameter record.
|
|
38
|
+
*
|
|
39
|
+
* Parameter schema failures stop before generator validation and generation. Generator callback
|
|
40
|
+
* failures and malformed output are intentionally allowed to throw so hosts cannot mistake a
|
|
41
|
+
* broken module for a valid generated model.
|
|
42
|
+
*/
|
|
43
|
+
export declare function executeGenerator<const D extends GeneratorDefinition, Context>(options: ExecuteGeneratorOptions<D, Context>): GeneratorExecutionResult<D>;
|
|
44
|
+
/** Executes an already-normalized parameter set after host services are prepared. */
|
|
45
|
+
export declare function executePreparedGenerator<const D extends GeneratorDefinition, Context>(options: ExecutePreparedGeneratorOptions<D, Context>): GeneratorExecutionResult<D>;
|
|
46
|
+
//# sourceMappingURL=execute-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-generator.d.ts","sourceRoot":"","sources":["../src/execute-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,yBAAyB,EAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAuB,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACtF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,6EAA6E;AAC7E,MAAM,MAAM,wBAAwB,CAClC,CAAC,SAAS,mBAAmB,GAAG,mBAAmB,EACnD,OAAO,GAAG,OAAO,IACf,IAAI,CAAC,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC;AAE/D,MAAM,WAAW,uBAAuB,CAAC,CAAC,SAAS,mBAAmB,EAAE,OAAO;IAC7E,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACvD,QAAQ,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IACtD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACjD;AAED,MAAM,WAAW,+BAA+B,CAAC,CAAC,SAAS,mBAAmB,EAAE,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mB,EAAE,OAAO,EACnF,OAAO,EAAE,+BAA+B,CAAC,CAAC,EAAE,OAAO,CAAC,GACnD,wBAAwB,CAAC,CAAC,CAAC,CAuB7B"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { parseGeneratedParts } from "./generated-parts.js";
|
|
2
|
+
import { aggregateParameterIssues, parseParameterIssues, prepareParameters } from "./parameters.js";
|
|
3
|
+
function invalidResult(prepared) {
|
|
4
|
+
return Object.freeze({
|
|
5
|
+
type: "invalid",
|
|
6
|
+
parameters: prepared.parameters,
|
|
7
|
+
validation: prepared.validation,
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Executes a generator from an untrusted parameter record.
|
|
12
|
+
*
|
|
13
|
+
* Parameter schema failures stop before generator validation and generation. Generator callback
|
|
14
|
+
* failures and malformed output are intentionally allowed to throw so hosts cannot mistake a
|
|
15
|
+
* broken module for a valid generated model.
|
|
16
|
+
*/
|
|
17
|
+
export function executeGenerator(options) {
|
|
18
|
+
return executePreparedGenerator({
|
|
19
|
+
...options,
|
|
20
|
+
prepared: prepareParameters(options.definition, options.parameters),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/** Executes an already-normalized parameter set after host services are prepared. */
|
|
24
|
+
export function executePreparedGenerator(options) {
|
|
25
|
+
const { definition, module, prepared, context, services, limits } = options;
|
|
26
|
+
if (!prepared.validation.isValid)
|
|
27
|
+
return invalidResult(prepared);
|
|
28
|
+
const generatorIssues = parseParameterIssues(definition, module.validate(prepared.parameters, services));
|
|
29
|
+
const validation = aggregateParameterIssues(prepared.validation.issues, generatorIssues);
|
|
30
|
+
if (!validation.isValid) {
|
|
31
|
+
return invalidResult({ parameters: prepared.parameters, validation });
|
|
32
|
+
}
|
|
33
|
+
const parts = parseGeneratedParts(module.generate(prepared.parameters, context, services), limits);
|
|
34
|
+
return Object.freeze({
|
|
35
|
+
type: "generated",
|
|
36
|
+
parameters: prepared.parameters,
|
|
37
|
+
validation,
|
|
38
|
+
parts,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=execute-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-generator.js","sourceRoot":"","sources":["../src/execute-generator.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,mBAAmB,EAA6B,MAAM,sBAAsB,CAAC;AAGtF,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AA2CpG,SAAS,aAAa,CACpB,QAA+B;IAE/B,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,UAAU,EAAE,QAAQ,CAAC,UAAU;KAChC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAA4C;IAE5C,OAAO,wBAAwB,CAAC;QAC9B,GAAG,OAAO;QACV,QAAQ,EAAE,iBAAiB,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC;KACpE,CAAC,CAAC;AACL,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,wBAAwB,CACtC,OAAoD;IAEpD,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC5E,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO;QAAE,OAAO,aAAa,CAAC,QAAQ,CAAC,CAAC;IAEjE,MAAM,eAAe,GAAG,oBAAoB,CAC1C,UAAU,EACV,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,CAC/C,CAAC;IACF,MAAM,UAAU,GAAG,wBAAwB,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACzF,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QACxB,OAAO,aAAa,CAAC,EAAE,UAAU,EAAE,QAAQ,CAAC,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,MAAM,KAAK,GAAG,mBAAmB,CAC/B,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC,EACvD,MAAM,CACP,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,IAAI,EAAE,WAAW;QACjB,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,UAAU;QACV,KAAK;KACN,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const METAMESH_RUNTIME_VERSION = "1.
|
|
1
|
+
export declare const METAMESH_RUNTIME_VERSION = "1.3.0";
|
|
2
2
|
export declare const GENERATOR_PACKAGE_FORMAT_VERSION = 1;
|
|
3
3
|
export declare const MAX_GENERATOR_PACKAGE_BYTES: number;
|
|
4
4
|
/** Portable metadata limits enforced before package content reaches Studio. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const METAMESH_RUNTIME_VERSION = "1.
|
|
1
|
+
export const METAMESH_RUNTIME_VERSION = "1.3.0";
|
|
2
2
|
export const GENERATOR_PACKAGE_FORMAT_VERSION = 1;
|
|
3
3
|
export const MAX_GENERATOR_PACKAGE_BYTES = 5 * 1024 * 1024;
|
|
4
4
|
/** Portable metadata limits enforced before package content reaches Studio. */
|
|
@@ -31,6 +31,7 @@ export declare const generatorDefinitionSchema: z.ZodObject<{
|
|
|
31
31
|
max: z.ZodOptional<z.ZodNumber>;
|
|
32
32
|
step: z.ZodOptional<z.ZodNumber>;
|
|
33
33
|
default: z.ZodNumber;
|
|
34
|
+
role: z.ZodOptional<z.ZodLiteral<"curve-resolution">>;
|
|
34
35
|
id: z.ZodString;
|
|
35
36
|
label: z.ZodString;
|
|
36
37
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -43,6 +44,7 @@ export declare const generatorDefinitionSchema: z.ZodObject<{
|
|
|
43
44
|
max: z.ZodNumber;
|
|
44
45
|
step: z.ZodNumber;
|
|
45
46
|
default: z.ZodNumber;
|
|
47
|
+
role: z.ZodOptional<z.ZodLiteral<"curve-resolution">>;
|
|
46
48
|
id: z.ZodString;
|
|
47
49
|
label: z.ZodString;
|
|
48
50
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -115,6 +117,23 @@ export declare const generatorDefinitionSchema: z.ZodObject<{
|
|
|
115
117
|
group: z.ZodOptional<z.ZodString>;
|
|
116
118
|
unit: z.ZodOptional<z.ZodString>;
|
|
117
119
|
visibleWhen: z.ZodOptional<z.ZodType<import("../../conditions.js").ConditionExpression, unknown, z.core.$ZodTypeInternals<import("../../conditions.js").ConditionExpression, unknown>>>;
|
|
120
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
121
|
+
type: z.ZodLiteral<"profile">;
|
|
122
|
+
default: z.ZodPipe<z.ZodCustom<import("../../profiles.js").ProfileValue, import("../../profiles.js").ProfileValue>, z.ZodTransform<import("../../profiles.js").ProfileValue, import("../../profiles.js").ProfileValue>>;
|
|
123
|
+
radiusScale: z.ZodOptional<z.ZodObject<{
|
|
124
|
+
parameterId: z.ZodString;
|
|
125
|
+
factor: z.ZodNumber;
|
|
126
|
+
}, z.core.$strict>>;
|
|
127
|
+
heightScale: z.ZodOptional<z.ZodObject<{
|
|
128
|
+
parameterId: z.ZodString;
|
|
129
|
+
factor: z.ZodNumber;
|
|
130
|
+
}, z.core.$strict>>;
|
|
131
|
+
id: z.ZodString;
|
|
132
|
+
label: z.ZodString;
|
|
133
|
+
description: z.ZodOptional<z.ZodString>;
|
|
134
|
+
group: z.ZodOptional<z.ZodString>;
|
|
135
|
+
unit: z.ZodOptional<z.ZodString>;
|
|
136
|
+
visibleWhen: z.ZodOptional<z.ZodType<import("../../conditions.js").ConditionExpression, unknown, z.core.$ZodTypeInternals<import("../../conditions.js").ConditionExpression, unknown>>>;
|
|
118
137
|
}, z.core.$strict>, z.ZodObject<{
|
|
119
138
|
type: z.ZodLiteral<"array">;
|
|
120
139
|
default: z.ZodUnion<readonly [z.ZodArray<z.ZodNumber>, z.ZodArray<z.ZodString>]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.schema.d.ts","sourceRoot":"","sources":["../../../src/generator-package/schemas/definition.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB,eAAO,MAAM,oBAAoB;;;;;kBAK/B,CAAC;AAEH,eAAO,MAAM,yBAAyB
|
|
1
|
+
{"version":3,"file":"definition.schema.d.ts","sourceRoot":"","sources":["../../../src/generator-package/schemas/definition.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB,eAAO,MAAM,oBAAoB;;;;;kBAK/B,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAOpC,CAAC;AAEH,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE,GACpD,SAAS,YAAY,CAAC,IAAI,CAAC,EAAE,GAC7B,CAAC,SAAS,MAAM,GACd;IAAE,QAAQ,EAAE,GAAG,IAAI,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;CAAE,GACnD,CAAC,CAAC;AAER,MAAM,MAAM,cAAc,GAAG,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC;AACjF,MAAM,MAAM,mBAAmB,GAAG,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,yBAAyB,CAAC,CAAC,CAAC"}
|