@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
|
@@ -1,144 +1,81 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Step-through debugging with breakpoints, call stack inspection,
|
|
5
|
-
* and variable watch capabilities.
|
|
6
|
-
*/
|
|
1
|
+
import { HoloScriptCodeParser } from './chunk-MCP6D4LT.js';
|
|
2
|
+
import { HoloScriptRuntime } from './chunk-EU6CZMGJ.js';
|
|
7
3
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
line: number;
|
|
27
|
-
column: number;
|
|
28
|
-
variables: Map<string, unknown>;
|
|
29
|
-
node: ASTNode;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface DebugState {
|
|
33
|
-
status: 'running' | 'paused' | 'stopped' | 'stepping';
|
|
34
|
-
currentLine: number;
|
|
35
|
-
currentColumn: number;
|
|
36
|
-
currentNode: ASTNode | null;
|
|
37
|
-
callStack: StackFrame[];
|
|
38
|
-
breakpoints: Breakpoint[];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export type StepMode = 'into' | 'over' | 'out';
|
|
42
|
-
|
|
43
|
-
export interface DebugEvent {
|
|
44
|
-
type: 'breakpoint-hit' | 'step-complete' | 'exception' | 'output' | 'state-change';
|
|
45
|
-
data: unknown;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
type DebugEventHandler = (event: DebugEvent) => void;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* HoloScript Debugger with breakpoints and step-through execution
|
|
52
|
-
*/
|
|
53
|
-
export class HoloScriptDebugger {
|
|
54
|
-
private runtime: HoloScriptRuntime;
|
|
55
|
-
private parser: HoloScriptCodeParser;
|
|
56
|
-
private breakpoints: Map<string, Breakpoint> = new Map();
|
|
57
|
-
private callStack: StackFrame[] = [];
|
|
58
|
-
private currentAST: ASTNode[] = [];
|
|
59
|
-
private currentNodeIndex: number = 0;
|
|
60
|
-
private frameIdCounter: number = 0;
|
|
61
|
-
private breakpointIdCounter: number = 0;
|
|
62
|
-
private eventHandlers: Map<string, DebugEventHandler[]> = new Map();
|
|
63
|
-
|
|
64
|
-
private state: DebugState = {
|
|
65
|
-
status: 'stopped',
|
|
66
|
-
currentLine: 0,
|
|
67
|
-
currentColumn: 0,
|
|
68
|
-
currentNode: null,
|
|
69
|
-
callStack: [],
|
|
70
|
-
breakpoints: [],
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
constructor(runtime?: HoloScriptRuntime) {
|
|
4
|
+
// src/HoloScriptDebugger.ts
|
|
5
|
+
var HoloScriptDebugger = class {
|
|
6
|
+
constructor(runtime) {
|
|
7
|
+
this.breakpoints = /* @__PURE__ */ new Map();
|
|
8
|
+
this.callStack = [];
|
|
9
|
+
this.currentAST = [];
|
|
10
|
+
this.currentNodeIndex = 0;
|
|
11
|
+
this.frameIdCounter = 0;
|
|
12
|
+
this.breakpointIdCounter = 0;
|
|
13
|
+
this.eventHandlers = /* @__PURE__ */ new Map();
|
|
14
|
+
this.state = {
|
|
15
|
+
status: "stopped",
|
|
16
|
+
currentLine: 0,
|
|
17
|
+
currentColumn: 0,
|
|
18
|
+
currentNode: null,
|
|
19
|
+
callStack: [],
|
|
20
|
+
breakpoints: []
|
|
21
|
+
};
|
|
74
22
|
this.runtime = runtime || new HoloScriptRuntime();
|
|
75
23
|
this.parser = new HoloScriptCodeParser();
|
|
76
24
|
}
|
|
77
|
-
|
|
78
25
|
/**
|
|
79
26
|
* Load source code for debugging
|
|
80
27
|
*/
|
|
81
|
-
loadSource(code
|
|
28
|
+
loadSource(code, file) {
|
|
82
29
|
const parseResult = this.parser.parse(code);
|
|
83
|
-
|
|
84
30
|
if (!parseResult.success) {
|
|
85
31
|
return {
|
|
86
32
|
success: false,
|
|
87
|
-
errors: parseResult.errors.map(e => `Line ${e.line}: ${e.message}`)
|
|
33
|
+
errors: parseResult.errors.map((e) => `Line ${e.line}: ${e.message}`)
|
|
88
34
|
};
|
|
89
35
|
}
|
|
90
|
-
|
|
91
36
|
this.currentAST = parseResult.ast;
|
|
92
37
|
this.currentNodeIndex = 0;
|
|
93
|
-
this.state.status =
|
|
38
|
+
this.state.status = "stopped";
|
|
94
39
|
this.callStack = [];
|
|
95
|
-
|
|
96
|
-
// Store file reference in nodes
|
|
97
40
|
if (file) {
|
|
98
41
|
for (const node of this.currentAST) {
|
|
99
|
-
|
|
42
|
+
node.file = file;
|
|
100
43
|
}
|
|
101
44
|
}
|
|
102
|
-
|
|
103
45
|
return { success: true };
|
|
104
46
|
}
|
|
105
|
-
|
|
106
47
|
/**
|
|
107
48
|
* Set a breakpoint at a line
|
|
108
49
|
*/
|
|
109
|
-
setBreakpoint(line
|
|
50
|
+
setBreakpoint(line, options = {}) {
|
|
110
51
|
const id = `bp_${++this.breakpointIdCounter}`;
|
|
111
|
-
const breakpoint
|
|
52
|
+
const breakpoint = {
|
|
112
53
|
id,
|
|
113
54
|
line,
|
|
114
55
|
column: options.column,
|
|
115
56
|
condition: options.condition,
|
|
116
57
|
hitCount: 0,
|
|
117
58
|
enabled: options.enabled !== false,
|
|
118
|
-
file: options.file
|
|
59
|
+
file: options.file
|
|
119
60
|
};
|
|
120
|
-
|
|
121
61
|
this.breakpoints.set(id, breakpoint);
|
|
122
62
|
this.updateBreakpointList();
|
|
123
|
-
|
|
124
63
|
return breakpoint;
|
|
125
64
|
}
|
|
126
|
-
|
|
127
65
|
/**
|
|
128
66
|
* Remove a breakpoint by ID
|
|
129
67
|
*/
|
|
130
|
-
removeBreakpoint(id
|
|
68
|
+
removeBreakpoint(id) {
|
|
131
69
|
const removed = this.breakpoints.delete(id);
|
|
132
70
|
if (removed) {
|
|
133
71
|
this.updateBreakpointList();
|
|
134
72
|
}
|
|
135
73
|
return removed;
|
|
136
74
|
}
|
|
137
|
-
|
|
138
75
|
/**
|
|
139
76
|
* Remove all breakpoints at a line
|
|
140
77
|
*/
|
|
141
|
-
removeBreakpointsAtLine(line
|
|
78
|
+
removeBreakpointsAtLine(line) {
|
|
142
79
|
let removed = 0;
|
|
143
80
|
for (const [id, bp] of this.breakpoints) {
|
|
144
81
|
if (bp.line === line) {
|
|
@@ -151,11 +88,10 @@ export class HoloScriptDebugger {
|
|
|
151
88
|
}
|
|
152
89
|
return removed;
|
|
153
90
|
}
|
|
154
|
-
|
|
155
91
|
/**
|
|
156
92
|
* Toggle breakpoint enabled state
|
|
157
93
|
*/
|
|
158
|
-
toggleBreakpoint(id
|
|
94
|
+
toggleBreakpoint(id) {
|
|
159
95
|
const bp = this.breakpoints.get(id);
|
|
160
96
|
if (bp) {
|
|
161
97
|
bp.enabled = !bp.enabled;
|
|
@@ -164,172 +100,143 @@ export class HoloScriptDebugger {
|
|
|
164
100
|
}
|
|
165
101
|
return false;
|
|
166
102
|
}
|
|
167
|
-
|
|
168
103
|
/**
|
|
169
104
|
* Get all breakpoints
|
|
170
105
|
*/
|
|
171
|
-
getBreakpoints()
|
|
106
|
+
getBreakpoints() {
|
|
172
107
|
return Array.from(this.breakpoints.values());
|
|
173
108
|
}
|
|
174
|
-
|
|
175
109
|
/**
|
|
176
110
|
* Clear all breakpoints
|
|
177
111
|
*/
|
|
178
|
-
clearBreakpoints()
|
|
112
|
+
clearBreakpoints() {
|
|
179
113
|
this.breakpoints.clear();
|
|
180
114
|
this.updateBreakpointList();
|
|
181
115
|
}
|
|
182
|
-
|
|
183
116
|
/**
|
|
184
117
|
* Start debugging from the beginning
|
|
185
118
|
*/
|
|
186
|
-
async start()
|
|
119
|
+
async start() {
|
|
187
120
|
this.currentNodeIndex = 0;
|
|
188
121
|
this.callStack = [];
|
|
189
122
|
this.frameIdCounter = 0;
|
|
190
123
|
this.runtime.reset();
|
|
191
|
-
this.state.status =
|
|
192
|
-
|
|
124
|
+
this.state.status = "running";
|
|
193
125
|
await this.runUntilBreakpoint();
|
|
194
126
|
}
|
|
195
|
-
|
|
196
127
|
/**
|
|
197
128
|
* Continue execution until next breakpoint or end
|
|
198
129
|
*/
|
|
199
|
-
async continue()
|
|
200
|
-
if (this.state.status !==
|
|
201
|
-
|
|
202
|
-
this.state.status = 'running';
|
|
130
|
+
async continue() {
|
|
131
|
+
if (this.state.status !== "paused") return;
|
|
132
|
+
this.state.status = "running";
|
|
203
133
|
this.currentNodeIndex++;
|
|
204
134
|
await this.runUntilBreakpoint();
|
|
205
135
|
}
|
|
206
|
-
|
|
207
136
|
/**
|
|
208
137
|
* Step into the next node
|
|
209
138
|
*/
|
|
210
|
-
async stepInto()
|
|
211
|
-
if (this.state.status !==
|
|
212
|
-
|
|
213
|
-
this.
|
|
214
|
-
await this.executeStep('into');
|
|
139
|
+
async stepInto() {
|
|
140
|
+
if (this.state.status !== "paused") return;
|
|
141
|
+
this.state.status = "stepping";
|
|
142
|
+
await this.executeStep("into");
|
|
215
143
|
}
|
|
216
|
-
|
|
217
144
|
/**
|
|
218
145
|
* Step over the current node
|
|
219
146
|
*/
|
|
220
|
-
async stepOver()
|
|
221
|
-
if (this.state.status !==
|
|
222
|
-
|
|
223
|
-
this.
|
|
224
|
-
await this.executeStep('over');
|
|
147
|
+
async stepOver() {
|
|
148
|
+
if (this.state.status !== "paused") return;
|
|
149
|
+
this.state.status = "stepping";
|
|
150
|
+
await this.executeStep("over");
|
|
225
151
|
}
|
|
226
|
-
|
|
227
152
|
/**
|
|
228
153
|
* Step out of the current function
|
|
229
154
|
*/
|
|
230
|
-
async stepOut()
|
|
231
|
-
if (this.state.status !==
|
|
232
|
-
|
|
233
|
-
this.
|
|
234
|
-
await this.executeStep('out');
|
|
155
|
+
async stepOut() {
|
|
156
|
+
if (this.state.status !== "paused") return;
|
|
157
|
+
this.state.status = "stepping";
|
|
158
|
+
await this.executeStep("out");
|
|
235
159
|
}
|
|
236
|
-
|
|
237
160
|
/**
|
|
238
161
|
* Stop debugging
|
|
239
162
|
*/
|
|
240
|
-
stop()
|
|
241
|
-
this.state.status =
|
|
163
|
+
stop() {
|
|
164
|
+
this.state.status = "stopped";
|
|
242
165
|
this.callStack = [];
|
|
243
166
|
this.currentNodeIndex = 0;
|
|
244
|
-
this.emitEvent({ type:
|
|
167
|
+
this.emitEvent({ type: "state-change", data: { status: "stopped" } });
|
|
245
168
|
}
|
|
246
|
-
|
|
247
169
|
/**
|
|
248
170
|
* Pause execution
|
|
249
171
|
*/
|
|
250
|
-
pause()
|
|
251
|
-
if (this.state.status ===
|
|
252
|
-
this.state.status =
|
|
253
|
-
this.emitEvent({ type:
|
|
172
|
+
pause() {
|
|
173
|
+
if (this.state.status === "running") {
|
|
174
|
+
this.state.status = "paused";
|
|
175
|
+
this.emitEvent({ type: "state-change", data: { status: "paused" } });
|
|
254
176
|
}
|
|
255
177
|
}
|
|
256
|
-
|
|
257
178
|
/**
|
|
258
179
|
* Get current debug state
|
|
259
180
|
*/
|
|
260
|
-
getState()
|
|
181
|
+
getState() {
|
|
261
182
|
return { ...this.state };
|
|
262
183
|
}
|
|
263
|
-
|
|
264
184
|
/**
|
|
265
185
|
* Get call stack
|
|
266
186
|
*/
|
|
267
|
-
getCallStack()
|
|
187
|
+
getCallStack() {
|
|
268
188
|
return [...this.callStack];
|
|
269
189
|
}
|
|
270
|
-
|
|
271
190
|
/**
|
|
272
191
|
* Get variables at a specific stack frame
|
|
273
192
|
*/
|
|
274
|
-
getVariables(frameId
|
|
275
|
-
if (frameId !==
|
|
276
|
-
const frame = this.callStack.find(f => f.id === frameId);
|
|
277
|
-
return frame?.variables || new Map();
|
|
193
|
+
getVariables(frameId) {
|
|
194
|
+
if (frameId !== void 0) {
|
|
195
|
+
const frame = this.callStack.find((f) => f.id === frameId);
|
|
196
|
+
return frame?.variables || /* @__PURE__ */ new Map();
|
|
278
197
|
}
|
|
279
|
-
|
|
280
|
-
// Return all variables from runtime context
|
|
281
198
|
return new Map(this.runtime.getContext().variables);
|
|
282
199
|
}
|
|
283
|
-
|
|
284
200
|
/**
|
|
285
201
|
* Evaluate an expression in the current context
|
|
286
202
|
*/
|
|
287
|
-
async evaluate(expression
|
|
203
|
+
async evaluate(expression) {
|
|
288
204
|
try {
|
|
289
|
-
// Try to evaluate as a variable lookup first
|
|
290
205
|
const varValue = this.runtime.getVariable(expression);
|
|
291
|
-
if (varValue !==
|
|
206
|
+
if (varValue !== void 0) {
|
|
292
207
|
return { value: varValue };
|
|
293
208
|
}
|
|
294
|
-
|
|
295
|
-
// Try to parse and execute as an expression
|
|
296
209
|
const parseResult = this.parser.parse(expression);
|
|
297
210
|
if (!parseResult.success) {
|
|
298
|
-
return { value:
|
|
211
|
+
return { value: void 0, error: parseResult.errors[0]?.message };
|
|
299
212
|
}
|
|
300
|
-
|
|
301
|
-
// Execute the expression
|
|
302
213
|
const results = await this.runtime.executeProgram(parseResult.ast);
|
|
303
214
|
const lastResult = results[results.length - 1];
|
|
304
|
-
|
|
305
215
|
return { value: lastResult?.output };
|
|
306
216
|
} catch (error) {
|
|
307
|
-
return { value:
|
|
217
|
+
return { value: void 0, error: String(error) };
|
|
308
218
|
}
|
|
309
219
|
}
|
|
310
|
-
|
|
311
220
|
/**
|
|
312
221
|
* Set a watch expression
|
|
313
222
|
*/
|
|
314
|
-
watch(expression
|
|
223
|
+
watch(expression) {
|
|
315
224
|
const id = `watch_${Date.now()}`;
|
|
316
225
|
return { id, expression };
|
|
317
226
|
}
|
|
318
|
-
|
|
319
227
|
/**
|
|
320
228
|
* Register an event handler
|
|
321
229
|
*/
|
|
322
|
-
on(event
|
|
230
|
+
on(event, handler) {
|
|
323
231
|
if (!this.eventHandlers.has(event)) {
|
|
324
232
|
this.eventHandlers.set(event, []);
|
|
325
233
|
}
|
|
326
|
-
this.eventHandlers.get(event)
|
|
234
|
+
this.eventHandlers.get(event).push(handler);
|
|
327
235
|
}
|
|
328
|
-
|
|
329
236
|
/**
|
|
330
237
|
* Remove an event handler
|
|
331
238
|
*/
|
|
332
|
-
off(event
|
|
239
|
+
off(event, handler) {
|
|
333
240
|
const handlers = this.eventHandlers.get(event);
|
|
334
241
|
if (handlers) {
|
|
335
242
|
const index = handlers.indexOf(handler);
|
|
@@ -338,143 +245,108 @@ export class HoloScriptDebugger {
|
|
|
338
245
|
}
|
|
339
246
|
}
|
|
340
247
|
}
|
|
341
|
-
|
|
342
248
|
/**
|
|
343
249
|
* Get the underlying runtime
|
|
344
250
|
*/
|
|
345
|
-
getRuntime()
|
|
251
|
+
getRuntime() {
|
|
346
252
|
return this.runtime;
|
|
347
253
|
}
|
|
348
|
-
|
|
349
254
|
// Private methods
|
|
350
|
-
|
|
351
|
-
private async runUntilBreakpoint(): Promise<void> {
|
|
255
|
+
async runUntilBreakpoint() {
|
|
352
256
|
while (this.currentNodeIndex < this.currentAST.length) {
|
|
353
|
-
if (this.state.status ===
|
|
354
|
-
|
|
257
|
+
if (this.state.status === "stopped") break;
|
|
355
258
|
const node = this.currentAST[this.currentNodeIndex];
|
|
356
|
-
|
|
357
|
-
// Check for breakpoint
|
|
358
259
|
if (this.shouldBreakAt(node)) {
|
|
359
|
-
this.state.status =
|
|
260
|
+
this.state.status = "paused";
|
|
360
261
|
this.updateCurrentState(node);
|
|
361
|
-
|
|
362
262
|
const bp = this.findBreakpointAtLine(node.line ?? 0);
|
|
363
263
|
if (bp) {
|
|
364
264
|
bp.hitCount++;
|
|
365
265
|
this.emitEvent({
|
|
366
|
-
type:
|
|
367
|
-
data: { breakpoint: bp, node, line: node.line ?? 0 }
|
|
266
|
+
type: "breakpoint-hit",
|
|
267
|
+
data: { breakpoint: bp, node, line: node.line ?? 0 }
|
|
368
268
|
});
|
|
369
269
|
}
|
|
370
270
|
return;
|
|
371
271
|
}
|
|
372
|
-
|
|
373
|
-
// Execute the node
|
|
374
272
|
await this.executeNode(node);
|
|
375
273
|
this.currentNodeIndex++;
|
|
376
274
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
this.state.status = 'stopped';
|
|
380
|
-
this.emitEvent({ type: 'state-change', data: { status: 'stopped', reason: 'complete' } });
|
|
275
|
+
this.state.status = "stopped";
|
|
276
|
+
this.emitEvent({ type: "state-change", data: { status: "stopped", reason: "complete" } });
|
|
381
277
|
}
|
|
382
|
-
|
|
383
|
-
private async executeStep(mode: StepMode): Promise<void> {
|
|
278
|
+
async executeStep(mode) {
|
|
384
279
|
const startStackDepth = this.callStack.length;
|
|
385
|
-
|
|
386
280
|
if (this.currentNodeIndex >= this.currentAST.length) {
|
|
387
|
-
this.state.status =
|
|
281
|
+
this.state.status = "stopped";
|
|
388
282
|
return;
|
|
389
283
|
}
|
|
390
|
-
|
|
391
284
|
const node = this.currentAST[this.currentNodeIndex];
|
|
392
|
-
|
|
393
285
|
switch (mode) {
|
|
394
|
-
case
|
|
395
|
-
// Execute one node, stepping into function calls
|
|
286
|
+
case "into":
|
|
396
287
|
await this.executeNode(node);
|
|
397
288
|
this.currentNodeIndex++;
|
|
398
289
|
break;
|
|
399
|
-
|
|
400
|
-
case 'over':
|
|
401
|
-
// Execute one node, treating function calls as single steps
|
|
290
|
+
case "over":
|
|
402
291
|
await this.executeNode(node);
|
|
403
292
|
this.currentNodeIndex++;
|
|
404
293
|
break;
|
|
405
|
-
|
|
406
|
-
case 'out':
|
|
407
|
-
// Execute until we leave the current stack frame
|
|
294
|
+
case "out":
|
|
408
295
|
while (this.currentNodeIndex < this.currentAST.length) {
|
|
409
296
|
await this.executeNode(this.currentAST[this.currentNodeIndex]);
|
|
410
297
|
this.currentNodeIndex++;
|
|
411
|
-
|
|
412
298
|
if (this.callStack.length < startStackDepth) {
|
|
413
299
|
break;
|
|
414
300
|
}
|
|
415
301
|
}
|
|
416
302
|
break;
|
|
417
303
|
}
|
|
418
|
-
|
|
419
|
-
// Update state after step
|
|
420
304
|
if (this.currentNodeIndex < this.currentAST.length) {
|
|
421
|
-
this.state.status =
|
|
305
|
+
this.state.status = "paused";
|
|
422
306
|
this.updateCurrentState(this.currentAST[this.currentNodeIndex]);
|
|
423
307
|
this.emitEvent({
|
|
424
|
-
type:
|
|
425
|
-
data: { mode, node: this.currentAST[this.currentNodeIndex] }
|
|
308
|
+
type: "step-complete",
|
|
309
|
+
data: { mode, node: this.currentAST[this.currentNodeIndex] }
|
|
426
310
|
});
|
|
427
311
|
} else {
|
|
428
|
-
this.state.status =
|
|
429
|
-
this.emitEvent({ type:
|
|
312
|
+
this.state.status = "stopped";
|
|
313
|
+
this.emitEvent({ type: "state-change", data: { status: "stopped", reason: "complete" } });
|
|
430
314
|
}
|
|
431
315
|
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
if (node.type === 'function') {
|
|
436
|
-
const funcNode = node as ASTNode & { name: string };
|
|
316
|
+
async executeNode(node) {
|
|
317
|
+
if (node.type === "function") {
|
|
318
|
+
const funcNode = node;
|
|
437
319
|
this.pushStackFrame(funcNode.name, node);
|
|
438
320
|
}
|
|
439
|
-
|
|
440
321
|
try {
|
|
441
|
-
// Execute via runtime
|
|
442
322
|
const result = await this.runtime.executeNode(node);
|
|
443
|
-
|
|
444
323
|
if (!result.success && result.error) {
|
|
445
324
|
this.emitEvent({
|
|
446
|
-
type:
|
|
447
|
-
data: { error: result.error, node, line: node.line }
|
|
325
|
+
type: "exception",
|
|
326
|
+
data: { error: result.error, node, line: node.line }
|
|
448
327
|
});
|
|
449
328
|
}
|
|
450
|
-
|
|
451
|
-
if (result.output !== undefined) {
|
|
329
|
+
if (result.output !== void 0) {
|
|
452
330
|
this.emitEvent({
|
|
453
|
-
type:
|
|
454
|
-
data: { output: result.output, node }
|
|
331
|
+
type: "output",
|
|
332
|
+
data: { output: result.output, node }
|
|
455
333
|
});
|
|
456
334
|
}
|
|
457
335
|
} catch (error) {
|
|
458
336
|
this.emitEvent({
|
|
459
|
-
type:
|
|
460
|
-
data: { error: String(error), node, line: node.line }
|
|
337
|
+
type: "exception",
|
|
338
|
+
data: { error: String(error), node, line: node.line }
|
|
461
339
|
});
|
|
462
340
|
}
|
|
463
|
-
|
|
464
|
-
// Pop stack frame when function completes
|
|
465
|
-
if (node.type === 'function') {
|
|
341
|
+
if (node.type === "function") {
|
|
466
342
|
this.popStackFrame();
|
|
467
343
|
}
|
|
468
344
|
}
|
|
469
|
-
|
|
470
|
-
private shouldBreakAt(node: ASTNode): boolean {
|
|
345
|
+
shouldBreakAt(node) {
|
|
471
346
|
const line = node.line;
|
|
472
|
-
|
|
473
347
|
for (const bp of this.breakpoints.values()) {
|
|
474
348
|
if (!bp.enabled) continue;
|
|
475
349
|
if (bp.line !== line) continue;
|
|
476
|
-
|
|
477
|
-
// Check condition if present
|
|
478
350
|
if (bp.condition) {
|
|
479
351
|
try {
|
|
480
352
|
const value = this.runtime.getVariable(bp.condition);
|
|
@@ -483,14 +355,11 @@ export class HoloScriptDebugger {
|
|
|
483
355
|
continue;
|
|
484
356
|
}
|
|
485
357
|
}
|
|
486
|
-
|
|
487
358
|
return true;
|
|
488
359
|
}
|
|
489
|
-
|
|
490
360
|
return false;
|
|
491
361
|
}
|
|
492
|
-
|
|
493
|
-
private findBreakpointAtLine(line: number): Breakpoint | null {
|
|
362
|
+
findBreakpointAtLine(line) {
|
|
494
363
|
for (const bp of this.breakpoints.values()) {
|
|
495
364
|
if (bp.line === line && bp.enabled) {
|
|
496
365
|
return bp;
|
|
@@ -498,63 +367,55 @@ export class HoloScriptDebugger {
|
|
|
498
367
|
}
|
|
499
368
|
return null;
|
|
500
369
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
const frame: StackFrame = {
|
|
370
|
+
pushStackFrame(name, node) {
|
|
371
|
+
const frame = {
|
|
504
372
|
id: ++this.frameIdCounter,
|
|
505
373
|
name,
|
|
506
|
-
file:
|
|
374
|
+
file: node.file,
|
|
507
375
|
line: node.line ?? 0,
|
|
508
376
|
column: node.column ?? 0,
|
|
509
377
|
variables: new Map(this.runtime.getContext().variables),
|
|
510
|
-
node
|
|
378
|
+
node
|
|
511
379
|
};
|
|
512
|
-
|
|
513
380
|
this.callStack.push(frame);
|
|
514
381
|
this.state.callStack = [...this.callStack];
|
|
515
382
|
}
|
|
516
|
-
|
|
517
|
-
private popStackFrame(): StackFrame | undefined {
|
|
383
|
+
popStackFrame() {
|
|
518
384
|
const frame = this.callStack.pop();
|
|
519
385
|
this.state.callStack = [...this.callStack];
|
|
520
386
|
return frame;
|
|
521
387
|
}
|
|
522
|
-
|
|
523
|
-
private updateCurrentState(node: ASTNode): void {
|
|
388
|
+
updateCurrentState(node) {
|
|
524
389
|
this.state.currentLine = node.line ?? 0;
|
|
525
390
|
this.state.currentColumn = node.column ?? 0;
|
|
526
391
|
this.state.currentNode = node;
|
|
527
392
|
}
|
|
528
|
-
|
|
529
|
-
private updateBreakpointList(): void {
|
|
393
|
+
updateBreakpointList() {
|
|
530
394
|
this.state.breakpoints = Array.from(this.breakpoints.values());
|
|
531
395
|
}
|
|
532
|
-
|
|
533
|
-
private emitEvent(event: DebugEvent): void {
|
|
396
|
+
emitEvent(event) {
|
|
534
397
|
const handlers = this.eventHandlers.get(event.type) || [];
|
|
535
398
|
for (const handler of handlers) {
|
|
536
399
|
try {
|
|
537
400
|
handler(event);
|
|
538
401
|
} catch (error) {
|
|
539
|
-
console.error(
|
|
402
|
+
console.error("Debug event handler error:", error);
|
|
540
403
|
}
|
|
541
404
|
}
|
|
542
|
-
|
|
543
|
-
// Also emit to 'all' handlers
|
|
544
|
-
const allHandlers = this.eventHandlers.get('all') || [];
|
|
405
|
+
const allHandlers = this.eventHandlers.get("all") || [];
|
|
545
406
|
for (const handler of allHandlers) {
|
|
546
407
|
try {
|
|
547
408
|
handler(event);
|
|
548
409
|
} catch (error) {
|
|
549
|
-
console.error(
|
|
410
|
+
console.error("Debug event handler error:", error);
|
|
550
411
|
}
|
|
551
412
|
}
|
|
552
413
|
}
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
/**
|
|
556
|
-
* Create a debugger instance
|
|
557
|
-
*/
|
|
558
|
-
export function createDebugger(runtime?: HoloScriptRuntime): HoloScriptDebugger {
|
|
414
|
+
};
|
|
415
|
+
function createDebugger(runtime) {
|
|
559
416
|
return new HoloScriptDebugger(runtime);
|
|
560
417
|
}
|
|
418
|
+
|
|
419
|
+
export { HoloScriptDebugger, createDebugger };
|
|
420
|
+
//# sourceMappingURL=chunk-VYIDLUCV.js.map
|
|
421
|
+
//# sourceMappingURL=chunk-VYIDLUCV.js.map
|