@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.
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,494 +0,0 @@
1
- /**
2
- * @holoscript/core Interoperability
3
- *
4
- * TypeScript module resolution, proper import/export handling,
5
- * async/await support, error boundaries
6
- */
7
-
8
- import * as path from 'path';
9
- import * as fs from 'fs';
10
-
11
- /**
12
- * Module resolver for TypeScript/JavaScript integration
13
- */
14
- export class ModuleResolver {
15
- private cache: Map<string, any> = new Map();
16
- private resolvedPaths: Map<string, string> = new Map();
17
- private basePath: string;
18
-
19
- constructor(basePath: string = process.cwd()) {
20
- this.basePath = basePath;
21
- }
22
-
23
- /**
24
- * Resolve module path
25
- */
26
- resolveModule(modulePath: string, fromPath?: string): string {
27
- const cacheKey = `${modulePath}:${fromPath || 'root'}`;
28
-
29
- if (this.resolvedPaths.has(cacheKey)) {
30
- return this.resolvedPaths.get(cacheKey)!;
31
- }
32
-
33
- const resolved = this.performResolve(modulePath, fromPath);
34
- this.resolvedPaths.set(cacheKey, resolved);
35
- return resolved;
36
- }
37
-
38
- /**
39
- * Perform actual module resolution
40
- */
41
- private performResolve(modulePath: string, fromPath?: string): string {
42
- // Handle built-in modules
43
- if (this.isBuiltinModule(modulePath)) {
44
- return modulePath;
45
- }
46
-
47
- // Handle relative imports
48
- if (modulePath.startsWith('.')) {
49
- const basePath = fromPath ? path.dirname(fromPath) : this.basePath;
50
- const resolved = path.resolve(basePath, modulePath);
51
- return this.findModuleFile(resolved);
52
- }
53
-
54
- // Handle node_modules
55
- if (modulePath.startsWith('@')) {
56
- // Scoped package
57
- return this.resolveNodeModule(modulePath);
58
- }
59
-
60
- // Standard package
61
- return this.resolveNodeModule(modulePath);
62
- }
63
-
64
- /**
65
- * Check if built-in module
66
- */
67
- private isBuiltinModule(modulePath: string): boolean {
68
- const builtins = ['fs', 'path', 'crypto', 'util', 'stream', 'events'];
69
- return builtins.includes(modulePath);
70
- }
71
-
72
- /**
73
- * Resolve from node_modules
74
- */
75
- private resolveNodeModule(modulePath: string): string {
76
- let current = this.basePath;
77
-
78
- while (current !== path.dirname(current)) {
79
- const nodeModulesPath = path.join(current, 'node_modules', modulePath);
80
-
81
- if (fs.existsSync(nodeModulesPath)) {
82
- return nodeModulesPath;
83
- }
84
-
85
- // Try package.json main field
86
- const packageJsonPath = path.join(nodeModulesPath, 'package.json');
87
-
88
- if (fs.existsSync(packageJsonPath)) {
89
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
90
- return this.findModuleFile(path.join(nodeModulesPath, packageJson.main || 'index.js'));
91
- }
92
-
93
- current = path.dirname(current);
94
- }
95
-
96
- throw new Error(`Module not found: ${modulePath}`);
97
- }
98
-
99
- /**
100
- * Find module file with various extensions
101
- */
102
- private findModuleFile(basePath: string): string {
103
- const extensions = ['.ts', '.tsx', '.js', '.jsx', '.json'];
104
-
105
- // Try exact file
106
- if (fs.existsSync(basePath)) {
107
- return basePath;
108
- }
109
-
110
- // Try with extensions
111
- for (const ext of extensions) {
112
- const withExt = basePath + ext;
113
- if (fs.existsSync(withExt)) {
114
- return withExt;
115
- }
116
- }
117
-
118
- // Try index
119
- const indexPath = path.join(basePath, 'index');
120
- for (const ext of extensions) {
121
- const withExt = indexPath + ext;
122
- if (fs.existsSync(withExt)) {
123
- return withExt;
124
- }
125
- }
126
-
127
- throw new Error(`Cannot resolve file: ${basePath}`);
128
- }
129
-
130
- /**
131
- * Load module (with caching)
132
- */
133
- loadModule(modulePath: string, fromPath?: string): any {
134
- const resolved = this.resolveModule(modulePath, fromPath);
135
- const cacheKey = resolved;
136
-
137
- if (this.cache.has(cacheKey)) {
138
- return this.cache.get(cacheKey);
139
- }
140
-
141
- // For now, return module info (real implementation would execute)
142
- const module = {
143
- path: resolved,
144
- exports: {},
145
- };
146
-
147
- this.cache.set(cacheKey, module);
148
- return module;
149
- }
150
-
151
- /**
152
- * Clear cache
153
- */
154
- clearCache(): void {
155
- this.cache.clear();
156
- this.resolvedPaths.clear();
157
- }
158
- }
159
-
160
- /**
161
- * Named export/import handler
162
- */
163
- export class ExportImportHandler {
164
- private exports: Map<string, Map<string, any>> = new Map();
165
-
166
- /**
167
- * Define named export
168
- */
169
- defineExport(modulePath: string, name: string, value: any): void {
170
- if (!this.exports.has(modulePath)) {
171
- this.exports.set(modulePath, new Map());
172
- }
173
-
174
- this.exports.get(modulePath)!.set(name, value);
175
- }
176
-
177
- /**
178
- * Get named export
179
- */
180
- getExport(modulePath: string, name: string): any {
181
- const moduleExports = this.exports.get(modulePath);
182
-
183
- if (!moduleExports) {
184
- throw new Error(`Module not found: ${modulePath}`);
185
- }
186
-
187
- if (!moduleExports.has(name)) {
188
- throw new Error(`Named export '${name}' not found in ${modulePath}`);
189
- }
190
-
191
- return moduleExports.get(name);
192
- }
193
-
194
- /**
195
- * Get all exports from module
196
- */
197
- getAllExports(modulePath: string): Record<string, any> {
198
- const moduleExports = this.exports.get(modulePath);
199
-
200
- if (!moduleExports) {
201
- return {};
202
- }
203
-
204
- const result: Record<string, any> = {};
205
-
206
- for (const [name, value] of moduleExports) {
207
- result[name] = value;
208
- }
209
-
210
- return result;
211
- }
212
-
213
- /**
214
- * Check if export exists
215
- */
216
- hasExport(modulePath: string, name: string): boolean {
217
- return this.exports.has(modulePath) && this.exports.get(modulePath)!.has(name);
218
- }
219
- }
220
-
221
- /**
222
- * Async function handler
223
- */
224
- export class AsyncFunctionHandler {
225
- /**
226
- * Wrap async function for HoloScript
227
- */
228
- wrapAsyncFunction(fn: (...args: any[]) => Promise<any>): (...args: any[]) => Promise<any> {
229
- return async (...args: any[]) => {
230
- try {
231
- return await fn(...args);
232
- } catch (error) {
233
- throw this.normalizeError(error);
234
- }
235
- };
236
- }
237
-
238
- /**
239
- * Check if function is async
240
- */
241
- isAsync(fn: any): boolean {
242
- if (typeof fn !== 'function') {
243
- return false;
244
- }
245
-
246
- const fnStr = fn.toString().trim();
247
- return fnStr.startsWith('async ') || fn.constructor.name === 'AsyncFunction';
248
- }
249
-
250
- /**
251
- * Convert callback to promise
252
- */
253
- callbackToPromise(
254
- fn: (callback: (err: any, result: any) => void) => void
255
- ): Promise<any> {
256
- return new Promise((resolve, reject) => {
257
- fn((err: any, result: any) => {
258
- if (err) {
259
- reject(err);
260
- } else {
261
- resolve(result);
262
- }
263
- });
264
- });
265
- }
266
-
267
- /**
268
- * Normalize error from async function
269
- */
270
- private normalizeError(error: any): Error {
271
- if (error instanceof Error) {
272
- return error;
273
- }
274
-
275
- if (typeof error === 'string') {
276
- return new Error(error);
277
- }
278
-
279
- return new Error(JSON.stringify(error));
280
- }
281
- }
282
-
283
- /**
284
- * Error boundary for isolation
285
- */
286
- export class ErrorBoundary {
287
- private errors: Error[] = [];
288
- private onError?: (error: Error) => void;
289
-
290
- constructor(onError?: (error: Error) => void) {
291
- this.onError = onError;
292
- }
293
-
294
- /**
295
- * Wrap function with error boundary
296
- */
297
- wrap<T extends (...args: any[]) => any>(fn: T): T {
298
- return ((...args: any[]) => {
299
- try {
300
- const result = fn(...args);
301
-
302
- // Handle async functions
303
- if (result instanceof Promise) {
304
- return result.catch((error: any) => {
305
- this.handleError(error);
306
- throw error;
307
- });
308
- }
309
-
310
- return result;
311
- } catch (error: any) {
312
- this.handleError(error);
313
- throw error;
314
- }
315
- }) as T;
316
- }
317
-
318
- /**
319
- * Wrap async function with error boundary
320
- */
321
- wrapAsync<T extends (...args: any[]) => Promise<any>>(fn: T): T {
322
- return (async (...args: any[]) => {
323
- try {
324
- return await fn(...args);
325
- } catch (error: any) {
326
- this.handleError(error);
327
- throw error;
328
- }
329
- }) as T;
330
- }
331
-
332
- /**
333
- * Execute function in boundary
334
- */
335
- execute<T>(fn: () => T): T {
336
- try {
337
- return fn();
338
- } catch (error: any) {
339
- this.handleError(error);
340
- throw error;
341
- }
342
- }
343
-
344
- /**
345
- * Execute async function in boundary
346
- */
347
- async executeAsync<T>(fn: () => Promise<T>): Promise<T> {
348
- try {
349
- return await fn();
350
- } catch (error: any) {
351
- this.handleError(error);
352
- throw error;
353
- }
354
- }
355
-
356
- /**
357
- * Handle error
358
- */
359
- private handleError(error: any): void {
360
- const normalized = this.normalizeError(error);
361
- this.errors.push(normalized);
362
-
363
- if (this.onError) {
364
- this.onError(normalized);
365
- }
366
- }
367
-
368
- /**
369
- * Get errors
370
- */
371
- getErrors(): Error[] {
372
- return [...this.errors];
373
- }
374
-
375
- /**
376
- * Clear errors
377
- */
378
- clearErrors(): void {
379
- this.errors = [];
380
- }
381
-
382
- /**
383
- * Normalize error
384
- */
385
- private normalizeError(error: any): Error {
386
- if (error instanceof Error) {
387
- return error;
388
- }
389
-
390
- if (typeof error === 'string') {
391
- return new Error(error);
392
- }
393
-
394
- return new Error(JSON.stringify(error));
395
- }
396
- }
397
-
398
- /**
399
- * TypeScript type loader
400
- */
401
- export class TypeScriptTypeLoader {
402
- /**
403
- * Load types from TypeScript declaration file
404
- */
405
- loadTypes(filePath: string): Map<string, any> {
406
- const types = new Map<string, any>();
407
-
408
- // In real implementation, would parse .d.ts file
409
- // For now, return empty map
410
- return types;
411
- }
412
-
413
- /**
414
- * Convert TypeScript type to HoloScript type
415
- */
416
- convertType(tsType: any): any {
417
- // Basic type mapping
418
- const mapping: Record<string, string> = {
419
- string: 'text',
420
- number: 'numeric',
421
- boolean: 'logical',
422
- void: 'void',
423
- any: 'dynamic',
424
- unknown: 'dynamic',
425
- null: 'null',
426
- undefined: 'void',
427
- };
428
-
429
- if (typeof tsType === 'string') {
430
- return mapping[tsType] || tsType;
431
- }
432
-
433
- if (Array.isArray(tsType)) {
434
- return {
435
- kind: 'array',
436
- elementType: this.convertType(tsType[0]),
437
- };
438
- }
439
-
440
- if (typeof tsType === 'object') {
441
- return {
442
- kind: 'object',
443
- properties: Object.entries(tsType).reduce(
444
- (acc, [key, val]) => {
445
- acc[key] = this.convertType(val);
446
- return acc;
447
- },
448
- {} as Record<string, any>
449
- ),
450
- };
451
- }
452
-
453
- return tsType;
454
- }
455
- }
456
-
457
- /**
458
- * Unified interop context
459
- */
460
- export class InteropContext {
461
- private moduleResolver: ModuleResolver;
462
- private exportImportHandler: ExportImportHandler;
463
- private asyncHandler: AsyncFunctionHandler;
464
- private errorBoundary: ErrorBoundary;
465
- private typeLoader: TypeScriptTypeLoader;
466
-
467
- constructor(basePath?: string) {
468
- this.moduleResolver = new ModuleResolver(basePath);
469
- this.exportImportHandler = new ExportImportHandler();
470
- this.asyncHandler = new AsyncFunctionHandler();
471
- this.errorBoundary = new ErrorBoundary();
472
- this.typeLoader = new TypeScriptTypeLoader();
473
- }
474
-
475
- getModuleResolver(): ModuleResolver {
476
- return this.moduleResolver;
477
- }
478
-
479
- getExportImportHandler(): ExportImportHandler {
480
- return this.exportImportHandler;
481
- }
482
-
483
- getAsyncHandler(): AsyncFunctionHandler {
484
- return this.asyncHandler;
485
- }
486
-
487
- getErrorBoundary(): ErrorBoundary {
488
- return this.errorBoundary;
489
- }
490
-
491
- getTypeLoader(): TypeScriptTypeLoader {
492
- return this.typeLoader;
493
- }
494
- }
package/src/logger.js DELETED
@@ -1,42 +0,0 @@
1
- /**
2
- * @holoscript/core Logger
3
- *
4
- * Simple pluggable logger for HoloScript
5
- */
6
- class NoOpLogger {
7
- debug() { }
8
- info() { }
9
- warn() { }
10
- error() { }
11
- }
12
- class ConsoleLogger {
13
- debug(message, meta) {
14
- console.debug(`[HoloScript:DEBUG] ${message}`, meta ?? '');
15
- }
16
- info(message, meta) {
17
- console.info(`[HoloScript:INFO] ${message}`, meta ?? '');
18
- }
19
- warn(message, meta) {
20
- console.warn(`[HoloScript:WARN] ${message}`, meta ?? '');
21
- }
22
- error(message, meta) {
23
- console.error(`[HoloScript:ERROR] ${message}`, meta ?? '');
24
- }
25
- }
26
- let currentLogger = new NoOpLogger();
27
- export function setHoloScriptLogger(logger) {
28
- currentLogger = logger;
29
- }
30
- export function enableConsoleLogging() {
31
- currentLogger = new ConsoleLogger();
32
- }
33
- export function resetLogger() {
34
- currentLogger = new NoOpLogger();
35
- }
36
- export const logger = {
37
- debug: (msg, meta) => currentLogger.debug(msg, meta),
38
- info: (msg, meta) => currentLogger.info(msg, meta),
39
- warn: (msg, meta) => currentLogger.warn(msg, meta),
40
- error: (msg, meta) => currentLogger.error(msg, meta),
41
- };
42
- export { NoOpLogger, ConsoleLogger };
package/src/logger.ts DELETED
@@ -1,57 +0,0 @@
1
- /**
2
- * @holoscript/core Logger
3
- *
4
- * Simple pluggable logger for HoloScript
5
- */
6
-
7
- export interface HoloScriptLogger {
8
- debug(message: string, meta?: Record<string, unknown>): void;
9
- info(message: string, meta?: Record<string, unknown>): void;
10
- warn(message: string, meta?: Record<string, unknown>): void;
11
- error(message: string, meta?: Record<string, unknown>): void;
12
- }
13
-
14
- class NoOpLogger implements HoloScriptLogger {
15
- debug(): void {}
16
- info(): void {}
17
- warn(): void {}
18
- error(): void {}
19
- }
20
-
21
- class ConsoleLogger implements HoloScriptLogger {
22
- debug(message: string, meta?: Record<string, unknown>): void {
23
- console.debug(`[HoloScript:DEBUG] ${message}`, meta ?? '');
24
- }
25
- info(message: string, meta?: Record<string, unknown>): void {
26
- console.info(`[HoloScript:INFO] ${message}`, meta ?? '');
27
- }
28
- warn(message: string, meta?: Record<string, unknown>): void {
29
- console.warn(`[HoloScript:WARN] ${message}`, meta ?? '');
30
- }
31
- error(message: string, meta?: Record<string, unknown>): void {
32
- console.error(`[HoloScript:ERROR] ${message}`, meta ?? '');
33
- }
34
- }
35
-
36
- let currentLogger: HoloScriptLogger = new NoOpLogger();
37
-
38
- export function setHoloScriptLogger(logger: HoloScriptLogger): void {
39
- currentLogger = logger;
40
- }
41
-
42
- export function enableConsoleLogging(): void {
43
- currentLogger = new ConsoleLogger();
44
- }
45
-
46
- export function resetLogger(): void {
47
- currentLogger = new NoOpLogger();
48
- }
49
-
50
- export const logger: HoloScriptLogger = {
51
- debug: (msg, meta) => currentLogger.debug(msg, meta),
52
- info: (msg, meta) => currentLogger.info(msg, meta),
53
- warn: (msg, meta) => currentLogger.warn(msg, meta),
54
- error: (msg, meta) => currentLogger.error(msg, meta),
55
- };
56
-
57
- export { NoOpLogger, ConsoleLogger };