@holoscript/core 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-2XXE34KS.js +344 -0
- package/dist/chunk-2XXE34KS.js.map +1 -0
- package/dist/chunk-3X2EGU7Z.cjs +52 -0
- package/dist/chunk-3X2EGU7Z.cjs.map +1 -0
- package/dist/chunk-AFFVFO4D.js +1689 -0
- package/dist/chunk-AFFVFO4D.js.map +1 -0
- package/dist/chunk-DGUM43GV.js +10 -0
- package/dist/chunk-DGUM43GV.js.map +1 -0
- package/{src/HoloScriptDebugger.ts → dist/chunk-DOY73HDH.js} +118 -257
- package/dist/chunk-DOY73HDH.js.map +1 -0
- package/dist/chunk-JEQ2X3Z6.cjs +12 -0
- package/dist/chunk-JEQ2X3Z6.cjs.map +1 -0
- package/dist/chunk-L6VLNVKP.cjs +1691 -0
- package/dist/chunk-L6VLNVKP.cjs.map +1 -0
- package/dist/chunk-MFNO57XL.cjs +347 -0
- package/dist/chunk-MFNO57XL.cjs.map +1 -0
- package/dist/chunk-R75MREOS.cjs +424 -0
- package/dist/chunk-R75MREOS.cjs.map +1 -0
- package/dist/chunk-SATNCODL.js +45 -0
- package/dist/chunk-SATNCODL.js.map +1 -0
- package/dist/chunk-T57ZL7KR.cjs +1281 -0
- package/dist/chunk-T57ZL7KR.cjs.map +1 -0
- package/dist/chunk-U72GEJZT.js +1279 -0
- package/dist/chunk-U72GEJZT.js.map +1 -0
- package/dist/debugger.cjs +20 -0
- package/dist/debugger.cjs.map +1 -0
- package/dist/debugger.d.cts +171 -0
- package/dist/debugger.d.ts +171 -0
- package/dist/debugger.js +7 -0
- package/dist/debugger.js.map +1 -0
- package/dist/index.cjs +6803 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4093 -0
- package/dist/index.d.ts +4093 -0
- package/dist/index.js +6715 -0
- package/dist/index.js.map +1 -0
- package/dist/parser.cjs +14 -0
- package/dist/parser.cjs.map +1 -0
- package/dist/parser.d.cts +172 -0
- package/dist/parser.d.ts +172 -0
- package/dist/parser.js +5 -0
- package/dist/parser.js.map +1 -0
- package/dist/runtime.cjs +14 -0
- package/dist/runtime.cjs.map +1 -0
- package/dist/runtime.d.cts +200 -0
- package/dist/runtime.d.ts +200 -0
- package/dist/runtime.js +5 -0
- package/dist/runtime.js.map +1 -0
- package/dist/type-checker.cjs +17 -0
- package/dist/type-checker.cjs.map +1 -0
- package/dist/type-checker.d.cts +105 -0
- package/dist/type-checker.d.ts +105 -0
- package/dist/type-checker.js +4 -0
- package/dist/type-checker.js.map +1 -0
- package/dist/types-4h8cbtF_.d.cts +329 -0
- package/dist/types-4h8cbtF_.d.ts +329 -0
- package/package.json +17 -13
- package/src/HoloScript2DParser.js +0 -227
- package/src/HoloScript2DParser.ts +0 -261
- package/src/HoloScriptCodeParser.js +0 -1102
- package/src/HoloScriptCodeParser.ts +0 -1188
- package/src/HoloScriptDebugger.js +0 -458
- package/src/HoloScriptParser.js +0 -338
- package/src/HoloScriptParser.ts +0 -397
- package/src/HoloScriptPlusParser.js +0 -371
- package/src/HoloScriptPlusParser.ts +0 -543
- package/src/HoloScriptRuntime.js +0 -1399
- package/src/HoloScriptRuntime.test.js +0 -351
- package/src/HoloScriptRuntime.test.ts +0 -436
- package/src/HoloScriptRuntime.ts +0 -1653
- package/src/HoloScriptTypeChecker.js +0 -356
- package/src/HoloScriptTypeChecker.ts +0 -475
- package/src/__tests__/GraphicsServices.test.js +0 -357
- package/src/__tests__/GraphicsServices.test.ts +0 -427
- package/src/__tests__/HoloScriptPlusParser.test.js +0 -317
- package/src/__tests__/HoloScriptPlusParser.test.ts +0 -392
- package/src/__tests__/integration.test.js +0 -336
- package/src/__tests__/integration.test.ts +0 -416
- package/src/__tests__/performance.bench.js +0 -218
- package/src/__tests__/performance.bench.ts +0 -262
- package/src/__tests__/type-checker.test.js +0 -60
- package/src/__tests__/type-checker.test.ts +0 -73
- package/src/index.js +0 -217
- package/src/index.ts +0 -426
- package/src/interop/Interoperability.js +0 -413
- package/src/interop/Interoperability.ts +0 -494
- package/src/logger.js +0 -42
- package/src/logger.ts +0 -57
- package/src/parser/EnhancedParser.js +0 -205
- package/src/parser/EnhancedParser.ts +0 -251
- package/src/parser/HoloScriptPlusParser.js +0 -928
- package/src/parser/HoloScriptPlusParser.ts +0 -1089
- package/src/runtime/HoloScriptPlusRuntime.js +0 -674
- package/src/runtime/HoloScriptPlusRuntime.ts +0 -861
- package/src/runtime/PerformanceTelemetry.js +0 -323
- package/src/runtime/PerformanceTelemetry.ts +0 -467
- package/src/runtime/RuntimeOptimization.js +0 -361
- package/src/runtime/RuntimeOptimization.ts +0 -416
- package/src/services/HololandGraphicsPipelineService.js +0 -506
- package/src/services/HololandGraphicsPipelineService.ts +0 -662
- package/src/services/PlatformPerformanceOptimizer.js +0 -356
- package/src/services/PlatformPerformanceOptimizer.ts +0 -503
- package/src/state/ReactiveState.js +0 -427
- package/src/state/ReactiveState.ts +0 -572
- package/src/tools/DeveloperExperience.js +0 -376
- package/src/tools/DeveloperExperience.ts +0 -438
- package/src/traits/AIDriverTrait.js +0 -322
- package/src/traits/AIDriverTrait.test.js +0 -329
- package/src/traits/AIDriverTrait.test.ts +0 -357
- package/src/traits/AIDriverTrait.ts +0 -474
- package/src/traits/LightingTrait.js +0 -313
- package/src/traits/LightingTrait.test.js +0 -410
- package/src/traits/LightingTrait.test.ts +0 -462
- package/src/traits/LightingTrait.ts +0 -505
- package/src/traits/MaterialTrait.js +0 -194
- package/src/traits/MaterialTrait.test.js +0 -286
- package/src/traits/MaterialTrait.test.ts +0 -329
- package/src/traits/MaterialTrait.ts +0 -324
- package/src/traits/RenderingTrait.js +0 -356
- package/src/traits/RenderingTrait.test.js +0 -363
- package/src/traits/RenderingTrait.test.ts +0 -427
- package/src/traits/RenderingTrait.ts +0 -555
- package/src/traits/VRTraitSystem.js +0 -740
- package/src/traits/VRTraitSystem.ts +0 -1040
- package/src/traits/VoiceInputTrait.js +0 -284
- package/src/traits/VoiceInputTrait.test.js +0 -226
- package/src/traits/VoiceInputTrait.test.ts +0 -252
- package/src/traits/VoiceInputTrait.ts +0 -401
- package/src/types/AdvancedTypeSystem.js +0 -226
- package/src/types/AdvancedTypeSystem.ts +0 -494
- package/src/types/HoloScriptPlus.d.ts +0 -853
- package/src/types.js +0 -6
- package/src/types.ts +0 -369
- package/tsconfig.json +0 -23
- package/tsup.config.d.ts +0 -2
- package/tsup.config.js +0 -18
- package/tsup.config.ts +0 -19
|
@@ -1,392 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HoloScriptPlus Parser Tests
|
|
3
|
-
*
|
|
4
|
-
* Tests for trait annotation parsing and validation
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { describe, it, expect, beforeEach } from 'vitest';
|
|
8
|
-
import { HoloScriptPlusParser } from '../HoloScriptPlusParser';
|
|
9
|
-
|
|
10
|
-
describe('HoloScriptPlusParser', () => {
|
|
11
|
-
let parser: HoloScriptPlusParser;
|
|
12
|
-
|
|
13
|
-
beforeEach(() => {
|
|
14
|
-
parser = new HoloScriptPlusParser();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
// ========================================================================
|
|
18
|
-
// Material Trait Tests
|
|
19
|
-
// ========================================================================
|
|
20
|
-
|
|
21
|
-
describe('Material Trait Annotations', () => {
|
|
22
|
-
it('should parse material trait annotation', () => {
|
|
23
|
-
const code = `
|
|
24
|
-
orb#sphere {
|
|
25
|
-
@material { type: pbr }
|
|
26
|
-
}
|
|
27
|
-
`;
|
|
28
|
-
|
|
29
|
-
const traits = parser.extractTraitAnnotations(code);
|
|
30
|
-
expect(traits).toHaveLength(1);
|
|
31
|
-
expect(traits[0].type).toBe('material');
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('should parse material with basic properties', () => {
|
|
35
|
-
const code = `@material { type: pbr }`;
|
|
36
|
-
const traits = parser.extractTraitAnnotations(code);
|
|
37
|
-
|
|
38
|
-
expect(traits[0].config.type).toBe('pbr');
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('should parse material with textures', () => {
|
|
42
|
-
const code = `@material { textures: [{ path: diffuse.jpg, channel: baseColor }] }`;
|
|
43
|
-
const traits = parser.extractTraitAnnotations(code);
|
|
44
|
-
|
|
45
|
-
expect(traits[0].config.textures).toBeDefined();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('should parse material compression option', () => {
|
|
49
|
-
const code = `@material { compression: basis }`;
|
|
50
|
-
const traits = parser.extractTraitAnnotations(code);
|
|
51
|
-
|
|
52
|
-
expect(traits[0].config.compression).toBe('basis');
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('should validate material trait', () => {
|
|
56
|
-
const trait = {
|
|
57
|
-
type: 'material' as const,
|
|
58
|
-
config: { pbr: { metallic: 0.5, roughness: 0.3 } },
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const validation = parser.validateTraitAnnotation(trait as any);
|
|
62
|
-
expect(validation.valid).toBe(true);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('should reject invalid metallic value', () => {
|
|
66
|
-
const trait = {
|
|
67
|
-
type: 'material' as const,
|
|
68
|
-
config: { pbr: { metallic: 1.5 } },
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const validation = parser.validateTraitAnnotation(trait as any);
|
|
72
|
-
expect(validation.valid).toBe(false);
|
|
73
|
-
expect(validation.errors.length).toBeGreaterThan(0);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('should reject invalid compression format', () => {
|
|
77
|
-
const trait = {
|
|
78
|
-
type: 'material' as const,
|
|
79
|
-
config: { compression: 'invalid' },
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const validation = parser.validateTraitAnnotation(trait as any);
|
|
83
|
-
expect(validation.valid).toBe(false);
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
// ========================================================================
|
|
88
|
-
// Lighting Trait Tests
|
|
89
|
-
// ========================================================================
|
|
90
|
-
|
|
91
|
-
describe('Lighting Trait Annotations', () => {
|
|
92
|
-
it('should parse lighting trait annotation', () => {
|
|
93
|
-
const code = `
|
|
94
|
-
@lighting { preset: studio, shadows: true }
|
|
95
|
-
`;
|
|
96
|
-
|
|
97
|
-
const traits = parser.extractTraitAnnotations(code);
|
|
98
|
-
expect(traits).toHaveLength(1);
|
|
99
|
-
expect(traits[0].type).toBe('lighting');
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('should parse lighting with preset', () => {
|
|
103
|
-
const code = `@lighting { preset: outdoor }`;
|
|
104
|
-
const traits = parser.extractTraitAnnotations(code);
|
|
105
|
-
|
|
106
|
-
expect(traits[0].config.preset).toBe('outdoor');
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it('should parse lighting with lights', () => {
|
|
110
|
-
const code = `@lighting { lights: [{ type: directional, intensity: 1.2 }] }`;
|
|
111
|
-
const traits = parser.extractTraitAnnotations(code);
|
|
112
|
-
|
|
113
|
-
expect(traits[0].config.lights).toBeDefined();
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it('should validate lighting trait', () => {
|
|
117
|
-
const trait = {
|
|
118
|
-
type: 'lighting' as const,
|
|
119
|
-
config: { preset: 'studio' },
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
const validation = parser.validateTraitAnnotation(trait as any);
|
|
123
|
-
expect(validation.valid).toBe(true);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it('should reject invalid preset', () => {
|
|
127
|
-
const trait = {
|
|
128
|
-
type: 'lighting' as const,
|
|
129
|
-
config: { preset: 'invalid' },
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
const validation = parser.validateTraitAnnotation(trait as any);
|
|
133
|
-
expect(validation.valid).toBe(false);
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it('should reject light with negative intensity', () => {
|
|
137
|
-
const trait = {
|
|
138
|
-
type: 'lighting' as const,
|
|
139
|
-
config: { lights: [{ type: 'point', intensity: -0.5 }] },
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
const validation = parser.validateTraitAnnotation(trait as any);
|
|
143
|
-
expect(validation.valid).toBe(false);
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
// ========================================================================
|
|
148
|
-
// Rendering Trait Tests
|
|
149
|
-
// ========================================================================
|
|
150
|
-
|
|
151
|
-
describe('Rendering Trait Annotations', () => {
|
|
152
|
-
it('should parse rendering trait annotation', () => {
|
|
153
|
-
const code = `
|
|
154
|
-
@rendering { quality: high, lod: true, culling: true }
|
|
155
|
-
`;
|
|
156
|
-
|
|
157
|
-
const traits = parser.extractTraitAnnotations(code);
|
|
158
|
-
expect(traits).toHaveLength(1);
|
|
159
|
-
expect(traits[0].type).toBe('rendering');
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
it('should parse rendering with quality preset', () => {
|
|
163
|
-
const code = `@rendering { quality: ultra }`;
|
|
164
|
-
const traits = parser.extractTraitAnnotations(code);
|
|
165
|
-
|
|
166
|
-
expect(traits[0].config.quality).toBe('ultra');
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it('should parse rendering with platform optimization', () => {
|
|
170
|
-
const code = `@rendering { platform: mobile, quality: low }`;
|
|
171
|
-
const traits = parser.extractTraitAnnotations(code);
|
|
172
|
-
|
|
173
|
-
expect(traits[0].config.platform).toBe('mobile');
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
it('should validate rendering trait', () => {
|
|
177
|
-
const trait = {
|
|
178
|
-
type: 'rendering' as const,
|
|
179
|
-
config: { quality: 'high', platform: 'desktop' },
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
const validation = parser.validateTraitAnnotation(trait as any);
|
|
183
|
-
expect(validation.valid).toBe(true);
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
it('should reject invalid quality preset', () => {
|
|
187
|
-
const trait = {
|
|
188
|
-
type: 'rendering' as const,
|
|
189
|
-
config: { quality: 'invalid' },
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
const validation = parser.validateTraitAnnotation(trait as any);
|
|
193
|
-
expect(validation.valid).toBe(false);
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
it('should reject invalid platform', () => {
|
|
197
|
-
const trait = {
|
|
198
|
-
type: 'rendering' as const,
|
|
199
|
-
config: { platform: 'console' },
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
const validation = parser.validateTraitAnnotation(trait as any);
|
|
203
|
-
expect(validation.valid).toBe(false);
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
it('should reject invalid FPS target', () => {
|
|
207
|
-
const trait = {
|
|
208
|
-
type: 'rendering' as const,
|
|
209
|
-
config: { targetFPS: 500 },
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
const validation = parser.validateTraitAnnotation(trait as any);
|
|
213
|
-
expect(validation.valid).toBe(false);
|
|
214
|
-
});
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
// ========================================================================
|
|
218
|
-
// Combined Trait Tests
|
|
219
|
-
// ========================================================================
|
|
220
|
-
|
|
221
|
-
describe('Combined Trait Annotations', () => {
|
|
222
|
-
it('should parse multiple traits on single orb', () => {
|
|
223
|
-
const code = `
|
|
224
|
-
orb#sphere {
|
|
225
|
-
@material { type: pbr, metallic: 0.5 }
|
|
226
|
-
@lighting { preset: studio }
|
|
227
|
-
@rendering { quality: high }
|
|
228
|
-
}
|
|
229
|
-
`;
|
|
230
|
-
|
|
231
|
-
const traits = parser.extractTraitAnnotations(code);
|
|
232
|
-
expect(traits).toHaveLength(3);
|
|
233
|
-
expect(traits.map((t) => t.type).sort()).toEqual(['lighting', 'material', 'rendering']);
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
it('should build graphics configuration from traits', () => {
|
|
237
|
-
const traits = [
|
|
238
|
-
{
|
|
239
|
-
type: 'material' as const,
|
|
240
|
-
config: { type: 'pbr', pbr: { metallic: 0.5 } },
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
type: 'lighting' as const,
|
|
244
|
-
config: { preset: 'studio' },
|
|
245
|
-
},
|
|
246
|
-
{
|
|
247
|
-
type: 'rendering' as const,
|
|
248
|
-
config: { quality: 'high' },
|
|
249
|
-
},
|
|
250
|
-
];
|
|
251
|
-
|
|
252
|
-
const config = parser.buildGraphicsConfig(traits as any);
|
|
253
|
-
|
|
254
|
-
expect(config.material).toBeDefined();
|
|
255
|
-
expect(config.lighting).toBeDefined();
|
|
256
|
-
expect(config.rendering).toBeDefined();
|
|
257
|
-
});
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
// ========================================================================
|
|
261
|
-
// Object Literal Parsing Tests
|
|
262
|
-
// ========================================================================
|
|
263
|
-
|
|
264
|
-
describe('Object Literal Parsing', () => {
|
|
265
|
-
it.skip('should parse simple key-value pairs', () => {
|
|
266
|
-
const result = parser.parseObjectLiteral('type: pbr');
|
|
267
|
-
expect(result.type).toBe('pbr');
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
it.skip('should parse boolean values', () => {
|
|
271
|
-
const result = parser.parseObjectLiteral('shadows: true');
|
|
272
|
-
expect(result.shadows).toBe(true);
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
it.skip('should parse numeric values', () => {
|
|
276
|
-
const result = parser.parseObjectLiteral('targetFPS: 120');
|
|
277
|
-
expect(result.targetFPS).toBe(120);
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
it.skip('should parse string values', () => {
|
|
281
|
-
const result = parser.parseObjectLiteral('compression: basis');
|
|
282
|
-
expect(result.compression).toBe('basis');
|
|
283
|
-
});
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
// ========================================================================
|
|
287
|
-
// Value Parsing Tests
|
|
288
|
-
// ========================================================================
|
|
289
|
-
|
|
290
|
-
describe('Value Parsing', () => {
|
|
291
|
-
it('should parse boolean true', () => {
|
|
292
|
-
const value = parser.parseValue('true');
|
|
293
|
-
expect(value).toBe(true);
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
it('should parse boolean false', () => {
|
|
297
|
-
const value = parser.parseValue('false');
|
|
298
|
-
expect(value).toBe(false);
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
it('should parse positive integer', () => {
|
|
302
|
-
const value = parser.parseValue('120');
|
|
303
|
-
expect(value).toBe(120);
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
it('should parse decimal number', () => {
|
|
307
|
-
const value = parser.parseValue('0.5');
|
|
308
|
-
expect(value).toBe(0.5);
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
it('should parse negative number', () => {
|
|
312
|
-
const value = parser.parseValue('-5.5');
|
|
313
|
-
expect(value).toBe(-5.5);
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
it('should parse quoted string', () => {
|
|
317
|
-
const value = parser.parseValue('"pbr"');
|
|
318
|
-
expect(value).toBe('pbr');
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
it('should parse single-quoted string', () => {
|
|
322
|
-
const value = parser.parseValue("'studio'");
|
|
323
|
-
expect(value).toBe('studio');
|
|
324
|
-
});
|
|
325
|
-
});;
|
|
326
|
-
|
|
327
|
-
// ========================================================================
|
|
328
|
-
// Enhanced Orb Node Tests
|
|
329
|
-
// ========================================================================
|
|
330
|
-
|
|
331
|
-
describe('Enhanced OrbNode with Graphics Traits', () => {
|
|
332
|
-
it('should extract graphics traits from code', () => {
|
|
333
|
-
const code = `
|
|
334
|
-
orb#sphere {
|
|
335
|
-
@material { type: pbr, metallic: 0.5 }
|
|
336
|
-
@lighting { preset: studio }
|
|
337
|
-
}
|
|
338
|
-
`;
|
|
339
|
-
|
|
340
|
-
const traits = parser.extractTraitAnnotations(code);
|
|
341
|
-
expect(traits).toHaveLength(2);
|
|
342
|
-
expect(traits[0].type).toBe('material');
|
|
343
|
-
expect(traits[1].type).toBe('lighting');
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
it('should create material trait from config', () => {
|
|
347
|
-
const code = `@material { type: pbr, metallic: 0.5, compression: basis }`;
|
|
348
|
-
|
|
349
|
-
const traits = parser.extractTraitAnnotations(code);
|
|
350
|
-
expect(traits).toHaveLength(1);
|
|
351
|
-
expect(traits[0].config.type).toBe('pbr');
|
|
352
|
-
});
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
// ========================================================================
|
|
356
|
-
// Edge Cases and Error Handling
|
|
357
|
-
// ========================================================================
|
|
358
|
-
|
|
359
|
-
describe('Edge Cases and Error Handling', () => {
|
|
360
|
-
it('should handle empty trait annotation gracefully', () => {
|
|
361
|
-
const code = `@material {}`;
|
|
362
|
-
const traits = parser.extractTraitAnnotations(code);
|
|
363
|
-
expect(traits).toHaveLength(1);
|
|
364
|
-
expect(traits[0].config).toBeDefined();
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
it('should handle malformed JSON gracefully', () => {
|
|
368
|
-
const code = `@material { invalid json }`;
|
|
369
|
-
const traits = parser.extractTraitAnnotations(code);
|
|
370
|
-
// Parser should attempt to parse and return best effort result
|
|
371
|
-
expect(traits.length).toBeGreaterThanOrEqual(0);
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
it('should ignore invalid trait types', () => {
|
|
375
|
-
const code = `@invalid { type: something }`;
|
|
376
|
-
const traits = parser.extractTraitAnnotations(code);
|
|
377
|
-
// Should not include invalid trait type
|
|
378
|
-
expect(traits.every((t) => ['material', 'lighting', 'rendering'].includes(t.type))).toBe(true);
|
|
379
|
-
});
|
|
380
|
-
|
|
381
|
-
it('should handle multiple orbs with different traits', () => {
|
|
382
|
-
const code = `
|
|
383
|
-
orb#sphere1 { @material { metallic: 0.5 } }
|
|
384
|
-
orb#sphere2 { @lighting { preset: studio } }
|
|
385
|
-
orb#sphere3 { @rendering { quality: high } }
|
|
386
|
-
`;
|
|
387
|
-
|
|
388
|
-
const traits = parser.extractTraitAnnotations(code);
|
|
389
|
-
expect(traits).toHaveLength(3);
|
|
390
|
-
});
|
|
391
|
-
});
|
|
392
|
-
});
|