@flighthq/scene-document 0.5.1-next.973.788d3d7 → 0.6.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/README.md +2 -2
- package/dist/.tsbuildinfo.contract +1 -0
- package/dist/.tsbuildinfo.runtime +1 -0
- package/dist/contract.d.ts +10 -5
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +10 -5
- package/dist/contract.js.map +1 -1
- package/dist/contract.scene-document-types.d.ts +2 -0
- package/dist/contract.scene-document-types.d.ts.map +1 -0
- package/dist/contract.scene-document-types.js +2 -0
- package/dist/contract.scene-document-types.js.map +1 -0
- package/dist/flightDocumentResourceDependencies.d.ts +1 -1
- package/dist/flightDocumentResourceDependencies.d.ts.map +1 -1
- package/dist/flightDocumentResourceDependencies.js +1 -2
- package/dist/flightDocumentResourceDependencies.js.map +1 -1
- package/dist/flightDocumentText.d.ts +3 -2
- package/dist/flightDocumentText.d.ts.map +1 -1
- package/dist/flightDocumentText.js +7 -7
- package/dist/flightDocumentText.js.map +1 -1
- package/dist/index.d.ts +10 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/dist/sceneDocumentInteractiveStateBindings.d.ts +2 -1
- package/dist/sceneDocumentInteractiveStateBindings.d.ts.map +1 -1
- package/dist/sceneDocumentInteractiveStateBindings.js +3 -4
- package/dist/sceneDocumentInteractiveStateBindings.js.map +1 -1
- package/dist/sceneDocumentLayoutBindings.d.ts +2 -1
- package/dist/sceneDocumentLayoutBindings.d.ts.map +1 -1
- package/dist/sceneDocumentLayoutBindings.js +2 -2
- package/dist/sceneDocumentLayoutBindings.js.map +1 -1
- package/dist/sceneDocumentMaterializationSelection.d.ts +1 -1
- package/dist/sceneDocumentMaterializationSelection.d.ts.map +1 -1
- package/dist/sceneDocumentMaterializationSelection.js +2 -2
- package/dist/sceneDocumentMaterializationSelection.js.map +1 -1
- package/dist/sceneDocumentRefusal.d.ts +2 -1
- package/dist/sceneDocumentRefusal.d.ts.map +1 -1
- package/dist/sceneDocumentRefusal.js +9 -10
- package/dist/sceneDocumentRefusal.js.map +1 -1
- package/dist/sceneDocumentScene2DMaterialization.d.ts +10 -3
- package/dist/sceneDocumentScene2DMaterialization.d.ts.map +1 -1
- package/dist/sceneDocumentScene2DMaterialization.js +22 -21
- package/dist/sceneDocumentScene2DMaterialization.js.map +1 -1
- package/dist/sceneDocumentScene3DMaterialization.d.ts +13 -3
- package/dist/sceneDocumentScene3DMaterialization.d.ts.map +1 -1
- package/dist/sceneDocumentScene3DMaterialization.js +19 -18
- package/dist/sceneDocumentScene3DMaterialization.js.map +1 -1
- package/dist/sceneDocumentYamlSubset.d.ts +1 -1
- package/dist/sceneDocumentYamlSubset.d.ts.map +1 -1
- package/dist/sceneDocumentYamlSubset.js.map +1 -1
- package/dist/types.d.ts +251 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +64 -0
- package/dist/types.js.map +1 -0
- package/package.json +14 -12
- package/src/flightDocumentResourceDependencies.test.ts +14 -11
- package/src/flightDocumentText.test.ts +4 -4
- package/src/sceneDocumentInteractiveStateBindings.test.ts +16 -16
- package/src/sceneDocumentLayoutBindings.test.ts +29 -9
- package/src/sceneDocumentMaterializationSelection.test.ts +5 -3
- package/src/sceneDocumentMultiSceneMaterialization.test.ts +28 -26
- package/src/sceneDocumentRefusal.test.ts +18 -18
- package/src/sceneDocumentScene2DMaterialization.test.ts +74 -49
- package/src/sceneDocumentScene3DMaterialization.test.ts +35 -37
- package/src/sceneDocumentYamlSubset.test.ts +2 -2
|
@@ -1,33 +1,35 @@
|
|
|
1
1
|
import { createTransform3D } from '@flighthq/geometry/contract';
|
|
2
2
|
import { createAmbientLight } from '@flighthq/lighting/contract';
|
|
3
|
-
import {
|
|
3
|
+
import type { NodeAny } from '@flighthq/node/contract';
|
|
4
|
+
import { withKindMapEntry } from '@flighthq/registry/contract';
|
|
4
5
|
import { createDisplayObject } from '@flighthq/scene2d/contract';
|
|
6
|
+
import { DisplayObjectKind } from '@flighthq/scene2d/contract';
|
|
5
7
|
import { createNode3D } from '@flighthq/scene3d/contract';
|
|
6
|
-
import
|
|
7
|
-
FlightDocument,
|
|
8
|
-
FlightDocumentFields,
|
|
9
|
-
FlightDocumentNodeSchema,
|
|
10
|
-
FlightDocumentResourceLookup,
|
|
11
|
-
FlightDocumentResourceResolver,
|
|
12
|
-
FlightDocumentResourceResolverRegistry,
|
|
13
|
-
FlightDocumentSchemaRegistry,
|
|
14
|
-
NodeAny,
|
|
15
|
-
} from '@flighthq/types/contract';
|
|
16
|
-
import { DisplayObjectKind, FlightDocumentRefusalReason, Node3DKind } from '@flighthq/types/contract';
|
|
8
|
+
import { Node3DKind } from '@flighthq/scene3d/contract';
|
|
17
9
|
import { describe, expect, it } from 'vitest';
|
|
18
10
|
|
|
19
|
-
import { formatFlightDocumentText } from './flightDocumentText';
|
|
11
|
+
import { formatFlightDocumentText } from './flightDocumentText.ts';
|
|
20
12
|
import {
|
|
21
13
|
createFlightDocumentScene2DMaterialization,
|
|
22
14
|
createFlightDocumentScene2DMaterializationFromText,
|
|
23
15
|
explainFlightDocumentRefusal,
|
|
24
16
|
explainFlightDocumentRefusalFromText,
|
|
25
|
-
} from './sceneDocumentScene2DMaterialization';
|
|
17
|
+
} from './sceneDocumentScene2DMaterialization.ts';
|
|
26
18
|
import {
|
|
27
19
|
createFlightDocumentScene3DMaterialization,
|
|
28
20
|
createFlightDocumentScene3DMaterializationFromText,
|
|
29
21
|
explainFlightDocumentScene3DRefusal,
|
|
30
|
-
} from './sceneDocumentScene3DMaterialization';
|
|
22
|
+
} from './sceneDocumentScene3DMaterialization.ts';
|
|
23
|
+
import type {
|
|
24
|
+
FlightDocument,
|
|
25
|
+
FlightDocumentFields,
|
|
26
|
+
FlightDocumentNodeSchema,
|
|
27
|
+
FlightDocumentResourceLookup,
|
|
28
|
+
FlightDocumentResourceResolver,
|
|
29
|
+
FlightDocumentResourceResolverRegistry,
|
|
30
|
+
FlightDocumentSchemaRegistry,
|
|
31
|
+
} from './types.ts';
|
|
32
|
+
import { FlightDocumentRefusalReason } from './types.ts';
|
|
31
33
|
|
|
32
34
|
const TestScene2DNodeKind = 'TestScene2DNode';
|
|
33
35
|
const TestScene3DNodeKind = 'TestScene3DNode';
|
|
@@ -163,8 +165,8 @@ function createMixedDocument(): FlightDocument {
|
|
|
163
165
|
}
|
|
164
166
|
|
|
165
167
|
function createTestResolvers(sharedResource: unknown): FlightDocumentResourceResolverRegistry {
|
|
166
|
-
let resolvers
|
|
167
|
-
resolvers =
|
|
168
|
+
let resolvers: ReadonlyMap<string, FlightDocumentResourceResolver> = new Map();
|
|
169
|
+
resolvers = withKindMapEntry(resolvers, 'TestResource', (() => sharedResource) as FlightDocumentResourceResolver);
|
|
168
170
|
return { resolvers };
|
|
169
171
|
}
|
|
170
172
|
|
|
@@ -178,13 +180,13 @@ function createTestSchemas(seenResources: unknown[]): FlightDocumentSchemaRegist
|
|
|
178
180
|
kind,
|
|
179
181
|
writeNodeFields: (_out: FlightDocumentFields, _source: Readonly<NodeAny>) => true,
|
|
180
182
|
});
|
|
181
|
-
let nodeSchemas
|
|
182
|
-
nodeSchemas =
|
|
183
|
+
let nodeSchemas: ReadonlyMap<string, FlightDocumentNodeSchema> = new Map();
|
|
184
|
+
nodeSchemas = withKindMapEntry(
|
|
183
185
|
nodeSchemas,
|
|
184
186
|
DisplayObjectKind,
|
|
185
187
|
createSchema(DisplayObjectKind, () => createDisplayObject()),
|
|
186
188
|
);
|
|
187
|
-
nodeSchemas =
|
|
189
|
+
nodeSchemas = withKindMapEntry(
|
|
188
190
|
nodeSchemas,
|
|
189
191
|
TestScene2DNodeKind,
|
|
190
192
|
createSchema(TestScene2DNodeKind, (resources) => {
|
|
@@ -192,12 +194,12 @@ function createTestSchemas(seenResources: unknown[]): FlightDocumentSchemaRegist
|
|
|
192
194
|
return createDisplayObject();
|
|
193
195
|
}),
|
|
194
196
|
);
|
|
195
|
-
nodeSchemas =
|
|
197
|
+
nodeSchemas = withKindMapEntry(
|
|
196
198
|
nodeSchemas,
|
|
197
199
|
Node3DKind,
|
|
198
200
|
createSchema(Node3DKind, () => createNode3D()),
|
|
199
201
|
);
|
|
200
|
-
nodeSchemas =
|
|
202
|
+
nodeSchemas = withKindMapEntry(
|
|
201
203
|
nodeSchemas,
|
|
202
204
|
TestScene3DNodeKind,
|
|
203
205
|
createSchema(TestScene3DNodeKind, (resources) => {
|
|
@@ -206,10 +208,10 @@ function createTestSchemas(seenResources: unknown[]): FlightDocumentSchemaRegist
|
|
|
206
208
|
}),
|
|
207
209
|
);
|
|
208
210
|
return {
|
|
209
|
-
interactiveStateExtensionSchemas:
|
|
210
|
-
interactiveStateTransitionSchemas:
|
|
211
|
+
interactiveStateExtensionSchemas: new Map(),
|
|
212
|
+
interactiveStateTransitionSchemas: new Map(),
|
|
211
213
|
nodeSchemas,
|
|
212
|
-
resourceSchemas:
|
|
213
|
-
shapeCommandSchemas:
|
|
214
|
+
resourceSchemas: new Map(),
|
|
215
|
+
shapeCommandSchemas: new Map(),
|
|
214
216
|
};
|
|
215
217
|
}
|
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
FlightDocumentFields,
|
|
4
|
-
FlightDocumentNode,
|
|
5
|
-
FlightDocumentNodeSchema,
|
|
6
|
-
FlightDocumentResourceLookup,
|
|
7
|
-
FlightDocumentSchemaRegistry,
|
|
8
|
-
NodeAny,
|
|
9
|
-
} from '@flighthq/types/contract';
|
|
10
|
-
import { FlightDocumentRefusalReason } from '@flighthq/types/contract';
|
|
1
|
+
import type { NodeAny } from '@flighthq/node/contract';
|
|
2
|
+
import { withKindMapEntry } from '@flighthq/registry/contract';
|
|
11
3
|
import { describe, expect, it } from 'vitest';
|
|
12
4
|
|
|
13
5
|
import {
|
|
@@ -19,7 +11,15 @@ import {
|
|
|
19
11
|
createDocumentRefusal,
|
|
20
12
|
createSceneRefusal,
|
|
21
13
|
initializeDocumentRefusal,
|
|
22
|
-
} from './sceneDocumentRefusal';
|
|
14
|
+
} from './sceneDocumentRefusal.ts';
|
|
15
|
+
import type {
|
|
16
|
+
FlightDocumentFields,
|
|
17
|
+
FlightDocumentNode,
|
|
18
|
+
FlightDocumentNodeSchema,
|
|
19
|
+
FlightDocumentResourceLookup,
|
|
20
|
+
FlightDocumentSchemaRegistry,
|
|
21
|
+
} from './types.ts';
|
|
22
|
+
import { FlightDocumentRefusalReason } from './types.ts';
|
|
23
23
|
|
|
24
24
|
describe('checkFlightDocumentFields', () => {
|
|
25
25
|
it('uses registered validators and rejects unknown fields', () => {
|
|
@@ -81,7 +81,7 @@ describe('checkFlightDocumentInteractiveStates', () => {
|
|
|
81
81
|
describe('checkFlightDocumentNodeFields', () => {
|
|
82
82
|
it('walks registered nodes recursively', () => {
|
|
83
83
|
const schemas = createTestSchemas('TestKind');
|
|
84
|
-
schemas.nodeSchemas =
|
|
84
|
+
schemas.nodeSchemas = withKindMapEntry(schemas.nodeSchemas, 'TestKind', {
|
|
85
85
|
createNode: () => null,
|
|
86
86
|
fields: [{ name: 'name', required: true, validate: (value) => typeof value === 'string' }],
|
|
87
87
|
kind: 'TestKind',
|
|
@@ -216,14 +216,14 @@ function createTestSchemas(registeredKind: string): FlightDocumentSchemaRegistry
|
|
|
216
216
|
kind: registeredKind,
|
|
217
217
|
writeNodeFields: (_out: FlightDocumentFields, _source: Readonly<NodeAny>) => true,
|
|
218
218
|
};
|
|
219
|
-
let nodeSchemas
|
|
220
|
-
nodeSchemas =
|
|
219
|
+
let nodeSchemas: ReadonlyMap<string, FlightDocumentNodeSchema> = new Map();
|
|
220
|
+
nodeSchemas = withKindMapEntry(nodeSchemas, registeredKind, schema);
|
|
221
221
|
return {
|
|
222
|
-
interactiveStateExtensionSchemas:
|
|
223
|
-
interactiveStateTransitionSchemas:
|
|
222
|
+
interactiveStateExtensionSchemas: new Map(),
|
|
223
|
+
interactiveStateTransitionSchemas: new Map(),
|
|
224
224
|
nodeSchemas,
|
|
225
|
-
resourceSchemas:
|
|
226
|
-
shapeCommandSchemas:
|
|
225
|
+
resourceSchemas: new Map(),
|
|
226
|
+
shapeCommandSchemas: new Map(),
|
|
227
227
|
};
|
|
228
228
|
}
|
|
229
229
|
describe('initializeDocumentRefusal', () => {
|
|
@@ -1,14 +1,25 @@
|
|
|
1
|
+
import { EntityRuntimeKey } from '@flighthq/entity/contract';
|
|
1
2
|
import { addNodeChild, getNodeChildren, getNodeRuntime } from '@flighthq/node/contract';
|
|
2
|
-
import {
|
|
3
|
+
import type { NodeAny } from '@flighthq/node/contract';
|
|
4
|
+
import { withKindMapEntry } from '@flighthq/registry/contract';
|
|
3
5
|
import { createDisplayObject, createScene2D, createSprite } from '@flighthq/scene2d/contract';
|
|
6
|
+
import { DisplayObjectKind, SpriteKind } from '@flighthq/scene2d/contract';
|
|
7
|
+
import type { Node2D } from '@flighthq/scene2d/contract';
|
|
4
8
|
import { createNode3D } from '@flighthq/scene3d/contract';
|
|
9
|
+
import { Node3DKind } from '@flighthq/scene3d/contract';
|
|
10
|
+
import { describe, expect, it } from 'vitest';
|
|
11
|
+
|
|
12
|
+
import { formatFlightDocumentText } from './flightDocumentText.ts';
|
|
5
13
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
createFlightDocumentFromScene2D,
|
|
15
|
+
createFlightDocumentScene2DMaterialization,
|
|
16
|
+
createFlightDocumentScene2DMaterializationFromText,
|
|
17
|
+
explainFlightDocumentRefusal,
|
|
18
|
+
explainFlightDocumentRefusalFromText,
|
|
19
|
+
initializeFlightDocumentFromScene2D,
|
|
20
|
+
initializeFlightDocumentScene2DMaterialization,
|
|
21
|
+
} from './sceneDocumentScene2DMaterialization.ts';
|
|
22
|
+
import { FlightDocumentRefusalReason } from './types.ts';
|
|
12
23
|
import type {
|
|
13
24
|
FlightDocument,
|
|
14
25
|
FlightDocumentFields,
|
|
@@ -19,21 +30,7 @@ import type {
|
|
|
19
30
|
FlightDocumentScene,
|
|
20
31
|
FlightDocumentScene2DMaterialization,
|
|
21
32
|
FlightDocumentSchemaRegistry,
|
|
22
|
-
|
|
23
|
-
NodeAny,
|
|
24
|
-
} from '@flighthq/types/contract';
|
|
25
|
-
import { describe, expect, it } from 'vitest';
|
|
26
|
-
|
|
27
|
-
import { formatFlightDocumentText } from './flightDocumentText';
|
|
28
|
-
import {
|
|
29
|
-
createFlightDocumentFromScene2D,
|
|
30
|
-
createFlightDocumentScene2DMaterialization,
|
|
31
|
-
createFlightDocumentScene2DMaterializationFromText,
|
|
32
|
-
explainFlightDocumentRefusal,
|
|
33
|
-
explainFlightDocumentRefusalFromText,
|
|
34
|
-
initializeFlightDocumentFromScene2D,
|
|
35
|
-
initializeFlightDocumentScene2DMaterialization,
|
|
36
|
-
} from './sceneDocumentScene2DMaterialization';
|
|
33
|
+
} from './types.ts';
|
|
37
34
|
|
|
38
35
|
describe('createFlightDocumentFromScene2D', () => {
|
|
39
36
|
it('creates a model from an empty Scene2D', () => {
|
|
@@ -46,7 +43,10 @@ describe('createFlightDocumentFromScene2D', () => {
|
|
|
46
43
|
|
|
47
44
|
it('elides default-valued fields', () => {
|
|
48
45
|
const scene = createScene2D();
|
|
49
|
-
const obj =
|
|
46
|
+
const obj = ((created) => {
|
|
47
|
+
Object.assign(created, { name: 'default' });
|
|
48
|
+
return created;
|
|
49
|
+
})(createDisplayObject());
|
|
50
50
|
addNodeChild(scene.root, obj);
|
|
51
51
|
const schemas = createTestSchemas();
|
|
52
52
|
const document = createFlightDocumentFromScene2D(scene, schemas);
|
|
@@ -60,7 +60,10 @@ describe('createFlightDocumentFromScene2D', () => {
|
|
|
60
60
|
|
|
61
61
|
it('preserves transform fields', () => {
|
|
62
62
|
const scene = createScene2D();
|
|
63
|
-
const obj =
|
|
63
|
+
const obj = ((created) => {
|
|
64
|
+
Object.assign(created, { name: 'moved' });
|
|
65
|
+
return created;
|
|
66
|
+
})(createDisplayObject());
|
|
64
67
|
obj.x = 100;
|
|
65
68
|
obj.y = 200;
|
|
66
69
|
obj.scaleX = 2;
|
|
@@ -114,7 +117,10 @@ describe('createFlightDocumentFromScene2D', () => {
|
|
|
114
117
|
|
|
115
118
|
it('serializes children into nested nodes', () => {
|
|
116
119
|
const scene = createScene2D();
|
|
117
|
-
const sprite =
|
|
120
|
+
const sprite = ((created) => {
|
|
121
|
+
Object.assign(created, { name: 'hero' });
|
|
122
|
+
return created;
|
|
123
|
+
})(createSprite());
|
|
118
124
|
addNodeChild(scene.root, sprite);
|
|
119
125
|
const schemas = createTestSchemas();
|
|
120
126
|
const document = createFlightDocumentFromScene2D(scene, schemas);
|
|
@@ -125,7 +131,10 @@ describe('createFlightDocumentFromScene2D', () => {
|
|
|
125
131
|
it('writes layouts only from explicit inert bindings and preserves unknown kinds and styles', () => {
|
|
126
132
|
const scene = createScene2D();
|
|
127
133
|
scene.root.name = 'root';
|
|
128
|
-
const child =
|
|
134
|
+
const child = ((created) => {
|
|
135
|
+
Object.assign(created, { name: 'child' });
|
|
136
|
+
return created;
|
|
137
|
+
})(createDisplayObject());
|
|
129
138
|
addNodeChild(scene.root, child);
|
|
130
139
|
const tree = {
|
|
131
140
|
nodes: [
|
|
@@ -143,7 +152,10 @@ describe('createFlightDocumentFromScene2D', () => {
|
|
|
143
152
|
it('rejects foreign, unnamed, ambiguous, and structurally invalid explicit layout bindings', () => {
|
|
144
153
|
const scene = createScene2D();
|
|
145
154
|
scene.root.name = 'root';
|
|
146
|
-
const duplicate =
|
|
155
|
+
const duplicate = ((created) => {
|
|
156
|
+
Object.assign(created, { name: 'root' });
|
|
157
|
+
return created;
|
|
158
|
+
})(createDisplayObject());
|
|
147
159
|
addNodeChild(scene.root, duplicate);
|
|
148
160
|
const tree = { nodes: [{ containerStyle: null, itemStyle: null, kind: 'acme.Leaf', parentIndex: -1 }] };
|
|
149
161
|
|
|
@@ -152,7 +164,17 @@ describe('createFlightDocumentFromScene2D', () => {
|
|
|
152
164
|
scene,
|
|
153
165
|
createTestSchemas(),
|
|
154
166
|
[],
|
|
155
|
-
[
|
|
167
|
+
[
|
|
168
|
+
{
|
|
169
|
+
targets: [
|
|
170
|
+
((created) => {
|
|
171
|
+
Object.assign(created, { name: 'foreign' });
|
|
172
|
+
return created;
|
|
173
|
+
})(createDisplayObject()),
|
|
174
|
+
],
|
|
175
|
+
tree,
|
|
176
|
+
},
|
|
177
|
+
],
|
|
156
178
|
),
|
|
157
179
|
).toThrow(RangeError);
|
|
158
180
|
expect(() =>
|
|
@@ -326,11 +348,11 @@ describe('explainFlightDocumentRefusal', () => {
|
|
|
326
348
|
tokens: [],
|
|
327
349
|
});
|
|
328
350
|
const schemas = createTestSchemas();
|
|
329
|
-
const schema = schemas.nodeSchemas.
|
|
330
|
-
if (schema
|
|
331
|
-
schemas.nodeSchemas =
|
|
332
|
-
...schema
|
|
333
|
-
fields: schema.
|
|
351
|
+
const schema = schemas.nodeSchemas.get(DisplayObjectKind);
|
|
352
|
+
if (schema == null) throw new Error('expected DisplayObject schema');
|
|
353
|
+
schemas.nodeSchemas = withKindMapEntry(schemas.nodeSchemas, DisplayObjectKind, {
|
|
354
|
+
...schema,
|
|
355
|
+
fields: schema.fields.map((field) => (field.name === 'x' ? { ...field, required: true } : field)),
|
|
334
356
|
});
|
|
335
357
|
|
|
336
358
|
expect(explainFlightDocumentRefusal(document, 'Scene2D', schemas)).toBeNull();
|
|
@@ -381,11 +403,11 @@ describe('explainFlightDocumentRefusal', () => {
|
|
|
381
403
|
tokens: [],
|
|
382
404
|
});
|
|
383
405
|
const schemas = createTestSchemas();
|
|
384
|
-
const schema = schemas.nodeSchemas.
|
|
385
|
-
if (schema
|
|
386
|
-
schemas.nodeSchemas =
|
|
387
|
-
...schema
|
|
388
|
-
fields: schema.
|
|
406
|
+
const schema = schemas.nodeSchemas.get(DisplayObjectKind);
|
|
407
|
+
if (schema == null) throw new Error('expected DisplayObject schema');
|
|
408
|
+
schemas.nodeSchemas = withKindMapEntry(schemas.nodeSchemas, DisplayObjectKind, {
|
|
409
|
+
...schema,
|
|
410
|
+
fields: schema.fields.map((field) => (field.name === 'name' ? { ...field, required: true } : field)),
|
|
389
411
|
});
|
|
390
412
|
|
|
391
413
|
expect(createFlightDocumentScene2DMaterialization(document, schemas)).toBeNull();
|
|
@@ -564,7 +586,10 @@ describe('formatFlightDocumentText', () => {
|
|
|
564
586
|
|
|
565
587
|
it('round-trips a Scene2D with children through text', () => {
|
|
566
588
|
const scene = createScene2D();
|
|
567
|
-
const sprite =
|
|
589
|
+
const sprite = ((created) => {
|
|
590
|
+
Object.assign(created, { name: 'hero' });
|
|
591
|
+
return created;
|
|
592
|
+
})(createSprite());
|
|
568
593
|
sprite.x = 50;
|
|
569
594
|
sprite.y = 100;
|
|
570
595
|
addNodeChild(scene.root, sprite);
|
|
@@ -631,16 +656,16 @@ function createTestSchemas(): FlightDocumentSchemaRegistry {
|
|
|
631
656
|
},
|
|
632
657
|
};
|
|
633
658
|
|
|
634
|
-
let nodeSchemas
|
|
635
|
-
nodeSchemas =
|
|
636
|
-
nodeSchemas =
|
|
659
|
+
let nodeSchemas: ReadonlyMap<string, FlightDocumentNodeSchema> = new Map();
|
|
660
|
+
nodeSchemas = withKindMapEntry(nodeSchemas, DisplayObjectKind, displayObjectSchema);
|
|
661
|
+
nodeSchemas = withKindMapEntry(nodeSchemas, SpriteKind, spriteSchema);
|
|
637
662
|
|
|
638
663
|
return {
|
|
639
|
-
interactiveStateExtensionSchemas:
|
|
640
|
-
interactiveStateTransitionSchemas:
|
|
664
|
+
interactiveStateExtensionSchemas: new Map(),
|
|
665
|
+
interactiveStateTransitionSchemas: new Map(),
|
|
641
666
|
nodeSchemas,
|
|
642
|
-
resourceSchemas:
|
|
643
|
-
shapeCommandSchemas:
|
|
667
|
+
resourceSchemas: new Map(),
|
|
668
|
+
shapeCommandSchemas: new Map(),
|
|
644
669
|
};
|
|
645
670
|
}
|
|
646
671
|
|
|
@@ -795,7 +820,7 @@ describe('Scene2D interactive-state materialization', () => {
|
|
|
795
820
|
|
|
796
821
|
it('validates registered extension fields through the shared validator', () => {
|
|
797
822
|
const schemas = createTestSchemas();
|
|
798
|
-
schemas.interactiveStateExtensionSchemas =
|
|
823
|
+
schemas.interactiveStateExtensionSchemas = withKindMapEntry(
|
|
799
824
|
schemas.interactiveStateExtensionSchemas,
|
|
800
825
|
'acme.Outline',
|
|
801
826
|
{
|
|
@@ -878,7 +903,7 @@ describe('Scene2D root fidelity', () => {
|
|
|
878
903
|
// The kind must be REGISTERED for this to be the case under test — an unregistered kind is caught one
|
|
879
904
|
// check earlier, and that is a different refusal with a different remedy.
|
|
880
905
|
const schemas = createTestSchemas();
|
|
881
|
-
schemas.nodeSchemas =
|
|
906
|
+
schemas.nodeSchemas = withKindMapEntry(schemas.nodeSchemas, Node3DKind, {
|
|
882
907
|
createNode: () => createNode3D() as unknown as NodeAny,
|
|
883
908
|
fields: [],
|
|
884
909
|
kind: Node3DKind,
|
|
@@ -894,7 +919,7 @@ describe('Scene2D root fidelity', () => {
|
|
|
894
919
|
it('passes a genuinely empty resource map to a root-dimension probe', () => {
|
|
895
920
|
const schemas = createTestSchemas();
|
|
896
921
|
let resourceKeys: string[] | null = null;
|
|
897
|
-
schemas.nodeSchemas =
|
|
922
|
+
schemas.nodeSchemas = withKindMapEntry(schemas.nodeSchemas, Node3DKind, {
|
|
898
923
|
createNode: (_fields, resources) => {
|
|
899
924
|
resourceKeys = Object.keys(resources);
|
|
900
925
|
return createNode3D() as unknown as NodeAny;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createPerspectiveProjection } from '@flighthq/camera/contract';
|
|
2
|
+
import { EntityRuntimeKey } from '@flighthq/entity/contract';
|
|
2
3
|
import { createTransform3D, createVector3, setQuaternionFromAxisAngle } from '@flighthq/geometry/contract';
|
|
3
4
|
import {
|
|
4
5
|
createAmbientLight,
|
|
@@ -7,37 +8,19 @@ import {
|
|
|
7
8
|
createPointLight,
|
|
8
9
|
createSpotLight,
|
|
9
10
|
} from '@flighthq/lighting/contract';
|
|
11
|
+
import type { Light, Scene3DLightsLike } from '@flighthq/lighting/contract';
|
|
12
|
+
import { AmbientLightKind, DirectionalLightKind } from '@flighthq/lighting/contract';
|
|
10
13
|
import { getNodeChildren, invalidateNodeLocalTransform } from '@flighthq/node/contract';
|
|
11
|
-
import {
|
|
14
|
+
import type { NodeAny } from '@flighthq/node/contract';
|
|
15
|
+
import { withKindMapEntry } from '@flighthq/registry/contract';
|
|
12
16
|
import { createDisplayObject } from '@flighthq/scene2d/contract';
|
|
17
|
+
import { DisplayObjectKind } from '@flighthq/scene2d/contract';
|
|
13
18
|
import { createNode3D, createScene3D } from '@flighthq/scene3d/contract';
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
FlightDocumentFields,
|
|
17
|
-
FlightDocumentInteractiveStates,
|
|
18
|
-
FlightDocumentNodeSchema,
|
|
19
|
-
FlightDocumentResourceDescriptor,
|
|
20
|
-
FlightDocumentResourceLookup,
|
|
21
|
-
FlightDocumentScene,
|
|
22
|
-
FlightDocumentScene3DMaterialization,
|
|
23
|
-
FlightDocumentSchemaRegistry,
|
|
24
|
-
Light,
|
|
25
|
-
NodeAny,
|
|
26
|
-
Scene3DLightsLike,
|
|
27
|
-
Scene3DDocumentCamera,
|
|
28
|
-
Scene3DDocumentLight,
|
|
29
|
-
} from '@flighthq/types/contract';
|
|
30
|
-
import {
|
|
31
|
-
AmbientLightKind,
|
|
32
|
-
DirectionalLightKind,
|
|
33
|
-
DisplayObjectKind,
|
|
34
|
-
EntityRuntimeKey,
|
|
35
|
-
FlightDocumentRefusalReason,
|
|
36
|
-
Node3DKind,
|
|
37
|
-
} from '@flighthq/types/contract';
|
|
19
|
+
import { Node3DKind } from '@flighthq/scene3d/contract';
|
|
20
|
+
import type { Scene3DDocumentCamera, Scene3DDocumentLight } from '@flighthq/scene3d/contract';
|
|
38
21
|
import { describe, expect, expectTypeOf, it } from 'vitest';
|
|
39
22
|
|
|
40
|
-
import { formatFlightDocumentText } from './flightDocumentText';
|
|
23
|
+
import { formatFlightDocumentText } from './flightDocumentText.ts';
|
|
41
24
|
import {
|
|
42
25
|
createFlightDocumentFromScene3D,
|
|
43
26
|
createFlightDocumentScene3DMaterialization,
|
|
@@ -46,7 +29,19 @@ import {
|
|
|
46
29
|
explainFlightDocumentScene3DRefusalFromText,
|
|
47
30
|
initializeFlightDocumentFromScene3D,
|
|
48
31
|
initializeFlightDocumentScene3DMaterialization,
|
|
49
|
-
} from './sceneDocumentScene3DMaterialization';
|
|
32
|
+
} from './sceneDocumentScene3DMaterialization.ts';
|
|
33
|
+
import type {
|
|
34
|
+
FlightDocument,
|
|
35
|
+
FlightDocumentFields,
|
|
36
|
+
FlightDocumentInteractiveStates,
|
|
37
|
+
FlightDocumentNodeSchema,
|
|
38
|
+
FlightDocumentResourceDescriptor,
|
|
39
|
+
FlightDocumentResourceLookup,
|
|
40
|
+
FlightDocumentScene,
|
|
41
|
+
FlightDocumentScene3DMaterialization,
|
|
42
|
+
FlightDocumentSchemaRegistry,
|
|
43
|
+
} from './types.ts';
|
|
44
|
+
import { FlightDocumentRefusalReason } from './types.ts';
|
|
50
45
|
|
|
51
46
|
describe('createFlightDocumentFromScene3D', () => {
|
|
52
47
|
it('creates a model from an empty Scene3D', () => {
|
|
@@ -101,7 +96,10 @@ describe('createFlightDocumentFromScene3D', () => {
|
|
|
101
96
|
});
|
|
102
97
|
|
|
103
98
|
it('writes layouts only from the optional explicit binding argument after interactive bindings', () => {
|
|
104
|
-
const scene =
|
|
99
|
+
const scene = ((created) => {
|
|
100
|
+
Object.assign(created.root, { name: 'world' });
|
|
101
|
+
return created;
|
|
102
|
+
})(createScene3D());
|
|
105
103
|
const tree = {
|
|
106
104
|
nodes: [{ containerStyle: { custom: true }, itemStyle: null, kind: 'acme.World', parentIndex: -1 }],
|
|
107
105
|
};
|
|
@@ -817,15 +815,15 @@ function createTestSchemas(): FlightDocumentSchemaRegistry {
|
|
|
817
815
|
},
|
|
818
816
|
};
|
|
819
817
|
|
|
820
|
-
let nodeSchemas
|
|
821
|
-
nodeSchemas =
|
|
818
|
+
let nodeSchemas: ReadonlyMap<string, FlightDocumentNodeSchema> = new Map();
|
|
819
|
+
nodeSchemas = withKindMapEntry(nodeSchemas, Node3DKind, node3DSchema);
|
|
822
820
|
|
|
823
821
|
return {
|
|
824
|
-
interactiveStateExtensionSchemas:
|
|
825
|
-
interactiveStateTransitionSchemas:
|
|
822
|
+
interactiveStateExtensionSchemas: new Map(),
|
|
823
|
+
interactiveStateTransitionSchemas: new Map(),
|
|
826
824
|
nodeSchemas,
|
|
827
|
-
resourceSchemas:
|
|
828
|
-
shapeCommandSchemas:
|
|
825
|
+
resourceSchemas: new Map(),
|
|
826
|
+
shapeCommandSchemas: new Map(),
|
|
829
827
|
};
|
|
830
828
|
}
|
|
831
829
|
|
|
@@ -851,7 +849,7 @@ describe('Scene3D root fidelity', () => {
|
|
|
851
849
|
|
|
852
850
|
it('refuses a registered root whose kind belongs to the other dimension', () => {
|
|
853
851
|
const schemas = createTestSchemas();
|
|
854
|
-
schemas.nodeSchemas =
|
|
852
|
+
schemas.nodeSchemas = withKindMapEntry(schemas.nodeSchemas, DisplayObjectKind, {
|
|
855
853
|
createNode: () => createDisplayObject() as unknown as NodeAny,
|
|
856
854
|
fields: [],
|
|
857
855
|
kind: DisplayObjectKind,
|
|
@@ -867,7 +865,7 @@ describe('Scene3D root fidelity', () => {
|
|
|
867
865
|
it('passes a genuinely empty resource map to a root-dimension probe', () => {
|
|
868
866
|
const schemas = createTestSchemas();
|
|
869
867
|
let resourceKeys: string[] | null = null;
|
|
870
|
-
schemas.nodeSchemas =
|
|
868
|
+
schemas.nodeSchemas = withKindMapEntry(schemas.nodeSchemas, DisplayObjectKind, {
|
|
871
869
|
createNode: (_fields, resources) => {
|
|
872
870
|
resourceKeys = Object.keys(resources);
|
|
873
871
|
return createDisplayObject() as unknown as NodeAny;
|
|
@@ -888,7 +886,7 @@ function rootDocument3D(
|
|
|
888
886
|
fields: Record<string, unknown>,
|
|
889
887
|
schemas: FlightDocumentSchemaRegistry,
|
|
890
888
|
): FlightDocument {
|
|
891
|
-
schemas.nodeSchemas =
|
|
889
|
+
schemas.nodeSchemas = withKindMapEntry(schemas.nodeSchemas, Node3DKind, {
|
|
892
890
|
createNode: (nodeFields) => {
|
|
893
891
|
const node = createNode3D();
|
|
894
892
|
if (typeof nodeFields['name'] === 'string') node.name = nodeFields['name'];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { FlightDocumentRefusalReason } from '@flighthq/types/contract';
|
|
2
1
|
import { expectTypeOf } from 'vitest';
|
|
3
2
|
|
|
4
|
-
import { parseSceneDocumentYamlSubset } from './sceneDocumentYamlSubset';
|
|
3
|
+
import { parseSceneDocumentYamlSubset } from './sceneDocumentYamlSubset.ts';
|
|
4
|
+
import type { FlightDocumentRefusalReason } from './types.ts';
|
|
5
5
|
|
|
6
6
|
describe('parseSceneDocumentYamlSubset', () => {
|
|
7
7
|
it('types every emitted refusal as a subset of the public taxonomy', () => {
|