@holoscript/core 6.0.4 → 7.0.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.
Files changed (236) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -1
  3. package/dist/compiler/index.d.ts +82 -0
  4. package/dist/constants.d.ts +3 -2
  5. package/dist/coordinators/index.d.ts +189 -0
  6. package/dist/index.d.ts +501 -19
  7. package/dist/paper-0c-spike/index.d.ts +29 -0
  8. package/dist/reconstruction/index.d.ts +78 -0
  9. package/dist/tools/index.d.ts +22 -1
  10. package/dist/traitDocs/traitDocs.d.ts +69 -0
  11. package/dist/traits/index.d.ts +61 -0
  12. package/package.json +105 -57
  13. package/dist/GLTFPipeline-DEN36VNK.js +0 -12
  14. package/dist/GLTFPipeline-YPCAK236.cjs +0 -33
  15. package/dist/HoloScriptPlusParser-BN6KVRCM.js +0 -692
  16. package/dist/HoloScriptPlusParser-NC5FE6AL.cjs +0 -697
  17. package/dist/USDZExporter-NTMBNTDB.js +0 -707
  18. package/dist/USDZExporter-UWGWNMMD.cjs +0 -709
  19. package/dist/chunk-27LWW5FU.cjs +0 -410
  20. package/dist/chunk-2CWOLHTE.js +0 -69
  21. package/dist/chunk-33LSUQDD.cjs +0 -835
  22. package/dist/chunk-3FJCK5XA.js +0 -2232
  23. package/dist/chunk-3FXV5S25.cjs +0 -633
  24. package/dist/chunk-3FYZOR7S.cjs +0 -69
  25. package/dist/chunk-3SAK5KFL.cjs +0 -83
  26. package/dist/chunk-4XSNJCLC.cjs +0 -1859
  27. package/dist/chunk-54FHG2MX.js +0 -655
  28. package/dist/chunk-56IF4NTA.js +0 -56
  29. package/dist/chunk-5BGSECRJ.cjs +0 -2237
  30. package/dist/chunk-5GLCTO44.js +0 -161
  31. package/dist/chunk-5O6TQC6M.cjs +0 -1871
  32. package/dist/chunk-5OEOHAAW.cjs +0 -682
  33. package/dist/chunk-5TOFIR6L.js +0 -407
  34. package/dist/chunk-5WUNN6ZN.cjs +0 -428
  35. package/dist/chunk-6TZPZCOJ.cjs +0 -1404
  36. package/dist/chunk-6UEHYZ7V.cjs +0 -773
  37. package/dist/chunk-6XSERL6L.js +0 -5678
  38. package/dist/chunk-72EQECGT.cjs +0 -908
  39. package/dist/chunk-7AGYRWKW.cjs +0 -507
  40. package/dist/chunk-7LCYLPW2.cjs +0 -663
  41. package/dist/chunk-A7PIMZGU.js +0 -263
  42. package/dist/chunk-ATSKSYVE.cjs +0 -51683
  43. package/dist/chunk-B5TCIAPQ.cjs +0 -117
  44. package/dist/chunk-BF2235SI.cjs +0 -5714
  45. package/dist/chunk-BKIGPPVM.js +0 -629
  46. package/dist/chunk-BND3ST2K.cjs +0 -662
  47. package/dist/chunk-BU7VWW2K.js +0 -2522
  48. package/dist/chunk-BWFJEM5A.js +0 -5419
  49. package/dist/chunk-CAUCGUEA.cjs +0 -130
  50. package/dist/chunk-CBJSLA2E.cjs +0 -5423
  51. package/dist/chunk-CDPGV4DN.js +0 -114
  52. package/dist/chunk-CLYEIWA5.cjs +0 -408
  53. package/dist/chunk-CS2EMTGF.js +0 -1966
  54. package/dist/chunk-DMG7C4H2.js +0 -975
  55. package/dist/chunk-DXJQDCFL.js +0 -468
  56. package/dist/chunk-E3FWRT3Z.js +0 -608
  57. package/dist/chunk-E3UALNFA.js +0 -421
  58. package/dist/chunk-EONILVMF.js +0 -762
  59. package/dist/chunk-EQV4R3EV.cjs +0 -769
  60. package/dist/chunk-F3HH56EB.cjs +0 -5538
  61. package/dist/chunk-F4IULT7N.js +0 -1488
  62. package/dist/chunk-FF3Q7ADR.js +0 -380
  63. package/dist/chunk-FFKU7BTK.cjs +0 -1046
  64. package/dist/chunk-FHQVYCH2.js +0 -70
  65. package/dist/chunk-FSF7EQVA.cjs +0 -1974
  66. package/dist/chunk-G4VZTCIB.js +0 -659
  67. package/dist/chunk-G7CT3EMP.cjs +0 -1002
  68. package/dist/chunk-GGHSW2NN.js +0 -51334
  69. package/dist/chunk-GVUR45UF.cjs +0 -777
  70. package/dist/chunk-H5Z7NASB.js +0 -9662
  71. package/dist/chunk-HE7ULERA.cjs +0 -697
  72. package/dist/chunk-HJJLD366.js +0 -1169
  73. package/dist/chunk-HPS76H7Q.js +0 -309
  74. package/dist/chunk-HQUEA5R6.cjs +0 -424
  75. package/dist/chunk-HYNTS5CP.js +0 -422
  76. package/dist/chunk-I6XZ5DZF.cjs +0 -488
  77. package/dist/chunk-IBDG74G2.cjs +0 -1219
  78. package/dist/chunk-IFNQFCTM.js +0 -3098
  79. package/dist/chunk-IHOUYQIA.js +0 -406
  80. package/dist/chunk-ILRBGFVD.cjs +0 -72
  81. package/dist/chunk-IWI6J7FX.js +0 -421
  82. package/dist/chunk-K3JDKWGI.cjs +0 -270
  83. package/dist/chunk-K6EKD26I.js +0 -630
  84. package/dist/chunk-KCQ5NDYC.cjs +0 -3172
  85. package/dist/chunk-KED34ILP.js +0 -832
  86. package/dist/chunk-KSGXLT74.cjs +0 -457
  87. package/dist/chunk-L4G4RLXX.js +0 -767
  88. package/dist/chunk-LDP5OK6G.js +0 -1216
  89. package/dist/chunk-LGGRPKTV.cjs +0 -735
  90. package/dist/chunk-LK5IAVH6.cjs +0 -1173
  91. package/dist/chunk-LSW7P7ML.js +0 -3675
  92. package/dist/chunk-LXJ4667L.cjs +0 -3874
  93. package/dist/chunk-LZ266PCM.cjs +0 -4499
  94. package/dist/chunk-MD6KDHVE.cjs +0 -237
  95. package/dist/chunk-MEASWI2Y.js +0 -126
  96. package/dist/chunk-MPXBVFHQ.js +0 -768
  97. package/dist/chunk-N5FTS757.cjs +0 -415
  98. package/dist/chunk-NCUKG4SK.cjs +0 -3075
  99. package/dist/chunk-NDQNIJEH.js +0 -1715
  100. package/dist/chunk-NOZZ46QU.js +0 -168
  101. package/dist/chunk-OFKWH2IP.js +0 -449
  102. package/dist/chunk-PHENW4MQ.js +0 -65
  103. package/dist/chunk-PMGODDJA.cjs +0 -319
  104. package/dist/chunk-Q4QX3AET.cjs +0 -1505
  105. package/dist/chunk-Q56TT7IL.js +0 -483
  106. package/dist/chunk-Q5JT3YML.cjs +0 -129
  107. package/dist/chunk-Q5SJOGHQ.cjs +0 -4256
  108. package/dist/chunk-QGKNANZ3.js +0 -3071
  109. package/dist/chunk-QLEAOI3Q.cjs +0 -424
  110. package/dist/chunk-R7MA7QWV.js +0 -732
  111. package/dist/chunk-RVYPEYPX.js +0 -678
  112. package/dist/chunk-S2N5TNMA.js +0 -1855
  113. package/dist/chunk-S565K7NK.js +0 -752
  114. package/dist/chunk-SDAMZIRE.js +0 -765
  115. package/dist/chunk-T36DDXSF.js +0 -4250
  116. package/dist/chunk-T4NKMBDL.js +0 -5474
  117. package/dist/chunk-T7LEXZUZ.cjs +0 -2526
  118. package/dist/chunk-TEWCN33Y.js +0 -694
  119. package/dist/chunk-TQSZUOW5.cjs +0 -793
  120. package/dist/chunk-TSH3MSQU.cjs +0 -129
  121. package/dist/chunk-UERJ3YJV.js +0 -504
  122. package/dist/chunk-UPJBDCVF.js +0 -1395
  123. package/dist/chunk-V3NN3HPP.js +0 -4462
  124. package/dist/chunk-VJ3L7CHT.cjs +0 -169
  125. package/dist/chunk-WB4Z63GG.js +0 -229
  126. package/dist/chunk-WDW67DZB.cjs +0 -9728
  127. package/dist/chunk-WGMEAYBG.js +0 -126
  128. package/dist/chunk-X4ZF6CNE.cjs +0 -473
  129. package/dist/chunk-X6SEAXAX.cjs +0 -3681
  130. package/dist/chunk-XCWFGZAA.js +0 -1043
  131. package/dist/chunk-XD6IYDUX.js +0 -903
  132. package/dist/chunk-XG23EUQX.cjs +0 -1717
  133. package/dist/chunk-XRKWN5PL.cjs +0 -173
  134. package/dist/chunk-XUILI4KB.cjs +0 -430
  135. package/dist/chunk-XUTX5CBW.js +0 -126
  136. package/dist/chunk-XWPNTWDN.cjs +0 -755
  137. package/dist/chunk-XXINBTZK.cjs +0 -633
  138. package/dist/chunk-YCXFCXDS.js +0 -1868
  139. package/dist/chunk-YQK5JNFK.js +0 -3725
  140. package/dist/chunk-YYXH45E2.js +0 -426
  141. package/dist/chunk-Z34RLXRA.cjs +0 -612
  142. package/dist/chunk-ZP4D3CSX.cjs +0 -72
  143. package/dist/cli/holoscript-runner.cjs +0 -2259
  144. package/dist/cli/holoscript-runner.js +0 -2234
  145. package/dist/codebase/index.cjs +0 -336
  146. package/dist/codebase/index.js +0 -331
  147. package/dist/compiler/agent-inference.cjs +0 -28
  148. package/dist/compiler/agent-inference.js +0 -5
  149. package/dist/compiler/android-xr.cjs +0 -19
  150. package/dist/compiler/android-xr.js +0 -9
  151. package/dist/compiler/android.cjs +0 -20
  152. package/dist/compiler/android.js +0 -10
  153. package/dist/compiler/ar.cjs +0 -20
  154. package/dist/compiler/ar.js +0 -8
  155. package/dist/compiler/babylon.cjs +0 -17
  156. package/dist/compiler/babylon.js +0 -11
  157. package/dist/compiler/coco.cjs +0 -27
  158. package/dist/compiler/coco.js +0 -4
  159. package/dist/compiler/domain-block-utils.cjs +0 -602
  160. package/dist/compiler/domain-block-utils.js +0 -8
  161. package/dist/compiler/dtdl.cjs +0 -24
  162. package/dist/compiler/dtdl.js +0 -8
  163. package/dist/compiler/gltf-pipeline.cjs +0 -39
  164. package/dist/compiler/gltf-pipeline.js +0 -4
  165. package/dist/compiler/godot.cjs +0 -15
  166. package/dist/compiler/godot.js +0 -9
  167. package/dist/compiler/incremental.cjs +0 -29
  168. package/dist/compiler/incremental.js +0 -4
  169. package/dist/compiler/index.cjs +0 -2578
  170. package/dist/compiler/index.js +0 -2383
  171. package/dist/compiler/ios.cjs +0 -20
  172. package/dist/compiler/ios.js +0 -10
  173. package/dist/compiler/multi-layer.cjs +0 -20
  174. package/dist/compiler/multi-layer.js +0 -11
  175. package/dist/compiler/nodetoy.cjs +0 -23
  176. package/dist/compiler/nodetoy.js +0 -4
  177. package/dist/compiler/openxr.cjs +0 -15
  178. package/dist/compiler/openxr.js +0 -9
  179. package/dist/compiler/playcanvas.cjs +0 -16
  180. package/dist/compiler/playcanvas.js +0 -10
  181. package/dist/compiler/r3f.cjs +0 -34
  182. package/dist/compiler/r3f.js +0 -12
  183. package/dist/compiler/remotion.cjs +0 -23
  184. package/dist/compiler/remotion.js +0 -4
  185. package/dist/compiler/reproducibility.cjs +0 -39
  186. package/dist/compiler/reproducibility.js +0 -4
  187. package/dist/compiler/sdf.cjs +0 -21
  188. package/dist/compiler/sdf.js +0 -9
  189. package/dist/compiler/semantic-scene.cjs +0 -31
  190. package/dist/compiler/semantic-scene.js +0 -4
  191. package/dist/compiler/state.cjs +0 -17
  192. package/dist/compiler/state.js +0 -7
  193. package/dist/compiler/trait-composition.cjs +0 -26
  194. package/dist/compiler/trait-composition.js +0 -5
  195. package/dist/compiler/unity.cjs +0 -15
  196. package/dist/compiler/unity.js +0 -9
  197. package/dist/compiler/unreal.cjs +0 -19
  198. package/dist/compiler/unreal.js +0 -9
  199. package/dist/compiler/urdf.cjs +0 -45
  200. package/dist/compiler/urdf.js +0 -9
  201. package/dist/compiler/usd-physics.cjs +0 -23
  202. package/dist/compiler/usd-physics.js +0 -6
  203. package/dist/compiler/visionos.cjs +0 -15
  204. package/dist/compiler/visionos.js +0 -9
  205. package/dist/compiler/vrchat.cjs +0 -19
  206. package/dist/compiler/vrchat.js +0 -9
  207. package/dist/compiler/vrr.cjs +0 -21
  208. package/dist/compiler/vrr.js +0 -9
  209. package/dist/compiler/wasm.cjs +0 -33
  210. package/dist/compiler/wasm.js +0 -9
  211. package/dist/compiler/webgpu.cjs +0 -15
  212. package/dist/compiler/webgpu.js +0 -9
  213. package/dist/debugger.cjs +0 -21
  214. package/dist/debugger.js +0 -8
  215. package/dist/entries/interop.cjs +0 -62
  216. package/dist/entries/interop.js +0 -5
  217. package/dist/entries/scripting.cjs +0 -68
  218. package/dist/entries/scripting.js +0 -11
  219. package/dist/index.cjs +0 -40921
  220. package/dist/index.js +0 -37763
  221. package/dist/math/vec3.cjs +0 -57
  222. package/dist/math/vec3.js +0 -4
  223. package/dist/ml-dsa-PHCWUBPX.cjs +0 -1178
  224. package/dist/ml-dsa-WYLJHJO6.js +0 -1178
  225. package/dist/parser.cjs +0 -27
  226. package/dist/parser.js +0 -10
  227. package/dist/playwright-5OSAPTNH.js +0 -98660
  228. package/dist/playwright-RL6GY4F7.cjs +0 -98673
  229. package/dist/runtime.cjs +0 -16
  230. package/dist/runtime.js +0 -7
  231. package/dist/storage/index.cjs +0 -37
  232. package/dist/storage/index.js +0 -4
  233. package/dist/traits/index.cjs +0 -14649
  234. package/dist/traits/index.js +0 -12243
  235. package/dist/type-checker.cjs +0 -18
  236. package/dist/type-checker.js +0 -5
@@ -1,114 +0,0 @@
1
- import { __export, __esm } from './chunk-2CWOLHTE.js';
2
- import { getRBAC, WorkflowStep, ResourceType } from '@holoscript/platform';
3
-
4
- // src/compiler/StateCompiler.ts
5
- var StateCompiler_exports = {};
6
- __export(StateCompiler_exports, {
7
- StateCompiler: () => StateCompiler,
8
- UnauthorizedStateCompilerAccessError: () => UnauthorizedStateCompilerAccessError
9
- });
10
- var StateCompiler, UnauthorizedStateCompilerAccessError;
11
- var init_StateCompiler = __esm({
12
- "src/compiler/StateCompiler.ts"() {
13
- StateCompiler = class {
14
- /**
15
- * Walk an entire HSPlusAST and extract all per-node stateBlocks.
16
- *
17
- * @param ast - The parse result returned by HoloScriptPlusParser.
18
- * @param agentToken - JWT token proving agent identity (optional for backwards compatibility).
19
- * @returns A StateShapeMap keyed by node.name (or a generated id).
20
- * @throws UnauthorizedStateCompilerAccessError if token is provided but invalid.
21
- */
22
- compile(ast, agentToken) {
23
- this.validateAccess(agentToken);
24
- const shapes = /* @__PURE__ */ new Map();
25
- this.walkNode(ast.root, shapes);
26
- return shapes;
27
- }
28
- // ---------------------------------------------------------------------------
29
- // RBAC enforcement
30
- // ---------------------------------------------------------------------------
31
- /**
32
- * Validate agent has permission to compile state blocks.
33
- * Skips validation when no token is provided (backwards compatibility / testing).
34
- */
35
- validateAccess(agentToken) {
36
- if (!agentToken) return;
37
- const rbac = getRBAC();
38
- const decision = rbac.checkAccess({
39
- token: agentToken,
40
- resourceType: ResourceType.AST,
41
- operation: "read",
42
- expectedWorkflowStep: WorkflowStep.GENERATE_ASSEMBLY
43
- });
44
- if (!decision.allowed) {
45
- throw new UnauthorizedStateCompilerAccessError(decision, "StateCompiler");
46
- }
47
- }
48
- /**
49
- * Compile a single HSPlusNode subtree.
50
- * Useful when only a portion of the AST is being (re-)compiled.
51
- */
52
- compileNode(node) {
53
- if (!node.stateBlock || Object.keys(node.stateBlock).length === 0) {
54
- return null;
55
- }
56
- return this.buildShape(node);
57
- }
58
- // ---------------------------------------------------------------------------
59
- // Private helpers
60
- // ---------------------------------------------------------------------------
61
- walkNode(node, out) {
62
- if (!node) return;
63
- if (node.stateBlock && Object.keys(node.stateBlock).length > 0) {
64
- const shape = this.buildShape(node);
65
- out.set(shape.nodeId, shape);
66
- }
67
- if (Array.isArray(node.children)) {
68
- for (const child of node.children) {
69
- this.walkNode(child, out);
70
- }
71
- }
72
- if (node.body && typeof node.body === "object" && !Array.isArray(node.body)) {
73
- if (node.body.type) {
74
- this.walkNode(node.body, out);
75
- }
76
- }
77
- }
78
- buildShape(node) {
79
- const nodeId = this.resolveNodeId(node);
80
- const stateBlock = node.stateBlock ?? {};
81
- const vars = [];
82
- const initialState = {};
83
- for (const [key, value] of Object.entries(stateBlock)) {
84
- if (key.startsWith("__spread_")) continue;
85
- vars.push({ name: key, initialValue: value });
86
- initialState[key] = value;
87
- }
88
- return { nodeId, initialState, vars };
89
- }
90
- resolveNodeId(node) {
91
- if (node.name) return node.name;
92
- const loc = node.loc;
93
- if (loc) return `${node.type}@${loc.start.line}:${loc.start.column}`;
94
- return `${node.type}_${Math.random().toString(36).slice(2, 7)}`;
95
- }
96
- };
97
- UnauthorizedStateCompilerAccessError = class extends Error {
98
- constructor(decision, compilerName) {
99
- super(
100
- `[${compilerName}] Unauthorized access: ${decision.reason || "Access denied"}
101
- Agent Role: ${decision.agentRole || "unknown"}
102
- Required Permission: ${decision.requiredPermission || "unknown"}`
103
- );
104
- this.decision = decision;
105
- this.compilerName = compilerName;
106
- this.name = "UnauthorizedStateCompilerAccessError";
107
- }
108
- };
109
- }
110
- });
111
-
112
- export { StateCompiler, StateCompiler_exports, UnauthorizedStateCompilerAccessError, init_StateCompiler };
113
- //# sourceMappingURL=chunk-CDPGV4DN.js.map
114
- //# sourceMappingURL=chunk-CDPGV4DN.js.map
@@ -1,408 +0,0 @@
1
- 'use strict';
2
-
3
- var path = require('path');
4
- var fs = require('fs');
5
-
6
- function _interopNamespace(e) {
7
- if (e && e.__esModule) return e;
8
- var n = Object.create(null);
9
- if (e) {
10
- Object.keys(e).forEach(function (k) {
11
- if (k !== 'default') {
12
- var d = Object.getOwnPropertyDescriptor(e, k);
13
- Object.defineProperty(n, k, d.get ? d : {
14
- enumerable: true,
15
- get: function () { return e[k]; }
16
- });
17
- }
18
- });
19
- }
20
- n.default = e;
21
- return Object.freeze(n);
22
- }
23
-
24
- var path__namespace = /*#__PURE__*/_interopNamespace(path);
25
- var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
26
-
27
- // src/interop/Interoperability.ts
28
- var ModuleResolver = class {
29
- constructor(basePath = process.cwd()) {
30
- this.cache = /* @__PURE__ */ new Map();
31
- this.resolvedPaths = /* @__PURE__ */ new Map();
32
- this.basePath = basePath;
33
- }
34
- /**
35
- * Resolve module path
36
- */
37
- resolveModule(modulePath, fromPath) {
38
- const cacheKey = `${modulePath}:${fromPath || "root"}`;
39
- if (this.resolvedPaths.has(cacheKey)) {
40
- return this.resolvedPaths.get(cacheKey);
41
- }
42
- const resolved = this.performResolve(modulePath, fromPath);
43
- this.resolvedPaths.set(cacheKey, resolved);
44
- return resolved;
45
- }
46
- /**
47
- * Perform actual module resolution
48
- */
49
- performResolve(modulePath, fromPath) {
50
- if (this.isBuiltinModule(modulePath)) {
51
- return modulePath;
52
- }
53
- if (modulePath.startsWith(".")) {
54
- const basePath = fromPath ? path__namespace.dirname(fromPath) : this.basePath;
55
- const resolved = path__namespace.resolve(basePath, modulePath);
56
- return this.findModuleFile(resolved);
57
- }
58
- if (modulePath.startsWith("@")) {
59
- return this.resolveNodeModule(modulePath);
60
- }
61
- return this.resolveNodeModule(modulePath);
62
- }
63
- /**
64
- * Check if built-in module
65
- */
66
- isBuiltinModule(modulePath) {
67
- const builtins = ["fs", "path", "crypto", "util", "stream", "events"];
68
- return builtins.includes(modulePath);
69
- }
70
- /**
71
- * Resolve from node_modules
72
- */
73
- resolveNodeModule(modulePath) {
74
- let current = this.basePath;
75
- while (current !== path__namespace.dirname(current)) {
76
- const nodeModulesPath = path__namespace.join(current, "node_modules", modulePath);
77
- if (fs__namespace.existsSync(nodeModulesPath)) {
78
- return nodeModulesPath;
79
- }
80
- const packageJsonPath = path__namespace.join(nodeModulesPath, "package.json");
81
- if (fs__namespace.existsSync(packageJsonPath)) {
82
- const packageJson = JSON.parse(fs__namespace.readFileSync(packageJsonPath, "utf-8"));
83
- return this.findModuleFile(path__namespace.join(nodeModulesPath, packageJson.main || "index.js"));
84
- }
85
- current = path__namespace.dirname(current);
86
- }
87
- throw new Error(`Module not found: ${modulePath}`);
88
- }
89
- /**
90
- * Find module file with various extensions
91
- */
92
- findModuleFile(basePath) {
93
- const extensions = [".ts", ".tsx", ".js", ".jsx", ".json"];
94
- if (fs__namespace.existsSync(basePath)) {
95
- return basePath;
96
- }
97
- for (const ext of extensions) {
98
- const withExt = basePath + ext;
99
- if (fs__namespace.existsSync(withExt)) {
100
- return withExt;
101
- }
102
- }
103
- const indexPath = path__namespace.join(basePath, "index");
104
- for (const ext of extensions) {
105
- const withExt = indexPath + ext;
106
- if (fs__namespace.existsSync(withExt)) {
107
- return withExt;
108
- }
109
- }
110
- throw new Error(`Cannot resolve file: ${basePath}`);
111
- }
112
- /**
113
- * Load module (with caching)
114
- */
115
- loadModule(modulePath, fromPath) {
116
- const resolved = this.resolveModule(modulePath, fromPath);
117
- const cacheKey = resolved;
118
- if (this.cache.has(cacheKey)) {
119
- return this.cache.get(cacheKey);
120
- }
121
- const module = {
122
- path: resolved,
123
- exports: {}
124
- };
125
- this.cache.set(cacheKey, module);
126
- return module;
127
- }
128
- /**
129
- * Clear cache
130
- */
131
- clearCache() {
132
- this.cache.clear();
133
- this.resolvedPaths.clear();
134
- }
135
- };
136
- var ExportImportHandler = class {
137
- constructor() {
138
- this.exports = /* @__PURE__ */ new Map();
139
- }
140
- /**
141
- * Define named export
142
- */
143
- defineExport(modulePath, name, value) {
144
- if (!this.exports.has(modulePath)) {
145
- this.exports.set(modulePath, /* @__PURE__ */ new Map());
146
- }
147
- this.exports.get(modulePath).set(name, value);
148
- }
149
- /**
150
- * Get named export
151
- */
152
- getExport(modulePath, name) {
153
- const moduleExports = this.exports.get(modulePath);
154
- if (!moduleExports) {
155
- throw new Error(`Module not found: ${modulePath}`);
156
- }
157
- if (!moduleExports.has(name)) {
158
- throw new Error(`Named export '${name}' not found in ${modulePath}`);
159
- }
160
- return moduleExports.get(name);
161
- }
162
- /**
163
- * Get all exports from module
164
- */
165
- getAllExports(modulePath) {
166
- const moduleExports = this.exports.get(modulePath);
167
- if (!moduleExports) {
168
- return {};
169
- }
170
- const result = {};
171
- for (const [name, value] of moduleExports) {
172
- result[name] = value;
173
- }
174
- return result;
175
- }
176
- /**
177
- * Check if export exists
178
- */
179
- hasExport(modulePath, name) {
180
- return this.exports.has(modulePath) && this.exports.get(modulePath).has(name);
181
- }
182
- };
183
- var AsyncFunctionHandler = class {
184
- /**
185
- * Wrap async function for HoloScript
186
- */
187
- wrapAsyncFunction(fn) {
188
- return async (...args) => {
189
- try {
190
- return await fn(...args);
191
- } catch (error) {
192
- throw this.normalizeError(error);
193
- }
194
- };
195
- }
196
- /**
197
- * Check if function is async
198
- */
199
- isAsync(fn) {
200
- if (typeof fn !== "function") {
201
- return false;
202
- }
203
- const fnStr = fn.toString().trim();
204
- return fnStr.startsWith("async ") || fn.constructor.name === "AsyncFunction";
205
- }
206
- /**
207
- * Convert callback to promise
208
- */
209
- callbackToPromise(fn) {
210
- return new Promise((resolve2, reject) => {
211
- fn((err, result) => {
212
- if (err) {
213
- reject(err);
214
- } else {
215
- resolve2(result);
216
- }
217
- });
218
- });
219
- }
220
- /**
221
- * Normalize error from async function
222
- */
223
- normalizeError(error) {
224
- if (error instanceof Error) {
225
- return error;
226
- }
227
- if (typeof error === "string") {
228
- return new Error(error);
229
- }
230
- return new Error(JSON.stringify(error));
231
- }
232
- };
233
- var ErrorBoundary = class {
234
- constructor(onError) {
235
- this.errors = [];
236
- this.onError = onError;
237
- }
238
- /**
239
- * Wrap function with error boundary
240
- */
241
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
242
- wrap(fn) {
243
- return ((...args) => {
244
- try {
245
- const result = fn(...args);
246
- if (result instanceof Promise) {
247
- return result.catch((error) => {
248
- this.handleError(error);
249
- throw error;
250
- });
251
- }
252
- return result;
253
- } catch (error) {
254
- this.handleError(error);
255
- throw error;
256
- }
257
- });
258
- }
259
- /**
260
- * Wrap async function with error boundary
261
- */
262
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
263
- wrapAsync(fn) {
264
- return (async (...args) => {
265
- try {
266
- return await fn(...args);
267
- } catch (error) {
268
- this.handleError(error);
269
- throw error;
270
- }
271
- });
272
- }
273
- /**
274
- * Execute function in boundary
275
- */
276
- execute(fn) {
277
- try {
278
- return fn();
279
- } catch (error) {
280
- this.handleError(error);
281
- throw error;
282
- }
283
- }
284
- /**
285
- * Execute async function in boundary
286
- */
287
- async executeAsync(fn) {
288
- try {
289
- return await fn();
290
- } catch (error) {
291
- this.handleError(error);
292
- throw error;
293
- }
294
- }
295
- /**
296
- * Handle error
297
- */
298
- handleError(error) {
299
- const normalized = this.normalizeError(error);
300
- this.errors.push(normalized);
301
- if (this.onError) {
302
- this.onError(normalized);
303
- }
304
- }
305
- /**
306
- * Get errors
307
- */
308
- getErrors() {
309
- return [...this.errors];
310
- }
311
- /**
312
- * Clear errors
313
- */
314
- clearErrors() {
315
- this.errors = [];
316
- }
317
- /**
318
- * Normalize error
319
- */
320
- normalizeError(error) {
321
- if (error instanceof Error) {
322
- return error;
323
- }
324
- if (typeof error === "string") {
325
- return new Error(error);
326
- }
327
- return new Error(JSON.stringify(error));
328
- }
329
- };
330
- var TypeScriptTypeLoader = class {
331
- /**
332
- * Load types from TypeScript declaration file
333
- */
334
- loadTypes(_filePath) {
335
- const types = /* @__PURE__ */ new Map();
336
- return types;
337
- }
338
- /**
339
- * Convert TypeScript type to HoloScript type
340
- */
341
- convertType(tsType) {
342
- const mapping = {
343
- string: "text",
344
- number: "numeric",
345
- boolean: "logical",
346
- void: "void",
347
- any: "dynamic",
348
- unknown: "dynamic",
349
- null: "null",
350
- undefined: "void"
351
- };
352
- if (typeof tsType === "string") {
353
- return mapping[tsType] || tsType;
354
- }
355
- if (Array.isArray(tsType)) {
356
- return {
357
- kind: "array",
358
- elementType: this.convertType(tsType[0])
359
- };
360
- }
361
- if (typeof tsType === "object") {
362
- return {
363
- kind: "object",
364
- properties: Object.entries(tsType).reduce(
365
- (acc, [key, val]) => {
366
- acc[key] = this.convertType(val);
367
- return acc;
368
- },
369
- {}
370
- )
371
- };
372
- }
373
- return tsType;
374
- }
375
- };
376
- var InteropContext = class {
377
- constructor(basePath) {
378
- this.moduleResolver = new ModuleResolver(basePath);
379
- this.exportImportHandler = new ExportImportHandler();
380
- this.asyncHandler = new AsyncFunctionHandler();
381
- this.errorBoundary = new ErrorBoundary();
382
- this.typeLoader = new TypeScriptTypeLoader();
383
- }
384
- getModuleResolver() {
385
- return this.moduleResolver;
386
- }
387
- getExportImportHandler() {
388
- return this.exportImportHandler;
389
- }
390
- getAsyncHandler() {
391
- return this.asyncHandler;
392
- }
393
- getErrorBoundary() {
394
- return this.errorBoundary;
395
- }
396
- getTypeLoader() {
397
- return this.typeLoader;
398
- }
399
- };
400
-
401
- exports.AsyncFunctionHandler = AsyncFunctionHandler;
402
- exports.ErrorBoundary = ErrorBoundary;
403
- exports.ExportImportHandler = ExportImportHandler;
404
- exports.InteropContext = InteropContext;
405
- exports.ModuleResolver = ModuleResolver;
406
- exports.TypeScriptTypeLoader = TypeScriptTypeLoader;
407
- //# sourceMappingURL=chunk-CLYEIWA5.cjs.map
408
- //# sourceMappingURL=chunk-CLYEIWA5.cjs.map