@metamesh/generator-sdk 0.1.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 +7 -0
- package/LICENSE +200 -0
- package/README.md +187 -0
- package/dist/conditions.d.ts +35 -0
- package/dist/conditions.d.ts.map +1 -0
- package/dist/conditions.js +42 -0
- package/dist/conditions.js.map +1 -0
- package/dist/contracts.d.ts +160 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +2 -0
- package/dist/contracts.js.map +1 -0
- package/dist/generated-parts.d.ts +17 -0
- package/dist/generated-parts.d.ts.map +1 -0
- package/dist/generated-parts.js +179 -0
- package/dist/generated-parts.js.map +1 -0
- package/dist/generator-module.d.ts +48 -0
- package/dist/generator-module.d.ts.map +1 -0
- package/dist/generator-module.js +112 -0
- package/dist/generator-module.js.map +1 -0
- package/dist/generator-package/constants.d.ts +16 -0
- package/dist/generator-package/constants.d.ts.map +1 -0
- package/dist/generator-package/constants.js +16 -0
- package/dist/generator-package/constants.js.map +1 -0
- package/dist/generator-package/errors.d.ts +6 -0
- package/dist/generator-package/errors.d.ts.map +1 -0
- package/dist/generator-package/errors.js +22 -0
- package/dist/generator-package/errors.js.map +1 -0
- package/dist/generator-package/index.d.ts +29 -0
- package/dist/generator-package/index.d.ts.map +1 -0
- package/dist/generator-package/index.js +44 -0
- package/dist/generator-package/index.js.map +1 -0
- package/dist/generator-package/schemas/common.schema.d.ts +13 -0
- package/dist/generator-package/schemas/common.schema.d.ts.map +1 -0
- package/dist/generator-package/schemas/common.schema.js +33 -0
- package/dist/generator-package/schemas/common.schema.js.map +1 -0
- package/dist/generator-package/schemas/condition.schema.d.ts +5 -0
- package/dist/generator-package/schemas/condition.schema.d.ts.map +1 -0
- package/dist/generator-package/schemas/condition.schema.js +27 -0
- package/dist/generator-package/schemas/condition.schema.js.map +1 -0
- package/dist/generator-package/schemas/definition.schema.d.ts +137 -0
- package/dist/generator-package/schemas/definition.schema.d.ts.map +1 -0
- package/dist/generator-package/schemas/definition.schema.js +19 -0
- package/dist/generator-package/schemas/definition.schema.js.map +1 -0
- package/dist/generator-package/schemas/descriptor.schema.d.ts +23 -0
- package/dist/generator-package/schemas/descriptor.schema.d.ts.map +1 -0
- package/dist/generator-package/schemas/descriptor.schema.js +17 -0
- package/dist/generator-package/schemas/descriptor.schema.js.map +1 -0
- package/dist/generator-package/schemas/manifest.schema.d.ts +6988 -0
- package/dist/generator-package/schemas/manifest.schema.d.ts.map +1 -0
- package/dist/generator-package/schemas/manifest.schema.js +34 -0
- package/dist/generator-package/schemas/manifest.schema.js.map +1 -0
- package/dist/generator-package/schemas/parameter.schema.d.ts +269 -0
- package/dist/generator-package/schemas/parameter.schema.d.ts.map +1 -0
- package/dist/generator-package/schemas/parameter.schema.js +103 -0
- package/dist/generator-package/schemas/parameter.schema.js.map +1 -0
- package/dist/generator-package/schemas/preset.schema.d.ts +16 -0
- package/dist/generator-package/schemas/preset.schema.d.ts.map +1 -0
- package/dist/generator-package/schemas/preset.schema.js +22 -0
- package/dist/generator-package/schemas/preset.schema.js.map +1 -0
- package/dist/generator-package/validate-definition.d.ts +8 -0
- package/dist/generator-package/validate-definition.d.ts.map +1 -0
- package/dist/generator-package/validate-definition.js +239 -0
- package/dist/generator-package/validate-definition.js.map +1 -0
- package/dist/generator-package/validate-manifest.d.ts +7 -0
- package/dist/generator-package/validate-manifest.d.ts.map +1 -0
- package/dist/generator-package/validate-manifest.js +47 -0
- package/dist/generator-package/validate-manifest.js.map +1 -0
- package/dist/generator-package/version-format.d.ts +5 -0
- package/dist/generator-package/version-format.d.ts.map +1 -0
- package/dist/generator-package/version-format.js +7 -0
- package/dist/generator-package/version-format.js.map +1 -0
- package/dist/generator-package/versions.d.ts +3 -0
- package/dist/generator-package/versions.d.ts.map +1 -0
- package/dist/generator-package/versions.js +36 -0
- package/dist/generator-package/versions.js.map +1 -0
- package/dist/generator-packages.d.ts +2 -0
- package/dist/generator-packages.d.ts.map +1 -0
- package/dist/generator-packages.js +2 -0
- package/dist/generator-packages.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/parameters.d.ts +69 -0
- package/dist/parameters.d.ts.map +1 -0
- package/dist/parameters.js +532 -0
- package/dist/parameters.js.map +1 -0
- package/dist/source-visibility.d.ts +9 -0
- package/dist/source-visibility.d.ts.map +1 -0
- package/dist/source-visibility.js +2 -0
- package/dist/source-visibility.js.map +1 -0
- package/dist/url-state.d.ts +13 -0
- package/dist/url-state.d.ts.map +1 -0
- package/dist/url-state.js +137 -0
- package/dist/url-state.js.map +1 -0
- package/package.json +45 -0
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice.
|
|
187
|
+
|
|
188
|
+
Copyright 2026 MetaMesh
|
|
189
|
+
|
|
190
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
191
|
+
you may not use this file except in compliance with the License.
|
|
192
|
+
You may obtain a copy of the License at
|
|
193
|
+
|
|
194
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
195
|
+
|
|
196
|
+
Unless required by applicable law or agreed to in writing, software
|
|
197
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
198
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
199
|
+
See the License for the specific language governing permissions and
|
|
200
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# `@metamesh/generator-sdk`
|
|
2
|
+
|
|
3
|
+
Portable contracts and helpers shared by Studio, built-in generators, and workers.
|
|
4
|
+
|
|
5
|
+
> **Preview:** `0.x` releases may contain breaking changes in a minor release. Patch releases are
|
|
6
|
+
> intended to remain compatible within the same minor line. A stable support commitment begins only
|
|
7
|
+
> after an explicit `1.0.0` review.
|
|
8
|
+
|
|
9
|
+
Install the public package from npm:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add @metamesh/generator-sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The package root is the only supported import path.
|
|
16
|
+
|
|
17
|
+
The package owns parameter/group definitions, serializable conditions, default derivation and
|
|
18
|
+
normalization, structured validation, runtime envelopes, normalized generated-model results, and
|
|
19
|
+
serializable catalog/package/install contracts. Project persistence belongs to Studio;
|
|
20
|
+
release-state transitions belong to trusted database/tooling boundaries.
|
|
21
|
+
|
|
22
|
+
Zod is its only runtime dependency and is used at untrusted package-data boundaries. The package
|
|
23
|
+
root owns exact exports and its strict schemas own accepted shapes. Generator package delivery
|
|
24
|
+
remains a separate host responsibility.
|
|
25
|
+
|
|
26
|
+
## Parameter definitions
|
|
27
|
+
|
|
28
|
+
Definitions use the `type` discriminant with `number`, `slider`, `boolean`, `select`, `choice-set`,
|
|
29
|
+
`color`, `text`, `svg`, and homogeneous `array` variants. A `slider` requires `min`, `max`, and
|
|
30
|
+
`step`, while a `number` may omit any of those constraints. Visibility uses serializable
|
|
31
|
+
`ConditionExpression` values; `evaluateCondition` supports `all`, `any`, `not`,
|
|
32
|
+
equality/inequality, numeric comparisons, and `choice-set` membership through `contains`.
|
|
33
|
+
|
|
34
|
+
Given a Generator `definition` and untrusted `persistedValues`:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import {
|
|
38
|
+
createParamCodec,
|
|
39
|
+
decodeParameterState,
|
|
40
|
+
defineGenerator,
|
|
41
|
+
EMPTY_SVG_PARAMETER_DEFAULT,
|
|
42
|
+
encodeParameterState,
|
|
43
|
+
prepareParameters,
|
|
44
|
+
type GeneratorParams,
|
|
45
|
+
} from "@metamesh/generator-sdk";
|
|
46
|
+
|
|
47
|
+
const definition = defineGenerator({/* serializable definition */});
|
|
48
|
+
type Parameters = GeneratorParams<typeof definition>;
|
|
49
|
+
|
|
50
|
+
const { parameters, validation } = prepareParameters(definition, persistedValues);
|
|
51
|
+
const strictParameters = createParamCodec(definition).parse(workerValues);
|
|
52
|
+
const query = encodeParameterState(definition, parameters);
|
|
53
|
+
const restored = decodeParameterState(definition, query);
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Normalization drops unknown parameter-value keys, fills missing or invalid values from each
|
|
57
|
+
parameter's declared `default`, clamps numbers, and returns a fresh frozen map. Strict codecs instead
|
|
58
|
+
reject missing, unknown, invalid, or noncanonical values and return cloned frozen arrays.
|
|
59
|
+
`prepareParameters()` normalizes once and returns that same canonical map with the combined schema
|
|
60
|
+
and Generator-owned validation result. Definitions accept only canonical parameter types. URL
|
|
61
|
+
state is versioned and only includes known non-default values.
|
|
62
|
+
Malformed, obsolete, or invalid URL values safely fall back to defaults. SVG runtime values remain
|
|
63
|
+
standard strings, are limited to 256 KiB each and 512 KiB per normalized project, and are omitted
|
|
64
|
+
from parameter URLs. URL scalars overlay a host-supplied persisted base so device-local SVG values
|
|
65
|
+
are never erased by a shared URL.
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
const profile = {
|
|
69
|
+
id: "profile",
|
|
70
|
+
label: "Profile",
|
|
71
|
+
type: "svg",
|
|
72
|
+
default: EMPTY_SVG_PARAMETER_DEFAULT,
|
|
73
|
+
} as const;
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Choice-set definitions use fixed, uniquely valued options and a default array of selected option
|
|
77
|
+
values. Optional `minSelections` and `maxSelections` bound the selection count. Normalized values
|
|
78
|
+
are unique and use option declaration order; invalid values fall back to the canonical default.
|
|
79
|
+
`{ param: "outputs", contains: "nut" }` may reference only a `choice-set` and one of its declared
|
|
80
|
+
option values.
|
|
81
|
+
|
|
82
|
+
Array definitions declare `items.type` as `number` or `string`. They may constrain `minItems` and
|
|
83
|
+
`maxItems`; number items may also declare `min`, `max`, `step`, and `unit`. Array-valued controls are
|
|
84
|
+
cloned at normalization and persistence boundaries, and URL state encodes them as deterministic
|
|
85
|
+
JSON without changing scalar URL encoding. Conditions may compare scalar controls or test
|
|
86
|
+
`choice-set` membership; arbitrary arrays cannot be condition operands.
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
const points = {
|
|
90
|
+
id: "points",
|
|
91
|
+
label: "Point sizes",
|
|
92
|
+
type: "array",
|
|
93
|
+
default: [4, 8],
|
|
94
|
+
minItems: 1,
|
|
95
|
+
items: { type: "number", min: 0, unit: "mm" },
|
|
96
|
+
} as const;
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Groups are ordered sections with stable IDs, user-facing labels, optional descriptions, and an
|
|
100
|
+
optional `collapsed` default. Parameters without a group render in Studio's General section.
|
|
101
|
+
|
|
102
|
+
`GeneratorDefinition` is callback-free, JSON-safe metadata used by forms, manifests, persistence,
|
|
103
|
+
normalization, and URL state. Its `min`, `max`, options, and other field constraints are portable
|
|
104
|
+
data. `defineGenerator()` preserves literal IDs and select options so `GeneratorParams`,
|
|
105
|
+
`GeneratorParamId`, `GeneratorIssue`, validators, defaults, and presets derive from the definition.
|
|
106
|
+
Keep derived-value, cross-parameter, warning, and geometry checks in a separate TypeScript
|
|
107
|
+
validator:
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
import { defineValidator } from "@metamesh/generator-sdk";
|
|
111
|
+
|
|
112
|
+
export const validate = defineValidator(definition, (parameters) => {
|
|
113
|
+
return parameters.outerDiameter - parameters.boreDiameter < 2
|
|
114
|
+
? [{ severity: "error", parameterId: "boreDiameter", message: "Leave at least a 1 mm wall." }]
|
|
115
|
+
: [];
|
|
116
|
+
});
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Pass the validator to `prepareParameters()` or `validateParameters()`. Use
|
|
120
|
+
`definePresets(definition, presets)` to require complete definition-derived preset values.
|
|
121
|
+
|
|
122
|
+
Schema editors only receive `definition`; they never serialize, parse, or rewrite validators.
|
|
123
|
+
Downloaded manifests remain callback-free and do not define a validation rules language. Runtime
|
|
124
|
+
validation receives normalized, frozen values. Its issue array is strictly checked and bounded;
|
|
125
|
+
malformed output is a runtime error rather than a user-facing validation result.
|
|
126
|
+
|
|
127
|
+
Definitions do not contain a second defaults map. Use `getDefaultParameters(definition)`
|
|
128
|
+
to derive a fresh frozen value map from parameter definitions. IDs are bounded safe keys; package
|
|
129
|
+
manifests, definitions, descriptors, conditions, and nested parameter objects reject unknown fields.
|
|
130
|
+
Definitions are bounded to 64 groups and 256 parameters, arrays to 1,024 items, options to 512,
|
|
131
|
+
presets to 256, and condition composition to 8 levels with 32 children per node. Strict rejection
|
|
132
|
+
is intentional so obsolete or pathological package shapes cannot be mistaken for the current
|
|
133
|
+
contract.
|
|
134
|
+
|
|
135
|
+
## Compiled module and output boundary
|
|
136
|
+
|
|
137
|
+
`defineGeneratorModule()` assembles and freezes the exact five-field format-1 runtime surface from
|
|
138
|
+
a typed definition, validator, and generator without coupling the SDK to a modeling library:
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
const runtime = defineGeneratorModule<typeof definition, ModelingContext>({
|
|
142
|
+
definition,
|
|
143
|
+
validate,
|
|
144
|
+
generate,
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
export const { formatVersion, generate, generatorId, validate, version } = runtime;
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
The author helper accepts definition-derived canonical parameters and adds neither runtime checking
|
|
151
|
+
nor a parameter decoder. This keeps self-contained releases small and lets a host reuse the exact
|
|
152
|
+
frozen map produced by `prepareParameters()`.
|
|
153
|
+
`parseGeneratorModule(namespace, definition)` is the corresponding host-side boundary for evaluated
|
|
154
|
+
packages: it requires exactly those five exports, verifies identity against the authoritative
|
|
155
|
+
definition, wraps callbacks to enforce synchronous array results, and returns two frozen lanes. Use `canonical`
|
|
156
|
+
only with host-prepared parameters; use `strict` for raw boundary values that must pass the host's
|
|
157
|
+
codec. Extra exports fail closed.
|
|
158
|
+
|
|
159
|
+
Call `parseGeneratedParts()` on executable output before downstream mesh work. It accepts only
|
|
160
|
+
non-empty arrays of uniquely identified parts backed by transferable `Float32Array` and
|
|
161
|
+
`Uint32Array` storage, checks finite coordinates and valid indices, normalizes six-digit hex colors
|
|
162
|
+
to lowercase, and enforces aggregate part, vertex, triangle, and backing-buffer byte limits. Closed-solid,
|
|
163
|
+
manufacturing, and reconstruction checks remain Geometry or Generator responsibilities.
|
|
164
|
+
|
|
165
|
+
## Worker boundary
|
|
166
|
+
|
|
167
|
+
`ValidateRequest`, `GenerateRequest`, `Export3mfRequest`, and the `WorkerResponse` union carry
|
|
168
|
+
monotonic request IDs. Validation errors are structured normal results; only actual worker,
|
|
169
|
+
validator, generator, or exporter exceptions use error envelopes. `GeneratedModel` contains only
|
|
170
|
+
structured data and transferable typed arrays—never live Manifold objects. A model can contain
|
|
171
|
+
multiple `GeneratedPart` entries and includes bounds, warnings, and optional statistics. Studio
|
|
172
|
+
supplies export filenames and the session-local `MeshTopologyMode`; generators supply semantic part
|
|
173
|
+
IDs and colors. `original` preserves the generated final triangles, while `optimized` permits
|
|
174
|
+
Studio's bounded planar-only topology pass after generation. This runtime choice is not a Generator
|
|
175
|
+
parameter, package field, or persisted Project contract.
|
|
176
|
+
|
|
177
|
+
## Constraints
|
|
178
|
+
|
|
179
|
+
- No React, Zustand, Three.js, Manifold, DOM, or Web Worker dependencies.
|
|
180
|
+
- Public data crossing a worker or persistence boundary must be serializable, except explicitly
|
|
181
|
+
transferable typed-array buffers.
|
|
182
|
+
- Conditions are data expressions, not callbacks.
|
|
183
|
+
- Validation returns structured issues rather than UI-ready strings or thrown user errors.
|
|
184
|
+
|
|
185
|
+
## License
|
|
186
|
+
|
|
187
|
+
Apache-2.0. The complete terms are included in `LICENSE`.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ParameterValues, ScalarParameterValue } from "./contracts.js";
|
|
2
|
+
export type ConditionExpression = {
|
|
3
|
+
readonly all: readonly ConditionExpression[];
|
|
4
|
+
} | {
|
|
5
|
+
readonly any: readonly ConditionExpression[];
|
|
6
|
+
} | {
|
|
7
|
+
readonly not: ConditionExpression;
|
|
8
|
+
} | {
|
|
9
|
+
readonly param: string;
|
|
10
|
+
readonly eq: ScalarParameterValue;
|
|
11
|
+
} | {
|
|
12
|
+
readonly param: string;
|
|
13
|
+
readonly ne: ScalarParameterValue;
|
|
14
|
+
} | {
|
|
15
|
+
readonly param: string;
|
|
16
|
+
readonly contains: string;
|
|
17
|
+
} | {
|
|
18
|
+
readonly param: string;
|
|
19
|
+
readonly gt: number;
|
|
20
|
+
} | {
|
|
21
|
+
readonly param: string;
|
|
22
|
+
readonly gte: number;
|
|
23
|
+
} | {
|
|
24
|
+
readonly param: string;
|
|
25
|
+
readonly lt: number;
|
|
26
|
+
} | {
|
|
27
|
+
readonly param: string;
|
|
28
|
+
readonly lte: number;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Evaluates a serializable visibility condition. A comparison against a
|
|
32
|
+
* missing parameter is always false, including `ne`.
|
|
33
|
+
*/
|
|
34
|
+
export declare function evaluateCondition(condition: ConditionExpression, parameters: ParameterValues): boolean;
|
|
35
|
+
//# sourceMappingURL=conditions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditions.d.ts","sourceRoot":"","sources":["../src/conditions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE5E,MAAM,MAAM,mBAAmB,GAC3B;IAAE,QAAQ,CAAC,GAAG,EAAE,SAAS,mBAAmB,EAAE,CAAA;CAAE,GAChD;IAAE,QAAQ,CAAC,GAAG,EAAE,SAAS,mBAAmB,EAAE,CAAA;CAAE,GAChD;IAAE,QAAQ,CAAC,GAAG,EAAE,mBAAmB,CAAA;CAAE,GACrC;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,oBAAoB,CAAA;CAAE,GAC7D;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,oBAAoB,CAAA;CAAE,GAC7D;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACrD;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAC/C;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAChD;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAC/C;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAErD;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,mBAAmB,EAC9B,UAAU,EAAE,eAAe,GAC1B,OAAO,CAgDT"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evaluates a serializable visibility condition. A comparison against a
|
|
3
|
+
* missing parameter is always false, including `ne`.
|
|
4
|
+
*/
|
|
5
|
+
export function evaluateCondition(condition, parameters) {
|
|
6
|
+
if ("all" in condition) {
|
|
7
|
+
return condition.all.every((child) => evaluateCondition(child, parameters));
|
|
8
|
+
}
|
|
9
|
+
if ("any" in condition) {
|
|
10
|
+
return condition.any.some((child) => evaluateCondition(child, parameters));
|
|
11
|
+
}
|
|
12
|
+
if ("not" in condition) {
|
|
13
|
+
return !evaluateCondition(condition.not, parameters);
|
|
14
|
+
}
|
|
15
|
+
if (!Object.hasOwn(parameters, condition.param)) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
const value = parameters[condition.param];
|
|
19
|
+
if ("eq" in condition) {
|
|
20
|
+
return Object.is(value, condition.eq);
|
|
21
|
+
}
|
|
22
|
+
if ("ne" in condition) {
|
|
23
|
+
return !Object.is(value, condition.ne);
|
|
24
|
+
}
|
|
25
|
+
if ("contains" in condition) {
|
|
26
|
+
return Array.isArray(value) && value.includes(condition.contains);
|
|
27
|
+
}
|
|
28
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
if ("gt" in condition) {
|
|
32
|
+
return value > condition.gt;
|
|
33
|
+
}
|
|
34
|
+
if ("gte" in condition) {
|
|
35
|
+
return value >= condition.gte;
|
|
36
|
+
}
|
|
37
|
+
if ("lt" in condition) {
|
|
38
|
+
return value < condition.lt;
|
|
39
|
+
}
|
|
40
|
+
return value <= condition.lte;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=conditions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditions.js","sourceRoot":"","sources":["../src/conditions.ts"],"names":[],"mappings":"AAcA;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,SAA8B,EAC9B,UAA2B;IAE3B,IAAI,KAAK,IAAI,SAAS,EAAE,CAAC;QACvB,OAAO,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;IAC9E,CAAC;IAED,IAAI,KAAK,IAAI,SAAS,EAAE,CAAC;QACvB,OAAO,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;IAC7E,CAAC;IAED,IAAI,KAAK,IAAI,SAAS,EAAE,CAAC;QACvB,OAAO,CAAC,iBAAiB,CAAC,SAAS,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IACvD,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,KAAK,GAAG,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAE1C,IAAI,IAAI,IAAI,SAAS,EAAE,CAAC;QACtB,OAAO,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC;IACxC,CAAC;IAED,IAAI,IAAI,IAAI,SAAS,EAAE,CAAC;QACtB,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC;IACzC,CAAC;IAED,IAAI,UAAU,IAAI,SAAS,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACpE,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACzD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,IAAI,IAAI,SAAS,EAAE,CAAC;QACtB,OAAO,KAAK,GAAG,SAAS,CAAC,EAAE,CAAC;IAC9B,CAAC;IAED,IAAI,KAAK,IAAI,SAAS,EAAE,CAAC;QACvB,OAAO,KAAK,IAAI,SAAS,CAAC,GAAG,CAAC;IAChC,CAAC;IAED,IAAI,IAAI,IAAI,SAAS,EAAE,CAAC;QACtB,OAAO,KAAK,GAAG,SAAS,CAAC,EAAE,CAAC;IAC9B,CAAC;IAED,OAAO,KAAK,IAAI,SAAS,CAAC,GAAG,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import type { ParameterGroup, GeneratorDefinition as ParsedGeneratorDefinition } from "./generator-package/schemas/definition.schema.js";
|
|
2
|
+
import type { ArrayParameterDefinition, BooleanParameterDefinition, ChoiceSetParameterDefinition, ColorParameterDefinition, NumberArrayItemDefinition, NumberArrayParameterDefinition, NumberParameterDefinition, NumericParameterDefinition, ParameterDefinition, SelectOption, SelectParameterDefinition, SliderParameterDefinition, StringArrayItemDefinition, StringArrayParameterDefinition, SvgParameterDefinition, TextParameterDefinition } from "./generator-package/schemas/parameter.schema.js";
|
|
3
|
+
import type { GeneratorRuntimeReference } from "./generator-packages.js";
|
|
4
|
+
export type { ArrayParameterDefinition, BooleanParameterDefinition, ChoiceSetParameterDefinition, ColorParameterDefinition, NumberArrayItemDefinition, NumberArrayParameterDefinition, NumberParameterDefinition, NumericParameterDefinition, ParameterDefinition, ParameterGroup, SelectOption, SelectParameterDefinition, StringArrayItemDefinition, StringArrayParameterDefinition, SvgParameterDefinition, SliderParameterDefinition, TextParameterDefinition, };
|
|
5
|
+
export type ScalarParameterValue = number | boolean | string;
|
|
6
|
+
export type ParameterValue = ScalarParameterValue | readonly number[] | readonly string[];
|
|
7
|
+
export type ParameterValues = Readonly<Record<string, ParameterValue>>;
|
|
8
|
+
type ParameterValueFor<Parameter extends ParameterDefinition> = Parameter extends {
|
|
9
|
+
readonly type: "number" | "slider";
|
|
10
|
+
} ? number : Parameter extends {
|
|
11
|
+
readonly type: "boolean";
|
|
12
|
+
} ? boolean : Parameter extends {
|
|
13
|
+
readonly type: "select";
|
|
14
|
+
readonly options: readonly {
|
|
15
|
+
readonly value: infer Value extends string;
|
|
16
|
+
}[];
|
|
17
|
+
} ? Value : Parameter extends {
|
|
18
|
+
readonly type: "choice-set";
|
|
19
|
+
readonly options: readonly {
|
|
20
|
+
readonly value: infer Value extends string;
|
|
21
|
+
}[];
|
|
22
|
+
} ? readonly Value[] : Parameter extends {
|
|
23
|
+
readonly type: "array";
|
|
24
|
+
readonly items: infer Items;
|
|
25
|
+
} ? Items extends {
|
|
26
|
+
readonly type: "number";
|
|
27
|
+
} ? readonly number[] : readonly string[] : string;
|
|
28
|
+
/** Exact normalized parameter values derived from a Generator definition. */
|
|
29
|
+
export type GeneratorParams<D extends GeneratorDefinition> = {
|
|
30
|
+
readonly [Parameter in D["parameters"][number] as Parameter["id"]]: ParameterValueFor<Parameter>;
|
|
31
|
+
};
|
|
32
|
+
/** The declared parameter ID union for a Generator definition. */
|
|
33
|
+
export type GeneratorParamId<D extends GeneratorDefinition> = Extract<D["parameters"][number]["id"], string>;
|
|
34
|
+
export type BaseParameterDefinition = Pick<NumericParameterDefinition, "id" | "label" | "description" | "group" | "unit" | "visibleWhen">;
|
|
35
|
+
export type ParameterIssueSeverity = "error" | "warning";
|
|
36
|
+
export interface ParameterIssue {
|
|
37
|
+
readonly severity: ParameterIssueSeverity;
|
|
38
|
+
readonly parameterId?: string;
|
|
39
|
+
readonly message: string;
|
|
40
|
+
}
|
|
41
|
+
/** A validation issue whose optional parameter ID is tied to one definition. */
|
|
42
|
+
export type GeneratorIssue<D extends GeneratorDefinition = GeneratorDefinition> = Omit<ParameterIssue, "parameterId"> & {
|
|
43
|
+
readonly parameterId?: GeneratorParamId<D>;
|
|
44
|
+
};
|
|
45
|
+
export interface ParameterValidationResult {
|
|
46
|
+
readonly isValid: boolean;
|
|
47
|
+
readonly issues: readonly ParameterIssue[];
|
|
48
|
+
readonly errors: readonly ParameterIssue[];
|
|
49
|
+
readonly warnings: readonly ParameterIssue[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* JSON-safe generator identity and parameter metadata.
|
|
53
|
+
*
|
|
54
|
+
* This is the contract used by forms, persistence, URL state, and package
|
|
55
|
+
* manifests. Basic per-field constraints belong here; executable validation
|
|
56
|
+
* deliberately does not.
|
|
57
|
+
*/
|
|
58
|
+
export type GeneratorDefinition = ParsedGeneratorDefinition;
|
|
59
|
+
/** Executable, generator-owned cross-parameter and geometry validation. */
|
|
60
|
+
export type GeneratorValidator<D extends GeneratorDefinition = GeneratorDefinition> = (parameters: GeneratorParams<D>) => readonly GeneratorIssue<D>[];
|
|
61
|
+
export type Vec3 = readonly [number, number, number];
|
|
62
|
+
export interface ModelBounds {
|
|
63
|
+
readonly min: Vec3;
|
|
64
|
+
readonly max: Vec3;
|
|
65
|
+
}
|
|
66
|
+
export interface ModelStats {
|
|
67
|
+
readonly triangles?: number;
|
|
68
|
+
readonly vertices?: number;
|
|
69
|
+
readonly generationMs?: number;
|
|
70
|
+
readonly volumeMm3?: number;
|
|
71
|
+
}
|
|
72
|
+
/** Selects whether Studio preserves or locally improves final planar triangle connectivity. */
|
|
73
|
+
export type MeshTopologyMode = "original" | "optimized";
|
|
74
|
+
export interface GeneratedPart {
|
|
75
|
+
readonly id: string;
|
|
76
|
+
readonly positions: Float32Array;
|
|
77
|
+
readonly indices: Uint32Array;
|
|
78
|
+
readonly normals?: Float32Array;
|
|
79
|
+
readonly color?: string;
|
|
80
|
+
}
|
|
81
|
+
export interface GeneratedModel {
|
|
82
|
+
readonly requestId: number;
|
|
83
|
+
readonly parts: readonly GeneratedPart[];
|
|
84
|
+
readonly bounds: ModelBounds;
|
|
85
|
+
readonly stats?: ModelStats;
|
|
86
|
+
readonly warnings: readonly ParameterIssue[];
|
|
87
|
+
}
|
|
88
|
+
export interface GenerateRequest {
|
|
89
|
+
readonly type: "generate";
|
|
90
|
+
readonly requestId: number;
|
|
91
|
+
readonly generatorId: string;
|
|
92
|
+
readonly meshTopologyMode: MeshTopologyMode;
|
|
93
|
+
readonly runtime: GeneratorRuntimeReference;
|
|
94
|
+
readonly parameters: ParameterValues;
|
|
95
|
+
}
|
|
96
|
+
export interface ValidateRequest {
|
|
97
|
+
readonly type: "validate";
|
|
98
|
+
readonly requestId: number;
|
|
99
|
+
readonly generatorId: string;
|
|
100
|
+
readonly runtime: GeneratorRuntimeReference;
|
|
101
|
+
readonly parameters: ParameterValues;
|
|
102
|
+
}
|
|
103
|
+
export interface Export3mfRequest {
|
|
104
|
+
readonly type: "export-3mf";
|
|
105
|
+
readonly requestId: number;
|
|
106
|
+
readonly generatorId: string;
|
|
107
|
+
readonly filename: string;
|
|
108
|
+
readonly meshTopologyMode: MeshTopologyMode;
|
|
109
|
+
readonly runtime: GeneratorRuntimeReference;
|
|
110
|
+
readonly parameters: ParameterValues;
|
|
111
|
+
}
|
|
112
|
+
export interface ValidationSuccess {
|
|
113
|
+
readonly type: "validation-success";
|
|
114
|
+
readonly requestId: number;
|
|
115
|
+
readonly validation: ParameterValidationResult;
|
|
116
|
+
}
|
|
117
|
+
export interface GenerationSuccess {
|
|
118
|
+
readonly type: "generation-success";
|
|
119
|
+
readonly requestId: number;
|
|
120
|
+
readonly model: GeneratedModel;
|
|
121
|
+
}
|
|
122
|
+
export interface GenerationInvalid {
|
|
123
|
+
readonly type: "generation-invalid";
|
|
124
|
+
readonly requestId: number;
|
|
125
|
+
readonly validation: ParameterValidationResult;
|
|
126
|
+
}
|
|
127
|
+
export interface ExportedFile {
|
|
128
|
+
readonly bytes: ArrayBuffer;
|
|
129
|
+
readonly filename: string;
|
|
130
|
+
readonly mimeType: "model/3mf";
|
|
131
|
+
}
|
|
132
|
+
export interface ExportSuccess {
|
|
133
|
+
readonly type: "export-success";
|
|
134
|
+
readonly requestId: number;
|
|
135
|
+
readonly file: ExportedFile;
|
|
136
|
+
}
|
|
137
|
+
export interface RuntimeError {
|
|
138
|
+
readonly code: string;
|
|
139
|
+
readonly message: string;
|
|
140
|
+
readonly stack?: string;
|
|
141
|
+
readonly recoverable?: boolean;
|
|
142
|
+
}
|
|
143
|
+
export interface GenerationError {
|
|
144
|
+
readonly type: "generation-error";
|
|
145
|
+
readonly requestId: number;
|
|
146
|
+
readonly error: RuntimeError;
|
|
147
|
+
}
|
|
148
|
+
export interface ExportError {
|
|
149
|
+
readonly type: "export-error";
|
|
150
|
+
readonly requestId: number;
|
|
151
|
+
readonly error: RuntimeError;
|
|
152
|
+
}
|
|
153
|
+
export interface ValidationError {
|
|
154
|
+
readonly type: "validation-error";
|
|
155
|
+
readonly requestId: number;
|
|
156
|
+
readonly error: RuntimeError;
|
|
157
|
+
}
|
|
158
|
+
export type WorkerRequest = ValidateRequest | GenerateRequest | Export3mfRequest;
|
|
159
|
+
export type WorkerResponse = ValidationSuccess | GenerationSuccess | GenerationInvalid | ExportSuccess | ValidationError | GenerationError | ExportError;
|
|
160
|
+
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","s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