@ricsam/isolate 0.0.1 → 0.1.1

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 (299) hide show
  1. package/README.md +243 -34
  2. package/dist/cjs/bridge/diagnostics.cjs +58 -0
  3. package/dist/cjs/bridge/diagnostics.cjs.map +10 -0
  4. package/dist/cjs/bridge/legacy-adapters.cjs +242 -0
  5. package/dist/cjs/bridge/legacy-adapters.cjs.map +10 -0
  6. package/dist/cjs/bridge/request-context.cjs +59 -0
  7. package/dist/cjs/bridge/request-context.cjs.map +10 -0
  8. package/dist/cjs/bridge/runtime-bindings.cjs +367 -0
  9. package/dist/cjs/bridge/runtime-bindings.cjs.map +10 -0
  10. package/dist/cjs/browser/browser-runtime.cjs +157 -0
  11. package/dist/cjs/browser/browser-runtime.cjs.map +10 -0
  12. package/dist/cjs/daemon.cjs +91 -0
  13. package/dist/cjs/daemon.cjs.map +10 -0
  14. package/dist/cjs/files/index.cjs +140 -0
  15. package/dist/cjs/files/index.cjs.map +10 -0
  16. package/dist/cjs/host/create-isolate-host.cjs +235 -0
  17. package/dist/cjs/host/create-isolate-host.cjs.map +10 -0
  18. package/dist/cjs/host/index.cjs +47 -0
  19. package/dist/cjs/host/index.cjs.map +10 -0
  20. package/dist/cjs/index.cjs +55 -0
  21. package/dist/cjs/index.cjs.map +10 -0
  22. package/dist/cjs/internal/client/connection.cjs +1919 -0
  23. package/dist/cjs/internal/client/connection.cjs.map +10 -0
  24. package/dist/cjs/internal/client/index.cjs +48 -0
  25. package/dist/cjs/internal/client/index.cjs.map +10 -0
  26. package/dist/cjs/internal/client/types.cjs +30 -0
  27. package/dist/cjs/internal/client/types.cjs.map +9 -0
  28. package/dist/cjs/internal/console/index.cjs +506 -0
  29. package/dist/cjs/internal/console/index.cjs.map +10 -0
  30. package/dist/cjs/internal/console/utils.cjs +70 -0
  31. package/dist/cjs/internal/console/utils.cjs.map +10 -0
  32. package/dist/cjs/internal/core/index.cjs +2745 -0
  33. package/dist/cjs/internal/core/index.cjs.map +10 -0
  34. package/dist/cjs/internal/crypto/index.cjs +470 -0
  35. package/dist/cjs/internal/crypto/index.cjs.map +10 -0
  36. package/dist/cjs/internal/daemon/callback-fs-handler.cjs +355 -0
  37. package/dist/cjs/internal/daemon/callback-fs-handler.cjs.map +10 -0
  38. package/dist/cjs/internal/daemon/connection.cjs +1952 -0
  39. package/dist/cjs/internal/daemon/connection.cjs.map +10 -0
  40. package/dist/cjs/internal/daemon/daemon.cjs +98 -0
  41. package/dist/cjs/internal/daemon/daemon.cjs.map +10 -0
  42. package/dist/cjs/internal/daemon/index.cjs +145 -0
  43. package/dist/cjs/internal/daemon/index.cjs.map +10 -0
  44. package/dist/cjs/internal/daemon/runtime-pool.cjs +106 -0
  45. package/dist/cjs/internal/daemon/runtime-pool.cjs.map +10 -0
  46. package/dist/cjs/internal/daemon/types.cjs +30 -0
  47. package/dist/cjs/internal/daemon/types.cjs.map +9 -0
  48. package/dist/cjs/internal/encoding/index.cjs +419 -0
  49. package/dist/cjs/internal/encoding/index.cjs.map +10 -0
  50. package/dist/cjs/internal/fetch/consistency/origins.cjs +598 -0
  51. package/dist/cjs/internal/fetch/consistency/origins.cjs.map +10 -0
  52. package/dist/cjs/internal/fetch/index.cjs +2640 -0
  53. package/dist/cjs/internal/fetch/index.cjs.map +10 -0
  54. package/dist/cjs/internal/fetch/stream-state.cjs +256 -0
  55. package/dist/cjs/internal/fetch/stream-state.cjs.map +10 -0
  56. package/dist/cjs/internal/fs/index.cjs +847 -0
  57. package/dist/cjs/internal/fs/index.cjs.map +10 -0
  58. package/dist/cjs/internal/fs/node-adapter.cjs +254 -0
  59. package/dist/cjs/internal/fs/node-adapter.cjs.map +10 -0
  60. package/dist/cjs/internal/module-loader/bundle.cjs +482 -0
  61. package/dist/cjs/internal/module-loader/bundle.cjs.map +10 -0
  62. package/dist/cjs/internal/module-loader/index.cjs +240 -0
  63. package/dist/cjs/internal/module-loader/index.cjs.map +10 -0
  64. package/dist/cjs/internal/module-loader/mappings.cjs +120 -0
  65. package/dist/cjs/internal/module-loader/mappings.cjs.map +10 -0
  66. package/dist/cjs/internal/module-loader/resolve.cjs +177 -0
  67. package/dist/cjs/internal/module-loader/resolve.cjs.map +10 -0
  68. package/dist/cjs/internal/module-loader/strip-types.cjs +236 -0
  69. package/dist/cjs/internal/module-loader/strip-types.cjs.map +10 -0
  70. package/dist/cjs/internal/path/index.cjs +503 -0
  71. package/dist/cjs/internal/path/index.cjs.map +10 -0
  72. package/dist/cjs/internal/playwright/client.cjs +49 -0
  73. package/dist/cjs/internal/playwright/client.cjs.map +10 -0
  74. package/dist/cjs/internal/playwright/handler.cjs +1416 -0
  75. package/dist/cjs/internal/playwright/handler.cjs.map +10 -0
  76. package/dist/cjs/internal/playwright/index.cjs +1289 -0
  77. package/dist/cjs/internal/playwright/index.cjs.map +10 -0
  78. package/dist/cjs/internal/playwright/types.cjs +47 -0
  79. package/dist/cjs/internal/playwright/types.cjs.map +10 -0
  80. package/dist/cjs/internal/protocol/codec.cjs +510 -0
  81. package/dist/cjs/internal/protocol/codec.cjs.map +10 -0
  82. package/dist/cjs/internal/protocol/framing.cjs +141 -0
  83. package/dist/cjs/internal/protocol/framing.cjs.map +10 -0
  84. package/dist/cjs/internal/protocol/index.cjs +110 -0
  85. package/dist/cjs/internal/protocol/index.cjs.map +10 -0
  86. package/dist/cjs/internal/protocol/marshalValue.cjs +518 -0
  87. package/dist/cjs/internal/protocol/marshalValue.cjs.map +10 -0
  88. package/dist/cjs/internal/protocol/serialization.cjs +109 -0
  89. package/dist/cjs/internal/protocol/serialization.cjs.map +10 -0
  90. package/dist/cjs/internal/protocol/types.cjs +181 -0
  91. package/dist/cjs/internal/protocol/types.cjs.map +10 -0
  92. package/dist/cjs/internal/runtime/index.cjs +1235 -0
  93. package/dist/cjs/internal/runtime/index.cjs.map +10 -0
  94. package/dist/cjs/internal/server/index.cjs +223 -0
  95. package/dist/cjs/internal/server/index.cjs.map +10 -0
  96. package/dist/cjs/internal/test-environment/index.cjs +1415 -0
  97. package/dist/cjs/internal/test-environment/index.cjs.map +10 -0
  98. package/dist/cjs/internal/timers/index.cjs +200 -0
  99. package/dist/cjs/internal/timers/index.cjs.map +10 -0
  100. package/dist/cjs/internal/transform/index.cjs +361 -0
  101. package/dist/cjs/internal/transform/index.cjs.map +10 -0
  102. package/dist/cjs/internal/typecheck/index.cjs +60 -0
  103. package/dist/cjs/internal/typecheck/index.cjs.map +10 -0
  104. package/dist/cjs/internal/typecheck/isolate-types.cjs +2614 -0
  105. package/dist/cjs/internal/typecheck/isolate-types.cjs.map +10 -0
  106. package/dist/cjs/internal/typecheck/typecheck.cjs +131 -0
  107. package/dist/cjs/internal/typecheck/typecheck.cjs.map +10 -0
  108. package/dist/cjs/modules/index.cjs +160 -0
  109. package/dist/cjs/modules/index.cjs.map +10 -0
  110. package/dist/cjs/package.json +5 -0
  111. package/dist/cjs/runtime/script-runtime.cjs +97 -0
  112. package/dist/cjs/runtime/script-runtime.cjs.map +10 -0
  113. package/dist/cjs/server/app-server.cjs +158 -0
  114. package/dist/cjs/server/app-server.cjs.map +10 -0
  115. package/dist/cjs/testing/integration-helpers.cjs +127 -0
  116. package/dist/cjs/testing/integration-helpers.cjs.map +10 -0
  117. package/dist/cjs/typecheck/index.cjs +96 -0
  118. package/dist/cjs/typecheck/index.cjs.map +10 -0
  119. package/dist/cjs/types.cjs +30 -0
  120. package/dist/cjs/types.cjs.map +9 -0
  121. package/dist/mjs/bridge/diagnostics.mjs +18 -0
  122. package/dist/mjs/bridge/diagnostics.mjs.map +10 -0
  123. package/dist/mjs/bridge/legacy-adapters.mjs +178 -0
  124. package/dist/mjs/bridge/legacy-adapters.mjs.map +10 -0
  125. package/dist/mjs/bridge/request-context.mjs +19 -0
  126. package/dist/mjs/bridge/request-context.mjs.map +10 -0
  127. package/dist/mjs/bridge/runtime-bindings.mjs +303 -0
  128. package/dist/mjs/bridge/runtime-bindings.mjs.map +10 -0
  129. package/dist/mjs/browser/browser-runtime.mjs +93 -0
  130. package/dist/mjs/browser/browser-runtime.mjs.map +10 -0
  131. package/dist/mjs/daemon.mjs +91 -0
  132. package/dist/mjs/daemon.mjs.map +10 -0
  133. package/dist/mjs/files/index.mjs +76 -0
  134. package/dist/mjs/files/index.mjs.map +10 -0
  135. package/dist/mjs/host/create-isolate-host.mjs +171 -0
  136. package/dist/mjs/host/create-isolate-host.mjs.map +10 -0
  137. package/dist/mjs/host/index.mjs +7 -0
  138. package/dist/mjs/host/index.mjs.map +10 -0
  139. package/dist/mjs/index.mjs +15 -0
  140. package/dist/mjs/index.mjs.map +10 -0
  141. package/dist/mjs/internal/client/connection.mjs +1872 -0
  142. package/dist/mjs/internal/client/connection.mjs.map +10 -0
  143. package/dist/mjs/internal/client/index.mjs +8 -0
  144. package/dist/mjs/internal/client/index.mjs.map +10 -0
  145. package/dist/mjs/internal/client/types.mjs +2 -0
  146. package/dist/mjs/internal/client/types.mjs.map +9 -0
  147. package/dist/mjs/internal/console/index.mjs +442 -0
  148. package/dist/mjs/internal/console/index.mjs.map +10 -0
  149. package/dist/mjs/internal/console/utils.mjs +30 -0
  150. package/dist/mjs/internal/console/utils.mjs.map +10 -0
  151. package/dist/mjs/internal/core/index.mjs +2681 -0
  152. package/dist/mjs/internal/core/index.mjs.map +10 -0
  153. package/dist/mjs/internal/crypto/index.mjs +406 -0
  154. package/dist/mjs/internal/crypto/index.mjs.map +10 -0
  155. package/dist/mjs/internal/daemon/callback-fs-handler.mjs +315 -0
  156. package/dist/mjs/internal/daemon/callback-fs-handler.mjs.map +10 -0
  157. package/dist/mjs/internal/daemon/connection.mjs +1931 -0
  158. package/dist/mjs/internal/daemon/connection.mjs.map +10 -0
  159. package/dist/mjs/internal/daemon/daemon.mjs +98 -0
  160. package/dist/mjs/internal/daemon/daemon.mjs.map +10 -0
  161. package/dist/mjs/internal/daemon/index.mjs +105 -0
  162. package/dist/mjs/internal/daemon/index.mjs.map +10 -0
  163. package/dist/mjs/internal/daemon/runtime-pool.mjs +66 -0
  164. package/dist/mjs/internal/daemon/runtime-pool.mjs.map +10 -0
  165. package/dist/mjs/internal/daemon/types.mjs +2 -0
  166. package/dist/mjs/internal/daemon/types.mjs.map +9 -0
  167. package/dist/mjs/internal/encoding/index.mjs +379 -0
  168. package/dist/mjs/internal/encoding/index.mjs.map +10 -0
  169. package/dist/mjs/internal/fetch/consistency/origins.mjs +558 -0
  170. package/dist/mjs/internal/fetch/consistency/origins.mjs.map +10 -0
  171. package/dist/mjs/internal/fetch/index.mjs +2580 -0
  172. package/dist/mjs/internal/fetch/index.mjs.map +10 -0
  173. package/dist/mjs/internal/fetch/stream-state.mjs +216 -0
  174. package/dist/mjs/internal/fetch/stream-state.mjs.map +10 -0
  175. package/dist/mjs/internal/fs/index.mjs +783 -0
  176. package/dist/mjs/internal/fs/index.mjs.map +10 -0
  177. package/dist/mjs/internal/fs/node-adapter.mjs +190 -0
  178. package/dist/mjs/internal/fs/node-adapter.mjs.map +10 -0
  179. package/dist/mjs/internal/module-loader/bundle.mjs +418 -0
  180. package/dist/mjs/internal/module-loader/bundle.mjs.map +10 -0
  181. package/dist/mjs/internal/module-loader/index.mjs +185 -0
  182. package/dist/mjs/internal/module-loader/index.mjs.map +10 -0
  183. package/dist/mjs/internal/module-loader/mappings.mjs +80 -0
  184. package/dist/mjs/internal/module-loader/mappings.mjs.map +10 -0
  185. package/dist/mjs/internal/module-loader/resolve.mjs +113 -0
  186. package/dist/mjs/internal/module-loader/resolve.mjs.map +10 -0
  187. package/dist/mjs/internal/module-loader/strip-types.mjs +172 -0
  188. package/dist/mjs/internal/module-loader/strip-types.mjs.map +10 -0
  189. package/dist/mjs/internal/path/index.mjs +463 -0
  190. package/dist/mjs/internal/path/index.mjs.map +10 -0
  191. package/dist/mjs/internal/playwright/client.mjs +13 -0
  192. package/dist/mjs/internal/playwright/client.mjs.map +10 -0
  193. package/dist/mjs/internal/playwright/handler.mjs +1378 -0
  194. package/dist/mjs/internal/playwright/handler.mjs.map +10 -0
  195. package/dist/mjs/internal/playwright/index.mjs +1234 -0
  196. package/dist/mjs/internal/playwright/index.mjs.map +10 -0
  197. package/dist/mjs/internal/playwright/types.mjs +7 -0
  198. package/dist/mjs/internal/playwright/types.mjs.map +10 -0
  199. package/dist/mjs/internal/protocol/codec.mjs +470 -0
  200. package/dist/mjs/internal/protocol/codec.mjs.map +10 -0
  201. package/dist/mjs/internal/protocol/framing.mjs +101 -0
  202. package/dist/mjs/internal/protocol/framing.mjs.map +10 -0
  203. package/dist/mjs/internal/protocol/index.mjs +98 -0
  204. package/dist/mjs/internal/protocol/index.mjs.map +10 -0
  205. package/dist/mjs/internal/protocol/marshalValue.mjs +494 -0
  206. package/dist/mjs/internal/protocol/marshalValue.mjs.map +10 -0
  207. package/dist/mjs/internal/protocol/serialization.mjs +69 -0
  208. package/dist/mjs/internal/protocol/serialization.mjs.map +10 -0
  209. package/dist/mjs/internal/protocol/types.mjs +141 -0
  210. package/dist/mjs/internal/protocol/types.mjs.map +10 -0
  211. package/dist/mjs/internal/runtime/index.mjs +1198 -0
  212. package/dist/mjs/internal/runtime/index.mjs.map +10 -0
  213. package/dist/mjs/internal/server/index.mjs +183 -0
  214. package/dist/mjs/internal/server/index.mjs.map +10 -0
  215. package/dist/mjs/internal/test-environment/index.mjs +1351 -0
  216. package/dist/mjs/internal/test-environment/index.mjs.map +10 -0
  217. package/dist/mjs/internal/timers/index.mjs +136 -0
  218. package/dist/mjs/internal/timers/index.mjs.map +10 -0
  219. package/dist/mjs/internal/transform/index.mjs +321 -0
  220. package/dist/mjs/internal/transform/index.mjs.map +10 -0
  221. package/dist/mjs/internal/typecheck/index.mjs +35 -0
  222. package/dist/mjs/internal/typecheck/index.mjs.map +10 -0
  223. package/dist/mjs/internal/typecheck/isolate-types.mjs +2574 -0
  224. package/dist/mjs/internal/typecheck/isolate-types.mjs.map +10 -0
  225. package/dist/mjs/internal/typecheck/typecheck.mjs +91 -0
  226. package/dist/mjs/internal/typecheck/typecheck.mjs.map +10 -0
  227. package/dist/mjs/modules/index.mjs +96 -0
  228. package/dist/mjs/modules/index.mjs.map +10 -0
  229. package/dist/mjs/package.json +5 -0
  230. package/dist/mjs/runtime/script-runtime.mjs +57 -0
  231. package/dist/mjs/runtime/script-runtime.mjs.map +10 -0
  232. package/dist/mjs/server/app-server.mjs +118 -0
  233. package/dist/mjs/server/app-server.mjs.map +10 -0
  234. package/dist/mjs/testing/integration-helpers.mjs +63 -0
  235. package/dist/mjs/testing/integration-helpers.mjs.map +10 -0
  236. package/dist/mjs/typecheck/index.mjs +56 -0
  237. package/dist/mjs/typecheck/index.mjs.map +10 -0
  238. package/dist/mjs/types.mjs +2 -0
  239. package/dist/mjs/types.mjs.map +9 -0
  240. package/dist/types/bridge/diagnostics.d.ts +12 -0
  241. package/dist/types/bridge/legacy-adapters.d.ts +14 -0
  242. package/dist/types/bridge/request-context.d.ts +10 -0
  243. package/dist/types/bridge/runtime-bindings.d.ts +14 -0
  244. package/dist/types/browser/browser-runtime.d.ts +3 -0
  245. package/dist/types/daemon.d.ts +2 -0
  246. package/dist/types/files/index.d.ts +5 -0
  247. package/dist/types/host/create-isolate-host.d.ts +2 -0
  248. package/dist/types/host/index.d.ts +1 -0
  249. package/dist/types/index.d.ts +5 -0
  250. package/dist/types/internal/client/connection.d.ts +9 -0
  251. package/dist/types/internal/client/index.d.ts +8 -0
  252. package/dist/types/internal/client/types.d.ts +198 -0
  253. package/dist/types/internal/console/index.d.ts +108 -0
  254. package/dist/types/internal/console/utils.d.ts +27 -0
  255. package/dist/types/internal/core/index.d.ts +119 -0
  256. package/dist/types/internal/crypto/index.d.ts +18 -0
  257. package/dist/types/internal/daemon/callback-fs-handler.d.ts +28 -0
  258. package/dist/types/internal/daemon/connection.d.ts +9 -0
  259. package/dist/types/internal/daemon/daemon.d.ts +2 -0
  260. package/dist/types/internal/daemon/index.d.ts +14 -0
  261. package/dist/types/internal/daemon/runtime-pool.d.ts +16 -0
  262. package/dist/types/internal/daemon/types.d.ts +211 -0
  263. package/dist/types/internal/encoding/index.d.ts +21 -0
  264. package/dist/types/internal/fetch/consistency/origins.d.ts +179 -0
  265. package/dist/types/internal/fetch/index.d.ts +93 -0
  266. package/dist/types/internal/fetch/stream-state.d.ts +65 -0
  267. package/dist/types/internal/fs/index.d.ts +70 -0
  268. package/dist/types/internal/fs/node-adapter.d.ts +24 -0
  269. package/dist/types/internal/module-loader/bundle.d.ts +33 -0
  270. package/dist/types/internal/module-loader/index.d.ts +30 -0
  271. package/dist/types/internal/module-loader/mappings.d.ts +47 -0
  272. package/dist/types/internal/module-loader/resolve.d.ts +26 -0
  273. package/dist/types/internal/module-loader/strip-types.d.ts +19 -0
  274. package/dist/types/internal/path/index.d.ts +23 -0
  275. package/dist/types/internal/playwright/client.d.ts +7 -0
  276. package/dist/types/internal/playwright/handler.d.ts +44 -0
  277. package/dist/types/internal/playwright/index.d.ts +14 -0
  278. package/dist/types/internal/playwright/types.d.ts +145 -0
  279. package/dist/types/internal/protocol/codec.d.ts +242 -0
  280. package/dist/types/internal/protocol/framing.d.ts +89 -0
  281. package/dist/types/internal/protocol/index.d.ts +10 -0
  282. package/dist/types/internal/protocol/marshalValue.d.ts +79 -0
  283. package/dist/types/internal/protocol/serialization.d.ts +23 -0
  284. package/dist/types/internal/protocol/types.d.ts +996 -0
  285. package/dist/types/internal/runtime/index.d.ts +200 -0
  286. package/dist/types/internal/server/index.d.ts +42 -0
  287. package/dist/types/internal/test-environment/index.d.ts +112 -0
  288. package/dist/types/internal/timers/index.d.ts +22 -0
  289. package/dist/types/internal/transform/index.d.ts +36 -0
  290. package/dist/types/internal/typecheck/index.d.ts +7 -0
  291. package/dist/types/internal/typecheck/isolate-types.d.ts +94 -0
  292. package/dist/types/internal/typecheck/typecheck.d.ts +148 -0
  293. package/dist/types/modules/index.d.ts +2 -0
  294. package/dist/types/runtime/script-runtime.d.ts +6 -0
  295. package/dist/types/server/app-server.d.ts +3 -0
  296. package/dist/types/testing/integration-helpers.d.ts +9 -0
  297. package/dist/types/typecheck/index.d.ts +8 -0
  298. package/dist/types/types.d.ts +233 -0
  299. package/package.json +82 -6
@@ -0,0 +1,240 @@
1
+ var __create = Object.create;
2
+ var __getProtoOf = Object.getPrototypeOf;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ function __accessProp(key) {
8
+ return this[key];
9
+ }
10
+ var __toESMCache_node;
11
+ var __toESMCache_esm;
12
+ var __toESM = (mod, isNodeMode, target) => {
13
+ var canCache = mod != null && typeof mod === "object";
14
+ if (canCache) {
15
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
+ var cached = cache.get(mod);
17
+ if (cached)
18
+ return cached;
19
+ }
20
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
21
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
+ for (let key of __getOwnPropNames(mod))
23
+ if (!__hasOwnProp.call(to, key))
24
+ __defProp(to, key, {
25
+ get: __accessProp.bind(mod, key),
26
+ enumerable: true
27
+ });
28
+ if (canCache)
29
+ cache.set(mod, to);
30
+ return to;
31
+ };
32
+ var __toCommonJS = (from) => {
33
+ var entry = (__moduleCache ??= new WeakMap).get(from), desc;
34
+ if (entry)
35
+ return entry;
36
+ entry = __defProp({}, "__esModule", { value: true });
37
+ if (from && typeof from === "object" || typeof from === "function") {
38
+ for (var key of __getOwnPropNames(from))
39
+ if (!__hasOwnProp.call(entry, key))
40
+ __defProp(entry, key, {
41
+ get: __accessProp.bind(from, key),
42
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
43
+ });
44
+ }
45
+ __moduleCache.set(from, entry);
46
+ return entry;
47
+ };
48
+ var __moduleCache;
49
+ var __returnValue = (v) => v;
50
+ function __exportSetter(name, newValue) {
51
+ this[name] = __returnValue.bind(null, newValue);
52
+ }
53
+ var __export = (target, all) => {
54
+ for (var name in all)
55
+ __defProp(target, name, {
56
+ get: all[name],
57
+ enumerable: true,
58
+ configurable: true,
59
+ set: __exportSetter.bind(all, name)
60
+ });
61
+ };
62
+
63
+ // src/internal/module-loader/index.ts
64
+ var exports_module_loader = {};
65
+ __export(exports_module_loader, {
66
+ virtualToHost: () => import_mappings2.virtualToHost,
67
+ resolveFilePath: () => import_resolve2.resolveFilePath,
68
+ processTypeScript: () => import_strip_types2.processTypeScript,
69
+ parseSpecifier: () => import_resolve2.parseSpecifier,
70
+ parseMappings: () => import_mappings2.parseMappings,
71
+ isTypeScriptFile: () => import_strip_types2.isTypeScriptFile,
72
+ isBareSpecifier: () => import_resolve2.isBareSpecifier,
73
+ findNodeModulesMapping: () => import_mappings2.findNodeModulesMapping,
74
+ findModuleAlias: () => import_mappings2.findModuleAlias,
75
+ detectFormat: () => import_resolve2.detectFormat,
76
+ defaultModuleLoader: () => defaultModuleLoader,
77
+ clearBundleCache: () => import_bundle2.clearBundleCache,
78
+ bundleSpecifier: () => import_bundle2.bundleSpecifier,
79
+ bundleHostFile: () => import_bundle2.bundleHostFile
80
+ });
81
+ module.exports = __toCommonJS(exports_module_loader);
82
+ var import_node_fs = __toESM(require("node:fs"));
83
+ var import_node_path = __toESM(require("node:path"));
84
+ var import_node_module = require("node:module");
85
+ var import_mappings = require("./mappings.cjs");
86
+ var import_resolve = require("./resolve.cjs");
87
+ var import_bundle = require("./bundle.cjs");
88
+ var import_strip_types = require("./strip-types.cjs");
89
+ var import_mappings2 = require("./mappings.cjs");
90
+ var import_resolve2 = require("./resolve.cjs");
91
+ var import_bundle2 = require("./bundle.cjs");
92
+ var import_strip_types2 = require("./strip-types.cjs");
93
+ function defaultModuleLoader(...paths) {
94
+ const mappings = import_mappings.parseMappings(paths);
95
+ const nodeModulesMapping = import_mappings.findNodeModulesMapping(mappings);
96
+ const importerHostPathByVirtualPath = new Map;
97
+ const loader = async (moduleName, importer) => {
98
+ if (import_resolve.isBareSpecifier(moduleName)) {
99
+ const alias = import_mappings.findModuleAlias(moduleName, mappings);
100
+ if (alias) {
101
+ return handleModuleAlias(alias, importerHostPathByVirtualPath);
102
+ }
103
+ return handleBareSpecifier(moduleName, importer, nodeModulesMapping, mappings, importerHostPathByVirtualPath);
104
+ }
105
+ return handlePathSpecifier(moduleName, importer, mappings, importerHostPathByVirtualPath);
106
+ };
107
+ return loader;
108
+ }
109
+ async function handleBareSpecifier(specifier, importer, nodeModulesMapping, mappings, importerHostPathByVirtualPath) {
110
+ if (!nodeModulesMapping) {
111
+ throw new Error(`Cannot resolve bare specifier "${specifier}": no node_modules mapping configured. ` + `Add a mapping like { from: '/path/to/node_modules', to: '/node_modules' }.`);
112
+ }
113
+ const importerHostPath = resolveImporterHostPath(importer, mappings, importerHostPathByVirtualPath);
114
+ const fallbackImporterHostPath = import_node_path.default.join(import_node_path.default.dirname(nodeModulesMapping.hostBase), "__isolate_module_loader__.js");
115
+ const effectiveImporterHostPath = importerHostPath ?? fallbackImporterHostPath;
116
+ const importerResolutionPath = toRealPath(effectiveImporterHostPath);
117
+ const resolvedHostPath = resolveBareSpecifierWithNode(specifier, importerResolutionPath);
118
+ if (!resolvedHostPath) {
119
+ throw new Error(`Cannot resolve bare specifier "${specifier}" from importer "${importer.path}" ` + `(host importer: ${effectiveImporterHostPath}).`);
120
+ }
121
+ const rootDir = import_node_path.default.dirname(importerResolutionPath);
122
+ const { code } = await import_bundle.bundleSpecifier(specifier, rootDir);
123
+ const { packageName, subpath } = import_resolve.parseSpecifier(specifier);
124
+ const filename = subpath ? `${packageName}${subpath}.bundled.js`.split("/").pop() : `${packageName}.bundled.js`.split("/").pop();
125
+ const result = {
126
+ code,
127
+ filename,
128
+ resolveDir: nodeModulesMapping.virtualMount,
129
+ static: true
130
+ };
131
+ registerImporterHostPath(result, toRealPath(resolvedHostPath), importerHostPathByVirtualPath);
132
+ return result;
133
+ }
134
+ async function handleModuleAlias(alias, importerHostPathByVirtualPath) {
135
+ const { code } = await import_bundle.bundleHostFile(alias.hostBase);
136
+ const filename = alias.to.replace(/^@[^/]*\//, "").replace(/[^a-zA-Z0-9_.-]/g, "-") + ".bundled.js";
137
+ const result = {
138
+ code,
139
+ filename,
140
+ resolveDir: "/"
141
+ };
142
+ registerImporterHostPath(result, toRealPath(alias.hostBase), importerHostPathByVirtualPath);
143
+ return result;
144
+ }
145
+ async function handlePathSpecifier(specifier, importer, mappings, importerHostPathByVirtualPath) {
146
+ let virtualPath;
147
+ if (specifier.startsWith("/")) {
148
+ virtualPath = specifier;
149
+ } else {
150
+ virtualPath = import_node_path.default.posix.normalize(import_node_path.default.posix.join(importer.resolveDir, specifier));
151
+ }
152
+ const hostBasePath = import_mappings.virtualToHost(virtualPath, mappings);
153
+ if (!hostBasePath) {
154
+ throw new Error(`Cannot resolve "${specifier}" (virtual: ${virtualPath}): no mapping matches this path. ` + `Importer: ${importer.path}`);
155
+ }
156
+ const resolvedHostPath = import_resolve.resolveFilePath(hostBasePath);
157
+ if (!resolvedHostPath) {
158
+ throw new Error(`Cannot resolve "${specifier}" (host: ${hostBasePath}): file not found after extension probing. ` + `Importer: ${importer.path}`);
159
+ }
160
+ let code = import_node_fs.default.readFileSync(resolvedHostPath, "utf-8");
161
+ let resolvedFilename = import_node_path.default.basename(resolvedHostPath);
162
+ if (import_strip_types.isTypeScriptFile(resolvedHostPath)) {
163
+ code = import_strip_types.processTypeScript(code, resolvedHostPath);
164
+ resolvedFilename = resolvedFilename.replace(/\.(tsx?|mts|cts)$/, ".js");
165
+ }
166
+ const hostDir = import_node_path.default.dirname(resolvedHostPath);
167
+ let virtualDir = null;
168
+ for (const mapping of mappings) {
169
+ if (mapping.isGlob) {
170
+ if (hostDir === mapping.hostBase || hostDir.startsWith(mapping.hostBase + "/")) {
171
+ const relativePart = hostDir.slice(mapping.hostBase.length);
172
+ virtualDir = mapping.virtualMount + relativePart;
173
+ break;
174
+ }
175
+ } else {
176
+ const mappedHostDir = import_node_path.default.dirname(mapping.hostBase);
177
+ if (hostDir === mappedHostDir) {
178
+ virtualDir = import_node_path.default.posix.dirname(mapping.virtualMount);
179
+ break;
180
+ }
181
+ }
182
+ }
183
+ if (!virtualDir) {
184
+ virtualDir = import_node_path.default.posix.dirname(virtualPath);
185
+ }
186
+ const result = {
187
+ code,
188
+ filename: resolvedFilename,
189
+ resolveDir: virtualDir
190
+ };
191
+ registerImporterHostPath(result, toRealPath(resolvedHostPath), importerHostPathByVirtualPath);
192
+ return result;
193
+ }
194
+ function resolveImporterHostPath(importer, mappings, importerHostPathByVirtualPath) {
195
+ const cached = importerHostPathByVirtualPath.get(importer.path);
196
+ if (cached) {
197
+ return cached;
198
+ }
199
+ const mappedHostPath = import_mappings.virtualToHost(importer.path, mappings);
200
+ if (!mappedHostPath) {
201
+ return null;
202
+ }
203
+ const resolvedMappedPath = import_resolve.resolveFilePath(mappedHostPath);
204
+ if (resolvedMappedPath) {
205
+ return resolvedMappedPath;
206
+ }
207
+ if (exists(mappedHostPath)) {
208
+ return mappedHostPath;
209
+ }
210
+ return null;
211
+ }
212
+ function resolveBareSpecifierWithNode(specifier, importerHostPath) {
213
+ try {
214
+ const req = import_node_module.createRequire(importerHostPath);
215
+ return req.resolve(specifier);
216
+ } catch {
217
+ return null;
218
+ }
219
+ }
220
+ function registerImporterHostPath(moduleResult, hostPath, importerHostPathByVirtualPath) {
221
+ const virtualModulePath = import_node_path.default.posix.join(moduleResult.resolveDir, moduleResult.filename);
222
+ importerHostPathByVirtualPath.set(virtualModulePath, hostPath);
223
+ }
224
+ function toRealPath(inputPath) {
225
+ try {
226
+ return import_node_fs.default.realpathSync(inputPath);
227
+ } catch {
228
+ return inputPath;
229
+ }
230
+ }
231
+ function exists(filePath) {
232
+ try {
233
+ import_node_fs.default.accessSync(filePath);
234
+ return true;
235
+ } catch {
236
+ return false;
237
+ }
238
+ }
239
+
240
+ //# debugId=46F8055BE16B42FB64756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/internal/module-loader/index.ts"],
4
+ "sourcesContent": [
5
+ "import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { createRequire } from \"node:module\";\nimport type {\n ModuleLoaderCallback,\n ModuleLoaderResult,\n} from \"../protocol/index.cjs\";\nimport {\n parseMappings,\n virtualToHost,\n findNodeModulesMapping,\n findModuleAlias,\n type MappingConfig,\n type PathMapping,\n} from \"./mappings.cjs\";\nimport {\n resolveFilePath,\n parseSpecifier,\n isBareSpecifier,\n} from \"./resolve.cjs\";\nimport { bundleSpecifier, bundleHostFile } from \"./bundle.cjs\";\nimport { isTypeScriptFile, processTypeScript } from \"./strip-types.cjs\";\n\nexport { parseMappings, virtualToHost, findNodeModulesMapping, findModuleAlias } from \"./mappings.cjs\";\nexport type { MappingConfig, PathMapping } from \"./mappings.cjs\";\nexport { resolveFilePath, detectFormat, parseSpecifier, isBareSpecifier } from \"./resolve.cjs\";\nexport { bundleSpecifier, bundleHostFile, clearBundleCache } from \"./bundle.cjs\";\nexport { isTypeScriptFile, processTypeScript } from \"./strip-types.cjs\";\n\n/**\n * Create a module loader callback that handles common patterns:\n * - Mapping host filesystem paths to virtual isolate paths\n * - Bundling npm packages with Rollup (ESM-first, browser conditions)\n * - Reading user files directly from the host filesystem\n *\n * Each npm package subpath is bundled independently and cached as static.\n *\n * @example\n * ```typescript\n * import { defaultModuleLoader } from './index.cjs';\n *\n * const loader = defaultModuleLoader(\n * { from: '/host/project/node_modules', to: '/node_modules' },\n * { from: '/host/project/src/entry.ts', to: '/app/entry.ts' }\n * );\n *\n * const runtime = await createRuntime({\n * moduleLoader: loader,\n * });\n * ```\n */\nexport function defaultModuleLoader(\n ...paths: MappingConfig[]\n): ModuleLoaderCallback {\n const mappings = parseMappings(paths);\n const nodeModulesMapping = findNodeModulesMapping(mappings);\n const importerHostPathByVirtualPath = new Map<string, string>();\n\n const loader: ModuleLoaderCallback = async (\n moduleName: string,\n importer: { path: string; resolveDir: string },\n ): Promise<ModuleLoaderResult> => {\n // A. Bare specifiers: module aliases or npm packages\n if (isBareSpecifier(moduleName)) {\n const alias = findModuleAlias(moduleName, mappings);\n if (alias) {\n return handleModuleAlias(alias, importerHostPathByVirtualPath);\n }\n return handleBareSpecifier(\n moduleName,\n importer,\n nodeModulesMapping,\n mappings,\n importerHostPathByVirtualPath,\n );\n }\n\n // B. Relative/absolute paths: user files or intra-package files\n return handlePathSpecifier(\n moduleName,\n importer,\n mappings,\n importerHostPathByVirtualPath,\n );\n };\n\n return loader;\n}\n\n/**\n * Handle bare specifiers (npm packages) by bundling with Rollup.\n */\nasync function handleBareSpecifier(\n specifier: string,\n importer: { path: string; resolveDir: string },\n nodeModulesMapping: PathMapping | undefined,\n mappings: PathMapping[],\n importerHostPathByVirtualPath: Map<string, string>,\n): Promise<ModuleLoaderResult> {\n if (!nodeModulesMapping) {\n throw new Error(\n `Cannot resolve bare specifier \"${specifier}\": no node_modules mapping configured. ` +\n `Add a mapping like { from: '/path/to/node_modules', to: '/node_modules' }.`\n );\n }\n\n const importerHostPath = resolveImporterHostPath(\n importer,\n mappings,\n importerHostPathByVirtualPath,\n );\n const fallbackImporterHostPath = path.join(\n path.dirname(nodeModulesMapping.hostBase),\n \"__isolate_module_loader__.js\",\n );\n const effectiveImporterHostPath = importerHostPath ?? fallbackImporterHostPath;\n const importerResolutionPath = toRealPath(effectiveImporterHostPath);\n const resolvedHostPath = resolveBareSpecifierWithNode(\n specifier,\n importerResolutionPath,\n );\n\n if (!resolvedHostPath) {\n throw new Error(\n `Cannot resolve bare specifier \"${specifier}\" from importer \"${importer.path}\" ` +\n `(host importer: ${effectiveImporterHostPath}).`\n );\n }\n\n const rootDir = path.dirname(importerResolutionPath);\n\n const { code } = await bundleSpecifier(specifier, rootDir);\n\n const { packageName, subpath } = parseSpecifier(specifier);\n const filename = subpath\n ? `${packageName}${subpath}.bundled.js`\n .split(\"/\")\n .pop()!\n : `${packageName}.bundled.js`\n .split(\"/\")\n .pop()!;\n\n const result: ModuleLoaderResult = {\n code,\n filename,\n resolveDir: nodeModulesMapping.virtualMount,\n static: true,\n };\n\n // Keep host importer context so transitive bare imports resolve like Node:\n // from the importing package location (realpath by default).\n registerImporterHostPath(result, toRealPath(resolvedHostPath), importerHostPathByVirtualPath);\n\n return result;\n}\n\n/**\n * Handle module alias specifiers by bundling the host file with Rollup.\n */\nasync function handleModuleAlias(\n alias: PathMapping,\n importerHostPathByVirtualPath: Map<string, string>,\n): Promise<ModuleLoaderResult> {\n const { code } = await bundleHostFile(alias.hostBase);\n\n // Sanitize the alias name into a filename (e.g. \"@/custom-module\" -> \"custom-module.bundled.js\")\n const filename = alias.to\n .replace(/^@[^/]*\\//, \"\") // strip scope prefix\n .replace(/[^a-zA-Z0-9_.-]/g, \"-\") // replace non-safe chars\n + \".bundled.js\";\n\n const result: ModuleLoaderResult = {\n code,\n filename,\n resolveDir: \"/\",\n };\n\n registerImporterHostPath(result, toRealPath(alias.hostBase), importerHostPathByVirtualPath);\n\n return result;\n}\n\n/**\n * Handle relative/absolute path specifiers by resolving to host files.\n */\nasync function handlePathSpecifier(\n specifier: string,\n importer: { path: string; resolveDir: string },\n mappings: PathMapping[],\n importerHostPathByVirtualPath: Map<string, string>,\n): Promise<ModuleLoaderResult> {\n // Resolve virtual path relative to importer's resolveDir\n let virtualPath: string;\n if (specifier.startsWith(\"/\")) {\n virtualPath = specifier;\n } else {\n virtualPath = path.posix.normalize(\n path.posix.join(importer.resolveDir, specifier)\n );\n }\n\n // Map virtual path -> host path\n const hostBasePath = virtualToHost(virtualPath, mappings);\n if (!hostBasePath) {\n throw new Error(\n `Cannot resolve \"${specifier}\" (virtual: ${virtualPath}): no mapping matches this path. ` +\n `Importer: ${importer.path}`\n );\n }\n\n // Probe extensions and index files\n const resolvedHostPath = resolveFilePath(hostBasePath);\n if (!resolvedHostPath) {\n throw new Error(\n `Cannot resolve \"${specifier}\" (host: ${hostBasePath}): file not found after extension probing. ` +\n `Importer: ${importer.path}`\n );\n }\n\n // Read the file\n let code = fs.readFileSync(resolvedHostPath, \"utf-8\");\n\n // Process TypeScript files: strip types, elide unused imports, add placeholders\n let resolvedFilename = path.basename(resolvedHostPath);\n if (isTypeScriptFile(resolvedHostPath)) {\n code = processTypeScript(code, resolvedHostPath);\n // Change extension to .js so V8 treats it as JavaScript\n resolvedFilename = resolvedFilename.replace(/\\.(tsx?|mts|cts)$/, \".js\");\n }\n // The host file may have a different name (due to extension probing), so rebuild virtual path\n const hostDir = path.dirname(resolvedHostPath);\n\n // Map the resolved host directory back to a virtual path for resolveDir\n // We need to find which mapping contains this host path\n let virtualDir: string | null = null;\n for (const mapping of mappings) {\n if (mapping.isGlob) {\n if (hostDir === mapping.hostBase || hostDir.startsWith(mapping.hostBase + \"/\")) {\n const relativePart = hostDir.slice(mapping.hostBase.length);\n virtualDir = mapping.virtualMount + relativePart;\n break;\n }\n } else {\n const mappedHostDir = path.dirname(mapping.hostBase);\n if (hostDir === mappedHostDir) {\n virtualDir = path.posix.dirname(mapping.virtualMount);\n break;\n }\n }\n }\n\n if (!virtualDir) {\n // Fallback: use the importer's resolveDir combined with the specifier's directory\n virtualDir = path.posix.dirname(virtualPath);\n }\n\n const result: ModuleLoaderResult = {\n code,\n filename: resolvedFilename,\n resolveDir: virtualDir,\n // User files are NOT static — they can change between evaluations\n };\n\n registerImporterHostPath(result, toRealPath(resolvedHostPath), importerHostPathByVirtualPath);\n\n return result;\n}\n\nfunction resolveImporterHostPath(\n importer: { path: string; resolveDir: string },\n mappings: PathMapping[],\n importerHostPathByVirtualPath: Map<string, string>,\n): string | null {\n const cached = importerHostPathByVirtualPath.get(importer.path);\n if (cached) {\n return cached;\n }\n\n const mappedHostPath = virtualToHost(importer.path, mappings);\n if (!mappedHostPath) {\n return null;\n }\n\n const resolvedMappedPath = resolveFilePath(mappedHostPath);\n if (resolvedMappedPath) {\n return resolvedMappedPath;\n }\n\n if (exists(mappedHostPath)) {\n return mappedHostPath;\n }\n\n return null;\n}\n\nfunction resolveBareSpecifierWithNode(\n specifier: string,\n importerHostPath: string,\n): string | null {\n try {\n const req = createRequire(importerHostPath);\n return req.resolve(specifier);\n } catch {\n return null;\n }\n}\n\nfunction registerImporterHostPath(\n moduleResult: ModuleLoaderResult,\n hostPath: string,\n importerHostPathByVirtualPath: Map<string, string>,\n): void {\n const virtualModulePath = path.posix.join(\n moduleResult.resolveDir,\n moduleResult.filename,\n );\n importerHostPathByVirtualPath.set(virtualModulePath, hostPath);\n}\n\nfunction toRealPath(inputPath: string): string {\n try {\n return fs.realpathSync(inputPath);\n } catch {\n return inputPath;\n }\n}\n\nfunction exists(filePath: string): boolean {\n try {\n fs.accessSync(filePath);\n return true;\n } catch {\n return false;\n }\n}\n"
6
+ ],
7
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAe,IAAf;AACiB,IAAjB;AAC8B,IAA9B;AAYO,IAPP;AAYO,IAJP;AAKgD,IAAhD;AACoD,IAApD;AAEsF,IAAtF;AAE+E,IAA/E;AACkE,IAAlE;AACoD,IAApD;AAwBO,SAAS,mBAAmB,IAC9B,OACmB;AAAA,EACtB,MAAM,WAAW,8BAAc,KAAK;AAAA,EACpC,MAAM,qBAAqB,uCAAuB,QAAQ;AAAA,EAC1D,MAAM,gCAAgC,IAAI;AAAA,EAE1C,MAAM,SAA+B,OACnC,YACA,aACgC;AAAA,IAEhC,IAAI,+BAAgB,UAAU,GAAG;AAAA,MAC/B,MAAM,QAAQ,gCAAgB,YAAY,QAAQ;AAAA,MAClD,IAAI,OAAO;AAAA,QACT,OAAO,kBAAkB,OAAO,6BAA6B;AAAA,MAC/D;AAAA,MACA,OAAO,oBACL,YACA,UACA,oBACA,UACA,6BACF;AAAA,IACF;AAAA,IAGA,OAAO,oBACL,YACA,UACA,UACA,6BACF;AAAA;AAAA,EAGF,OAAO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B;AAAA,EAC7C,IAAI;AAAA,IACF,OAAO,uBAAG,aAAa,SAAS;AAAA,IAChC,MAAM;AAAA,IACN,OAAO;AAAA;AAAA;AAIX,SAAS,MAAM,CAAC,UAA2B;AAAA,EACzC,IAAI;AAAA,IACF,uBAAG,WAAW,QAAQ;AAAA,IACtB,OAAO;AAAA,IACP,MAAM;AAAA,IACN,OAAO;AAAA;AAAA;",
8
+ "debugId": "46F8055BE16B42FB64756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,120 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropNames = Object.getOwnPropertyNames;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ function __accessProp(key) {
6
+ return this[key];
7
+ }
8
+ var __toCommonJS = (from) => {
9
+ var entry = (__moduleCache ??= new WeakMap).get(from), desc;
10
+ if (entry)
11
+ return entry;
12
+ entry = __defProp({}, "__esModule", { value: true });
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (var key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(entry, key))
16
+ __defProp(entry, key, {
17
+ get: __accessProp.bind(from, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ __moduleCache.set(from, entry);
22
+ return entry;
23
+ };
24
+ var __moduleCache;
25
+ var __returnValue = (v) => v;
26
+ function __exportSetter(name, newValue) {
27
+ this[name] = __returnValue.bind(null, newValue);
28
+ }
29
+ var __export = (target, all) => {
30
+ for (var name in all)
31
+ __defProp(target, name, {
32
+ get: all[name],
33
+ enumerable: true,
34
+ configurable: true,
35
+ set: __exportSetter.bind(all, name)
36
+ });
37
+ };
38
+
39
+ // src/internal/module-loader/mappings.ts
40
+ var exports_mappings = {};
41
+ __export(exports_mappings, {
42
+ virtualToHost: () => virtualToHost,
43
+ parseMappings: () => parseMappings,
44
+ hostToVirtual: () => hostToVirtual,
45
+ findNodeModulesMapping: () => findNodeModulesMapping,
46
+ findModuleAlias: () => findModuleAlias
47
+ });
48
+ module.exports = __toCommonJS(exports_mappings);
49
+ function parseMappings(configs) {
50
+ return configs.map((config) => {
51
+ const isGlob = config.from.includes("*");
52
+ const isModuleAlias = !config.to.startsWith("/");
53
+ if (isModuleAlias && isGlob) {
54
+ throw new Error(`Module alias "${config.to}" cannot use a glob pattern in "from" ("${config.from}"). ` + `Module aliases must map a single host file.`);
55
+ }
56
+ let hostBase;
57
+ if (isGlob) {
58
+ const parts = config.from.split("/");
59
+ const baseSegments = [];
60
+ for (const part of parts) {
61
+ if (part.includes("*"))
62
+ break;
63
+ baseSegments.push(part);
64
+ }
65
+ hostBase = baseSegments.join("/");
66
+ } else {
67
+ hostBase = config.from;
68
+ }
69
+ hostBase = hostBase.replace(/\/+$/, "");
70
+ const virtualMount = isModuleAlias ? config.to : config.to.replace(/\/+$/, "");
71
+ const isNodeModules = hostBase.endsWith("/node_modules") || hostBase === "node_modules";
72
+ return {
73
+ from: config.from,
74
+ to: config.to,
75
+ isGlob,
76
+ hostBase,
77
+ virtualMount,
78
+ isNodeModules,
79
+ isModuleAlias
80
+ };
81
+ });
82
+ }
83
+ function virtualToHost(virtualPath, mappings) {
84
+ for (const mapping of mappings) {
85
+ if (mapping.isGlob) {
86
+ if (virtualPath === mapping.virtualMount || virtualPath.startsWith(mapping.virtualMount + "/")) {
87
+ const relativePart = virtualPath.slice(mapping.virtualMount.length);
88
+ return mapping.hostBase + relativePart;
89
+ }
90
+ } else {
91
+ if (virtualPath === mapping.virtualMount) {
92
+ return mapping.hostBase;
93
+ }
94
+ }
95
+ }
96
+ return null;
97
+ }
98
+ function hostToVirtual(hostPath, mappings) {
99
+ for (const mapping of mappings) {
100
+ if (mapping.isGlob) {
101
+ if (hostPath === mapping.hostBase || hostPath.startsWith(mapping.hostBase + "/")) {
102
+ const relativePart = hostPath.slice(mapping.hostBase.length);
103
+ return mapping.virtualMount + relativePart;
104
+ }
105
+ } else {
106
+ if (hostPath === mapping.hostBase) {
107
+ return mapping.virtualMount;
108
+ }
109
+ }
110
+ }
111
+ return null;
112
+ }
113
+ function findNodeModulesMapping(mappings) {
114
+ return mappings.find((m) => m.isNodeModules);
115
+ }
116
+ function findModuleAlias(specifier, mappings) {
117
+ return mappings.find((m) => m.isModuleAlias && m.to === specifier);
118
+ }
119
+
120
+ //# debugId=EF2971DD05B91B6464756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/internal/module-loader/mappings.ts"],
4
+ "sourcesContent": [
5
+ "import path from \"node:path\";\n\nexport interface PathMapping {\n /** Original 'from' path (host) */\n from: string;\n /** Original 'to' path (virtual) */\n to: string;\n /** Whether this is a glob pattern */\n isGlob: boolean;\n /** For globs: the base path before the glob (host-side) */\n hostBase: string;\n /** For globs: the virtual mount point */\n virtualMount: string;\n /** Whether the host base ends with node_modules */\n isNodeModules: boolean;\n /** Whether this mapping is a module alias (to doesn't start with '/') */\n isModuleAlias: boolean;\n}\n\nexport interface MappingConfig {\n from: string;\n to: string;\n}\n\n/**\n * Parse {from, to} pairs into structured PathMapping objects.\n *\n * - Glob patterns (contain `*`): extract base path before glob -> prefix mapping\n * - Direct file paths (no glob): 1:1 mapping\n * - Node modules detection: if base path ends with `node_modules`, flag as isNodeModules\n */\nexport function parseMappings(configs: MappingConfig[]): PathMapping[] {\n return configs.map((config) => {\n const isGlob = config.from.includes(\"*\");\n const isModuleAlias = !config.to.startsWith(\"/\");\n\n if (isModuleAlias && isGlob) {\n throw new Error(\n `Module alias \"${config.to}\" cannot use a glob pattern in \"from\" (\"${config.from}\"). ` +\n `Module aliases must map a single host file.`\n );\n }\n\n let hostBase: string;\n if (isGlob) {\n // Extract base path before the first glob segment\n const parts = config.from.split(\"/\");\n const baseSegments: string[] = [];\n for (const part of parts) {\n if (part.includes(\"*\")) break;\n baseSegments.push(part);\n }\n hostBase = baseSegments.join(\"/\");\n } else {\n hostBase = config.from;\n }\n\n // Normalize trailing slashes\n hostBase = hostBase.replace(/\\/+$/, \"\");\n const virtualMount = isModuleAlias ? config.to : config.to.replace(/\\/+$/, \"\");\n\n const isNodeModules = hostBase.endsWith(\"/node_modules\") || hostBase === \"node_modules\";\n\n return {\n from: config.from,\n to: config.to,\n isGlob,\n hostBase,\n virtualMount,\n isNodeModules,\n isModuleAlias,\n };\n });\n}\n\n/**\n * Map a virtual path to a host path using the configured mappings.\n * Returns null if no mapping matches.\n */\nexport function virtualToHost(virtualPath: string, mappings: PathMapping[]): string | null {\n for (const mapping of mappings) {\n if (mapping.isGlob) {\n // Prefix matching: virtual path must start with the virtual mount\n if (virtualPath === mapping.virtualMount || virtualPath.startsWith(mapping.virtualMount + \"/\")) {\n const relativePart = virtualPath.slice(mapping.virtualMount.length);\n return mapping.hostBase + relativePart;\n }\n } else {\n // Direct file mapping\n if (virtualPath === mapping.virtualMount) {\n return mapping.hostBase;\n }\n }\n }\n return null;\n}\n\n/**\n * Map a host path to a virtual path using the configured mappings.\n * Returns null if no mapping matches.\n */\nexport function hostToVirtual(hostPath: string, mappings: PathMapping[]): string | null {\n for (const mapping of mappings) {\n if (mapping.isGlob) {\n if (hostPath === mapping.hostBase || hostPath.startsWith(mapping.hostBase + \"/\")) {\n const relativePart = hostPath.slice(mapping.hostBase.length);\n return mapping.virtualMount + relativePart;\n }\n } else {\n if (hostPath === mapping.hostBase) {\n return mapping.virtualMount;\n }\n }\n }\n return null;\n}\n\n/**\n * Find the node_modules mapping (if any).\n */\nexport function findNodeModulesMapping(mappings: PathMapping[]): PathMapping | undefined {\n return mappings.find((m) => m.isNodeModules);\n}\n\n/**\n * Find a module alias mapping that matches the given bare specifier.\n * Returns undefined if no module alias matches.\n */\nexport function findModuleAlias(specifier: string, mappings: PathMapping[]): PathMapping | undefined {\n return mappings.find((m) => m.isModuleAlias && m.to === specifier);\n}\n"
6
+ ],
7
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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W;AAAA,MAC5B;AAAA,IACF,EAAO;AAAA,MAEL,IAAI,gBAAgB,QAAQ,cAAc;AAAA,QACxC,OAAO,QAAQ;AAAA,MACjB;AAAA;AAAA,EAEJ;AAAA,EACA,OAAO;AAAA;AAOF,SAAS,aAAa,CAAC,UAAkB,UAAwC;AAAA,EACtF,WAAW,WAAW,UAAU;AAAA,IAC9B,IAAI,QAAQ,QAAQ;AAAA,MAClB,IAAI,aAAa,QAAQ,YAAY,SAAS,WAAW,QAAQ,WAAW,GAAG,GAAG;AAAA,QAChF,MAAM,eAAe,SAAS,MAAM,QAAQ,SAAS,MAAM;AAAA,QAC3D,OAAO,QAAQ,eAAe;AAAA,MAChC;AAAA,IACF,EAAO;AAAA,MACL,IAAI,aAAa,QAAQ,UAAU;AAAA,QACjC,OAAO,QAAQ;AAAA,MACjB;AAAA;AAAA,EAEJ;AAAA,EACA,OAAO;AAAA;AAMF,SAAS,sBAAsB,CAAC,UAAkD;AAAA,EACvF,OAAO,SAAS,KAAK,CAAC,MAAM,EAAE,aAAa;AAAA;AAOtC,SAAS,eAAe,CAAC,WAAmB,UAAkD;AAAA,EACnG,OAAO,SAAS,KAAK,CAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,SAAS;AAAA;",
8
+ "debugId": "EF2971DD05B91B6464756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,177 @@
1
+ var __create = Object.create;
2
+ var __getProtoOf = Object.getPrototypeOf;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ function __accessProp(key) {
8
+ return this[key];
9
+ }
10
+ var __toESMCache_node;
11
+ var __toESMCache_esm;
12
+ var __toESM = (mod, isNodeMode, target) => {
13
+ var canCache = mod != null && typeof mod === "object";
14
+ if (canCache) {
15
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
+ var cached = cache.get(mod);
17
+ if (cached)
18
+ return cached;
19
+ }
20
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
21
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
+ for (let key of __getOwnPropNames(mod))
23
+ if (!__hasOwnProp.call(to, key))
24
+ __defProp(to, key, {
25
+ get: __accessProp.bind(mod, key),
26
+ enumerable: true
27
+ });
28
+ if (canCache)
29
+ cache.set(mod, to);
30
+ return to;
31
+ };
32
+ var __toCommonJS = (from) => {
33
+ var entry = (__moduleCache ??= new WeakMap).get(from), desc;
34
+ if (entry)
35
+ return entry;
36
+ entry = __defProp({}, "__esModule", { value: true });
37
+ if (from && typeof from === "object" || typeof from === "function") {
38
+ for (var key of __getOwnPropNames(from))
39
+ if (!__hasOwnProp.call(entry, key))
40
+ __defProp(entry, key, {
41
+ get: __accessProp.bind(from, key),
42
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
43
+ });
44
+ }
45
+ __moduleCache.set(from, entry);
46
+ return entry;
47
+ };
48
+ var __moduleCache;
49
+ var __returnValue = (v) => v;
50
+ function __exportSetter(name, newValue) {
51
+ this[name] = __returnValue.bind(null, newValue);
52
+ }
53
+ var __export = (target, all) => {
54
+ for (var name in all)
55
+ __defProp(target, name, {
56
+ get: all[name],
57
+ enumerable: true,
58
+ configurable: true,
59
+ set: __exportSetter.bind(all, name)
60
+ });
61
+ };
62
+
63
+ // src/internal/module-loader/resolve.ts
64
+ var exports_resolve = {};
65
+ __export(exports_resolve, {
66
+ resolveFilePath: () => resolveFilePath,
67
+ parseSpecifier: () => parseSpecifier,
68
+ isBareSpecifier: () => isBareSpecifier,
69
+ detectFormat: () => detectFormat
70
+ });
71
+ module.exports = __toCommonJS(exports_resolve);
72
+ var import_node_fs = __toESM(require("node:fs"));
73
+ var import_node_path = __toESM(require("node:path"));
74
+ var EXTENSIONS = [
75
+ ".tsx",
76
+ ".jsx",
77
+ ".ts",
78
+ ".mjs",
79
+ ".js",
80
+ ".cjs",
81
+ ".json"
82
+ ];
83
+ function resolveFilePath(basePath) {
84
+ if (isFile(basePath))
85
+ return basePath;
86
+ const dir = import_node_path.default.dirname(basePath);
87
+ const ext = import_node_path.default.extname(basePath);
88
+ const nameWithoutExt = import_node_path.default.basename(basePath, ext);
89
+ if (ext) {
90
+ const browserPath = import_node_path.default.join(dir, `${nameWithoutExt}.browser${ext}`);
91
+ if (isFile(browserPath))
92
+ return browserPath;
93
+ return null;
94
+ }
95
+ for (const probeExt of EXTENSIONS) {
96
+ const browserPath = import_node_path.default.join(dir, `${nameWithoutExt}.browser${probeExt}`);
97
+ if (isFile(browserPath))
98
+ return browserPath;
99
+ const probePath = basePath + probeExt;
100
+ if (isFile(probePath))
101
+ return probePath;
102
+ }
103
+ if (isDirectory(basePath)) {
104
+ for (const probeExt of EXTENSIONS) {
105
+ const browserIndex = import_node_path.default.join(basePath, `index.browser${probeExt}`);
106
+ if (isFile(browserIndex))
107
+ return browserIndex;
108
+ const indexPath = import_node_path.default.join(basePath, `index${probeExt}`);
109
+ if (isFile(indexPath))
110
+ return indexPath;
111
+ }
112
+ }
113
+ return null;
114
+ }
115
+ function detectFormat(filePath, code) {
116
+ const ext = import_node_path.default.extname(filePath);
117
+ if (ext === ".json")
118
+ return "json";
119
+ if (ext === ".cjs")
120
+ return "cjs";
121
+ if (ext === ".mjs")
122
+ return "esm";
123
+ if (hasESMSyntax(code))
124
+ return "esm";
125
+ if (hasCJSSyntax(code))
126
+ return "cjs";
127
+ return "esm";
128
+ }
129
+ function hasESMSyntax(code) {
130
+ return /\b(import\s+|export\s+(default\s+|{|const\s|let\s|var\s|function\s|class\s|async\s))/m.test(code);
131
+ }
132
+ function hasCJSSyntax(code) {
133
+ return /\b(module\.exports|exports\.\w+\s*=|require\s*\()/m.test(code);
134
+ }
135
+ function parseSpecifier(specifier) {
136
+ if (specifier.startsWith("@")) {
137
+ const slashIndex2 = specifier.indexOf("/");
138
+ if (slashIndex2 === -1) {
139
+ return { packageName: specifier, subpath: "" };
140
+ }
141
+ const secondSlash = specifier.indexOf("/", slashIndex2 + 1);
142
+ if (secondSlash === -1) {
143
+ return { packageName: specifier, subpath: "" };
144
+ }
145
+ return {
146
+ packageName: specifier.slice(0, secondSlash),
147
+ subpath: specifier.slice(secondSlash)
148
+ };
149
+ }
150
+ const slashIndex = specifier.indexOf("/");
151
+ if (slashIndex === -1) {
152
+ return { packageName: specifier, subpath: "" };
153
+ }
154
+ return {
155
+ packageName: specifier.slice(0, slashIndex),
156
+ subpath: specifier.slice(slashIndex)
157
+ };
158
+ }
159
+ function isBareSpecifier(specifier) {
160
+ return !specifier.startsWith(".") && !specifier.startsWith("/");
161
+ }
162
+ function isFile(p) {
163
+ try {
164
+ return import_node_fs.default.statSync(p).isFile();
165
+ } catch {
166
+ return false;
167
+ }
168
+ }
169
+ function isDirectory(p) {
170
+ try {
171
+ return import_node_fs.default.statSync(p).isDirectory();
172
+ } catch {
173
+ return false;
174
+ }
175
+ }
176
+
177
+ //# debugId=A471F9C1EDA796C564756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/internal/module-loader/resolve.ts"],
4
+ "sourcesContent": [
5
+ "import fs from \"node:fs\";\nimport path from \"node:path\";\n\n/**\n * Extensions to probe for module resolution, in order of priority.\n */\nconst EXTENSIONS = [\n \".tsx\",\n \".jsx\",\n \".ts\",\n \".mjs\",\n \".js\",\n \".cjs\",\n \".json\",\n];\n\n/**\n * Resolve a file path with extension probing, index fallback, and browser variant probing.\n * Returns the resolved absolute path, or null if not found.\n */\nexport function resolveFilePath(basePath: string): string | null {\n // Try exact path first\n if (isFile(basePath)) return basePath;\n\n // Try browser variant (e.g., file.browser.ts before file.ts)\n const dir = path.dirname(basePath);\n const ext = path.extname(basePath);\n const nameWithoutExt = path.basename(basePath, ext);\n\n if (ext) {\n // Has extension — try browser variant\n const browserPath = path.join(dir, `${nameWithoutExt}.browser${ext}`);\n if (isFile(browserPath)) return browserPath;\n\n // Exact extension didn't work and file doesn't exist\n return null;\n }\n\n // No extension — probe extensions\n for (const probeExt of EXTENSIONS) {\n // Try browser variant first\n const browserPath = path.join(dir, `${nameWithoutExt}.browser${probeExt}`);\n if (isFile(browserPath)) return browserPath;\n\n const probePath = basePath + probeExt;\n if (isFile(probePath)) return probePath;\n }\n\n // Try as directory with index file\n if (isDirectory(basePath)) {\n for (const probeExt of EXTENSIONS) {\n const browserIndex = path.join(basePath, `index.browser${probeExt}`);\n if (isFile(browserIndex)) return browserIndex;\n\n const indexPath = path.join(basePath, `index${probeExt}`);\n if (isFile(indexPath)) return indexPath;\n }\n }\n\n return null;\n}\n\n/**\n * Detect the format of a file based on its extension and content.\n */\nexport function detectFormat(filePath: string, code: string): \"cjs\" | \"esm\" | \"json\" {\n const ext = path.extname(filePath);\n\n if (ext === \".json\") return \"json\";\n if (ext === \".cjs\") return \"cjs\";\n if (ext === \".mjs\") return \"esm\";\n\n // Heuristic: check for CJS patterns vs ESM patterns\n if (hasESMSyntax(code)) return \"esm\";\n if (hasCJSSyntax(code)) return \"cjs\";\n\n // Default to ESM\n return \"esm\";\n}\n\n/**\n * Check if code has ES module syntax.\n */\nfunction hasESMSyntax(code: string): boolean {\n // import ... from or export ...\n return /\\b(import\\s+|export\\s+(default\\s+|{|const\\s|let\\s|var\\s|function\\s|class\\s|async\\s))/m.test(code);\n}\n\n/**\n * Check if code has CommonJS syntax.\n */\nfunction hasCJSSyntax(code: string): boolean {\n return /\\b(module\\.exports|exports\\.\\w+\\s*=|require\\s*\\()/m.test(code);\n}\n\n/**\n * Parse a bare specifier into package name and subpath.\n *\n * Examples:\n * \"lodash\" -> { packageName: \"lodash\", subpath: \"\" }\n * \"lodash/chunk\" -> { packageName: \"lodash\", subpath: \"/chunk\" }\n * \"@scope/pkg\" -> { packageName: \"@scope/pkg\", subpath: \"\" }\n * \"@scope/pkg/sub/path\" -> { packageName: \"@scope/pkg\", subpath: \"/sub/path\" }\n */\nexport function parseSpecifier(specifier: string): { packageName: string; subpath: string } {\n if (specifier.startsWith(\"@\")) {\n // Scoped package: @scope/name or @scope/name/subpath\n const slashIndex = specifier.indexOf(\"/\");\n if (slashIndex === -1) {\n return { packageName: specifier, subpath: \"\" };\n }\n const secondSlash = specifier.indexOf(\"/\", slashIndex + 1);\n if (secondSlash === -1) {\n return { packageName: specifier, subpath: \"\" };\n }\n return {\n packageName: specifier.slice(0, secondSlash),\n subpath: specifier.slice(secondSlash),\n };\n }\n\n // Non-scoped: name or name/subpath\n const slashIndex = specifier.indexOf(\"/\");\n if (slashIndex === -1) {\n return { packageName: specifier, subpath: \"\" };\n }\n return {\n packageName: specifier.slice(0, slashIndex),\n subpath: specifier.slice(slashIndex),\n };\n}\n\n/**\n * Check if a specifier is a bare specifier (npm package name, not relative/absolute).\n */\nexport function isBareSpecifier(specifier: string): boolean {\n return !specifier.startsWith(\".\") && !specifier.startsWith(\"/\");\n}\n\nfunction isFile(p: string): boolean {\n try {\n return fs.statSync(p).isFile();\n } catch {\n return false;\n }\n}\n\nfunction isDirectory(p: string): boolean {\n try {\n return fs.statSync(p).isDirectory();\n } catch {\n return false;\n }\n}\n"
6
+ ],
7
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAe,IAAf;AACiB,IAAjB;AAKA,IAAM,aAAa;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAMO,SAAS,eAAe,CAAC,UAAiC;AAAA,EAE/D,IAAI,OAAO,QAAQ;AAAA,IAAG,OAAO;AAAA,EAG7B,MAAM,MAAM,yBAAK,QAAQ,QAAQ;AAAA,EACjC,MAAM,MAAM,yBAAK,QAAQ,QAAQ;AAAA,EACjC,MAAM,iBAAiB,yBAAK,SAAS,UAAU,GAAG;AAAA,EAElD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