@metamesh/generator-sdk 0.12.0 → 0.14.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 +32 -0
- package/README.md +68 -66
- package/dist/contracts.d.ts +5 -5
- package/dist/contracts.d.ts.map +1 -1
- package/dist/docs/guides/authoring.md +127 -0
- package/dist/docs/guides/package.md +121 -0
- package/dist/docs/guides/parameters.md +427 -0
- package/dist/docs/manifest.json +2361 -0
- package/dist/docs/reference/fonts/FontSelection.md +14 -0
- package/dist/docs/reference/fonts/isFontSelection.md +10 -0
- package/dist/docs/reference/index/ArrayParameterDefinition.md +12 -0
- package/dist/docs/reference/index/BaseParameterDefinition.md +16 -0
- package/dist/docs/reference/index/BooleanParameterDefinition.md +12 -0
- package/dist/docs/reference/index/ChoiceOption.md +13 -0
- package/dist/docs/reference/index/ChoiceParameterDefinition.md +14 -0
- package/dist/docs/reference/index/ChoiceSetParameterDefinition.md +15 -0
- package/dist/docs/reference/index/ColorParameterDefinition.md +12 -0
- package/dist/docs/reference/index/ConditionExpression.md +36 -0
- package/dist/docs/reference/index/ContourAnchor.md +12 -0
- package/dist/docs/reference/index/ContourParameterDefinition.md +13 -0
- package/dist/docs/reference/index/ContourParameterUi.md +12 -0
- package/dist/docs/reference/index/ContourPoint.md +13 -0
- package/dist/docs/reference/index/ContourSegment.md +17 -0
- package/dist/docs/reference/index/ContourValue.md +14 -0
- package/dist/docs/reference/index/FontParameterDefinition.md +12 -0
- package/dist/docs/reference/index/FontSelection.md +14 -0
- package/dist/docs/reference/index/GeneratorDefinition.md +14 -0
- package/dist/docs/reference/index/GeneratorIssue.md +12 -0
- package/dist/docs/reference/index/GeneratorModule.md +15 -0
- package/dist/docs/reference/index/GeneratorModuleOptions.md +12 -0
- package/dist/docs/reference/index/GeneratorParamId.md +10 -0
- package/dist/docs/reference/index/GeneratorParams.md +12 -0
- package/dist/docs/reference/index/GeneratorPreset.md +14 -0
- package/dist/docs/reference/index/GeneratorProgram.md +13 -0
- package/dist/docs/reference/index/GeneratorServices.md +15 -0
- package/dist/docs/reference/index/GeneratorTextArcBaseline.md +18 -0
- package/dist/docs/reference/index/GeneratorTextLayout.md +13 -0
- package/dist/docs/reference/index/GeneratorTextMetrics.md +21 -0
- package/dist/docs/reference/index/GeneratorTextOptions.md +19 -0
- package/dist/docs/reference/index/MAX_CONTOUR_SEGMENTS.md +9 -0
- package/dist/docs/reference/index/MAX_SIDE_PROFILE_SEGMENTS.md +9 -0
- package/dist/docs/reference/index/NumberArrayItemDefinition.md +19 -0
- package/dist/docs/reference/index/NumberArrayParameterDefinition.md +12 -0
- package/dist/docs/reference/index/NumberParameterDefinition.md +19 -0
- package/dist/docs/reference/index/NumberParameterUi.md +14 -0
- package/dist/docs/reference/index/ParameterDefinition.md +9 -0
- package/dist/docs/reference/index/ParameterDefinitionDocument.md +12 -0
- package/dist/docs/reference/index/ParameterGroup.md +15 -0
- package/dist/docs/reference/index/ParameterIssue.md +17 -0
- package/dist/docs/reference/index/ParameterIssueCode.md +10 -0
- package/dist/docs/reference/index/ParameterIssueSeverity.md +9 -0
- package/dist/docs/reference/index/ParameterScaleReference.md +13 -0
- package/dist/docs/reference/index/ParameterUi.md +15 -0
- package/dist/docs/reference/index/ParameterValidationResult.md +14 -0
- package/dist/docs/reference/index/ParameterValue.md +9 -0
- package/dist/docs/reference/index/ParameterValues.md +9 -0
- package/dist/docs/reference/index/RowParameterUi.md +12 -0
- package/dist/docs/reference/index/ScalarParameterValue.md +9 -0
- package/dist/docs/reference/index/SideProfileAnchor.md +12 -0
- package/dist/docs/reference/index/SideProfileParameterDefinition.md +13 -0
- package/dist/docs/reference/index/SideProfileParameterUi.md +12 -0
- package/dist/docs/reference/index/SideProfilePoint.md +13 -0
- package/dist/docs/reference/index/SideProfileSegment.md +17 -0
- package/dist/docs/reference/index/SideProfileValue.md +14 -0
- package/dist/docs/reference/index/SourceVisibility.md +15 -0
- package/dist/docs/reference/index/StringArrayItemDefinition.md +11 -0
- package/dist/docs/reference/index/StringArrayParameterDefinition.md +12 -0
- package/dist/docs/reference/index/SvgParameterDefinition.md +12 -0
- package/dist/docs/reference/index/TextParameterDefinition.md +13 -0
- package/dist/docs/reference/index/UNPREPARED_GENERATOR_SERVICES.md +9 -0
- package/dist/docs/reference/index/cloneContourValue.md +10 -0
- package/dist/docs/reference/index/cloneSideProfileValue.md +10 -0
- package/dist/docs/reference/index/contourValuesEqual.md +10 -0
- package/dist/docs/reference/index/defineGenerator.md +10 -0
- package/dist/docs/reference/index/defineGeneratorModule.md +10 -0
- package/dist/docs/reference/index/definePresets.md +10 -0
- package/dist/docs/reference/index/evaluateCondition.md +13 -0
- package/dist/docs/reference/index/isContourValue.md +10 -0
- package/dist/docs/reference/index/isFontSelection.md +10 -0
- package/dist/docs/reference/index/isSideProfileValue.md +10 -0
- package/dist/docs/reference/index/sideProfileValuesEqual.md +10 -0
- package/dist/docs/reference/packages/GENERATOR_PACKAGE_FORMAT_VERSION.md +9 -0
- package/dist/docs/reference/packages/GeneratorAccess.md +9 -0
- package/dist/docs/reference/packages/GeneratorDefinitionIssue.md +14 -0
- package/dist/docs/reference/packages/GeneratorDefinitionParseResult.md +15 -0
- package/dist/docs/reference/packages/GeneratorDescriptor.md +9 -0
- package/dist/docs/reference/packages/GeneratorPackageManifest.md +11 -0
- package/dist/docs/reference/packages/GeneratorPackageSource.md +9 -0
- package/dist/docs/reference/packages/GeneratorPackageValidationError.md +12 -0
- package/dist/docs/reference/packages/GeneratorPreset.md +14 -0
- package/dist/docs/reference/packages/GeneratorRuntimeReference.md +15 -0
- package/dist/docs/reference/packages/InstalledGenerator.md +15 -0
- package/dist/docs/reference/packages/MAX_ARRAY_ITEMS.md +9 -0
- package/dist/docs/reference/packages/MAX_CONDITION_BRANCHES.md +9 -0
- package/dist/docs/reference/packages/MAX_CONDITION_DEPTH.md +9 -0
- package/dist/docs/reference/packages/MAX_DESCRIPTOR_LIST_ITEMS.md +9 -0
- package/dist/docs/reference/packages/MAX_GENERATOR_ID_LENGTH.md +9 -0
- package/dist/docs/reference/packages/MAX_GENERATOR_PACKAGE_BYTES.md +9 -0
- package/dist/docs/reference/packages/MAX_GENERATOR_PRESETS.md +9 -0
- package/dist/docs/reference/packages/MAX_METADATA_TEXT_LENGTH.md +9 -0
- package/dist/docs/reference/packages/MAX_PARAMETERS.md +9 -0
- package/dist/docs/reference/packages/MAX_PARAMETER_GROUPS.md +9 -0
- package/dist/docs/reference/packages/MAX_PARAMETER_OPTIONS.md +9 -0
- package/dist/docs/reference/packages/MAX_TEXT_PARAMETER_LENGTH.md +9 -0
- package/dist/docs/reference/packages/METAMESH_RUNTIME_VERSION.md +9 -0
- package/dist/docs/reference/packages/compareSemanticVersions.md +9 -0
- package/dist/docs/reference/packages/definitionIssuesFromZod.md +10 -0
- package/dist/docs/reference/packages/isRuntimeCompatible.md +9 -0
- package/dist/docs/reference/packages/parseGeneratorDefinition.md +9 -0
- package/dist/docs/reference/packages/parseGeneratorDescriptor.md +9 -0
- package/dist/docs/reference/packages/parseGeneratorPackageManifest.md +9 -0
- package/dist/docs/reference/packages/parseParameterDefinitionDocument.md +9 -0
- package/dist/docs/reference/packages/safeParseGeneratorDefinition.md +10 -0
- package/dist/docs/reference/packages/safeParseParameterDefinitionDocument.md +10 -0
- package/dist/docs/reference/packages/validateGeneratorPresets.md +10 -0
- package/dist/docs/reference/packages/validationErrorFromIssues.md +9 -0
- package/dist/docs/reference/packages/validationErrorFromZod.md +9 -0
- package/dist/docs/reference/parameters/EMPTY_SVG_PARAMETER_DEFAULT.md +9 -0
- package/dist/docs/reference/parameters/MAX_PARAMETER_ISSUES.md +9 -0
- package/dist/docs/reference/parameters/MAX_PARAMETER_ISSUE_MESSAGE_LENGTH.md +9 -0
- package/dist/docs/reference/parameters/MAX_PROJECT_SVG_PARAMETER_BYTES.md +9 -0
- package/dist/docs/reference/parameters/MAX_SVG_PARAMETER_BYTES.md +9 -0
- package/dist/docs/reference/parameters/ParamCodec.md +14 -0
- package/dist/docs/reference/parameters/ParamDecodeCode.md +9 -0
- package/dist/docs/reference/parameters/ParamDecodeError.md +12 -0
- package/dist/docs/reference/parameters/ParamDecodeIssue.md +14 -0
- package/dist/docs/reference/parameters/ParamParseResult.md +15 -0
- package/dist/docs/reference/parameters/PreparedParameters.md +12 -0
- package/dist/docs/reference/parameters/aggregateParameterIssues.md +10 -0
- package/dist/docs/reference/parameters/canonicalizeParameters.md +10 -0
- package/dist/docs/reference/parameters/createParamCodec.md +13 -0
- package/dist/docs/reference/parameters/getDefaultParameters.md +9 -0
- package/dist/docs/reference/parameters/normalizeParameters.md +13 -0
- package/dist/docs/reference/parameters/parameterValueEquals.md +9 -0
- package/dist/docs/reference/parameters/parseParameterIssues.md +15 -0
- package/dist/docs/reference/parameters/prepareParameters.md +13 -0
- package/dist/docs/reference/parameters/svgParameterBytes.md +9 -0
- package/dist/docs/reference/parameters/validateParameters.md +10 -0
- package/dist/docs/reference/runtime/ExecuteGeneratorOptions.md +18 -0
- package/dist/docs/reference/runtime/Export3mfRequest.md +18 -0
- package/dist/docs/reference/runtime/ExportError.md +13 -0
- package/dist/docs/reference/runtime/ExportSuccess.md +13 -0
- package/dist/docs/reference/runtime/ExportedFile.md +13 -0
- package/dist/docs/reference/runtime/GenerateRequest.md +16 -0
- package/dist/docs/reference/runtime/GeneratedModel.md +17 -0
- package/dist/docs/reference/runtime/GeneratedModelDelivery.md +12 -0
- package/dist/docs/reference/runtime/GeneratedPart.md +20 -0
- package/dist/docs/reference/runtime/GeneratedPartDelivery.md +13 -0
- package/dist/docs/reference/runtime/GeneratedPartsDecoder.md +24 -0
- package/dist/docs/reference/runtime/GeneratedPartsLimits.md +15 -0
- package/dist/docs/reference/runtime/GenerationError.md +13 -0
- package/dist/docs/reference/runtime/GenerationInvalid.md +13 -0
- package/dist/docs/reference/runtime/GenerationSuccess.md +15 -0
- package/dist/docs/reference/runtime/GeneratorExecutionGenerated.md +14 -0
- package/dist/docs/reference/runtime/GeneratorExecutionInvalid.md +13 -0
- package/dist/docs/reference/runtime/GeneratorExecutionResult.md +9 -0
- package/dist/docs/reference/runtime/MeshTopologyMode.md +10 -0
- package/dist/docs/reference/runtime/ModelBounds.md +12 -0
- package/dist/docs/reference/runtime/ModelStats.md +15 -0
- package/dist/docs/reference/runtime/ModelTimings.md +27 -0
- package/dist/docs/reference/runtime/ParsedGeneratorModule.md +9 -0
- package/dist/docs/reference/runtime/RuntimeError.md +14 -0
- package/dist/docs/reference/runtime/ValidateRequest.md +15 -0
- package/dist/docs/reference/runtime/ValidationError.md +13 -0
- package/dist/docs/reference/runtime/ValidationSuccess.md +13 -0
- package/dist/docs/reference/runtime/WorkerRequest.md +9 -0
- package/dist/docs/reference/runtime/WorkerResponse.md +9 -0
- package/dist/docs/reference/runtime/executeGenerator.md +10 -0
- package/dist/docs/reference/runtime/generationIssues.md +10 -0
- package/dist/docs/reference/runtime/isGeneratorModule.md +9 -0
- package/dist/docs/reference/runtime/parseGeneratedParts.md +15 -0
- package/dist/docs/reference/runtime/parseGenerationSentAt.md +10 -0
- package/dist/docs/reference/runtime/parseGeneratorModule.md +10 -0
- package/dist/generator-package/constants.d.ts +1 -1
- package/dist/generator-package/constants.js +1 -1
- package/dist/generator-package/validate-manifest.js +2 -2
- package/dist/parameters/issues.d.ts +2 -2
- package/dist/parameters/issues.js +2 -2
- package/dist/parameters/strict.d.ts +4 -3
- package/dist/parameters/strict.d.ts.map +1 -1
- package/dist/parameters/strict.js +2 -3
- package/dist/parameters/strict.js.map +1 -1
- package/dist/{execute-generator.d.ts → runtime/execute-generator.d.ts} +4 -4
- package/dist/runtime/execute-generator.d.ts.map +1 -0
- package/dist/{execute-generator.js → runtime/execute-generator.js} +1 -1
- package/dist/runtime/execute-generator.js.map +1 -0
- package/dist/{generated-parts.d.ts → runtime/generated-parts.d.ts} +1 -1
- package/dist/runtime/generated-parts.d.ts.map +1 -0
- package/dist/runtime/generated-parts.js.map +1 -0
- package/dist/{parse-generator-module.d.ts → runtime/parse-generator-module.d.ts} +2 -2
- package/dist/runtime/parse-generator-module.d.ts.map +1 -0
- package/dist/{parse-generator-module.js → runtime/parse-generator-module.js} +1 -1
- package/dist/runtime/parse-generator-module.js.map +1 -0
- package/dist/{worker-contracts.d.ts → runtime/worker-contracts.d.ts} +2 -2
- package/dist/runtime/worker-contracts.d.ts.map +1 -0
- package/dist/runtime/worker-contracts.js.map +1 -0
- package/dist/runtime.d.ts +8 -8
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +4 -4
- package/dist/runtime.js.map +1 -1
- package/dist/source-visibility.d.ts +2 -3
- package/dist/source-visibility.d.ts.map +1 -1
- package/package.json +4 -3
- package/dist/execute-generator.d.ts.map +0 -1
- package/dist/execute-generator.js.map +0 -1
- package/dist/generated-parts.d.ts.map +0 -1
- package/dist/generated-parts.js.map +0 -1
- package/dist/parse-generator-module.d.ts.map +0 -1
- package/dist/parse-generator-module.js.map +0 -1
- package/dist/worker-contracts.d.ts.map +0 -1
- package/dist/worker-contracts.js.map +0 -1
- /package/dist/{generated-parts.js → runtime/generated-parts.js} +0 -0
- /package/dist/{worker-contracts.js → runtime/worker-contracts.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @metamesh/generator-sdk
|
|
2
2
|
|
|
3
|
+
## 0.14.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- be565ad: Add native `stroke()` sections and pure `closestPointOnPath()` queries. Correct face-sized
|
|
8
|
+
circular sampling and odd-pinion internal gear motion. Native stroke uses the current runtime
|
|
9
|
+
contract so older hosts reject packages requiring the new operation before execution.
|
|
10
|
+
|
|
11
|
+
## 0.13.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- 2ebe03f: Ship exact-version offline documentation and a development-only authoring CLI for semantic
|
|
16
|
+
checking, generation, captured geometry inspection, and explicit Chromium previews. Use exact
|
|
17
|
+
package versions in documentation metadata and reject unsupported authoring artifact formats.
|
|
18
|
+
Provide generated command help and strict per-command argument validation, and enforce semantic
|
|
19
|
+
checking even when the consumer's TypeScript configuration disables it.
|
|
20
|
+
|
|
21
|
+
Publish lightweight model and Generator testing helpers as `@metamesh/testkit`. Move the
|
|
22
|
+
`metamesh` executable and Node authoring API into `@metamesh/cli`, which owns compiler, bundler,
|
|
23
|
+
renderer, and browser dependencies. Remove the former package name and authoring entry from
|
|
24
|
+
Testkit without compatibility aliases.
|
|
25
|
+
|
|
26
|
+
- 7e1b75d: Simplify modeling authoring with `polygon` construction, shared bounds and vector text fitting,
|
|
27
|
+
Section patterns, pure pattern transforms, and explicit profile closure and part layout helpers.
|
|
28
|
+
Zero-sized round, chamfer, and smooth treatments preserve untreated geometry.
|
|
29
|
+
|
|
30
|
+
Replace the public geometry vocabulary with `Vector2`, `Vector3`, `Contour`, `Polygon`, and
|
|
31
|
+
`Region`, and use canonical `Bounds2` and `Bounds3` throughout. Remove retired constructor and
|
|
32
|
+
type names. Bundles require runtime major 5 and the generation realm uses protocol 5; older
|
|
33
|
+
runtime packages reject before execution. The package envelope remains format 4.
|
|
34
|
+
|
|
3
35
|
## 0.12.0
|
|
4
36
|
|
|
5
37
|
No changes in this release.
|
package/README.md
CHANGED
|
@@ -1,32 +1,30 @@
|
|
|
1
1
|
# `@metamesh/generator-sdk`
|
|
2
2
|
|
|
3
|
-
Turn a parametric model into a MetaMesh Generator. Define
|
|
4
|
-
types, and use the same
|
|
3
|
+
Turn a parametric model into a MetaMesh Generator. Define controls once, infer their TypeScript
|
|
4
|
+
types, and use the same parameter contract for forms, saved values, and execution.
|
|
5
5
|
|
|
6
6
|
> **Preview:** `0.x` minor releases may break compatibility. Patches remain compatible within the
|
|
7
|
-
> same minor line.
|
|
7
|
+
> same minor line.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
8
10
|
|
|
9
11
|
```bash
|
|
10
12
|
pnpm add @metamesh/generator-sdk
|
|
11
13
|
```
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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 |
|
|
15
|
+
The SDK is renderer-neutral. To build geometry in the example below, also install
|
|
16
|
+
[`@metamesh/modeling`](https://github.com/JasonKoolman/metamesh/blob/main/packages/modeling/README.md).
|
|
17
|
+
Keep installed MetaMesh packages on the same exact release.
|
|
20
18
|
|
|
21
19
|
## Define controls
|
|
22
20
|
|
|
23
|
-
A definition
|
|
24
|
-
parameter types:
|
|
21
|
+
A definition describes the Generator and its editable parameters. Literal IDs and options give
|
|
22
|
+
you exact parameter types:
|
|
25
23
|
|
|
26
24
|
```ts
|
|
27
25
|
import { defineGenerator, type GeneratorParams } from "@metamesh/generator-sdk";
|
|
28
26
|
|
|
29
|
-
const definition = defineGenerator({
|
|
27
|
+
export const definition = defineGenerator({
|
|
30
28
|
id: "sleeve",
|
|
31
29
|
version: "0.1.0",
|
|
32
30
|
title: "Sleeve",
|
|
@@ -39,81 +37,85 @@ const definition = defineGenerator({
|
|
|
39
37
|
type Parameters = GeneratorParams<typeof definition>;
|
|
40
38
|
```
|
|
41
39
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
`
|
|
45
|
-
|
|
46
|
-
|
|
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`.
|
|
51
|
-
|
|
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.
|
|
40
|
+
Definitions are serializable. Optional `ui` metadata describes grouping, visibility, hints, and
|
|
41
|
+
editing increments. Number inputs and sliders share `type: "number"`; sliders add
|
|
42
|
+
`ui.control: "slider"`, bounds, and `ui.step`. See the
|
|
43
|
+
[parameter guide](https://github.com/JasonKoolman/metamesh/blob/main/apps/web/content/docs/develop/parameters-and-validation.mdx)
|
|
44
|
+
for the full set of controls.
|
|
57
45
|
|
|
58
46
|
## Generate a model
|
|
59
47
|
|
|
60
|
-
|
|
48
|
+
Add a synchronous generation program to the same module. Assertions describe relationships
|
|
49
|
+
between controls; the module helper binds the program to its definition:
|
|
61
50
|
|
|
62
51
|
```ts
|
|
63
|
-
import { defineGeneratorModule
|
|
52
|
+
import { defineGeneratorModule } from "@metamesh/generator-sdk";
|
|
64
53
|
import { generate, tube } from "@metamesh/modeling";
|
|
65
54
|
|
|
66
|
-
const model = generate<
|
|
55
|
+
const model = generate<Parameters>(({ params, assert, part }) => {
|
|
67
56
|
assert(
|
|
68
57
|
params.boreDiameter < params.outerDiameter,
|
|
69
58
|
"The bore must be smaller than the outside diameter.",
|
|
70
59
|
{ parameterId: "boreDiameter" }
|
|
71
60
|
);
|
|
72
|
-
return
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
),
|
|
81
|
-
];
|
|
61
|
+
return part(
|
|
62
|
+
"body",
|
|
63
|
+
tube({
|
|
64
|
+
outerRadius: params.outerDiameter / 2,
|
|
65
|
+
innerRadius: params.boreDiameter / 2,
|
|
66
|
+
height: 20,
|
|
67
|
+
})
|
|
68
|
+
);
|
|
82
69
|
});
|
|
83
70
|
export default defineGeneratorModule({ definition, generate: model });
|
|
84
71
|
```
|
|
85
72
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
envelope and maps engine diagnostics to definition-owned issues. Unsupported package formats are
|
|
91
|
-
rejected before executable bytes are evaluated.
|
|
73
|
+
Return a single `part(...)` or a readonly array of parts. The host normalizes parameters and prepares
|
|
74
|
+
assets before generation. Modeling manages geometry, sessions, and snapshots; the SDK provides
|
|
75
|
+
portable definitions, module envelopes, and validated runtime messages. Unsupported package formats
|
|
76
|
+
reject before executable bytes are evaluated.
|
|
92
77
|
|
|
93
|
-
|
|
94
|
-
geometry buffers once and hydrates later resource references, while checking part metadata and
|
|
95
|
-
aggregate limits on every delivery. The receiving host keeps admitted buffers immutable and
|
|
96
|
-
attached, and calls `clear()` when replacing the delivery source.
|
|
78
|
+
## Work with saved values
|
|
97
79
|
|
|
98
|
-
|
|
80
|
+
Use `normalizeParameters` from `/parameters` to recover saved values: it drops unknown keys,
|
|
81
|
+
restores missing or invalid values from defaults, and clamps numbers. At a trust boundary, use
|
|
82
|
+
`createParamCodec(definition)` to reject incomplete, unknown, invalid, or noncanonical values.
|
|
83
|
+
Both return fresh frozen parameter maps.
|
|
84
|
+
|
|
85
|
+
For definition editors, `/packages` provides `safeParseParameterDefinitionDocument` and structured
|
|
86
|
+
issue paths. The included `@metamesh/generator-sdk/parameters.schema.json` supports offline
|
|
87
|
+
completion; SDK validation also checks references, defaults, and cross-field rules.
|
|
88
|
+
|
|
89
|
+
## API entry points
|
|
99
90
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
91
|
+
| Import | Use it for |
|
|
92
|
+
| ------------------------------------ | ------------------------------------------------ |
|
|
93
|
+
| `@metamesh/generator-sdk` | Definitions, presets, and module authoring |
|
|
94
|
+
| `@metamesh/generator-sdk/parameters` | Defaults, saved values, and strict codecs |
|
|
95
|
+
| `@metamesh/generator-sdk/runtime` | Module execution, mesh data, and Worker messages |
|
|
96
|
+
| `@metamesh/generator-sdk/packages` | Package, catalog, and installation parsing |
|
|
97
|
+
| `@metamesh/generator-sdk/fonts` | Immutable font selection values |
|
|
98
|
+
|
|
99
|
+
Incremental Worker hosts can use `GeneratedPartsDecoder` from `/runtime` to hydrate validated
|
|
100
|
+
geometry resources while checking part metadata and aggregate limits on every delivery. Keep
|
|
101
|
+
admitted buffers immutable and attached; call `clear()` when replacing the delivery source.
|
|
102
|
+
|
|
103
|
+
## Documentation
|
|
103
104
|
|
|
104
|
-
|
|
105
|
+
Resolve `@metamesh/generator-sdk/docs/manifest.json` from your project for exact-version Markdown
|
|
106
|
+
guides and annotated declaration references. Document paths are relative to that manifest.
|
|
107
|
+
With [`@metamesh/cli`](https://github.com/JasonKoolman/metamesh/blob/main/packages/cli/README.md)
|
|
108
|
+
installed, `pnpm exec metamesh docs search "parameters"` searches the local index;
|
|
109
|
+
`pnpm exec metamesh docs show sdk/guide/generator-modules` reads this package's authoring guide.
|
|
105
110
|
|
|
106
|
-
- [
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
- [Authoring helpers](https://github.com/JasonKoolman/metamesh/blob/main/packages/generator-sdk/src/authoring.ts),
|
|
110
|
-
[module contract](https://github.com/JasonKoolman/metamesh/blob/main/packages/generator-sdk/src/generator-module.ts), and
|
|
111
|
-
[runtime execution](https://github.com/JasonKoolman/metamesh/blob/main/packages/generator-sdk/src/execute-generator.ts).
|
|
111
|
+
- [Parameters and validation](https://github.com/JasonKoolman/metamesh/blob/main/apps/web/content/docs/develop/parameters-and-validation.mdx) — controls, defaults, and diagnostics.
|
|
112
|
+
- [Local authoring](https://github.com/JasonKoolman/metamesh/blob/main/apps/web/content/docs/create/author-locally.mdx) — the current Generator workflow.
|
|
113
|
+
- [API source](https://github.com/JasonKoolman/metamesh/blob/main/packages/generator-sdk/src/index.ts) — exports, types, and implementation references.
|
|
112
114
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
Until the public documentation site launches, use these repository guides or
|
|
116
|
+
[run the docs locally](https://github.com/JasonKoolman/metamesh/blob/main/apps/web/README.md#local-use).
|
|
117
|
+
For package development, see [Contributing](https://github.com/JasonKoolman/metamesh/blob/main/CONTRIBUTING.md).
|
|
116
118
|
|
|
117
119
|
## License
|
|
118
120
|
|
|
119
|
-
Apache-2.0.
|
|
121
|
+
[Apache-2.0](https://github.com/JasonKoolman/metamesh/blob/main/packages/generator-sdk/LICENSE).
|
package/dist/contracts.d.ts
CHANGED
|
@@ -66,10 +66,10 @@ export interface GeneratorPreset<D extends GeneratorDefinition = GeneratorDefini
|
|
|
66
66
|
readonly description?: string | undefined;
|
|
67
67
|
readonly parameterValues: GeneratorParams<D>;
|
|
68
68
|
}
|
|
69
|
-
export type
|
|
69
|
+
export type Vector3 = readonly [number, number, number];
|
|
70
70
|
export interface ModelBounds {
|
|
71
|
-
readonly min:
|
|
72
|
-
readonly max:
|
|
71
|
+
readonly min: Vector3;
|
|
72
|
+
readonly max: Vector3;
|
|
73
73
|
}
|
|
74
74
|
export interface ModelStats {
|
|
75
75
|
readonly triangles?: number | undefined;
|
|
@@ -104,8 +104,8 @@ export interface GeneratedPart {
|
|
|
104
104
|
readonly geometryId: string;
|
|
105
105
|
readonly geometryRevision: number;
|
|
106
106
|
/** Authoritative translation in mm and fixed global X, Y, Z rotations in degrees. */
|
|
107
|
-
readonly position:
|
|
108
|
-
readonly rotation:
|
|
107
|
+
readonly position: Vector3;
|
|
108
|
+
readonly rotation: Vector3;
|
|
109
109
|
readonly id: string;
|
|
110
110
|
readonly positions: Float32Array;
|
|
111
111
|
readonly indices: Uint32Array;
|
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,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,0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ACnE,QAAQ,CAAC,KAAK,EAAE,SAAS,qBAAqB,EAAE,CAAC;CAClD,CAAC"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Design reusable controls
|
|
2
|
+
|
|
3
|
+
Make a code Project useful to someone else with clear inputs, tested defaults, focused validation, and portable files.
|
|
4
|
+
|
|
5
|
+
Turn a working authored Project into a model someone can adjust without reading its source.
|
|
6
|
+
If you need a working model first, follow [Build your first code Project](https://metamesh.studio/docs/develop/code-projects).
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
const { width, depth, height, holeDiameter, addHole } = params;
|
|
12
|
+
const body = box({ size: [width, depth, height] });
|
|
13
|
+
if (!addHole) return [part("body", body)];
|
|
14
|
+
// Two extra millimetres clear the centered body's top and bottom faces.
|
|
15
|
+
const bore = cylinder({ height: height + 2, diameter: holeDiameter, sizing: "face" });
|
|
16
|
+
return [part("body", body.subtract([bore]))];
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
A plate is a useful starting example: its controls describe the finished size and an optional hole, while the source handles construction.
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## Choose the decisions to expose
|
|
24
|
+
|
|
25
|
+
Describe what someone should be able to change: the overall size, a fit, an optional feature, or
|
|
26
|
+
which parts to produce. Expose those decisions as controls. Keep implementation details in the
|
|
27
|
+
source unless changing them serves a clear purpose.
|
|
28
|
+
|
|
29
|
+
For a plate with an optional hole, Width and Hole diameter express design decisions. The cylinder's
|
|
30
|
+
segment count usually does not need equal prominence.
|
|
31
|
+
|
|
32
|
+
Open **Parameter actions → Edit controls**, or **MetaMesh menu → Current project → Edit controls**.
|
|
33
|
+
Group related controls into sections, put the most common decisions first, and choose
|
|
34
|
+
**Apply & return** to use the updated definition. See
|
|
35
|
+
[Define parameters and validation](parameters.md#choose-the-right-control)
|
|
36
|
+
for supported control types and their configuration.
|
|
37
|
+
|
|
38
|
+
## Make labels and units unambiguous
|
|
39
|
+
|
|
40
|
+
Use labels that describe the finished model, such as **Outer Diameter**, rather than a variable
|
|
41
|
+
name like `d2`. Add a short description when a measurement could have more than one interpretation:
|
|
42
|
+
for example, whether Length includes an end cap.
|
|
43
|
+
|
|
44
|
+
Show units for dimensional controls. MetaMesh model dimensions use millimetres; explain any
|
|
45
|
+
conversion your source performs so the displayed input and exported size agree. Use a step that
|
|
46
|
+
matches the decision: whole numbers for a count, or an appropriate increment for a dimension.
|
|
47
|
+
|
|
48
|
+
Keep control IDs stable as you refine labels. IDs connect controls to source values and validation
|
|
49
|
+
messages; a clearer label should not require a different identifier.
|
|
50
|
+
|
|
51
|
+
## Choose defaults that demonstrate the model
|
|
52
|
+
|
|
53
|
+
Choose representative defaults that produce a useful, recognizable result without validation
|
|
54
|
+
errors and show the important features without requiring several edits.
|
|
55
|
+
|
|
56
|
+
Try the model from the parameter panel with the code editor closed. Confirm that:
|
|
57
|
+
|
|
58
|
+
- the first controls lead to the most useful variations;
|
|
59
|
+
- changing a value produces the result its label suggests;
|
|
60
|
+
- optional features reveal their relevant controls; and
|
|
61
|
+
- resetting values restores the intended starting model.
|
|
62
|
+
|
|
63
|
+
Use [conditional visibility](parameters.md#reveal-a-control-only-when-it-applies)
|
|
64
|
+
to keep optional settings out of the way until they matter.
|
|
65
|
+
|
|
66
|
+
## Explain constraints where they matter
|
|
67
|
+
|
|
68
|
+
Set field limits for a single value's supported range. Add cross-field validation when a valid
|
|
69
|
+
range depends on another control, such as a hole that must fit inside a plate.
|
|
70
|
+
|
|
71
|
+
A helpful message identifies the problem and gives a next action: "Reduce Hole diameter or increase
|
|
72
|
+
Width" is more useful than "Invalid parameters." Associate the message with the relevant control.
|
|
73
|
+
Use an error for unsupported combinations and a warning for a trade-off the person can choose to
|
|
74
|
+
accept. The [validation guide](parameters.md#add-cross-field-validation-in-typescript)
|
|
75
|
+
explains the implementation with examples.
|
|
76
|
+
|
|
77
|
+
Test more than the default combination. Check the smallest and largest supported dimensions,
|
|
78
|
+
optional features, and any choice or list combinations. After an error, confirm that the suggested
|
|
79
|
+
correction produces a current model again.
|
|
80
|
+
|
|
81
|
+
For the plate above, test these decisions separately:
|
|
82
|
+
|
|
83
|
+
| Variation | What to verify |
|
|
84
|
+
| --------------------------------- | ----------------------------------------------------------------------------- |
|
|
85
|
+
| Turn Add hole off | The plate becomes solid and hides Hole diameter. |
|
|
86
|
+
| Change Width and Depth | The body follows the controls; the hole stays in its intended position. |
|
|
87
|
+
| Make the hole wider than the body | The message identifies Hole diameter and explains which dimensions to change. |
|
|
88
|
+
| Restore valid values | A new successful preview replaces the retained older model. |
|
|
89
|
+
| Reset all | The demonstrated starting configuration returns without errors. |
|
|
90
|
+
|
|
91
|
+
## Keep related parts understandable
|
|
92
|
+
|
|
93
|
+
Use named parts when one set of controls produces related outputs, such as a lid and its container.
|
|
94
|
+
Give them stable, descriptive IDs so inspection and export remain understandable as dimensions
|
|
95
|
+
change. The [part contract](https://metamesh.studio/docs/develop/code-project-contract#parts-and-placement) describes the
|
|
96
|
+
supported output shape.
|
|
97
|
+
|
|
98
|
+
Inspect each output and check the exported model in its intended downstream tool. A valid solid
|
|
99
|
+
alone does not establish a suitable fit or printable wall thickness. Follow the
|
|
100
|
+
[export guide](https://metamesh.studio/docs/use/export-3mf) for format capabilities and verification steps.
|
|
101
|
+
|
|
102
|
+
## Use the same design in a local module
|
|
103
|
+
|
|
104
|
+
These control-design principles also apply to a Generator authored in a local TypeScript project.
|
|
105
|
+
Use `@metamesh/generator-sdk` for its serializable definition and module envelope, and
|
|
106
|
+
`@metamesh/modeling` for generation. Studio's virtual `@metamesh/project` import is specific to
|
|
107
|
+
Studio and cannot be copied into a local Node module.
|
|
108
|
+
|
|
109
|
+
Follow [local authoring](https://metamesh.studio/docs/develop/agent-authoring#generator-entries) to check and run the
|
|
110
|
+
module with the CLI, inspect dimensions and named parts, and render the captured result. Add
|
|
111
|
+
[Testkit checks](https://metamesh.studio/docs/develop/agent-authoring#test-models) when you need repeatable assertions for
|
|
112
|
+
defaults, presets, supported bounds, or validation recovery. Keep those tests in your project's
|
|
113
|
+
test runner; the CLI owns compilation and capture tools.
|
|
114
|
+
|
|
115
|
+
## Keep a portable copy
|
|
116
|
+
|
|
117
|
+
Save the authored Project as a `.metamesh.json` file, then
|
|
118
|
+
[import the Project file](https://metamesh.studio/docs/use/projects-and-offline#save-and-import-an-authored-project) to check its source,
|
|
119
|
+
controls, and values. Keep the file in storage you control; browser storage is local to the device
|
|
120
|
+
and profile.
|
|
121
|
+
|
|
122
|
+
A saved Project is not a published catalog Generator. Check
|
|
123
|
+
[publishing availability](https://metamesh.studio/docs/create/publishing-status) if you intend to distribute through
|
|
124
|
+
MetaMesh.
|
|
125
|
+
|
|
126
|
+
- [Define parameters and validation](parameters.md)
|
|
127
|
+
- [Save and protect your work](https://metamesh.studio/docs/use/projects-and-offline)
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# `@metamesh/generator-sdk`
|
|
2
|
+
|
|
3
|
+
Turn a parametric model into a MetaMesh Generator. Define controls once, infer their TypeScript
|
|
4
|
+
types, and use the same parameter contract for forms, saved values, and execution.
|
|
5
|
+
|
|
6
|
+
> **Preview:** `0.x` minor releases may break compatibility. Patches remain compatible within the
|
|
7
|
+
> same minor line.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add @metamesh/generator-sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The SDK is renderer-neutral. To build geometry in the example below, also install
|
|
16
|
+
[`@metamesh/modeling`](https://github.com/JasonKoolman/metamesh/blob/main/packages/modeling/README.md).
|
|
17
|
+
Keep installed MetaMesh packages on the same exact release.
|
|
18
|
+
|
|
19
|
+
## Define controls
|
|
20
|
+
|
|
21
|
+
A definition describes the Generator and its editable parameters. Literal IDs and options give
|
|
22
|
+
you exact parameter types:
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { defineGenerator, type GeneratorParams } from "@metamesh/generator-sdk";
|
|
26
|
+
|
|
27
|
+
export const definition = defineGenerator({
|
|
28
|
+
id: "sleeve",
|
|
29
|
+
version: "0.1.0",
|
|
30
|
+
title: "Sleeve",
|
|
31
|
+
groups: [],
|
|
32
|
+
parameters: [
|
|
33
|
+
{ id: "outerDiameter", label: "Outer diameter", type: "number", default: 20, min: 4 },
|
|
34
|
+
{ id: "boreDiameter", label: "Bore diameter", type: "number", default: 10, min: 1 },
|
|
35
|
+
],
|
|
36
|
+
});
|
|
37
|
+
type Parameters = GeneratorParams<typeof definition>;
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Definitions are serializable. Optional `ui` metadata describes grouping, visibility, hints, and
|
|
41
|
+
editing increments. Number inputs and sliders share `type: "number"`; sliders add
|
|
42
|
+
`ui.control: "slider"`, bounds, and `ui.step`. See the
|
|
43
|
+
[parameter guide](https://github.com/JasonKoolman/metamesh/blob/main/apps/web/content/docs/develop/parameters-and-validation.mdx)
|
|
44
|
+
for the full set of controls.
|
|
45
|
+
|
|
46
|
+
## Generate a model
|
|
47
|
+
|
|
48
|
+
Add a synchronous generation program to the same module. Assertions describe relationships
|
|
49
|
+
between controls; the module helper binds the program to its definition:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { defineGeneratorModule } from "@metamesh/generator-sdk";
|
|
53
|
+
import { generate, tube } from "@metamesh/modeling";
|
|
54
|
+
|
|
55
|
+
const model = generate<Parameters>(({ params, assert, part }) => {
|
|
56
|
+
assert(
|
|
57
|
+
params.boreDiameter < params.outerDiameter,
|
|
58
|
+
"The bore must be smaller than the outside diameter.",
|
|
59
|
+
{ parameterId: "boreDiameter" }
|
|
60
|
+
);
|
|
61
|
+
return part(
|
|
62
|
+
"body",
|
|
63
|
+
tube({
|
|
64
|
+
outerRadius: params.outerDiameter / 2,
|
|
65
|
+
innerRadius: params.boreDiameter / 2,
|
|
66
|
+
height: 20,
|
|
67
|
+
})
|
|
68
|
+
);
|
|
69
|
+
});
|
|
70
|
+
export default defineGeneratorModule({ definition, generate: model });
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Return a single `part(...)` or a readonly array of parts. The host normalizes parameters and prepares
|
|
74
|
+
assets before generation. Modeling manages geometry, sessions, and snapshots; the SDK provides
|
|
75
|
+
portable definitions, module envelopes, and validated runtime messages. Unsupported package formats
|
|
76
|
+
reject before executable bytes are evaluated.
|
|
77
|
+
|
|
78
|
+
## Work with saved values
|
|
79
|
+
|
|
80
|
+
Use `normalizeParameters` from `/parameters` to recover saved values: it drops unknown keys,
|
|
81
|
+
restores missing or invalid values from defaults, and clamps numbers. At a trust boundary, use
|
|
82
|
+
`createParamCodec(definition)` to reject incomplete, unknown, invalid, or noncanonical values.
|
|
83
|
+
Both return fresh frozen parameter maps.
|
|
84
|
+
|
|
85
|
+
For definition editors, `/packages` provides `safeParseParameterDefinitionDocument` and structured
|
|
86
|
+
issue paths. The included `@metamesh/generator-sdk/parameters.schema.json` supports offline
|
|
87
|
+
completion; SDK validation also checks references, defaults, and cross-field rules.
|
|
88
|
+
|
|
89
|
+
## API entry points
|
|
90
|
+
|
|
91
|
+
| Import | Use it for |
|
|
92
|
+
| ------------------------------------ | ------------------------------------------------ |
|
|
93
|
+
| `@metamesh/generator-sdk` | Definitions, presets, and module authoring |
|
|
94
|
+
| `@metamesh/generator-sdk/parameters` | Defaults, saved values, and strict codecs |
|
|
95
|
+
| `@metamesh/generator-sdk/runtime` | Module execution, mesh data, and Worker messages |
|
|
96
|
+
| `@metamesh/generator-sdk/packages` | Package, catalog, and installation parsing |
|
|
97
|
+
| `@metamesh/generator-sdk/fonts` | Immutable font selection values |
|
|
98
|
+
|
|
99
|
+
Incremental Worker hosts can use `GeneratedPartsDecoder` from `/runtime` to hydrate validated
|
|
100
|
+
geometry resources while checking part metadata and aggregate limits on every delivery. Keep
|
|
101
|
+
admitted buffers immutable and attached; call `clear()` when replacing the delivery source.
|
|
102
|
+
|
|
103
|
+
## Documentation
|
|
104
|
+
|
|
105
|
+
Resolve `@metamesh/generator-sdk/docs/manifest.json` from your project for exact-version Markdown
|
|
106
|
+
guides and annotated declaration references. Document paths are relative to that manifest.
|
|
107
|
+
With [`@metamesh/cli`](https://github.com/JasonKoolman/metamesh/blob/main/packages/cli/README.md)
|
|
108
|
+
installed, `pnpm exec metamesh docs search "parameters"` searches the local index;
|
|
109
|
+
`pnpm exec metamesh docs show sdk/guide/generator-modules` reads this package's authoring guide.
|
|
110
|
+
|
|
111
|
+
- [Parameters and validation](https://github.com/JasonKoolman/metamesh/blob/main/apps/web/content/docs/develop/parameters-and-validation.mdx) — controls, defaults, and diagnostics.
|
|
112
|
+
- [Local authoring](https://github.com/JasonKoolman/metamesh/blob/main/apps/web/content/docs/create/author-locally.mdx) — the current Generator workflow.
|
|
113
|
+
- [API source](https://github.com/JasonKoolman/metamesh/blob/main/packages/generator-sdk/src/index.ts) — exports, types, and implementation references.
|
|
114
|
+
|
|
115
|
+
Until the public documentation site launches, use these repository guides or
|
|
116
|
+
[run the docs locally](https://github.com/JasonKoolman/metamesh/blob/main/apps/web/README.md#local-use).
|
|
117
|
+
For package development, see [Contributing](https://github.com/JasonKoolman/metamesh/blob/main/CONTRIBUTING.md).
|
|
118
|
+
|
|
119
|
+
## License
|
|
120
|
+
|
|
121
|
+
[Apache-2.0](https://github.com/JasonKoolman/metamesh/blob/main/packages/generator-sdk/LICENSE).
|