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