@holoscript/core 2.0.1 → 2.0.2

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/LICENSE +21 -0
  2. package/dist/chunk-3N67RLQP.cjs +1298 -0
  3. package/dist/chunk-3N67RLQP.cjs.map +1 -0
  4. package/dist/chunk-3X2EGU7Z.cjs +52 -0
  5. package/dist/chunk-3X2EGU7Z.cjs.map +1 -0
  6. package/dist/chunk-4CV4JOE5.js +24 -0
  7. package/dist/chunk-4CV4JOE5.js.map +1 -0
  8. package/dist/chunk-4OHVW4XR.cjs +1027 -0
  9. package/dist/chunk-4OHVW4XR.cjs.map +1 -0
  10. package/dist/chunk-CZLDE2OZ.cjs +28 -0
  11. package/dist/chunk-CZLDE2OZ.cjs.map +1 -0
  12. package/{src/HoloScriptRuntime.ts → dist/chunk-EU6CZMGJ.js} +437 -794
  13. package/dist/chunk-EU6CZMGJ.js.map +1 -0
  14. package/dist/chunk-KWYIVRIH.js +344 -0
  15. package/dist/chunk-KWYIVRIH.js.map +1 -0
  16. package/dist/chunk-MCP6D4LT.js +1025 -0
  17. package/dist/chunk-MCP6D4LT.js.map +1 -0
  18. package/dist/chunk-SATNCODL.js +45 -0
  19. package/dist/chunk-SATNCODL.js.map +1 -0
  20. package/dist/chunk-VMZN4EVR.cjs +347 -0
  21. package/dist/chunk-VMZN4EVR.cjs.map +1 -0
  22. package/{src/HoloScriptDebugger.ts → dist/chunk-VYIDLUCV.js} +118 -257
  23. package/dist/chunk-VYIDLUCV.js.map +1 -0
  24. package/dist/chunk-WFI4T3XB.cjs +424 -0
  25. package/dist/chunk-WFI4T3XB.cjs.map +1 -0
  26. package/dist/debugger.cjs +20 -0
  27. package/dist/debugger.cjs.map +1 -0
  28. package/dist/debugger.d.cts +171 -0
  29. package/dist/debugger.d.ts +171 -0
  30. package/dist/debugger.js +7 -0
  31. package/dist/debugger.js.map +1 -0
  32. package/dist/index.cjs +6006 -0
  33. package/dist/index.cjs.map +1 -0
  34. package/dist/index.d.cts +2482 -0
  35. package/dist/index.d.ts +2482 -0
  36. package/dist/index.js +5926 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/parser.cjs +14 -0
  39. package/dist/parser.cjs.map +1 -0
  40. package/dist/parser.d.cts +139 -0
  41. package/dist/parser.d.ts +139 -0
  42. package/dist/parser.js +5 -0
  43. package/dist/parser.js.map +1 -0
  44. package/dist/runtime.cjs +14 -0
  45. package/dist/runtime.cjs.map +1 -0
  46. package/dist/runtime.d.cts +180 -0
  47. package/dist/runtime.d.ts +180 -0
  48. package/dist/runtime.js +5 -0
  49. package/dist/runtime.js.map +1 -0
  50. package/dist/type-checker.cjs +17 -0
  51. package/dist/type-checker.cjs.map +1 -0
  52. package/dist/type-checker.d.cts +105 -0
  53. package/dist/type-checker.d.ts +105 -0
  54. package/dist/type-checker.js +4 -0
  55. package/dist/type-checker.js.map +1 -0
  56. package/dist/types-D6g4ACjP.d.cts +262 -0
  57. package/dist/types-D6g4ACjP.d.ts +262 -0
  58. package/package.json +11 -8
  59. package/src/HoloScript2DParser.js +0 -227
  60. package/src/HoloScript2DParser.ts +0 -261
  61. package/src/HoloScriptCodeParser.js +0 -1102
  62. package/src/HoloScriptCodeParser.ts +0 -1188
  63. package/src/HoloScriptDebugger.js +0 -458
  64. package/src/HoloScriptParser.js +0 -338
  65. package/src/HoloScriptParser.ts +0 -397
  66. package/src/HoloScriptPlusParser.js +0 -371
  67. package/src/HoloScriptPlusParser.ts +0 -543
  68. package/src/HoloScriptRuntime.js +0 -1399
  69. package/src/HoloScriptRuntime.test.js +0 -351
  70. package/src/HoloScriptRuntime.test.ts +0 -436
  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
@@ -0,0 +1,1027 @@
1
+ 'use strict';
2
+
3
+ var chunk3X2EGU7Z_cjs = require('./chunk-3X2EGU7Z.cjs');
4
+
5
+ // src/HoloScriptCodeParser.ts
6
+ var CODE_SECURITY_CONFIG = {
7
+ maxCodeLength: 5e4,
8
+ maxBlocks: 100,
9
+ suspiciousKeywords: [
10
+ "process",
11
+ "require",
12
+ "eval",
13
+ "import",
14
+ "constructor",
15
+ "prototype",
16
+ "__proto__",
17
+ "fs",
18
+ "child_process",
19
+ "exec",
20
+ "spawn"
21
+ ]
22
+ };
23
+ var HoloScriptCodeParser = class {
24
+ constructor() {
25
+ this.errors = [];
26
+ this.warnings = [];
27
+ this.tokens = [];
28
+ this.position = 0;
29
+ this.keywordSet = /* @__PURE__ */ new Set([
30
+ "orb",
31
+ "function",
32
+ "connect",
33
+ "to",
34
+ "as",
35
+ "gate",
36
+ "stream",
37
+ "from",
38
+ "through",
39
+ "return",
40
+ "if",
41
+ "else",
42
+ "nexus",
43
+ "building",
44
+ "pillar",
45
+ "foundation",
46
+ "for",
47
+ "while",
48
+ "forEach",
49
+ "in",
50
+ "of",
51
+ "break",
52
+ "continue",
53
+ "import",
54
+ "export",
55
+ "module",
56
+ "use",
57
+ "type",
58
+ "interface",
59
+ "extends",
60
+ "implements",
61
+ "async",
62
+ "await",
63
+ "spawn",
64
+ "parallel",
65
+ "class",
66
+ "new",
67
+ "this",
68
+ "super",
69
+ "static",
70
+ "private",
71
+ "public",
72
+ "try",
73
+ "catch",
74
+ "finally",
75
+ "throw",
76
+ "const",
77
+ "let",
78
+ "var",
79
+ "animate",
80
+ "modify",
81
+ "pulse",
82
+ "move",
83
+ "show",
84
+ "hide"
85
+ ]);
86
+ }
87
+ /**
88
+ * Parse HoloScript code string into AST
89
+ */
90
+ parse(code) {
91
+ this.errors = [];
92
+ this.warnings = [];
93
+ this.tokens = [];
94
+ this.position = 0;
95
+ if (code.length > CODE_SECURITY_CONFIG.maxCodeLength) {
96
+ return {
97
+ success: false,
98
+ ast: [],
99
+ errors: [{ line: 0, column: 0, message: `Code exceeds max length (${CODE_SECURITY_CONFIG.maxCodeLength})` }],
100
+ warnings: []
101
+ };
102
+ }
103
+ for (const keyword of CODE_SECURITY_CONFIG.suspiciousKeywords) {
104
+ if (code.toLowerCase().includes(keyword)) {
105
+ chunk3X2EGU7Z_cjs.logger.warn("Suspicious keyword detected", { keyword });
106
+ return {
107
+ success: false,
108
+ ast: [],
109
+ errors: [{ line: 0, column: 0, message: `Suspicious keyword detected: ${keyword}` }],
110
+ warnings: []
111
+ };
112
+ }
113
+ }
114
+ try {
115
+ this.tokens = this.tokenize(code);
116
+ const ast = this.parseProgram();
117
+ return {
118
+ success: this.errors.length === 0,
119
+ ast,
120
+ errors: this.errors,
121
+ warnings: this.warnings
122
+ };
123
+ } catch (error) {
124
+ return {
125
+ success: false,
126
+ ast: [],
127
+ errors: [{ line: 0, column: 0, message: String(error) }],
128
+ warnings: this.warnings
129
+ };
130
+ }
131
+ }
132
+ /**
133
+ * Tokenize code into tokens
134
+ */
135
+ tokenize(code) {
136
+ const tokens = [];
137
+ let line = 1;
138
+ let column = 1;
139
+ let i = 0;
140
+ while (i < code.length) {
141
+ const char = code[i];
142
+ if (char === " " || char === " " || char === "\r") {
143
+ i++;
144
+ column++;
145
+ continue;
146
+ }
147
+ if (char === "\n") {
148
+ tokens.push({ type: "newline", value: "\n", line, column });
149
+ line++;
150
+ column = 1;
151
+ i++;
152
+ continue;
153
+ }
154
+ if (char === "/" && code[i + 1] === "/") {
155
+ while (i < code.length && code[i] !== "\n") {
156
+ i++;
157
+ }
158
+ continue;
159
+ }
160
+ if (char === '"' || char === "'") {
161
+ const quote = char;
162
+ let str = "";
163
+ const startCol = column;
164
+ i++;
165
+ column++;
166
+ while (i < code.length && code[i] !== quote) {
167
+ if (code[i] === "\\" && i + 1 < code.length) {
168
+ str += code[i + 1];
169
+ i += 2;
170
+ column += 2;
171
+ } else {
172
+ str += code[i];
173
+ i++;
174
+ column++;
175
+ }
176
+ }
177
+ i++;
178
+ column++;
179
+ tokens.push({ type: "string", value: str, line, column: startCol });
180
+ continue;
181
+ }
182
+ if (/[0-9]/.test(char) || char === "-" && /[0-9]/.test(code[i + 1])) {
183
+ let num = "";
184
+ const startCol = column;
185
+ while (i < code.length && /[0-9.\-]/.test(code[i])) {
186
+ num += code[i];
187
+ i++;
188
+ column++;
189
+ }
190
+ tokens.push({ type: "number", value: num, line, column: startCol });
191
+ continue;
192
+ }
193
+ if (/[a-zA-Z_]/.test(char)) {
194
+ let ident = "";
195
+ const startCol = column;
196
+ while (i < code.length && /[a-zA-Z0-9_]/.test(code[i])) {
197
+ ident += code[i];
198
+ i++;
199
+ column++;
200
+ }
201
+ const isKeyword = this.keywordSet.has(ident.toLowerCase());
202
+ tokens.push({
203
+ type: isKeyword ? "keyword" : "identifier",
204
+ value: ident,
205
+ line,
206
+ column: startCol
207
+ });
208
+ continue;
209
+ }
210
+ const multiCharOps = ["===", "!==", "==", "!=", ">=", "<=", "&&", "||", "++", "--", "+=", "-=", "*=", "/=", "%=", "=>", "->"];
211
+ let foundMultiOp = false;
212
+ for (const op of multiCharOps) {
213
+ if (code.substring(i, i + op.length) === op) {
214
+ tokens.push({ type: "operator", value: op, line, column });
215
+ i += op.length;
216
+ column += op.length;
217
+ foundMultiOp = true;
218
+ break;
219
+ }
220
+ }
221
+ if (foundMultiOp) continue;
222
+ const punctuation = ["{", "}", "(", ")", "[", "]", ":", ",", ".", ";", "=", "<", ">", "+", "-", "*", "/", "%", "!", "&", "|", "?"];
223
+ if (punctuation.includes(char)) {
224
+ tokens.push({ type: "punctuation", value: char, line, column });
225
+ i++;
226
+ column++;
227
+ continue;
228
+ }
229
+ i++;
230
+ column++;
231
+ }
232
+ return tokens;
233
+ }
234
+ /**
235
+ * Parse program (list of declarations)
236
+ */
237
+ parseProgram() {
238
+ const nodes = [];
239
+ let blockCount = 0;
240
+ while (this.position < this.tokens.length) {
241
+ while (this.currentToken()?.type === "newline") {
242
+ this.advance();
243
+ }
244
+ if (this.position >= this.tokens.length) break;
245
+ blockCount++;
246
+ if (blockCount > CODE_SECURITY_CONFIG.maxBlocks) {
247
+ this.errors.push({ line: 0, column: 0, message: "Too many blocks in program" });
248
+ break;
249
+ }
250
+ const node = this.parseDeclaration();
251
+ if (node) {
252
+ nodes.push(node);
253
+ }
254
+ }
255
+ return nodes;
256
+ }
257
+ /**
258
+ * Parse a single declaration
259
+ */
260
+ parseDeclaration() {
261
+ const token = this.currentToken();
262
+ if (!token) return null;
263
+ if (token.type === "keyword") {
264
+ switch (token.value.toLowerCase()) {
265
+ case "orb":
266
+ return this.parseOrb();
267
+ case "function":
268
+ return this.parseFunction();
269
+ case "connect":
270
+ return this.parseConnection();
271
+ case "gate":
272
+ case "if":
273
+ return this.parseGate();
274
+ case "stream":
275
+ return this.parseStream();
276
+ case "nexus":
277
+ return this.parseNexus();
278
+ case "building":
279
+ case "class":
280
+ return this.parseBuilding();
281
+ // Phase 2: Loop constructs
282
+ case "for":
283
+ return this.parseForLoop();
284
+ case "while":
285
+ return this.parseWhileLoop();
286
+ case "foreach":
287
+ return this.parseForEachLoop();
288
+ // Phase 2: Module system
289
+ case "import":
290
+ return this.parseImport();
291
+ case "export":
292
+ return this.parseExport();
293
+ // Phase 2: Variable declarations
294
+ // UI Extensions
295
+ case "ui2d":
296
+ case "card":
297
+ case "metric":
298
+ case "button":
299
+ case "row":
300
+ case "col":
301
+ case "text":
302
+ return this.parseUIElement();
303
+ case "const":
304
+ case "let":
305
+ case "var":
306
+ return this.parseVariableDeclaration();
307
+ // DSL-first commands (Phase 54)
308
+ case "animate":
309
+ return this.parseAnimate();
310
+ case "modify":
311
+ return this.parseModify();
312
+ default:
313
+ this.advance();
314
+ return null;
315
+ }
316
+ }
317
+ this.advance();
318
+ return null;
319
+ }
320
+ /**
321
+ * Parse for loop: for (init; condition; update) { body }
322
+ */
323
+ parseForLoop() {
324
+ this.expect("keyword", "for");
325
+ if (!this.check("punctuation", "(")) {
326
+ this.errors.push({ line: 0, column: 0, message: "Expected ( after for" });
327
+ return null;
328
+ }
329
+ this.advance();
330
+ let init = "", condition = "", update = "";
331
+ let depth = 0;
332
+ while (this.position < this.tokens.length) {
333
+ const t = this.currentToken();
334
+ if (!t) break;
335
+ if (t.value === ";" && depth === 0) {
336
+ this.advance();
337
+ break;
338
+ }
339
+ if (t.value === "(") depth++;
340
+ if (t.value === ")") depth--;
341
+ init += t.value + " ";
342
+ this.advance();
343
+ }
344
+ depth = 0;
345
+ while (this.position < this.tokens.length) {
346
+ const t = this.currentToken();
347
+ if (!t) break;
348
+ if (t.value === ";" && depth === 0) {
349
+ this.advance();
350
+ break;
351
+ }
352
+ if (t.value === "(") depth++;
353
+ if (t.value === ")") depth--;
354
+ condition += t.value + " ";
355
+ this.advance();
356
+ }
357
+ depth = 0;
358
+ while (this.position < this.tokens.length) {
359
+ const t = this.currentToken();
360
+ if (!t) break;
361
+ if (t.value === ")" && depth === 0) {
362
+ this.advance();
363
+ break;
364
+ }
365
+ if (t.value === "(") depth++;
366
+ if (t.value === ")") depth--;
367
+ update += t.value + " ";
368
+ this.advance();
369
+ }
370
+ const body = [];
371
+ if (this.check("punctuation", "{")) {
372
+ this.advance();
373
+ let braceDepth = 1;
374
+ while (braceDepth > 0 && this.position < this.tokens.length) {
375
+ if (this.check("punctuation", "{")) braceDepth++;
376
+ if (this.check("punctuation", "}")) braceDepth--;
377
+ this.advance();
378
+ }
379
+ }
380
+ return {
381
+ type: "for-loop",
382
+ init: init.trim(),
383
+ condition: condition.trim(),
384
+ update: update.trim(),
385
+ body,
386
+ position: { x: 0, y: 0, z: 0 }
387
+ };
388
+ }
389
+ /**
390
+ * Parse while loop: while (condition) { body }
391
+ */
392
+ parseWhileLoop() {
393
+ this.expect("keyword", "while");
394
+ let condition = "";
395
+ if (this.check("punctuation", "(")) {
396
+ this.advance();
397
+ let depth = 1;
398
+ while (depth > 0 && this.position < this.tokens.length) {
399
+ const t = this.currentToken();
400
+ if (!t) break;
401
+ if (t.value === "(") depth++;
402
+ if (t.value === ")") {
403
+ depth--;
404
+ if (depth === 0) {
405
+ this.advance();
406
+ break;
407
+ }
408
+ }
409
+ condition += t.value + " ";
410
+ this.advance();
411
+ }
412
+ }
413
+ if (this.check("punctuation", "{")) {
414
+ this.advance();
415
+ let braceDepth = 1;
416
+ while (braceDepth > 0 && this.position < this.tokens.length) {
417
+ if (this.check("punctuation", "{")) braceDepth++;
418
+ if (this.check("punctuation", "}")) braceDepth--;
419
+ this.advance();
420
+ }
421
+ }
422
+ return {
423
+ type: "while-loop",
424
+ condition: condition.trim(),
425
+ body: [],
426
+ position: { x: 0, y: 0, z: 0 }
427
+ };
428
+ }
429
+ /**
430
+ * Parse forEach loop: forEach item in collection { body }
431
+ */
432
+ parseForEachLoop() {
433
+ this.expect("keyword", "forEach");
434
+ const variable = this.expectIdentifier();
435
+ this.expect("keyword", "in");
436
+ const collection = this.expectIdentifier();
437
+ if (this.check("punctuation", "{")) {
438
+ this.advance();
439
+ let braceDepth = 1;
440
+ while (braceDepth > 0 && this.position < this.tokens.length) {
441
+ if (this.check("punctuation", "{")) braceDepth++;
442
+ if (this.check("punctuation", "}")) braceDepth--;
443
+ this.advance();
444
+ }
445
+ }
446
+ return {
447
+ type: "foreach-loop",
448
+ variable: variable || "item",
449
+ collection: collection || "items",
450
+ body: [],
451
+ position: { x: 0, y: 0, z: 0 }
452
+ };
453
+ }
454
+ /**
455
+ * Parse import: import { x, y } from "module"
456
+ */
457
+ parseImport() {
458
+ this.expect("keyword", "import");
459
+ const imports = [];
460
+ let modulePath = "";
461
+ let defaultImport;
462
+ if (this.check("punctuation", "{")) {
463
+ this.advance();
464
+ while (!this.check("punctuation", "}") && this.position < this.tokens.length) {
465
+ const name = this.expectIdentifier();
466
+ if (name) imports.push(name);
467
+ if (this.check("punctuation", ",")) this.advance();
468
+ }
469
+ this.expect("punctuation", "}");
470
+ } else {
471
+ defaultImport = this.expectIdentifier() || void 0;
472
+ }
473
+ if (this.check("keyword", "from")) {
474
+ this.advance();
475
+ const pathToken = this.currentToken();
476
+ if (pathToken?.type === "string") {
477
+ modulePath = pathToken.value;
478
+ this.advance();
479
+ }
480
+ }
481
+ return {
482
+ type: "import",
483
+ imports,
484
+ defaultImport,
485
+ modulePath,
486
+ position: { x: 0, y: 0, z: 0 }
487
+ };
488
+ }
489
+ /**
490
+ * Parse export: export { x, y } or export function/orb
491
+ */
492
+ parseExport() {
493
+ this.expect("keyword", "export");
494
+ const next = this.currentToken();
495
+ if (next?.type === "keyword") {
496
+ const declaration = this.parseDeclaration();
497
+ return {
498
+ type: "export",
499
+ declaration: declaration || void 0,
500
+ position: { x: 0, y: 0, z: 0 }
501
+ };
502
+ }
503
+ const exports$1 = [];
504
+ if (this.check("punctuation", "{")) {
505
+ this.advance();
506
+ while (!this.check("punctuation", "}") && this.position < this.tokens.length) {
507
+ const name = this.expectIdentifier();
508
+ if (name) exports$1.push(name);
509
+ if (this.check("punctuation", ",")) this.advance();
510
+ }
511
+ this.expect("punctuation", "}");
512
+ }
513
+ return {
514
+ type: "export",
515
+ exports: exports$1,
516
+ position: { x: 0, y: 0, z: 0 }
517
+ };
518
+ }
519
+ /**
520
+ * Parse variable declaration: const/let/var name = value
521
+ */
522
+ parseVariableDeclaration() {
523
+ const kindToken = this.currentToken()?.value.toLowerCase();
524
+ const kind = kindToken === "let" ? "let" : kindToken === "var" ? "var" : "const";
525
+ this.advance();
526
+ const name = this.expectIdentifier();
527
+ if (!name) return null;
528
+ let dataType;
529
+ if (this.check("punctuation", ":")) {
530
+ this.advance();
531
+ dataType = this.expectIdentifier() || void 0;
532
+ }
533
+ let value;
534
+ if (this.check("punctuation", "=")) {
535
+ this.advance();
536
+ const valueToken = this.currentToken();
537
+ if (valueToken?.type === "string") {
538
+ value = valueToken.value;
539
+ this.advance();
540
+ } else if (valueToken?.type === "number") {
541
+ value = parseFloat(valueToken.value);
542
+ this.advance();
543
+ } else if (valueToken?.type === "identifier") {
544
+ if (valueToken.value === "true") value = true;
545
+ else if (valueToken.value === "false") value = false;
546
+ else value = valueToken.value;
547
+ this.advance();
548
+ } else if (this.check("punctuation", "[")) {
549
+ value = this.parseArray();
550
+ } else if (this.check("punctuation", "{")) {
551
+ value = this.parseObject();
552
+ }
553
+ }
554
+ return {
555
+ type: "variable-declaration",
556
+ kind,
557
+ name,
558
+ dataType,
559
+ value,
560
+ position: { x: 0, y: 0, z: 0 }
561
+ };
562
+ }
563
+ /**
564
+ * Parse orb declaration
565
+ */
566
+ parseOrb() {
567
+ this.expect("keyword", "orb");
568
+ const name = this.expectIdentifier();
569
+ if (!name) return null;
570
+ const properties = {};
571
+ let position;
572
+ let hologram;
573
+ if (this.check("punctuation", "{")) {
574
+ this.advance();
575
+ while (!this.check("punctuation", "}") && this.position < this.tokens.length) {
576
+ this.skipNewlines();
577
+ if (this.check("punctuation", "}")) break;
578
+ const prop = this.parseProperty();
579
+ if (prop) {
580
+ if (prop.key === "position" || prop.key === "at") {
581
+ position = this.parsePosition(prop.value);
582
+ } else if (prop.key === "color" || prop.key === "glow" || prop.key === "size") {
583
+ hologram = hologram || { shape: "orb", color: "#00ffff", size: 1, glow: true, interactive: true };
584
+ if (prop.key === "color") hologram.color = String(prop.value);
585
+ if (prop.key === "glow") hologram.glow = Boolean(prop.value);
586
+ if (prop.key === "size") hologram.size = Number(prop.value);
587
+ } else {
588
+ properties[prop.key] = prop.value;
589
+ }
590
+ }
591
+ this.skipNewlines();
592
+ }
593
+ this.expect("punctuation", "}");
594
+ }
595
+ return {
596
+ type: "orb",
597
+ name,
598
+ position: position || { x: 0, y: 0, z: 0 },
599
+ hologram: hologram || { shape: "orb", color: "#00ffff", size: 1, glow: true, interactive: true },
600
+ properties,
601
+ methods: []
602
+ };
603
+ }
604
+ /**
605
+ * Parse function declaration
606
+ */
607
+ parseFunction() {
608
+ this.expect("keyword", "function");
609
+ const name = this.expectIdentifier();
610
+ if (!name) return null;
611
+ const parameters = [];
612
+ let returnType;
613
+ if (this.check("punctuation", "(")) {
614
+ this.advance();
615
+ while (!this.check("punctuation", ")") && this.position < this.tokens.length) {
616
+ const paramName = this.expectIdentifier();
617
+ if (!paramName) break;
618
+ let paramType = "any";
619
+ if (this.check("punctuation", ":")) {
620
+ this.advance();
621
+ paramType = this.expectIdentifier() || "any";
622
+ }
623
+ parameters.push({
624
+ type: "parameter",
625
+ name: paramName,
626
+ dataType: paramType
627
+ });
628
+ if (this.check("punctuation", ",")) {
629
+ this.advance();
630
+ }
631
+ }
632
+ this.expect("punctuation", ")");
633
+ }
634
+ if (this.check("punctuation", ":")) {
635
+ this.advance();
636
+ returnType = this.expectIdentifier() || void 0;
637
+ }
638
+ const body = [];
639
+ if (this.check("punctuation", "{")) {
640
+ this.advance();
641
+ let depth = 1;
642
+ while (depth > 0 && this.position < this.tokens.length) {
643
+ if (this.check("punctuation", "{")) depth++;
644
+ if (this.check("punctuation", "}")) depth--;
645
+ this.advance();
646
+ }
647
+ }
648
+ return {
649
+ type: "method",
650
+ name,
651
+ parameters,
652
+ body,
653
+ returnType,
654
+ position: { x: 0, y: 0, z: 0 },
655
+ hologram: { shape: "cube", color: "#ff6b35", size: 1.5, glow: true, interactive: true }
656
+ };
657
+ }
658
+ /**
659
+ * Parse connection
660
+ */
661
+ parseConnection() {
662
+ this.expect("keyword", "connect");
663
+ const from = this.expectIdentifier();
664
+ if (!from) return null;
665
+ this.expect("keyword", "to");
666
+ const to = this.expectIdentifier();
667
+ if (!to) return null;
668
+ let dataType = "any";
669
+ if (this.check("keyword", "as")) {
670
+ this.advance();
671
+ const typeStr = this.currentToken();
672
+ if (typeStr?.type === "string" || typeStr?.type === "identifier") {
673
+ dataType = typeStr.value;
674
+ this.advance();
675
+ }
676
+ }
677
+ return {
678
+ type: "connection",
679
+ from,
680
+ to,
681
+ dataType,
682
+ bidirectional: false
683
+ };
684
+ }
685
+ /**
686
+ * Parse gate (conditional)
687
+ */
688
+ parseGate() {
689
+ this.expect("keyword", "gate");
690
+ this.expectIdentifier();
691
+ let condition = "";
692
+ if (this.check("punctuation", "(")) {
693
+ this.advance();
694
+ while (!this.check("punctuation", ")") && this.position < this.tokens.length) {
695
+ const token = this.currentToken();
696
+ if (token) condition += token.value + " ";
697
+ this.advance();
698
+ }
699
+ this.expect("punctuation", ")");
700
+ }
701
+ if (this.check("punctuation", "{")) {
702
+ this.advance();
703
+ let depth = 1;
704
+ while (depth > 0 && this.position < this.tokens.length) {
705
+ if (this.check("punctuation", "{")) depth++;
706
+ if (this.check("punctuation", "}")) depth--;
707
+ this.advance();
708
+ }
709
+ }
710
+ return {
711
+ type: "gate",
712
+ condition: condition.trim(),
713
+ truePath: [],
714
+ falsePath: [],
715
+ position: { x: 0, y: 0, z: 0 },
716
+ hologram: { shape: "pyramid", color: "#4ecdc4", size: 1, glow: true, interactive: true }
717
+ };
718
+ }
719
+ /**
720
+ * Parse stream
721
+ */
722
+ parseStream() {
723
+ this.expect("keyword", "stream");
724
+ const name = this.expectIdentifier();
725
+ if (!name) return null;
726
+ let source = "unknown";
727
+ if (this.check("keyword", "from")) {
728
+ this.advance();
729
+ source = this.expectIdentifier() || "unknown";
730
+ }
731
+ if (this.check("punctuation", "{")) {
732
+ this.advance();
733
+ let depth = 1;
734
+ while (depth > 0 && this.position < this.tokens.length) {
735
+ if (this.check("punctuation", "{")) depth++;
736
+ if (this.check("punctuation", "}")) depth--;
737
+ this.advance();
738
+ }
739
+ }
740
+ return {
741
+ type: "stream",
742
+ name,
743
+ source,
744
+ transformations: [],
745
+ position: { x: 0, y: 0, z: 0 },
746
+ hologram: { shape: "cylinder", color: "#45b7d1", size: 2, glow: true, interactive: true }
747
+ };
748
+ }
749
+ /**
750
+ * Parse nexus (multi-agent hub)
751
+ */
752
+ parseNexus() {
753
+ this.expect("keyword", "nexus");
754
+ const name = this.expectIdentifier();
755
+ if (!name) return null;
756
+ if (this.check("punctuation", "{")) {
757
+ this.advance();
758
+ let depth = 1;
759
+ while (depth > 0 && this.position < this.tokens.length) {
760
+ if (this.check("punctuation", "{")) depth++;
761
+ if (this.check("punctuation", "}")) depth--;
762
+ this.advance();
763
+ }
764
+ }
765
+ return {
766
+ type: "nexus",
767
+ position: { x: 0, y: 0, z: 0 },
768
+ hologram: { shape: "sphere", color: "#9b59b6", size: 3, glow: true, interactive: true }
769
+ };
770
+ }
771
+ /**
772
+ * Parse building (class-like)
773
+ */
774
+ parseBuilding() {
775
+ this.expect("keyword", "building");
776
+ const name = this.expectIdentifier();
777
+ if (!name) return null;
778
+ if (this.check("punctuation", "{")) {
779
+ this.advance();
780
+ let depth = 1;
781
+ while (depth > 0 && this.position < this.tokens.length) {
782
+ if (this.check("punctuation", "{")) depth++;
783
+ if (this.check("punctuation", "}")) depth--;
784
+ this.advance();
785
+ }
786
+ }
787
+ return {
788
+ type: "building",
789
+ position: { x: 0, y: 0, z: 0 },
790
+ hologram: { shape: "cube", color: "#e74c3c", size: 4, glow: true, interactive: true }
791
+ };
792
+ }
793
+ /**
794
+ * Parse a property (key: value)
795
+ */
796
+ parseProperty() {
797
+ const key = this.expectIdentifier();
798
+ if (!key) return null;
799
+ if (!this.check("punctuation", ":")) {
800
+ return { key, value: true };
801
+ }
802
+ this.advance();
803
+ const valueToken = this.currentToken();
804
+ if (!valueToken) return null;
805
+ let value;
806
+ if (valueToken.type === "string") {
807
+ value = valueToken.value;
808
+ this.advance();
809
+ } else if (valueToken.type === "number") {
810
+ value = parseFloat(valueToken.value);
811
+ this.advance();
812
+ } else if (valueToken.type === "identifier") {
813
+ if (valueToken.value === "true") value = true;
814
+ else if (valueToken.value === "false") value = false;
815
+ else value = valueToken.value;
816
+ this.advance();
817
+ } else if (this.check("punctuation", "[")) {
818
+ value = this.parseArray();
819
+ } else if (this.check("punctuation", "{")) {
820
+ value = this.parseObject();
821
+ } else {
822
+ value = valueToken.value;
823
+ this.advance();
824
+ }
825
+ return { key, value };
826
+ }
827
+ /**
828
+ * Parse array [...]
829
+ */
830
+ parseArray() {
831
+ const arr = [];
832
+ this.expect("punctuation", "[");
833
+ while (!this.check("punctuation", "]") && this.position < this.tokens.length) {
834
+ const token = this.currentToken();
835
+ if (token?.type === "string" || token?.type === "number" || token?.type === "identifier") {
836
+ if (token.type === "number") {
837
+ arr.push(parseFloat(token.value));
838
+ } else {
839
+ arr.push(token.value);
840
+ }
841
+ this.advance();
842
+ }
843
+ if (this.check("punctuation", ",")) {
844
+ this.advance();
845
+ }
846
+ }
847
+ this.expect("punctuation", "]");
848
+ return arr;
849
+ }
850
+ /**
851
+ * Parse object {...}
852
+ */
853
+ parseObject() {
854
+ const obj = {};
855
+ this.expect("punctuation", "{");
856
+ while (!this.check("punctuation", "}") && this.position < this.tokens.length) {
857
+ this.skipNewlines();
858
+ if (this.check("punctuation", "}")) break;
859
+ const prop = this.parseProperty();
860
+ if (prop) {
861
+ obj[prop.key] = prop.value;
862
+ }
863
+ this.skipNewlines();
864
+ if (this.check("punctuation", ",")) {
865
+ this.advance();
866
+ }
867
+ }
868
+ this.expect("punctuation", "}");
869
+ return obj;
870
+ }
871
+ /**
872
+ * Parse position from value
873
+ */
874
+ parsePosition(value) {
875
+ if (typeof value === "object" && value !== null) {
876
+ const v = value;
877
+ return {
878
+ x: Number(v.x) || 0,
879
+ y: Number(v.y) || 0,
880
+ z: Number(v.z) || 0
881
+ };
882
+ }
883
+ return { x: 0, y: 0, z: 0 };
884
+ }
885
+ // Helper methods
886
+ currentToken() {
887
+ return this.tokens[this.position];
888
+ }
889
+ advance() {
890
+ return this.tokens[this.position++];
891
+ }
892
+ check(type, value) {
893
+ const token = this.currentToken();
894
+ if (!token) return false;
895
+ if (token.type !== type) return false;
896
+ if (value !== void 0 && token.value.toLowerCase() !== value.toLowerCase()) return false;
897
+ return true;
898
+ }
899
+ expect(type, value) {
900
+ if (this.check(type, value)) {
901
+ this.advance();
902
+ return true;
903
+ }
904
+ const token = this.currentToken();
905
+ this.errors.push({
906
+ line: token?.line || 0,
907
+ column: token?.column || 0,
908
+ message: `Expected ${type}${value ? ` '${value}'` : ""}, got ${token?.type || "EOF"} '${token?.value || ""}'`
909
+ });
910
+ return false;
911
+ }
912
+ expectIdentifier() {
913
+ const token = this.currentToken();
914
+ if (token?.type === "identifier" || token?.type === "keyword") {
915
+ this.advance();
916
+ return token.value;
917
+ }
918
+ this.errors.push({
919
+ line: token?.line || 0,
920
+ column: token?.column || 0,
921
+ message: `Expected identifier, got ${token?.type || "EOF"}`
922
+ });
923
+ return null;
924
+ }
925
+ /**
926
+ * Parse animate command: animate target property: "..." from: 0 to: 1 duration: 1000
927
+ */
928
+ parseAnimate() {
929
+ this.expect("keyword", "animate");
930
+ const target = this.expectIdentifier();
931
+ if (!target) return null;
932
+ const properties = {};
933
+ while (this.position < this.tokens.length) {
934
+ this.skipNewlines();
935
+ const t = this.currentToken();
936
+ if (!t || t.type === "newline" || t.type === "keyword" && this.keywordSet.has(t.value.toLowerCase())) break;
937
+ const prop = this.parseProperty();
938
+ if (prop) {
939
+ properties[prop.key] = prop.value;
940
+ } else {
941
+ break;
942
+ }
943
+ }
944
+ return {
945
+ type: "expression-statement",
946
+ expression: `animate("${target}", ${JSON.stringify(properties)})`,
947
+ position: { x: 0, y: 0, z: 0 }
948
+ };
949
+ }
950
+ /**
951
+ * Parse modify command: modify target { prop: value }
952
+ */
953
+ parseModify() {
954
+ this.expect("keyword", "modify");
955
+ const target = this.expectIdentifier();
956
+ if (!target) return null;
957
+ const properties = {};
958
+ if (this.check("punctuation", "{")) {
959
+ this.advance();
960
+ while (!this.check("punctuation", "}") && this.position < this.tokens.length) {
961
+ this.skipNewlines();
962
+ if (this.check("punctuation", "}")) break;
963
+ const prop = this.parseProperty();
964
+ if (prop) {
965
+ properties[prop.key] = prop.value;
966
+ }
967
+ this.skipNewlines();
968
+ }
969
+ this.expect("punctuation", "}");
970
+ }
971
+ return {
972
+ type: "expression-statement",
973
+ expression: `modify("${target}", ${JSON.stringify(properties)})`,
974
+ position: { x: 0, y: 0, z: 0 }
975
+ };
976
+ }
977
+ /**
978
+ * Parse UI Element: ui2d dashboard#id { ... }
979
+ */
980
+ parseUIElement() {
981
+ const typeToken = this.currentToken();
982
+ if (!typeToken) return null;
983
+ const elementType = typeToken.value;
984
+ this.advance();
985
+ let elementId = `${elementType}_${Date.now()}`;
986
+ if (this.currentToken()?.type === "punctuation" && this.currentToken()?.value === "#") {
987
+ this.advance();
988
+ const idToken = this.currentToken();
989
+ if (idToken) {
990
+ elementId = idToken.value;
991
+ this.advance();
992
+ }
993
+ } else if (this.currentToken()?.type === "identifier" && this.currentToken()?.value.startsWith("#")) {
994
+ elementId = this.currentToken()?.value.slice(1) || elementId;
995
+ this.advance();
996
+ }
997
+ const properties = {};
998
+ if (this.check("punctuation", "{")) {
999
+ this.advance();
1000
+ while (!this.check("punctuation", "}") && this.position < this.tokens.length) {
1001
+ this.skipNewlines();
1002
+ if (this.check("punctuation", "}")) break;
1003
+ const prop = this.parseProperty();
1004
+ if (prop) {
1005
+ properties[prop.key] = prop.value;
1006
+ }
1007
+ this.skipNewlines();
1008
+ }
1009
+ this.expect("punctuation", "}");
1010
+ }
1011
+ return {
1012
+ type: "ui2d",
1013
+ name: elementType,
1014
+ properties: { id: elementId, ...properties },
1015
+ position: { x: 0, y: 0, z: 0 }
1016
+ };
1017
+ }
1018
+ skipNewlines() {
1019
+ while (this.currentToken()?.type === "newline") {
1020
+ this.advance();
1021
+ }
1022
+ }
1023
+ };
1024
+
1025
+ exports.HoloScriptCodeParser = HoloScriptCodeParser;
1026
+ //# sourceMappingURL=chunk-4OHVW4XR.cjs.map
1027
+ //# sourceMappingURL=chunk-4OHVW4XR.cjs.map