@absolutejs/absolute 0.19.0-beta.807 → 0.19.0-beta.809

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 (260) hide show
  1. package/dist/angular/browser.js +9801 -57
  2. package/dist/angular/browser.js.map +246 -4
  3. package/dist/angular/components/core/streamingSlotRegistrar.js +1 -1
  4. package/dist/angular/components/core/streamingSlotRegistry.js +2 -2
  5. package/dist/angular/index.js +14877 -60
  6. package/dist/angular/index.js.map +281 -4
  7. package/dist/angular/server.js +5610 -45
  8. package/dist/angular/server.js.map +51 -3
  9. package/dist/build.js +18092 -45
  10. package/dist/build.js.map +99 -3
  11. package/dist/cli/index.js +317 -86
  12. package/dist/client/index.js +1091 -70
  13. package/dist/client/index.js.map +24 -4
  14. package/dist/core/streamingSlotRegistrar.js +108 -11
  15. package/dist/core/streamingSlotRegistrar.js.map +4 -3
  16. package/dist/core/streamingSlotRegistry.js +169 -7
  17. package/dist/core/streamingSlotRegistry.js.map +5 -3
  18. package/dist/index.js +19957 -547
  19. package/dist/index.js.map +116 -3
  20. package/dist/islands/browser.js +228 -9
  21. package/dist/islands/browser.js.map +9 -4
  22. package/dist/islands/index.js +1908 -17
  23. package/dist/islands/index.js.map +27 -3
  24. package/dist/react/browser.js +328 -12
  25. package/dist/react/browser.js.map +12 -4
  26. package/dist/react/components/index.js +167 -16
  27. package/dist/react/components/index.js.map +6 -3
  28. package/dist/react/hooks/index.js +183 -8
  29. package/dist/react/hooks/index.js.map +7 -3
  30. package/dist/react/index.js +3627 -36
  31. package/dist/react/index.js.map +45 -4
  32. package/dist/react/jsxDevRuntimeCompat.js +61 -2
  33. package/dist/react/jsxDevRuntimeCompat.js.map +2 -2
  34. package/dist/react/server.js +1789 -18
  35. package/dist/react/server.js.map +21 -3
  36. package/dist/src/angular/injectorPatch.d.ts +1 -0
  37. package/dist/src/angular/islands.d.ts +1 -0
  38. package/dist/src/client/hydrators/react.d.ts +3 -0
  39. package/dist/src/client/hydrators/svelte.d.ts +2 -0
  40. package/dist/src/client/hydrators/vue.d.ts +2 -0
  41. package/dist/src/index.d.ts +1 -0
  42. package/dist/svelte/browser.js +247 -12
  43. package/dist/svelte/browser.js.map +10 -3
  44. package/dist/svelte/index.js +3732 -37
  45. package/dist/svelte/index.js.map +47 -4
  46. package/dist/svelte/server.js +2794 -21
  47. package/dist/svelte/server.js.map +27 -3
  48. package/dist/vue/browser.js +348 -12
  49. package/dist/vue/browser.js.map +12 -4
  50. package/dist/vue/components/Image.js +240 -7
  51. package/dist/vue/components/Image.js.map +6 -3
  52. package/dist/vue/components/index.js +544 -11
  53. package/dist/vue/components/index.js.map +9 -3
  54. package/dist/vue/index.js +4212 -52
  55. package/dist/vue/index.js.map +50 -4
  56. package/dist/vue/server.js +1849 -18
  57. package/dist/vue/server.js.map +21 -3
  58. package/package.json +1 -1
  59. package/dist/chunk-0867j0r0.js +0 -136
  60. package/dist/chunk-0867j0r0.js.map +0 -10
  61. package/dist/chunk-102fp7xe.js +0 -63
  62. package/dist/chunk-102fp7xe.js.map +0 -10
  63. package/dist/chunk-11zpfqz6.js +0 -19
  64. package/dist/chunk-11zpfqz6.js.map +0 -10
  65. package/dist/chunk-1rfh7hw9.js +0 -319
  66. package/dist/chunk-1rfh7hw9.js.map +0 -11
  67. package/dist/chunk-1x4fxm57.js +0 -51
  68. package/dist/chunk-1x4fxm57.js.map +0 -9
  69. package/dist/chunk-25v9t56f.js +0 -29
  70. package/dist/chunk-25v9t56f.js.map +0 -11
  71. package/dist/chunk-2f21eenc.js +0 -21
  72. package/dist/chunk-2f21eenc.js.map +0 -10
  73. package/dist/chunk-2ga2znex.js +0 -13
  74. package/dist/chunk-2ga2znex.js.map +0 -9
  75. package/dist/chunk-30yrw0f6.js +0 -33
  76. package/dist/chunk-30yrw0f6.js.map +0 -10
  77. package/dist/chunk-3g91wb4f.js +0 -358
  78. package/dist/chunk-3g91wb4f.js.map +0 -10
  79. package/dist/chunk-3rea1gam.js +0 -4403
  80. package/dist/chunk-3rea1gam.js.map +0 -28
  81. package/dist/chunk-3yjzpcne.js +0 -34
  82. package/dist/chunk-3yjzpcne.js.map +0 -10
  83. package/dist/chunk-41bf6aqt.js +0 -17
  84. package/dist/chunk-41bf6aqt.js.map +0 -9
  85. package/dist/chunk-4d39r92n.js +0 -81
  86. package/dist/chunk-4d39r92n.js.map +0 -10
  87. package/dist/chunk-5003emhv.js +0 -17
  88. package/dist/chunk-5003emhv.js.map +0 -10
  89. package/dist/chunk-5f67rsed.js +0 -466
  90. package/dist/chunk-5f67rsed.js.map +0 -10
  91. package/dist/chunk-5fhp1jap.js +0 -9169
  92. package/dist/chunk-5fhp1jap.js.map +0 -236
  93. package/dist/chunk-629x0yh4.js +0 -20
  94. package/dist/chunk-629x0yh4.js.map +0 -9
  95. package/dist/chunk-6pdj08z3.js +0 -73
  96. package/dist/chunk-6pdj08z3.js.map +0 -12
  97. package/dist/chunk-6qjbrt0k.js +0 -13
  98. package/dist/chunk-6qjbrt0k.js.map +0 -9
  99. package/dist/chunk-6sccb4jr.js +0 -14
  100. package/dist/chunk-6sccb4jr.js.map +0 -9
  101. package/dist/chunk-798spvzv.js +0 -50
  102. package/dist/chunk-798spvzv.js.map +0 -10
  103. package/dist/chunk-7fw6x3js.js +0 -131
  104. package/dist/chunk-7fw6x3js.js.map +0 -11
  105. package/dist/chunk-7kjj42xm.js +0 -11
  106. package/dist/chunk-7kjj42xm.js.map +0 -10
  107. package/dist/chunk-7mtstdqn.js +0 -90
  108. package/dist/chunk-7mtstdqn.js.map +0 -10
  109. package/dist/chunk-851whwc7.js +0 -17
  110. package/dist/chunk-851whwc7.js.map +0 -10
  111. package/dist/chunk-85n68sy6.js +0 -103
  112. package/dist/chunk-85n68sy6.js.map +0 -10
  113. package/dist/chunk-8kcfffry.js +0 -35
  114. package/dist/chunk-8kcfffry.js.map +0 -10
  115. package/dist/chunk-92fsjfpp.js +0 -1731
  116. package/dist/chunk-92fsjfpp.js.map +0 -11
  117. package/dist/chunk-93sqk7be.js +0 -139
  118. package/dist/chunk-93sqk7be.js.map +0 -12
  119. package/dist/chunk-9c5tj4k3.js +0 -130
  120. package/dist/chunk-9c5tj4k3.js.map +0 -10
  121. package/dist/chunk-9j59emg3.js +0 -184
  122. package/dist/chunk-9j59emg3.js.map +0 -11
  123. package/dist/chunk-9ve9jq72.js +0 -203
  124. package/dist/chunk-9ve9jq72.js.map +0 -10
  125. package/dist/chunk-9xrsjeem.js +0 -12
  126. package/dist/chunk-9xrsjeem.js.map +0 -9
  127. package/dist/chunk-a9mvyp04.js +0 -87
  128. package/dist/chunk-a9mvyp04.js.map +0 -10
  129. package/dist/chunk-b3gbnrwe.js +0 -21
  130. package/dist/chunk-b3gbnrwe.js.map +0 -10
  131. package/dist/chunk-bgb8k1qs.js +0 -672
  132. package/dist/chunk-bgb8k1qs.js.map +0 -15
  133. package/dist/chunk-bmgqm774.js +0 -65
  134. package/dist/chunk-bmgqm774.js.map +0 -9
  135. package/dist/chunk-bxfghpma.js +0 -69
  136. package/dist/chunk-bxfghpma.js.map +0 -10
  137. package/dist/chunk-c1jfjnka.js +0 -74
  138. package/dist/chunk-c1jfjnka.js.map +0 -10
  139. package/dist/chunk-cbkrwmvh.js +0 -80
  140. package/dist/chunk-cbkrwmvh.js.map +0 -10
  141. package/dist/chunk-cdxd7sy2.js +0 -71
  142. package/dist/chunk-cdxd7sy2.js.map +0 -10
  143. package/dist/chunk-cg95827x.js +0 -21
  144. package/dist/chunk-cg95827x.js.map +0 -10
  145. package/dist/chunk-cm0g4q6w.js +0 -149
  146. package/dist/chunk-cm0g4q6w.js.map +0 -10
  147. package/dist/chunk-d7mwkzry.js +0 -261
  148. package/dist/chunk-d7mwkzry.js.map +0 -10
  149. package/dist/chunk-d9c0am65.js +0 -12
  150. package/dist/chunk-d9c0am65.js.map +0 -10
  151. package/dist/chunk-daqghmg8.js +0 -12
  152. package/dist/chunk-daqghmg8.js.map +0 -9
  153. package/dist/chunk-e3r9fxaa.js +0 -149
  154. package/dist/chunk-e3r9fxaa.js.map +0 -10
  155. package/dist/chunk-e8eecyrq.js +0 -244
  156. package/dist/chunk-e8eecyrq.js.map +0 -10
  157. package/dist/chunk-ex2hxe0v.js +0 -160
  158. package/dist/chunk-ex2hxe0v.js.map +0 -11
  159. package/dist/chunk-fak944et.js +0 -91
  160. package/dist/chunk-fak944et.js.map +0 -10
  161. package/dist/chunk-fygx2ymm.js +0 -118
  162. package/dist/chunk-fygx2ymm.js.map +0 -12
  163. package/dist/chunk-g15qj669.js +0 -271
  164. package/dist/chunk-g15qj669.js.map +0 -11
  165. package/dist/chunk-gd6wmknh.js +0 -121
  166. package/dist/chunk-gd6wmknh.js.map +0 -11
  167. package/dist/chunk-gf0ygptk.js +0 -85
  168. package/dist/chunk-gf0ygptk.js.map +0 -11
  169. package/dist/chunk-gytkmthr.js +0 -220
  170. package/dist/chunk-gytkmthr.js.map +0 -10
  171. package/dist/chunk-h5bbfn3n.js +0 -28
  172. package/dist/chunk-h5bbfn3n.js.map +0 -11
  173. package/dist/chunk-h6mye9r3.js +0 -93
  174. package/dist/chunk-h6mye9r3.js.map +0 -10
  175. package/dist/chunk-hcsmxw1v.js +0 -85
  176. package/dist/chunk-hcsmxw1v.js.map +0 -10
  177. package/dist/chunk-hyjs4bqs.js +0 -8
  178. package/dist/chunk-hyjs4bqs.js.map +0 -10
  179. package/dist/chunk-jn91vzkh.js +0 -66
  180. package/dist/chunk-jn91vzkh.js.map +0 -10
  181. package/dist/chunk-jpkjdgsk.js +0 -167
  182. package/dist/chunk-jpkjdgsk.js.map +0 -11
  183. package/dist/chunk-jwxt8gnp.js +0 -13
  184. package/dist/chunk-jwxt8gnp.js.map +0 -9
  185. package/dist/chunk-kk8w9rh5.js +0 -195
  186. package/dist/chunk-kk8w9rh5.js.map +0 -10
  187. package/dist/chunk-kwgh8rmg.js +0 -426
  188. package/dist/chunk-kwgh8rmg.js.map +0 -14
  189. package/dist/chunk-m97ze5hz.js +0 -46
  190. package/dist/chunk-m97ze5hz.js.map +0 -10
  191. package/dist/chunk-mbazhahf.js +0 -60
  192. package/dist/chunk-mbazhahf.js.map +0 -10
  193. package/dist/chunk-mgfwq18r.js +0 -15
  194. package/dist/chunk-mgfwq18r.js.map +0 -9
  195. package/dist/chunk-mtgf69xn.js +0 -88
  196. package/dist/chunk-mtgf69xn.js.map +0 -10
  197. package/dist/chunk-mtxzyxpg.js +0 -102
  198. package/dist/chunk-mtxzyxpg.js.map +0 -10
  199. package/dist/chunk-nehhtthw.js +0 -225
  200. package/dist/chunk-nehhtthw.js.map +0 -10
  201. package/dist/chunk-p5504p14.js +0 -16
  202. package/dist/chunk-p5504p14.js.map +0 -10
  203. package/dist/chunk-p5zgj77m.js +0 -184
  204. package/dist/chunk-p5zgj77m.js.map +0 -10
  205. package/dist/chunk-pnscgw95.js +0 -90
  206. package/dist/chunk-pnscgw95.js.map +0 -10
  207. package/dist/chunk-pvpp4pvs.js +0 -17
  208. package/dist/chunk-pvpp4pvs.js.map +0 -10
  209. package/dist/chunk-qh75agse.js +0 -95
  210. package/dist/chunk-qh75agse.js.map +0 -10
  211. package/dist/chunk-qxq2zcty.js +0 -52
  212. package/dist/chunk-qxq2zcty.js.map +0 -10
  213. package/dist/chunk-r6e8pytx.js +0 -22
  214. package/dist/chunk-r6e8pytx.js.map +0 -9
  215. package/dist/chunk-r7jmgqnw.js +0 -114
  216. package/dist/chunk-r7jmgqnw.js.map +0 -10
  217. package/dist/chunk-s6defjk2.js +0 -116
  218. package/dist/chunk-s6defjk2.js.map +0 -10
  219. package/dist/chunk-sd39p726.js +0 -619
  220. package/dist/chunk-sd39p726.js.map +0 -10
  221. package/dist/chunk-swrnzs4c.js +0 -63
  222. package/dist/chunk-swrnzs4c.js.map +0 -10
  223. package/dist/chunk-tfe3sb44.js +0 -33
  224. package/dist/chunk-tfe3sb44.js.map +0 -10
  225. package/dist/chunk-tjr0kcev.js +0 -41
  226. package/dist/chunk-tjr0kcev.js.map +0 -9
  227. package/dist/chunk-tx9edm1x.js +0 -34
  228. package/dist/chunk-tx9edm1x.js.map +0 -10
  229. package/dist/chunk-txhm2vb5.js +0 -18
  230. package/dist/chunk-txhm2vb5.js.map +0 -9
  231. package/dist/chunk-v5vmsxmy.js +0 -526
  232. package/dist/chunk-v5vmsxmy.js.map +0 -12
  233. package/dist/chunk-vjhxm8n2.js +0 -29
  234. package/dist/chunk-vjhxm8n2.js.map +0 -9
  235. package/dist/chunk-vkrpm7kc.js +0 -247
  236. package/dist/chunk-vkrpm7kc.js.map +0 -12
  237. package/dist/chunk-w3m4m5we.js +0 -4925
  238. package/dist/chunk-w3m4m5we.js.map +0 -12
  239. package/dist/chunk-wrxtn9ve.js +0 -18
  240. package/dist/chunk-wrxtn9ve.js.map +0 -10
  241. package/dist/chunk-x09cskqd.js +0 -377
  242. package/dist/chunk-x09cskqd.js.map +0 -10
  243. package/dist/chunk-xnt8c6h2.js +0 -576
  244. package/dist/chunk-xnt8c6h2.js.map +0 -10
  245. package/dist/chunk-xw0tx842.js +0 -13
  246. package/dist/chunk-xw0tx842.js.map +0 -9
  247. package/dist/chunk-xx5b6b9m.js +0 -69
  248. package/dist/chunk-xx5b6b9m.js.map +0 -10
  249. package/dist/chunk-xz1kdswj.js +0 -21
  250. package/dist/chunk-xz1kdswj.js.map +0 -9
  251. package/dist/chunk-y84qnsd3.js +0 -32
  252. package/dist/chunk-y84qnsd3.js.map +0 -10
  253. package/dist/chunk-ywjn0rad.js +0 -14
  254. package/dist/chunk-ywjn0rad.js.map +0 -9
  255. package/dist/chunk-z9nvhm6r.js +0 -13
  256. package/dist/chunk-z9nvhm6r.js.map +0 -9
  257. package/dist/chunk-zhmvdpk6.js +0 -15
  258. package/dist/chunk-zhmvdpk6.js.map +0 -9
  259. package/dist/chunk-zrg9d4zw.js +0 -784
  260. package/dist/chunk-zrg9d4zw.js.map +0 -10
@@ -1,784 +0,0 @@
1
- // @bun
2
- import {
3
- getInvalidationVersion,
4
- getTransformed,
5
- invalidate,
6
- setTransformed
7
- } from "./chunk-swrnzs4c.js";
8
- import {
9
- buildIslandMetadataExports
10
- } from "./chunk-a9mvyp04.js";
11
- import {
12
- lowerSvelteAwaitSlotSyntax,
13
- lowerSvelteIslandSyntax
14
- } from "./chunk-7fw6x3js.js";
15
- import {
16
- resolvePackageImport
17
- } from "./chunk-mbazhahf.js";
18
- import {
19
- compileStyleSource,
20
- createSvelteStylePreprocessor
21
- } from "./chunk-xnt8c6h2.js";
22
- import {
23
- BASE_36_RADIX,
24
- UNFOUND_INDEX
25
- } from "./chunk-qh75agse.js";
26
- import {
27
- __require
28
- } from "./chunk-bmgqm774.js";
29
-
30
- // src/dev/moduleServer.ts
31
- import { existsSync, readFileSync, statSync } from "fs";
32
- import { basename, dirname, extname, resolve, relative } from "path";
33
- var SRC_PREFIX = "/@src/";
34
- var jsTranspiler = new Bun.Transpiler({
35
- loader: "js",
36
- trimUnusedImports: true
37
- });
38
- var tsTranspiler = new Bun.Transpiler({
39
- loader: "ts",
40
- trimUnusedImports: true
41
- });
42
- var tsxTranspiler = new Bun.Transpiler({
43
- loader: "tsx",
44
- trimUnusedImports: true
45
- });
46
- var TRANSPILABLE = new Set([".ts", ".tsx", ".js", ".jsx", ".mjs"]);
47
- var ALL_EXPORTS_RE = /export\s+(?:type|interface|const|let|var|function|class|enum|abstract\s+class)\s+(\w+)/g;
48
- var STRING_CONTENTS_RE = /`(?:[^`\\]|\\.)*`|'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/gs;
49
- var preserveTypeExports = (originalSource, transpiled, valueExports) => {
50
- const codeOnly = originalSource.replace(STRING_CONTENTS_RE, '""');
51
- const allExports = [];
52
- let match;
53
- ALL_EXPORTS_RE.lastIndex = 0;
54
- while ((match = ALL_EXPORTS_RE.exec(codeOnly)) !== null) {
55
- if (match[1])
56
- allExports.push(match[1]);
57
- }
58
- const valueSet = new Set(valueExports);
59
- const typeExports = allExports.filter((exp) => !valueSet.has(exp));
60
- if (typeExports.length === 0)
61
- return transpiled;
62
- const stubs = typeExports.map((name) => `export const ${name} = undefined;`).join(`
63
- `);
64
- return `${transpiled}
65
- ${stubs}
66
- `;
67
- };
68
- var resolveRelativeExtension = (srcPath, projectRoot, extensions) => {
69
- const found = extensions.find((ext) => existsSync(resolve(projectRoot, srcPath + ext)));
70
- return found ? srcPath + found : srcPath;
71
- };
72
- var IMPORT_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js", ".svelte", ".vue"];
73
- var SIDE_EFFECT_EXTENSIONS = [
74
- ".tsx",
75
- ".ts",
76
- ".jsx",
77
- ".js",
78
- ".css",
79
- ".svelte",
80
- ".vue"
81
- ];
82
- var MODULE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js", ".svelte", ".vue"];
83
- var RESOLVED_MODULE_EXTENSIONS = new Set([
84
- ...IMPORT_EXTENSIONS,
85
- ...SIDE_EFFECT_EXTENSIONS,
86
- ".mjs",
87
- ".css"
88
- ]);
89
- var REACT_EXTENSIONS = new Set([".tsx", ".jsx"]);
90
- var escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
91
- var buildImportRewriter = (vendorPaths) => {
92
- const entries = Object.entries(vendorPaths).sort(([a], [b]) => b.length - a.length);
93
- if (entries.length === 0)
94
- return null;
95
- const alt = entries.map(([spec]) => escapeRegex(spec)).join("|");
96
- const lookup = new Map(entries);
97
- const vendorRegex = new RegExp(`((?:from|import)\\s*["']|import\\s*\\(\\s*["'])(${alt})(["'](?:\\s*[;)]?)?)`, "g");
98
- return { lookup, vendorRegex };
99
- };
100
- var mtimeCache = new Map;
101
- var buildVersion = (mtime, absPath) => {
102
- const invalidationVersion = getInvalidationVersion(absPath);
103
- return invalidationVersion > 0 ? `${mtime}.${invalidationVersion}` : `${mtime}`;
104
- };
105
- var srcUrl = (relPath, projectRoot) => {
106
- const base = `${SRC_PREFIX}${relPath.replace(/\\/g, "/")}`;
107
- const absPath = resolve(projectRoot, relPath);
108
- const cached = mtimeCache.get(absPath);
109
- if (cached !== undefined)
110
- return `${base}?v=${buildVersion(cached, absPath)}`;
111
- try {
112
- const mtime = Math.round(statSync(absPath).mtimeMs);
113
- mtimeCache.set(absPath, mtime);
114
- return `${base}?v=${buildVersion(mtime, absPath)}`;
115
- } catch {
116
- return base;
117
- }
118
- };
119
- var resolveRelativeImport = (relPath, fileDir, projectRoot, extensions) => {
120
- const absPath = resolve(fileDir, relPath);
121
- const rel = relative(projectRoot, absPath);
122
- const extension = extname(rel);
123
- let srcPath = RESOLVED_MODULE_EXTENSIONS.has(extension) ? rel : resolveRelativeExtension(rel, projectRoot, extensions);
124
- if (extname(srcPath) === ".svelte") {
125
- srcPath = relative(projectRoot, resolveSvelteModulePath(resolve(projectRoot, srcPath)));
126
- }
127
- return srcUrl(srcPath, projectRoot);
128
- };
129
- var resolveAbsoluteSpecifier = (specifier, projectRoot) => {
130
- try {
131
- const target = resolvePackageImport(specifier, ["browser", "import"]) ?? Bun.resolveSync(specifier, projectRoot);
132
- return relative(projectRoot, target);
133
- } catch {
134
- return;
135
- }
136
- };
137
- var rewriteImports = (code, filePath, projectRoot, rewriter) => {
138
- let result = code;
139
- const vendorReplace = (_match, prefix, specifier, suffix) => {
140
- const webPath = rewriter?.lookup.get(specifier);
141
- return webPath ? `${prefix}${webPath}${suffix}` : _match;
142
- };
143
- if (rewriter) {
144
- rewriter.vendorRegex.lastIndex = 0;
145
- result = result.replace(rewriter.vendorRegex, vendorReplace);
146
- }
147
- const stubReplace = (_match, prefix, specifier, suffix) => {
148
- if (specifier.startsWith("/") || specifier.startsWith("."))
149
- return _match;
150
- if (!specifier.startsWith("@absolutejs/"))
151
- return `${prefix}/@stub/${encodeURIComponent(specifier)}${suffix}`;
152
- const resolved = resolveAbsoluteSpecifier(specifier, projectRoot);
153
- if (resolved) {
154
- return `${prefix}${srcUrl(resolved, projectRoot)}${suffix}`;
155
- }
156
- return `${prefix}/@stub/${encodeURIComponent(specifier)}${suffix}`;
157
- };
158
- result = result.replace(/^((?:import\s+[\s\S]+?\s+from|export\s+[\s\S]+?\s+from|import)\s*["'])([^"'./][^"']*)(["'])/gm, stubReplace);
159
- result = result.replace(/(import\s*\(\s*["'])([^"'./][^"']*)(["']\s*\))/g, stubReplace);
160
- const fileDir = dirname(filePath);
161
- result = result.replace(/(from\s*["'])(\.\.?\/[^"']+)(["'])/g, (_match, prefix, relPath, suffix) => `${prefix}${resolveRelativeImport(relPath, fileDir, projectRoot, IMPORT_EXTENSIONS)}${suffix}`);
162
- result = result.replace(/(import\s*\(\s*["'])(\.\.?\/[^"']+)(["']\s*\))/g, (_match, prefix, relPath, suffix) => `${prefix}${resolveRelativeImport(relPath, fileDir, projectRoot, IMPORT_EXTENSIONS)}${suffix}`);
163
- result = result.replace(/(import\s*["'])(\.\.?\/[^"']+)(["']\s*;?)/g, (_match, prefix, relPath, suffix) => `${prefix}${resolveRelativeImport(relPath, fileDir, projectRoot, SIDE_EFFECT_EXTENSIONS)}${suffix}`);
164
- result = result.replace(/((?:from|import)\s*["'])(\/[^"']+\.(tsx?|jsx?|ts))(["'])/g, (_match, prefix, absPath, _ext, suffix) => {
165
- if (absPath.startsWith(projectRoot)) {
166
- const rel2 = relative(projectRoot, absPath).replace(/\\/g, "/");
167
- return `${prefix}${srcUrl(rel2, projectRoot)}${suffix}`;
168
- }
169
- const rel = relative(projectRoot, absPath).replace(/\\/g, "/");
170
- return `${prefix}${srcUrl(rel, projectRoot)}${suffix}`;
171
- });
172
- result = result.replace(/new\s+URL\(\s*["'](\.\.?\/[^"']+)["']\s*,\s*import\.meta\.url\s*\)/g, (_match, relPath) => {
173
- const absPath = resolve(fileDir, relPath);
174
- const rel = relative(projectRoot, absPath);
175
- return `new URL('${srcUrl(rel, projectRoot)}', import.meta.url)`;
176
- });
177
- result = result.replace(/import\.meta\.resolve\(\s*["'](\.\.?\/[^"']+)["']\s*\)/g, (_match, relPath) => {
178
- const absPath = resolve(fileDir, relPath);
179
- const rel = relative(projectRoot, absPath);
180
- return `'${srcUrl(rel, projectRoot)}'`;
181
- });
182
- return result;
183
- };
184
- var JSX_AUTO_RE = /\b(jsxDEV_[a-z0-9]+)\b/;
185
- var JSXS_AUTO_RE = /\b(jsxs_[a-z0-9]+)\b/;
186
- var JSX_PROD_RE = /\b(jsx_[a-z0-9]+)\b/;
187
- var FRAGMENT_RE = /\b(Fragment_[a-z0-9]+)\b/;
188
- var addJsxImport = (code) => {
189
- const imports = [];
190
- const jsxDevMatch = JSX_AUTO_RE.exec(code);
191
- if (jsxDevMatch) {
192
- imports.push(`import { jsxDEV as ${jsxDevMatch[1]} } from "react/jsx-dev-runtime";`);
193
- }
194
- const jsxsMatch = JSXS_AUTO_RE.exec(code);
195
- if (jsxsMatch && (!jsxDevMatch || jsxsMatch[1] !== jsxDevMatch[1])) {
196
- imports.push(`import { jsxs as ${jsxsMatch[1]} } from "react/jsx-runtime";`);
197
- }
198
- const jsxProdMatch = JSX_PROD_RE.exec(code);
199
- if (jsxProdMatch) {
200
- imports.push(`import { jsx as ${jsxProdMatch[1]} } from "react/jsx-runtime";`);
201
- }
202
- const fragmentMatch = FRAGMENT_RE.exec(code);
203
- if (fragmentMatch) {
204
- imports.push(`import { Fragment as ${fragmentMatch[1]} } from "react";`);
205
- }
206
- if (imports.length === 0)
207
- return code;
208
- return `${imports.join(`
209
- `)}
210
- ${code}`;
211
- };
212
- var reactTranspilerOptions = {
213
- loader: "tsx",
214
- reactFastRefresh: true,
215
- trimUnusedImports: true
216
- };
217
- var reactTranspiler = new Bun.Transpiler(reactTranspilerOptions);
218
- var transformReactFile = (filePath, projectRoot, rewriter) => {
219
- const raw = readFileSync(filePath, "utf-8");
220
- const valueExports = tsxTranspiler.scan(raw).exports;
221
- let transpiled = reactTranspiler.transformSync(raw);
222
- transpiled = preserveTypeExports(raw, transpiled, valueExports);
223
- transpiled = addJsxImport(transpiled);
224
- transpiled = transpiled.replace(/import\s*\{[^}]*\}\s*from\s*["']react-refresh\/runtime["'];?\n?/, "");
225
- transpiled = transpiled.replace(/\$RefreshReg\$_[a-z0-9]+/g, "$RefreshReg$");
226
- transpiled = transpiled.replace(/\$RefreshSig\$_[a-z0-9]+/g, "$RefreshSig$");
227
- transpiled = `var $RefreshReg$ = window.$RefreshReg$ || function(){};
228
- ` + `var $RefreshSig$ = window.$RefreshSig$ || function(){ return function(t){ return t; }; };
229
- ${transpiled}`;
230
- const relPath = relative(projectRoot, filePath).replace(/\\/g, "/");
231
- transpiled = transpiled.replace(/\binput\.tsx:/g, `${relPath}:`);
232
- transpiled += buildIslandMetadataExports(raw);
233
- return rewriteImports(transpiled, filePath, projectRoot, rewriter);
234
- };
235
- var transformPlainFile = (filePath, projectRoot, rewriter, vueDir) => {
236
- const raw = readFileSync(filePath, "utf-8");
237
- const ext = extname(filePath);
238
- const isTS = ext === ".ts" || ext === ".tsx";
239
- const isTSX = ext === ".tsx" || ext === ".jsx";
240
- let transpiler = jsTranspiler;
241
- if (isTSX)
242
- transpiler = tsxTranspiler;
243
- else if (isTS)
244
- transpiler = tsTranspiler;
245
- const valueExports = isTS ? transpiler.scan(raw).exports : [];
246
- let transpiled = transpiler.transformSync(raw);
247
- if (isTS) {
248
- transpiled = preserveTypeExports(raw, transpiled, valueExports);
249
- }
250
- transpiled = rewriteImports(transpiled, filePath, projectRoot, rewriter);
251
- if (!vueDir || !filePath.startsWith(vueDir) || !isTS)
252
- return transpiled;
253
- const useExports = valueExports.filter((e) => e.startsWith("use"));
254
- if (useExports.length === 0)
255
- return transpiled;
256
- return injectComposableTracking(transpiled, filePath, useExports);
257
- };
258
- var classifyChar = (char, prevChar, inString) => {
259
- if (inString) {
260
- const closed = char === inString && prevChar !== "\\";
261
- return { nextString: closed ? false : inString, skip: true };
262
- }
263
- if (char === '"' || char === "'" || char === "`")
264
- return { nextString: char, skip: true };
265
- return { nextString: false, skip: false };
266
- };
267
- var findFunctionEnd = (source, startPos) => {
268
- let depth = 0;
269
- let inString = false;
270
- for (let idx = startPos;idx < source.length; idx++) {
271
- const char = source[idx] ?? "";
272
- const classified = classifyChar(char, source[idx - 1] ?? "", inString);
273
- inString = classified.nextString;
274
- if (classified.skip)
275
- continue;
276
- if (char === "{" || char === "(")
277
- depth++;
278
- if (char === "}" || char === ")")
279
- depth--;
280
- if (depth === 0 && char === ";")
281
- return idx;
282
- }
283
- return startPos;
284
- };
285
- var injectComposableTracking = (code, filePath, useExports) => {
286
- const moduleId = JSON.stringify(filePath);
287
- const runtime = [
288
- `var __hmr_cs = (globalThis.__HMR_COMPOSABLE_STATE__ ??= {});`,
289
- `var __hmr_mid = ${moduleId};`,
290
- `var __hmr_prev_refs = __hmr_cs[__hmr_mid];`,
291
- `var __hmr_idx = {};`,
292
- `__hmr_cs[__hmr_mid] = {};`,
293
- `function __hmr_wrap(name, fn) {`,
294
- ` return function() {`,
295
- ` var idx = (__hmr_idx[name] = (__hmr_idx[name] ?? -1) + 1);`,
296
- ` var result = fn.apply(this, arguments);`,
297
- ` if (result && typeof result === "object") {`,
298
- ` var refs = {};`,
299
- ` for (var k in result) {`,
300
- ` var v = result[k];`,
301
- ` if (v && typeof v === "object" && "value" in v && !v.effect && typeof v.value !== "function") {`,
302
- ` refs[k] = v;`,
303
- ` }`,
304
- ` }`,
305
- ` (__hmr_cs[__hmr_mid][name] ??= [])[idx] = refs;`,
306
- ` if (__hmr_prev_refs && __hmr_prev_refs[name] && __hmr_prev_refs[name][idx]) {`,
307
- ` var old = __hmr_prev_refs[name][idx];`,
308
- ` for (var k in old) {`,
309
- ` var nv = result[k];`,
310
- ` var ov = old[k];`,
311
- ` if (nv && ov && typeof nv === "object" && "value" in nv && !nv.effect && typeof nv.value === typeof ov.value) {`,
312
- ` nv.value = ov.value;`,
313
- ` }`,
314
- ` }`,
315
- ` }`,
316
- ` }`,
317
- ` return result;`,
318
- ` };`,
319
- `}`
320
- ].join(`
321
- `);
322
- let result = `${runtime}
323
- ${code}`;
324
- for (const name of useExports) {
325
- result = wrapComposableExport(result, name);
326
- }
327
- return result;
328
- };
329
- var wrapComposableExport = (source, name) => {
330
- const marker = new RegExp(`export\\s+(?:const|var|let)\\s+${name}\\s*=\\s*`);
331
- const match = marker.exec(source);
332
- if (!match)
333
- return source;
334
- const insertPos = match.index + match[0].length;
335
- const endPos = findFunctionEnd(source, insertPos);
336
- const funcBody = source.slice(insertPos, endPos);
337
- return `${source.slice(0, insertPos)}__hmr_wrap(${JSON.stringify(name)}, ${funcBody})${source.slice(endPos)}`;
338
- };
339
- var svelteExternalCss = new Map;
340
- var svelteCompiler = null;
341
- var vueCompiler = null;
342
- var getLoadedSvelteCompiler = () => {
343
- if (!svelteCompiler)
344
- throw new Error("Svelte compiler is not loaded.");
345
- return svelteCompiler;
346
- };
347
- var getLoadedVueCompiler = () => {
348
- if (!vueCompiler)
349
- throw new Error("Vue compiler is not loaded.");
350
- return vueCompiler;
351
- };
352
- var warmCompilers = async (frameworks) => {
353
- const [svelteModule, vueModule] = await Promise.all([
354
- frameworks.svelte ? import("svelte/compiler") : undefined,
355
- frameworks.vue ? import("@vue/compiler-sfc") : undefined
356
- ]);
357
- if (svelteModule) {
358
- svelteCompiler = svelteModule;
359
- svelteModule.compile("<script>let x=$state(0)</script>{x}", {
360
- css: "external",
361
- dev: true,
362
- filename: "_warm.svelte",
363
- generate: "client",
364
- hmr: true
365
- });
366
- }
367
- if (!vueModule)
368
- return;
369
- vueCompiler = vueModule;
370
- const { descriptor } = vueModule.parse("<script setup>const x=1</script><template>{{x}}</template>", { filename: "_warm.vue" });
371
- vueModule.compileScript(descriptor, { id: "w", inlineTemplate: false });
372
- if (!descriptor.template)
373
- return;
374
- vueModule.compileTemplate({
375
- filename: "_warm.vue",
376
- id: "w",
377
- source: descriptor.template.content
378
- });
379
- };
380
- var compileSvelteModule = (raw, filePath) => {
381
- const compiler = getLoadedSvelteCompiler();
382
- const source = tsTranspiler.transformSync(raw);
383
- return compiler.compileModule(source, {
384
- dev: true,
385
- filename: filePath
386
- }).js.code;
387
- };
388
- var compileSvelteComponent = (raw, filePath, projectRoot, enableAsync = false) => {
389
- const compiler = getLoadedSvelteCompiler();
390
- const compiled = compiler.compile(raw, {
391
- css: "external",
392
- dev: true,
393
- experimental: {
394
- async: enableAsync
395
- },
396
- filename: filePath,
397
- generate: "client",
398
- hmr: true
399
- });
400
- let { code } = compiled.js;
401
- if (compiled.css?.code) {
402
- const cssPath = `${filePath}.css`;
403
- svelteExternalCss.set(cssPath, compiled.css.code);
404
- const cssUrl = srcUrl(relative(projectRoot, cssPath), projectRoot);
405
- code = `import "${cssUrl}";
406
- ${code}`;
407
- }
408
- const moduleUrl = `${SRC_PREFIX}${relative(projectRoot, filePath).replace(/\\/g, "/")}`;
409
- code = code.replace(/if\s*\(import\.meta\.hot\)\s*\{/, `if (typeof window !== "undefined") {
410
- ` + ` if (!window.__SVELTE_HMR_ACCEPT__) window.__SVELTE_HMR_ACCEPT__ = {};
411
- ` + ` var __hmr_accept = function(cb) { window.__SVELTE_HMR_ACCEPT__[${JSON.stringify(moduleUrl)}] = cb; };`);
412
- return code.replace(/import\.meta\.hot\.accept\(/g, "__hmr_accept(");
413
- };
414
- var transformSvelteFile = async (filePath, projectRoot, rewriter, stylePreprocessors) => {
415
- const raw = readFileSync(filePath, "utf-8");
416
- if (!svelteCompiler) {
417
- svelteCompiler = await import("svelte/compiler");
418
- }
419
- const isModule = filePath.endsWith(".svelte.ts") || filePath.endsWith(".svelte.js");
420
- const loweredAwaitSource = isModule ? { code: raw, transformed: false } : lowerSvelteAwaitSlotSyntax(raw);
421
- const loweredSource = isModule ? loweredAwaitSource : lowerSvelteIslandSyntax(loweredAwaitSource.code, "client");
422
- const source = isModule ? loweredSource.code : (await svelteCompiler.preprocess(loweredSource.code, createSvelteStylePreprocessor(stylePreprocessors))).code;
423
- const enableAsync = loweredAwaitSource.transformed || loweredSource.transformed;
424
- const code = isModule ? compileSvelteModule(source, filePath) : compileSvelteComponent(source, filePath, projectRoot, enableAsync);
425
- return rewriteImports(code, filePath, projectRoot, rewriter);
426
- };
427
- var compileVueTemplate = (descriptor, compiledScript, filePath, componentId) => {
428
- const compiler = getLoadedVueCompiler();
429
- const scriptContent = compiledScript.content;
430
- if (!descriptor.template)
431
- return scriptContent;
432
- const isScoped = descriptor.styles.some((style) => style.scoped);
433
- const templateResult = compiler.compileTemplate({
434
- compilerOptions: {
435
- bindingMetadata: compiledScript.bindings,
436
- prefixIdentifiers: true
437
- },
438
- filename: filePath,
439
- id: componentId,
440
- scoped: isScoped,
441
- source: descriptor.template.content
442
- });
443
- let code = scriptContent.replace("export default", "const __script__ =");
444
- code += `
445
- ${templateResult.code}`;
446
- code += `
447
- __script__.render = render;`;
448
- code += `
449
- export default __script__;`;
450
- return code;
451
- };
452
- var compileVueStyles = async (descriptor, filePath, componentId, code, stylePreprocessors) => {
453
- if (descriptor.styles.length === 0)
454
- return code;
455
- const compiler = getLoadedVueCompiler();
456
- const cssCode = (await Promise.all(descriptor.styles.map(async (style) => compiler.compileStyle({
457
- filename: filePath,
458
- id: `data-v-${componentId}`,
459
- scoped: Boolean(style.scoped),
460
- source: style.lang ? await compileStyleSource(filePath, style.content, style.lang, stylePreprocessors) : style.content,
461
- trim: true
462
- }).code))).join(`
463
- `);
464
- const escaped = cssCode.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$/g, "\\$");
465
- const hmrId = JSON.stringify(filePath);
466
- const cssInjection = [
467
- `var __style=document.createElement('style');`,
468
- `__style.textContent=\`${escaped}\`;`,
469
- `__style.dataset.hmrId=${hmrId};`,
470
- `var __prev=document.querySelector('style[data-hmr-id="${filePath}"]');`,
471
- `if(__prev)__prev.remove();`,
472
- `document.head.appendChild(__style);`
473
- ].join("");
474
- return `${cssInjection}
475
- ${code}`;
476
- };
477
- var transformVueFile = async (filePath, projectRoot, rewriter, vueDir, stylePreprocessors) => {
478
- const raw = readFileSync(filePath, "utf-8");
479
- if (!vueCompiler) {
480
- vueCompiler = await import("@vue/compiler-sfc");
481
- }
482
- const fileName = basename(filePath, ".vue");
483
- const componentId = fileName.toLowerCase();
484
- const { descriptor } = vueCompiler.parse(raw, { filename: filePath });
485
- const compiledScript = vueCompiler.compileScript(descriptor, {
486
- id: componentId,
487
- inlineTemplate: false
488
- });
489
- const compiledSfcScript = {
490
- bindings: compiledScript.bindings ?? {},
491
- content: compiledScript.content
492
- };
493
- let code = compileVueTemplate(descriptor, compiledSfcScript, filePath, componentId);
494
- code = await compileVueStyles(descriptor, filePath, componentId, code, stylePreprocessors);
495
- code = tsTranspiler.transformSync(code);
496
- code = injectVueHmr(code, filePath, projectRoot, vueDir);
497
- return rewriteImports(code, filePath, projectRoot, rewriter);
498
- };
499
- var injectVueHmr = (code, filePath, projectRoot, vueDir) => {
500
- const hmrBase = vueDir ? resolve(vueDir) : projectRoot;
501
- const hmrId = relative(hmrBase, filePath).replace(/\\/g, "/").replace(/\.vue$/, "");
502
- let result = code.replace(/export\s+default\s+/, "var __hmr_comp__ = ");
503
- result += [
504
- "",
505
- `__hmr_comp__.__hmrId = ${JSON.stringify(hmrId)};`,
506
- `if (typeof __VUE_HMR_RUNTIME__ !== "undefined") {`,
507
- ` __VUE_HMR_RUNTIME__.createRecord(${JSON.stringify(hmrId)}, __hmr_comp__);`,
508
- ` __VUE_HMR_RUNTIME__.rerender(${JSON.stringify(hmrId)}, __hmr_comp__.render);`,
509
- `}`,
510
- "export default __hmr_comp__;"
511
- ].join(`
512
- `);
513
- return result;
514
- };
515
- var resolveSvelteModulePath = (path) => {
516
- if (existsSync(path))
517
- return path;
518
- if (existsSync(`${path}.ts`))
519
- return `${path}.ts`;
520
- if (existsSync(`${path}.js`))
521
- return `${path}.js`;
522
- return path;
523
- };
524
- var jsResponse = (body) => {
525
- const etag = `"${Bun.hash(body).toString(BASE_36_RADIX)}"`;
526
- return new Response(body, {
527
- headers: {
528
- "Cache-Control": "no-cache",
529
- "Content-Type": "application/javascript",
530
- ETag: etag
531
- }
532
- });
533
- };
534
- var handleCssRequest = (filePath) => {
535
- const raw = readFileSync(filePath, "utf-8");
536
- const escaped = raw.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$/g, "\\$");
537
- return [
538
- `const style = document.createElement('style');`,
539
- `style.textContent = \`${escaped}\`;`,
540
- `style.dataset.hmrId = ${JSON.stringify(filePath)};`,
541
- `const existing = document.querySelector(\`style[data-hmr-id="${filePath}"]\`);`,
542
- `if (existing) existing.remove();`,
543
- `document.head.appendChild(style);`
544
- ].join(`
545
- `);
546
- };
547
- var generateSvelteHmrBootstrap = (moduleUrl, vendorPaths, timestamp) => {
548
- const sveltePath = vendorPaths["svelte"] || "/svelte/vendor/svelte.js";
549
- return [
550
- `import { mount, unmount } from "${sveltePath}";`,
551
- `const { default: Component } = await import("${moduleUrl}?t=${timestamp}");`,
552
- ``,
553
- `// Extract count from DOM before unmount (survives across runtime instances)`,
554
- `var countBtn = document.querySelector("button");`,
555
- `var countMatch = countBtn && countBtn.textContent && countBtn.textContent.match(/(\\d+)/);`,
556
- `var domCount = countMatch ? parseInt(countMatch[1], 10) : null;`,
557
- ``,
558
- `var preservedState = window.__HMR_PRESERVED_STATE__ || {};`,
559
- `if (domCount !== null && preservedState.initialCount === undefined) {`,
560
- ` preservedState.initialCount = domCount;`,
561
- `}`,
562
- `var initialProps = window.__INITIAL_PROPS__ || {};`,
563
- `var mergedProps = Object.assign({}, initialProps, preservedState);`,
564
- ``,
565
- `// Update __INITIAL_PROPS__ so subsequent HMR cycles start with current state`,
566
- `if (domCount !== null) window.__INITIAL_PROPS__ = Object.assign({}, initialProps, { initialCount: domCount });`,
567
- ``,
568
- `if (typeof window.__SVELTE_UNMOUNT__ === "function") {`,
569
- ` try { window.__SVELTE_UNMOUNT__(); } catch (err) { /* ignore */ }`,
570
- `}`,
571
- ``,
572
- `var target = document.getElementById("__absolute_svelte_root__") || document.body;`,
573
- `var component = mount(Component, { target, props: mergedProps });`,
574
- `window.__SVELTE_COMPONENT__ = component;`,
575
- `window.__SVELTE_UNMOUNT__ = function() { unmount(component); };`,
576
- `window.__HMR_PRESERVED_STATE__ = undefined;`
577
- ].join(`
578
- `);
579
- };
580
- var generateVueHmrBootstrap = (moduleUrl, vendorPaths, timestamp) => {
581
- const vuePath = vendorPaths["vue"] || "/vue/vendor/vue.js";
582
- return [
583
- `import { createApp } from "${vuePath}";`,
584
- `const { default: Component } = await import("${moduleUrl}?t=${timestamp}");`,
585
- ``,
586
- `// Extract count from DOM before unmount (works across Vue instances)`,
587
- `var countBtn = document.querySelector("button");`,
588
- `var countMatch = countBtn && countBtn.textContent && countBtn.textContent.match(/(\\d+)/);`,
589
- `var domCount = countMatch ? parseInt(countMatch[1], 10) : null;`,
590
- ``,
591
- `var preservedState = window.__HMR_PRESERVED_STATE__ || {};`,
592
- `if (domCount !== null && preservedState.initialCount === undefined) {`,
593
- ` preservedState.initialCount = domCount;`,
594
- `}`,
595
- `var initialProps = window.__INITIAL_PROPS__ || {};`,
596
- `var mergedProps = Object.assign({}, initialProps, preservedState);`,
597
- ``,
598
- `// Update __INITIAL_PROPS__ so subsequent HMR cycles start with current state`,
599
- `if (domCount !== null) window.__INITIAL_PROPS__ = Object.assign({}, initialProps, { initialCount: domCount });`,
600
- ``,
601
- `var root = document.getElementById("root");`,
602
- `var savedHTML = root ? root.innerHTML : "";`,
603
- `if (window.__VUE_APP__) {`,
604
- ` window.__VUE_APP__.unmount();`,
605
- ` window.__VUE_APP__ = null;`,
606
- `}`,
607
- `if (root) root.innerHTML = savedHTML;`,
608
- ``,
609
- `var app = createApp(Component, mergedProps);`,
610
- `app.mount(root);`,
611
- `window.__VUE_APP__ = app;`,
612
- `window.__HMR_PRESERVED_STATE__ = undefined;`
613
- ].join(`
614
- `);
615
- };
616
- var handleStubRequest = async (pathname) => {
617
- const specifier = decodeURIComponent(pathname.slice("/@stub/".length));
618
- const stubCode = await buildStubCode(specifier);
619
- return new Response(stubCode, {
620
- headers: {
621
- "Cache-Control": "no-cache",
622
- "Content-Type": "application/javascript"
623
- }
624
- });
625
- };
626
- var buildStubCode = async (specifier) => {
627
- try {
628
- const mod = await import(specifier);
629
- const names = Object.keys(mod).filter((key) => key !== "default" && key !== "__esModule");
630
- if (names.length === 0)
631
- return `export default {};
632
- `;
633
- const noops = names.map((n) => `export const ${n} = () => {};`).join(`
634
- `);
635
- return `${noops}
636
- export default {};
637
- `;
638
- } catch {
639
- return `export default {};
640
- `;
641
- }
642
- };
643
- var handleHmrBootstrap = (pathname, vendorPaths) => {
644
- const rest = pathname.slice("/@hmr/".length);
645
- const slashIdx = rest.indexOf("/");
646
- if (slashIdx === UNFOUND_INDEX)
647
- return;
648
- const framework = rest.slice(0, slashIdx);
649
- const componentRelPath = rest.slice(slashIdx + 1);
650
- const url = `${SRC_PREFIX}${componentRelPath}`;
651
- const timestamp = String(Date.now());
652
- const generators = {
653
- svelte: generateSvelteHmrBootstrap,
654
- vue: generateVueHmrBootstrap
655
- };
656
- const generate = generators[framework];
657
- if (!generate)
658
- return;
659
- return jsResponse(generate(url, vendorPaths, timestamp));
660
- };
661
- var handleVirtualSvelteCss = (cssCheckPath) => {
662
- const virtualCss = svelteExternalCss.get(cssCheckPath);
663
- if (!virtualCss)
664
- return;
665
- const escaped = virtualCss.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$/g, "\\$");
666
- return jsResponse(`var s=document.createElement('style');s.textContent=\`${escaped}\`;s.dataset.svelteHmr=${JSON.stringify(cssCheckPath)};var p=document.querySelector('style[data-svelte-hmr="${cssCheckPath}"]');if(p)p.remove();document.head.appendChild(s);`);
667
- };
668
- var resolveSourcePath = (relPath, projectRoot) => {
669
- const filePath = resolve(projectRoot, relPath);
670
- const ext = extname(filePath);
671
- if (ext === ".svelte")
672
- return { ext, filePath: resolveSvelteModulePath(filePath) };
673
- if (ext)
674
- return { ext, filePath };
675
- const found = MODULE_EXTENSIONS.find((candidate) => existsSync(filePath + candidate));
676
- if (!found)
677
- return { ext, filePath };
678
- const resolved = filePath + found;
679
- if (found === ".svelte")
680
- return { ext: found, filePath: resolveSvelteModulePath(resolved) };
681
- return { ext: found, filePath: resolved };
682
- };
683
- var transformAndCache = async (filePath, ext, projectRoot, rewriter, vueDir, stylePreprocessors) => {
684
- if (ext === ".css")
685
- return jsResponse(handleCssRequest(filePath));
686
- const isSvelte = ext === ".svelte" || filePath.endsWith(".svelte.ts") || filePath.endsWith(".svelte.js");
687
- const cached = getTransformed(filePath);
688
- if (cached)
689
- return jsResponse(cached);
690
- if (isSvelte)
691
- return transformAndCacheSvelte(filePath, projectRoot, rewriter, stylePreprocessors);
692
- if (ext === ".vue")
693
- return transformAndCacheVue(filePath, projectRoot, rewriter, vueDir, stylePreprocessors);
694
- if (!TRANSPILABLE.has(ext))
695
- return;
696
- const stat = statSync(filePath);
697
- const resolvedVueDir = vueDir ? resolve(vueDir) : undefined;
698
- const content = REACT_EXTENSIONS.has(ext) ? transformReactFile(filePath, projectRoot, rewriter) : transformPlainFile(filePath, projectRoot, rewriter, resolvedVueDir);
699
- setTransformed(filePath, content, stat.mtimeMs, extractImportedFiles(content, projectRoot));
700
- return jsResponse(content);
701
- };
702
- var transformAndCacheSvelte = async (filePath, projectRoot, rewriter, stylePreprocessors) => {
703
- const stat = statSync(filePath);
704
- const content = await transformSvelteFile(filePath, projectRoot, rewriter, stylePreprocessors);
705
- setTransformed(filePath, content, stat.mtimeMs, extractImportedFiles(content, projectRoot));
706
- return jsResponse(content);
707
- };
708
- var transformAndCacheVue = async (filePath, projectRoot, rewriter, vueDir, stylePreprocessors) => {
709
- const stat = statSync(filePath);
710
- const content = await transformVueFile(filePath, projectRoot, rewriter, vueDir, stylePreprocessors);
711
- setTransformed(filePath, content, stat.mtimeMs, extractImportedFiles(content, projectRoot));
712
- return jsResponse(content);
713
- };
714
- var transformErrorResponse = (err) => {
715
- const errMsg = err instanceof Error ? err.message : String(err);
716
- return new Response(`console.error('[ModuleServer] Transform error:', ${JSON.stringify(errMsg)});`, {
717
- headers: { "Content-Type": "application/javascript" },
718
- status: 500
719
- });
720
- };
721
- var createModuleServer = (config) => {
722
- const { projectRoot, vendorPaths, frameworkDirs, stylePreprocessors } = config;
723
- const rewriter = buildImportRewriter(vendorPaths);
724
- return async (pathname) => {
725
- if (pathname.startsWith("/@stub/"))
726
- return handleStubRequest(pathname);
727
- if (pathname.startsWith("/@hmr/"))
728
- return handleHmrBootstrap(pathname, vendorPaths);
729
- if (!pathname.startsWith(SRC_PREFIX))
730
- return;
731
- const relPath = pathname.slice(SRC_PREFIX.length);
732
- const virtualCssResponse = handleVirtualSvelteCss(resolve(projectRoot, relPath));
733
- if (virtualCssResponse)
734
- return virtualCssResponse;
735
- const { filePath, ext } = resolveSourcePath(relPath, projectRoot);
736
- try {
737
- return await transformAndCache(filePath, ext, projectRoot, rewriter, frameworkDirs?.vue, stylePreprocessors);
738
- } catch (err) {
739
- return transformErrorResponse(err);
740
- }
741
- };
742
- };
743
- var SRC_IMPORT_RE = /\/@src\/([^"'?\s]+)/g;
744
- var extractImportedFiles = (content, projectRoot) => {
745
- const files = [];
746
- let match;
747
- SRC_IMPORT_RE.lastIndex = 0;
748
- while ((match = SRC_IMPORT_RE.exec(content)) !== null) {
749
- if (match[1])
750
- files.push(resolve(projectRoot, match[1]));
751
- }
752
- return files;
753
- };
754
- var invalidateModule = (filePath) => {
755
- const resolved = resolve(filePath);
756
- invalidate(filePath);
757
- if (resolved !== filePath)
758
- invalidate(resolved);
759
- mtimeCache.delete(filePath);
760
- mtimeCache.delete(resolved);
761
- };
762
- var warmCache = (pathname) => {
763
- if (!pathname.startsWith(SRC_PREFIX))
764
- return;
765
- if (!globalModuleServer)
766
- return;
767
- globalModuleServer(pathname);
768
- };
769
- var globalModuleServer = null;
770
- var SRC_URL_PREFIX = SRC_PREFIX;
771
- var setGlobalModuleServer = (handler) => {
772
- globalModuleServer = handler;
773
- };
774
- export {
775
- warmCompilers,
776
- warmCache,
777
- setGlobalModuleServer,
778
- invalidateModule,
779
- createModuleServer,
780
- SRC_URL_PREFIX
781
- };
782
-
783
- //# debugId=518E604077F8CEC164756E2164756E21
784
- //# sourceMappingURL=chunk-zrg9d4zw.js.map