@holoscript/core 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-2XXE34KS.js +344 -0
- package/dist/chunk-2XXE34KS.js.map +1 -0
- package/dist/chunk-3X2EGU7Z.cjs +52 -0
- package/dist/chunk-3X2EGU7Z.cjs.map +1 -0
- package/dist/chunk-AFFVFO4D.js +1689 -0
- package/dist/chunk-AFFVFO4D.js.map +1 -0
- package/dist/chunk-DGUM43GV.js +10 -0
- package/dist/chunk-DGUM43GV.js.map +1 -0
- package/{src/HoloScriptDebugger.ts → dist/chunk-DOY73HDH.js} +118 -257
- package/dist/chunk-DOY73HDH.js.map +1 -0
- package/dist/chunk-JEQ2X3Z6.cjs +12 -0
- package/dist/chunk-JEQ2X3Z6.cjs.map +1 -0
- package/dist/chunk-L6VLNVKP.cjs +1691 -0
- package/dist/chunk-L6VLNVKP.cjs.map +1 -0
- package/dist/chunk-MFNO57XL.cjs +347 -0
- package/dist/chunk-MFNO57XL.cjs.map +1 -0
- package/dist/chunk-R75MREOS.cjs +424 -0
- package/dist/chunk-R75MREOS.cjs.map +1 -0
- package/dist/chunk-SATNCODL.js +45 -0
- package/dist/chunk-SATNCODL.js.map +1 -0
- package/dist/chunk-T57ZL7KR.cjs +1281 -0
- package/dist/chunk-T57ZL7KR.cjs.map +1 -0
- package/dist/chunk-U72GEJZT.js +1279 -0
- package/dist/chunk-U72GEJZT.js.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 +6803 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4093 -0
- package/dist/index.d.ts +4093 -0
- package/dist/index.js +6715 -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 +172 -0
- package/dist/parser.d.ts +172 -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 +200 -0
- package/dist/runtime.d.ts +200 -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-4h8cbtF_.d.cts +329 -0
- package/dist/types-4h8cbtF_.d.ts +329 -0
- package/package.json +17 -13
- 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/HoloScriptRuntime.ts +0 -1653
- 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,200 @@
|
|
|
1
|
+
import { v as ImportLoader, J as HoloScriptValue, A as ASTNode, B as ExecutionResult, K as ParticleSystem, z as RuntimeContext, Q as Animation, b as HologramProperties } from './types-4h8cbtF_.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* HoloScript Runtime Engine
|
|
5
|
+
*
|
|
6
|
+
* Executes HoloScript AST in VR environment with spatial computation.
|
|
7
|
+
* Supports:
|
|
8
|
+
* - Orb creation and manipulation
|
|
9
|
+
* - Function definition and invocation with arguments
|
|
10
|
+
* - Connections and reactive data flow
|
|
11
|
+
* - Gates (conditionals)
|
|
12
|
+
* - Streams (data pipelines)
|
|
13
|
+
* - 2D UI elements
|
|
14
|
+
* - Built-in commands (show, hide, animate, pulse)
|
|
15
|
+
* - Expression evaluation
|
|
16
|
+
* - Event system
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Event handler type
|
|
21
|
+
*/
|
|
22
|
+
type EventHandler = (data?: HoloScriptValue) => void | Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* UI Element state
|
|
25
|
+
*/
|
|
26
|
+
interface UIElementState {
|
|
27
|
+
type: string;
|
|
28
|
+
name: string;
|
|
29
|
+
properties: Record<string, HoloScriptValue>;
|
|
30
|
+
value?: HoloScriptValue;
|
|
31
|
+
visible: boolean;
|
|
32
|
+
enabled: boolean;
|
|
33
|
+
}
|
|
34
|
+
declare class HoloScriptRuntime {
|
|
35
|
+
private context;
|
|
36
|
+
private particleSystems;
|
|
37
|
+
private executionHistory;
|
|
38
|
+
private startTime;
|
|
39
|
+
private nodeCount;
|
|
40
|
+
private currentScope;
|
|
41
|
+
private callStack;
|
|
42
|
+
private eventHandlers;
|
|
43
|
+
private animations;
|
|
44
|
+
private uiElements;
|
|
45
|
+
private builtinFunctions;
|
|
46
|
+
constructor(_importLoader?: ImportLoader, customFunctions?: Record<string, (args: HoloScriptValue[]) => HoloScriptValue>);
|
|
47
|
+
/**
|
|
48
|
+
* Initialize built-in functions
|
|
49
|
+
*/
|
|
50
|
+
private initBuiltins;
|
|
51
|
+
/**
|
|
52
|
+
* Execute a single AST node
|
|
53
|
+
*/
|
|
54
|
+
executeNode(node: ASTNode): Promise<ExecutionResult>;
|
|
55
|
+
/**
|
|
56
|
+
* Execute multiple nodes or a single node (unified entry point)
|
|
57
|
+
*/
|
|
58
|
+
execute(nodes: ASTNode | ASTNode[]): Promise<ExecutionResult>;
|
|
59
|
+
/**
|
|
60
|
+
* Execute multiple nodes in sequence
|
|
61
|
+
*/
|
|
62
|
+
executeProgram(nodes: ASTNode[], depth?: number): Promise<ExecutionResult[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Call a function with arguments
|
|
65
|
+
*/
|
|
66
|
+
callFunction(name: string, args?: HoloScriptValue[]): Promise<ExecutionResult>;
|
|
67
|
+
/**
|
|
68
|
+
* Set a variable in current scope
|
|
69
|
+
*/
|
|
70
|
+
setVariable(name: string, value: HoloScriptValue): void;
|
|
71
|
+
/**
|
|
72
|
+
* Get a variable from scope chain
|
|
73
|
+
*/
|
|
74
|
+
getVariable(name: string): HoloScriptValue;
|
|
75
|
+
/**
|
|
76
|
+
* Evaluate an expression
|
|
77
|
+
*/
|
|
78
|
+
evaluateExpression(expr: string): HoloScriptValue;
|
|
79
|
+
private executeOrb;
|
|
80
|
+
private executeFunction;
|
|
81
|
+
private executeConnection;
|
|
82
|
+
private executeGate;
|
|
83
|
+
private executeStream;
|
|
84
|
+
private executeCall;
|
|
85
|
+
private executeDebug;
|
|
86
|
+
private executeVisualize;
|
|
87
|
+
private executeUIElement;
|
|
88
|
+
/**
|
|
89
|
+
* Execute generic voice commands
|
|
90
|
+
* Handles commands like: show, hide, animate, pulse, create
|
|
91
|
+
*/
|
|
92
|
+
private executeGeneric;
|
|
93
|
+
/**
|
|
94
|
+
* Execute 'show' command
|
|
95
|
+
*/
|
|
96
|
+
private executeShowCommand;
|
|
97
|
+
/**
|
|
98
|
+
* Execute 'hide' command
|
|
99
|
+
*/
|
|
100
|
+
private executeHideCommand;
|
|
101
|
+
/**
|
|
102
|
+
* Execute 'create' command
|
|
103
|
+
*/
|
|
104
|
+
private executeCreateCommand;
|
|
105
|
+
/**
|
|
106
|
+
* Execute 'animate' command
|
|
107
|
+
*/
|
|
108
|
+
private executeAnimateCommand;
|
|
109
|
+
/**
|
|
110
|
+
* Execute 'pulse' command
|
|
111
|
+
*/
|
|
112
|
+
private executePulseCommand;
|
|
113
|
+
/**
|
|
114
|
+
* Execute 'move' command
|
|
115
|
+
*/
|
|
116
|
+
private executeMoveCommand;
|
|
117
|
+
/**
|
|
118
|
+
* Execute 'delete' command
|
|
119
|
+
*/
|
|
120
|
+
private executeDeleteCommand;
|
|
121
|
+
private executeStructure;
|
|
122
|
+
private executeAssignment;
|
|
123
|
+
private executeReturn;
|
|
124
|
+
private evaluateCondition;
|
|
125
|
+
private applyTransformation;
|
|
126
|
+
/**
|
|
127
|
+
* Register event handler
|
|
128
|
+
*/
|
|
129
|
+
on(event: string, handler: EventHandler): void;
|
|
130
|
+
/**
|
|
131
|
+
* Register host function
|
|
132
|
+
*/
|
|
133
|
+
registerFunction(name: string, handler: (args: HoloScriptValue[]) => HoloScriptValue): void;
|
|
134
|
+
/**
|
|
135
|
+
* Remove event handler
|
|
136
|
+
*/
|
|
137
|
+
off(event: string, handler?: EventHandler): void;
|
|
138
|
+
/**
|
|
139
|
+
* Emit event
|
|
140
|
+
*/
|
|
141
|
+
emit(event: string, data?: unknown): Promise<void>;
|
|
142
|
+
/**
|
|
143
|
+
* Trigger UI event
|
|
144
|
+
*/
|
|
145
|
+
triggerUIEvent(elementName: string, eventType: string, data?: unknown): Promise<void>;
|
|
146
|
+
/**
|
|
147
|
+
* Update all animations
|
|
148
|
+
*/
|
|
149
|
+
updateAnimations(): void;
|
|
150
|
+
/**
|
|
151
|
+
* Update real-life and system variables ($time, $user, etc.)
|
|
152
|
+
*/
|
|
153
|
+
private updateSystemVariables;
|
|
154
|
+
private handleShop;
|
|
155
|
+
private handleInventory;
|
|
156
|
+
private handlePurchase;
|
|
157
|
+
private handlePresence;
|
|
158
|
+
private handleInvite;
|
|
159
|
+
private handleShare;
|
|
160
|
+
private handlePhysics;
|
|
161
|
+
private handleGravity;
|
|
162
|
+
private handleCollide;
|
|
163
|
+
/**
|
|
164
|
+
* Handle calculate_arc(start, end, speed)
|
|
165
|
+
*/
|
|
166
|
+
private handleCalculateArc;
|
|
167
|
+
private handleAnimate;
|
|
168
|
+
private applyEasing;
|
|
169
|
+
private createParticleEffect;
|
|
170
|
+
private createConnectionStream;
|
|
171
|
+
private createFlowingStream;
|
|
172
|
+
private createExecutionEffect;
|
|
173
|
+
private createDataVisualization;
|
|
174
|
+
private getDataTypeColor;
|
|
175
|
+
getParticleSystems(): Map<string, ParticleSystem>;
|
|
176
|
+
updateParticles(deltaTime: number): void;
|
|
177
|
+
getContext(): RuntimeContext;
|
|
178
|
+
getUIElements(): Map<string, UIElementState>;
|
|
179
|
+
getUIElement(name: string): UIElementState | undefined;
|
|
180
|
+
getAnimations(): Map<string, Animation>;
|
|
181
|
+
reset(): void;
|
|
182
|
+
private createEmptyContext;
|
|
183
|
+
private executeScale;
|
|
184
|
+
private executeFocus;
|
|
185
|
+
private executeEnvironment;
|
|
186
|
+
private executeComposition;
|
|
187
|
+
private executeTemplate;
|
|
188
|
+
private executeServerNode;
|
|
189
|
+
private executeDatabaseNode;
|
|
190
|
+
private executeFetchNode;
|
|
191
|
+
private executeTarget;
|
|
192
|
+
private executeStateDeclaration;
|
|
193
|
+
private applyDirectives;
|
|
194
|
+
getExecutionHistory(): ExecutionResult[];
|
|
195
|
+
getHologramStates(): Map<string, HologramProperties>;
|
|
196
|
+
getCallStack(): string[];
|
|
197
|
+
getState(): Record<string, HoloScriptValue>;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export { HoloScriptRuntime };
|
package/dist/runtime.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"runtime.js"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkMFNO57XL_cjs = require('./chunk-MFNO57XL.cjs');
|
|
4
|
+
require('./chunk-JEQ2X3Z6.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "HoloScriptTypeChecker", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkMFNO57XL_cjs.HoloScriptTypeChecker; }
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "createTypeChecker", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunkMFNO57XL_cjs.createTypeChecker; }
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=type-checker.cjs.map
|
|
17
|
+
//# sourceMappingURL=type-checker.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"type-checker.cjs"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { A as ASTNode, J as HoloScriptValue } from './types-4h8cbtF_.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* HoloScript Type Checker
|
|
5
|
+
*
|
|
6
|
+
* Static type analysis for HoloScript code.
|
|
7
|
+
* Validates types, detects errors, and provides type information.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
type HoloScriptType = 'number' | 'string' | 'boolean' | 'array' | 'object' | 'function' | 'void' | 'any' | 'unknown' | 'never' | 'orb' | 'stream' | 'connection' | 'gate';
|
|
11
|
+
interface TypeInfo {
|
|
12
|
+
type: HoloScriptType;
|
|
13
|
+
elementType?: HoloScriptType;
|
|
14
|
+
properties?: Map<string, TypeInfo>;
|
|
15
|
+
parameters?: ParameterType[];
|
|
16
|
+
returnType?: HoloScriptType;
|
|
17
|
+
nullable?: boolean;
|
|
18
|
+
}
|
|
19
|
+
interface ParameterType {
|
|
20
|
+
name: string;
|
|
21
|
+
type: HoloScriptType;
|
|
22
|
+
optional?: boolean;
|
|
23
|
+
defaultValue?: HoloScriptValue;
|
|
24
|
+
}
|
|
25
|
+
interface TypeDiagnostic {
|
|
26
|
+
severity: 'error' | 'warning' | 'info';
|
|
27
|
+
message: string;
|
|
28
|
+
line: number;
|
|
29
|
+
column: number;
|
|
30
|
+
code: string;
|
|
31
|
+
suggestions?: string[];
|
|
32
|
+
}
|
|
33
|
+
interface TypeCheckResult {
|
|
34
|
+
valid: boolean;
|
|
35
|
+
diagnostics: TypeDiagnostic[];
|
|
36
|
+
typeMap: Map<string, TypeInfo>;
|
|
37
|
+
}
|
|
38
|
+
declare class HoloScriptTypeChecker {
|
|
39
|
+
private typeMap;
|
|
40
|
+
private diagnostics;
|
|
41
|
+
private currentLine;
|
|
42
|
+
private currentColumn;
|
|
43
|
+
constructor();
|
|
44
|
+
/**
|
|
45
|
+
* Type check an AST
|
|
46
|
+
*/
|
|
47
|
+
check(ast: ASTNode[]): TypeCheckResult;
|
|
48
|
+
/**
|
|
49
|
+
* Collect type declarations
|
|
50
|
+
*/
|
|
51
|
+
private collectDeclaration;
|
|
52
|
+
private collectOrbDeclaration;
|
|
53
|
+
private collectMethodDeclaration;
|
|
54
|
+
private collectVariableDeclaration;
|
|
55
|
+
private collectStreamDeclaration;
|
|
56
|
+
/**
|
|
57
|
+
* Check a node for type errors
|
|
58
|
+
*/
|
|
59
|
+
private checkNode;
|
|
60
|
+
private checkConnection;
|
|
61
|
+
private checkGate;
|
|
62
|
+
private checkForLoop;
|
|
63
|
+
private checkWhileLoop;
|
|
64
|
+
private checkForEachLoop;
|
|
65
|
+
private checkImport;
|
|
66
|
+
private checkExport;
|
|
67
|
+
/**
|
|
68
|
+
* Infer type from a value
|
|
69
|
+
*/
|
|
70
|
+
inferType(value: HoloScriptValue): TypeInfo;
|
|
71
|
+
/**
|
|
72
|
+
* Parse type string to HoloScriptType
|
|
73
|
+
*/
|
|
74
|
+
private parseTypeString;
|
|
75
|
+
/**
|
|
76
|
+
* Extract variable names from an expression string
|
|
77
|
+
*/
|
|
78
|
+
private extractVariables;
|
|
79
|
+
/**
|
|
80
|
+
* Check if string is a literal
|
|
81
|
+
*/
|
|
82
|
+
private isLiteral;
|
|
83
|
+
/**
|
|
84
|
+
* Add a diagnostic
|
|
85
|
+
*/
|
|
86
|
+
private addDiagnostic;
|
|
87
|
+
/**
|
|
88
|
+
* Get type info for a name
|
|
89
|
+
*/
|
|
90
|
+
getType(name: string): TypeInfo | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Get all registered types
|
|
93
|
+
*/
|
|
94
|
+
getAllTypes(): Map<string, TypeInfo>;
|
|
95
|
+
/**
|
|
96
|
+
* Reset the type checker
|
|
97
|
+
*/
|
|
98
|
+
reset(): void;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Create a type checker instance
|
|
102
|
+
*/
|
|
103
|
+
declare function createTypeChecker(): HoloScriptTypeChecker;
|
|
104
|
+
|
|
105
|
+
export { type HoloScriptType, HoloScriptTypeChecker, type ParameterType, type TypeCheckResult, type TypeDiagnostic, type TypeInfo, createTypeChecker };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { A as ASTNode, J as HoloScriptValue } from './types-4h8cbtF_.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* HoloScript Type Checker
|
|
5
|
+
*
|
|
6
|
+
* Static type analysis for HoloScript code.
|
|
7
|
+
* Validates types, detects errors, and provides type information.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
type HoloScriptType = 'number' | 'string' | 'boolean' | 'array' | 'object' | 'function' | 'void' | 'any' | 'unknown' | 'never' | 'orb' | 'stream' | 'connection' | 'gate';
|
|
11
|
+
interface TypeInfo {
|
|
12
|
+
type: HoloScriptType;
|
|
13
|
+
elementType?: HoloScriptType;
|
|
14
|
+
properties?: Map<string, TypeInfo>;
|
|
15
|
+
parameters?: ParameterType[];
|
|
16
|
+
returnType?: HoloScriptType;
|
|
17
|
+
nullable?: boolean;
|
|
18
|
+
}
|
|
19
|
+
interface ParameterType {
|
|
20
|
+
name: string;
|
|
21
|
+
type: HoloScriptType;
|
|
22
|
+
optional?: boolean;
|
|
23
|
+
defaultValue?: HoloScriptValue;
|
|
24
|
+
}
|
|
25
|
+
interface TypeDiagnostic {
|
|
26
|
+
severity: 'error' | 'warning' | 'info';
|
|
27
|
+
message: string;
|
|
28
|
+
line: number;
|
|
29
|
+
column: number;
|
|
30
|
+
code: string;
|
|
31
|
+
suggestions?: string[];
|
|
32
|
+
}
|
|
33
|
+
interface TypeCheckResult {
|
|
34
|
+
valid: boolean;
|
|
35
|
+
diagnostics: TypeDiagnostic[];
|
|
36
|
+
typeMap: Map<string, TypeInfo>;
|
|
37
|
+
}
|
|
38
|
+
declare class HoloScriptTypeChecker {
|
|
39
|
+
private typeMap;
|
|
40
|
+
private diagnostics;
|
|
41
|
+
private currentLine;
|
|
42
|
+
private currentColumn;
|
|
43
|
+
constructor();
|
|
44
|
+
/**
|
|
45
|
+
* Type check an AST
|
|
46
|
+
*/
|
|
47
|
+
check(ast: ASTNode[]): TypeCheckResult;
|
|
48
|
+
/**
|
|
49
|
+
* Collect type declarations
|
|
50
|
+
*/
|
|
51
|
+
private collectDeclaration;
|
|
52
|
+
private collectOrbDeclaration;
|
|
53
|
+
private collectMethodDeclaration;
|
|
54
|
+
private collectVariableDeclaration;
|
|
55
|
+
private collectStreamDeclaration;
|
|
56
|
+
/**
|
|
57
|
+
* Check a node for type errors
|
|
58
|
+
*/
|
|
59
|
+
private checkNode;
|
|
60
|
+
private checkConnection;
|
|
61
|
+
private checkGate;
|
|
62
|
+
private checkForLoop;
|
|
63
|
+
private checkWhileLoop;
|
|
64
|
+
private checkForEachLoop;
|
|
65
|
+
private checkImport;
|
|
66
|
+
private checkExport;
|
|
67
|
+
/**
|
|
68
|
+
* Infer type from a value
|
|
69
|
+
*/
|
|
70
|
+
inferType(value: HoloScriptValue): TypeInfo;
|
|
71
|
+
/**
|
|
72
|
+
* Parse type string to HoloScriptType
|
|
73
|
+
*/
|
|
74
|
+
private parseTypeString;
|
|
75
|
+
/**
|
|
76
|
+
* Extract variable names from an expression string
|
|
77
|
+
*/
|
|
78
|
+
private extractVariables;
|
|
79
|
+
/**
|
|
80
|
+
* Check if string is a literal
|
|
81
|
+
*/
|
|
82
|
+
private isLiteral;
|
|
83
|
+
/**
|
|
84
|
+
* Add a diagnostic
|
|
85
|
+
*/
|
|
86
|
+
private addDiagnostic;
|
|
87
|
+
/**
|
|
88
|
+
* Get type info for a name
|
|
89
|
+
*/
|
|
90
|
+
getType(name: string): TypeInfo | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Get all registered types
|
|
93
|
+
*/
|
|
94
|
+
getAllTypes(): Map<string, TypeInfo>;
|
|
95
|
+
/**
|
|
96
|
+
* Reset the type checker
|
|
97
|
+
*/
|
|
98
|
+
reset(): void;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Create a type checker instance
|
|
102
|
+
*/
|
|
103
|
+
declare function createTypeChecker(): HoloScriptTypeChecker;
|
|
104
|
+
|
|
105
|
+
export { type HoloScriptType, HoloScriptTypeChecker, type ParameterType, type TypeCheckResult, type TypeDiagnostic, type TypeInfo, createTypeChecker };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"type-checker.js"}
|