@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
@@ -0,0 +1,1279 @@
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
+ "scale",
84
+ "focus",
85
+ "environment",
86
+ "composition",
87
+ "template",
88
+ "settings",
89
+ "chat"
90
+ ]);
91
+ }
92
+ /**
93
+ * Parse HoloScript code string into AST
94
+ */
95
+ parse(code) {
96
+ this.errors = [];
97
+ this.warnings = [];
98
+ this.tokens = [];
99
+ this.position = 0;
100
+ if (code.length > CODE_SECURITY_CONFIG.maxCodeLength) {
101
+ return {
102
+ success: false,
103
+ ast: [],
104
+ errors: [{ line: 0, column: 0, message: `Code exceeds max length (${CODE_SECURITY_CONFIG.maxCodeLength})` }],
105
+ warnings: []
106
+ };
107
+ }
108
+ for (const keyword of CODE_SECURITY_CONFIG.suspiciousKeywords) {
109
+ if (code.toLowerCase().includes(keyword)) {
110
+ logger.warn("Suspicious keyword detected", { keyword });
111
+ return {
112
+ success: false,
113
+ ast: [],
114
+ errors: [{ line: 0, column: 0, message: `Suspicious keyword detected: ${keyword}` }],
115
+ warnings: []
116
+ };
117
+ }
118
+ }
119
+ try {
120
+ this.tokens = this.tokenize(code);
121
+ const ast = this.parseProgram();
122
+ return {
123
+ success: this.errors.length === 0,
124
+ ast,
125
+ errors: this.errors,
126
+ warnings: this.warnings
127
+ };
128
+ } catch (error) {
129
+ return {
130
+ success: false,
131
+ ast: [],
132
+ errors: [{ line: 0, column: 0, message: String(error) }],
133
+ warnings: this.warnings
134
+ };
135
+ }
136
+ }
137
+ /**
138
+ * Tokenize code into tokens
139
+ */
140
+ tokenize(code) {
141
+ const tokens = [];
142
+ let line = 1;
143
+ let column = 1;
144
+ let i = 0;
145
+ while (i < code.length) {
146
+ const char = code[i];
147
+ if (char === " " || char === " " || char === "\r") {
148
+ i++;
149
+ column++;
150
+ continue;
151
+ }
152
+ if (char === "\n") {
153
+ tokens.push({ type: "newline", value: "\n", line, column });
154
+ line++;
155
+ column = 1;
156
+ i++;
157
+ continue;
158
+ }
159
+ if (char === "/" && code[i + 1] === "/") {
160
+ while (i < code.length && code[i] !== "\n") {
161
+ i++;
162
+ }
163
+ continue;
164
+ }
165
+ if (char === '"' || char === "'") {
166
+ const quote = char;
167
+ let str = "";
168
+ const startCol = column;
169
+ i++;
170
+ column++;
171
+ while (i < code.length && code[i] !== quote) {
172
+ if (code[i] === "\\" && i + 1 < code.length) {
173
+ str += code[i + 1];
174
+ i += 2;
175
+ column += 2;
176
+ } else {
177
+ str += code[i];
178
+ i++;
179
+ column++;
180
+ }
181
+ }
182
+ i++;
183
+ column++;
184
+ tokens.push({ type: "string", value: str, line, column: startCol });
185
+ continue;
186
+ }
187
+ if (/[0-9]/.test(char) || char === "-" && /[0-9]/.test(code[i + 1])) {
188
+ let num = "";
189
+ const startCol = column;
190
+ while (i < code.length && /[0-9.\-]/.test(code[i])) {
191
+ num += code[i];
192
+ i++;
193
+ column++;
194
+ }
195
+ tokens.push({ type: "number", value: num, line, column: startCol });
196
+ continue;
197
+ }
198
+ if (/[a-zA-Z_]/.test(char)) {
199
+ let ident = "";
200
+ const startCol = column;
201
+ while (i < code.length && /[a-zA-Z0-9_]/.test(code[i])) {
202
+ ident += code[i];
203
+ i++;
204
+ column++;
205
+ }
206
+ const isKeyword = this.keywordSet.has(ident.toLowerCase());
207
+ tokens.push({
208
+ type: isKeyword ? "keyword" : "identifier",
209
+ value: ident,
210
+ line,
211
+ column: startCol
212
+ });
213
+ continue;
214
+ }
215
+ const multiCharOps = ["===", "!==", "==", "!=", ">=", "<=", "&&", "||", "++", "--", "+=", "-=", "*=", "/=", "%=", "=>", "->"];
216
+ let foundMultiOp = false;
217
+ for (const op of multiCharOps) {
218
+ if (code.substring(i, i + op.length) === op) {
219
+ tokens.push({ type: "operator", value: op, line, column });
220
+ i += op.length;
221
+ column += op.length;
222
+ foundMultiOp = true;
223
+ break;
224
+ }
225
+ }
226
+ if (foundMultiOp) continue;
227
+ const punctuation = ["{", "}", "(", ")", "[", "]", ":", ",", ".", ";", "=", "<", ">", "+", "-", "*", "/", "%", "!", "&", "|", "?", "#", "@"];
228
+ if (punctuation.includes(char)) {
229
+ tokens.push({ type: "punctuation", value: char, line, column });
230
+ i++;
231
+ column++;
232
+ continue;
233
+ }
234
+ i++;
235
+ column++;
236
+ }
237
+ return tokens;
238
+ }
239
+ /**
240
+ * Parse program (list of declarations)
241
+ */
242
+ parseProgram() {
243
+ const nodes = [];
244
+ let blockCount = 0;
245
+ while (this.position < this.tokens.length) {
246
+ while (this.currentToken()?.type === "newline") {
247
+ this.advance();
248
+ }
249
+ if (this.position >= this.tokens.length) break;
250
+ blockCount++;
251
+ if (blockCount > CODE_SECURITY_CONFIG.maxBlocks) {
252
+ this.errors.push({ line: 0, column: 0, message: "Too many blocks in program" });
253
+ break;
254
+ }
255
+ const node = this.parseDeclaration();
256
+ if (node) {
257
+ nodes.push(node);
258
+ }
259
+ }
260
+ return nodes;
261
+ }
262
+ /**
263
+ * Parse a single declaration
264
+ */
265
+ parseDeclaration() {
266
+ const token = this.currentToken();
267
+ if (!token) return null;
268
+ if (token.type === "keyword") {
269
+ switch (token.value.toLowerCase()) {
270
+ case "orb":
271
+ case "object":
272
+ return this.parseOrb();
273
+ case "function":
274
+ return this.parseFunction();
275
+ case "connect":
276
+ return this.parseConnection();
277
+ case "gate":
278
+ case "if":
279
+ return this.parseGate();
280
+ case "stream":
281
+ return this.parseStream();
282
+ case "nexus":
283
+ return this.parseNexus();
284
+ case "building":
285
+ case "class":
286
+ return this.parseBuilding();
287
+ // Phase 2: Loop constructs
288
+ case "for":
289
+ return this.parseForLoop();
290
+ case "while":
291
+ return this.parseWhileLoop();
292
+ case "foreach":
293
+ return this.parseForEachLoop();
294
+ // Phase 2: Module system
295
+ case "import":
296
+ return this.parseImport();
297
+ case "export":
298
+ return this.parseExport();
299
+ // Phase 2: Variable declarations
300
+ // UI Extensions
301
+ case "ui2d":
302
+ case "card":
303
+ case "metric":
304
+ case "button":
305
+ case "row":
306
+ case "col":
307
+ case "text":
308
+ return this.parseUIElement();
309
+ case "const":
310
+ case "let":
311
+ case "var":
312
+ return this.parseVariableDeclaration();
313
+ // DSL-first commands (Phase 54)
314
+ case "animate":
315
+ return this.parseAnimate();
316
+ case "modify":
317
+ return this.parseModify();
318
+ case "scale":
319
+ return this.parseScale();
320
+ case "focus":
321
+ return this.parseFocus();
322
+ case "environment":
323
+ return this.parseEnvironment();
324
+ case "composition":
325
+ return this.parseComposition();
326
+ case "template":
327
+ return this.parseTemplate();
328
+ case "settings":
329
+ return this.parseSettings();
330
+ case "chat":
331
+ return this.parseChat();
332
+ default:
333
+ this.advance();
334
+ return null;
335
+ }
336
+ }
337
+ this.advance();
338
+ return null;
339
+ }
340
+ /**
341
+ * Parse for loop: for (init; condition; update) { body }
342
+ */
343
+ parseForLoop() {
344
+ this.expect("keyword", "for");
345
+ if (!this.check("punctuation", "(")) {
346
+ this.errors.push({ line: 0, column: 0, message: "Expected ( after for" });
347
+ return null;
348
+ }
349
+ this.advance();
350
+ let init = "", condition = "", update = "";
351
+ let depth = 0;
352
+ while (this.position < this.tokens.length) {
353
+ const t = this.currentToken();
354
+ if (!t) break;
355
+ if (t.value === ";" && depth === 0) {
356
+ this.advance();
357
+ break;
358
+ }
359
+ if (t.value === "(") depth++;
360
+ if (t.value === ")") depth--;
361
+ init += t.value + " ";
362
+ this.advance();
363
+ }
364
+ depth = 0;
365
+ while (this.position < this.tokens.length) {
366
+ const t = this.currentToken();
367
+ if (!t) break;
368
+ if (t.value === ";" && depth === 0) {
369
+ this.advance();
370
+ break;
371
+ }
372
+ if (t.value === "(") depth++;
373
+ if (t.value === ")") depth--;
374
+ condition += t.value + " ";
375
+ this.advance();
376
+ }
377
+ depth = 0;
378
+ while (this.position < this.tokens.length) {
379
+ const t = this.currentToken();
380
+ if (!t) break;
381
+ if (t.value === ")" && depth === 0) {
382
+ this.advance();
383
+ break;
384
+ }
385
+ if (t.value === "(") depth++;
386
+ if (t.value === ")") depth--;
387
+ update += t.value + " ";
388
+ this.advance();
389
+ }
390
+ const body = [];
391
+ if (this.check("punctuation", "{")) {
392
+ this.advance();
393
+ let braceDepth = 1;
394
+ while (braceDepth > 0 && this.position < this.tokens.length) {
395
+ if (this.check("punctuation", "{")) braceDepth++;
396
+ if (this.check("punctuation", "}")) braceDepth--;
397
+ this.advance();
398
+ }
399
+ }
400
+ return {
401
+ type: "for-loop",
402
+ init: init.trim(),
403
+ condition: condition.trim(),
404
+ update: update.trim(),
405
+ body,
406
+ position: { x: 0, y: 0, z: 0 }
407
+ };
408
+ }
409
+ /**
410
+ * Parse while loop: while (condition) { body }
411
+ */
412
+ parseWhileLoop() {
413
+ this.expect("keyword", "while");
414
+ let condition = "";
415
+ if (this.check("punctuation", "(")) {
416
+ this.advance();
417
+ let depth = 1;
418
+ while (depth > 0 && this.position < this.tokens.length) {
419
+ const t = this.currentToken();
420
+ if (!t) break;
421
+ if (t.value === "(") depth++;
422
+ if (t.value === ")") {
423
+ depth--;
424
+ if (depth === 0) {
425
+ this.advance();
426
+ break;
427
+ }
428
+ }
429
+ condition += t.value + " ";
430
+ this.advance();
431
+ }
432
+ }
433
+ if (this.check("punctuation", "{")) {
434
+ this.advance();
435
+ let braceDepth = 1;
436
+ while (braceDepth > 0 && this.position < this.tokens.length) {
437
+ if (this.check("punctuation", "{")) braceDepth++;
438
+ if (this.check("punctuation", "}")) braceDepth--;
439
+ this.advance();
440
+ }
441
+ }
442
+ return {
443
+ type: "while-loop",
444
+ condition: condition.trim(),
445
+ body: [],
446
+ position: { x: 0, y: 0, z: 0 }
447
+ };
448
+ }
449
+ /**
450
+ * Parse forEach loop: forEach item in collection { body }
451
+ */
452
+ parseForEachLoop() {
453
+ this.expect("keyword", "forEach");
454
+ const variable = this.expectIdentifier();
455
+ this.expect("keyword", "in");
456
+ const collection = this.expectIdentifier();
457
+ if (this.check("punctuation", "{")) {
458
+ this.advance();
459
+ let braceDepth = 1;
460
+ while (braceDepth > 0 && this.position < this.tokens.length) {
461
+ if (this.check("punctuation", "{")) braceDepth++;
462
+ if (this.check("punctuation", "}")) braceDepth--;
463
+ this.advance();
464
+ }
465
+ }
466
+ return {
467
+ type: "foreach-loop",
468
+ variable: variable || "item",
469
+ collection: collection || "items",
470
+ body: [],
471
+ position: { x: 0, y: 0, z: 0 }
472
+ };
473
+ }
474
+ /**
475
+ * Parse import: import { x, y } from "module"
476
+ */
477
+ parseImport() {
478
+ this.expect("keyword", "import");
479
+ const imports = [];
480
+ let modulePath = "";
481
+ let defaultImport;
482
+ if (this.check("punctuation", "{")) {
483
+ this.advance();
484
+ while (!this.check("punctuation", "}") && this.position < this.tokens.length) {
485
+ const name = this.expectIdentifier();
486
+ if (name) imports.push(name);
487
+ if (this.check("punctuation", ",")) this.advance();
488
+ }
489
+ this.expect("punctuation", "}");
490
+ } else {
491
+ defaultImport = this.expectIdentifier() || void 0;
492
+ }
493
+ if (this.check("keyword", "from")) {
494
+ this.advance();
495
+ const pathToken = this.currentToken();
496
+ if (pathToken?.type === "string") {
497
+ modulePath = pathToken.value;
498
+ this.advance();
499
+ }
500
+ }
501
+ return {
502
+ type: "import",
503
+ imports,
504
+ defaultImport,
505
+ modulePath,
506
+ position: { x: 0, y: 0, z: 0 }
507
+ };
508
+ }
509
+ /**
510
+ * Parse export: export { x, y } or export function/orb
511
+ */
512
+ parseExport() {
513
+ this.expect("keyword", "export");
514
+ const next = this.currentToken();
515
+ if (next?.type === "keyword") {
516
+ const declaration = this.parseDeclaration();
517
+ return {
518
+ type: "export",
519
+ declaration: declaration || void 0,
520
+ position: { x: 0, y: 0, z: 0 }
521
+ };
522
+ }
523
+ const exports$1 = [];
524
+ if (this.check("punctuation", "{")) {
525
+ this.advance();
526
+ while (!this.check("punctuation", "}") && this.position < this.tokens.length) {
527
+ const name = this.expectIdentifier();
528
+ if (name) exports$1.push(name);
529
+ if (this.check("punctuation", ",")) this.advance();
530
+ }
531
+ this.expect("punctuation", "}");
532
+ }
533
+ return {
534
+ type: "export",
535
+ exports: exports$1,
536
+ position: { x: 0, y: 0, z: 0 }
537
+ };
538
+ }
539
+ /**
540
+ * Parse variable declaration: const/let/var name = value
541
+ */
542
+ parseVariableDeclaration() {
543
+ const kindToken = this.currentToken()?.value.toLowerCase();
544
+ const kind = kindToken === "let" ? "let" : kindToken === "var" ? "var" : "const";
545
+ this.advance();
546
+ const name = this.expectIdentifier();
547
+ if (!name) return null;
548
+ let dataType;
549
+ if (this.check("punctuation", ":")) {
550
+ this.advance();
551
+ dataType = this.expectIdentifier() || void 0;
552
+ }
553
+ let value;
554
+ if (this.check("punctuation", "=")) {
555
+ this.advance();
556
+ const valueToken = this.currentToken();
557
+ if (valueToken?.type === "string") {
558
+ value = valueToken.value;
559
+ this.advance();
560
+ } else if (valueToken?.type === "number") {
561
+ value = parseFloat(valueToken.value);
562
+ this.advance();
563
+ } else if (valueToken?.type === "identifier") {
564
+ if (valueToken.value === "true") value = true;
565
+ else if (valueToken.value === "false") value = false;
566
+ else value = valueToken.value;
567
+ this.advance();
568
+ } else if (this.check("punctuation", "[")) {
569
+ value = this.parseArray();
570
+ } else if (this.check("punctuation", "{")) {
571
+ value = this.parseObject();
572
+ }
573
+ }
574
+ return {
575
+ type: "variable-declaration",
576
+ kind,
577
+ name,
578
+ dataType,
579
+ value,
580
+ position: { x: 0, y: 0, z: 0 }
581
+ };
582
+ }
583
+ /**
584
+ * Parse orb declaration
585
+ */
586
+ parseOrb() {
587
+ const startToken = this.currentToken();
588
+ if (this.check("keyword", "orb") || this.check("keyword", "object")) {
589
+ this.advance();
590
+ } else {
591
+ this.expect("keyword", "orb");
592
+ }
593
+ let name = "";
594
+ if (this.check("punctuation", "#")) {
595
+ this.advance();
596
+ name = this.expectIdentifier() || `orb_${Date.now()}`;
597
+ } else {
598
+ name = this.expectIdentifier() || `orb_${Date.now()}`;
599
+ }
600
+ const properties = {};
601
+ const directives = [];
602
+ let position;
603
+ let hologram;
604
+ if (this.check("punctuation", "{")) {
605
+ this.advance();
606
+ while (!this.check("punctuation", "}") && this.position < this.tokens.length) {
607
+ this.skipNewlines();
608
+ if (this.check("punctuation", "}")) break;
609
+ const token = this.currentToken();
610
+ if (token?.type === "punctuation" && token.value === "@") {
611
+ const directive = this.parseDirective();
612
+ if (directive) directives.push(directive);
613
+ } else {
614
+ const prop = this.parseProperty();
615
+ if (prop) {
616
+ if (prop.key === "position" || prop.key === "at") {
617
+ position = this.parsePosition(prop.value);
618
+ } else if (prop.key === "color" || prop.key === "glow" || prop.key === "size") {
619
+ hologram = hologram || { shape: "orb", color: "#00ffff", size: 0.5, glow: true, interactive: true };
620
+ if (prop.key === "color") hologram.color = String(prop.value);
621
+ if (prop.key === "glow") hologram.glow = Boolean(prop.value);
622
+ if (prop.key === "size") hologram.size = Number(prop.value);
623
+ } else {
624
+ properties[prop.key] = prop.value;
625
+ }
626
+ }
627
+ }
628
+ this.skipNewlines();
629
+ }
630
+ this.expect("punctuation", "}");
631
+ }
632
+ return {
633
+ type: "orb",
634
+ name,
635
+ position: position || { x: 0, y: 0, z: 0 },
636
+ hologram: hologram || { shape: "orb", color: "#00ffff", size: 0.5, glow: true, interactive: true },
637
+ properties,
638
+ directives,
639
+ methods: [],
640
+ line: startToken?.line || 0
641
+ };
642
+ }
643
+ /**
644
+ * Parse HoloScript+ directive: @name(...) or @name { ... }
645
+ */
646
+ parseDirective() {
647
+ this.expect("punctuation", "@");
648
+ const name = this.expectIdentifier();
649
+ if (!name) return null;
650
+ if (name === "state") {
651
+ const body = this.parseObject();
652
+ return { type: "state", body };
653
+ }
654
+ if (name.startsWith("on_")) {
655
+ let body = "";
656
+ if (this.check("punctuation", "{")) {
657
+ this.advance();
658
+ let braceDepth = 1;
659
+ while (braceDepth > 0 && this.position < this.tokens.length) {
660
+ const t = this.advance();
661
+ if (t.value === "{") braceDepth++;
662
+ if (t.value === "}") braceDepth--;
663
+ if (braceDepth > 0) body += t.value + " ";
664
+ else if (braceDepth < 0) break;
665
+ }
666
+ } else {
667
+ const t = this.advance();
668
+ if (t) body = t.value;
669
+ }
670
+ return { type: "lifecycle", hook: name, body };
671
+ }
672
+ let config = {};
673
+ if (this.check("punctuation", "(")) {
674
+ this.advance();
675
+ while (!this.check("punctuation", ")") && this.position < this.tokens.length) {
676
+ const prop = this.parseProperty();
677
+ if (prop) {
678
+ config[prop.key] = prop.value;
679
+ }
680
+ if (this.check("punctuation", ",")) {
681
+ this.advance();
682
+ }
683
+ }
684
+ this.expect("punctuation", ")");
685
+ } else if (this.check("punctuation", "{")) {
686
+ config = this.parseObject();
687
+ }
688
+ return { type: "trait", name, config };
689
+ }
690
+ /**
691
+ * Parse function declaration
692
+ */
693
+ parseFunction() {
694
+ this.expect("keyword", "function");
695
+ const name = this.expectIdentifier();
696
+ if (!name) return null;
697
+ const parameters = [];
698
+ let returnType;
699
+ if (this.check("punctuation", "(")) {
700
+ this.advance();
701
+ while (!this.check("punctuation", ")") && this.position < this.tokens.length) {
702
+ const paramName = this.expectIdentifier();
703
+ if (!paramName) break;
704
+ let paramType = "any";
705
+ if (this.check("punctuation", ":")) {
706
+ this.advance();
707
+ paramType = this.expectIdentifier() || "any";
708
+ }
709
+ parameters.push({
710
+ type: "parameter",
711
+ name: paramName,
712
+ dataType: paramType
713
+ });
714
+ if (this.check("punctuation", ",")) {
715
+ this.advance();
716
+ }
717
+ }
718
+ this.expect("punctuation", ")");
719
+ }
720
+ if (this.check("punctuation", ":")) {
721
+ this.advance();
722
+ returnType = this.expectIdentifier() || void 0;
723
+ }
724
+ const body = [];
725
+ if (this.check("punctuation", "{")) {
726
+ this.advance();
727
+ let depth = 1;
728
+ while (depth > 0 && this.position < this.tokens.length) {
729
+ if (this.check("punctuation", "{")) depth++;
730
+ if (this.check("punctuation", "}")) depth--;
731
+ this.advance();
732
+ }
733
+ }
734
+ return {
735
+ type: "method",
736
+ name,
737
+ parameters,
738
+ body,
739
+ returnType,
740
+ position: { x: 0, y: 0, z: 0 },
741
+ hologram: { shape: "cube", color: "#ff6b35", size: 1.5, glow: true, interactive: true }
742
+ };
743
+ }
744
+ /**
745
+ * Parse connection
746
+ */
747
+ parseConnection() {
748
+ this.expect("keyword", "connect");
749
+ const from = this.expectIdentifier();
750
+ if (!from) return null;
751
+ this.expect("keyword", "to");
752
+ const to = this.expectIdentifier();
753
+ if (!to) return null;
754
+ let dataType = "any";
755
+ if (this.check("keyword", "as")) {
756
+ this.advance();
757
+ const typeStr = this.currentToken();
758
+ if (typeStr?.type === "string" || typeStr?.type === "identifier") {
759
+ dataType = typeStr.value;
760
+ this.advance();
761
+ }
762
+ }
763
+ return {
764
+ type: "connection",
765
+ from,
766
+ to,
767
+ dataType,
768
+ bidirectional: false
769
+ };
770
+ }
771
+ /**
772
+ * Parse scale block: scale <magnitude> { body }
773
+ */
774
+ parseScale() {
775
+ this.expect("keyword", "scale");
776
+ const magnitude = this.expectIdentifier() || "standard";
777
+ const multipliers = {
778
+ "galactic": 1e6,
779
+ "macro": 1e3,
780
+ "standard": 1,
781
+ "micro": 1e-3,
782
+ "atomic": 1e-6
783
+ };
784
+ const body = [];
785
+ if (this.check("punctuation", "{")) {
786
+ this.advance();
787
+ while (!this.check("punctuation", "}") && this.position < this.tokens.length) {
788
+ this.skipNewlines();
789
+ const node = this.parseDeclaration();
790
+ if (node) body.push(node);
791
+ this.skipNewlines();
792
+ }
793
+ this.expect("punctuation", "}");
794
+ }
795
+ return {
796
+ type: "scale",
797
+ magnitude,
798
+ multiplier: multipliers[magnitude] || 1,
799
+ body,
800
+ position: { x: 0, y: 0, z: 0 }
801
+ };
802
+ }
803
+ /**
804
+ * Parse focus block: focus <target> { body }
805
+ */
806
+ parseFocus() {
807
+ this.expect("keyword", "focus");
808
+ const target = this.expectIdentifier() || "origin";
809
+ const body = [];
810
+ if (this.check("punctuation", "{")) {
811
+ this.advance();
812
+ while (!this.check("punctuation", "}") && this.position < this.tokens.length) {
813
+ this.skipNewlines();
814
+ const node = this.parseDeclaration();
815
+ if (node) body.push(node);
816
+ this.skipNewlines();
817
+ }
818
+ this.expect("punctuation", "}");
819
+ }
820
+ return {
821
+ type: "focus",
822
+ target,
823
+ body,
824
+ position: { x: 0, y: 0, z: 0 }
825
+ };
826
+ }
827
+ /**
828
+ * Parse environment declaration
829
+ */
830
+ parseEnvironment() {
831
+ this.expect("keyword", "environment");
832
+ const settings = {};
833
+ while (this.position < this.tokens.length && this.currentToken()?.type !== "newline" && !this.check("punctuation", "}")) {
834
+ const key = this.expectIdentifier();
835
+ if (!key) break;
836
+ settings[key] = this.parseLiteral();
837
+ }
838
+ return {
839
+ type: "environment",
840
+ settings
841
+ };
842
+ }
843
+ /**
844
+ * Parse composition block
845
+ */
846
+ parseComposition() {
847
+ this.expect("keyword", "composition");
848
+ const name = this.expectIdentifier() || "unnamed";
849
+ const children = [];
850
+ if (this.check("punctuation", "{")) {
851
+ this.advance();
852
+ while (!this.check("punctuation", "}") && this.position < this.tokens.length) {
853
+ this.skipNewlines();
854
+ const node = this.parseDeclaration();
855
+ if (node) children.push(node);
856
+ this.skipNewlines();
857
+ }
858
+ this.expect("punctuation", "}");
859
+ }
860
+ return {
861
+ type: "composition",
862
+ name,
863
+ children
864
+ };
865
+ }
866
+ /**
867
+ * Parse template declaration
868
+ */
869
+ parseTemplate() {
870
+ this.expect("keyword", "template");
871
+ const name = this.expectIdentifier() || "template";
872
+ const params = [];
873
+ if (this.check("punctuation", "(")) {
874
+ this.advance();
875
+ while (!this.check("punctuation", ")") && this.position < this.tokens.length) {
876
+ const p = this.expectIdentifier();
877
+ if (p) params.push(p);
878
+ if (this.check("punctuation", ",")) this.advance();
879
+ }
880
+ this.expect("punctuation", ")");
881
+ }
882
+ const body = [];
883
+ if (this.check("punctuation", "{")) {
884
+ this.advance();
885
+ while (!this.check("punctuation", "}") && this.position < this.tokens.length) {
886
+ this.skipNewlines();
887
+ const node = this.parseDeclaration();
888
+ if (node) body.push(node);
889
+ this.skipNewlines();
890
+ }
891
+ this.expect("punctuation", "}");
892
+ }
893
+ return {
894
+ type: "template",
895
+ name,
896
+ parameters: params,
897
+ body
898
+ };
899
+ }
900
+ /**
901
+ * Parse gate (conditional)
902
+ */
903
+ parseGate() {
904
+ this.expect("keyword", "gate");
905
+ this.expectIdentifier();
906
+ let condition = "";
907
+ if (this.check("punctuation", "(")) {
908
+ this.advance();
909
+ while (!this.check("punctuation", ")") && this.position < this.tokens.length) {
910
+ const token = this.currentToken();
911
+ if (token) condition += token.value + " ";
912
+ this.advance();
913
+ }
914
+ this.expect("punctuation", ")");
915
+ }
916
+ if (this.check("punctuation", "{")) {
917
+ this.advance();
918
+ let depth = 1;
919
+ while (depth > 0 && this.position < this.tokens.length) {
920
+ if (this.check("punctuation", "{")) depth++;
921
+ if (this.check("punctuation", "}")) depth--;
922
+ this.advance();
923
+ }
924
+ }
925
+ return {
926
+ type: "gate",
927
+ condition: condition.trim(),
928
+ truePath: [],
929
+ falsePath: [],
930
+ position: { x: 0, y: 0, z: 0 },
931
+ hologram: { shape: "pyramid", color: "#4ecdc4", size: 1, glow: true, interactive: true }
932
+ };
933
+ }
934
+ /**
935
+ * Parse stream
936
+ */
937
+ parseStream() {
938
+ this.expect("keyword", "stream");
939
+ const name = this.expectIdentifier();
940
+ if (!name) return null;
941
+ let source = "unknown";
942
+ if (this.check("keyword", "from")) {
943
+ this.advance();
944
+ source = this.expectIdentifier() || "unknown";
945
+ }
946
+ if (this.check("punctuation", "{")) {
947
+ this.advance();
948
+ let depth = 1;
949
+ while (depth > 0 && this.position < this.tokens.length) {
950
+ if (this.check("punctuation", "{")) depth++;
951
+ if (this.check("punctuation", "}")) depth--;
952
+ this.advance();
953
+ }
954
+ }
955
+ return {
956
+ type: "stream",
957
+ name,
958
+ source,
959
+ transformations: [],
960
+ position: { x: 0, y: 0, z: 0 },
961
+ hologram: { shape: "cylinder", color: "#45b7d1", size: 2, glow: true, interactive: true }
962
+ };
963
+ }
964
+ /**
965
+ * Parse nexus (multi-agent hub)
966
+ */
967
+ parseNexus() {
968
+ this.expect("keyword", "nexus");
969
+ const name = this.expectIdentifier();
970
+ if (!name) return null;
971
+ if (this.check("punctuation", "{")) {
972
+ this.advance();
973
+ let depth = 1;
974
+ while (depth > 0 && this.position < this.tokens.length) {
975
+ if (this.check("punctuation", "{")) depth++;
976
+ if (this.check("punctuation", "}")) depth--;
977
+ this.advance();
978
+ }
979
+ }
980
+ return {
981
+ type: "nexus",
982
+ position: { x: 0, y: 0, z: 0 },
983
+ hologram: { shape: "sphere", color: "#9b59b6", size: 3, glow: true, interactive: true }
984
+ };
985
+ }
986
+ /**
987
+ * Parse building (class-like)
988
+ */
989
+ parseBuilding() {
990
+ this.expect("keyword", "building");
991
+ const name = this.expectIdentifier();
992
+ if (!name) return null;
993
+ if (this.check("punctuation", "{")) {
994
+ this.advance();
995
+ let depth = 1;
996
+ while (depth > 0 && this.position < this.tokens.length) {
997
+ if (this.check("punctuation", "{")) depth++;
998
+ if (this.check("punctuation", "}")) depth--;
999
+ this.advance();
1000
+ }
1001
+ }
1002
+ return {
1003
+ type: "building",
1004
+ position: { x: 0, y: 0, z: 0 },
1005
+ hologram: { shape: "cube", color: "#e74c3c", size: 4, glow: true, interactive: true }
1006
+ };
1007
+ }
1008
+ /**
1009
+ * Parse a literal value (string, number, boolean, array, or object)
1010
+ */
1011
+ parseLiteral() {
1012
+ const token = this.currentToken();
1013
+ if (!token) return null;
1014
+ if (token.type === "string") {
1015
+ this.advance();
1016
+ return token.value;
1017
+ }
1018
+ if (token.type === "number") {
1019
+ this.advance();
1020
+ return parseFloat(token.value);
1021
+ }
1022
+ if (token.type === "identifier") {
1023
+ const val = token.value.toLowerCase();
1024
+ this.advance();
1025
+ if (val === "true") return true;
1026
+ if (val === "false") return false;
1027
+ if (val === "null") return null;
1028
+ return token.value;
1029
+ }
1030
+ if (this.check("punctuation", "[")) {
1031
+ return this.parseArray();
1032
+ }
1033
+ if (this.check("punctuation", "{")) {
1034
+ return this.parseObject();
1035
+ }
1036
+ this.advance();
1037
+ return token.value;
1038
+ }
1039
+ /**
1040
+ * Parse a property (key: value)
1041
+ */
1042
+ parseProperty() {
1043
+ const key = this.expectIdentifier();
1044
+ if (!key) return null;
1045
+ if (!this.check("punctuation", ":")) {
1046
+ return { key, value: true };
1047
+ }
1048
+ this.advance();
1049
+ const value = this.parseLiteral();
1050
+ return { key, value };
1051
+ }
1052
+ /**
1053
+ * Parse array [...]
1054
+ */
1055
+ parseArray() {
1056
+ const arr = [];
1057
+ this.expect("punctuation", "[");
1058
+ while (!this.check("punctuation", "]") && this.position < this.tokens.length) {
1059
+ const token = this.currentToken();
1060
+ if (token?.type === "string" || token?.type === "number" || token?.type === "identifier") {
1061
+ if (token.type === "number") {
1062
+ arr.push(parseFloat(token.value));
1063
+ } else {
1064
+ arr.push(token.value);
1065
+ }
1066
+ this.advance();
1067
+ }
1068
+ if (this.check("punctuation", ",")) {
1069
+ this.advance();
1070
+ }
1071
+ }
1072
+ this.expect("punctuation", "]");
1073
+ return arr;
1074
+ }
1075
+ /**
1076
+ * Parse object {...}
1077
+ */
1078
+ parseObject() {
1079
+ const obj = {};
1080
+ this.expect("punctuation", "{");
1081
+ while (!this.check("punctuation", "}") && this.position < this.tokens.length) {
1082
+ this.skipNewlines();
1083
+ if (this.check("punctuation", "}")) break;
1084
+ const prop = this.parseProperty();
1085
+ if (prop) {
1086
+ obj[prop.key] = prop.value;
1087
+ }
1088
+ this.skipNewlines();
1089
+ if (this.check("punctuation", ",")) {
1090
+ this.advance();
1091
+ }
1092
+ }
1093
+ this.expect("punctuation", "}");
1094
+ return obj;
1095
+ }
1096
+ /**
1097
+ * Parse position from value
1098
+ */
1099
+ parsePosition(value) {
1100
+ if (Array.isArray(value)) {
1101
+ return {
1102
+ x: Number(value[0]) || 0,
1103
+ y: Number(value[1]) || 0,
1104
+ z: Number(value[2]) || 0
1105
+ };
1106
+ }
1107
+ if (typeof value === "object" && value !== null) {
1108
+ const v = value;
1109
+ return {
1110
+ x: Number(v.x) || 0,
1111
+ y: Number(v.y) || 0,
1112
+ z: Number(v.z) || 0
1113
+ };
1114
+ }
1115
+ return { x: 0, y: 0, z: 0 };
1116
+ }
1117
+ // Helper methods
1118
+ currentToken() {
1119
+ return this.tokens[this.position];
1120
+ }
1121
+ advance() {
1122
+ return this.tokens[this.position++];
1123
+ }
1124
+ check(type, value) {
1125
+ const token = this.currentToken();
1126
+ if (!token) return false;
1127
+ if (token.type !== type) return false;
1128
+ if (value !== void 0 && token.value.toLowerCase() !== value.toLowerCase()) return false;
1129
+ return true;
1130
+ }
1131
+ expect(type, value) {
1132
+ if (this.check(type, value)) {
1133
+ this.advance();
1134
+ return true;
1135
+ }
1136
+ const token = this.currentToken();
1137
+ this.errors.push({
1138
+ line: token?.line || 0,
1139
+ column: token?.column || 0,
1140
+ message: `Expected ${type}${value ? ` '${value}'` : ""}, got ${token?.type || "EOF"} '${token?.value || ""}'`
1141
+ });
1142
+ return false;
1143
+ }
1144
+ expectIdentifier() {
1145
+ const token = this.currentToken();
1146
+ if (token?.type === "identifier" || token?.type === "keyword") {
1147
+ this.advance();
1148
+ return token.value;
1149
+ }
1150
+ this.errors.push({
1151
+ line: token?.line || 0,
1152
+ column: token?.column || 0,
1153
+ message: `Expected identifier, got ${token?.type || "EOF"}`
1154
+ });
1155
+ return null;
1156
+ }
1157
+ /**
1158
+ * Parse animate command: animate target property: "..." from: 0 to: 1 duration: 1000
1159
+ */
1160
+ parseAnimate() {
1161
+ this.expect("keyword", "animate");
1162
+ const target = this.expectIdentifier();
1163
+ if (!target) return null;
1164
+ const properties = {};
1165
+ while (this.position < this.tokens.length) {
1166
+ this.skipNewlines();
1167
+ const t = this.currentToken();
1168
+ if (!t || t.type === "newline" || t.type === "keyword" && this.keywordSet.has(t.value.toLowerCase())) break;
1169
+ const prop = this.parseProperty();
1170
+ if (prop) {
1171
+ properties[prop.key] = prop.value;
1172
+ } else {
1173
+ break;
1174
+ }
1175
+ }
1176
+ return {
1177
+ type: "expression-statement",
1178
+ expression: `animate("${target}", ${JSON.stringify(properties)})`,
1179
+ position: { x: 0, y: 0, z: 0 }
1180
+ };
1181
+ }
1182
+ /**
1183
+ * Parse modify command: modify target { prop: value }
1184
+ */
1185
+ parseModify() {
1186
+ this.expect("keyword", "modify");
1187
+ const target = this.expectIdentifier();
1188
+ if (!target) return null;
1189
+ const properties = {};
1190
+ if (this.check("punctuation", "{")) {
1191
+ this.advance();
1192
+ while (!this.check("punctuation", "}") && this.position < this.tokens.length) {
1193
+ this.skipNewlines();
1194
+ if (this.check("punctuation", "}")) break;
1195
+ const prop = this.parseProperty();
1196
+ if (prop) {
1197
+ properties[prop.key] = prop.value;
1198
+ }
1199
+ this.skipNewlines();
1200
+ }
1201
+ this.expect("punctuation", "}");
1202
+ }
1203
+ return {
1204
+ type: "expression-statement",
1205
+ expression: `modify("${target}", ${JSON.stringify(properties)})`,
1206
+ position: { x: 0, y: 0, z: 0 }
1207
+ };
1208
+ }
1209
+ /**
1210
+ * Parse UI Element: ui2d dashboard#id { ... }
1211
+ */
1212
+ parseUIElement() {
1213
+ const typeToken = this.currentToken();
1214
+ if (!typeToken) return null;
1215
+ const elementType = typeToken.value;
1216
+ this.advance();
1217
+ let elementId = `${elementType}_${Date.now()}`;
1218
+ const token = this.currentToken();
1219
+ if (token?.type === "punctuation" && token.value === "#") {
1220
+ this.advance();
1221
+ const idToken = this.currentToken();
1222
+ if (idToken) {
1223
+ elementId = idToken.value;
1224
+ this.advance();
1225
+ }
1226
+ } else if (token?.type === "identifier" && token.value.startsWith("#")) {
1227
+ elementId = token.value.slice(1) || elementId;
1228
+ this.advance();
1229
+ }
1230
+ const properties = {};
1231
+ if (this.check("punctuation", "{")) {
1232
+ this.advance();
1233
+ while (!this.check("punctuation", "}") && this.position < this.tokens.length) {
1234
+ this.skipNewlines();
1235
+ if (this.check("punctuation", "}")) break;
1236
+ const prop = this.parseProperty();
1237
+ if (prop) {
1238
+ properties[prop.key] = prop.value;
1239
+ }
1240
+ this.skipNewlines();
1241
+ }
1242
+ this.expect("punctuation", "}");
1243
+ }
1244
+ return {
1245
+ type: "ui2d",
1246
+ name: elementType,
1247
+ properties: { id: elementId, ...properties },
1248
+ position: { x: 0, y: 0, z: 0 }
1249
+ };
1250
+ }
1251
+ /**
1252
+ * Parse settings command: settings
1253
+ */
1254
+ parseSettings() {
1255
+ this.expect("keyword", "settings");
1256
+ return {
1257
+ type: "expression-statement",
1258
+ expression: "showSettings()",
1259
+ position: { x: 0, y: 0, z: 0 }
1260
+ };
1261
+ }
1262
+ parseChat() {
1263
+ this.expect("keyword", "chat");
1264
+ return {
1265
+ type: "expression-statement",
1266
+ expression: "openChat()",
1267
+ position: { x: 0, y: 0, z: 0 }
1268
+ };
1269
+ }
1270
+ skipNewlines() {
1271
+ while (this.currentToken()?.type === "newline") {
1272
+ this.advance();
1273
+ }
1274
+ }
1275
+ };
1276
+
1277
+ export { HoloScriptCodeParser };
1278
+ //# sourceMappingURL=chunk-U72GEJZT.js.map
1279
+ //# sourceMappingURL=chunk-U72GEJZT.js.map