geospec 0.1.0-beta.9 → 0.4.1-next.331
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/README.md +34 -9
- package/agent/doctrine.md +2 -1
- package/agent/geospec-authoring/SKILL.md +3 -3
- package/agent/geospec-authoring/api-index.md +20 -92
- package/agent/geospec-authoring/api-types.md +85 -480
- package/agent/geospec-authoring/public-api-functions.md +21 -1
- package/agent/geospec-authoring/public-api-index.md +215 -319
- package/agent/geospec-authoring/public-api-types-2.md +480 -352
- package/agent/geospec-authoring/public-api-types-3.md +79 -215
- package/agent/geospec-authoring/public-api-types.md +334 -849
- package/agent/resources.js +12 -13
- package/agent/skills.json +2 -3
- package/dist/assertion-client/client.d.mts +14 -15
- package/dist/assertion-client/client.mjs +1 -1
- package/dist/cli/check.mjs +2 -0
- package/dist/cli/cli.d.mts +5 -5
- package/dist/cli/cli.mjs +20 -3
- package/dist/cli/node-host.d.mts +5 -4
- package/dist/cli/node-host.mjs +1 -1
- package/dist/cli/wire-value.mjs +1 -1
- package/dist/config/define-config.d.mts +2 -3
- package/dist/config/node/index.mjs +1 -1
- package/dist/config/node/load.d.mts +2 -3
- package/dist/config/node/load.mjs +1 -1
- package/dist/config/read-geospec-config.d.mts +10 -6
- package/dist/config/read-geospec-config.mjs +1 -1
- package/dist/config/types.d.mts +6 -7
- package/dist/create-geospec.d.mts +7 -6
- package/dist/engine/client.d.mts +15 -15
- package/dist/engine/client.mjs +1 -1
- package/dist/engine/matchers.d.mts +10 -11
- package/dist/engine/pmi.types.d.mts +11 -12
- package/dist/engine/protocol.d.mts +7 -8
- package/dist/engine/protocol.mjs +1 -1
- package/dist/geometry-unit.d.mts +2 -3
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/mesh/index.d.mts +2 -2
- package/dist/mesh/types.d.mts +8 -505
- package/dist/model/errors.d.mts +2 -3
- package/dist/model/load-model.d.mts +3 -4
- package/dist/model/mesh-evidence-matchers.d.mts +2 -3
- package/dist/model/native-model-loader.d.mts +14 -17
- package/dist/model/native-model-loader.mjs +1 -1
- package/dist/model/node/command-exporter.d.mts +3 -4
- package/dist/model/node/command-exporter.mjs +1 -1
- package/dist/model/node/index.mjs +1 -1
- package/dist/model/region-scope.d.mts +3 -6
- package/dist/model/region-scope.mjs +1 -1
- package/dist/model/subject.d.mts +2 -5
- package/dist/model/subject.mjs +1 -1
- package/dist/model/types.d.mts +19 -20
- package/dist/runner/collector.d.mts +7 -8
- package/dist/runner/collector.mjs +3 -1
- package/dist/runner/discovery.d.mts +10 -11
- package/dist/runner/discovery.mjs +5 -1
- package/dist/runner/filter.d.mts +6 -7
- package/dist/runner/filter.mjs +3 -1
- package/dist/runner/index.d.mts +3 -1
- package/dist/runner/index.mjs +1 -1
- package/dist/runner/native/native-pool-grants.d.mts +2 -3
- package/dist/runner/native/native-serial-runner.d.mts +4 -7
- package/dist/runner/native/native-serial-runner.mjs +1 -1
- package/dist/runner/node/engine.d.mts +5 -6
- package/dist/runner/node/index.mjs +1 -1
- package/dist/runner/node/node-vm-filesystem.d.mts +4 -5
- package/dist/runner/node/node-vm-filesystem.mjs +1 -1
- package/dist/runner/node/pool-runner.d.mts +15 -6
- package/dist/runner/node/pool-runner.mjs +1 -1
- package/dist/runner/node/pool-worker-entry.d.mts +9 -6
- package/dist/runner/node/pool-worker-entry.mjs +1 -1
- package/dist/runner/pool/events.mjs +1 -1
- package/dist/runner/pool/pool-messages.d.mts +8 -9
- package/dist/runner/pool/pool.d.mts +4 -6
- package/dist/runner/pool/pool.mjs +1 -1
- package/dist/runner/pool/shard-timings.d.mts +3 -4
- package/dist/runner/pool/worker-host.d.mts +6 -5
- package/dist/runner/pool/worker-host.mjs +1 -1
- package/dist/runner/run-geospec-module.d.mts +2 -3
- package/dist/runner/run-geospec-module.mjs +2 -2
- package/dist/runner/timeout-codes.d.mts +6 -8
- package/dist/runner/types.d.mts +56 -53
- package/dist/runner/worker/no-matching-tests-issue.d.mts +3 -4
- package/dist/runner/worker/runner-types.d.mts +17 -16
- package/dist/runner/worker/serial-runner.mjs +1 -1
- package/dist/selector/types.d.mts +22 -23
- package/dist/step/types.d.mts +4 -119
- package/dist/support/filesystem-errors.mjs +1 -0
- package/dist/support/hash.mjs +1 -0
- package/dist/support/path.mjs +1 -0
- package/dist/support/sha256.mjs +1 -0
- package/dist/support/types.d.mts +38 -0
- package/dist/vitest/adapter.d.mts +5 -6
- package/dist/vitest/adapter.mjs +1 -1
- package/dist/vitest/index.d.mts +0 -1
- package/dist/vitest/index.mjs +1 -1
- package/dist/vitest/node/index.d.mts +2 -0
- package/dist/vitest/node/index.mjs +1 -0
- package/dist/vitest/node/setup-project.d.mts +60 -0
- package/dist/vitest/node/setup-project.mjs +1 -0
- package/dist/vm/plain-module-vm.d.mts +13 -0
- package/dist/vm/plain-module-vm.mjs +8 -0
- package/dist/vm/types.d.mts +142 -0
- package/package.json +17 -9
- package/agent/geospec-authoring/api-types-2.md +0 -85
|
@@ -6,13 +6,13 @@ import { Vec3 } from "../mesh/types.mjs";
|
|
|
6
6
|
*
|
|
7
7
|
* @public
|
|
8
8
|
*/
|
|
9
|
-
type SelectorSurfaceType = 'plane' | 'cylinder' | 'cone' | 'sphere' | 'torus' | 'bspline' | 'other';
|
|
9
|
+
export type SelectorSurfaceType = 'plane' | 'cylinder' | 'cone' | 'sphere' | 'torus' | 'bspline' | 'other';
|
|
10
10
|
/**
|
|
11
11
|
* Inclusive numeric band. A bare number matches within the linear tolerance.
|
|
12
12
|
*
|
|
13
13
|
* @public
|
|
14
14
|
*/
|
|
15
|
-
type NumericRange = number | {
|
|
15
|
+
export type NumericRange = number | {
|
|
16
16
|
min?: number;
|
|
17
17
|
max?: number;
|
|
18
18
|
};
|
|
@@ -21,7 +21,7 @@ type NumericRange = number | {
|
|
|
21
21
|
*
|
|
22
22
|
* @public
|
|
23
23
|
*/
|
|
24
|
-
type Vec3Record = {
|
|
24
|
+
export type Vec3Record = {
|
|
25
25
|
x: number;
|
|
26
26
|
y: number;
|
|
27
27
|
z: number;
|
|
@@ -32,7 +32,7 @@ type Vec3Record = {
|
|
|
32
32
|
*
|
|
33
33
|
* @public
|
|
34
34
|
*/
|
|
35
|
-
type Cardinality = 'one' | 'many' | {
|
|
35
|
+
export type Cardinality = 'one' | 'many' | {
|
|
36
36
|
exactly: number;
|
|
37
37
|
} | {
|
|
38
38
|
atLeast: number;
|
|
@@ -42,7 +42,7 @@ type Cardinality = 'one' | 'many' | {
|
|
|
42
42
|
*
|
|
43
43
|
* @public
|
|
44
44
|
*/
|
|
45
|
-
type DirectionPredicate = {
|
|
45
|
+
export type DirectionPredicate = {
|
|
46
46
|
direction: Vec3;
|
|
47
47
|
angularToleranceDegrees?: number;
|
|
48
48
|
};
|
|
@@ -51,7 +51,7 @@ type DirectionPredicate = {
|
|
|
51
51
|
*
|
|
52
52
|
* @public
|
|
53
53
|
*/
|
|
54
|
-
type RayPredicate = {
|
|
54
|
+
export type RayPredicate = {
|
|
55
55
|
origin: Vec3;
|
|
56
56
|
direction: Vec3;
|
|
57
57
|
};
|
|
@@ -62,7 +62,7 @@ type RayPredicate = {
|
|
|
62
62
|
*
|
|
63
63
|
* @public
|
|
64
64
|
*/
|
|
65
|
-
type FaceQuery = {
|
|
65
|
+
export type FaceQuery = {
|
|
66
66
|
surfaceType?: SelectorSurfaceType;
|
|
67
67
|
/** Face normal parallelism (planar faces). */
|
|
68
68
|
normal?: DirectionPredicate;
|
|
@@ -99,7 +99,7 @@ type FaceQuery = {
|
|
|
99
99
|
*
|
|
100
100
|
* @public
|
|
101
101
|
*/
|
|
102
|
-
type AxisQuery = {
|
|
102
|
+
export type AxisQuery = {
|
|
103
103
|
/** Axis direction parallelism. */
|
|
104
104
|
axis?: DirectionPredicate;
|
|
105
105
|
radius?: NumericRange;
|
|
@@ -121,7 +121,7 @@ type AxisQuery = {
|
|
|
121
121
|
*
|
|
122
122
|
* @public
|
|
123
123
|
*/
|
|
124
|
-
type PlaneQuery = {
|
|
124
|
+
export type PlaneQuery = {
|
|
125
125
|
normal?: DirectionPredicate;
|
|
126
126
|
offset?: NumericRange;
|
|
127
127
|
area?: NumericRange;
|
|
@@ -139,7 +139,7 @@ type PlaneQuery = {
|
|
|
139
139
|
not?: PlaneQuery;
|
|
140
140
|
};
|
|
141
141
|
/**
|
|
142
|
-
* Body query predicates over available source facts. The STEP index
|
|
142
|
+
* Body query predicates over available source facts. The STEP index
|
|
143
143
|
* exposes per-occurrence solid aggregates. Qualified mesh Bodies are material
|
|
144
144
|
* roots, including their cavities; disconnected roots and cavity islands stay
|
|
145
145
|
* separate. Mesh measure, probe and ordering predicates without the required
|
|
@@ -147,7 +147,7 @@ type PlaneQuery = {
|
|
|
147
147
|
*
|
|
148
148
|
* @public
|
|
149
149
|
*/
|
|
150
|
-
type BodyQuery = {
|
|
150
|
+
export type BodyQuery = {
|
|
151
151
|
area?: NumericRange;
|
|
152
152
|
near?: Partial<Vec3Record> & {
|
|
153
153
|
tolerance?: number;
|
|
@@ -166,7 +166,7 @@ type BodyQuery = {
|
|
|
166
166
|
*
|
|
167
167
|
* @public
|
|
168
168
|
*/
|
|
169
|
-
type OccurrenceSelector = {
|
|
169
|
+
export type OccurrenceSelector = {
|
|
170
170
|
kind: 'occurrence';
|
|
171
171
|
/** Product or instance name to match. */
|
|
172
172
|
name?: string | RegExp;
|
|
@@ -176,12 +176,12 @@ type OccurrenceSelector = {
|
|
|
176
176
|
};
|
|
177
177
|
/**
|
|
178
178
|
* Body selector over source-backed solid evidence. Qualified mesh input exposes
|
|
179
|
-
* one material root with its cavities; the STEP index
|
|
179
|
+
* one material root with its cavities; the STEP index exposes one
|
|
180
180
|
* solid aggregate per occurrence. These are not interchangeable body counts.
|
|
181
181
|
*
|
|
182
182
|
* @public
|
|
183
183
|
*/
|
|
184
|
-
type BodySelector = {
|
|
184
|
+
export type BodySelector = {
|
|
185
185
|
kind: 'body';
|
|
186
186
|
/** STEP occurrence scope, or the exact retained mesh primitive label including any ordinal suffix. */
|
|
187
187
|
of?: string | RegExp;
|
|
@@ -193,7 +193,7 @@ type BodySelector = {
|
|
|
193
193
|
*
|
|
194
194
|
* @public
|
|
195
195
|
*/
|
|
196
|
-
type FaceSelector = {
|
|
196
|
+
export type FaceSelector = {
|
|
197
197
|
kind: 'face';
|
|
198
198
|
of?: string | RegExp;
|
|
199
199
|
query?: FaceQuery;
|
|
@@ -204,7 +204,7 @@ type FaceSelector = {
|
|
|
204
204
|
*
|
|
205
205
|
* @public
|
|
206
206
|
*/
|
|
207
|
-
type AxisSelector = {
|
|
207
|
+
export type AxisSelector = {
|
|
208
208
|
kind: 'axis';
|
|
209
209
|
of?: string | RegExp;
|
|
210
210
|
query?: AxisQuery;
|
|
@@ -215,7 +215,7 @@ type AxisSelector = {
|
|
|
215
215
|
*
|
|
216
216
|
* @public
|
|
217
217
|
*/
|
|
218
|
-
type PlaneSelector = {
|
|
218
|
+
export type PlaneSelector = {
|
|
219
219
|
kind: 'plane';
|
|
220
220
|
of?: string | RegExp;
|
|
221
221
|
query?: PlaneQuery;
|
|
@@ -227,7 +227,7 @@ type PlaneSelector = {
|
|
|
227
227
|
*
|
|
228
228
|
* @public
|
|
229
229
|
*/
|
|
230
|
-
type DatumSelector = {
|
|
230
|
+
export type DatumSelector = {
|
|
231
231
|
kind: 'datum';
|
|
232
232
|
/** Full datum name, or part-relative name when `of` scopes an occurrence. */
|
|
233
233
|
name: string;
|
|
@@ -240,7 +240,7 @@ type DatumSelector = {
|
|
|
240
240
|
*
|
|
241
241
|
* @public
|
|
242
242
|
*/
|
|
243
|
-
type InterfaceSelector = {
|
|
243
|
+
export type InterfaceSelector = {
|
|
244
244
|
kind: 'interface';
|
|
245
245
|
/** Full interface name, or part-relative name when `of` scopes an occurrence. */
|
|
246
246
|
name: string;
|
|
@@ -252,7 +252,7 @@ type InterfaceSelector = {
|
|
|
252
252
|
*
|
|
253
253
|
* @public
|
|
254
254
|
*/
|
|
255
|
-
type GroupSelector = {
|
|
255
|
+
export type GroupSelector = {
|
|
256
256
|
kind: 'group';
|
|
257
257
|
/** Full group prefix, or part-relative prefix when `of` scopes an occurrence. */
|
|
258
258
|
name: string;
|
|
@@ -266,6 +266,5 @@ type GroupSelector = {
|
|
|
266
266
|
*
|
|
267
267
|
* @public
|
|
268
268
|
*/
|
|
269
|
-
type GeometrySelector = string | OccurrenceSelector | BodySelector | FaceSelector | AxisSelector | PlaneSelector | DatumSelector | InterfaceSelector | GroupSelector;
|
|
270
|
-
//#endregion
|
|
271
|
-
export { AxisQuery, AxisSelector, BodyQuery, BodySelector, Cardinality, DatumSelector, DirectionPredicate, FaceQuery, FaceSelector, GeometrySelector, GroupSelector, InterfaceSelector, NumericRange, OccurrenceSelector, PlaneQuery, PlaneSelector, RayPredicate, SelectorSurfaceType, Vec3Record };
|
|
269
|
+
export type GeometrySelector = string | OccurrenceSelector | BodySelector | FaceSelector | AxisSelector | PlaneSelector | DatumSelector | InterfaceSelector | GroupSelector;
|
|
270
|
+
//#endregion
|
package/dist/step/types.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/step/types.d.ts
|
|
2
2
|
/**
|
|
3
|
-
* STEP source
|
|
3
|
+
* STEP source types accepted by model loading.
|
|
4
4
|
*
|
|
5
5
|
* @module
|
|
6
6
|
*/
|
|
@@ -9,126 +9,11 @@
|
|
|
9
9
|
*
|
|
10
10
|
* @public
|
|
11
11
|
*/
|
|
12
|
-
type StepSource = string | URL | Uint8Array<ArrayBuffer> | ArrayBuffer | Blob | File | ReadableStream<Uint8Array<ArrayBuffer>> | AsyncIterable<Uint8Array<ArrayBuffer>>;
|
|
12
|
+
export type StepSource = string | URL | Uint8Array<ArrayBuffer> | ArrayBuffer | Blob | File | ReadableStream<Uint8Array<ArrayBuffer>> | AsyncIterable<Uint8Array<ArrayBuffer>>;
|
|
13
13
|
/**
|
|
14
14
|
* STEP reader strategy used by GeoSpec model loading.
|
|
15
15
|
*
|
|
16
16
|
* @public
|
|
17
17
|
*/
|
|
18
|
-
type StepStreamingMode = 'auto' | 'native-stream' | 'filesystem';
|
|
19
|
-
|
|
20
|
-
* One placed occurrence recovered from an AP242 STEP structure read.
|
|
21
|
-
*
|
|
22
|
-
* `path` is dot-joined instance-name segments from the root (root omitted) per
|
|
23
|
-
* the GeoSpec AP242 profile; repeated names under one parent are disambiguated
|
|
24
|
-
* `name[k]` in the parent's stored component order.
|
|
25
|
-
*
|
|
26
|
-
* @public
|
|
27
|
-
*/
|
|
28
|
-
type XdeOccurrence = {
|
|
29
|
-
path: string;
|
|
30
|
-
productName: string;
|
|
31
|
-
instanceName?: string;
|
|
32
|
-
/** 4x4 row-major placement transform (part-local frame -> subject frame). */
|
|
33
|
-
transform: number[];
|
|
34
|
-
/** Index into the native result's retained shape table (proof calls use it). */
|
|
35
|
-
shapeIndex: number;
|
|
36
|
-
/** Analytic axis-aligned bounds of the placed occurrence in subject space. */
|
|
37
|
-
bounds?: {
|
|
38
|
-
min: [number, number, number];
|
|
39
|
-
max: [number, number, number];
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* One part-relative authored subshape name, expanded per occurrence of the
|
|
44
|
-
* owning product (full selector name = `${occurrencePath}.${name}`).
|
|
45
|
-
*
|
|
46
|
-
* @public
|
|
47
|
-
*/
|
|
48
|
-
type XdeSubshapeName = {
|
|
49
|
-
occurrencePath: string;
|
|
50
|
-
name: string;
|
|
51
|
-
shapeType: 'face' | 'edge' | 'vertex' | 'solid';
|
|
52
|
-
/** Index within the owning product shape's deterministic face traversal order. */
|
|
53
|
-
faceIndex: number;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* One native AP242 datum placement row (a coordinate *frame* from the
|
|
57
|
-
* supplemental-geometry channel), expanded per occurrence like subshape names
|
|
58
|
-
* and expressed in subject-frame coordinates.
|
|
59
|
-
*
|
|
60
|
-
* Distinct from {@link XdeSemanticDatum}: this is supplemental geometry
|
|
61
|
-
* (`AXIS2_PLACEMENT_3D` items in a CONSTRUCTIVE_GEOMETRY_REPRESENTATION), not
|
|
62
|
-
* the GD&T `DATUM` family.
|
|
63
|
-
*
|
|
64
|
-
* @public
|
|
65
|
-
*/
|
|
66
|
-
type XdeDatumPlacement = {
|
|
67
|
-
occurrencePath: string;
|
|
68
|
-
name: string;
|
|
69
|
-
origin: [number, number, number];
|
|
70
|
-
xAxis: [number, number, number];
|
|
71
|
-
zAxis: [number, number, number];
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* One semantic GD&T datum (`DATUM` + `DATUM_FEATURE` family) recovered from an
|
|
75
|
-
* AP242 file, attached to product faces via GEOMETRIC_ITEM_SPECIFIC_USAGE and
|
|
76
|
-
* expanded per occurrence of the owning product.
|
|
77
|
-
*
|
|
78
|
-
* @public
|
|
79
|
-
*/
|
|
80
|
-
type XdeSemanticDatum = {
|
|
81
|
-
occurrencePath: string;
|
|
82
|
-
/** The GD&T datum identification letter(s): 'A', 'B', … */
|
|
83
|
-
label: string;
|
|
84
|
-
/** DATUM_FEATURE name when the file authored one. */
|
|
85
|
-
featureName?: string;
|
|
86
|
-
/** Attached faces in the owning product's deterministic face traversal order. */
|
|
87
|
-
faceIndexes: number[];
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* One GD&T datum reference frame (`DATUM_SYSTEM`) with its precedence
|
|
91
|
-
* compartments, expanded per occurrence of the owning product.
|
|
92
|
-
*
|
|
93
|
-
* @public
|
|
94
|
-
*/
|
|
95
|
-
type XdeDatumSystem = {
|
|
96
|
-
occurrencePath: string;
|
|
97
|
-
name: string;
|
|
98
|
-
/** Compartments in precedence order; each holds one or more datum labels (common datums). */
|
|
99
|
-
references: string[][];
|
|
100
|
-
};
|
|
101
|
-
/**
|
|
102
|
-
* One supplemental-geometry `PLANE` item (e.g. `'Datum Plane 1'`), expanded per
|
|
103
|
-
* occurrence and expressed in subject-frame millimetres (per-context units
|
|
104
|
-
* resolved by the reader).
|
|
105
|
-
*
|
|
106
|
-
* @public
|
|
107
|
-
*/
|
|
108
|
-
type XdeSupplementalPlane = {
|
|
109
|
-
occurrencePath: string;
|
|
110
|
-
name: string;
|
|
111
|
-
origin: [number, number, number];
|
|
112
|
-
normal: [number, number, number];
|
|
113
|
-
};
|
|
114
|
-
/**
|
|
115
|
-
* Structured AP242 read result produced by the GeoSpec verification kernel's
|
|
116
|
-
* XDE reader (SB1). One STEP-XDE read yields structure and geometry together.
|
|
117
|
-
*
|
|
118
|
-
* @public
|
|
119
|
-
*/
|
|
120
|
-
type XdeReadResult = {
|
|
121
|
-
occurrences: XdeOccurrence[];
|
|
122
|
-
subshapeNames: XdeSubshapeName[];
|
|
123
|
-
datumPlacements: XdeDatumPlacement[];
|
|
124
|
-
/** Semantic GD&T datums (the `DATUM` family) — empty for graphical-only files. */
|
|
125
|
-
semanticDatums: XdeSemanticDatum[];
|
|
126
|
-
/** GD&T datum reference frames (`DATUM_SYSTEM`). */
|
|
127
|
-
datumSystems: XdeDatumSystem[];
|
|
128
|
-
/** Supplemental-geometry `PLANE` items. */
|
|
129
|
-
supplementalPlanes: XdeSupplementalPlane[];
|
|
130
|
-
/** Free (non-assembly) top-level shapes — the flat-export degenerate case. */
|
|
131
|
-
freeShapeCount: number;
|
|
132
|
-
};
|
|
133
|
-
//#endregion
|
|
134
|
-
export { StepSource, StepStreamingMode, XdeDatumPlacement, XdeDatumSystem, XdeOccurrence, XdeReadResult, XdeSemanticDatum, XdeSubshapeName, XdeSupplementalPlane };
|
|
18
|
+
export type StepStreamingMode = 'auto' | 'native-stream' | 'filesystem';
|
|
19
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=e=>{if(typeof e!=`object`||!e||!(`code`in e))return!1;let{code:t}=e;return t===`ENOENT`||t===`ENOTDIR`};export{e as isNotFoundError};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{sha256 as e}from"./sha256.mjs";async function t(t){let{subtle:n}=globalThis.crypto,r=n?new Uint8Array(await n.digest(`SHA-256`,t)):e(t);return Array.from(r,e=>e.toString(16).padStart(2,`0`)).join(``)}export{t as sha256Bytes};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=class extends Error{code;metadata;constructor(e,t){super(e===`PATH_OUTSIDE_ROOT`?`Virtual path escapes the filesystem root.`:`Invalid virtual path.`),this.name=`VirtualPathError`,this.code=e,this.metadata={input:t}}};const t=/^[A-Za-z][A-Za-z0-9+.-]*:/u,n=n=>{let r=()=>{throw new e(`INVALID_PATH`,n)};if(n.includes(`\\`)||t.test(n))return r();for(let e of n){let t=e.codePointAt(0);if(t!==void 0&&(t<=31||t>=127&&t<=159))return r()}};function r(t){if(t.startsWith(`/`))throw new e(`INVALID_PATH`,t);n(t);let r=[];for(let n of t.split(`/`))if(n.length!==0&&n!==`.`){if(n===`..`){if(r.pop()===void 0)throw new e(`PATH_OUTSIDE_ROOT`,t)}else r.push(n)}return r.join(`/`)}function i(t){if(r(t)!==t)throw new e(`INVALID_PATH`,t);return t}function a(...e){let t=[];for(let n of e)if(n!==``)for(let e of n.split(`/`))e.length>0&&t.push(e);return t.join(`/`)}export{e as VirtualPathError,i as assertRootedPath,a as joinRelativePath,r as resolveRootedPath};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),t=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),n=/* @__PURE__ */ new Uint32Array(64),r=(e,t)=>e<<32-t|e>>>t,i=(e,t,n)=>e&t^~e&n,a=(e,t,n)=>e&t^e&n^t&n;function o(t,o,s){let c=s;for(let e=0;e<16;e++,c+=4)n[e]=o.getUint32(c,!1);for(let e=16;e<64;e++){let t=n[e-15],i=n[e-2],a=r(t,7)^r(t,18)^t>>>3,o=r(i,17)^r(i,19)^i>>>10;n[e]=o+n[e-7]+a+n[e-16]|0}let l=t[0],u=t[1],d=t[2],f=t[3],p=t[4],m=t[5],h=t[6],g=t[7];for(let t=0;t<64;t++){let o=r(p,6)^r(p,11)^r(p,25),s=g+o+i(p,m,h)+e[t]+n[t]|0,c=(r(l,2)^r(l,13)^r(l,22))+a(l,u,d)|0;g=h,h=m,m=p,p=f+s|0,f=d,d=u,u=l,l=s+c|0}t[0]=t[0]+l|0,t[1]=t[1]+u|0,t[2]=t[2]+d|0,t[3]=t[3]+f|0,t[4]=t[4]+p|0,t[5]=t[5]+m|0,t[6]=t[6]+h|0,t[7]=t[7]+g|0}function s(e){let r=Uint32Array.from(t),i=new DataView(e.buffer,e.byteOffset,e.byteLength),{length:a}=e,s=0;for(;s+64<=a;s+=64)o(r,i,s);let c=/* @__PURE__ */ new Uint8Array(64),l=new DataView(c.buffer),u=a-s;c.set(e.subarray(s),0),c[u++]=128,u>56&&(o(r,l,0),c.fill(0));let d=BigInt(a)*8n;l.setBigUint64(56,d,!1),o(r,l,0),n.fill(0);let f=/* @__PURE__ */ new Uint8Array(32),p=new DataView(f.buffer);for(let e=0;e<8;e++)p.setUint32(e*4,r[e],!1);return f}export{s as sha256};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//#region src/support/types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Structural types GeoSpec owns in place of Tau's runtime types, so that `geospec` depends on no Tau
|
|
4
|
+
* package. Each one is structurally identical to (or wider than) Tau's, so Tau values stay assignable.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* A JSON value can be a string, number, boolean, object, array, or null.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export type JSONValue = null | string | number | boolean | JSONObject | JSONArray;
|
|
12
|
+
/** A JSON object: string keys to JSON values. @public */
|
|
13
|
+
export type JSONObject = {
|
|
14
|
+
[key: string]: JSONValue;
|
|
15
|
+
};
|
|
16
|
+
/** A JSON array of JSON values. @public */
|
|
17
|
+
export type JSONArray = JSONValue[];
|
|
18
|
+
/**
|
|
19
|
+
* Runtime issue codes a kernel diagnostic may carry, as Tau's runtime registers them. A host may add codes; GeoSpec
|
|
20
|
+
* diagnostics accept any string beside these.
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
export type KernelIssueCode = 'OPERATION_TIMEOUT' | 'KERNEL_BINDING_FAILED' | 'KERNEL_CAPABILITY_MISSING' | 'KERNEL_NOT_PREPARED' | 'LIBRARY_VERSION_MISMATCH' | 'KERNEL_REALM_CONFLICT' | 'TRANSCODER_CAPABILITY_MISSING' | 'TRANSCODER_OPTIONS_INVALID' | 'TRANSCODER_INITIALIZATION_FAILED' | 'TRANSCODER_EXECUTION_FAILED' | 'TRANSCODER_TIMEOUT' | 'BUNDLER_FAILED' | 'MIDDLEWARE_FAILED' | 'INVALID_SCHEMA' | 'INVALID_ANNOTATION' | 'INVALID_REFERENCE' | 'RESOURCE_LIMIT' | 'TESSELLATION_DOWNGRADED' | 'DISPLAY_SIMPLIFIED' | 'METADATA_CONFLICT' | 'SEMANTICS_UNRESOLVED' | 'REPRESENTATION_UNSUPPORTED' | 'LEGACY_PROJECTION_LOSS' | 'INVALID_RECORD' | 'RENDER_ARTIFACT_MISSING' | 'GLTF_BYTES_INVALID' | 'SVG_DOCUMENT_INVALID' | 'HANDLE_MISSING' | 'VIEW_UNKNOWN' | 'VIEW_UNAVAILABLE' | 'VIEW_OPTIONS_INVALID' | 'EXPORT_UNKNOWN' | 'EXPORT_AMBIGUOUS' | 'EXPORT_OPTIONS_INVALID' | 'EVALUATE_OPTIONS_INVALID' | 'EXPORT_ARTIFACT_SET_INVALID' | 'RUNTIME_CONTENT_UNSUPPORTED' | 'SOURCE_SNAPSHOT_CHANGED' | 'SOURCE_SNAPSHOT_INVALID' | 'GEOMETRY_INVALID' | 'AUTHENTICATION_ERROR' | 'RUNTIME' | 'UNKNOWN';
|
|
25
|
+
/**
|
|
26
|
+
* The exact source a request-scoped kernel operation read: one entry per project source file in the entry's resolved
|
|
27
|
+
* dependency closure, keyed by rooted path, valued with the SHA-256 digest of the bytes read, or `'missing'` for an
|
|
28
|
+
* import that resolved to no file.
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
export type SourceRevision = Readonly<{
|
|
33
|
+
/** Rooted path of the entry file the operation evaluated. */
|
|
34
|
+
entry: string;
|
|
35
|
+
/** Content digest per rooted source path; `'missing'` where the import resolved to no file. */
|
|
36
|
+
files: Readonly<Record<string, `sha256:${string}` | 'missing'>>;
|
|
37
|
+
}>;
|
|
38
|
+
//#endregion
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { GeoSpecSubject } from "../model/subject.mjs";
|
|
2
2
|
import { GeoSpecCanonicalClaimReport, GeoSpecNativeSubject } from "../engine/client.mjs";
|
|
3
3
|
import { GeoSpecAssertionClient, GeoSpecAssertionClientOptions, GeoSpecMatcherMethods } from "../assertion-client/client.mjs";
|
|
4
|
-
import "../assertion-client/index.mjs";
|
|
5
4
|
import { MatcherState } from "vitest";
|
|
6
5
|
//#region src/vitest/adapter.d.ts
|
|
7
6
|
type GeoSpecVitestMatcherMethods = GeoSpecMatcherMethods<Promise<void>>;
|
|
@@ -24,7 +23,7 @@ declare module 'vitest' {
|
|
|
24
23
|
interface Matchers<T = any> extends GeoSpecVitestMatcherMethods {}
|
|
25
24
|
}
|
|
26
25
|
/** Installed Vitest matcher map and lifecycle settlement hook. @public */
|
|
27
|
-
type GeoSpecVitestAdapter = {
|
|
26
|
+
export type GeoSpecVitestAdapter = {
|
|
28
27
|
readonly matchers: GeoSpecVitestMatcherMap;
|
|
29
28
|
flush(): Promise<void>;
|
|
30
29
|
};
|
|
@@ -35,7 +34,7 @@ type GeoSpecVitestAdapter = {
|
|
|
35
34
|
* @returns Matchers and a hook that settles every operation started by a test.
|
|
36
35
|
* @public
|
|
37
36
|
*/
|
|
38
|
-
declare const createGeoSpecVitestAdapter: (client: GeoSpecAssertionClient) => GeoSpecVitestAdapter;
|
|
37
|
+
export declare const createGeoSpecVitestAdapter: (client: GeoSpecAssertionClient) => GeoSpecVitestAdapter;
|
|
39
38
|
/**
|
|
40
39
|
* Register GeoSpec matchers and their settlement hook in the active Vitest file.
|
|
41
40
|
*
|
|
@@ -43,7 +42,7 @@ declare const createGeoSpecVitestAdapter: (client: GeoSpecAssertionClient) => Ge
|
|
|
43
42
|
* @returns The installed adapter for reporters or explicit flushing.
|
|
44
43
|
* @public
|
|
45
44
|
*/
|
|
46
|
-
declare const installGeoSpecVitest: (client: GeoSpecAssertionClient) => GeoSpecVitestAdapter;
|
|
45
|
+
export declare const installGeoSpecVitest: (client: GeoSpecAssertionClient) => GeoSpecVitestAdapter;
|
|
47
46
|
/**
|
|
48
47
|
* Create a native client and register it with the active Vitest file.
|
|
49
48
|
*
|
|
@@ -51,6 +50,6 @@ declare const installGeoSpecVitest: (client: GeoSpecAssertionClient) => GeoSpecV
|
|
|
51
50
|
* @returns The installed adapter for reporters or explicit flushing.
|
|
52
51
|
* @public
|
|
53
52
|
*/
|
|
54
|
-
declare const setupGeoSpecVitest: (options: GeoSpecAssertionClientOptions) => GeoSpecVitestAdapter;
|
|
53
|
+
export declare const setupGeoSpecVitest: (options: GeoSpecAssertionClientOptions) => GeoSpecVitestAdapter;
|
|
55
54
|
//#endregion
|
|
56
|
-
export {
|
|
55
|
+
export {};
|
package/dist/vitest/adapter.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import{geoSpecMatcherDescriptors as e}from"../engine/matchers.mjs";import{GeoSpecAssertionError as t,createGeoSpecAssertionClient as n}from"../assertion-client/client.mjs";import{afterEach as r,expect as i}from"vitest";const a=e=>e.evidence!==null&&typeof e.evidence==`object`&&!Array.isArray(e.evidence)?e.evidence:void 0,o=(e,t)=>{let n=a(t)?.positiveSatisfied;return{pass:(t.status===`passed`||t.status===`failed`)&&typeof n==`boolean`&&t.status===`passed`==(n===(t.polarity===`positive`))?n:e.isNot,actual:t,expected:{claimId:t.claimId,polarity:t.polarity,status:t.status},meta:{geoSpec:t},message:()=>JSON.stringify(t.result)}};var s=class{task;tracked=[];constructor(e){this.task=e,e.onFinished??=[],e.onFinished.push(()=>{for(;this.tracked.length>0;){let[e]=this.tracked;if(e===void 0)break;this.remove(e)}})}replace(e,t){return this.remove(e),this.track(t)}track(e){let t=new c(e,this);return this.task.promises??=[],this.task.promises.push(t),this.tracked.push(t),t}remove(e){let t=this.task.promises?.indexOf(e)??-1;t!==-1&&this.task.promises?.splice(t,1);let n=this.tracked.indexOf(e);n!==-1&&this.tracked.splice(n,1)}},c=class{promise;tracker;constructor(e,t){this.promise=e,this.tracker=t,e.catch(()=>void 0)}get[Symbol.toStringTag](){return`Promise`}then(e,t){return this.tracker.replace(this,this.promise.then(e,t))}catch(e){return this.tracker.replace(this,this.promise.catch(e))}finally(e){return this.tracker.replace(this,this.promise.finally(e))}},l=class{invocationStack;promise;task;constructor(e,t,n){this.promise=e,this.task=t,this.invocationStack=n}get[Symbol.toStringTag](){return`Promise`}then(e,t){let n=this.promise.then(e,t).catch(e=>{if(e instanceof Error&&this.invocationStack!==void 0){let t=this.invocationStack.split(`
|
|
2
2
|
`).slice(1).join(`
|
|
3
|
-
`);e.stack=`${e.stack??e.message}\nGeoSpec assertion invoked at:\n${t}`}throw e});return this.task===void 0?n:new s(this.task).track(n)}catch(e){return this.promise.catch(e)}finally(e){return this.promise.finally(e)}};const u=n=>{let r
|
|
3
|
+
`);e.stack=`${e.stack??e.message}\nGeoSpec assertion invoked at:\n${t}`}throw e});return this.task===void 0?n:new s(this.task).track(n)}catch(e){return this.promise.catch(e)}finally(e){return this.promise.finally(e)}};const u=n=>{let r=/* @__PURE__ */ new Set,i={};for(let a of Object.keys(e))i[a]=function(e,...i){if(!Reflect.has(this,`assertion`))throw TypeError(`GeoSpec Vitest matchers do not support asymmetric use.`);let s=Reflect.get(this,`task`),c=(async()=>{let r=await e,o=n.expectGeo(r),s=this.isNot?o.not:o;try{return Reflect.apply(s[a],s,i)}catch(e){if(e instanceof t)return e.report;throw e}})();return s===void 0&&r.add(c),new l((async()=>o(this,await c))(),s,(/* @__PURE__ */ Error(`Track GeoSpec assertion origin.`)).stack)};let a=async()=>{let e=[...r];r.clear();let n=(await Promise.all(e)).find(e=>e.status!==`passed`);if(n!==void 0)throw new t(n);r.size>0&&await a()};return{matchers:i,flush:a}},d=e=>{let t=u(e);return i.extend(t.matchers),r(async()=>t.flush()),t},f=e=>d(n(e));export{u as createGeoSpecVitestAdapter,d as installGeoSpecVitest,f as setupGeoSpecVitest};
|
package/dist/vitest/index.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { GeoSpecAssertionClient, GeoSpecAssertionClientOptions } from "../assertion-client/client.mjs";
|
|
2
|
-
import "../assertion-client/index.mjs";
|
|
3
2
|
import { GeoSpecVitestAdapter, createGeoSpecVitestAdapter, installGeoSpecVitest, setupGeoSpecVitest } from "./adapter.mjs";
|
|
4
3
|
export { type GeoSpecAssertionClient, type GeoSpecAssertionClientOptions, type GeoSpecVitestAdapter, createGeoSpecVitestAdapter, installGeoSpecVitest, setupGeoSpecVitest };
|
package/dist/vitest/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export{createGeoSpecVitestAdapter,installGeoSpecVitest,setupGeoSpecVitest}from"./adapter.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{setupGeoSpecVitestProject}from"./setup-project.mjs";
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { GeoSpecSubject } from "../../model/subject.mjs";
|
|
2
|
+
import { LoadModelOptions } from "../../model/types.mjs";
|
|
3
|
+
import { GeoSpecNativeModelEngine } from "../../model/native-model-loader.mjs";
|
|
4
|
+
import { GeoSpecAssertionClientOptions } from "../../assertion-client/client.mjs";
|
|
5
|
+
import { GeoSpecConfig } from "../../config/types.mjs";
|
|
6
|
+
import { GeoSpecEngineBinding } from "../../runner/node/engine.mjs";
|
|
7
|
+
import { GeoSpecVitestAdapter } from "../adapter.mjs";
|
|
8
|
+
//#region src/vitest/node/setup-project.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Options for {@link setupGeoSpecVitestProject}. The work-unit maximum stays the host default, because the model
|
|
11
|
+
* loader and the matchers must enforce the same one. @public
|
|
12
|
+
*/
|
|
13
|
+
export type SetupGeoSpecVitestProjectOptions = Omit<GeoSpecAssertionClientOptions, 'engine' | 'maximumWorkUnitLimit'> & {
|
|
14
|
+
/** Absolute project root: `loadModel({ file })` resolves against it and its `geospec.config.*` is read. */
|
|
15
|
+
readonly projectPath: string;
|
|
16
|
+
/** Explicit config file, resolved relative to the project unless absolute. */
|
|
17
|
+
readonly configPath?: string;
|
|
18
|
+
/** Fields that replace the config's whole, as a CLI flag does: `exporters` and `testTimeout` apply here. */
|
|
19
|
+
readonly overrides?: Pick<GeoSpecConfig, 'exporters' | 'testTimeout'>;
|
|
20
|
+
/**
|
|
21
|
+
* A caller-owned engine, kept open after the file. Omitted creates this process's engine (the native addon, else
|
|
22
|
+
* the WASM build) and closes it after the file.
|
|
23
|
+
*/
|
|
24
|
+
readonly engine?: GeoSpecNativeModelEngine;
|
|
25
|
+
};
|
|
26
|
+
/** The installed matchers plus the project's model loader. @public */
|
|
27
|
+
export type GeoSpecVitestProject = GeoSpecVitestAdapter & {
|
|
28
|
+
/** Load a model through the config's exporters; its subjects are released after the file. */
|
|
29
|
+
readonly loadModel: (options: LoadModelOptions) => Promise<GeoSpecSubject>;
|
|
30
|
+
/** The config file that was read, when the project has one. */
|
|
31
|
+
readonly configPath: string | undefined;
|
|
32
|
+
/** The build the created engine runs on; absent for a caller-owned engine. */
|
|
33
|
+
readonly binding: GeoSpecEngineBinding | undefined;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Configure GeoSpec for the active Vitest file from the project's `geospec.config.*`, the file the `geospec` CLI
|
|
37
|
+
* reads. Its `exporters` load models and its `testTimeout` becomes this file's test timeout; Vitest owns discovery,
|
|
38
|
+
* so `include`, `exclude`, `testNamePattern` and `bail` do not apply. The config is trusted code run in-process.
|
|
39
|
+
*
|
|
40
|
+
* Call it at the top level of a test file or a setup file and await it. Subjects are released, and an engine this
|
|
41
|
+
* call created is closed, after the file's tests.
|
|
42
|
+
*
|
|
43
|
+
* @param options - Project root, config file, overrides and assertion-client options.
|
|
44
|
+
* @returns The installed matchers and a `loadModel` over the config's exporters.
|
|
45
|
+
* @public
|
|
46
|
+
*
|
|
47
|
+
* @example <caption>A Vitest file over a project with a geospec.config.ts</caption>
|
|
48
|
+
* ```typescript
|
|
49
|
+
* import { expect, it } from 'vitest';
|
|
50
|
+
* import { setupGeoSpecVitestProject } from 'geospec/vitest/node';
|
|
51
|
+
*
|
|
52
|
+
* const geo = await setupGeoSpecVitestProject({ projectPath: import.meta.dirname });
|
|
53
|
+
*
|
|
54
|
+
* it('has the intended volume', async () => {
|
|
55
|
+
* await expect(await geo.loadModel({ file: 'part.step' })).toHaveVolume({ value: 1000, tolerance: 1 });
|
|
56
|
+
* });
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare const setupGeoSpecVitestProject: (options: SetupGeoSpecVitestProjectOptions) => Promise<GeoSpecVitestProject>;
|
|
60
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createGeoSpecAssertionClient as e}from"../../assertion-client/client.mjs";import{loadGeoSpecConfig as t}from"../../config/node/load.mjs";import{installGeoSpecVitest as n}from"../adapter.mjs";import{createModelLoader as r}from"../../model/load-model.mjs";import{createNodeGeoSpecEngine as i}from"../../runner/node/engine.mjs";import{createNodeVmFileSystem as a}from"../../runner/node/node-vm-filesystem.mjs";import{afterAll as o,vi as s}from"vitest";const c=async c=>{let{projectPath:l,configPath:u,overrides:d,engine:f,...p}=c,m=await t({projectPath:l,...u===void 0?{}:{configPath:u},...d===void 0?{}:{overrides:d}}),h=f===void 0?await i():void 0,g=f??h.engine;try{let t=a(l),i=r({engine:g,projectPath:l,...m.options.exporters===void 0?{}:{exporters:m.options.exporters},readSource:async e=>{if(typeof e!=`string`)throw TypeError(`GeoSpec Vitest file sources must be project-rooted paths.`);return t.readFile(e)}}),c=n(e({...p,engine:g}));return m.options.testTimeout!==void 0&&s.setConfig({testTimeout:m.options.testTimeout}),o(async()=>{try{await i.dispose()}finally{h?.engine.close()}}),{...c,loadModel:i,configPath:m.configPath,binding:h?.binding}}catch(e){throw h?.engine.close(),e}};export{c as setupGeoSpecVitestProject};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ModuleVm, ModuleVmOptions } from "./types.mjs";
|
|
2
|
+
//#region src/vm/plain-module-vm.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Create GeoSpec's default module VM: native `esbuild` over the project filesystem, resolving project files and
|
|
5
|
+
* registered builtins only. A bare npm or URL import is refused with a `BUNDLER_FAILED` issue that names the
|
|
6
|
+
* specifier. Outside Node every bundle is refused with `BUNDLER_FAILED` until a host injects a VM.
|
|
7
|
+
*
|
|
8
|
+
* @param options - The project filesystem.
|
|
9
|
+
* @returns A module VM.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare const createPlainModuleVm: (options: ModuleVmOptions) => Promise<ModuleVm>;
|
|
13
|
+
//#endregion
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{resolveRootedPath as e}from"../support/path.mjs";const t=`BUNDLER_FAILED`,n={project:`vfs`,builtin:`builtin`},r=async e=>import(
|
|
2
|
+
/* webpackIgnore: true */
|
|
3
|
+
/* @vite-ignore */
|
|
4
|
+
e),i=()=>typeof process<`u`&&!!process.versions?.node,a="No module VM is available on this host: GeoSpec bundles specs with native esbuild on Node only. Inject one with `createModuleVm`.",o=e=>`Cannot import '${e}': GeoSpec's default module VM resolves project files and GeoSpec builtins only, never npm packages or URLs. Run the spec on a host that injects a module VM with package resolution (\`createModuleVm\`), or import a project file instead.`,s=e=>e.startsWith(`./`)||e.startsWith(`../`)||e.startsWith(`/`),c=e=>/^[A-Za-z][A-Za-z0-9+.-]*:/u.test(e),l=e=>{let t=e.split(`/`);return e.startsWith(`@`)?t.slice(0,2).join(`/`):t[0]??e},u=[`.ts`,`.tsx`,`.js`,`.jsx`,`/index.ts`,`/index.js`],d=/* @__PURE__ */ new Map([[`.js`,[`.ts`,`.tsx`]],[`.jsx`,[`.tsx`]]]),f=async(e,t)=>{try{return await e.exists(t)}catch(e){if(e.code===`EISDIR`)return!1;throw e}},p=async(t,n,r)=>{let i;if(n.startsWith(`/`))i=e(n.slice(1));else{let t=r.lastIndexOf(`/`),a=t===-1?``:r.slice(0,t);i=e(`${a?`${a}/`:``}${n}`)}if(await f(t,i))return i;let a=/\.[jt]sx?$/u.exec(i)?.[0],o=a?(d.get(a)??[]).map(e=>i.slice(0,-a.length)+e):u.map(e=>i+e);for(let e of o)if(await f(t,e))return e},m=e=>e.endsWith(`.ts`)||e.endsWith(`.mts`)||e.endsWith(`.cts`)?`ts`:e.endsWith(`.tsx`)?`tsx`:e.endsWith(`.jsx`)?`jsx`:e.endsWith(`.json`)?`json`:`js`,h=(e,n)=>({message:e.text,code:t,...e.detail===void 0?{}:{details:e.detail},type:`compilation`,severity:n,location:e.location===null?void 0:{fileName:e.location.file.replace(/^vfs:\/?/u,``),startLineNumber:e.location.line,startColumn:e.location.column}}),g=e=>{if(typeof e==`object`&&e&&`errors`in e){let t=e;return[...(t.errors??[]).map(e=>h(e,`error`)),...(t.warnings??[]).map(e=>h(e,`warning`))]}return[{message:e instanceof Error?e.message:String(e),code:t,type:`compilation`,severity:`error`}]},_=e=>`${[...e.values()].filter(e=>e.globalName!==void 0&&e.registryExpression!==void 0).map(e=>`const ${e.globalName} = ${e.registryExpression};`).join(`
|
|
5
|
+
`)}\nconst exports = {};\nconst module = { exports };\n`,v=({filesystem:t,builtins:r,session:i,detect:a})=>({name:a?`geospec-vfs-detection`:`geospec-vfs`,setup(u){u.onResolve({filter:/.*/},async u=>{let{path:d}=u,f=u.importer.length===0?void 0:u.importer;if(f===void 0){let t=e(d);return i.dependencies.add(t),{path:t,namespace:n.project}}if(s(d)&&u.namespace===n.project)try{let e=await p(t,d,f);return e===void 0?(i.unresolvedPaths.add(d),{errors:[{text:`Cannot find '${d}' imported by '${f}'.`}]}):(i.dependencies.add(e),{path:e,namespace:n.project})}catch(e){return{errors:[{text:`Failed to resolve '${d}': ${e instanceof Error?e.message:String(e)}`}]}}let m=r.has(d)?d:r.has(l(d))?l(d):void 0;return a&&!s(d)?(i.detectedModules.add(d),{path:d,external:!0}):m===void 0?{errors:[{text:o(d),detail:{code:c(d)?`url-import-unsupported`:`package-import-unsupported`,specifier:d}}]}:{path:m,namespace:n.builtin}}),u.onLoad({filter:/.*/,namespace:n.builtin},e=>{let t=r.get(e.path);return t===void 0?{errors:[{text:`Missing builtin module '${e.path}'.`}]}:{contents:t.code,loader:`js`}}),u.onLoad({filter:/.*/,namespace:n.project},async e=>{try{return{contents:await t.readFile(e.path,`utf8`),loader:m(e.path)}}catch(t){return{errors:[{text:`Failed to load '${e.path}': ${t instanceof Error?t.message:String(t)}`}]}}})}});let y=0;const b=e=>e.replace(/\/\/# sourceMappingURL=data:[^\n]+$/mu,``),x=async e=>{let[t,n,i,a,o]=await Promise.all([r(`node:fs`),r(`node:os`),r(`node:path`),r(`node:process`),r(`node:url`)]),s=Math.random().toString(36).slice(2,10),c=i.join(n.tmpdir(),`geospec-exec-${a.pid}-${++y}-${s}.mjs`),l=o.pathToFileURL(c).href;t.writeFileSync(c,b(e),`utf8`);try{return{value:await import(
|
|
6
|
+
/* webpackIgnore: true */
|
|
7
|
+
/* @vite-ignore */
|
|
8
|
+
l),entryUrl:l}}finally{try{t.unlinkSync(c)}catch{}}},S=()=>({code:``,issues:[{message:a,code:t,type:`compilation`,severity:`error`}],success:!1,dependencies:[],unresolvedPaths:[]}),C=async e=>{let{filesystem:n}=e,o=/* @__PURE__ */ new Map,s=i()?await r(`esbuild`):void 0,c=()=>({detectedModules:/* @__PURE__ */ new Set,dependencies:/* @__PURE__ */ new Set,unresolvedPaths:/* @__PURE__ */ new Set});return{async detectImports(e){if(s===void 0)throw Error(a);let t=c();return await s.build({entryPoints:[e],bundle:!0,write:!1,metafile:!0,format:`esm`,target:`es2022`,platform:`browser`,plugins:[v({filesystem:n,builtins:o,session:t,detect:!0})],logLevel:`silent`}),{detectedModules:[...t.detectedModules],dependencies:[...t.dependencies]}},async bundle(e,r){if(s===void 0)return S();let i=c();try{r?.throwIfAborted();let a=await s.build({entryPoints:[e],bundle:!0,write:!1,format:`esm`,target:`es2022`,platform:`browser`,sourcemap:`external`,outdir:`out`,plugins:[v({filesystem:n,builtins:o,session:i,detect:!1})],logLevel:`silent`,banner:{js:_(o)}}),c=a.outputFiles.find(e=>e.path.endsWith(`.js`))??a.outputFiles[0],l=a.outputFiles.find(e=>e.path.endsWith(`.js.map`))?.text,u=a.warnings.map(e=>h(e,`warning`));return c===void 0&&u.push({message:`No output generated`,code:t,type:`compilation`,severity:`error`}),{code:c?.text??``,...l===void 0?{}:{sourceMap:l},issues:u,dependencies:[...i.dependencies],unresolvedPaths:[...i.unresolvedPaths],success:c!==void 0}}catch(e){return{code:``,issues:g(e),dependencies:[...i.dependencies],unresolvedPaths:[...i.unresolvedPaths],success:!1}}},async execute(e,t){try{if(t?.throwIfAborted(),!i())throw Error(a);let{value:n,entryUrl:r}=await x(e);return t?.throwIfAborted(),{success:!0,value:n,entryUrl:r}}catch(e){return{success:!1,issues:[{message:e instanceof Error?e.message:String(e),code:`RUNTIME`,type:`runtime`,severity:`error`}]}}},registerModule(e,t){o.set(e,t)},dispose(){o.clear()}}};export{C as createPlainModuleVm};
|