@metamesh/testkit 0.15.0 → 0.17.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 +54 -0
- package/README.md +36 -10
- package/dist/docs/guides/package.md +36 -10
- package/dist/docs/manifest.json +29 -1
- package/dist/docs/reference/font-fixtures/LoadedFontFixtures.md +1 -1
- package/dist/docs/reference/font-fixtures/loadFontFixtureServices.md +1 -1
- package/dist/docs/reference/font-fixtures/loadFontFixtures.md +1 -1
- package/dist/docs/reference/fonts/FontTestFixture.md +1 -1
- package/dist/docs/reference/fonts/prepareFontTestServices.md +1 -1
- package/dist/docs/reference/index/GeneratorTestExecution.md +1 -1
- package/dist/docs/reference/index/GeneratorTestRunner.md +3 -1
- package/dist/docs/reference/index/GeneratorTestRunnerOptions.md +1 -1
- package/dist/docs/reference/index/MeshMeasurementExpectation.md +2 -2
- package/dist/docs/reference/index/MeshMeasurementTolerances.md +1 -1
- package/dist/docs/reference/index/ModelTestOptions.md +13 -0
- package/dist/docs/reference/index/createGeneratorTestRunner.md +1 -1
- package/dist/docs/reference/index/expectMeshMeasurements.md +1 -1
- package/dist/docs/reference/index/expectSerializableDefinition.md +1 -1
- package/dist/docs/reference/index/expectValidDefaults.md +1 -1
- package/dist/docs/reference/index/expectValidParts.md +1 -1
- package/dist/docs/reference/index/expectValidPresets.md +1 -1
- package/dist/docs/reference/index/getTestEngine.md +1 -1
- package/dist/docs/reference/index/withModel.md +17 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/measurements.d.ts +2 -2
- package/dist/measurements.d.ts.map +1 -1
- package/dist/model.d.ts +17 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +22 -0
- package/dist/model.js.map +1 -0
- package/dist/runner.d.ts +3 -1
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +31 -22
- package/dist/runner.js.map +1 -1
- package/dist/snapshot-scope.d.ts +4 -0
- package/dist/snapshot-scope.d.ts.map +1 -0
- package/dist/snapshot-scope.js +10 -0
- package/dist/snapshot-scope.js.map +1 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,59 @@
|
|
|
1
1
|
# @metamesh/testkit
|
|
2
2
|
|
|
3
|
+
## 0.17.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add `defineGeneratorModel(definition, callback)` through the optional
|
|
8
|
+
`@metamesh/generator-sdk/modeling` adapter. It infers controls, synchronous services, and diagnostic
|
|
9
|
+
parameter IDs while leaving the SDK root independent of the Modeling runtime.
|
|
10
|
+
|
|
11
|
+
Add `runner.withModel(parameters, callback)` and Testkit's `withModel(program, parameters, callback,
|
|
12
|
+
options?)` for scoped assertions. Both await synchronous or asynchronous callbacks and release
|
|
13
|
+
their snapshot in `finally`; the plain-model helper also releases its temporary session.
|
|
14
|
+
Generator validation failures throw the existing structured `GenerationError` diagnostics.
|
|
15
|
+
|
|
16
|
+
Migration tip: replace private definition-plus-`generate` wrappers with the SDK adapter, and use
|
|
17
|
+
scoped callbacks instead of repeated successful-result narrowing and snapshot disposal. Keep
|
|
18
|
+
`runner.execute` and direct engine sessions for tests that inspect invalid results, cache behavior,
|
|
19
|
+
or explicit snapshot ownership. Prepared services are required for plain models that declare them.
|
|
20
|
+
|
|
21
|
+
Scoped callbacks retain snapshot parts without eagerly copying their buffers. For cross-run
|
|
22
|
+
geometry comparisons, select manufacturing fields rather than transient geometry resource IDs.
|
|
23
|
+
Capture `positions` and `indices` once before dense traversal: each accessor read returns a copy.
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Updated dependencies
|
|
28
|
+
- Updated dependencies
|
|
29
|
+
- Updated dependencies [d0cc194]
|
|
30
|
+
- Updated dependencies
|
|
31
|
+
- Updated dependencies
|
|
32
|
+
- @metamesh/modeling@0.17.0
|
|
33
|
+
- @metamesh/generator-sdk@0.17.0
|
|
34
|
+
|
|
35
|
+
## 0.16.0
|
|
36
|
+
|
|
37
|
+
### Minor Changes
|
|
38
|
+
|
|
39
|
+
- fbd7276: Standardize immutable value interchange on domain names, Data representations, Input construction
|
|
40
|
+
forms, and toData(). Rename vector tuples and transform matrices to Vector2Data/Vector3Data and
|
|
41
|
+
Transform2Data/Transform3Data. Path2Data and Path3Data now preserve dimension, points, and closure;
|
|
42
|
+
path factories accept complete data records as well as coordinate collections. Advance the host
|
|
43
|
+
runtime to major 8 for the new value protocol, and update consumers, examples, and references.
|
|
44
|
+
- 1585391: Add immutable `bounds2()` and `bounds3()` values with fluent measurements, positioned containment,
|
|
45
|
+
and plain-data conversion. Path bounds now return these values. Rename plain bounds records to
|
|
46
|
+
`Bounds2Data` and `Bounds3Data` across geometry, model snapshots, CLI captures, and Testkit contracts.
|
|
47
|
+
Bounds values in recipe inputs and computed data use the runtime 8 value interchange protocol.
|
|
48
|
+
|
|
49
|
+
### Patch Changes
|
|
50
|
+
|
|
51
|
+
- Updated dependencies [fbd7276]
|
|
52
|
+
- Updated dependencies [1585391]
|
|
53
|
+
- Updated dependencies [29e19a5]
|
|
54
|
+
- @metamesh/modeling@0.16.0
|
|
55
|
+
- @metamesh/generator-sdk@0.16.0
|
|
56
|
+
|
|
3
57
|
## 0.15.0
|
|
4
58
|
|
|
5
59
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -28,21 +28,47 @@ import runtime, { definition } from "./generator.js";
|
|
|
28
28
|
|
|
29
29
|
const runner = createGeneratorTestRunner(definition, runtime);
|
|
30
30
|
try {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
await expectValidParts(result.model.parts);
|
|
35
|
-
} finally {
|
|
36
|
-
result.model.dispose();
|
|
37
|
-
}
|
|
31
|
+
await runner.withModel(getDefaultParameters(definition), async (model) => {
|
|
32
|
+
await expectValidParts(model.parts);
|
|
33
|
+
});
|
|
38
34
|
} finally {
|
|
39
35
|
runner.dispose();
|
|
40
36
|
}
|
|
41
37
|
```
|
|
42
38
|
|
|
43
|
-
`
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
`withModel` normalizes values, prepares services, and runs the persistent session. It awaits the
|
|
40
|
+
callback, returns its result, and disposes the snapshot even when assertions throw or reject.
|
|
41
|
+
Schema or generation assertion failures throw `GenerationError` with their structured diagnostics.
|
|
42
|
+
Unexpected execution and malformed-output errors retain their original failures. The runner's
|
|
43
|
+
session and caches remain reusable until `runner.dispose()`.
|
|
44
|
+
|
|
45
|
+
For a plain model program, import `withModel` from Testkit:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { box, generate } from "@metamesh/modeling";
|
|
49
|
+
import { expectValidParts, withModel } from "@metamesh/testkit";
|
|
50
|
+
|
|
51
|
+
const model = generate<{ width: number }>(({ params, part }) =>
|
|
52
|
+
part("plate", box({ size: [params.width, 20, 4] }))
|
|
53
|
+
);
|
|
54
|
+
await withModel(model, { width: 30 }, async (snapshot) => {
|
|
55
|
+
await expectValidParts(snapshot.parts);
|
|
56
|
+
});
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The plain-model helper also disposes its temporary session. Its optional fourth argument accepts
|
|
60
|
+
session policy, prepared `services`, and a test-owned `engine`; declared services are required.
|
|
61
|
+
It passes model parameters directly without Generator normalization and never disposes the engine.
|
|
62
|
+
Previously obtained parts remain usable after snapshot disposal; returning parts does not eagerly
|
|
63
|
+
copy their buffers.
|
|
64
|
+
|
|
65
|
+
Snapshot parts include session-specific geometry resource identities. Compare manufacturing
|
|
66
|
+
fields such as world positions, indices, measurements, IDs and colors for equality across runs.
|
|
67
|
+
Each positions or indices read copies its buffer; capture the buffer once before a dense loop.
|
|
68
|
+
|
|
69
|
+
Use `runner.execute` for explicit snapshot ownership or invalid-result assertions. It returns
|
|
70
|
+
`invalid` for schema or generation assertion errors. Dispose successful snapshots separately from
|
|
71
|
+
the runner; captured snapshots remain valid after runner disposal.
|
|
46
72
|
|
|
47
73
|
Use `runner.validate(parameters, { normalize: false })` to probe deliberately invalid typed values
|
|
48
74
|
without finalizing parts. It checks declarations and reached assertions; observing geometry can
|
|
@@ -28,21 +28,47 @@ import runtime, { definition } from "./generator.js";
|
|
|
28
28
|
|
|
29
29
|
const runner = createGeneratorTestRunner(definition, runtime);
|
|
30
30
|
try {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
await expectValidParts(result.model.parts);
|
|
35
|
-
} finally {
|
|
36
|
-
result.model.dispose();
|
|
37
|
-
}
|
|
31
|
+
await runner.withModel(getDefaultParameters(definition), async (model) => {
|
|
32
|
+
await expectValidParts(model.parts);
|
|
33
|
+
});
|
|
38
34
|
} finally {
|
|
39
35
|
runner.dispose();
|
|
40
36
|
}
|
|
41
37
|
```
|
|
42
38
|
|
|
43
|
-
`
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
`withModel` normalizes values, prepares services, and runs the persistent session. It awaits the
|
|
40
|
+
callback, returns its result, and disposes the snapshot even when assertions throw or reject.
|
|
41
|
+
Schema or generation assertion failures throw `GenerationError` with their structured diagnostics.
|
|
42
|
+
Unexpected execution and malformed-output errors retain their original failures. The runner's
|
|
43
|
+
session and caches remain reusable until `runner.dispose()`.
|
|
44
|
+
|
|
45
|
+
For a plain model program, import `withModel` from Testkit:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { box, generate } from "@metamesh/modeling";
|
|
49
|
+
import { expectValidParts, withModel } from "@metamesh/testkit";
|
|
50
|
+
|
|
51
|
+
const model = generate<{ width: number }>(({ params, part }) =>
|
|
52
|
+
part("plate", box({ size: [params.width, 20, 4] }))
|
|
53
|
+
);
|
|
54
|
+
await withModel(model, { width: 30 }, async (snapshot) => {
|
|
55
|
+
await expectValidParts(snapshot.parts);
|
|
56
|
+
});
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The plain-model helper also disposes its temporary session. Its optional fourth argument accepts
|
|
60
|
+
session policy, prepared `services`, and a test-owned `engine`; declared services are required.
|
|
61
|
+
It passes model parameters directly without Generator normalization and never disposes the engine.
|
|
62
|
+
Previously obtained parts remain usable after snapshot disposal; returning parts does not eagerly
|
|
63
|
+
copy their buffers.
|
|
64
|
+
|
|
65
|
+
Snapshot parts include session-specific geometry resource identities. Compare manufacturing
|
|
66
|
+
fields such as world positions, indices, measurements, IDs and colors for equality across runs.
|
|
67
|
+
Each positions or indices read copies its buffer; capture the buffer once before a dense loop.
|
|
68
|
+
|
|
69
|
+
Use `runner.execute` for explicit snapshot ownership or invalid-result assertions. It returns
|
|
70
|
+
`invalid` for schema or generation assertion errors. Dispose successful snapshots separately from
|
|
71
|
+
the runner; captured snapshots remain valid after runner disposal.
|
|
46
72
|
|
|
47
73
|
Use `runner.validate(parameters, { normalize: false })` to probe deliberately invalid typed values
|
|
48
74
|
without finalizing parts. It checks declarations and reached assertions; observing geometry can
|
package/dist/docs/manifest.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"formatVersion": 1,
|
|
3
3
|
"packageName": "@metamesh/testkit",
|
|
4
|
-
"packageVersion": "0.
|
|
4
|
+
"packageVersion": "0.17.0",
|
|
5
5
|
"documents": [
|
|
6
6
|
{
|
|
7
7
|
"id": "testkit/guide/testing",
|
|
@@ -254,6 +254,34 @@
|
|
|
254
254
|
"index",
|
|
255
255
|
"MeshMeasurementTolerances"
|
|
256
256
|
]
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
"id": "testkit/reference/index/ModelTestOptions",
|
|
260
|
+
"title": "ModelTestOptions",
|
|
261
|
+
"summary": "Session policy and prepared capabilities for one scoped model test. The engine stays host-owned.",
|
|
262
|
+
"path": "reference/index/ModelTestOptions.md",
|
|
263
|
+
"importPath": "@metamesh/testkit",
|
|
264
|
+
"availability": "Local Node testing",
|
|
265
|
+
"canonical": "https://metamesh.studio/docs/develop/agent-authoring#test-models",
|
|
266
|
+
"keywords": [
|
|
267
|
+
"reference",
|
|
268
|
+
"index",
|
|
269
|
+
"ModelTestOptions"
|
|
270
|
+
]
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
"id": "testkit/reference/index/withModel",
|
|
274
|
+
"title": "withModel",
|
|
275
|
+
"summary": "Runs a plain model once and releases its snapshot and temporary session after assertions finish. Prepared services are required when the model declares them. Parameters are passed directly, without Generator normalization. Previously obtained parts remain usable after disposal. The supplied or shared engine is never disposed by this helper.",
|
|
276
|
+
"path": "reference/index/withModel.md",
|
|
277
|
+
"importPath": "@metamesh/testkit",
|
|
278
|
+
"availability": "Local Node testing",
|
|
279
|
+
"canonical": "https://metamesh.studio/docs/develop/agent-authoring#test-models",
|
|
280
|
+
"keywords": [
|
|
281
|
+
"reference",
|
|
282
|
+
"index",
|
|
283
|
+
"withModel"
|
|
284
|
+
]
|
|
257
285
|
}
|
|
258
286
|
]
|
|
259
287
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Byte-verified local font selections and a reusable Generator service-preparation adapter.
|
|
4
4
|
|
|
5
|
-
Import from `@metamesh/testkit/font-fixtures` (@metamesh/testkit@0.
|
|
5
|
+
Import from `@metamesh/testkit/font-fixtures` (@metamesh/testkit@0.17.0).
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
8
|
/** Byte-verified local font selections and a reusable Generator service-preparation adapter. */
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Fixture provider matching createGeneratorTestRunner's asynchronous service boundary.
|
|
4
4
|
|
|
5
|
-
Import from `@metamesh/testkit/font-fixtures` (@metamesh/testkit@0.
|
|
5
|
+
Import from `@metamesh/testkit/font-fixtures` (@metamesh/testkit@0.17.0).
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
8
|
/** Fixture provider matching createGeneratorTestRunner's asynchronous service boundary. */
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Node-only local descriptor loader. Paths resolve beside the descriptor; bytes never come from a catalog.
|
|
4
4
|
|
|
5
|
-
Import from `@metamesh/testkit/font-fixtures` (@metamesh/testkit@0.
|
|
5
|
+
Import from `@metamesh/testkit/font-fixtures` (@metamesh/testkit@0.17.0).
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
8
|
/** Node-only local descriptor loader. Paths resolve beside the descriptor; bytes never come from a catalog. */
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
A checked-in immutable font fixture; no catalog or network is used by the test harness.
|
|
4
4
|
|
|
5
|
-
Import from `@metamesh/testkit/fonts` (@metamesh/testkit@0.
|
|
5
|
+
Import from `@metamesh/testkit/fonts` (@metamesh/testkit@0.17.0).
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
8
|
/** A checked-in immutable font fixture; no catalog or network is used by the test harness. */
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Prepares the same synchronous text service used by Studio, from reproducible fixture bytes.
|
|
4
4
|
|
|
5
|
-
Import from `@metamesh/testkit/fonts` (@metamesh/testkit@0.
|
|
5
|
+
Import from `@metamesh/testkit/fonts` (@metamesh/testkit@0.17.0).
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
8
|
/** Prepares the same synchronous text service used by Studio, from reproducible fixture bytes. */
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Parameter or assertion failure, or a generated snapshot owned separately from its runner.
|
|
4
4
|
|
|
5
|
-
Import from `@metamesh/testkit` (@metamesh/testkit@0.
|
|
5
|
+
Import from `@metamesh/testkit` (@metamesh/testkit@0.17.0).
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
8
|
/** Parameter or assertion failure, or a generated snapshot owned separately from its runner. */
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
A lazy reusable Generator test session; dispose the runner and every returned snapshot separately.
|
|
4
4
|
|
|
5
|
-
Import from `@metamesh/testkit` (@metamesh/testkit@0.
|
|
5
|
+
Import from `@metamesh/testkit` (@metamesh/testkit@0.17.0).
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
8
|
/** A lazy reusable Generator test session; dispose the runner and every returned snapshot separately. */
|
|
@@ -13,6 +13,8 @@ export interface GeneratorTestRunner<D extends GeneratorDefinition> {
|
|
|
13
13
|
}) => Promise<ParameterValidationResult>;
|
|
14
14
|
/** Normalizes once, prepares assets, and executes the same persistent session used by production hosts. */
|
|
15
15
|
readonly execute: (parameters: Readonly<Record<string, unknown>>) => Promise<GeneratorTestExecution<D>>;
|
|
16
|
+
/** Executes once and disposes the snapshot after awaited assertions; invalid output throws its diagnostics. */
|
|
17
|
+
readonly withModel: <Result>(parameters: Readonly<Record<string, unknown>>, inspect: (model: ModelSnapshot) => Result | PromiseLike<Result>) => Promise<Result>;
|
|
16
18
|
/** Releases runner caches; separately owned snapshots remain valid. */
|
|
17
19
|
readonly dispose: () => void;
|
|
18
20
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Fixed host resources and optional asynchronous asset preparation.
|
|
4
4
|
|
|
5
|
-
Import from `@metamesh/testkit` (@metamesh/testkit@0.
|
|
5
|
+
Import from `@metamesh/testkit` (@metamesh/testkit@0.17.0).
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
8
|
/** Fixed host resources and optional asynchronous asset preparation. */
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Physical expectations for a closed mesh; omitted facts are not asserted.
|
|
4
4
|
|
|
5
|
-
Import from `@metamesh/testkit` (@metamesh/testkit@0.
|
|
5
|
+
Import from `@metamesh/testkit` (@metamesh/testkit@0.17.0).
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
8
|
/** Physical expectations for a closed mesh; omitted facts are not asserted. */
|
|
9
9
|
export interface MeshMeasurementExpectation {
|
|
10
10
|
/** Axis-aligned XYZ bounds in millimetres. */
|
|
11
|
-
readonly bounds?:
|
|
11
|
+
readonly bounds?: Bounds3Data;
|
|
12
12
|
/** Oriented enclosed volume in cubic millimetres; outward winding is positive. */
|
|
13
13
|
readonly signedVolume?: number;
|
|
14
14
|
/** Sum of triangle areas in square millimetres. */
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Absolute nonnegative comparison allowances; each omitted tolerance defaults to zero.
|
|
4
4
|
|
|
5
|
-
Import from `@metamesh/testkit` (@metamesh/testkit@0.
|
|
5
|
+
Import from `@metamesh/testkit` (@metamesh/testkit@0.17.0).
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
8
|
/** Absolute nonnegative comparison allowances; each omitted tolerance defaults to zero. */
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# ModelTestOptions
|
|
2
|
+
|
|
3
|
+
Session policy and prepared capabilities for one scoped model test. The engine stays host-owned.
|
|
4
|
+
|
|
5
|
+
Import from `@metamesh/testkit` (@metamesh/testkit@0.17.0).
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
/** Session policy and prepared capabilities for one scoped model test. The engine stays host-owned. */
|
|
9
|
+
export interface ModelTestOptions<S = Record<never, never>> extends SessionOptions<S> {
|
|
10
|
+
/** Reuse a test-owned engine; omitted uses the lazy shared test engine. */
|
|
11
|
+
readonly engine?: ModelEngine;
|
|
12
|
+
}
|
|
13
|
+
```
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Creates a lazy runner for one generation program without loading assets or an engine.
|
|
4
4
|
|
|
5
|
-
Import from `@metamesh/testkit` (@metamesh/testkit@0.
|
|
5
|
+
Import from `@metamesh/testkit` (@metamesh/testkit@0.17.0).
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
8
|
/** Creates a lazy runner for one generation program without loading assets or an engine. */
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Analyzes current buffers, requires closed oriented edge topology, and checks selected physical facts with explicit absolute tolerances. Returns fresh measurements without initializing an engine. These facts do not prove geometric equivalence or absence of self-intersections.
|
|
4
4
|
|
|
5
|
-
Import from `@metamesh/testkit` (@metamesh/testkit@0.
|
|
5
|
+
Import from `@metamesh/testkit` (@metamesh/testkit@0.17.0).
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
8
|
/**
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Throws unless a definition already has the canonical package-serializable representation.
|
|
4
4
|
|
|
5
|
-
Import from `@metamesh/testkit` (@metamesh/testkit@0.
|
|
5
|
+
Import from `@metamesh/testkit` (@metamesh/testkit@0.17.0).
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
8
|
/** Throws unless a definition already has the canonical package-serializable representation. */
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Throws unless defaults strictly decode and equal the defaults derived from the definition.
|
|
4
4
|
|
|
5
|
-
Import from `@metamesh/testkit` (@metamesh/testkit@0.
|
|
5
|
+
Import from `@metamesh/testkit` (@metamesh/testkit@0.17.0).
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
8
|
/** Throws unless defaults strictly decode and equal the defaults derived from the definition. */
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Checks finalized parts without measurement facts, retaining shared snapshot resources and placement. Runs mesh reconstruction/finalization synchronously using the supplied engine. Strictly checks unknown wire data and reconstructs its meshes using the supplied engine. Initializes the shared test engine lazily, then applies the same wire and mesh checks.
|
|
4
4
|
|
|
5
|
-
Import from `@metamesh/testkit` (@metamesh/testkit@0.
|
|
5
|
+
Import from `@metamesh/testkit` (@metamesh/testkit@0.17.0).
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
8
|
/**
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Checks preset metadata. Validate domain assertions through the generation test runner.
|
|
4
4
|
|
|
5
|
-
Import from `@metamesh/testkit` (@metamesh/testkit@0.
|
|
5
|
+
Import from `@metamesh/testkit` (@metamesh/testkit@0.17.0).
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
8
|
/** Checks preset metadata. Validate domain assertions through the generation test runner. */
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# withModel
|
|
2
|
+
|
|
3
|
+
Runs a plain model once and releases its snapshot and temporary session after assertions finish. Prepared services are required when the model declares them. Parameters are passed directly, without Generator normalization. Previously obtained parts remain usable after disposal. The supplied or shared engine is never disposed by this helper.
|
|
4
|
+
|
|
5
|
+
Import from `@metamesh/testkit` (@metamesh/testkit@0.17.0).
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
/**
|
|
9
|
+
* Runs a plain model once and releases its snapshot and temporary session after assertions finish.
|
|
10
|
+
* Prepared services are required when the model declares them. Parameters are passed directly,
|
|
11
|
+
* without Generator normalization. Previously obtained parts remain usable after disposal.
|
|
12
|
+
* The supplied or shared engine is never disposed by this helper.
|
|
13
|
+
*/
|
|
14
|
+
export declare function withModel<P, S, Result>(program: ModelProgram<P, S>, parameters: Readonly<NoInfer<P>>, inspect: (model: ModelSnapshot) => Result | PromiseLike<Result>, ...[options]: keyof S extends never ? [options?: ModelTestOptions<S>] : [options: ModelTestOptions<S> & {
|
|
15
|
+
readonly services: S;
|
|
16
|
+
}]): Promise<Result>;
|
|
17
|
+
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { createGeneratorTestRunner } from "./runner.js";
|
|
2
|
+
export { withModel } from "./model.js";
|
|
3
|
+
export type { ModelTestOptions } from "./model.js";
|
|
2
4
|
export type { GeneratorTestExecution, GeneratorTestRunner, GeneratorTestRunnerOptions, } from "./runner.js";
|
|
3
5
|
export { expectSerializableDefinition, expectValidDefaults, expectValidParts, expectValidPresets, } from "./assertions.js";
|
|
4
6
|
export { getTestEngine } from "./engine.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AACxD,YAAY,EACV,sBAAsB,EACtB,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,4BAA4B,EAC5B,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,YAAY,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,YAAY,EACV,sBAAsB,EACtB,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,4BAA4B,EAC5B,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,YAAY,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { createGeneratorTestRunner } from "./runner.js";
|
|
2
|
+
export { withModel } from "./model.js";
|
|
2
3
|
export { expectSerializableDefinition, expectValidDefaults, expectValidParts, expectValidPresets, } from "./assertions.js";
|
|
3
4
|
export { getTestEngine } from "./engine.js";
|
|
4
5
|
export { expectMeshMeasurements } from "./measurements.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAOvC,OAAO,EACL,4BAA4B,EAC5B,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/measurements.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Bounds3Data, type TriangleMesh, type TriangleMeshAnalysis } from "@metamesh/modeling/geometry";
|
|
2
2
|
/** Physical expectations for a closed mesh; omitted facts are not asserted. */
|
|
3
3
|
export interface MeshMeasurementExpectation {
|
|
4
4
|
/** Axis-aligned XYZ bounds in millimetres. */
|
|
5
|
-
readonly bounds?:
|
|
5
|
+
readonly bounds?: Bounds3Data;
|
|
6
6
|
/** Oriented enclosed volume in cubic millimetres; outward winding is positive. */
|
|
7
7
|
readonly signedVolume?: number;
|
|
8
8
|
/** Sum of triangle areas in square millimetres. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"measurements.d.ts","sourceRoot":"","sources":["../src/measurements.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,
|
|
1
|
+
{"version":3,"file":"measurements.d.ts","sourceRoot":"","sources":["../src/measurements.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EAC1B,MAAM,6BAA6B,CAAC;AAErC,+EAA+E;AAC/E,MAAM,WAAW,0BAA0B;IACzC,8CAA8C;IAC9C,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,kFAAkF;IAClF,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,mDAAmD;IACnD,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,kEAAkE;IAClE,QAAQ,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAC3C;AAED,2FAA2F;AAC3F,MAAM,WAAW,yBAAyB;IACxC,wEAAwE;IACxE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,wDAAwD;IACxD,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,wDAAwD;IACxD,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAaD;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,YAAY,EAClB,QAAQ,EAAE,0BAA0B,EACpC,UAAU,GAAE,yBAA8B,GACzC,oBAAoB,CAqDtB"}
|
package/dist/model.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ModelProgram } from "@metamesh/modeling";
|
|
2
|
+
import type { ModelEngine, ModelSnapshot, SessionOptions } from "@metamesh/modeling/engine";
|
|
3
|
+
/** Session policy and prepared capabilities for one scoped model test. The engine stays host-owned. */
|
|
4
|
+
export interface ModelTestOptions<S = Record<never, never>> extends SessionOptions<S> {
|
|
5
|
+
/** Reuse a test-owned engine; omitted uses the lazy shared test engine. */
|
|
6
|
+
readonly engine?: ModelEngine;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Runs a plain model once and releases its snapshot and temporary session after assertions finish.
|
|
10
|
+
* Prepared services are required when the model declares them. Parameters are passed directly,
|
|
11
|
+
* without Generator normalization. Previously obtained parts remain usable after disposal.
|
|
12
|
+
* The supplied or shared engine is never disposed by this helper.
|
|
13
|
+
*/
|
|
14
|
+
export declare function withModel<P, S, Result>(program: ModelProgram<P, S>, parameters: Readonly<NoInfer<P>>, inspect: (model: ModelSnapshot) => Result | PromiseLike<Result>, ...[options]: keyof S extends never ? [options?: ModelTestOptions<S>] : [options: ModelTestOptions<S> & {
|
|
15
|
+
readonly services: S;
|
|
16
|
+
}]): Promise<Result>;
|
|
17
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAK5F,uGAAuG;AACvG,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;IACnF,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAC1C,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,EAC3B,UAAU,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAChC,OAAO,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,EAC/D,GAAG,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,SAAS,KAAK,GAC/B,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,GAC/B,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAA;CAAE,CAAC,GAC5D,OAAO,CAAC,MAAM,CAAC,CAgBjB"}
|
package/dist/model.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getTestEngine } from "./engine.js";
|
|
2
|
+
import { withSnapshot } from "./snapshot-scope.js";
|
|
3
|
+
/**
|
|
4
|
+
* Runs a plain model once and releases its snapshot and temporary session after assertions finish.
|
|
5
|
+
* Prepared services are required when the model declares them. Parameters are passed directly,
|
|
6
|
+
* without Generator normalization. Previously obtained parts remain usable after disposal.
|
|
7
|
+
* The supplied or shared engine is never disposed by this helper.
|
|
8
|
+
*/
|
|
9
|
+
export async function withModel(program, parameters, inspect, ...[options]) {
|
|
10
|
+
const settings = options ?? {};
|
|
11
|
+
const { engine: providedEngine, ...sessionOptions } = settings;
|
|
12
|
+
const engine = providedEngine ?? (await getTestEngine());
|
|
13
|
+
// The public conditional tuple already requires services for nonempty capabilities.
|
|
14
|
+
const session = engine.createSession(program, ...[sessionOptions]);
|
|
15
|
+
try {
|
|
16
|
+
return await withSnapshot(session.run(parameters), inspect);
|
|
17
|
+
}
|
|
18
|
+
finally {
|
|
19
|
+
session.dispose();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAQnD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,OAA2B,EAC3B,UAAgC,EAChC,OAA+D,EAC/D,GAAG,CAAC,OAAO,CAEkD;IAE7D,MAAM,QAAQ,GAAwB,OAAO,IAAI,EAAE,CAAC;IACpD,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,cAAc,EAAE,GAAG,QAAQ,CAAC;IAC/D,MAAM,MAAM,GAAG,cAAc,IAAI,CAAC,MAAM,aAAa,EAAE,CAAC,CAAC;IACzD,oFAAoF;IACpF,MAAM,OAAO,GAAG,MAAM,CAAC,aAAa,CAClC,OAAO,EACP,GAAI,CAAC,cAAc,CAEyC,CAC7D,CAAC;IACF,IAAI,CAAC;QACH,OAAO,MAAM,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,CAAC;IAC9D,CAAC;YAAS,CAAC;QACT,OAAO,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;AACH,CAAC"}
|
package/dist/runner.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type GeneratorDefinition, type GeneratorParams, type GeneratorServices, type ParameterValidationResult } from "@metamesh/generator-sdk";
|
|
2
|
-
import type
|
|
2
|
+
import { type ModelingLimits, type ModelProgram } from "@metamesh/modeling";
|
|
3
3
|
import { type ModelEngine, type ModelSnapshot } from "@metamesh/modeling/engine";
|
|
4
4
|
/** Fixed host resources and optional asynchronous asset preparation. */
|
|
5
5
|
export interface GeneratorTestRunnerOptions<D extends GeneratorDefinition> {
|
|
@@ -26,6 +26,8 @@ export interface GeneratorTestRunner<D extends GeneratorDefinition> {
|
|
|
26
26
|
}) => Promise<ParameterValidationResult>;
|
|
27
27
|
/** Normalizes once, prepares assets, and executes the same persistent session used by production hosts. */
|
|
28
28
|
readonly execute: (parameters: Readonly<Record<string, unknown>>) => Promise<GeneratorTestExecution<D>>;
|
|
29
|
+
/** Executes once and disposes the snapshot after awaited assertions; invalid output throws its diagnostics. */
|
|
30
|
+
readonly withModel: <Result>(parameters: Readonly<Record<string, unknown>>, inspect: (model: ModelSnapshot) => Result | PromiseLike<Result>) => Promise<Result>;
|
|
29
31
|
/** Releases runner caches; separately owned snapshots remain valid. */
|
|
30
32
|
readonly dispose: () => void;
|
|
31
33
|
}
|
package/dist/runner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/run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UNPREPARED_GENERATOR_SERVICES, } from "@metamesh/generator-sdk";
|
|
2
2
|
import { aggregateParameterIssues, canonicalizeParameters, parseParameterIssues, prepareParameters, } from "@metamesh/generator-sdk/parameters";
|
|
3
3
|
import { generationIssues } from "@metamesh/generator-sdk/runtime";
|
|
4
|
+
import { GenerationError } from "@metamesh/modeling";
|
|
4
5
|
import { validateModel, } from "@metamesh/modeling/engine";
|
|
5
6
|
import { isGeometryError } from "@metamesh/modeling/geometry";
|
|
6
7
|
import { getTestEngine } from "./engine.js";
|
|
8
|
+
import { withSnapshot } from "./snapshot-scope.js";
|
|
7
9
|
/** Creates a lazy runner for one generation program without loading assets or an engine. */
|
|
8
10
|
export function createGeneratorTestRunner(definition, runtime, options = {}) {
|
|
9
11
|
let session;
|
|
@@ -48,6 +50,29 @@ export function createGeneratorTestRunner(definition, runtime, options = {}) {
|
|
|
48
50
|
previous = result;
|
|
49
51
|
return result;
|
|
50
52
|
}
|
|
53
|
+
async function execute(parameters) {
|
|
54
|
+
assertActive();
|
|
55
|
+
const state = prepareParameters(definition, parameters);
|
|
56
|
+
if (!state.validation.isValid)
|
|
57
|
+
return Object.freeze({ type: "invalid", ...state });
|
|
58
|
+
const params = canonical(state.parameters);
|
|
59
|
+
try {
|
|
60
|
+
const capabilities = await services(params);
|
|
61
|
+
const model = await withSession(params, capabilities, (active) => active.run(params));
|
|
62
|
+
const validation = aggregateParameterIssues(state.validation.issues, parseParameterIssues(definition, model.diagnostics));
|
|
63
|
+
return Object.freeze({ type: "generated", parameters: params, validation, model });
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
const issues = generationIssues(definition, error);
|
|
67
|
+
if (issues === undefined || !issues.some(({ severity }) => severity === "error"))
|
|
68
|
+
throw error;
|
|
69
|
+
return Object.freeze({
|
|
70
|
+
type: "invalid",
|
|
71
|
+
parameters: params,
|
|
72
|
+
validation: aggregateParameterIssues(state.validation.issues, issues),
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
51
76
|
return Object.freeze({
|
|
52
77
|
async validate(parameters, probe = {}) {
|
|
53
78
|
assertActive();
|
|
@@ -86,28 +111,12 @@ export function createGeneratorTestRunner(definition, runtime, options = {}) {
|
|
|
86
111
|
return aggregateParameterIssues(state.validation.issues, issues);
|
|
87
112
|
}
|
|
88
113
|
},
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
if (
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
try {
|
|
96
|
-
const capabilities = await services(params);
|
|
97
|
-
const model = await withSession(params, capabilities, (active) => active.run(params));
|
|
98
|
-
const validation = aggregateParameterIssues(state.validation.issues, parseParameterIssues(definition, model.diagnostics));
|
|
99
|
-
return Object.freeze({ type: "generated", parameters: params, validation, model });
|
|
100
|
-
}
|
|
101
|
-
catch (error) {
|
|
102
|
-
const issues = generationIssues(definition, error);
|
|
103
|
-
if (issues === undefined || !issues.some(({ severity }) => severity === "error"))
|
|
104
|
-
throw error;
|
|
105
|
-
return Object.freeze({
|
|
106
|
-
type: "invalid",
|
|
107
|
-
parameters: params,
|
|
108
|
-
validation: aggregateParameterIssues(state.validation.issues, issues),
|
|
109
|
-
});
|
|
110
|
-
}
|
|
114
|
+
execute,
|
|
115
|
+
async withModel(parameters, inspect) {
|
|
116
|
+
const result = await execute(parameters);
|
|
117
|
+
if (result.type === "invalid")
|
|
118
|
+
throw new GenerationError(result.validation.issues);
|
|
119
|
+
return withSnapshot(result.model, inspect);
|
|
111
120
|
},
|
|
112
121
|
dispose() {
|
|
113
122
|
disposed = true;
|
package/dist/runner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,GAK9B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,oCAAoC,C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YACpB,eAAe,GAAG,SAAS,CAAC;YAC5B,QAAQ,GAAG,SAAS,CAAC;QACvB,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ModelSnapshot } from "@metamesh/modeling/engine";
|
|
2
|
+
/** @internal Retains a revision until synchronous or asynchronous assertions finish. */
|
|
3
|
+
export declare function withSnapshot<Result>(model: ModelSnapshot, inspect: (model: ModelSnapshot) => Result | PromiseLike<Result>): Promise<Result>;
|
|
4
|
+
//# sourceMappingURL=snapshot-scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot-scope.d.ts","sourceRoot":"","sources":["../src/snapshot-scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,wFAAwF;AACxF,wBAAsB,YAAY,CAAC,MAAM,EACvC,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,GAC9D,OAAO,CAAC,MAAM,CAAC,CAMjB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** @internal Retains a revision until synchronous or asynchronous assertions finish. */
|
|
2
|
+
export async function withSnapshot(model, inspect) {
|
|
3
|
+
try {
|
|
4
|
+
return await inspect(model);
|
|
5
|
+
}
|
|
6
|
+
finally {
|
|
7
|
+
model.dispose();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=snapshot-scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot-scope.js","sourceRoot":"","sources":["../src/snapshot-scope.ts"],"names":[],"mappings":"AAEA,wFAAwF;AACxF,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,KAAoB,EACpB,OAA+D;IAE/D,IAAI,CAAC;QACH,OAAO,MAAM,OAAO,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;YAAS,CAAC;QACT,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamesh/testkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Runner-neutral MetaMesh model and Generator testing helpers, assertions, and local font fixtures.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -38,13 +38,13 @@
|
|
|
38
38
|
"registry": "https://registry.npmjs.org/"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@metamesh/generator-sdk": "0.
|
|
42
|
-
"@metamesh/modeling": "0.
|
|
41
|
+
"@metamesh/generator-sdk": "0.17.0",
|
|
42
|
+
"@metamesh/modeling": "0.17.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@metamesh/config": "0.0.0",
|
|
46
|
-
"@metamesh/generator-sdk": "0.
|
|
47
|
-
"@metamesh/modeling": "0.
|
|
46
|
+
"@metamesh/generator-sdk": "0.17.0",
|
|
47
|
+
"@metamesh/modeling": "0.17.0",
|
|
48
48
|
"vitest": "^5.0.5",
|
|
49
49
|
"@types/node": "^24.19.2",
|
|
50
50
|
"typescript": "6.0.3"
|