@holoscript/core 2.0.1 → 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,261 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HoloScript 2D Parser Extension
|
|
3
|
-
*
|
|
4
|
-
* Adds support for 2D UI elements to HoloScript for desktop/mobile apps.
|
|
5
|
-
* Works alongside 3D VR syntax for hybrid applications.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { logger } from './logger';
|
|
9
|
-
import type { UI2DNode, UIElementType, Position2D } from './types';
|
|
10
|
-
|
|
11
|
-
const UI_SECURITY_CONFIG = {
|
|
12
|
-
maxUIElements: 500,
|
|
13
|
-
maxNestingDepth: 10,
|
|
14
|
-
maxPropertyLength: 500,
|
|
15
|
-
allowedEventHandlers: ['onClick', 'onChange', 'onSubmit', 'onFocus', 'onBlur', 'onHover'],
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export class HoloScript2DParser {
|
|
19
|
-
private uiElements: Map<string, UI2DNode> = new Map();
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Parse 2D UI element from HoloScript code
|
|
23
|
-
*/
|
|
24
|
-
parse2DElement(code: string, depth: number = 0): UI2DNode | null {
|
|
25
|
-
if (depth > UI_SECURITY_CONFIG.maxNestingDepth) {
|
|
26
|
-
logger.warn('Max nesting depth exceeded', { depth });
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const trimmedCode = code.trim();
|
|
31
|
-
const lines = trimmedCode.split('\n');
|
|
32
|
-
if (lines.length === 0) return null;
|
|
33
|
-
|
|
34
|
-
const firstLine = lines[0].trim();
|
|
35
|
-
const headerMatch = firstLine.match(/^([\w-]+)\s+(\w+)\s*\{/);
|
|
36
|
-
|
|
37
|
-
if (!headerMatch) {
|
|
38
|
-
logger.warn('Invalid 2D element syntax', { line: firstLine });
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const [, elementType, name] = headerMatch;
|
|
43
|
-
|
|
44
|
-
if (!this.isValidUIElementType(elementType)) {
|
|
45
|
-
logger.warn('Invalid UI element type', { elementType });
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const startIndex = trimmedCode.indexOf('{');
|
|
50
|
-
const endIndex = trimmedCode.lastIndexOf('}');
|
|
51
|
-
if (startIndex === -1 || endIndex === -1 || endIndex <= startIndex) {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const innerContent = trimmedCode.slice(startIndex + 1, endIndex).trim();
|
|
56
|
-
const innerLines = this.splitIntoLogicalBlocks(innerContent);
|
|
57
|
-
|
|
58
|
-
const properties: Record<string, unknown> = {};
|
|
59
|
-
const events: Record<string, string> = {};
|
|
60
|
-
const children: UI2DNode[] = [];
|
|
61
|
-
|
|
62
|
-
for (const block of innerLines) {
|
|
63
|
-
const line = block.trim();
|
|
64
|
-
if (!line) continue;
|
|
65
|
-
|
|
66
|
-
if (line.includes('{')) {
|
|
67
|
-
const childNode = this.parse2DElement(line, depth + 1);
|
|
68
|
-
if (childNode) children.push(childNode);
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const propMatch = line.match(/^(\w+):\s*(.+)$/);
|
|
73
|
-
if (propMatch) {
|
|
74
|
-
const [, key, rawValue] = propMatch;
|
|
75
|
-
if (UI_SECURITY_CONFIG.allowedEventHandlers.includes(key)) {
|
|
76
|
-
events[key] = rawValue.trim();
|
|
77
|
-
} else {
|
|
78
|
-
properties[key] = this.parsePropertyValue(rawValue);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const node: UI2DNode = {
|
|
84
|
-
type: '2d-element',
|
|
85
|
-
elementType: elementType as UIElementType,
|
|
86
|
-
name,
|
|
87
|
-
properties: { ...this.getDefaultProperties(elementType as UIElementType), ...properties },
|
|
88
|
-
events: Object.keys(events).length > 0 ? events : undefined,
|
|
89
|
-
children: children.length > 0 ? children : undefined,
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
if (depth === 0) {
|
|
93
|
-
if (this.uiElements.size >= UI_SECURITY_CONFIG.maxUIElements) {
|
|
94
|
-
logger.warn('Max UI elements limit reached');
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
this.uiElements.set(name, node);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return node;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
private splitIntoLogicalBlocks(content: string): string[] {
|
|
104
|
-
const blocks: string[] = [];
|
|
105
|
-
let currentBlock = '';
|
|
106
|
-
let bracketDepth = 0;
|
|
107
|
-
|
|
108
|
-
for (let i = 0; i < content.length; i++) {
|
|
109
|
-
const char = content[i];
|
|
110
|
-
if (char === '{') bracketDepth++;
|
|
111
|
-
if (char === '}') bracketDepth--;
|
|
112
|
-
|
|
113
|
-
currentBlock += char;
|
|
114
|
-
|
|
115
|
-
if (bracketDepth === 0) {
|
|
116
|
-
if (char === '\n' || i === content.length - 1) {
|
|
117
|
-
const trimmed = currentBlock.trim();
|
|
118
|
-
if (trimmed) blocks.push(trimmed);
|
|
119
|
-
currentBlock = '';
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const finalTrimmed = currentBlock.trim();
|
|
125
|
-
if (finalTrimmed) blocks.push(finalTrimmed);
|
|
126
|
-
|
|
127
|
-
return blocks;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Parse voice command for 2D UI creation
|
|
132
|
-
*/
|
|
133
|
-
parse2DVoiceCommand(command: string): UI2DNode | null {
|
|
134
|
-
const tokens = command.toLowerCase().trim().split(/\s+/);
|
|
135
|
-
|
|
136
|
-
if (tokens.length < 3) return null;
|
|
137
|
-
|
|
138
|
-
const action = tokens[0];
|
|
139
|
-
const elementType = tokens[1];
|
|
140
|
-
const name = tokens[2];
|
|
141
|
-
|
|
142
|
-
if (action !== 'create' && action !== 'add') return null;
|
|
143
|
-
if (!this.isValidUIElementType(elementType)) return null;
|
|
144
|
-
|
|
145
|
-
const node: UI2DNode = {
|
|
146
|
-
type: '2d-element',
|
|
147
|
-
elementType: elementType as UIElementType,
|
|
148
|
-
name,
|
|
149
|
-
properties: this.getDefaultProperties(elementType as UIElementType),
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
this.uiElements.set(name, node);
|
|
153
|
-
return node;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Parse gesture for 2D UI interaction
|
|
158
|
-
*/
|
|
159
|
-
parse2DGesture(gestureType: string, position: Position2D): UI2DNode | null {
|
|
160
|
-
switch (gestureType) {
|
|
161
|
-
case 'tap':
|
|
162
|
-
return this.createQuick2DElement('button', `button_${Date.now()}`, position);
|
|
163
|
-
case 'double-tap':
|
|
164
|
-
return this.createQuick2DElement('textinput', `input_${Date.now()}`, position);
|
|
165
|
-
case 'long-press':
|
|
166
|
-
return this.createQuick2DElement('panel', `panel_${Date.now()}`, position);
|
|
167
|
-
default:
|
|
168
|
-
return null;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
private createQuick2DElement(elementType: UIElementType, name: string, position: Position2D): UI2DNode {
|
|
173
|
-
const node: UI2DNode = {
|
|
174
|
-
type: '2d-element',
|
|
175
|
-
elementType,
|
|
176
|
-
name,
|
|
177
|
-
properties: {
|
|
178
|
-
...this.getDefaultProperties(elementType),
|
|
179
|
-
x: position.x,
|
|
180
|
-
y: position.y,
|
|
181
|
-
},
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
this.uiElements.set(name, node);
|
|
185
|
-
return node;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
private isValidUIElementType(type: string): boolean {
|
|
189
|
-
const validTypes: UIElementType[] = [
|
|
190
|
-
'canvas', 'button', 'textinput', 'panel', 'text', 'image',
|
|
191
|
-
'list', 'modal', 'slider', 'toggle', 'dropdown',
|
|
192
|
-
'flex-container', 'grid-container', 'scroll-view', 'tab-view'
|
|
193
|
-
];
|
|
194
|
-
return validTypes.includes(type as UIElementType);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
private parsePropertyValue(value: string): unknown {
|
|
198
|
-
const trimmed = value.trim();
|
|
199
|
-
|
|
200
|
-
if ((trimmed.startsWith('"') && trimmed.endsWith('"')) ||
|
|
201
|
-
(trimmed.startsWith("'") && trimmed.endsWith("'"))) {
|
|
202
|
-
return trimmed.slice(1, -1);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
if (!isNaN(parseFloat(trimmed)) && isFinite(parseFloat(trimmed))) {
|
|
206
|
-
return parseFloat(trimmed);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if (trimmed === 'true') return true;
|
|
210
|
-
if (trimmed === 'false') return false;
|
|
211
|
-
|
|
212
|
-
if (trimmed.startsWith('[') && trimmed.endsWith(']')) {
|
|
213
|
-
const items = trimmed.slice(1, -1).split(',').map(item =>
|
|
214
|
-
this.parsePropertyValue(item.trim())
|
|
215
|
-
);
|
|
216
|
-
return items;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
return trimmed;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
private getDefaultProperties(elementType: UIElementType): Record<string, unknown> {
|
|
223
|
-
const defaults: Record<UIElementType, Record<string, unknown>> = {
|
|
224
|
-
'canvas': { width: 800, height: 600, backgroundColor: '#ffffff' },
|
|
225
|
-
'button': { text: 'Button', width: 120, height: 40, backgroundColor: '#007bff', color: '#ffffff', borderRadius: 4 },
|
|
226
|
-
'textinput': { placeholder: '', width: 200, height: 36, fontSize: 14, borderColor: '#cccccc', borderWidth: 1, borderRadius: 4 },
|
|
227
|
-
'panel': { width: 200, height: 200, backgroundColor: '#f0f0f0', borderRadius: 0 },
|
|
228
|
-
'text': { content: 'Text', fontSize: 16, color: '#000000', fontFamily: 'sans-serif' },
|
|
229
|
-
'image': { src: '', width: 100, height: 100, fit: 'cover' },
|
|
230
|
-
'list': { items: [], itemHeight: 40, width: 200, height: 300 },
|
|
231
|
-
'modal': { title: 'Modal', width: 400, height: 300, visible: false, backgroundColor: '#ffffff' },
|
|
232
|
-
'slider': { min: 0, max: 100, value: 50, width: 200 },
|
|
233
|
-
'toggle': { checked: false, width: 50, height: 24 },
|
|
234
|
-
'dropdown': { options: [], selected: null, width: 200 },
|
|
235
|
-
'flex-container': { direction: 'row', gap: 10, padding: 10 },
|
|
236
|
-
'grid-container': { columns: 3, gap: 10, padding: 10 },
|
|
237
|
-
'scroll-view': { width: 300, height: 400, scrollDirection: 'vertical' },
|
|
238
|
-
'tab-view': { tabs: [], activeTabId: null, tabPosition: 'top', width: 400, height: 300 },
|
|
239
|
-
'dashboard': { title: 'Dashboard', width: 1200, height: 800, layout: 'grid', columns: 4 },
|
|
240
|
-
'card': { title: '', width: 300, height: 200, backgroundColor: '#ffffff', elevation: 2 },
|
|
241
|
-
'metric': { label: '', value: 0, unit: '', fontSize: 24, color: '#000000' },
|
|
242
|
-
'row': { height: 'auto', gap: 10, alignItems: 'center' },
|
|
243
|
-
'col': { width: 'auto', gap: 10, alignItems: 'stretch' },
|
|
244
|
-
};
|
|
245
|
-
return { ...defaults[elementType] };
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
getUIElements(): Map<string, UI2DNode> {
|
|
249
|
-
return new Map(this.uiElements);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
findElement(name: string): UI2DNode | null {
|
|
253
|
-
return this.uiElements.get(name) || null;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
clear(): void {
|
|
257
|
-
this.uiElements.clear();
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
export type { UI2DNode, UIElementType, Position2D };
|