@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.
Files changed (137) hide show
  1. package/dist/chunk-2XXE34KS.js +344 -0
  2. package/dist/chunk-2XXE34KS.js.map +1 -0
  3. package/dist/chunk-3X2EGU7Z.cjs +52 -0
  4. package/dist/chunk-3X2EGU7Z.cjs.map +1 -0
  5. package/dist/chunk-AFFVFO4D.js +1689 -0
  6. package/dist/chunk-AFFVFO4D.js.map +1 -0
  7. package/dist/chunk-DGUM43GV.js +10 -0
  8. package/dist/chunk-DGUM43GV.js.map +1 -0
  9. package/{src/HoloScriptDebugger.ts → dist/chunk-DOY73HDH.js} +118 -257
  10. package/dist/chunk-DOY73HDH.js.map +1 -0
  11. package/dist/chunk-JEQ2X3Z6.cjs +12 -0
  12. package/dist/chunk-JEQ2X3Z6.cjs.map +1 -0
  13. package/dist/chunk-L6VLNVKP.cjs +1691 -0
  14. package/dist/chunk-L6VLNVKP.cjs.map +1 -0
  15. package/dist/chunk-MFNO57XL.cjs +347 -0
  16. package/dist/chunk-MFNO57XL.cjs.map +1 -0
  17. package/dist/chunk-R75MREOS.cjs +424 -0
  18. package/dist/chunk-R75MREOS.cjs.map +1 -0
  19. package/dist/chunk-SATNCODL.js +45 -0
  20. package/dist/chunk-SATNCODL.js.map +1 -0
  21. package/dist/chunk-T57ZL7KR.cjs +1281 -0
  22. package/dist/chunk-T57ZL7KR.cjs.map +1 -0
  23. package/dist/chunk-U72GEJZT.js +1279 -0
  24. package/dist/chunk-U72GEJZT.js.map +1 -0
  25. package/dist/debugger.cjs +20 -0
  26. package/dist/debugger.cjs.map +1 -0
  27. package/dist/debugger.d.cts +171 -0
  28. package/dist/debugger.d.ts +171 -0
  29. package/dist/debugger.js +7 -0
  30. package/dist/debugger.js.map +1 -0
  31. package/dist/index.cjs +6803 -0
  32. package/dist/index.cjs.map +1 -0
  33. package/dist/index.d.cts +4093 -0
  34. package/dist/index.d.ts +4093 -0
  35. package/dist/index.js +6715 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/parser.cjs +14 -0
  38. package/dist/parser.cjs.map +1 -0
  39. package/dist/parser.d.cts +172 -0
  40. package/dist/parser.d.ts +172 -0
  41. package/dist/parser.js +5 -0
  42. package/dist/parser.js.map +1 -0
  43. package/dist/runtime.cjs +14 -0
  44. package/dist/runtime.cjs.map +1 -0
  45. package/dist/runtime.d.cts +200 -0
  46. package/dist/runtime.d.ts +200 -0
  47. package/dist/runtime.js +5 -0
  48. package/dist/runtime.js.map +1 -0
  49. package/dist/type-checker.cjs +17 -0
  50. package/dist/type-checker.cjs.map +1 -0
  51. package/dist/type-checker.d.cts +105 -0
  52. package/dist/type-checker.d.ts +105 -0
  53. package/dist/type-checker.js +4 -0
  54. package/dist/type-checker.js.map +1 -0
  55. package/dist/types-4h8cbtF_.d.cts +329 -0
  56. package/dist/types-4h8cbtF_.d.ts +329 -0
  57. package/package.json +17 -13
  58. package/src/HoloScript2DParser.js +0 -227
  59. package/src/HoloScript2DParser.ts +0 -261
  60. package/src/HoloScriptCodeParser.js +0 -1102
  61. package/src/HoloScriptCodeParser.ts +0 -1188
  62. package/src/HoloScriptDebugger.js +0 -458
  63. package/src/HoloScriptParser.js +0 -338
  64. package/src/HoloScriptParser.ts +0 -397
  65. package/src/HoloScriptPlusParser.js +0 -371
  66. package/src/HoloScriptPlusParser.ts +0 -543
  67. package/src/HoloScriptRuntime.js +0 -1399
  68. package/src/HoloScriptRuntime.test.js +0 -351
  69. package/src/HoloScriptRuntime.test.ts +0 -436
  70. package/src/HoloScriptRuntime.ts +0 -1653
  71. package/src/HoloScriptTypeChecker.js +0 -356
  72. package/src/HoloScriptTypeChecker.ts +0 -475
  73. package/src/__tests__/GraphicsServices.test.js +0 -357
  74. package/src/__tests__/GraphicsServices.test.ts +0 -427
  75. package/src/__tests__/HoloScriptPlusParser.test.js +0 -317
  76. package/src/__tests__/HoloScriptPlusParser.test.ts +0 -392
  77. package/src/__tests__/integration.test.js +0 -336
  78. package/src/__tests__/integration.test.ts +0 -416
  79. package/src/__tests__/performance.bench.js +0 -218
  80. package/src/__tests__/performance.bench.ts +0 -262
  81. package/src/__tests__/type-checker.test.js +0 -60
  82. package/src/__tests__/type-checker.test.ts +0 -73
  83. package/src/index.js +0 -217
  84. package/src/index.ts +0 -426
  85. package/src/interop/Interoperability.js +0 -413
  86. package/src/interop/Interoperability.ts +0 -494
  87. package/src/logger.js +0 -42
  88. package/src/logger.ts +0 -57
  89. package/src/parser/EnhancedParser.js +0 -205
  90. package/src/parser/EnhancedParser.ts +0 -251
  91. package/src/parser/HoloScriptPlusParser.js +0 -928
  92. package/src/parser/HoloScriptPlusParser.ts +0 -1089
  93. package/src/runtime/HoloScriptPlusRuntime.js +0 -674
  94. package/src/runtime/HoloScriptPlusRuntime.ts +0 -861
  95. package/src/runtime/PerformanceTelemetry.js +0 -323
  96. package/src/runtime/PerformanceTelemetry.ts +0 -467
  97. package/src/runtime/RuntimeOptimization.js +0 -361
  98. package/src/runtime/RuntimeOptimization.ts +0 -416
  99. package/src/services/HololandGraphicsPipelineService.js +0 -506
  100. package/src/services/HololandGraphicsPipelineService.ts +0 -662
  101. package/src/services/PlatformPerformanceOptimizer.js +0 -356
  102. package/src/services/PlatformPerformanceOptimizer.ts +0 -503
  103. package/src/state/ReactiveState.js +0 -427
  104. package/src/state/ReactiveState.ts +0 -572
  105. package/src/tools/DeveloperExperience.js +0 -376
  106. package/src/tools/DeveloperExperience.ts +0 -438
  107. package/src/traits/AIDriverTrait.js +0 -322
  108. package/src/traits/AIDriverTrait.test.js +0 -329
  109. package/src/traits/AIDriverTrait.test.ts +0 -357
  110. package/src/traits/AIDriverTrait.ts +0 -474
  111. package/src/traits/LightingTrait.js +0 -313
  112. package/src/traits/LightingTrait.test.js +0 -410
  113. package/src/traits/LightingTrait.test.ts +0 -462
  114. package/src/traits/LightingTrait.ts +0 -505
  115. package/src/traits/MaterialTrait.js +0 -194
  116. package/src/traits/MaterialTrait.test.js +0 -286
  117. package/src/traits/MaterialTrait.test.ts +0 -329
  118. package/src/traits/MaterialTrait.ts +0 -324
  119. package/src/traits/RenderingTrait.js +0 -356
  120. package/src/traits/RenderingTrait.test.js +0 -363
  121. package/src/traits/RenderingTrait.test.ts +0 -427
  122. package/src/traits/RenderingTrait.ts +0 -555
  123. package/src/traits/VRTraitSystem.js +0 -740
  124. package/src/traits/VRTraitSystem.ts +0 -1040
  125. package/src/traits/VoiceInputTrait.js +0 -284
  126. package/src/traits/VoiceInputTrait.test.js +0 -226
  127. package/src/traits/VoiceInputTrait.test.ts +0 -252
  128. package/src/traits/VoiceInputTrait.ts +0 -401
  129. package/src/types/AdvancedTypeSystem.js +0 -226
  130. package/src/types/AdvancedTypeSystem.ts +0 -494
  131. package/src/types/HoloScriptPlus.d.ts +0 -853
  132. package/src/types.js +0 -6
  133. package/src/types.ts +0 -369
  134. package/tsconfig.json +0 -23
  135. package/tsup.config.d.ts +0 -2
  136. package/tsup.config.js +0 -18
  137. package/tsup.config.ts +0 -19
@@ -1,356 +0,0 @@
1
- /**
2
- * HoloScript Type Checker
3
- *
4
- * Static type analysis for HoloScript code.
5
- * Validates types, detects errors, and provides type information.
6
- */
7
- // Built-in type definitions
8
- const BUILTIN_FUNCTIONS = new Map([
9
- ['add', { type: 'function', parameters: [{ name: 'a', type: 'number' }, { name: 'b', type: 'number' }], returnType: 'number' }],
10
- ['subtract', { type: 'function', parameters: [{ name: 'a', type: 'number' }, { name: 'b', type: 'number' }], returnType: 'number' }],
11
- ['multiply', { type: 'function', parameters: [{ name: 'a', type: 'number' }, { name: 'b', type: 'number' }], returnType: 'number' }],
12
- ['divide', { type: 'function', parameters: [{ name: 'a', type: 'number' }, { name: 'b', type: 'number' }], returnType: 'number' }],
13
- ['concat', { type: 'function', parameters: [{ name: 'a', type: 'string' }, { name: 'b', type: 'string' }], returnType: 'string' }],
14
- ['length', { type: 'function', parameters: [{ name: 'value', type: 'any' }], returnType: 'number' }],
15
- ['push', { type: 'function', parameters: [{ name: 'arr', type: 'array' }, { name: 'item', type: 'any' }], returnType: 'array' }],
16
- ['pop', { type: 'function', parameters: [{ name: 'arr', type: 'array' }], returnType: 'any' }],
17
- ['log', { type: 'function', parameters: [{ name: 'message', type: 'any' }], returnType: 'void' }],
18
- ['print', { type: 'function', parameters: [{ name: 'message', type: 'any' }], returnType: 'void' }],
19
- ['show', { type: 'function', parameters: [{ name: 'target', type: 'orb' }], returnType: 'void' }],
20
- ['hide', { type: 'function', parameters: [{ name: 'target', type: 'orb' }], returnType: 'void' }],
21
- ['pulse', { type: 'function', parameters: [{ name: 'target', type: 'orb' }], returnType: 'void' }],
22
- ['animate', { type: 'function', parameters: [{ name: 'target', type: 'orb' }, { name: 'config', type: 'object' }], returnType: 'void' }],
23
- ['spawn', { type: 'function', parameters: [{ name: 'type', type: 'string' }, { name: 'position', type: 'object' }], returnType: 'orb' }],
24
- ['isNumber', { type: 'function', parameters: [{ name: 'value', type: 'any' }], returnType: 'boolean' }],
25
- ['isString', { type: 'function', parameters: [{ name: 'value', type: 'any' }], returnType: 'boolean' }],
26
- ['isArray', { type: 'function', parameters: [{ name: 'value', type: 'any' }], returnType: 'boolean' }],
27
- ]);
28
- export class HoloScriptTypeChecker {
29
- constructor() {
30
- this.typeMap = new Map();
31
- this.diagnostics = [];
32
- this.currentLine = 0;
33
- this.currentColumn = 0;
34
- // Initialize with built-in functions
35
- BUILTIN_FUNCTIONS.forEach((type, name) => {
36
- this.typeMap.set(name, type);
37
- });
38
- }
39
- /**
40
- * Type check an AST
41
- */
42
- check(ast) {
43
- this.diagnostics = [];
44
- // First pass: collect declarations
45
- for (const node of ast) {
46
- this.collectDeclaration(node);
47
- }
48
- // Second pass: validate types
49
- for (const node of ast) {
50
- this.checkNode(node);
51
- }
52
- return {
53
- valid: this.diagnostics.filter(d => d.severity === 'error').length === 0,
54
- diagnostics: this.diagnostics,
55
- typeMap: new Map(this.typeMap),
56
- };
57
- }
58
- /**
59
- * Collect type declarations
60
- */
61
- collectDeclaration(node) {
62
- switch (node.type) {
63
- case 'orb':
64
- this.collectOrbDeclaration(node);
65
- break;
66
- case 'method':
67
- this.collectMethodDeclaration(node);
68
- break;
69
- case 'variable-declaration':
70
- this.collectVariableDeclaration(node);
71
- break;
72
- case 'stream':
73
- this.collectStreamDeclaration(node);
74
- break;
75
- }
76
- }
77
- collectOrbDeclaration(node) {
78
- const properties = new Map();
79
- // Add default orb properties
80
- properties.set('position', { type: 'object', properties: new Map([
81
- ['x', { type: 'number' }],
82
- ['y', { type: 'number' }],
83
- ['z', { type: 'number' }],
84
- ]) });
85
- properties.set('color', { type: 'string' });
86
- properties.set('glow', { type: 'boolean' });
87
- properties.set('interactive', { type: 'boolean' });
88
- properties.set('visible', { type: 'boolean' });
89
- // Add user-defined properties
90
- for (const [key, value] of Object.entries(node.properties)) {
91
- properties.set(key, this.inferType(value));
92
- }
93
- this.typeMap.set(node.name, {
94
- type: 'orb',
95
- properties,
96
- });
97
- }
98
- collectMethodDeclaration(node) {
99
- const parameters = node.parameters.map(p => ({
100
- name: p.name,
101
- type: this.parseTypeString(p.dataType),
102
- optional: p.defaultValue !== undefined,
103
- defaultValue: p.defaultValue,
104
- }));
105
- this.typeMap.set(node.name, {
106
- type: 'function',
107
- parameters,
108
- returnType: node.returnType ? this.parseTypeString(node.returnType) : 'void',
109
- });
110
- }
111
- collectVariableDeclaration(node) {
112
- let type = 'any';
113
- if (node.dataType) {
114
- type = this.parseTypeString(node.dataType);
115
- }
116
- else if (node.value !== undefined) {
117
- type = this.inferType(node.value).type;
118
- }
119
- this.typeMap.set(node.name, { type });
120
- }
121
- collectStreamDeclaration(node) {
122
- this.typeMap.set(node.name, {
123
- type: 'stream',
124
- properties: new Map([
125
- ['source', { type: 'string' }],
126
- ['result', { type: 'any' }],
127
- ]),
128
- });
129
- }
130
- /**
131
- * Check a node for type errors
132
- */
133
- checkNode(node) {
134
- this.currentLine = node.position?.x ?? 0;
135
- this.currentColumn = node.position?.y ?? 0;
136
- switch (node.type) {
137
- case 'connection':
138
- this.checkConnection(node);
139
- break;
140
- case 'gate':
141
- this.checkGate(node);
142
- break;
143
- case 'for-loop':
144
- this.checkForLoop(node);
145
- break;
146
- case 'while-loop':
147
- this.checkWhileLoop(node);
148
- break;
149
- case 'foreach-loop':
150
- this.checkForEachLoop(node);
151
- break;
152
- case 'import':
153
- this.checkImport(node);
154
- break;
155
- case 'export':
156
- this.checkExport(node);
157
- break;
158
- }
159
- }
160
- checkConnection(node) {
161
- const fromType = this.typeMap.get(node.from);
162
- const toType = this.typeMap.get(node.to);
163
- if (!fromType) {
164
- this.addDiagnostic('error', `Unknown source '${node.from}' in connection`, 'E001');
165
- }
166
- if (!toType) {
167
- this.addDiagnostic('error', `Unknown target '${node.to}' in connection`, 'E002');
168
- }
169
- // Check if types are compatible
170
- if (fromType && toType && node.dataType !== 'any') {
171
- // Warn if connecting incompatible types
172
- if (fromType.type !== toType.type && fromType.type !== 'any' && toType.type !== 'any') {
173
- this.addDiagnostic('warning', `Connection from '${node.from}' (${fromType.type}) to '${node.to}' (${toType.type}) may be incompatible`, 'W001', [`Consider using 'as "any"' to bypass type checking`]);
174
- }
175
- }
176
- }
177
- checkGate(node) {
178
- // Validate condition references valid variables
179
- const conditionVars = this.extractVariables(node.condition);
180
- for (const varName of conditionVars) {
181
- if (!this.typeMap.has(varName) && !this.isLiteral(varName)) {
182
- this.addDiagnostic('error', `Unknown variable '${varName}' in gate condition`, 'E003');
183
- }
184
- }
185
- }
186
- checkForLoop(node) {
187
- // Check init references
188
- const initVars = this.extractVariables(node.init);
189
- // For loops can declare new variables in init, so we add them
190
- for (const varName of initVars) {
191
- if (!this.typeMap.has(varName)) {
192
- this.typeMap.set(varName, { type: 'number' }); // Loop vars are typically numbers
193
- }
194
- }
195
- // Check condition
196
- const condVars = this.extractVariables(node.condition);
197
- for (const varName of condVars) {
198
- if (!this.typeMap.has(varName) && !this.isLiteral(varName)) {
199
- this.addDiagnostic('error', `Unknown variable '${varName}' in for loop condition`, 'E004');
200
- }
201
- }
202
- }
203
- checkWhileLoop(node) {
204
- const condVars = this.extractVariables(node.condition);
205
- for (const varName of condVars) {
206
- if (!this.typeMap.has(varName) && !this.isLiteral(varName)) {
207
- this.addDiagnostic('error', `Unknown variable '${varName}' in while loop condition`, 'E005');
208
- }
209
- }
210
- }
211
- checkForEachLoop(node) {
212
- // Check collection exists
213
- if (!this.typeMap.has(node.collection)) {
214
- this.addDiagnostic('error', `Unknown collection '${node.collection}' in forEach loop`, 'E006');
215
- }
216
- else {
217
- const collectionType = this.typeMap.get(node.collection);
218
- if (collectionType && collectionType.type !== 'array' && collectionType.type !== 'any') {
219
- this.addDiagnostic('error', `'${node.collection}' is not iterable (type: ${collectionType.type})`, 'E007');
220
- }
221
- }
222
- // Add loop variable to scope
223
- this.typeMap.set(node.variable, { type: 'any' });
224
- }
225
- checkImport(node) {
226
- if (!node.modulePath) {
227
- this.addDiagnostic('error', 'Import statement missing module path', 'E008');
228
- }
229
- // Register imported names as 'any' type (can't resolve external modules)
230
- for (const name of node.imports) {
231
- this.typeMap.set(name, { type: 'any' });
232
- }
233
- if (node.defaultImport) {
234
- this.typeMap.set(node.defaultImport, { type: 'any' });
235
- }
236
- }
237
- checkExport(node) {
238
- if (node.exports) {
239
- for (const name of node.exports) {
240
- if (!this.typeMap.has(name)) {
241
- this.addDiagnostic('error', `Cannot export unknown identifier '${name}'`, 'E009');
242
- }
243
- }
244
- }
245
- }
246
- /**
247
- * Infer type from a value
248
- */
249
- inferType(value) {
250
- if (value === null || value === undefined) {
251
- return { type: 'any', nullable: true };
252
- }
253
- if (typeof value === 'number') {
254
- return { type: 'number' };
255
- }
256
- if (typeof value === 'string') {
257
- return { type: 'string' };
258
- }
259
- if (typeof value === 'boolean') {
260
- return { type: 'boolean' };
261
- }
262
- if (Array.isArray(value)) {
263
- const elementType = value.length > 0 ? this.inferType(value[0]).type : 'any';
264
- return { type: 'array', elementType };
265
- }
266
- if (typeof value === 'object') {
267
- const properties = new Map();
268
- for (const [key, val] of Object.entries(value)) {
269
- properties.set(key, this.inferType(val));
270
- }
271
- return { type: 'object', properties };
272
- }
273
- return { type: 'any' };
274
- }
275
- /**
276
- * Parse type string to HoloScriptType
277
- */
278
- parseTypeString(typeStr) {
279
- const normalized = typeStr.toLowerCase().trim();
280
- const validTypes = [
281
- 'number', 'string', 'boolean', 'array', 'object',
282
- 'function', 'void', 'any', 'unknown', 'never',
283
- 'orb', 'stream', 'connection', 'gate'
284
- ];
285
- if (validTypes.includes(normalized)) {
286
- return normalized;
287
- }
288
- return 'any';
289
- }
290
- /**
291
- * Extract variable names from an expression string
292
- */
293
- extractVariables(expr) {
294
- const varPattern = /\b([a-zA-Z_][a-zA-Z0-9_]*)\b/g;
295
- const matches = expr.match(varPattern) || [];
296
- const keywords = ['true', 'false', 'null', 'undefined', 'if', 'else', 'for', 'while', 'return'];
297
- return matches.filter(m => !keywords.includes(m));
298
- }
299
- /**
300
- * Check if string is a literal
301
- */
302
- isLiteral(str) {
303
- // Number literal
304
- if (/^-?\d+(\.\d+)?$/.test(str))
305
- return true;
306
- // Boolean
307
- if (str === 'true' || str === 'false')
308
- return true;
309
- // String literal
310
- if (/^["'].*["']$/.test(str))
311
- return true;
312
- return false;
313
- }
314
- /**
315
- * Add a diagnostic
316
- */
317
- addDiagnostic(severity, message, code, suggestions) {
318
- this.diagnostics.push({
319
- severity,
320
- message,
321
- line: this.currentLine,
322
- column: this.currentColumn,
323
- code,
324
- suggestions,
325
- });
326
- }
327
- /**
328
- * Get type info for a name
329
- */
330
- getType(name) {
331
- return this.typeMap.get(name);
332
- }
333
- /**
334
- * Get all registered types
335
- */
336
- getAllTypes() {
337
- return new Map(this.typeMap);
338
- }
339
- /**
340
- * Reset the type checker
341
- */
342
- reset() {
343
- this.typeMap.clear();
344
- this.diagnostics = [];
345
- // Re-add built-ins
346
- BUILTIN_FUNCTIONS.forEach((type, name) => {
347
- this.typeMap.set(name, type);
348
- });
349
- }
350
- }
351
- /**
352
- * Create a type checker instance
353
- */
354
- export function createTypeChecker() {
355
- return new HoloScriptTypeChecker();
356
- }