@holoscript/core 1.0.0-alpha.1 → 2.0.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 (127) hide show
  1. package/package.json +10 -9
  2. package/src/HoloScript2DParser.js +227 -0
  3. package/src/HoloScript2DParser.ts +5 -0
  4. package/src/HoloScriptCodeParser.js +1102 -0
  5. package/src/HoloScriptCodeParser.ts +145 -20
  6. package/src/HoloScriptDebugger.js +458 -0
  7. package/src/HoloScriptParser.js +338 -0
  8. package/src/HoloScriptPlusParser.js +371 -0
  9. package/src/HoloScriptPlusParser.ts +543 -0
  10. package/src/HoloScriptRuntime.js +1399 -0
  11. package/src/HoloScriptRuntime.test.js +351 -0
  12. package/src/HoloScriptRuntime.ts +257 -3
  13. package/src/HoloScriptTypeChecker.js +356 -0
  14. package/src/__tests__/GraphicsServices.test.js +357 -0
  15. package/src/__tests__/GraphicsServices.test.ts +427 -0
  16. package/src/__tests__/HoloScriptPlusParser.test.js +317 -0
  17. package/src/__tests__/HoloScriptPlusParser.test.ts +392 -0
  18. package/src/__tests__/integration.test.js +336 -0
  19. package/src/__tests__/performance.bench.js +218 -0
  20. package/src/__tests__/type-checker.test.js +60 -0
  21. package/src/__tests__/type-checker.test.ts +73 -0
  22. package/src/index.js +217 -0
  23. package/src/index.ts +158 -18
  24. package/src/interop/Interoperability.js +413 -0
  25. package/src/interop/Interoperability.ts +494 -0
  26. package/src/logger.js +42 -0
  27. package/src/parser/EnhancedParser.js +205 -0
  28. package/src/parser/EnhancedParser.ts +251 -0
  29. package/src/parser/HoloScriptPlusParser.js +928 -0
  30. package/src/parser/HoloScriptPlusParser.ts +1089 -0
  31. package/src/runtime/HoloScriptPlusRuntime.js +674 -0
  32. package/src/runtime/HoloScriptPlusRuntime.ts +861 -0
  33. package/src/runtime/PerformanceTelemetry.js +323 -0
  34. package/src/runtime/PerformanceTelemetry.ts +467 -0
  35. package/src/runtime/RuntimeOptimization.js +361 -0
  36. package/src/runtime/RuntimeOptimization.ts +416 -0
  37. package/src/services/HololandGraphicsPipelineService.js +506 -0
  38. package/src/services/HololandGraphicsPipelineService.ts +662 -0
  39. package/src/services/PlatformPerformanceOptimizer.js +356 -0
  40. package/src/services/PlatformPerformanceOptimizer.ts +503 -0
  41. package/src/state/ReactiveState.js +427 -0
  42. package/src/state/ReactiveState.ts +572 -0
  43. package/src/tools/DeveloperExperience.js +376 -0
  44. package/src/tools/DeveloperExperience.ts +438 -0
  45. package/src/traits/AIDriverTrait.js +322 -0
  46. package/src/traits/AIDriverTrait.test.js +329 -0
  47. package/src/traits/AIDriverTrait.test.ts +357 -0
  48. package/src/traits/AIDriverTrait.ts +474 -0
  49. package/src/traits/LightingTrait.js +313 -0
  50. package/src/traits/LightingTrait.test.js +410 -0
  51. package/src/traits/LightingTrait.test.ts +462 -0
  52. package/src/traits/LightingTrait.ts +505 -0
  53. package/src/traits/MaterialTrait.js +194 -0
  54. package/src/traits/MaterialTrait.test.js +286 -0
  55. package/src/traits/MaterialTrait.test.ts +329 -0
  56. package/src/traits/MaterialTrait.ts +324 -0
  57. package/src/traits/RenderingTrait.js +356 -0
  58. package/src/traits/RenderingTrait.test.js +363 -0
  59. package/src/traits/RenderingTrait.test.ts +427 -0
  60. package/src/traits/RenderingTrait.ts +555 -0
  61. package/src/traits/VRTraitSystem.js +740 -0
  62. package/src/traits/VRTraitSystem.ts +1040 -0
  63. package/src/traits/VoiceInputTrait.js +284 -0
  64. package/src/traits/VoiceInputTrait.test.js +226 -0
  65. package/src/traits/VoiceInputTrait.test.ts +252 -0
  66. package/src/traits/VoiceInputTrait.ts +401 -0
  67. package/src/types/AdvancedTypeSystem.js +226 -0
  68. package/src/types/AdvancedTypeSystem.ts +494 -0
  69. package/src/types/HoloScriptPlus.d.ts +853 -0
  70. package/src/types.js +6 -0
  71. package/src/types.ts +96 -1
  72. package/tsconfig.json +1 -1
  73. package/tsup.config.d.ts +2 -0
  74. package/tsup.config.js +18 -0
  75. package/LICENSE +0 -21
  76. package/dist/chunk-3X2EGU7Z.cjs +0 -52
  77. package/dist/chunk-3X2EGU7Z.cjs.map +0 -1
  78. package/dist/chunk-723TPVHD.js +0 -1074
  79. package/dist/chunk-723TPVHD.js.map +0 -1
  80. package/dist/chunk-EOKNAVDO.cjs +0 -424
  81. package/dist/chunk-EOKNAVDO.cjs.map +0 -1
  82. package/dist/chunk-HQZ3HUMY.js +0 -1087
  83. package/dist/chunk-HQZ3HUMY.js.map +0 -1
  84. package/dist/chunk-KWYIVRIH.js +0 -344
  85. package/dist/chunk-KWYIVRIH.js.map +0 -1
  86. package/dist/chunk-LKH4ZAN6.js +0 -421
  87. package/dist/chunk-LKH4ZAN6.js.map +0 -1
  88. package/dist/chunk-SATNCODL.js +0 -45
  89. package/dist/chunk-SATNCODL.js.map +0 -1
  90. package/dist/chunk-VMZN4EVR.cjs +0 -347
  91. package/dist/chunk-VMZN4EVR.cjs.map +0 -1
  92. package/dist/chunk-VV3UUUYP.cjs +0 -1089
  93. package/dist/chunk-VV3UUUYP.cjs.map +0 -1
  94. package/dist/chunk-XRYTSQHZ.cjs +0 -1076
  95. package/dist/chunk-XRYTSQHZ.cjs.map +0 -1
  96. package/dist/debugger.cjs +0 -19
  97. package/dist/debugger.cjs.map +0 -1
  98. package/dist/debugger.d.cts +0 -171
  99. package/dist/debugger.d.ts +0 -171
  100. package/dist/debugger.js +0 -6
  101. package/dist/debugger.js.map +0 -1
  102. package/dist/index.cjs +0 -755
  103. package/dist/index.cjs.map +0 -1
  104. package/dist/index.d.cts +0 -169
  105. package/dist/index.d.ts +0 -169
  106. package/dist/index.js +0 -699
  107. package/dist/index.js.map +0 -1
  108. package/dist/parser.cjs +0 -13
  109. package/dist/parser.cjs.map +0 -1
  110. package/dist/parser.d.cts +0 -154
  111. package/dist/parser.d.ts +0 -154
  112. package/dist/parser.js +0 -4
  113. package/dist/parser.js.map +0 -1
  114. package/dist/runtime.cjs +0 -13
  115. package/dist/runtime.cjs.map +0 -1
  116. package/dist/runtime.d.cts +0 -147
  117. package/dist/runtime.d.ts +0 -147
  118. package/dist/runtime.js +0 -4
  119. package/dist/runtime.js.map +0 -1
  120. package/dist/type-checker.cjs +0 -16
  121. package/dist/type-checker.cjs.map +0 -1
  122. package/dist/type-checker.d.cts +0 -105
  123. package/dist/type-checker.d.ts +0 -105
  124. package/dist/type-checker.js +0 -3
  125. package/dist/type-checker.js.map +0 -1
  126. package/dist/types-WQSk1Qs2.d.cts +0 -238
  127. package/dist/types-WQSk1Qs2.d.ts +0 -238
package/dist/index.js DELETED
@@ -1,699 +0,0 @@
1
- export { HoloScriptTypeChecker, createTypeChecker } from './chunk-KWYIVRIH.js';
2
- export { HoloScriptDebugger, createDebugger } from './chunk-LKH4ZAN6.js';
3
- export { HoloScriptCodeParser } from './chunk-723TPVHD.js';
4
- import { HoloScriptRuntime } from './chunk-HQZ3HUMY.js';
5
- export { HoloScriptRuntime } from './chunk-HQZ3HUMY.js';
6
- import { logger } from './chunk-SATNCODL.js';
7
- export { ConsoleLogger, NoOpLogger, enableConsoleLogging, logger, resetLogger, setHoloScriptLogger } from './chunk-SATNCODL.js';
8
-
9
- // src/HoloScript2DParser.ts
10
- var UI_SECURITY_CONFIG = {
11
- maxUIElements: 500,
12
- maxNestingDepth: 10,
13
- allowedEventHandlers: ["onClick", "onChange", "onSubmit", "onFocus", "onBlur", "onHover"]
14
- };
15
- var HoloScript2DParser = class {
16
- constructor() {
17
- this.uiElements = /* @__PURE__ */ new Map();
18
- }
19
- /**
20
- * Parse 2D UI element from HoloScript code
21
- */
22
- parse2DElement(code, depth = 0) {
23
- if (depth > UI_SECURITY_CONFIG.maxNestingDepth) {
24
- logger.warn("Max nesting depth exceeded", { depth });
25
- return null;
26
- }
27
- const trimmedCode = code.trim();
28
- const lines = trimmedCode.split("\n");
29
- if (lines.length === 0) return null;
30
- const firstLine = lines[0].trim();
31
- const headerMatch = firstLine.match(/^([\w-]+)\s+(\w+)\s*\{/);
32
- if (!headerMatch) {
33
- logger.warn("Invalid 2D element syntax", { line: firstLine });
34
- return null;
35
- }
36
- const [, elementType, name] = headerMatch;
37
- if (!this.isValidUIElementType(elementType)) {
38
- logger.warn("Invalid UI element type", { elementType });
39
- return null;
40
- }
41
- const startIndex = trimmedCode.indexOf("{");
42
- const endIndex = trimmedCode.lastIndexOf("}");
43
- if (startIndex === -1 || endIndex === -1 || endIndex <= startIndex) {
44
- return null;
45
- }
46
- const innerContent = trimmedCode.slice(startIndex + 1, endIndex).trim();
47
- const innerLines = this.splitIntoLogicalBlocks(innerContent);
48
- const properties = {};
49
- const events = {};
50
- const children = [];
51
- for (const block of innerLines) {
52
- const line = block.trim();
53
- if (!line) continue;
54
- if (line.includes("{")) {
55
- const childNode = this.parse2DElement(line, depth + 1);
56
- if (childNode) children.push(childNode);
57
- continue;
58
- }
59
- const propMatch = line.match(/^(\w+):\s*(.+)$/);
60
- if (propMatch) {
61
- const [, key, rawValue] = propMatch;
62
- if (UI_SECURITY_CONFIG.allowedEventHandlers.includes(key)) {
63
- events[key] = rawValue.trim();
64
- } else {
65
- properties[key] = this.parsePropertyValue(rawValue);
66
- }
67
- }
68
- }
69
- const node = {
70
- type: "2d-element",
71
- elementType,
72
- name,
73
- properties: { ...this.getDefaultProperties(elementType), ...properties },
74
- events: Object.keys(events).length > 0 ? events : void 0,
75
- children: children.length > 0 ? children : void 0
76
- };
77
- if (depth === 0) {
78
- if (this.uiElements.size >= UI_SECURITY_CONFIG.maxUIElements) {
79
- logger.warn("Max UI elements limit reached");
80
- return null;
81
- }
82
- this.uiElements.set(name, node);
83
- }
84
- return node;
85
- }
86
- splitIntoLogicalBlocks(content) {
87
- const blocks = [];
88
- let currentBlock = "";
89
- let bracketDepth = 0;
90
- for (let i = 0; i < content.length; i++) {
91
- const char = content[i];
92
- if (char === "{") bracketDepth++;
93
- if (char === "}") bracketDepth--;
94
- currentBlock += char;
95
- if (bracketDepth === 0) {
96
- if (char === "\n" || i === content.length - 1) {
97
- const trimmed = currentBlock.trim();
98
- if (trimmed) blocks.push(trimmed);
99
- currentBlock = "";
100
- }
101
- }
102
- }
103
- const finalTrimmed = currentBlock.trim();
104
- if (finalTrimmed) blocks.push(finalTrimmed);
105
- return blocks;
106
- }
107
- /**
108
- * Parse voice command for 2D UI creation
109
- */
110
- parse2DVoiceCommand(command) {
111
- const tokens = command.toLowerCase().trim().split(/\s+/);
112
- if (tokens.length < 3) return null;
113
- const action = tokens[0];
114
- const elementType = tokens[1];
115
- const name = tokens[2];
116
- if (action !== "create" && action !== "add") return null;
117
- if (!this.isValidUIElementType(elementType)) return null;
118
- const node = {
119
- type: "2d-element",
120
- elementType,
121
- name,
122
- properties: this.getDefaultProperties(elementType)
123
- };
124
- this.uiElements.set(name, node);
125
- return node;
126
- }
127
- /**
128
- * Parse gesture for 2D UI interaction
129
- */
130
- parse2DGesture(gestureType, position) {
131
- switch (gestureType) {
132
- case "tap":
133
- return this.createQuick2DElement("button", `button_${Date.now()}`, position);
134
- case "double-tap":
135
- return this.createQuick2DElement("textinput", `input_${Date.now()}`, position);
136
- case "long-press":
137
- return this.createQuick2DElement("panel", `panel_${Date.now()}`, position);
138
- default:
139
- return null;
140
- }
141
- }
142
- createQuick2DElement(elementType, name, position) {
143
- const node = {
144
- type: "2d-element",
145
- elementType,
146
- name,
147
- properties: {
148
- ...this.getDefaultProperties(elementType),
149
- x: position.x,
150
- y: position.y
151
- }
152
- };
153
- this.uiElements.set(name, node);
154
- return node;
155
- }
156
- isValidUIElementType(type) {
157
- const validTypes = [
158
- "canvas",
159
- "button",
160
- "textinput",
161
- "panel",
162
- "text",
163
- "image",
164
- "list",
165
- "modal",
166
- "slider",
167
- "toggle",
168
- "dropdown",
169
- "flex-container",
170
- "grid-container",
171
- "scroll-view",
172
- "tab-view"
173
- ];
174
- return validTypes.includes(type);
175
- }
176
- parsePropertyValue(value) {
177
- const trimmed = value.trim();
178
- if (trimmed.startsWith('"') && trimmed.endsWith('"') || trimmed.startsWith("'") && trimmed.endsWith("'")) {
179
- return trimmed.slice(1, -1);
180
- }
181
- if (!isNaN(parseFloat(trimmed)) && isFinite(parseFloat(trimmed))) {
182
- return parseFloat(trimmed);
183
- }
184
- if (trimmed === "true") return true;
185
- if (trimmed === "false") return false;
186
- if (trimmed.startsWith("[") && trimmed.endsWith("]")) {
187
- const items = trimmed.slice(1, -1).split(",").map(
188
- (item) => this.parsePropertyValue(item.trim())
189
- );
190
- return items;
191
- }
192
- return trimmed;
193
- }
194
- getDefaultProperties(elementType) {
195
- const defaults = {
196
- "canvas": { width: 800, height: 600, backgroundColor: "#ffffff" },
197
- "button": { text: "Button", width: 120, height: 40, backgroundColor: "#007bff", color: "#ffffff", borderRadius: 4 },
198
- "textinput": { placeholder: "", width: 200, height: 36, fontSize: 14, borderColor: "#cccccc", borderWidth: 1, borderRadius: 4 },
199
- "panel": { width: 200, height: 200, backgroundColor: "#f0f0f0", borderRadius: 0 },
200
- "text": { content: "Text", fontSize: 16, color: "#000000", fontFamily: "sans-serif" },
201
- "image": { src: "", width: 100, height: 100, fit: "cover" },
202
- "list": { items: [], itemHeight: 40, width: 200, height: 300 },
203
- "modal": { title: "Modal", width: 400, height: 300, visible: false, backgroundColor: "#ffffff" },
204
- "slider": { min: 0, max: 100, value: 50, width: 200 },
205
- "toggle": { checked: false, width: 50, height: 24 },
206
- "dropdown": { options: [], selected: null, width: 200 },
207
- "flex-container": { direction: "row", gap: 10, padding: 10 },
208
- "grid-container": { columns: 3, gap: 10, padding: 10 },
209
- "scroll-view": { width: 300, height: 400, scrollDirection: "vertical" },
210
- "tab-view": { tabs: [], activeTabId: null, tabPosition: "top", width: 400, height: 300 }
211
- };
212
- return { ...defaults[elementType] };
213
- }
214
- getUIElements() {
215
- return new Map(this.uiElements);
216
- }
217
- findElement(name) {
218
- return this.uiElements.get(name) || null;
219
- }
220
- clear() {
221
- this.uiElements.clear();
222
- }
223
- };
224
-
225
- // src/HoloScriptParser.ts
226
- var HOLOSCRIPT_SECURITY_CONFIG = {
227
- maxCommandLength: 1e3,
228
- maxTokens: 100,
229
- suspiciousKeywords: [
230
- "process",
231
- "require",
232
- "eval",
233
- "import",
234
- "constructor",
235
- "prototype",
236
- "__proto__",
237
- "fs",
238
- "child_process",
239
- "exec",
240
- "spawn",
241
- "fetch",
242
- "xmlhttprequest"
243
- ],
244
- allowedUIElements: [
245
- "canvas",
246
- "button",
247
- "textinput",
248
- "panel",
249
- "text",
250
- "image",
251
- "list",
252
- "modal",
253
- "slider",
254
- "toggle",
255
- "dropdown",
256
- "flex-container",
257
- "grid-container",
258
- "scroll-view"
259
- ]
260
- };
261
- var HoloScriptParser = class {
262
- constructor() {
263
- this.ast = [];
264
- this.parser2D = new HoloScript2DParser();
265
- }
266
- /**
267
- * Parse voice command into AST nodes
268
- */
269
- parseVoiceCommand(command) {
270
- if (command.command.length > HOLOSCRIPT_SECURITY_CONFIG.maxCommandLength) {
271
- logger.warn("Command too long", {
272
- length: command.command.length,
273
- limit: HOLOSCRIPT_SECURITY_CONFIG.maxCommandLength
274
- });
275
- return [];
276
- }
277
- const rawTokens = this.tokenizeCommand(command.command.toLowerCase());
278
- const tokens = this.sanitizeTokens(rawTokens);
279
- if (tokens.length === 0) return [];
280
- if (tokens.length > HOLOSCRIPT_SECURITY_CONFIG.maxTokens) {
281
- logger.warn("Too many tokens in command", {
282
- tokenCount: tokens.length,
283
- limit: HOLOSCRIPT_SECURITY_CONFIG.maxTokens
284
- });
285
- return [];
286
- }
287
- const commandType = tokens[0];
288
- if ((commandType === "create" || commandType === "add") && tokens.length > 1) {
289
- const elementType = tokens[1];
290
- if (HOLOSCRIPT_SECURITY_CONFIG.allowedUIElements.includes(elementType)) {
291
- return this.parse2DUICommand(command.command);
292
- }
293
- }
294
- switch (commandType) {
295
- case "create":
296
- case "summon":
297
- return this.parseCreateCommand(tokens.slice(1), command.spatialContext);
298
- case "connect":
299
- return this.parseConnectCommand(tokens.slice(1));
300
- case "execute":
301
- case "run":
302
- return this.parseExecuteCommand(tokens.slice(1));
303
- case "debug":
304
- return this.parseDebugCommand(tokens.slice(1));
305
- case "visualize":
306
- return this.parseVisualizeCommand(tokens.slice(1));
307
- default:
308
- return this.parseGenericCommand(tokens);
309
- }
310
- }
311
- parse2DUICommand(command) {
312
- const ui2DNode = this.parser2D.parse2DVoiceCommand(command);
313
- if (!ui2DNode) return [];
314
- const astNode = {
315
- type: "2d-ui",
316
- uiElementType: ui2DNode.elementType,
317
- name: ui2DNode.name,
318
- properties: ui2DNode.properties,
319
- events: ui2DNode.events,
320
- children: ui2DNode.children
321
- };
322
- return [astNode];
323
- }
324
- /**
325
- * Parse gesture input
326
- */
327
- parseGesture(gesture) {
328
- switch (gesture.type) {
329
- case "pinch":
330
- return this.parsePinchGesture(gesture);
331
- case "swipe":
332
- return this.parseSwipeGesture(gesture);
333
- case "rotate":
334
- return this.parseRotateGesture(gesture);
335
- case "grab":
336
- return this.parseGrabGesture(gesture);
337
- default:
338
- return [];
339
- }
340
- }
341
- parseCreateCommand(tokens, position) {
342
- if (tokens.length < 2) return [];
343
- const shape = tokens[0];
344
- const name = tokens[1];
345
- switch (shape) {
346
- case "orb":
347
- case "sphere":
348
- return [this.createOrbNode(name, position)];
349
- case "function":
350
- return [this.createFunctionNode(name, tokens.slice(2), position)];
351
- case "gate":
352
- return [this.createGateNode(name, tokens.slice(2), position)];
353
- case "stream":
354
- return [this.createStreamNode(name, tokens.slice(2), position)];
355
- default:
356
- return [this.createGenericNode(shape, name, position)];
357
- }
358
- }
359
- parseConnectCommand(tokens) {
360
- if (tokens.length < 3) return [];
361
- const from = tokens[0];
362
- const to = tokens[2];
363
- const dataType = tokens.length > 3 ? tokens[3] : "any";
364
- return [{
365
- type: "connection",
366
- from,
367
- to,
368
- dataType,
369
- bidirectional: tokens.includes("bidirectional") || tokens.includes("both")
370
- }];
371
- }
372
- createOrbNode(name, position) {
373
- return {
374
- type: "orb",
375
- name,
376
- position: position || { x: 0, y: 0, z: 0 },
377
- hologram: {
378
- shape: "orb",
379
- color: "#00ffff",
380
- size: 1,
381
- glow: true,
382
- interactive: true
383
- },
384
- properties: {},
385
- methods: []
386
- };
387
- }
388
- createFunctionNode(name, params, position) {
389
- const parameters = [];
390
- let inParams = false;
391
- for (const param of params) {
392
- if (param === "with" || param === "parameters") {
393
- inParams = true;
394
- continue;
395
- }
396
- if (inParams && param !== "do" && param !== "execute") {
397
- parameters.push({
398
- type: "parameter",
399
- name: param,
400
- dataType: "any"
401
- });
402
- }
403
- }
404
- return {
405
- type: "function",
406
- name,
407
- parameters,
408
- body: [],
409
- position: position || { x: 0, y: 0, z: 0 },
410
- hologram: {
411
- shape: "cube",
412
- color: "#ff6b35",
413
- size: 1.5,
414
- glow: true,
415
- interactive: true
416
- }
417
- };
418
- }
419
- createGateNode(_name, params, position) {
420
- const condition = params.join(" ").replace("condition", "").trim();
421
- return {
422
- type: "gate",
423
- condition,
424
- truePath: [],
425
- falsePath: [],
426
- position: position || { x: 0, y: 0, z: 0 },
427
- hologram: {
428
- shape: "pyramid",
429
- color: "#4ecdc4",
430
- size: 1,
431
- glow: true,
432
- interactive: true
433
- }
434
- };
435
- }
436
- createStreamNode(name, params, position) {
437
- return {
438
- type: "stream",
439
- name,
440
- source: params[0] || "unknown",
441
- transformations: [],
442
- position: position || { x: 0, y: 0, z: 0 },
443
- hologram: {
444
- shape: "cylinder",
445
- color: "#45b7d1",
446
- size: 2,
447
- glow: true,
448
- interactive: true
449
- }
450
- };
451
- }
452
- createGenericNode(shape, name, position) {
453
- return {
454
- type: shape,
455
- name,
456
- position: position || { x: 0, y: 0, z: 0 },
457
- hologram: {
458
- shape,
459
- color: "#ffffff",
460
- size: 1,
461
- glow: false,
462
- interactive: true
463
- }
464
- };
465
- }
466
- parsePinchGesture(gesture) {
467
- return [{
468
- type: "create",
469
- position: gesture.position,
470
- hologram: { shape: "orb", color: "#ff0000", size: 0.5, glow: true, interactive: true }
471
- }];
472
- }
473
- parseSwipeGesture(gesture) {
474
- if (!gesture.direction) return [];
475
- return [{
476
- type: "connect",
477
- position: gesture.position,
478
- hologram: { shape: "cylinder", color: "#00ff00", size: gesture.magnitude, glow: true, interactive: false }
479
- }];
480
- }
481
- parseRotateGesture(gesture) {
482
- return [{
483
- type: "modify",
484
- position: gesture.position,
485
- hologram: { shape: "sphere", color: "#ffff00", size: 0.8, glow: true, interactive: true }
486
- }];
487
- }
488
- parseGrabGesture(gesture) {
489
- return [{
490
- type: "select",
491
- position: gesture.position,
492
- hologram: { shape: "cube", color: "#ff00ff", size: 0.3, glow: true, interactive: true }
493
- }];
494
- }
495
- tokenizeCommand(command) {
496
- return command.toLowerCase().replace(/[^\w\s]/g, " ").split(/\s+/).filter((token) => token.length > 0);
497
- }
498
- sanitizeTokens(tokens) {
499
- return tokens.filter((token) => {
500
- const isSuspicious = HOLOSCRIPT_SECURITY_CONFIG.suspiciousKeywords.some(
501
- (keyword) => token.includes(keyword)
502
- );
503
- if (isSuspicious) {
504
- logger.warn("Suspicious token blocked", { token });
505
- return false;
506
- }
507
- return true;
508
- });
509
- }
510
- parseExecuteCommand(tokens) {
511
- return [{
512
- type: "execute",
513
- target: tokens[0] || "unknown",
514
- hologram: { shape: "sphere", color: "#ff4500", size: 1.2, glow: true, interactive: false }
515
- }];
516
- }
517
- parseDebugCommand(tokens) {
518
- return [{
519
- type: "debug",
520
- target: tokens[0] || "program",
521
- hologram: { shape: "pyramid", color: "#ff1493", size: 0.8, glow: true, interactive: true }
522
- }];
523
- }
524
- parseVisualizeCommand(tokens) {
525
- return [{
526
- type: "visualize",
527
- target: tokens[0] || "data",
528
- hologram: { shape: "cylinder", color: "#32cd32", size: 1.5, glow: true, interactive: true }
529
- }];
530
- }
531
- parseGenericCommand(tokens) {
532
- return [{
533
- type: "generic",
534
- command: tokens.join(" "),
535
- hologram: { shape: "orb", color: "#808080", size: 0.5, glow: false, interactive: true }
536
- }];
537
- }
538
- getAST() {
539
- return [...this.ast];
540
- }
541
- addNode(node) {
542
- this.ast.push(node);
543
- }
544
- clear() {
545
- this.ast = [];
546
- }
547
- findNode(name) {
548
- return this.ast.find((node) => "name" in node && node.name === name) || null;
549
- }
550
- getNodesAtPosition(position, radius = 1) {
551
- return this.ast.filter((node) => {
552
- if (!node.position) return false;
553
- const distance = Math.sqrt(
554
- Math.pow(node.position.x - position.x, 2) + Math.pow(node.position.y - position.y, 2) + Math.pow(node.position.z - position.z, 2)
555
- );
556
- return distance <= radius;
557
- });
558
- }
559
- parse2DCode(code) {
560
- return this.parser2D.parse2DElement(code);
561
- }
562
- get2DParser() {
563
- return this.parser2D;
564
- }
565
- };
566
-
567
- // src/index.ts
568
- var HOLOSCRIPT_VERSION = "1.0.0-alpha.1";
569
- var HOLOSCRIPT_SUPPORTED_PLATFORMS = [
570
- "WebXR",
571
- "Oculus Quest",
572
- "HTC Vive",
573
- "Valve Index",
574
- "Apple Vision Pro",
575
- "Windows Mixed Reality"
576
- ];
577
- var HOLOSCRIPT_VOICE_COMMANDS = [
578
- // 3D VR Commands
579
- "create orb [name]",
580
- "summon function [name]",
581
- "connect [from] to [to]",
582
- "execute [function]",
583
- "debug program",
584
- "visualize [data]",
585
- "gate [condition]",
586
- "stream [source] through [transformations]",
587
- // 2D UI Commands
588
- "create button [name]",
589
- "add textinput [name]",
590
- "create panel [name]",
591
- "add slider [name]"
592
- ];
593
- var HOLOSCRIPT_GESTURES = [
594
- "pinch - create object",
595
- "swipe - connect objects",
596
- "rotate - modify properties",
597
- "grab - select object",
598
- "spread - expand view",
599
- "fist - execute action"
600
- ];
601
- var HOLOSCRIPT_DEMO_SCRIPTS = {
602
- helloWorld: `orb greeting {
603
- message: "Hello, HoloScript World!"
604
- color: "#00ffff"
605
- glow: true
606
- }
607
-
608
- function displayGreeting() {
609
- show greeting
610
- }`,
611
- aiAgent: `orb agentCore {
612
- personality: "helpful"
613
- capabilities: ["conversation", "problem_solving", "learning"]
614
- energy: 100
615
- }
616
-
617
- function processQuery(query: string): string {
618
- analyze query
619
- generate response
620
- return response
621
- }`,
622
- neuralNetwork: `orb inputLayer { neurons: 784 }
623
- orb hiddenLayer { neurons: 128 }
624
- orb outputLayer { neurons: 10 }
625
-
626
- connect inputLayer to hiddenLayer as "weights"
627
- connect hiddenLayer to outputLayer as "weights"
628
-
629
- function trainNetwork(data: array): object {
630
- forward_pass data
631
- calculate_loss
632
- backward_pass
633
- update_weights
634
- return metrics
635
- }`,
636
- loginForm: `button loginBtn {
637
- text: "Login"
638
- x: 100
639
- y: 150
640
- width: 200
641
- height: 40
642
- onClick: handleLogin
643
- }
644
-
645
- textinput usernameInput {
646
- placeholder: "Username"
647
- x: 100
648
- y: 50
649
- width: 200
650
- height: 36
651
- }
652
-
653
- textinput passwordInput {
654
- placeholder: "Password"
655
- x: 100
656
- y: 100
657
- width: 200
658
- height: 36
659
- }`,
660
- dashboard: `panel sidebar {
661
- x: 0
662
- y: 0
663
- width: 200
664
- height: 600
665
- backgroundColor: "#2c3e50"
666
- }
667
-
668
- text title {
669
- content: "Dashboard"
670
- x: 220
671
- y: 20
672
- fontSize: 24
673
- color: "#34495e"
674
- }
675
-
676
- button refreshBtn {
677
- text: "Refresh Data"
678
- x: 220
679
- y: 60
680
- onClick: refreshData
681
- }`
682
- };
683
- function createHoloScriptEnvironment() {
684
- return {
685
- parser: new HoloScriptParser(),
686
- runtime: new HoloScriptRuntime(),
687
- version: HOLOSCRIPT_VERSION
688
- };
689
- }
690
- function isHoloScriptSupported() {
691
- if (typeof globalThis === "undefined") return false;
692
- const win = globalThis;
693
- if (!win.window) return false;
694
- return !!(win.window.navigator?.xr || win.window.navigator?.getVRDisplays || win.window.webkitGetUserMedia);
695
- }
696
-
697
- export { HOLOSCRIPT_DEMO_SCRIPTS, HOLOSCRIPT_GESTURES, HOLOSCRIPT_SUPPORTED_PLATFORMS, HOLOSCRIPT_VERSION, HOLOSCRIPT_VOICE_COMMANDS, HoloScript2DParser, HoloScriptParser, createHoloScriptEnvironment, isHoloScriptSupported };
698
- //# sourceMappingURL=index.js.map
699
- //# sourceMappingURL=index.js.map