@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.
Files changed (137) hide show
  1. package/LICENSE +21 -0
  2. package/dist/chunk-3N67RLQP.cjs +1298 -0
  3. package/dist/chunk-3N67RLQP.cjs.map +1 -0
  4. package/dist/chunk-3X2EGU7Z.cjs +52 -0
  5. package/dist/chunk-3X2EGU7Z.cjs.map +1 -0
  6. package/dist/chunk-4CV4JOE5.js +24 -0
  7. package/dist/chunk-4CV4JOE5.js.map +1 -0
  8. package/dist/chunk-4OHVW4XR.cjs +1027 -0
  9. package/dist/chunk-4OHVW4XR.cjs.map +1 -0
  10. package/dist/chunk-CZLDE2OZ.cjs +28 -0
  11. package/dist/chunk-CZLDE2OZ.cjs.map +1 -0
  12. package/{src/HoloScriptRuntime.ts → dist/chunk-EU6CZMGJ.js} +437 -794
  13. package/dist/chunk-EU6CZMGJ.js.map +1 -0
  14. package/dist/chunk-KWYIVRIH.js +344 -0
  15. package/dist/chunk-KWYIVRIH.js.map +1 -0
  16. package/dist/chunk-MCP6D4LT.js +1025 -0
  17. package/dist/chunk-MCP6D4LT.js.map +1 -0
  18. package/dist/chunk-SATNCODL.js +45 -0
  19. package/dist/chunk-SATNCODL.js.map +1 -0
  20. package/dist/chunk-VMZN4EVR.cjs +347 -0
  21. package/dist/chunk-VMZN4EVR.cjs.map +1 -0
  22. package/{src/HoloScriptDebugger.ts → dist/chunk-VYIDLUCV.js} +118 -257
  23. package/dist/chunk-VYIDLUCV.js.map +1 -0
  24. package/dist/chunk-WFI4T3XB.cjs +424 -0
  25. package/dist/chunk-WFI4T3XB.cjs.map +1 -0
  26. package/dist/debugger.cjs +20 -0
  27. package/dist/debugger.cjs.map +1 -0
  28. package/dist/debugger.d.cts +171 -0
  29. package/dist/debugger.d.ts +171 -0
  30. package/dist/debugger.js +7 -0
  31. package/dist/debugger.js.map +1 -0
  32. package/dist/index.cjs +6006 -0
  33. package/dist/index.cjs.map +1 -0
  34. package/dist/index.d.cts +2482 -0
  35. package/dist/index.d.ts +2482 -0
  36. package/dist/index.js +5926 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/parser.cjs +14 -0
  39. package/dist/parser.cjs.map +1 -0
  40. package/dist/parser.d.cts +139 -0
  41. package/dist/parser.d.ts +139 -0
  42. package/dist/parser.js +5 -0
  43. package/dist/parser.js.map +1 -0
  44. package/dist/runtime.cjs +14 -0
  45. package/dist/runtime.cjs.map +1 -0
  46. package/dist/runtime.d.cts +180 -0
  47. package/dist/runtime.d.ts +180 -0
  48. package/dist/runtime.js +5 -0
  49. package/dist/runtime.js.map +1 -0
  50. package/dist/type-checker.cjs +17 -0
  51. package/dist/type-checker.cjs.map +1 -0
  52. package/dist/type-checker.d.cts +105 -0
  53. package/dist/type-checker.d.ts +105 -0
  54. package/dist/type-checker.js +4 -0
  55. package/dist/type-checker.js.map +1 -0
  56. package/dist/types-D6g4ACjP.d.cts +262 -0
  57. package/dist/types-D6g4ACjP.d.ts +262 -0
  58. package/package.json +11 -8
  59. package/src/HoloScript2DParser.js +0 -227
  60. package/src/HoloScript2DParser.ts +0 -261
  61. package/src/HoloScriptCodeParser.js +0 -1102
  62. package/src/HoloScriptCodeParser.ts +0 -1188
  63. package/src/HoloScriptDebugger.js +0 -458
  64. package/src/HoloScriptParser.js +0 -338
  65. package/src/HoloScriptParser.ts +0 -397
  66. package/src/HoloScriptPlusParser.js +0 -371
  67. package/src/HoloScriptPlusParser.ts +0 -543
  68. package/src/HoloScriptRuntime.js +0 -1399
  69. package/src/HoloScriptRuntime.test.js +0 -351
  70. package/src/HoloScriptRuntime.test.ts +0 -436
  71. package/src/HoloScriptTypeChecker.js +0 -356
  72. package/src/HoloScriptTypeChecker.ts +0 -475
  73. package/src/__tests__/GraphicsServices.test.js +0 -357
  74. package/src/__tests__/GraphicsServices.test.ts +0 -427
  75. package/src/__tests__/HoloScriptPlusParser.test.js +0 -317
  76. package/src/__tests__/HoloScriptPlusParser.test.ts +0 -392
  77. package/src/__tests__/integration.test.js +0 -336
  78. package/src/__tests__/integration.test.ts +0 -416
  79. package/src/__tests__/performance.bench.js +0 -218
  80. package/src/__tests__/performance.bench.ts +0 -262
  81. package/src/__tests__/type-checker.test.js +0 -60
  82. package/src/__tests__/type-checker.test.ts +0 -73
  83. package/src/index.js +0 -217
  84. package/src/index.ts +0 -426
  85. package/src/interop/Interoperability.js +0 -413
  86. package/src/interop/Interoperability.ts +0 -494
  87. package/src/logger.js +0 -42
  88. package/src/logger.ts +0 -57
  89. package/src/parser/EnhancedParser.js +0 -205
  90. package/src/parser/EnhancedParser.ts +0 -251
  91. package/src/parser/HoloScriptPlusParser.js +0 -928
  92. package/src/parser/HoloScriptPlusParser.ts +0 -1089
  93. package/src/runtime/HoloScriptPlusRuntime.js +0 -674
  94. package/src/runtime/HoloScriptPlusRuntime.ts +0 -861
  95. package/src/runtime/PerformanceTelemetry.js +0 -323
  96. package/src/runtime/PerformanceTelemetry.ts +0 -467
  97. package/src/runtime/RuntimeOptimization.js +0 -361
  98. package/src/runtime/RuntimeOptimization.ts +0 -416
  99. package/src/services/HololandGraphicsPipelineService.js +0 -506
  100. package/src/services/HololandGraphicsPipelineService.ts +0 -662
  101. package/src/services/PlatformPerformanceOptimizer.js +0 -356
  102. package/src/services/PlatformPerformanceOptimizer.ts +0 -503
  103. package/src/state/ReactiveState.js +0 -427
  104. package/src/state/ReactiveState.ts +0 -572
  105. package/src/tools/DeveloperExperience.js +0 -376
  106. package/src/tools/DeveloperExperience.ts +0 -438
  107. package/src/traits/AIDriverTrait.js +0 -322
  108. package/src/traits/AIDriverTrait.test.js +0 -329
  109. package/src/traits/AIDriverTrait.test.ts +0 -357
  110. package/src/traits/AIDriverTrait.ts +0 -474
  111. package/src/traits/LightingTrait.js +0 -313
  112. package/src/traits/LightingTrait.test.js +0 -410
  113. package/src/traits/LightingTrait.test.ts +0 -462
  114. package/src/traits/LightingTrait.ts +0 -505
  115. package/src/traits/MaterialTrait.js +0 -194
  116. package/src/traits/MaterialTrait.test.js +0 -286
  117. package/src/traits/MaterialTrait.test.ts +0 -329
  118. package/src/traits/MaterialTrait.ts +0 -324
  119. package/src/traits/RenderingTrait.js +0 -356
  120. package/src/traits/RenderingTrait.test.js +0 -363
  121. package/src/traits/RenderingTrait.test.ts +0 -427
  122. package/src/traits/RenderingTrait.ts +0 -555
  123. package/src/traits/VRTraitSystem.js +0 -740
  124. package/src/traits/VRTraitSystem.ts +0 -1040
  125. package/src/traits/VoiceInputTrait.js +0 -284
  126. package/src/traits/VoiceInputTrait.test.js +0 -226
  127. package/src/traits/VoiceInputTrait.test.ts +0 -252
  128. package/src/traits/VoiceInputTrait.ts +0 -401
  129. package/src/types/AdvancedTypeSystem.js +0 -226
  130. package/src/types/AdvancedTypeSystem.ts +0 -494
  131. package/src/types/HoloScriptPlus.d.ts +0 -853
  132. package/src/types.js +0 -6
  133. package/src/types.ts +0 -369
  134. package/tsconfig.json +0 -23
  135. package/tsup.config.d.ts +0 -2
  136. package/tsup.config.js +0 -18
  137. package/tsup.config.ts +0 -19
@@ -1,413 +0,0 @@
1
- /**
2
- * @holoscript/core Interoperability
3
- *
4
- * TypeScript module resolution, proper import/export handling,
5
- * async/await support, error boundaries
6
- */
7
- import * as path from 'path';
8
- import * as fs from 'fs';
9
- /**
10
- * Module resolver for TypeScript/JavaScript integration
11
- */
12
- export class ModuleResolver {
13
- constructor(basePath = process.cwd()) {
14
- this.cache = new Map();
15
- this.resolvedPaths = new Map();
16
- this.basePath = basePath;
17
- }
18
- /**
19
- * Resolve module path
20
- */
21
- resolveModule(modulePath, fromPath) {
22
- const cacheKey = `${modulePath}:${fromPath || 'root'}`;
23
- if (this.resolvedPaths.has(cacheKey)) {
24
- return this.resolvedPaths.get(cacheKey);
25
- }
26
- const resolved = this.performResolve(modulePath, fromPath);
27
- this.resolvedPaths.set(cacheKey, resolved);
28
- return resolved;
29
- }
30
- /**
31
- * Perform actual module resolution
32
- */
33
- performResolve(modulePath, fromPath) {
34
- // Handle built-in modules
35
- if (this.isBuiltinModule(modulePath)) {
36
- return modulePath;
37
- }
38
- // Handle relative imports
39
- if (modulePath.startsWith('.')) {
40
- const basePath = fromPath ? path.dirname(fromPath) : this.basePath;
41
- const resolved = path.resolve(basePath, modulePath);
42
- return this.findModuleFile(resolved);
43
- }
44
- // Handle node_modules
45
- if (modulePath.startsWith('@')) {
46
- // Scoped package
47
- return this.resolveNodeModule(modulePath);
48
- }
49
- // Standard package
50
- return this.resolveNodeModule(modulePath);
51
- }
52
- /**
53
- * Check if built-in module
54
- */
55
- isBuiltinModule(modulePath) {
56
- const builtins = ['fs', 'path', 'crypto', 'util', 'stream', 'events'];
57
- return builtins.includes(modulePath);
58
- }
59
- /**
60
- * Resolve from node_modules
61
- */
62
- resolveNodeModule(modulePath) {
63
- let current = this.basePath;
64
- while (current !== path.dirname(current)) {
65
- const nodeModulesPath = path.join(current, 'node_modules', modulePath);
66
- if (fs.existsSync(nodeModulesPath)) {
67
- return nodeModulesPath;
68
- }
69
- // Try package.json main field
70
- const packageJsonPath = path.join(nodeModulesPath, 'package.json');
71
- if (fs.existsSync(packageJsonPath)) {
72
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
73
- return this.findModuleFile(path.join(nodeModulesPath, packageJson.main || 'index.js'));
74
- }
75
- current = path.dirname(current);
76
- }
77
- throw new Error(`Module not found: ${modulePath}`);
78
- }
79
- /**
80
- * Find module file with various extensions
81
- */
82
- findModuleFile(basePath) {
83
- const extensions = ['.ts', '.tsx', '.js', '.jsx', '.json'];
84
- // Try exact file
85
- if (fs.existsSync(basePath)) {
86
- return basePath;
87
- }
88
- // Try with extensions
89
- for (const ext of extensions) {
90
- const withExt = basePath + ext;
91
- if (fs.existsSync(withExt)) {
92
- return withExt;
93
- }
94
- }
95
- // Try index
96
- const indexPath = path.join(basePath, 'index');
97
- for (const ext of extensions) {
98
- const withExt = indexPath + ext;
99
- if (fs.existsSync(withExt)) {
100
- return withExt;
101
- }
102
- }
103
- throw new Error(`Cannot resolve file: ${basePath}`);
104
- }
105
- /**
106
- * Load module (with caching)
107
- */
108
- loadModule(modulePath, fromPath) {
109
- const resolved = this.resolveModule(modulePath, fromPath);
110
- const cacheKey = resolved;
111
- if (this.cache.has(cacheKey)) {
112
- return this.cache.get(cacheKey);
113
- }
114
- // For now, return module info (real implementation would execute)
115
- const module = {
116
- path: resolved,
117
- exports: {},
118
- };
119
- this.cache.set(cacheKey, module);
120
- return module;
121
- }
122
- /**
123
- * Clear cache
124
- */
125
- clearCache() {
126
- this.cache.clear();
127
- this.resolvedPaths.clear();
128
- }
129
- }
130
- /**
131
- * Named export/import handler
132
- */
133
- export class ExportImportHandler {
134
- constructor() {
135
- this.exports = new Map();
136
- }
137
- /**
138
- * Define named export
139
- */
140
- defineExport(modulePath, name, value) {
141
- if (!this.exports.has(modulePath)) {
142
- this.exports.set(modulePath, new Map());
143
- }
144
- this.exports.get(modulePath).set(name, value);
145
- }
146
- /**
147
- * Get named export
148
- */
149
- getExport(modulePath, name) {
150
- const moduleExports = this.exports.get(modulePath);
151
- if (!moduleExports) {
152
- throw new Error(`Module not found: ${modulePath}`);
153
- }
154
- if (!moduleExports.has(name)) {
155
- throw new Error(`Named export '${name}' not found in ${modulePath}`);
156
- }
157
- return moduleExports.get(name);
158
- }
159
- /**
160
- * Get all exports from module
161
- */
162
- getAllExports(modulePath) {
163
- const moduleExports = this.exports.get(modulePath);
164
- if (!moduleExports) {
165
- return {};
166
- }
167
- const result = {};
168
- for (const [name, value] of moduleExports) {
169
- result[name] = value;
170
- }
171
- return result;
172
- }
173
- /**
174
- * Check if export exists
175
- */
176
- hasExport(modulePath, name) {
177
- return this.exports.has(modulePath) && this.exports.get(modulePath).has(name);
178
- }
179
- }
180
- /**
181
- * Async function handler
182
- */
183
- export class AsyncFunctionHandler {
184
- /**
185
- * Wrap async function for HoloScript
186
- */
187
- wrapAsyncFunction(fn) {
188
- return async (...args) => {
189
- try {
190
- return await fn(...args);
191
- }
192
- catch (error) {
193
- throw this.normalizeError(error);
194
- }
195
- };
196
- }
197
- /**
198
- * Check if function is async
199
- */
200
- isAsync(fn) {
201
- if (typeof fn !== 'function') {
202
- return false;
203
- }
204
- const fnStr = fn.toString().trim();
205
- return fnStr.startsWith('async ') || fn.constructor.name === 'AsyncFunction';
206
- }
207
- /**
208
- * Convert callback to promise
209
- */
210
- callbackToPromise(fn) {
211
- return new Promise((resolve, reject) => {
212
- fn((err, result) => {
213
- if (err) {
214
- reject(err);
215
- }
216
- else {
217
- resolve(result);
218
- }
219
- });
220
- });
221
- }
222
- /**
223
- * Normalize error from async function
224
- */
225
- normalizeError(error) {
226
- if (error instanceof Error) {
227
- return error;
228
- }
229
- if (typeof error === 'string') {
230
- return new Error(error);
231
- }
232
- return new Error(JSON.stringify(error));
233
- }
234
- }
235
- /**
236
- * Error boundary for isolation
237
- */
238
- export class ErrorBoundary {
239
- constructor(onError) {
240
- this.errors = [];
241
- this.onError = onError;
242
- }
243
- /**
244
- * Wrap function with error boundary
245
- */
246
- wrap(fn) {
247
- return ((...args) => {
248
- try {
249
- const result = fn(...args);
250
- // Handle async functions
251
- if (result instanceof Promise) {
252
- return result.catch((error) => {
253
- this.handleError(error);
254
- throw error;
255
- });
256
- }
257
- return result;
258
- }
259
- catch (error) {
260
- this.handleError(error);
261
- throw error;
262
- }
263
- });
264
- }
265
- /**
266
- * Wrap async function with error boundary
267
- */
268
- wrapAsync(fn) {
269
- return (async (...args) => {
270
- try {
271
- return await fn(...args);
272
- }
273
- catch (error) {
274
- this.handleError(error);
275
- throw error;
276
- }
277
- });
278
- }
279
- /**
280
- * Execute function in boundary
281
- */
282
- execute(fn) {
283
- try {
284
- return fn();
285
- }
286
- catch (error) {
287
- this.handleError(error);
288
- throw error;
289
- }
290
- }
291
- /**
292
- * Execute async function in boundary
293
- */
294
- async executeAsync(fn) {
295
- try {
296
- return await fn();
297
- }
298
- catch (error) {
299
- this.handleError(error);
300
- throw error;
301
- }
302
- }
303
- /**
304
- * Handle error
305
- */
306
- handleError(error) {
307
- const normalized = this.normalizeError(error);
308
- this.errors.push(normalized);
309
- if (this.onError) {
310
- this.onError(normalized);
311
- }
312
- }
313
- /**
314
- * Get errors
315
- */
316
- getErrors() {
317
- return [...this.errors];
318
- }
319
- /**
320
- * Clear errors
321
- */
322
- clearErrors() {
323
- this.errors = [];
324
- }
325
- /**
326
- * Normalize error
327
- */
328
- normalizeError(error) {
329
- if (error instanceof Error) {
330
- return error;
331
- }
332
- if (typeof error === 'string') {
333
- return new Error(error);
334
- }
335
- return new Error(JSON.stringify(error));
336
- }
337
- }
338
- /**
339
- * TypeScript type loader
340
- */
341
- export class TypeScriptTypeLoader {
342
- /**
343
- * Load types from TypeScript declaration file
344
- */
345
- loadTypes(filePath) {
346
- const types = new Map();
347
- // In real implementation, would parse .d.ts file
348
- // For now, return empty map
349
- return types;
350
- }
351
- /**
352
- * Convert TypeScript type to HoloScript type
353
- */
354
- convertType(tsType) {
355
- // Basic type mapping
356
- const mapping = {
357
- string: 'text',
358
- number: 'numeric',
359
- boolean: 'logical',
360
- void: 'void',
361
- any: 'dynamic',
362
- unknown: 'dynamic',
363
- null: 'null',
364
- undefined: 'void',
365
- };
366
- if (typeof tsType === 'string') {
367
- return mapping[tsType] || tsType;
368
- }
369
- if (Array.isArray(tsType)) {
370
- return {
371
- kind: 'array',
372
- elementType: this.convertType(tsType[0]),
373
- };
374
- }
375
- if (typeof tsType === 'object') {
376
- return {
377
- kind: 'object',
378
- properties: Object.entries(tsType).reduce((acc, [key, val]) => {
379
- acc[key] = this.convertType(val);
380
- return acc;
381
- }, {}),
382
- };
383
- }
384
- return tsType;
385
- }
386
- }
387
- /**
388
- * Unified interop context
389
- */
390
- export class InteropContext {
391
- constructor(basePath) {
392
- this.moduleResolver = new ModuleResolver(basePath);
393
- this.exportImportHandler = new ExportImportHandler();
394
- this.asyncHandler = new AsyncFunctionHandler();
395
- this.errorBoundary = new ErrorBoundary();
396
- this.typeLoader = new TypeScriptTypeLoader();
397
- }
398
- getModuleResolver() {
399
- return this.moduleResolver;
400
- }
401
- getExportImportHandler() {
402
- return this.exportImportHandler;
403
- }
404
- getAsyncHandler() {
405
- return this.asyncHandler;
406
- }
407
- getErrorBoundary() {
408
- return this.errorBoundary;
409
- }
410
- getTypeLoader() {
411
- return this.typeLoader;
412
- }
413
- }