@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.
- package/LICENSE +21 -0
- package/dist/chunk-3N67RLQP.cjs +1298 -0
- package/dist/chunk-3N67RLQP.cjs.map +1 -0
- package/dist/chunk-3X2EGU7Z.cjs +52 -0
- package/dist/chunk-3X2EGU7Z.cjs.map +1 -0
- package/dist/chunk-4CV4JOE5.js +24 -0
- package/dist/chunk-4CV4JOE5.js.map +1 -0
- package/dist/chunk-4OHVW4XR.cjs +1027 -0
- package/dist/chunk-4OHVW4XR.cjs.map +1 -0
- package/dist/chunk-CZLDE2OZ.cjs +28 -0
- package/dist/chunk-CZLDE2OZ.cjs.map +1 -0
- package/{src/HoloScriptRuntime.ts → dist/chunk-EU6CZMGJ.js} +437 -794
- package/dist/chunk-EU6CZMGJ.js.map +1 -0
- package/dist/chunk-KWYIVRIH.js +344 -0
- package/dist/chunk-KWYIVRIH.js.map +1 -0
- package/dist/chunk-MCP6D4LT.js +1025 -0
- package/dist/chunk-MCP6D4LT.js.map +1 -0
- package/dist/chunk-SATNCODL.js +45 -0
- package/dist/chunk-SATNCODL.js.map +1 -0
- package/dist/chunk-VMZN4EVR.cjs +347 -0
- package/dist/chunk-VMZN4EVR.cjs.map +1 -0
- package/{src/HoloScriptDebugger.ts → dist/chunk-VYIDLUCV.js} +118 -257
- package/dist/chunk-VYIDLUCV.js.map +1 -0
- package/dist/chunk-WFI4T3XB.cjs +424 -0
- package/dist/chunk-WFI4T3XB.cjs.map +1 -0
- package/dist/debugger.cjs +20 -0
- package/dist/debugger.cjs.map +1 -0
- package/dist/debugger.d.cts +171 -0
- package/dist/debugger.d.ts +171 -0
- package/dist/debugger.js +7 -0
- package/dist/debugger.js.map +1 -0
- package/dist/index.cjs +6006 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2482 -0
- package/dist/index.d.ts +2482 -0
- package/dist/index.js +5926 -0
- package/dist/index.js.map +1 -0
- package/dist/parser.cjs +14 -0
- package/dist/parser.cjs.map +1 -0
- package/dist/parser.d.cts +139 -0
- package/dist/parser.d.ts +139 -0
- package/dist/parser.js +5 -0
- package/dist/parser.js.map +1 -0
- package/dist/runtime.cjs +14 -0
- package/dist/runtime.cjs.map +1 -0
- package/dist/runtime.d.cts +180 -0
- package/dist/runtime.d.ts +180 -0
- package/dist/runtime.js +5 -0
- package/dist/runtime.js.map +1 -0
- package/dist/type-checker.cjs +17 -0
- package/dist/type-checker.cjs.map +1 -0
- package/dist/type-checker.d.cts +105 -0
- package/dist/type-checker.d.ts +105 -0
- package/dist/type-checker.js +4 -0
- package/dist/type-checker.js.map +1 -0
- package/dist/types-D6g4ACjP.d.cts +262 -0
- package/dist/types-D6g4ACjP.d.ts +262 -0
- package/package.json +11 -8
- package/src/HoloScript2DParser.js +0 -227
- package/src/HoloScript2DParser.ts +0 -261
- package/src/HoloScriptCodeParser.js +0 -1102
- package/src/HoloScriptCodeParser.ts +0 -1188
- package/src/HoloScriptDebugger.js +0 -458
- package/src/HoloScriptParser.js +0 -338
- package/src/HoloScriptParser.ts +0 -397
- package/src/HoloScriptPlusParser.js +0 -371
- package/src/HoloScriptPlusParser.ts +0 -543
- package/src/HoloScriptRuntime.js +0 -1399
- package/src/HoloScriptRuntime.test.js +0 -351
- package/src/HoloScriptRuntime.test.ts +0 -436
- package/src/HoloScriptTypeChecker.js +0 -356
- package/src/HoloScriptTypeChecker.ts +0 -475
- package/src/__tests__/GraphicsServices.test.js +0 -357
- package/src/__tests__/GraphicsServices.test.ts +0 -427
- package/src/__tests__/HoloScriptPlusParser.test.js +0 -317
- package/src/__tests__/HoloScriptPlusParser.test.ts +0 -392
- package/src/__tests__/integration.test.js +0 -336
- package/src/__tests__/integration.test.ts +0 -416
- package/src/__tests__/performance.bench.js +0 -218
- package/src/__tests__/performance.bench.ts +0 -262
- package/src/__tests__/type-checker.test.js +0 -60
- package/src/__tests__/type-checker.test.ts +0 -73
- package/src/index.js +0 -217
- package/src/index.ts +0 -426
- package/src/interop/Interoperability.js +0 -413
- package/src/interop/Interoperability.ts +0 -494
- package/src/logger.js +0 -42
- package/src/logger.ts +0 -57
- package/src/parser/EnhancedParser.js +0 -205
- package/src/parser/EnhancedParser.ts +0 -251
- package/src/parser/HoloScriptPlusParser.js +0 -928
- package/src/parser/HoloScriptPlusParser.ts +0 -1089
- package/src/runtime/HoloScriptPlusRuntime.js +0 -674
- package/src/runtime/HoloScriptPlusRuntime.ts +0 -861
- package/src/runtime/PerformanceTelemetry.js +0 -323
- package/src/runtime/PerformanceTelemetry.ts +0 -467
- package/src/runtime/RuntimeOptimization.js +0 -361
- package/src/runtime/RuntimeOptimization.ts +0 -416
- package/src/services/HololandGraphicsPipelineService.js +0 -506
- package/src/services/HololandGraphicsPipelineService.ts +0 -662
- package/src/services/PlatformPerformanceOptimizer.js +0 -356
- package/src/services/PlatformPerformanceOptimizer.ts +0 -503
- package/src/state/ReactiveState.js +0 -427
- package/src/state/ReactiveState.ts +0 -572
- package/src/tools/DeveloperExperience.js +0 -376
- package/src/tools/DeveloperExperience.ts +0 -438
- package/src/traits/AIDriverTrait.js +0 -322
- package/src/traits/AIDriverTrait.test.js +0 -329
- package/src/traits/AIDriverTrait.test.ts +0 -357
- package/src/traits/AIDriverTrait.ts +0 -474
- package/src/traits/LightingTrait.js +0 -313
- package/src/traits/LightingTrait.test.js +0 -410
- package/src/traits/LightingTrait.test.ts +0 -462
- package/src/traits/LightingTrait.ts +0 -505
- package/src/traits/MaterialTrait.js +0 -194
- package/src/traits/MaterialTrait.test.js +0 -286
- package/src/traits/MaterialTrait.test.ts +0 -329
- package/src/traits/MaterialTrait.ts +0 -324
- package/src/traits/RenderingTrait.js +0 -356
- package/src/traits/RenderingTrait.test.js +0 -363
- package/src/traits/RenderingTrait.test.ts +0 -427
- package/src/traits/RenderingTrait.ts +0 -555
- package/src/traits/VRTraitSystem.js +0 -740
- package/src/traits/VRTraitSystem.ts +0 -1040
- package/src/traits/VoiceInputTrait.js +0 -284
- package/src/traits/VoiceInputTrait.test.js +0 -226
- package/src/traits/VoiceInputTrait.test.ts +0 -252
- package/src/traits/VoiceInputTrait.ts +0 -401
- package/src/types/AdvancedTypeSystem.js +0 -226
- package/src/types/AdvancedTypeSystem.ts +0 -494
- package/src/types/HoloScriptPlus.d.ts +0 -853
- package/src/types.js +0 -6
- package/src/types.ts +0 -369
- package/tsconfig.json +0 -23
- package/tsup.config.d.ts +0 -2
- package/tsup.config.js +0 -18
- package/tsup.config.ts +0 -19
|
@@ -0,0 +1,1298 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk3X2EGU7Z_cjs = require('./chunk-3X2EGU7Z.cjs');
|
|
4
|
+
|
|
5
|
+
// src/HoloScriptRuntime.ts
|
|
6
|
+
var RUNTIME_SECURITY_LIMITS = {
|
|
7
|
+
maxExecutionDepth: 50,
|
|
8
|
+
maxTotalNodes: 1e3,
|
|
9
|
+
maxExecutionTimeMs: 5e3,
|
|
10
|
+
maxParticlesPerSystem: 1e3,
|
|
11
|
+
maxCallStackDepth: 100
|
|
12
|
+
};
|
|
13
|
+
var HoloScriptRuntime = class {
|
|
14
|
+
constructor(_importLoader) {
|
|
15
|
+
this.particleSystems = /* @__PURE__ */ new Map();
|
|
16
|
+
this.executionHistory = [];
|
|
17
|
+
this.startTime = 0;
|
|
18
|
+
this.nodeCount = 0;
|
|
19
|
+
this.callStack = [];
|
|
20
|
+
this.eventHandlers = /* @__PURE__ */ new Map();
|
|
21
|
+
this.animations = /* @__PURE__ */ new Map();
|
|
22
|
+
this.uiElements = /* @__PURE__ */ new Map();
|
|
23
|
+
this.context = this.createEmptyContext();
|
|
24
|
+
this.currentScope = { variables: this.context.variables };
|
|
25
|
+
this.builtinFunctions = this.initBuiltins();
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Initialize built-in functions
|
|
29
|
+
*/
|
|
30
|
+
initBuiltins() {
|
|
31
|
+
const builtins = /* @__PURE__ */ new Map();
|
|
32
|
+
builtins.set("show", (args) => {
|
|
33
|
+
const target = String(args[0]);
|
|
34
|
+
const element = this.uiElements.get(target);
|
|
35
|
+
if (element) element.visible = true;
|
|
36
|
+
const hologram = this.context.hologramState.get(target);
|
|
37
|
+
if (hologram) {
|
|
38
|
+
this.createParticleEffect(`${target}_show`, { x: 0, y: 0, z: 0 }, hologram.color, 15);
|
|
39
|
+
}
|
|
40
|
+
chunk3X2EGU7Z_cjs.logger.info("show", { target });
|
|
41
|
+
return { shown: target };
|
|
42
|
+
});
|
|
43
|
+
builtins.set("hide", (args) => {
|
|
44
|
+
const target = String(args[0]);
|
|
45
|
+
const element = this.uiElements.get(target);
|
|
46
|
+
if (element) element.visible = false;
|
|
47
|
+
chunk3X2EGU7Z_cjs.logger.info("hide", { target });
|
|
48
|
+
return { hidden: target };
|
|
49
|
+
});
|
|
50
|
+
builtins.set("pulse", (args) => {
|
|
51
|
+
const target = String(args[0]);
|
|
52
|
+
const options = args[1] || {};
|
|
53
|
+
const duration = Number(options.duration) || 1e3;
|
|
54
|
+
const color = String(options.color || "#ffffff");
|
|
55
|
+
const position = this.context.spatialMemory.get(target) || { x: 0, y: 0, z: 0 };
|
|
56
|
+
this.createParticleEffect(`${target}_pulse`, position, color, 30);
|
|
57
|
+
return { pulsing: target, duration };
|
|
58
|
+
});
|
|
59
|
+
builtins.set("animate", (args) => {
|
|
60
|
+
const target = String(args[0]);
|
|
61
|
+
const options = args[1] || {};
|
|
62
|
+
const animation = {
|
|
63
|
+
target,
|
|
64
|
+
property: String(options.property || "position.y"),
|
|
65
|
+
from: Number(options.from || 0),
|
|
66
|
+
to: Number(options.to || 1),
|
|
67
|
+
duration: Number(options.duration || 1e3),
|
|
68
|
+
startTime: Date.now(),
|
|
69
|
+
easing: String(options.easing || "linear"),
|
|
70
|
+
loop: Boolean(options.loop),
|
|
71
|
+
yoyo: Boolean(options.yoyo)
|
|
72
|
+
};
|
|
73
|
+
this.animations.set(`${target}_${animation.property}`, animation);
|
|
74
|
+
return { animating: target, animation };
|
|
75
|
+
});
|
|
76
|
+
builtins.set("spawn", (args) => {
|
|
77
|
+
const target = String(args[0]);
|
|
78
|
+
const position = args[1] || { x: 0, y: 0, z: 0 };
|
|
79
|
+
this.context.spatialMemory.set(target, position);
|
|
80
|
+
this.createParticleEffect(`${target}_spawn`, position, "#00ff00", 25);
|
|
81
|
+
return { spawned: target, at: position };
|
|
82
|
+
});
|
|
83
|
+
builtins.set("move", (args) => {
|
|
84
|
+
const target = String(args[0]);
|
|
85
|
+
const position = args[1] || { x: 0, y: 0, z: 0 };
|
|
86
|
+
const current = this.context.spatialMemory.get(target);
|
|
87
|
+
if (current) {
|
|
88
|
+
this.context.spatialMemory.set(target, position);
|
|
89
|
+
this.createConnectionStream(target, `${target}_dest`, current, position, "move");
|
|
90
|
+
}
|
|
91
|
+
return { moved: target, to: position };
|
|
92
|
+
});
|
|
93
|
+
builtins.set("set", (args) => {
|
|
94
|
+
const target = String(args[0]);
|
|
95
|
+
const value = args[1];
|
|
96
|
+
this.setVariable(target, value);
|
|
97
|
+
return { set: target, value };
|
|
98
|
+
});
|
|
99
|
+
builtins.set("get", (args) => {
|
|
100
|
+
const target = String(args[0]);
|
|
101
|
+
return this.getVariable(target);
|
|
102
|
+
});
|
|
103
|
+
builtins.set("add", (args) => Number(args[0]) + Number(args[1]));
|
|
104
|
+
builtins.set("subtract", (args) => Number(args[0]) - Number(args[1]));
|
|
105
|
+
builtins.set("multiply", (args) => Number(args[0]) * Number(args[1]));
|
|
106
|
+
builtins.set("divide", (args) => Number(args[1]) !== 0 ? Number(args[0]) / Number(args[1]) : 0);
|
|
107
|
+
builtins.set("mod", (args) => Number(args[0]) % Number(args[1]));
|
|
108
|
+
builtins.set("abs", (args) => Math.abs(Number(args[0])));
|
|
109
|
+
builtins.set("floor", (args) => Math.floor(Number(args[0])));
|
|
110
|
+
builtins.set("ceil", (args) => Math.ceil(Number(args[0])));
|
|
111
|
+
builtins.set("round", (args) => Math.round(Number(args[0])));
|
|
112
|
+
builtins.set("min", (args) => Math.min(...args.map(Number)));
|
|
113
|
+
builtins.set("max", (args) => Math.max(...args.map(Number)));
|
|
114
|
+
builtins.set("random", () => Math.random());
|
|
115
|
+
builtins.set("concat", (args) => args.map(String).join(""));
|
|
116
|
+
builtins.set("length", (args) => {
|
|
117
|
+
const val = args[0];
|
|
118
|
+
if (typeof val === "string") return val.length;
|
|
119
|
+
if (Array.isArray(val)) return val.length;
|
|
120
|
+
return 0;
|
|
121
|
+
});
|
|
122
|
+
builtins.set("substring", (args) => String(args[0]).substring(Number(args[1]), Number(args[2])));
|
|
123
|
+
builtins.set("uppercase", (args) => String(args[0]).toUpperCase());
|
|
124
|
+
builtins.set("lowercase", (args) => String(args[0]).toLowerCase());
|
|
125
|
+
builtins.set("push", (args) => {
|
|
126
|
+
const arr = args[0];
|
|
127
|
+
if (Array.isArray(arr)) {
|
|
128
|
+
arr.push(args[1]);
|
|
129
|
+
return arr;
|
|
130
|
+
}
|
|
131
|
+
return [args[0], args[1]];
|
|
132
|
+
});
|
|
133
|
+
builtins.set("pop", (args) => {
|
|
134
|
+
const arr = args[0];
|
|
135
|
+
if (Array.isArray(arr)) return arr.pop();
|
|
136
|
+
return void 0;
|
|
137
|
+
});
|
|
138
|
+
builtins.set("at", (args) => {
|
|
139
|
+
const arr = args[0];
|
|
140
|
+
const index = Number(args[1]);
|
|
141
|
+
if (Array.isArray(arr)) return arr[index];
|
|
142
|
+
return void 0;
|
|
143
|
+
});
|
|
144
|
+
builtins.set("log", (args) => {
|
|
145
|
+
chunk3X2EGU7Z_cjs.logger.info("HoloScript log", { args });
|
|
146
|
+
return args[0];
|
|
147
|
+
});
|
|
148
|
+
builtins.set("print", (args) => {
|
|
149
|
+
const message = args.map(String).join(" ");
|
|
150
|
+
chunk3X2EGU7Z_cjs.logger.info("print", { message });
|
|
151
|
+
return message;
|
|
152
|
+
});
|
|
153
|
+
builtins.set("typeof", (args) => typeof args[0]);
|
|
154
|
+
builtins.set("isArray", (args) => Array.isArray(args[0]));
|
|
155
|
+
builtins.set("isNumber", (args) => typeof args[0] === "number" && !isNaN(args[0]));
|
|
156
|
+
builtins.set("isString", (args) => typeof args[0] === "string");
|
|
157
|
+
return builtins;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Execute a single AST node
|
|
161
|
+
*/
|
|
162
|
+
async executeNode(node) {
|
|
163
|
+
const startTime = Date.now();
|
|
164
|
+
try {
|
|
165
|
+
this.context.executionStack.push(node);
|
|
166
|
+
let result;
|
|
167
|
+
switch (node.type) {
|
|
168
|
+
case "orb":
|
|
169
|
+
result = await this.executeOrb(node);
|
|
170
|
+
break;
|
|
171
|
+
case "method":
|
|
172
|
+
case "function":
|
|
173
|
+
result = await this.executeFunction(node);
|
|
174
|
+
break;
|
|
175
|
+
case "connection":
|
|
176
|
+
result = await this.executeConnection(node);
|
|
177
|
+
break;
|
|
178
|
+
case "gate":
|
|
179
|
+
result = await this.executeGate(node);
|
|
180
|
+
break;
|
|
181
|
+
case "stream":
|
|
182
|
+
result = await this.executeStream(node);
|
|
183
|
+
break;
|
|
184
|
+
case "execute":
|
|
185
|
+
case "call":
|
|
186
|
+
result = await this.executeCall(node);
|
|
187
|
+
break;
|
|
188
|
+
case "debug":
|
|
189
|
+
result = await this.executeDebug(node);
|
|
190
|
+
break;
|
|
191
|
+
case "visualize":
|
|
192
|
+
result = await this.executeVisualize(node);
|
|
193
|
+
break;
|
|
194
|
+
case "2d-element":
|
|
195
|
+
result = await this.executeUIElement(node);
|
|
196
|
+
break;
|
|
197
|
+
case "nexus":
|
|
198
|
+
case "building":
|
|
199
|
+
result = await this.executeStructure(node);
|
|
200
|
+
break;
|
|
201
|
+
case "assignment":
|
|
202
|
+
result = await this.executeAssignment(node);
|
|
203
|
+
break;
|
|
204
|
+
case "return":
|
|
205
|
+
result = await this.executeReturn(node);
|
|
206
|
+
break;
|
|
207
|
+
case "generic":
|
|
208
|
+
result = await this.executeGeneric(node);
|
|
209
|
+
break;
|
|
210
|
+
case "expression-statement":
|
|
211
|
+
result = await this.executeCall(node);
|
|
212
|
+
break;
|
|
213
|
+
default:
|
|
214
|
+
result = {
|
|
215
|
+
success: false,
|
|
216
|
+
error: `Unknown node type: ${node.type}`,
|
|
217
|
+
executionTime: Date.now() - startTime
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
result.executionTime = Date.now() - startTime;
|
|
221
|
+
this.executionHistory.push(result);
|
|
222
|
+
this.context.executionStack.pop();
|
|
223
|
+
return result;
|
|
224
|
+
} catch (error) {
|
|
225
|
+
const execTime = Date.now() - startTime;
|
|
226
|
+
const errorResult = {
|
|
227
|
+
success: false,
|
|
228
|
+
error: error instanceof Error ? error.message : String(error),
|
|
229
|
+
executionTime: execTime
|
|
230
|
+
};
|
|
231
|
+
this.executionHistory.push(errorResult);
|
|
232
|
+
this.context.executionStack.pop();
|
|
233
|
+
return errorResult;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Execute multiple nodes in sequence
|
|
238
|
+
*/
|
|
239
|
+
async executeProgram(nodes, depth = 0) {
|
|
240
|
+
if (depth === 0) {
|
|
241
|
+
this.startTime = Date.now();
|
|
242
|
+
this.nodeCount = 0;
|
|
243
|
+
}
|
|
244
|
+
if (depth > RUNTIME_SECURITY_LIMITS.maxExecutionDepth) {
|
|
245
|
+
chunk3X2EGU7Z_cjs.logger.error("Max execution depth exceeded", { depth });
|
|
246
|
+
return [{
|
|
247
|
+
success: false,
|
|
248
|
+
error: `Max execution depth exceeded (${RUNTIME_SECURITY_LIMITS.maxExecutionDepth})`,
|
|
249
|
+
executionTime: 0
|
|
250
|
+
}];
|
|
251
|
+
}
|
|
252
|
+
const results = [];
|
|
253
|
+
for (const node of nodes) {
|
|
254
|
+
this.nodeCount++;
|
|
255
|
+
if (this.nodeCount > RUNTIME_SECURITY_LIMITS.maxTotalNodes) {
|
|
256
|
+
chunk3X2EGU7Z_cjs.logger.error("Max total nodes exceeded", { count: this.nodeCount });
|
|
257
|
+
results.push({
|
|
258
|
+
success: false,
|
|
259
|
+
error: "Max total nodes exceeded",
|
|
260
|
+
executionTime: Date.now() - this.startTime
|
|
261
|
+
});
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
if (Date.now() - this.startTime > RUNTIME_SECURITY_LIMITS.maxExecutionTimeMs) {
|
|
265
|
+
chunk3X2EGU7Z_cjs.logger.error("Execution timeout", { duration: Date.now() - this.startTime });
|
|
266
|
+
results.push({
|
|
267
|
+
success: false,
|
|
268
|
+
error: "Execution timeout",
|
|
269
|
+
executionTime: Date.now() - this.startTime
|
|
270
|
+
});
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
const result = await this.executeNode(node);
|
|
274
|
+
results.push(result);
|
|
275
|
+
if (!result.success && node.type !== "visualize") {
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
if (node.type === "return") {
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return results;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Call a function with arguments
|
|
286
|
+
*/
|
|
287
|
+
async callFunction(name, args = []) {
|
|
288
|
+
const builtin = this.builtinFunctions.get(name);
|
|
289
|
+
if (builtin) {
|
|
290
|
+
try {
|
|
291
|
+
const result = builtin(args);
|
|
292
|
+
return {
|
|
293
|
+
success: true,
|
|
294
|
+
output: result
|
|
295
|
+
};
|
|
296
|
+
} catch (error) {
|
|
297
|
+
return {
|
|
298
|
+
success: false,
|
|
299
|
+
error: `Built-in function ${name} failed: ${error}`
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
const func = this.context.functions.get(name);
|
|
304
|
+
if (!func) {
|
|
305
|
+
return {
|
|
306
|
+
success: false,
|
|
307
|
+
error: `Function '${name}' not found`
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
if (this.callStack.length >= RUNTIME_SECURITY_LIMITS.maxCallStackDepth) {
|
|
311
|
+
return {
|
|
312
|
+
success: false,
|
|
313
|
+
error: `Max call stack depth exceeded (${RUNTIME_SECURITY_LIMITS.maxCallStackDepth})`
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
const parentScope = this.currentScope;
|
|
317
|
+
this.currentScope = {
|
|
318
|
+
variables: /* @__PURE__ */ new Map(),
|
|
319
|
+
parent: parentScope
|
|
320
|
+
};
|
|
321
|
+
func.parameters.forEach((param, index) => {
|
|
322
|
+
const value = index < args.length ? args[index] : param.defaultValue;
|
|
323
|
+
this.currentScope.variables.set(param.name, value);
|
|
324
|
+
});
|
|
325
|
+
this.callStack.push(name);
|
|
326
|
+
let returnValue = void 0;
|
|
327
|
+
try {
|
|
328
|
+
const results = await this.executeProgram(func.body, this.callStack.length);
|
|
329
|
+
const lastResult = results[results.length - 1];
|
|
330
|
+
if (lastResult?.output !== void 0) {
|
|
331
|
+
returnValue = lastResult.output;
|
|
332
|
+
}
|
|
333
|
+
this.createExecutionEffect(name, func.position || { x: 0, y: 0, z: 0 });
|
|
334
|
+
return {
|
|
335
|
+
success: results.every((r) => r.success),
|
|
336
|
+
output: returnValue,
|
|
337
|
+
hologram: func.hologram,
|
|
338
|
+
spatialPosition: func.position
|
|
339
|
+
};
|
|
340
|
+
} finally {
|
|
341
|
+
this.currentScope = parentScope;
|
|
342
|
+
this.callStack.pop();
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Set a variable in current scope
|
|
347
|
+
*/
|
|
348
|
+
setVariable(name, value) {
|
|
349
|
+
if (name.includes(".")) {
|
|
350
|
+
const parts = name.split(".");
|
|
351
|
+
const objName = parts[0];
|
|
352
|
+
const propPath = parts.slice(1);
|
|
353
|
+
let obj = this.getVariable(objName);
|
|
354
|
+
if (obj === void 0 || typeof obj !== "object" || obj === null) {
|
|
355
|
+
obj = {};
|
|
356
|
+
this.currentScope.variables.set(objName, obj);
|
|
357
|
+
}
|
|
358
|
+
let current = obj;
|
|
359
|
+
for (let i = 0; i < propPath.length - 1; i++) {
|
|
360
|
+
if (current[propPath[i]] === void 0 || typeof current[propPath[i]] !== "object") {
|
|
361
|
+
current[propPath[i]] = {};
|
|
362
|
+
}
|
|
363
|
+
current = current[propPath[i]];
|
|
364
|
+
}
|
|
365
|
+
current[propPath[propPath.length - 1]] = value;
|
|
366
|
+
} else {
|
|
367
|
+
this.currentScope.variables.set(name, value);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Get a variable from scope chain
|
|
372
|
+
*/
|
|
373
|
+
getVariable(name) {
|
|
374
|
+
if (name.includes(".")) {
|
|
375
|
+
const parts = name.split(".");
|
|
376
|
+
let value = this.getVariable(parts[0]);
|
|
377
|
+
for (let i = 1; i < parts.length && value !== void 0; i++) {
|
|
378
|
+
if (typeof value === "object" && value !== null) {
|
|
379
|
+
value = value[parts[i]];
|
|
380
|
+
} else {
|
|
381
|
+
return void 0;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
return value;
|
|
385
|
+
}
|
|
386
|
+
let scope = this.currentScope;
|
|
387
|
+
while (scope) {
|
|
388
|
+
if (scope.variables.has(name)) {
|
|
389
|
+
return scope.variables.get(name);
|
|
390
|
+
}
|
|
391
|
+
scope = scope.parent;
|
|
392
|
+
}
|
|
393
|
+
if (this.context.variables.has(name)) {
|
|
394
|
+
return this.context.variables.get(name);
|
|
395
|
+
}
|
|
396
|
+
if (this.context.functions.has(name)) {
|
|
397
|
+
return this.context.functions.get(name);
|
|
398
|
+
}
|
|
399
|
+
return void 0;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Evaluate an expression
|
|
403
|
+
*/
|
|
404
|
+
evaluateExpression(expr) {
|
|
405
|
+
if (!expr || typeof expr !== "string") return expr;
|
|
406
|
+
expr = expr.trim();
|
|
407
|
+
const suspicious = ["eval", "process", "require", "__proto__", "constructor", "Function"];
|
|
408
|
+
if (suspicious.some((kw) => expr.toLowerCase().includes(kw))) {
|
|
409
|
+
chunk3X2EGU7Z_cjs.logger.warn("Suspicious expression blocked", { expr });
|
|
410
|
+
return void 0;
|
|
411
|
+
}
|
|
412
|
+
if (expr.startsWith('"') && expr.endsWith('"') || expr.startsWith("'") && expr.endsWith("'")) {
|
|
413
|
+
return expr.slice(1, -1);
|
|
414
|
+
}
|
|
415
|
+
if (/^-?\d+(\.\d+)?$/.test(expr)) {
|
|
416
|
+
return parseFloat(expr);
|
|
417
|
+
}
|
|
418
|
+
if (expr === "true") return true;
|
|
419
|
+
if (expr === "false") return false;
|
|
420
|
+
if (expr === "null") return null;
|
|
421
|
+
if (expr === "undefined") return void 0;
|
|
422
|
+
if (expr.startsWith("[") && expr.endsWith("]")) {
|
|
423
|
+
const inner = expr.slice(1, -1);
|
|
424
|
+
if (!inner.trim()) return [];
|
|
425
|
+
const elements = this.splitByComma(inner);
|
|
426
|
+
return elements.map((e) => this.evaluateExpression(e.trim()));
|
|
427
|
+
}
|
|
428
|
+
if (expr.startsWith("{") && expr.endsWith("}")) {
|
|
429
|
+
const inner = expr.slice(1, -1);
|
|
430
|
+
if (!inner.trim()) return {};
|
|
431
|
+
const pairs = this.splitByComma(inner);
|
|
432
|
+
const obj = {};
|
|
433
|
+
for (const pair of pairs) {
|
|
434
|
+
const colonIndex = pair.indexOf(":");
|
|
435
|
+
if (colonIndex > 0) {
|
|
436
|
+
const key = pair.slice(0, colonIndex).trim();
|
|
437
|
+
const value = pair.slice(colonIndex + 1).trim();
|
|
438
|
+
obj[key] = this.evaluateExpression(value);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
return obj;
|
|
442
|
+
}
|
|
443
|
+
const funcMatch = expr.match(/^(\w+)\s*\((.*)?\)$/);
|
|
444
|
+
if (funcMatch) {
|
|
445
|
+
const [, funcName, argsStr] = funcMatch;
|
|
446
|
+
const args = argsStr ? this.splitByComma(argsStr).map((a) => this.evaluateExpression(a.trim())) : [];
|
|
447
|
+
const builtin = this.builtinFunctions.get(funcName);
|
|
448
|
+
if (builtin) {
|
|
449
|
+
return builtin(args);
|
|
450
|
+
}
|
|
451
|
+
if (this.context.functions.has(funcName)) {
|
|
452
|
+
return { __holoCall: funcName, args };
|
|
453
|
+
}
|
|
454
|
+
return void 0;
|
|
455
|
+
}
|
|
456
|
+
const binaryOps = [
|
|
457
|
+
{ pattern: /(.+)\s*\+\s*(.+)/, op: (a, b) => typeof a === "string" || typeof b === "string" ? String(a) + String(b) : Number(a) + Number(b) },
|
|
458
|
+
{ pattern: /(.+)\s*-\s*(.+)/, op: (a, b) => Number(a) - Number(b) },
|
|
459
|
+
{ pattern: /(.+)\s*\*\s*(.+)/, op: (a, b) => Number(a) * Number(b) },
|
|
460
|
+
{ pattern: /(.+)\s*\/\s*(.+)/, op: (a, b) => Number(b) !== 0 ? Number(a) / Number(b) : 0 },
|
|
461
|
+
{ pattern: /(.+)\s*%\s*(.+)/, op: (a, b) => Number(a) % Number(b) }
|
|
462
|
+
];
|
|
463
|
+
for (const { pattern, op } of binaryOps) {
|
|
464
|
+
const match = expr.match(pattern);
|
|
465
|
+
if (match) {
|
|
466
|
+
const left = this.evaluateExpression(match[1]);
|
|
467
|
+
const right = this.evaluateExpression(match[2]);
|
|
468
|
+
return op(left, right);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
return this.getVariable(expr);
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Split string by comma, respecting nesting
|
|
475
|
+
*/
|
|
476
|
+
splitByComma(str) {
|
|
477
|
+
const parts = [];
|
|
478
|
+
let current = "";
|
|
479
|
+
let depth = 0;
|
|
480
|
+
let inString = false;
|
|
481
|
+
let stringChar = "";
|
|
482
|
+
for (let i = 0; i < str.length; i++) {
|
|
483
|
+
const char = str[i];
|
|
484
|
+
if (!inString && (char === '"' || char === "'")) {
|
|
485
|
+
inString = true;
|
|
486
|
+
stringChar = char;
|
|
487
|
+
} else if (inString && char === stringChar && str[i - 1] !== "\\") {
|
|
488
|
+
inString = false;
|
|
489
|
+
}
|
|
490
|
+
if (!inString) {
|
|
491
|
+
if (char === "(" || char === "[" || char === "{") depth++;
|
|
492
|
+
if (char === ")" || char === "]" || char === "}") depth--;
|
|
493
|
+
if (char === "," && depth === 0) {
|
|
494
|
+
parts.push(current.trim());
|
|
495
|
+
current = "";
|
|
496
|
+
continue;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
current += char;
|
|
500
|
+
}
|
|
501
|
+
if (current.trim()) {
|
|
502
|
+
parts.push(current.trim());
|
|
503
|
+
}
|
|
504
|
+
return parts;
|
|
505
|
+
}
|
|
506
|
+
// ============================================================================
|
|
507
|
+
// Node Executors
|
|
508
|
+
// ============================================================================
|
|
509
|
+
async executeOrb(node) {
|
|
510
|
+
if (node.position) {
|
|
511
|
+
this.context.spatialMemory.set(node.name, node.position);
|
|
512
|
+
}
|
|
513
|
+
const orbData = {
|
|
514
|
+
__type: "orb",
|
|
515
|
+
name: node.name,
|
|
516
|
+
properties: { ...node.properties },
|
|
517
|
+
position: node.position || { x: 0, y: 0, z: 0 },
|
|
518
|
+
hologram: node.hologram,
|
|
519
|
+
created: Date.now(),
|
|
520
|
+
// Methods bound to this orb
|
|
521
|
+
show: () => this.builtinFunctions.get("show")([node.name]),
|
|
522
|
+
hide: () => this.builtinFunctions.get("hide")([node.name]),
|
|
523
|
+
pulse: (opts) => this.builtinFunctions.get("pulse")([node.name, opts])
|
|
524
|
+
};
|
|
525
|
+
this.context.variables.set(node.name, orbData);
|
|
526
|
+
if (node.hologram) {
|
|
527
|
+
this.context.hologramState.set(node.name, node.hologram);
|
|
528
|
+
}
|
|
529
|
+
this.createParticleEffect(`${node.name}_creation`, node.position || { x: 0, y: 0, z: 0 }, "#00ffff", 20);
|
|
530
|
+
chunk3X2EGU7Z_cjs.logger.info("Orb created", { name: node.name, properties: Object.keys(node.properties) });
|
|
531
|
+
return {
|
|
532
|
+
success: true,
|
|
533
|
+
output: orbData,
|
|
534
|
+
hologram: node.hologram,
|
|
535
|
+
spatialPosition: node.position
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
async executeFunction(node) {
|
|
539
|
+
this.context.functions.set(node.name, node);
|
|
540
|
+
const hologram = {
|
|
541
|
+
shape: "cube",
|
|
542
|
+
color: "#ff6b35",
|
|
543
|
+
size: 1.5,
|
|
544
|
+
glow: true,
|
|
545
|
+
interactive: true,
|
|
546
|
+
...node.hologram
|
|
547
|
+
};
|
|
548
|
+
this.context.hologramState.set(node.name, hologram);
|
|
549
|
+
chunk3X2EGU7Z_cjs.logger.info("Function defined", { name: node.name, params: node.parameters.map((p) => p.name) });
|
|
550
|
+
return {
|
|
551
|
+
success: true,
|
|
552
|
+
output: `Function '${node.name}' defined with ${node.parameters.length} parameter(s)`,
|
|
553
|
+
hologram,
|
|
554
|
+
spatialPosition: node.position
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
async executeConnection(node) {
|
|
558
|
+
this.context.connections.push(node);
|
|
559
|
+
const fromPos = this.context.spatialMemory.get(node.from);
|
|
560
|
+
const toPos = this.context.spatialMemory.get(node.to);
|
|
561
|
+
if (fromPos && toPos) {
|
|
562
|
+
this.createConnectionStream(node.from, node.to, fromPos, toPos, node.dataType);
|
|
563
|
+
}
|
|
564
|
+
if (node.bidirectional) {
|
|
565
|
+
this.on(`${node.from}.changed`, async (data) => {
|
|
566
|
+
this.setVariable(node.to, data);
|
|
567
|
+
this.emit(`${node.to}.changed`, data);
|
|
568
|
+
});
|
|
569
|
+
this.on(`${node.to}.changed`, async (data) => {
|
|
570
|
+
this.setVariable(node.from, data);
|
|
571
|
+
this.emit(`${node.from}.changed`, data);
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
chunk3X2EGU7Z_cjs.logger.info("Connection created", { from: node.from, to: node.to, dataType: node.dataType });
|
|
575
|
+
return {
|
|
576
|
+
success: true,
|
|
577
|
+
output: `Connected '${node.from}' to '${node.to}' (${node.dataType})`,
|
|
578
|
+
hologram: {
|
|
579
|
+
shape: "cylinder",
|
|
580
|
+
color: this.getDataTypeColor(node.dataType),
|
|
581
|
+
size: 0.1,
|
|
582
|
+
glow: true,
|
|
583
|
+
interactive: false
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
async executeGate(node) {
|
|
588
|
+
try {
|
|
589
|
+
const condition = this.evaluateCondition(node.condition);
|
|
590
|
+
const path = condition ? node.truePath : node.falsePath;
|
|
591
|
+
chunk3X2EGU7Z_cjs.logger.info("Gate evaluation", { condition: node.condition, result: condition });
|
|
592
|
+
if (path.length > 0) {
|
|
593
|
+
await this.executeProgram(path, this.callStack.length + 1);
|
|
594
|
+
}
|
|
595
|
+
return {
|
|
596
|
+
success: true,
|
|
597
|
+
output: `Gate: took ${condition ? "true" : "false"} path`,
|
|
598
|
+
hologram: {
|
|
599
|
+
shape: "pyramid",
|
|
600
|
+
color: condition ? "#00ff00" : "#ff0000",
|
|
601
|
+
size: 1,
|
|
602
|
+
glow: true,
|
|
603
|
+
interactive: true
|
|
604
|
+
}
|
|
605
|
+
};
|
|
606
|
+
} catch (error) {
|
|
607
|
+
return {
|
|
608
|
+
success: false,
|
|
609
|
+
error: `Gate execution failed: ${error}`
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
async executeStream(node) {
|
|
614
|
+
let data = this.getVariable(node.source);
|
|
615
|
+
chunk3X2EGU7Z_cjs.logger.info("Stream processing", { name: node.name, source: node.source, transforms: node.transformations.length });
|
|
616
|
+
for (const transform of node.transformations) {
|
|
617
|
+
data = await this.applyTransformation(data, transform);
|
|
618
|
+
}
|
|
619
|
+
this.setVariable(`${node.name}_result`, data);
|
|
620
|
+
this.createFlowingStream(node.name, node.position || { x: 0, y: 0, z: 0 }, data);
|
|
621
|
+
return {
|
|
622
|
+
success: true,
|
|
623
|
+
output: `Stream '${node.name}' processed ${Array.isArray(data) ? data.length : 1} item(s)`,
|
|
624
|
+
hologram: node.hologram,
|
|
625
|
+
spatialPosition: node.position
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
async executeCall(node) {
|
|
629
|
+
const funcName = node.target || "";
|
|
630
|
+
const args = node.args || [];
|
|
631
|
+
return this.callFunction(funcName, args);
|
|
632
|
+
}
|
|
633
|
+
async executeDebug(node) {
|
|
634
|
+
const debugInfo = {
|
|
635
|
+
variables: Object.fromEntries(this.currentScope.variables),
|
|
636
|
+
contextVariables: Object.fromEntries(this.context.variables),
|
|
637
|
+
functions: Array.from(this.context.functions.keys()),
|
|
638
|
+
connections: this.context.connections.length,
|
|
639
|
+
callStack: [...this.callStack],
|
|
640
|
+
uiElements: Array.from(this.uiElements.keys()),
|
|
641
|
+
animations: Array.from(this.animations.keys()),
|
|
642
|
+
executionHistory: this.executionHistory.slice(-10)
|
|
643
|
+
};
|
|
644
|
+
const debugOrb = {
|
|
645
|
+
shape: "pyramid",
|
|
646
|
+
color: "#ff1493",
|
|
647
|
+
size: 0.8,
|
|
648
|
+
glow: true,
|
|
649
|
+
interactive: true
|
|
650
|
+
};
|
|
651
|
+
this.context.hologramState.set(`debug_${node.target || "program"}`, debugOrb);
|
|
652
|
+
chunk3X2EGU7Z_cjs.logger.info("Debug info", debugInfo);
|
|
653
|
+
return {
|
|
654
|
+
success: true,
|
|
655
|
+
output: debugInfo,
|
|
656
|
+
hologram: debugOrb
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
async executeVisualize(node) {
|
|
660
|
+
const target = node.target || "";
|
|
661
|
+
const data = this.getVariable(target);
|
|
662
|
+
if (data === void 0) {
|
|
663
|
+
return {
|
|
664
|
+
success: false,
|
|
665
|
+
error: `No data found for '${target}'`
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
const visHologram = {
|
|
669
|
+
shape: "cylinder",
|
|
670
|
+
color: "#32cd32",
|
|
671
|
+
size: 1.5,
|
|
672
|
+
glow: true,
|
|
673
|
+
interactive: true
|
|
674
|
+
};
|
|
675
|
+
this.createDataVisualization(target, data, node.position || { x: 0, y: 0, z: 0 });
|
|
676
|
+
return {
|
|
677
|
+
success: true,
|
|
678
|
+
output: { visualizing: target, data },
|
|
679
|
+
hologram: visHologram
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
async executeUIElement(node) {
|
|
683
|
+
const element = {
|
|
684
|
+
type: node.elementType,
|
|
685
|
+
name: node.name,
|
|
686
|
+
properties: { ...node.properties },
|
|
687
|
+
visible: true,
|
|
688
|
+
enabled: true
|
|
689
|
+
};
|
|
690
|
+
if (node.elementType === "textinput") {
|
|
691
|
+
element.value = node.properties.value || "";
|
|
692
|
+
} else if (node.elementType === "slider") {
|
|
693
|
+
element.value = node.properties.value || node.properties.min || 0;
|
|
694
|
+
} else if (node.elementType === "toggle") {
|
|
695
|
+
element.value = node.properties.checked || false;
|
|
696
|
+
}
|
|
697
|
+
this.uiElements.set(node.name, element);
|
|
698
|
+
if (node.events) {
|
|
699
|
+
for (const [eventName, handlerName] of Object.entries(node.events)) {
|
|
700
|
+
this.on(`${node.name}.${eventName}`, async () => {
|
|
701
|
+
await this.callFunction(handlerName);
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
chunk3X2EGU7Z_cjs.logger.info("UI element created", { type: node.elementType, name: node.name });
|
|
706
|
+
return {
|
|
707
|
+
success: true,
|
|
708
|
+
output: element
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* Execute generic voice commands
|
|
713
|
+
* Handles commands like: show, hide, animate, pulse, create
|
|
714
|
+
*/
|
|
715
|
+
async executeGeneric(_node) {
|
|
716
|
+
const genericNode = _node;
|
|
717
|
+
const command = String(genericNode.command || "").trim().toLowerCase();
|
|
718
|
+
const tokens = command.split(/\s+/);
|
|
719
|
+
const action = tokens[0];
|
|
720
|
+
const target = tokens[1];
|
|
721
|
+
chunk3X2EGU7Z_cjs.logger.info("Executing generic command", { command, action, target });
|
|
722
|
+
try {
|
|
723
|
+
let result;
|
|
724
|
+
switch (action) {
|
|
725
|
+
case "show":
|
|
726
|
+
result = await this.executeShowCommand(target, genericNode);
|
|
727
|
+
break;
|
|
728
|
+
case "hide":
|
|
729
|
+
result = await this.executeHideCommand(target, genericNode);
|
|
730
|
+
break;
|
|
731
|
+
case "create":
|
|
732
|
+
case "summon":
|
|
733
|
+
result = await this.executeCreateCommand(tokens.slice(1), genericNode);
|
|
734
|
+
break;
|
|
735
|
+
case "animate":
|
|
736
|
+
result = await this.executeAnimateCommand(target, tokens.slice(2), genericNode);
|
|
737
|
+
break;
|
|
738
|
+
case "pulse":
|
|
739
|
+
result = await this.executePulseCommand(target, tokens.slice(2), genericNode);
|
|
740
|
+
break;
|
|
741
|
+
case "move":
|
|
742
|
+
result = await this.executeMoveCommand(target, tokens.slice(2), genericNode);
|
|
743
|
+
break;
|
|
744
|
+
case "delete":
|
|
745
|
+
case "remove":
|
|
746
|
+
result = await this.executeDeleteCommand(target, genericNode);
|
|
747
|
+
break;
|
|
748
|
+
default:
|
|
749
|
+
chunk3X2EGU7Z_cjs.logger.warn("Unknown voice command action", { action, command });
|
|
750
|
+
result = {
|
|
751
|
+
executed: false,
|
|
752
|
+
message: `Unknown command: ${action}`
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
return {
|
|
756
|
+
success: true,
|
|
757
|
+
output: result
|
|
758
|
+
};
|
|
759
|
+
} catch (error) {
|
|
760
|
+
return {
|
|
761
|
+
success: false,
|
|
762
|
+
error: `Generic command execution failed: ${String(error)}`
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* Execute 'show' command
|
|
768
|
+
*/
|
|
769
|
+
async executeShowCommand(target, _node) {
|
|
770
|
+
const hologram = _node.hologram || {
|
|
771
|
+
shape: "orb",
|
|
772
|
+
color: "#00ffff",
|
|
773
|
+
size: 0.8,
|
|
774
|
+
glow: true,
|
|
775
|
+
interactive: true
|
|
776
|
+
};
|
|
777
|
+
const position = _node.position || { x: 0, y: 0, z: 0 };
|
|
778
|
+
this.context.spatialMemory.set(target, position);
|
|
779
|
+
this.createParticleEffect(`${target}_show`, position, hologram.color, 15);
|
|
780
|
+
chunk3X2EGU7Z_cjs.logger.info("Show command executed", { target, position });
|
|
781
|
+
return {
|
|
782
|
+
showed: target,
|
|
783
|
+
hologram,
|
|
784
|
+
position
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* Execute 'hide' command
|
|
789
|
+
*/
|
|
790
|
+
async executeHideCommand(target, _node) {
|
|
791
|
+
const position = this.context.spatialMemory.get(target) || { x: 0, y: 0, z: 0 };
|
|
792
|
+
this.createParticleEffect(`${target}_hide`, position, "#ff0000", 10);
|
|
793
|
+
chunk3X2EGU7Z_cjs.logger.info("Hide command executed", { target });
|
|
794
|
+
return {
|
|
795
|
+
hidden: target
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
/**
|
|
799
|
+
* Execute 'create' command
|
|
800
|
+
*/
|
|
801
|
+
async executeCreateCommand(tokens, _node) {
|
|
802
|
+
if (tokens.length < 2) {
|
|
803
|
+
return { error: "Create command requires shape and name" };
|
|
804
|
+
}
|
|
805
|
+
const shape = tokens[0];
|
|
806
|
+
const name = tokens[1];
|
|
807
|
+
const position = _node.position || { x: 0, y: 0, z: 0 };
|
|
808
|
+
const hologram = {
|
|
809
|
+
shape,
|
|
810
|
+
color: _node.hologram?.color || "#00ffff",
|
|
811
|
+
size: _node.hologram?.size || 1,
|
|
812
|
+
glow: _node.hologram?.glow !== false,
|
|
813
|
+
interactive: _node.hologram?.interactive !== false
|
|
814
|
+
};
|
|
815
|
+
this.context.spatialMemory.set(name, position);
|
|
816
|
+
this.createParticleEffect(`${name}_create`, position, hologram.color, 20);
|
|
817
|
+
chunk3X2EGU7Z_cjs.logger.info("Create command executed", { shape, name, position });
|
|
818
|
+
return {
|
|
819
|
+
created: name,
|
|
820
|
+
shape,
|
|
821
|
+
hologram,
|
|
822
|
+
position
|
|
823
|
+
};
|
|
824
|
+
}
|
|
825
|
+
/**
|
|
826
|
+
* Execute 'animate' command
|
|
827
|
+
*/
|
|
828
|
+
async executeAnimateCommand(target, tokens, _node) {
|
|
829
|
+
const property = tokens[0] || "position.y";
|
|
830
|
+
const duration = parseInt(tokens[1] || "1000", 10);
|
|
831
|
+
const animation = {
|
|
832
|
+
target,
|
|
833
|
+
property,
|
|
834
|
+
from: 0,
|
|
835
|
+
to: 1,
|
|
836
|
+
duration,
|
|
837
|
+
startTime: Date.now(),
|
|
838
|
+
easing: "ease-in-out"
|
|
839
|
+
};
|
|
840
|
+
this.animations.set(`${target}_${property}`, animation);
|
|
841
|
+
chunk3X2EGU7Z_cjs.logger.info("Animate command executed", { target, property, duration });
|
|
842
|
+
return {
|
|
843
|
+
animating: target,
|
|
844
|
+
animation
|
|
845
|
+
};
|
|
846
|
+
}
|
|
847
|
+
/**
|
|
848
|
+
* Execute 'pulse' command
|
|
849
|
+
*/
|
|
850
|
+
async executePulseCommand(target, tokens, _node) {
|
|
851
|
+
const duration = parseInt(tokens[0] || "500", 10);
|
|
852
|
+
const position = this.context.spatialMemory.get(target) || { x: 0, y: 0, z: 0 };
|
|
853
|
+
this.createParticleEffect(`${target}_pulse`, position, "#ffff00", 30);
|
|
854
|
+
const animation = {
|
|
855
|
+
target,
|
|
856
|
+
property: "scale",
|
|
857
|
+
from: 1,
|
|
858
|
+
to: 1.5,
|
|
859
|
+
duration,
|
|
860
|
+
startTime: Date.now(),
|
|
861
|
+
easing: "sine",
|
|
862
|
+
yoyo: true,
|
|
863
|
+
loop: true
|
|
864
|
+
};
|
|
865
|
+
this.animations.set(`${target}_pulse`, animation);
|
|
866
|
+
chunk3X2EGU7Z_cjs.logger.info("Pulse command executed", { target, duration });
|
|
867
|
+
return {
|
|
868
|
+
pulsing: target,
|
|
869
|
+
duration
|
|
870
|
+
};
|
|
871
|
+
}
|
|
872
|
+
/**
|
|
873
|
+
* Execute 'move' command
|
|
874
|
+
*/
|
|
875
|
+
async executeMoveCommand(target, tokens, _node) {
|
|
876
|
+
const x = parseFloat(tokens[0] || "0");
|
|
877
|
+
const y = parseFloat(tokens[1] || "0");
|
|
878
|
+
const z = parseFloat(tokens[2] || "0");
|
|
879
|
+
const position = { x, y, z };
|
|
880
|
+
const current = this.context.spatialMemory.get(target);
|
|
881
|
+
if (current) {
|
|
882
|
+
this.context.spatialMemory.set(target, position);
|
|
883
|
+
this.createConnectionStream(target, `${target}_move`, current, position, "movement");
|
|
884
|
+
} else {
|
|
885
|
+
this.context.spatialMemory.set(target, position);
|
|
886
|
+
}
|
|
887
|
+
chunk3X2EGU7Z_cjs.logger.info("Move command executed", { target, position });
|
|
888
|
+
return {
|
|
889
|
+
moved: target,
|
|
890
|
+
to: position
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
/**
|
|
894
|
+
* Execute 'delete' command
|
|
895
|
+
*/
|
|
896
|
+
async executeDeleteCommand(target, _node) {
|
|
897
|
+
const position = this.context.spatialMemory.get(target);
|
|
898
|
+
if (position) {
|
|
899
|
+
this.createParticleEffect(`${target}_delete`, position, "#ff0000", 15);
|
|
900
|
+
this.context.spatialMemory.delete(target);
|
|
901
|
+
}
|
|
902
|
+
chunk3X2EGU7Z_cjs.logger.info("Delete command executed", { target });
|
|
903
|
+
return {
|
|
904
|
+
deleted: target
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
async executeStructure(node) {
|
|
908
|
+
const hologram = node.hologram || {
|
|
909
|
+
shape: node.type === "nexus" ? "sphere" : "cube",
|
|
910
|
+
color: node.type === "nexus" ? "#9b59b6" : "#e74c3c",
|
|
911
|
+
size: node.type === "nexus" ? 3 : 4,
|
|
912
|
+
glow: true,
|
|
913
|
+
interactive: true
|
|
914
|
+
};
|
|
915
|
+
return {
|
|
916
|
+
success: true,
|
|
917
|
+
output: { type: node.type, created: true },
|
|
918
|
+
hologram,
|
|
919
|
+
spatialPosition: node.position
|
|
920
|
+
};
|
|
921
|
+
}
|
|
922
|
+
async executeAssignment(node) {
|
|
923
|
+
const value = this.evaluateExpression(String(node.value));
|
|
924
|
+
this.setVariable(node.name, value);
|
|
925
|
+
return {
|
|
926
|
+
success: true,
|
|
927
|
+
output: { assigned: node.name, value }
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
async executeReturn(node) {
|
|
931
|
+
const value = this.evaluateExpression(String(node.value));
|
|
932
|
+
return {
|
|
933
|
+
success: true,
|
|
934
|
+
output: value
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
// ============================================================================
|
|
938
|
+
// Condition Evaluation
|
|
939
|
+
// ============================================================================
|
|
940
|
+
evaluateCondition(condition) {
|
|
941
|
+
if (!condition) return false;
|
|
942
|
+
const suspiciousKeywords = ["eval", "process", "require", "__proto__", "constructor"];
|
|
943
|
+
if (suspiciousKeywords.some((kw) => condition.toLowerCase().includes(kw))) {
|
|
944
|
+
chunk3X2EGU7Z_cjs.logger.warn("Suspicious condition blocked", { condition });
|
|
945
|
+
return false;
|
|
946
|
+
}
|
|
947
|
+
try {
|
|
948
|
+
if (condition.trim().toLowerCase() === "true") return true;
|
|
949
|
+
if (condition.trim().toLowerCase() === "false") return false;
|
|
950
|
+
const comparisonPatterns = [
|
|
951
|
+
{ regex: /^(.+?)\s*(===|!==)\s*(.+)$/ },
|
|
952
|
+
{ regex: /^(.+?)\s*(==|!=|>=|<=|>|<)\s*(.+)$/ },
|
|
953
|
+
{ regex: /^(.+?)\s*(&&)\s*(.+)$/, logical: "and" },
|
|
954
|
+
{ regex: /^(.+?)\s*(\|\|)\s*(.+)$/, logical: "or" }
|
|
955
|
+
];
|
|
956
|
+
for (const { regex, logical } of comparisonPatterns) {
|
|
957
|
+
const match = condition.match(regex);
|
|
958
|
+
if (match) {
|
|
959
|
+
const [, leftExpr, operator, rightExpr] = match;
|
|
960
|
+
const left = this.evaluateExpression(leftExpr.trim());
|
|
961
|
+
const right = this.evaluateExpression(rightExpr.trim());
|
|
962
|
+
if (logical === "and") return Boolean(left) && Boolean(right);
|
|
963
|
+
if (logical === "or") return Boolean(left) || Boolean(right);
|
|
964
|
+
switch (operator) {
|
|
965
|
+
case "===":
|
|
966
|
+
return left === right;
|
|
967
|
+
case "!==":
|
|
968
|
+
return left !== right;
|
|
969
|
+
case "==":
|
|
970
|
+
return left == right;
|
|
971
|
+
case "!=":
|
|
972
|
+
return left != right;
|
|
973
|
+
case ">=":
|
|
974
|
+
return Number(left) >= Number(right);
|
|
975
|
+
case "<=":
|
|
976
|
+
return Number(left) <= Number(right);
|
|
977
|
+
case ">":
|
|
978
|
+
return Number(left) > Number(right);
|
|
979
|
+
case "<":
|
|
980
|
+
return Number(left) < Number(right);
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
if (condition.startsWith("!")) {
|
|
985
|
+
return !this.evaluateCondition(condition.slice(1).trim());
|
|
986
|
+
}
|
|
987
|
+
const value = this.evaluateExpression(condition.trim());
|
|
988
|
+
return Boolean(value);
|
|
989
|
+
} catch (error) {
|
|
990
|
+
chunk3X2EGU7Z_cjs.logger.error("Condition evaluation error", { condition, error });
|
|
991
|
+
return false;
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
// ============================================================================
|
|
995
|
+
// Transformation
|
|
996
|
+
// ============================================================================
|
|
997
|
+
async applyTransformation(data, transform) {
|
|
998
|
+
const params = transform.parameters || {};
|
|
999
|
+
switch (transform.operation) {
|
|
1000
|
+
case "filter": {
|
|
1001
|
+
if (!Array.isArray(data)) return data;
|
|
1002
|
+
const predicate = params.predicate;
|
|
1003
|
+
if (predicate) {
|
|
1004
|
+
return data.filter((item) => {
|
|
1005
|
+
this.setVariable("_item", item);
|
|
1006
|
+
return this.evaluateCondition(predicate);
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
1009
|
+
return data.filter((item) => item !== null && item !== void 0);
|
|
1010
|
+
}
|
|
1011
|
+
case "map": {
|
|
1012
|
+
if (!Array.isArray(data)) return data;
|
|
1013
|
+
const mapper = params.mapper;
|
|
1014
|
+
if (mapper) {
|
|
1015
|
+
return data.map((item) => {
|
|
1016
|
+
this.setVariable("_item", item);
|
|
1017
|
+
return this.evaluateExpression(mapper);
|
|
1018
|
+
});
|
|
1019
|
+
}
|
|
1020
|
+
return data.map((item) => ({ value: item, processed: true }));
|
|
1021
|
+
}
|
|
1022
|
+
case "reduce": {
|
|
1023
|
+
if (!Array.isArray(data)) return data;
|
|
1024
|
+
const initial = params.initial ?? 0;
|
|
1025
|
+
const reducer = params.reducer;
|
|
1026
|
+
if (reducer) {
|
|
1027
|
+
return data.reduce((acc, item) => {
|
|
1028
|
+
this.setVariable("_acc", acc);
|
|
1029
|
+
this.setVariable("_item", item);
|
|
1030
|
+
return this.evaluateExpression(reducer);
|
|
1031
|
+
}, initial);
|
|
1032
|
+
}
|
|
1033
|
+
return data.reduce((acc, item) => acc + (typeof item === "number" ? item : 0), 0);
|
|
1034
|
+
}
|
|
1035
|
+
case "sort": {
|
|
1036
|
+
if (!Array.isArray(data)) return data;
|
|
1037
|
+
const key = params.key;
|
|
1038
|
+
const desc = params.descending;
|
|
1039
|
+
const sorted = [...data].sort((a, b) => {
|
|
1040
|
+
const aVal = key ? a[key] : a;
|
|
1041
|
+
const bVal = key ? b[key] : b;
|
|
1042
|
+
if (aVal < bVal) return desc ? 1 : -1;
|
|
1043
|
+
if (aVal > bVal) return desc ? -1 : 1;
|
|
1044
|
+
return 0;
|
|
1045
|
+
});
|
|
1046
|
+
return sorted;
|
|
1047
|
+
}
|
|
1048
|
+
case "sum":
|
|
1049
|
+
return Array.isArray(data) ? data.reduce((sum, item) => sum + (typeof item === "number" ? item : 0), 0) : data;
|
|
1050
|
+
case "count":
|
|
1051
|
+
return Array.isArray(data) ? data.length : 1;
|
|
1052
|
+
case "unique":
|
|
1053
|
+
return Array.isArray(data) ? [...new Set(data)] : data;
|
|
1054
|
+
case "flatten":
|
|
1055
|
+
return Array.isArray(data) ? data.flat() : data;
|
|
1056
|
+
case "reverse":
|
|
1057
|
+
return Array.isArray(data) ? [...data].reverse() : data;
|
|
1058
|
+
case "take": {
|
|
1059
|
+
if (!Array.isArray(data)) return data;
|
|
1060
|
+
const count = Number(params.count) || 10;
|
|
1061
|
+
return data.slice(0, count);
|
|
1062
|
+
}
|
|
1063
|
+
case "skip": {
|
|
1064
|
+
if (!Array.isArray(data)) return data;
|
|
1065
|
+
const count = Number(params.count) || 0;
|
|
1066
|
+
return data.slice(count);
|
|
1067
|
+
}
|
|
1068
|
+
default:
|
|
1069
|
+
chunk3X2EGU7Z_cjs.logger.warn("Unknown transformation", { operation: transform.operation });
|
|
1070
|
+
return data;
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
// ============================================================================
|
|
1074
|
+
// Event System
|
|
1075
|
+
// ============================================================================
|
|
1076
|
+
/**
|
|
1077
|
+
* Register event handler
|
|
1078
|
+
*/
|
|
1079
|
+
on(event, handler) {
|
|
1080
|
+
const handlers = this.eventHandlers.get(event) || [];
|
|
1081
|
+
handlers.push(handler);
|
|
1082
|
+
this.eventHandlers.set(event, handlers);
|
|
1083
|
+
}
|
|
1084
|
+
/**
|
|
1085
|
+
* Remove event handler
|
|
1086
|
+
*/
|
|
1087
|
+
off(event, handler) {
|
|
1088
|
+
if (!handler) {
|
|
1089
|
+
this.eventHandlers.delete(event);
|
|
1090
|
+
} else {
|
|
1091
|
+
const handlers = this.eventHandlers.get(event) || [];
|
|
1092
|
+
this.eventHandlers.set(event, handlers.filter((h) => h !== handler));
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
/**
|
|
1096
|
+
* Emit event
|
|
1097
|
+
*/
|
|
1098
|
+
async emit(event, data) {
|
|
1099
|
+
const handlers = this.eventHandlers.get(event) || [];
|
|
1100
|
+
for (const handler of handlers) {
|
|
1101
|
+
try {
|
|
1102
|
+
await handler(data);
|
|
1103
|
+
} catch (error) {
|
|
1104
|
+
chunk3X2EGU7Z_cjs.logger.error("Event handler error", { event, error });
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
/**
|
|
1109
|
+
* Trigger UI event
|
|
1110
|
+
*/
|
|
1111
|
+
async triggerUIEvent(elementName, eventType, data) {
|
|
1112
|
+
const element = this.uiElements.get(elementName);
|
|
1113
|
+
if (!element) {
|
|
1114
|
+
chunk3X2EGU7Z_cjs.logger.warn("UI element not found", { elementName });
|
|
1115
|
+
return;
|
|
1116
|
+
}
|
|
1117
|
+
if (eventType === "change" && data !== void 0) {
|
|
1118
|
+
element.value = data;
|
|
1119
|
+
}
|
|
1120
|
+
await this.emit(`${elementName}.${eventType}`, data);
|
|
1121
|
+
}
|
|
1122
|
+
// ============================================================================
|
|
1123
|
+
// Animation System
|
|
1124
|
+
// ============================================================================
|
|
1125
|
+
/**
|
|
1126
|
+
* Update all animations
|
|
1127
|
+
*/
|
|
1128
|
+
updateAnimations() {
|
|
1129
|
+
const now = Date.now();
|
|
1130
|
+
for (const [key, anim] of this.animations) {
|
|
1131
|
+
const elapsed = now - anim.startTime;
|
|
1132
|
+
let progress = Math.min(elapsed / anim.duration, 1);
|
|
1133
|
+
progress = this.applyEasing(progress, anim.easing);
|
|
1134
|
+
let currentValue = anim.from + (anim.to - anim.from) * progress;
|
|
1135
|
+
if (anim.yoyo && progress >= 1) {
|
|
1136
|
+
anim.startTime = now;
|
|
1137
|
+
[anim.from, anim.to] = [anim.to, anim.from];
|
|
1138
|
+
}
|
|
1139
|
+
this.setVariable(`${anim.target}.${anim.property}`, currentValue);
|
|
1140
|
+
if (progress >= 1 && !anim.loop && !anim.yoyo) {
|
|
1141
|
+
this.animations.delete(key);
|
|
1142
|
+
} else if (progress >= 1 && anim.loop) {
|
|
1143
|
+
anim.startTime = now;
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
applyEasing(t, easing) {
|
|
1148
|
+
switch (easing) {
|
|
1149
|
+
case "easeIn":
|
|
1150
|
+
return t * t;
|
|
1151
|
+
case "easeOut":
|
|
1152
|
+
return t * (2 - t);
|
|
1153
|
+
case "easeInOut":
|
|
1154
|
+
return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
|
|
1155
|
+
case "easeInQuad":
|
|
1156
|
+
return t * t;
|
|
1157
|
+
case "easeOutQuad":
|
|
1158
|
+
return t * (2 - t);
|
|
1159
|
+
case "easeInOutQuad":
|
|
1160
|
+
return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
|
|
1161
|
+
case "linear":
|
|
1162
|
+
default:
|
|
1163
|
+
return t;
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
// ============================================================================
|
|
1167
|
+
// Particle Effects
|
|
1168
|
+
// ============================================================================
|
|
1169
|
+
createParticleEffect(name, position, color, count) {
|
|
1170
|
+
const limitedCount = Math.min(count, RUNTIME_SECURITY_LIMITS.maxParticlesPerSystem);
|
|
1171
|
+
const particles = [];
|
|
1172
|
+
for (let i = 0; i < limitedCount; i++) {
|
|
1173
|
+
particles.push({
|
|
1174
|
+
x: position.x + (Math.random() - 0.5) * 2,
|
|
1175
|
+
y: position.y + (Math.random() - 0.5) * 2,
|
|
1176
|
+
z: position.z + (Math.random() - 0.5) * 2
|
|
1177
|
+
});
|
|
1178
|
+
}
|
|
1179
|
+
this.particleSystems.set(name, {
|
|
1180
|
+
particles,
|
|
1181
|
+
color,
|
|
1182
|
+
lifetime: 3e3,
|
|
1183
|
+
speed: 0.01
|
|
1184
|
+
});
|
|
1185
|
+
}
|
|
1186
|
+
createConnectionStream(from, to, fromPos, toPos, dataType) {
|
|
1187
|
+
const streamName = `connection_${from}_${to}`;
|
|
1188
|
+
const particles = [];
|
|
1189
|
+
const steps = 20;
|
|
1190
|
+
for (let i = 0; i <= steps; i++) {
|
|
1191
|
+
const t = i / steps;
|
|
1192
|
+
particles.push({
|
|
1193
|
+
x: fromPos.x + (toPos.x - fromPos.x) * t,
|
|
1194
|
+
y: fromPos.y + (toPos.y - fromPos.y) * t,
|
|
1195
|
+
z: fromPos.z + (toPos.z - fromPos.z) * t
|
|
1196
|
+
});
|
|
1197
|
+
}
|
|
1198
|
+
this.particleSystems.set(streamName, {
|
|
1199
|
+
particles,
|
|
1200
|
+
color: this.getDataTypeColor(dataType),
|
|
1201
|
+
lifetime: 5e3,
|
|
1202
|
+
speed: 0.02
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
createFlowingStream(name, position, data) {
|
|
1206
|
+
const count = Array.isArray(data) ? Math.min(data.length, 50) : 10;
|
|
1207
|
+
this.createParticleEffect(`${name}_flow`, position, "#45b7d1", count);
|
|
1208
|
+
}
|
|
1209
|
+
createExecutionEffect(name, position) {
|
|
1210
|
+
this.createParticleEffect(`${name}_execution`, position, "#ff4500", 30);
|
|
1211
|
+
}
|
|
1212
|
+
createDataVisualization(name, data, position) {
|
|
1213
|
+
let count = 10;
|
|
1214
|
+
if (Array.isArray(data)) {
|
|
1215
|
+
count = Math.min(data.length, 100);
|
|
1216
|
+
} else if (typeof data === "object" && data !== null) {
|
|
1217
|
+
count = Math.min(Object.keys(data).length * 5, 50);
|
|
1218
|
+
}
|
|
1219
|
+
this.createParticleEffect(`${name}_visualization`, position, "#32cd32", count);
|
|
1220
|
+
}
|
|
1221
|
+
getDataTypeColor(dataType) {
|
|
1222
|
+
const colors = {
|
|
1223
|
+
"string": "#ff6b35",
|
|
1224
|
+
"number": "#4ecdc4",
|
|
1225
|
+
"boolean": "#45b7d1",
|
|
1226
|
+
"object": "#96ceb4",
|
|
1227
|
+
"array": "#ffeaa7",
|
|
1228
|
+
"any": "#dda0dd",
|
|
1229
|
+
"move": "#ff69b4"
|
|
1230
|
+
};
|
|
1231
|
+
return colors[dataType] || "#ffffff";
|
|
1232
|
+
}
|
|
1233
|
+
// ============================================================================
|
|
1234
|
+
// Public API
|
|
1235
|
+
// ============================================================================
|
|
1236
|
+
getParticleSystems() {
|
|
1237
|
+
return new Map(this.particleSystems);
|
|
1238
|
+
}
|
|
1239
|
+
updateParticles(deltaTime) {
|
|
1240
|
+
for (const [name, system] of this.particleSystems) {
|
|
1241
|
+
system.lifetime -= deltaTime;
|
|
1242
|
+
system.particles.forEach((particle) => {
|
|
1243
|
+
particle.x += (Math.random() - 0.5) * system.speed;
|
|
1244
|
+
particle.y += (Math.random() - 0.5) * system.speed;
|
|
1245
|
+
particle.z += (Math.random() - 0.5) * system.speed;
|
|
1246
|
+
});
|
|
1247
|
+
if (system.lifetime <= 0) {
|
|
1248
|
+
this.particleSystems.delete(name);
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
getContext() {
|
|
1253
|
+
return { ...this.context };
|
|
1254
|
+
}
|
|
1255
|
+
getUIElements() {
|
|
1256
|
+
return new Map(this.uiElements);
|
|
1257
|
+
}
|
|
1258
|
+
getUIElement(name) {
|
|
1259
|
+
return this.uiElements.get(name);
|
|
1260
|
+
}
|
|
1261
|
+
getAnimations() {
|
|
1262
|
+
return new Map(this.animations);
|
|
1263
|
+
}
|
|
1264
|
+
reset() {
|
|
1265
|
+
this.context = this.createEmptyContext();
|
|
1266
|
+
this.currentScope = { variables: this.context.variables };
|
|
1267
|
+
this.callStack = [];
|
|
1268
|
+
this.particleSystems.clear();
|
|
1269
|
+
this.executionHistory = [];
|
|
1270
|
+
this.eventHandlers.clear();
|
|
1271
|
+
this.animations.clear();
|
|
1272
|
+
this.uiElements.clear();
|
|
1273
|
+
}
|
|
1274
|
+
createEmptyContext() {
|
|
1275
|
+
return {
|
|
1276
|
+
variables: /* @__PURE__ */ new Map(),
|
|
1277
|
+
functions: /* @__PURE__ */ new Map(),
|
|
1278
|
+
exports: /* @__PURE__ */ new Map(),
|
|
1279
|
+
connections: [],
|
|
1280
|
+
spatialMemory: /* @__PURE__ */ new Map(),
|
|
1281
|
+
hologramState: /* @__PURE__ */ new Map(),
|
|
1282
|
+
executionStack: []
|
|
1283
|
+
};
|
|
1284
|
+
}
|
|
1285
|
+
getExecutionHistory() {
|
|
1286
|
+
return [...this.executionHistory];
|
|
1287
|
+
}
|
|
1288
|
+
getHologramStates() {
|
|
1289
|
+
return new Map(this.context.hologramState);
|
|
1290
|
+
}
|
|
1291
|
+
getCallStack() {
|
|
1292
|
+
return [...this.callStack];
|
|
1293
|
+
}
|
|
1294
|
+
};
|
|
1295
|
+
|
|
1296
|
+
exports.HoloScriptRuntime = HoloScriptRuntime;
|
|
1297
|
+
//# sourceMappingURL=chunk-3N67RLQP.cjs.map
|
|
1298
|
+
//# sourceMappingURL=chunk-3N67RLQP.cjs.map
|