@absolutejs/absolute 0.15.26 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +402 -423
- package/dist/index.js.map +13 -12
- package/dist/react/hooks/index.js +98 -0
- package/dist/react/hooks/index.js.map +10 -0
- package/dist/react/index.js +97 -0
- package/dist/react/index.js.map +11 -0
- package/dist/src/core/pageHandlers.d.ts +0 -13
- package/dist/src/react/hooks/index.d.ts +2 -0
- package/dist/src/react/hooks/useMediaQuery.d.ts +7 -0
- package/dist/src/react/index.d.ts +1 -0
- package/dist/src/react/pageHandler.d.ts +2 -0
- package/dist/src/svelte/index.d.ts +2 -0
- package/dist/src/svelte/pageHandler.d.ts +6 -0
- package/dist/src/utils/userAgentFunctions.d.ts +1 -0
- package/dist/src/vue/index.d.ts +1 -0
- package/dist/src/vue/pageHandler.d.ts +2 -0
- package/dist/svelte/index.js +176 -0
- package/dist/svelte/index.js.map +15 -0
- package/dist/types/build.d.ts +0 -5
- package/dist/types/mediaQuery.d.ts +9 -0
- package/dist/types/react.d.ts +2 -0
- package/dist/types/svelte.d.ts +2 -0
- package/dist/types/userAgentTypes.d.ts +2 -0
- package/dist/types/vue.d.ts +2 -0
- package/dist/types/window-globals.d.ts +26 -0
- package/dist/vue/index.js +114 -0
- package/dist/vue/index.js.map +12 -0
- package/package.json +24 -2
- package/tsconfig.build.json +1 -1
- package/types/build.ts +0 -14
- package/types/mediaQuery.ts +10 -0
- package/types/react.ts +4 -0
- package/types/svelte.ts +4 -0
- package/types/userAgentTypes.ts +3 -0
- package/types/vue.ts +4 -0
package/dist/index.js
CHANGED
|
@@ -33,6 +33,180 @@ var normalizeSlug = (str) => str.trim().replace(/\s+/g, "-").replace(/[^A-Za-z0-
|
|
|
33
33
|
return normalizeSlug(str).split(/[-_]/).filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1).toLowerCase()).join("");
|
|
34
34
|
}, toKebab = (str) => normalizeSlug(str).replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
35
35
|
|
|
36
|
+
// src/build/compileSvelte.ts
|
|
37
|
+
var exports_compileSvelte = {};
|
|
38
|
+
__export(exports_compileSvelte, {
|
|
39
|
+
compileSvelte: () => compileSvelte
|
|
40
|
+
});
|
|
41
|
+
import { existsSync as existsSync3 } from "fs";
|
|
42
|
+
import { mkdir as mkdir2, stat } from "fs/promises";
|
|
43
|
+
import {
|
|
44
|
+
dirname,
|
|
45
|
+
join as join3,
|
|
46
|
+
basename as basename2,
|
|
47
|
+
extname as extname2,
|
|
48
|
+
resolve as resolve4,
|
|
49
|
+
relative as relative2,
|
|
50
|
+
sep
|
|
51
|
+
} from "path";
|
|
52
|
+
import { env } from "process";
|
|
53
|
+
var {write, file, Transpiler } = globalThis.Bun;
|
|
54
|
+
import { compile, compileModule, preprocess } from "svelte/compiler";
|
|
55
|
+
var devClientDir2, hmrClientPath3, transpiler, exists = async (path) => {
|
|
56
|
+
try {
|
|
57
|
+
await stat(path);
|
|
58
|
+
return true;
|
|
59
|
+
} catch {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}, resolveSvelte = async (spec, from) => {
|
|
63
|
+
const basePath = resolve4(dirname(from), spec);
|
|
64
|
+
const explicit = /\.(svelte|svelte\.(?:ts|js))$/.test(basePath);
|
|
65
|
+
if (!explicit) {
|
|
66
|
+
const extensions = [".svelte", ".svelte.ts", ".svelte.js"];
|
|
67
|
+
const paths = extensions.map((ext) => `${basePath}${ext}`);
|
|
68
|
+
const checks = await Promise.all(paths.map(exists));
|
|
69
|
+
const match = paths.find((_, index) => checks[index]);
|
|
70
|
+
return match ?? null;
|
|
71
|
+
}
|
|
72
|
+
if (await exists(basePath))
|
|
73
|
+
return basePath;
|
|
74
|
+
if (!basePath.endsWith(".svelte"))
|
|
75
|
+
return null;
|
|
76
|
+
const tsPath = `${basePath}.ts`;
|
|
77
|
+
if (await exists(tsPath))
|
|
78
|
+
return tsPath;
|
|
79
|
+
const jsPath = `${basePath}.js`;
|
|
80
|
+
if (await exists(jsPath))
|
|
81
|
+
return jsPath;
|
|
82
|
+
return null;
|
|
83
|
+
}, compileSvelte = async (entryPoints, svelteRoot, cache = new Map, isDev = false) => {
|
|
84
|
+
const compiledRoot = join3(svelteRoot, "compiled");
|
|
85
|
+
const clientDir = join3(compiledRoot, "client");
|
|
86
|
+
const indexDir = join3(compiledRoot, "indexes");
|
|
87
|
+
const pagesDir = join3(compiledRoot, "pages");
|
|
88
|
+
await Promise.all([clientDir, indexDir, pagesDir].map((dir) => mkdir2(dir, { recursive: true })));
|
|
89
|
+
const dev = env.NODE_ENV !== "production";
|
|
90
|
+
const build2 = async (src) => {
|
|
91
|
+
const memoized = cache.get(src);
|
|
92
|
+
if (memoized)
|
|
93
|
+
return memoized;
|
|
94
|
+
const raw = await file(src).text();
|
|
95
|
+
const isModule = src.endsWith(".svelte.ts") || src.endsWith(".svelte.js");
|
|
96
|
+
const preprocessed = isModule ? raw : (await preprocess(raw, {})).code;
|
|
97
|
+
const transpiled = src.endsWith(".ts") || src.endsWith(".svelte.ts") ? transpiler.transformSync(preprocessed) : preprocessed;
|
|
98
|
+
const relDir = dirname(relative2(svelteRoot, src)).replace(/\\/g, "/");
|
|
99
|
+
const baseName = basename2(src).replace(/\.svelte(\.(ts|js))?$/, "");
|
|
100
|
+
const importPaths = Array.from(transpiled.matchAll(/from\s+['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((path) => path !== undefined);
|
|
101
|
+
const resolvedImports = await Promise.all(importPaths.map((importPath) => resolveSvelte(importPath, src)));
|
|
102
|
+
const childSources = resolvedImports.filter((path) => path !== null);
|
|
103
|
+
await Promise.all(childSources.map((child) => build2(child)));
|
|
104
|
+
const generate = (mode) => (isModule ? compileModule(transpiled, {
|
|
105
|
+
dev: mode === "client" && dev,
|
|
106
|
+
filename: src
|
|
107
|
+
}).js.code : compile(transpiled, {
|
|
108
|
+
css: "injected",
|
|
109
|
+
dev: mode === "client" && dev,
|
|
110
|
+
filename: src,
|
|
111
|
+
generate: mode
|
|
112
|
+
}).js.code).replace(/\.svelte(?:\.(?:ts|js))?(['"])/g, ".js$1");
|
|
113
|
+
const ssrPath = join3(pagesDir, relDir, `${baseName}.js`);
|
|
114
|
+
const clientPath = join3(clientDir, relDir, `${baseName}.js`);
|
|
115
|
+
await Promise.all([
|
|
116
|
+
mkdir2(dirname(ssrPath), { recursive: true }),
|
|
117
|
+
mkdir2(dirname(clientPath), { recursive: true })
|
|
118
|
+
]);
|
|
119
|
+
if (isModule) {
|
|
120
|
+
const bundle = generate("client");
|
|
121
|
+
await Promise.all([
|
|
122
|
+
write(ssrPath, bundle),
|
|
123
|
+
write(clientPath, bundle)
|
|
124
|
+
]);
|
|
125
|
+
} else {
|
|
126
|
+
const serverBundle = generate("server");
|
|
127
|
+
const clientBundle = generate("client");
|
|
128
|
+
await Promise.all([
|
|
129
|
+
write(ssrPath, serverBundle),
|
|
130
|
+
write(clientPath, clientBundle)
|
|
131
|
+
]);
|
|
132
|
+
}
|
|
133
|
+
const built = { client: clientPath, ssr: ssrPath };
|
|
134
|
+
cache.set(src, built);
|
|
135
|
+
return built;
|
|
136
|
+
};
|
|
137
|
+
const roots = await Promise.all(entryPoints.map(build2));
|
|
138
|
+
await Promise.all(roots.map(async ({ client: client2 }) => {
|
|
139
|
+
const relClientDir = dirname(relative2(clientDir, client2));
|
|
140
|
+
const name = basename2(client2, extname2(client2));
|
|
141
|
+
const indexPath = join3(indexDir, relClientDir, `${name}.js`);
|
|
142
|
+
const importRaw = relative2(dirname(indexPath), client2).split(sep).join("/");
|
|
143
|
+
const importPath = importRaw.startsWith(".") || importRaw.startsWith("/") ? importRaw : `./${importRaw}`;
|
|
144
|
+
const hmrImports = isDev ? `window.__HMR_FRAMEWORK__ = "svelte";
|
|
145
|
+
import "${hmrClientPath3}";
|
|
146
|
+
` : "";
|
|
147
|
+
const bootstrap = `${hmrImports}import Component from "${importPath}";
|
|
148
|
+
import { hydrate, mount, unmount } from "svelte";
|
|
149
|
+
|
|
150
|
+
var initialProps = (typeof window !== "undefined" && window.__INITIAL_PROPS__) ? window.__INITIAL_PROPS__ : {};
|
|
151
|
+
var isHMR = typeof window !== "undefined" && window.__SVELTE_COMPONENT__ !== undefined;
|
|
152
|
+
var component;
|
|
153
|
+
|
|
154
|
+
if (isHMR) {
|
|
155
|
+
var headLinks = document.querySelectorAll('link[rel="stylesheet"]');
|
|
156
|
+
var preservedLinks = [];
|
|
157
|
+
headLinks.forEach(function(link) {
|
|
158
|
+
var clone = link.cloneNode(true);
|
|
159
|
+
clone.setAttribute("data-hmr-preserve", "true");
|
|
160
|
+
document.head.appendChild(clone);
|
|
161
|
+
preservedLinks.push(clone);
|
|
162
|
+
});
|
|
163
|
+
if (typeof window.__SVELTE_UNMOUNT__ === "function") {
|
|
164
|
+
try { window.__SVELTE_UNMOUNT__(); } catch (err) { console.warn("[HMR] unmount error:", err); }
|
|
165
|
+
}
|
|
166
|
+
var preservedState = window.__HMR_PRESERVED_STATE__;
|
|
167
|
+
if (!preservedState) {
|
|
168
|
+
try {
|
|
169
|
+
var stored = sessionStorage.getItem("__SVELTE_HMR_STATE__");
|
|
170
|
+
if (stored) preservedState = JSON.parse(stored);
|
|
171
|
+
} catch (err) { /* ignore */ }
|
|
172
|
+
}
|
|
173
|
+
var mergedProps = preservedState ? Object.assign({}, initialProps, preservedState) : initialProps;
|
|
174
|
+
component = mount(Component, { target: document.body, props: mergedProps });
|
|
175
|
+
requestAnimationFrame(function() {
|
|
176
|
+
preservedLinks.forEach(function(link) { link.remove(); });
|
|
177
|
+
});
|
|
178
|
+
window.__HMR_PRESERVED_STATE__ = undefined;
|
|
179
|
+
} else {
|
|
180
|
+
component = hydrate(Component, { target: document.body, props: initialProps });
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (typeof window !== "undefined") {
|
|
184
|
+
window.__SVELTE_COMPONENT__ = component;
|
|
185
|
+
window.__SVELTE_UNMOUNT__ = function() { unmount(component); };
|
|
186
|
+
}`;
|
|
187
|
+
await mkdir2(dirname(indexPath), { recursive: true });
|
|
188
|
+
return write(indexPath, bootstrap);
|
|
189
|
+
}));
|
|
190
|
+
return {
|
|
191
|
+
svelteIndexPaths: roots.map(({ client: client2 }) => {
|
|
192
|
+
const rel = dirname(relative2(clientDir, client2));
|
|
193
|
+
return join3(indexDir, rel, basename2(client2));
|
|
194
|
+
}),
|
|
195
|
+
svelteClientPaths: roots.map(({ client: client2 }) => client2),
|
|
196
|
+
svelteServerPaths: roots.map(({ ssr }) => ssr)
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
var init_compileSvelte = __esm(() => {
|
|
200
|
+
devClientDir2 = (() => {
|
|
201
|
+
const fromSource = resolve4(import.meta.dir, "../dev/client");
|
|
202
|
+
if (existsSync3(fromSource))
|
|
203
|
+
return fromSource;
|
|
204
|
+
return resolve4(import.meta.dir, "./dev/client");
|
|
205
|
+
})();
|
|
206
|
+
hmrClientPath3 = join3(devClientDir2, "hmrClient.ts").replace(/\\/g, "/");
|
|
207
|
+
transpiler = new Transpiler({ loader: "ts", target: "browser" });
|
|
208
|
+
});
|
|
209
|
+
|
|
36
210
|
// src/build/compileVue.ts
|
|
37
211
|
var exports_compileVue = {};
|
|
38
212
|
__export(exports_compileVue, {
|
|
@@ -42,9 +216,9 @@ __export(exports_compileVue, {
|
|
|
42
216
|
compileVue: () => compileVue,
|
|
43
217
|
clearVueHmrCaches: () => clearVueHmrCaches
|
|
44
218
|
});
|
|
45
|
-
import { existsSync as
|
|
46
|
-
import { mkdir as
|
|
47
|
-
import { basename as
|
|
219
|
+
import { existsSync as existsSync4 } from "fs";
|
|
220
|
+
import { mkdir as mkdir3 } from "fs/promises";
|
|
221
|
+
import { basename as basename3, dirname as dirname2, join as join4, relative as relative3, resolve as resolve5 } from "path";
|
|
48
222
|
import {
|
|
49
223
|
parse,
|
|
50
224
|
compileScript,
|
|
@@ -52,7 +226,7 @@ import {
|
|
|
52
226
|
compileStyle
|
|
53
227
|
} from "@vue/compiler-sfc";
|
|
54
228
|
var {file: file2, write: write2, Transpiler: Transpiler2 } = globalThis.Bun;
|
|
55
|
-
var
|
|
229
|
+
var devClientDir3, hmrClientPath4, transpiler2, scriptCache, scriptSetupCache, templateCache, styleCache, vueHmrMetadata, detectVueChangeType = (filePath, descriptor) => {
|
|
56
230
|
const prevScript = scriptCache.get(filePath);
|
|
57
231
|
const prevScriptSetup = scriptSetupCache.get(filePath);
|
|
58
232
|
const prevTemplate = templateCache.get(filePath);
|
|
@@ -83,7 +257,7 @@ var devClientDir2, hmrClientPath2, transpiler2, scriptCache, scriptSetupCache, t
|
|
|
83
257
|
}
|
|
84
258
|
return "full";
|
|
85
259
|
}, generateVueHmrId = (sourceFilePath, vueRootDir) => {
|
|
86
|
-
return
|
|
260
|
+
return relative3(vueRootDir, sourceFilePath).replace(/\\/g, "/").replace(/\.vue$/, "");
|
|
87
261
|
}, clearVueHmrCaches = () => {
|
|
88
262
|
scriptCache.clear();
|
|
89
263
|
scriptSetupCache.clear();
|
|
@@ -117,9 +291,9 @@ var devClientDir2, hmrClientPath2, transpiler2, scriptCache, scriptSetupCache, t
|
|
|
117
291
|
const cachedResult = cacheMap.get(sourceFilePath);
|
|
118
292
|
if (cachedResult)
|
|
119
293
|
return cachedResult;
|
|
120
|
-
const relativeFilePath =
|
|
294
|
+
const relativeFilePath = relative3(vueRootDir, sourceFilePath).replace(/\\/g, "/");
|
|
121
295
|
const relativeWithoutExtension = relativeFilePath.replace(/\.vue$/, "");
|
|
122
|
-
const fileBaseName =
|
|
296
|
+
const fileBaseName = basename3(sourceFilePath, ".vue");
|
|
123
297
|
const componentId = toKebab(fileBaseName);
|
|
124
298
|
const sourceContent = await file2(sourceFilePath).text();
|
|
125
299
|
const { descriptor } = parse(sourceContent, { filename: sourceFilePath });
|
|
@@ -130,7 +304,7 @@ var devClientDir2, hmrClientPath2, transpiler2, scriptCache, scriptSetupCache, t
|
|
|
130
304
|
const importPaths = extractImports(scriptSource);
|
|
131
305
|
const childComponentPaths = importPaths.filter((path) => path.startsWith(".") && path.endsWith(".vue"));
|
|
132
306
|
const helperModulePaths = importPaths.filter((path) => path.startsWith(".") && !path.endsWith(".vue"));
|
|
133
|
-
const childBuildResults = await Promise.all(childComponentPaths.map((relativeChildPath) => compileVueFile(
|
|
307
|
+
const childBuildResults = await Promise.all(childComponentPaths.map((relativeChildPath) => compileVueFile(resolve5(dirname2(sourceFilePath), relativeChildPath), outputDirs, cacheMap, false, vueRootDir)));
|
|
134
308
|
const compiledScript = compileScript(descriptor, {
|
|
135
309
|
id: componentId,
|
|
136
310
|
inlineTemplate: false
|
|
@@ -162,8 +336,8 @@ var devClientDir2, hmrClientPath2, transpiler2, scriptCache, scriptSetupCache, t
|
|
|
162
336
|
];
|
|
163
337
|
let cssOutputPaths = [];
|
|
164
338
|
if (isEntryPoint && allCss.length) {
|
|
165
|
-
const cssOutputFile =
|
|
166
|
-
await
|
|
339
|
+
const cssOutputFile = join4(outputDirs.css, `${toKebab(fileBaseName)}.css`);
|
|
340
|
+
await mkdir3(dirname2(cssOutputFile), { recursive: true });
|
|
167
341
|
await write2(cssOutputFile, allCss.join(`
|
|
168
342
|
`));
|
|
169
343
|
cssOutputPaths = [cssOutputFile];
|
|
@@ -193,10 +367,10 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
193
367
|
};
|
|
194
368
|
const clientCode = assembleModule(generateRenderFunction(false), "render", true);
|
|
195
369
|
const serverCode = assembleModule(generateRenderFunction(true), "ssrRender", false);
|
|
196
|
-
const clientOutputPath =
|
|
197
|
-
const serverOutputPath =
|
|
198
|
-
await
|
|
199
|
-
await
|
|
370
|
+
const clientOutputPath = join4(outputDirs.client, `${relativeWithoutExtension}.js`);
|
|
371
|
+
const serverOutputPath = join4(outputDirs.server, `${relativeWithoutExtension}.js`);
|
|
372
|
+
await mkdir3(dirname2(clientOutputPath), { recursive: true });
|
|
373
|
+
await mkdir3(dirname2(serverOutputPath), { recursive: true });
|
|
200
374
|
await write2(clientOutputPath, clientCode);
|
|
201
375
|
await write2(serverOutputPath, serverCode);
|
|
202
376
|
const result = {
|
|
@@ -205,7 +379,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
205
379
|
cssPaths: cssOutputPaths,
|
|
206
380
|
serverPath: serverOutputPath,
|
|
207
381
|
tsHelperPaths: [
|
|
208
|
-
...helperModulePaths.map((helper) =>
|
|
382
|
+
...helperModulePaths.map((helper) => resolve5(dirname2(sourceFilePath), helper.endsWith(".ts") ? helper : `${helper}.ts`)),
|
|
209
383
|
...childBuildResults.flatMap((child) => child.tsHelperPaths)
|
|
210
384
|
],
|
|
211
385
|
hmrId
|
|
@@ -213,44 +387,44 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
213
387
|
cacheMap.set(sourceFilePath, result);
|
|
214
388
|
return result;
|
|
215
389
|
}, compileVue = async (entryPoints, vueRootDir, isDev = false) => {
|
|
216
|
-
const compiledOutputRoot =
|
|
217
|
-
const clientOutputDir =
|
|
218
|
-
const indexOutputDir =
|
|
219
|
-
const serverOutputDir =
|
|
220
|
-
const cssOutputDir =
|
|
390
|
+
const compiledOutputRoot = join4(vueRootDir, "compiled");
|
|
391
|
+
const clientOutputDir = join4(compiledOutputRoot, "client");
|
|
392
|
+
const indexOutputDir = join4(compiledOutputRoot, "indexes");
|
|
393
|
+
const serverOutputDir = join4(compiledOutputRoot, "pages");
|
|
394
|
+
const cssOutputDir = join4(compiledOutputRoot, "styles");
|
|
221
395
|
await Promise.all([
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
396
|
+
mkdir3(clientOutputDir, { recursive: true }),
|
|
397
|
+
mkdir3(indexOutputDir, { recursive: true }),
|
|
398
|
+
mkdir3(serverOutputDir, { recursive: true }),
|
|
399
|
+
mkdir3(cssOutputDir, { recursive: true })
|
|
226
400
|
]);
|
|
227
401
|
const buildCache = new Map;
|
|
228
402
|
const allTsHelperPaths = new Set;
|
|
229
403
|
const compiledPages = await Promise.all(entryPoints.map(async (entryPath) => {
|
|
230
|
-
const result = await compileVueFile(
|
|
404
|
+
const result = await compileVueFile(resolve5(entryPath), {
|
|
231
405
|
client: clientOutputDir,
|
|
232
406
|
css: cssOutputDir,
|
|
233
407
|
server: serverOutputDir
|
|
234
408
|
}, buildCache, true, vueRootDir);
|
|
235
409
|
result.tsHelperPaths.forEach((path) => allTsHelperPaths.add(path));
|
|
236
|
-
const entryBaseName =
|
|
237
|
-
const indexOutputFile =
|
|
238
|
-
const clientOutputFile =
|
|
239
|
-
await
|
|
410
|
+
const entryBaseName = basename3(entryPath, ".vue");
|
|
411
|
+
const indexOutputFile = join4(indexOutputDir, `${entryBaseName}.js`);
|
|
412
|
+
const clientOutputFile = join4(clientOutputDir, relative3(vueRootDir, entryPath).replace(/\\/g, "/").replace(/\.vue$/, ".js"));
|
|
413
|
+
await mkdir3(dirname2(indexOutputFile), { recursive: true });
|
|
240
414
|
const vueHmrImports = isDev ? [
|
|
241
415
|
`window.__HMR_FRAMEWORK__ = "vue";`,
|
|
242
|
-
`import "${
|
|
416
|
+
`import "${hmrClientPath4}";`
|
|
243
417
|
] : [];
|
|
244
418
|
await write2(indexOutputFile, [
|
|
245
419
|
...vueHmrImports,
|
|
246
|
-
`import Comp from "${
|
|
420
|
+
`import Comp from "${relative3(dirname2(indexOutputFile), clientOutputFile).replace(/\\/g, "/")}";`,
|
|
247
421
|
'import { createSSRApp } from "vue";',
|
|
248
422
|
"",
|
|
249
423
|
"// HMR State Preservation: Check for preserved state from HMR",
|
|
250
424
|
'let preservedState = (typeof window !== "undefined" && window.__HMR_PRESERVED_STATE__) ? window.__HMR_PRESERVED_STATE__ : {};',
|
|
251
425
|
"",
|
|
252
|
-
"// Fallback: check sessionStorage if window state is empty",
|
|
253
|
-
'if (typeof window !== "undefined" && Object.keys(preservedState).length === 0) {',
|
|
426
|
+
"// Fallback: check sessionStorage if window state is empty (only during active HMR, not full page refresh)",
|
|
427
|
+
'if (typeof window !== "undefined" && Object.keys(preservedState).length === 0 && sessionStorage.getItem("__HMR_ACTIVE__")) {',
|
|
254
428
|
" try {",
|
|
255
429
|
' const stored = sessionStorage.getItem("__VUE_HMR_STATE__");',
|
|
256
430
|
" if (stored) {",
|
|
@@ -259,6 +433,10 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
259
433
|
" }",
|
|
260
434
|
" } catch (e) {}",
|
|
261
435
|
"}",
|
|
436
|
+
"// Clean up stale HMR state on full page refresh",
|
|
437
|
+
'if (typeof window !== "undefined" && !sessionStorage.getItem("__HMR_ACTIVE__")) {',
|
|
438
|
+
' sessionStorage.removeItem("__VUE_HMR_STATE__");',
|
|
439
|
+
"}",
|
|
262
440
|
"",
|
|
263
441
|
"const initialProps = window.__INITIAL_PROPS__ ?? {};",
|
|
264
442
|
"// Only merge preserved state keys that match declared props (avoids passing refs/components as attributes)",
|
|
@@ -338,11 +516,11 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
338
516
|
await Promise.all(Array.from(allTsHelperPaths).map(async (tsPath) => {
|
|
339
517
|
const sourceCode = await file2(tsPath).text();
|
|
340
518
|
const transpiledCode = transpiler2.transformSync(sourceCode);
|
|
341
|
-
const relativeJsPath =
|
|
342
|
-
const outClientPath =
|
|
343
|
-
const outServerPath =
|
|
344
|
-
await
|
|
345
|
-
await
|
|
519
|
+
const relativeJsPath = relative3(vueRootDir, tsPath).replace(/\.ts$/, ".js");
|
|
520
|
+
const outClientPath = join4(clientOutputDir, relativeJsPath);
|
|
521
|
+
const outServerPath = join4(serverOutputDir, relativeJsPath);
|
|
522
|
+
await mkdir3(dirname2(outClientPath), { recursive: true });
|
|
523
|
+
await mkdir3(dirname2(outServerPath), { recursive: true });
|
|
346
524
|
await write2(outClientPath, transpiledCode);
|
|
347
525
|
await write2(outServerPath, transpiledCode);
|
|
348
526
|
}));
|
|
@@ -355,13 +533,13 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
355
533
|
};
|
|
356
534
|
};
|
|
357
535
|
var init_compileVue = __esm(() => {
|
|
358
|
-
|
|
359
|
-
const fromSource =
|
|
360
|
-
if (
|
|
536
|
+
devClientDir3 = (() => {
|
|
537
|
+
const fromSource = resolve5(import.meta.dir, "../dev/client");
|
|
538
|
+
if (existsSync4(fromSource))
|
|
361
539
|
return fromSource;
|
|
362
|
-
return
|
|
540
|
+
return resolve5(import.meta.dir, "./dev/client");
|
|
363
541
|
})();
|
|
364
|
-
|
|
542
|
+
hmrClientPath4 = join4(devClientDir3, "hmrClient.ts").replace(/\\/g, "/");
|
|
365
543
|
transpiler2 = new Transpiler2({ loader: "ts", target: "browser" });
|
|
366
544
|
scriptCache = new Map;
|
|
367
545
|
scriptSetupCache = new Map;
|
|
@@ -401,71 +579,6 @@ var handleHTMLUpdate = async (htmlFilePath) => {
|
|
|
401
579
|
};
|
|
402
580
|
var init_simpleHTMLHMR = () => {};
|
|
403
581
|
|
|
404
|
-
// src/utils/escapeScriptContent.ts
|
|
405
|
-
var ESCAPE_LOOKUP, ESCAPE_REGEX, escapeScriptContent = (content) => content.replace(ESCAPE_REGEX, (char) => {
|
|
406
|
-
const escaped = ESCAPE_LOOKUP[char];
|
|
407
|
-
return escaped !== undefined ? escaped : char;
|
|
408
|
-
});
|
|
409
|
-
var init_escapeScriptContent = __esm(() => {
|
|
410
|
-
ESCAPE_LOOKUP = {
|
|
411
|
-
"\u2028": "\\u2028",
|
|
412
|
-
"\u2029": "\\u2029",
|
|
413
|
-
"&": "\\u0026",
|
|
414
|
-
"<": "\\u003C",
|
|
415
|
-
">": "\\u003E"
|
|
416
|
-
};
|
|
417
|
-
ESCAPE_REGEX = /[&><\u2028\u2029]/g;
|
|
418
|
-
});
|
|
419
|
-
|
|
420
|
-
// src/svelte/renderToReadableStream.ts
|
|
421
|
-
import { render } from "svelte/server";
|
|
422
|
-
var renderToReadableStream = async (component, props, {
|
|
423
|
-
bootstrapScriptContent,
|
|
424
|
-
bootstrapScripts = [],
|
|
425
|
-
bootstrapModules = [],
|
|
426
|
-
nonce,
|
|
427
|
-
onError = console.error,
|
|
428
|
-
progressiveChunkSize = DEFAULT_CHUNK_SIZE,
|
|
429
|
-
signal,
|
|
430
|
-
headContent,
|
|
431
|
-
bodyContent
|
|
432
|
-
} = {}) => {
|
|
433
|
-
try {
|
|
434
|
-
const { head, body } = typeof props === "undefined" ? render(component) : render(component, { props });
|
|
435
|
-
const nonceAttr = nonce ? ` nonce="${nonce}"` : "";
|
|
436
|
-
const scripts = (bootstrapScriptContent ? `<script${nonceAttr}>${escapeScriptContent(bootstrapScriptContent)}</script>` : "") + bootstrapScripts.map((src) => `<script${nonceAttr} src="${src}"></script>`).join("") + bootstrapModules.map((src) => `<script${nonceAttr} type="module" src="${src}"></script>`).join("");
|
|
437
|
-
const encoder = new TextEncoder;
|
|
438
|
-
const full = encoder.encode(`<!DOCTYPE html><html lang="en"><head>${head}${headContent ?? ""}</head><body>${body}${scripts}${bodyContent ?? ""}</body></html>`);
|
|
439
|
-
let offset = 0;
|
|
440
|
-
return new ReadableStream({
|
|
441
|
-
type: "bytes",
|
|
442
|
-
cancel(reason) {
|
|
443
|
-
onError?.(reason);
|
|
444
|
-
},
|
|
445
|
-
pull(controller) {
|
|
446
|
-
if (signal?.aborted) {
|
|
447
|
-
controller.close();
|
|
448
|
-
return;
|
|
449
|
-
}
|
|
450
|
-
if (offset >= full.length) {
|
|
451
|
-
controller.close();
|
|
452
|
-
return;
|
|
453
|
-
}
|
|
454
|
-
const end = Math.min(offset + progressiveChunkSize, full.length);
|
|
455
|
-
controller.enqueue(full.subarray(offset, end));
|
|
456
|
-
offset = end;
|
|
457
|
-
}
|
|
458
|
-
});
|
|
459
|
-
} catch (error) {
|
|
460
|
-
onError?.(error);
|
|
461
|
-
throw error;
|
|
462
|
-
}
|
|
463
|
-
};
|
|
464
|
-
var init_renderToReadableStream = __esm(() => {
|
|
465
|
-
init_constants();
|
|
466
|
-
init_escapeScriptContent();
|
|
467
|
-
});
|
|
468
|
-
|
|
469
582
|
// src/utils/ssrErrorPage.ts
|
|
470
583
|
var ssrErrorPage = (framework, error) => {
|
|
471
584
|
const frameworkColors2 = {
|
|
@@ -518,60 +631,14 @@ body{min-height:100vh;background:linear-gradient(135deg,rgba(15,23,42,0.98) 0%,r
|
|
|
518
631
|
</html>`;
|
|
519
632
|
};
|
|
520
633
|
|
|
521
|
-
// src/
|
|
522
|
-
var
|
|
523
|
-
__export(
|
|
524
|
-
handleVuePageRequest: () => handleVuePageRequest
|
|
525
|
-
handleSveltePageRequest: () => handleSveltePageRequest,
|
|
526
|
-
handleReactPageRequest: () => handleReactPageRequest,
|
|
527
|
-
handlePageRequest: () => handlePageRequest,
|
|
528
|
-
handleHTMXPageRequest: () => handleHTMXPageRequest,
|
|
529
|
-
handleHTMLPageRequest: () => handleHTMLPageRequest
|
|
634
|
+
// src/vue/pageHandler.ts
|
|
635
|
+
var exports_pageHandler = {};
|
|
636
|
+
__export(exports_pageHandler, {
|
|
637
|
+
handleVuePageRequest: () => handleVuePageRequest
|
|
530
638
|
});
|
|
531
|
-
var {file: file3 } = globalThis.Bun;
|
|
532
|
-
import { createElement } from "react";
|
|
533
|
-
import { renderToReadableStream as renderReactToReadableStream } from "react-dom/server";
|
|
534
639
|
import { createSSRApp, h } from "vue";
|
|
535
640
|
import { renderToWebStream as renderVueToWebStream } from "vue/server-renderer";
|
|
536
|
-
var
|
|
537
|
-
try {
|
|
538
|
-
const [maybeProps] = props;
|
|
539
|
-
const element = maybeProps !== undefined ? createElement(PageComponent, maybeProps) : createElement(PageComponent);
|
|
540
|
-
const stream = await renderReactToReadableStream(element, {
|
|
541
|
-
bootstrapModules: [index],
|
|
542
|
-
bootstrapScriptContent: maybeProps ? `window.__INITIAL_PROPS__=${JSON.stringify(maybeProps)}` : undefined,
|
|
543
|
-
onError(error) {
|
|
544
|
-
console.error("[SSR] React streaming error:", error);
|
|
545
|
-
}
|
|
546
|
-
});
|
|
547
|
-
return new Response(stream, {
|
|
548
|
-
headers: { "Content-Type": "text/html" }
|
|
549
|
-
});
|
|
550
|
-
} catch (error) {
|
|
551
|
-
console.error("[SSR] React render error:", error);
|
|
552
|
-
return new Response(ssrErrorPage("react", error), {
|
|
553
|
-
status: 500,
|
|
554
|
-
headers: { "Content-Type": "text/html" }
|
|
555
|
-
});
|
|
556
|
-
}
|
|
557
|
-
}, handleSveltePageRequest = async (_PageComponent, pagePath, indexPath, props) => {
|
|
558
|
-
try {
|
|
559
|
-
const { default: ImportedPageComponent } = await import(pagePath);
|
|
560
|
-
const stream = await renderToReadableStream(ImportedPageComponent, props, {
|
|
561
|
-
bootstrapModules: indexPath ? [indexPath] : [],
|
|
562
|
-
bootstrapScriptContent: `window.__INITIAL_PROPS__=${JSON.stringify(props)}`
|
|
563
|
-
});
|
|
564
|
-
return new Response(stream, {
|
|
565
|
-
headers: { "Content-Type": "text/html" }
|
|
566
|
-
});
|
|
567
|
-
} catch (error) {
|
|
568
|
-
console.error("[SSR] Svelte render error:", error);
|
|
569
|
-
return new Response(ssrErrorPage("svelte", error), {
|
|
570
|
-
status: 500,
|
|
571
|
-
headers: { "Content-Type": "text/html" }
|
|
572
|
-
});
|
|
573
|
-
}
|
|
574
|
-
}, handleVuePageRequest = async (_PageComponent, pagePath, indexPath, headTag = "<head></head>", ...props) => {
|
|
641
|
+
var handleVuePageRequest = async (_PageComponent, pagePath, indexPath, headTag = "<head></head>", ...props) => {
|
|
575
642
|
try {
|
|
576
643
|
const [maybeProps] = props;
|
|
577
644
|
const { default: ImportedPageComponent } = await import(pagePath);
|
|
@@ -601,12 +668,8 @@ var handleReactPageRequest = async (PageComponent, index, ...props) => {
|
|
|
601
668
|
headers: { "Content-Type": "text/html" }
|
|
602
669
|
});
|
|
603
670
|
}
|
|
604
|
-
}, handleHTMLPageRequest = (pagePath) => file3(pagePath), handleHTMXPageRequest = (pagePath) => file3(pagePath), handlePageRequest = (PageComponent, ...props) => {
|
|
605
|
-
console.log("handlePageRequest coming soon.", PageComponent, props);
|
|
606
671
|
};
|
|
607
|
-
var
|
|
608
|
-
init_renderToReadableStream();
|
|
609
|
-
});
|
|
672
|
+
var init_pageHandler = () => {};
|
|
610
673
|
|
|
611
674
|
// src/utils/generateHeadElement.ts
|
|
612
675
|
var exports_generateHeadElement = {};
|
|
@@ -664,7 +727,7 @@ var handleVueUpdate = async (vueFilePath, manifest, buildDir) => {
|
|
|
664
727
|
console.warn("[Vue HMR] Index path not found in manifest for:", indexKey);
|
|
665
728
|
return null;
|
|
666
729
|
}
|
|
667
|
-
const { handleVuePageRequest: handleVuePageRequest2 } = await Promise.resolve().then(() => (
|
|
730
|
+
const { handleVuePageRequest: handleVuePageRequest2 } = await Promise.resolve().then(() => (init_pageHandler(), exports_pageHandler));
|
|
668
731
|
const { generateHeadElement: generateHeadElement2 } = await Promise.resolve().then(() => exports_generateHeadElement);
|
|
669
732
|
const response = await handleVuePageRequest2(serverModule.default, serverPath, indexPath, generateHeadElement2({
|
|
670
733
|
cssPath: manifest[cssKey] || "",
|
|
@@ -684,6 +747,98 @@ var handleVueUpdate = async (vueFilePath, manifest, buildDir) => {
|
|
|
684
747
|
};
|
|
685
748
|
var init_simpleVueHMR = () => {};
|
|
686
749
|
|
|
750
|
+
// src/utils/escapeScriptContent.ts
|
|
751
|
+
var ESCAPE_LOOKUP, ESCAPE_REGEX, escapeScriptContent = (content) => content.replace(ESCAPE_REGEX, (char) => {
|
|
752
|
+
const escaped = ESCAPE_LOOKUP[char];
|
|
753
|
+
return escaped !== undefined ? escaped : char;
|
|
754
|
+
});
|
|
755
|
+
var init_escapeScriptContent = __esm(() => {
|
|
756
|
+
ESCAPE_LOOKUP = {
|
|
757
|
+
"\u2028": "\\u2028",
|
|
758
|
+
"\u2029": "\\u2029",
|
|
759
|
+
"&": "\\u0026",
|
|
760
|
+
"<": "\\u003C",
|
|
761
|
+
">": "\\u003E"
|
|
762
|
+
};
|
|
763
|
+
ESCAPE_REGEX = /[&><\u2028\u2029]/g;
|
|
764
|
+
});
|
|
765
|
+
|
|
766
|
+
// src/svelte/renderToReadableStream.ts
|
|
767
|
+
import { render } from "svelte/server";
|
|
768
|
+
var renderToReadableStream = async (component, props, {
|
|
769
|
+
bootstrapScriptContent,
|
|
770
|
+
bootstrapScripts = [],
|
|
771
|
+
bootstrapModules = [],
|
|
772
|
+
nonce,
|
|
773
|
+
onError = console.error,
|
|
774
|
+
progressiveChunkSize = DEFAULT_CHUNK_SIZE,
|
|
775
|
+
signal,
|
|
776
|
+
headContent,
|
|
777
|
+
bodyContent
|
|
778
|
+
} = {}) => {
|
|
779
|
+
try {
|
|
780
|
+
const { head, body } = typeof props === "undefined" ? render(component) : render(component, { props });
|
|
781
|
+
const nonceAttr = nonce ? ` nonce="${nonce}"` : "";
|
|
782
|
+
const scripts = (bootstrapScriptContent ? `<script${nonceAttr}>${escapeScriptContent(bootstrapScriptContent)}</script>` : "") + bootstrapScripts.map((src) => `<script${nonceAttr} src="${src}"></script>`).join("") + bootstrapModules.map((src) => `<script${nonceAttr} type="module" src="${src}"></script>`).join("");
|
|
783
|
+
const encoder = new TextEncoder;
|
|
784
|
+
const full = encoder.encode(`<!DOCTYPE html><html lang="en"><head>${head}${headContent ?? ""}</head><body>${body}${scripts}${bodyContent ?? ""}</body></html>`);
|
|
785
|
+
let offset = 0;
|
|
786
|
+
return new ReadableStream({
|
|
787
|
+
type: "bytes",
|
|
788
|
+
cancel(reason) {
|
|
789
|
+
onError?.(reason);
|
|
790
|
+
},
|
|
791
|
+
pull(controller) {
|
|
792
|
+
if (signal?.aborted) {
|
|
793
|
+
controller.close();
|
|
794
|
+
return;
|
|
795
|
+
}
|
|
796
|
+
if (offset >= full.length) {
|
|
797
|
+
controller.close();
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
const end = Math.min(offset + progressiveChunkSize, full.length);
|
|
801
|
+
controller.enqueue(full.subarray(offset, end));
|
|
802
|
+
offset = end;
|
|
803
|
+
}
|
|
804
|
+
});
|
|
805
|
+
} catch (error) {
|
|
806
|
+
onError?.(error);
|
|
807
|
+
throw error;
|
|
808
|
+
}
|
|
809
|
+
};
|
|
810
|
+
var init_renderToReadableStream = __esm(() => {
|
|
811
|
+
init_constants();
|
|
812
|
+
init_escapeScriptContent();
|
|
813
|
+
});
|
|
814
|
+
|
|
815
|
+
// src/svelte/pageHandler.ts
|
|
816
|
+
var exports_pageHandler2 = {};
|
|
817
|
+
__export(exports_pageHandler2, {
|
|
818
|
+
handleSveltePageRequest: () => handleSveltePageRequest
|
|
819
|
+
});
|
|
820
|
+
var handleSveltePageRequest = async (_PageComponent, pagePath, indexPath, props) => {
|
|
821
|
+
try {
|
|
822
|
+
const { default: ImportedPageComponent } = await import(pagePath);
|
|
823
|
+
const stream = await renderToReadableStream(ImportedPageComponent, props, {
|
|
824
|
+
bootstrapModules: indexPath ? [indexPath] : [],
|
|
825
|
+
bootstrapScriptContent: `window.__INITIAL_PROPS__=${JSON.stringify(props)}`
|
|
826
|
+
});
|
|
827
|
+
return new Response(stream, {
|
|
828
|
+
headers: { "Content-Type": "text/html" }
|
|
829
|
+
});
|
|
830
|
+
} catch (error) {
|
|
831
|
+
console.error("[SSR] Svelte render error:", error);
|
|
832
|
+
return new Response(ssrErrorPage("svelte", error), {
|
|
833
|
+
status: 500,
|
|
834
|
+
headers: { "Content-Type": "text/html" }
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
};
|
|
838
|
+
var init_pageHandler2 = __esm(() => {
|
|
839
|
+
init_renderToReadableStream();
|
|
840
|
+
});
|
|
841
|
+
|
|
687
842
|
// src/dev/simpleSvelteHMR.ts
|
|
688
843
|
var exports_simpleSvelteHMR = {};
|
|
689
844
|
__export(exports_simpleSvelteHMR, {
|
|
@@ -717,7 +872,7 @@ var handleSvelteUpdate = async (svelteFilePath, manifest, buildDir) => {
|
|
|
717
872
|
console.warn("[Svelte HMR] Index path not found in manifest for:", indexKey);
|
|
718
873
|
return null;
|
|
719
874
|
}
|
|
720
|
-
const { handleSveltePageRequest: handleSveltePageRequest2 } = await Promise.resolve().then(() => (
|
|
875
|
+
const { handleSveltePageRequest: handleSveltePageRequest2 } = await Promise.resolve().then(() => (init_pageHandler2(), exports_pageHandler2));
|
|
721
876
|
const response = await handleSveltePageRequest2(serverModule.default, serverPath, indexPath, {
|
|
722
877
|
cssPath: manifest[cssKey] || "",
|
|
723
878
|
initialCount: 0
|
|
@@ -814,182 +969,9 @@ import { basename as basename4, join as join5, resolve as resolve6 } from "path"
|
|
|
814
969
|
import { cwd, env as env2, exit } from "process";
|
|
815
970
|
var {$, build: bunBuild2, Glob: Glob3 } = globalThis.Bun;
|
|
816
971
|
|
|
817
|
-
// src/build/compileSvelte.ts
|
|
818
|
-
import { existsSync } from "fs";
|
|
819
|
-
import { mkdir, stat } from "fs/promises";
|
|
820
|
-
import {
|
|
821
|
-
dirname,
|
|
822
|
-
join,
|
|
823
|
-
basename,
|
|
824
|
-
extname,
|
|
825
|
-
resolve,
|
|
826
|
-
relative,
|
|
827
|
-
sep
|
|
828
|
-
} from "path";
|
|
829
|
-
import { env } from "process";
|
|
830
|
-
var {write, file, Transpiler } = globalThis.Bun;
|
|
831
|
-
import { compile, compileModule, preprocess } from "svelte/compiler";
|
|
832
|
-
var devClientDir = (() => {
|
|
833
|
-
const fromSource = resolve(import.meta.dir, "../dev/client");
|
|
834
|
-
if (existsSync(fromSource))
|
|
835
|
-
return fromSource;
|
|
836
|
-
return resolve(import.meta.dir, "./dev/client");
|
|
837
|
-
})();
|
|
838
|
-
var hmrClientPath = join(devClientDir, "hmrClient.ts").replace(/\\/g, "/");
|
|
839
|
-
var transpiler = new Transpiler({ loader: "ts", target: "browser" });
|
|
840
|
-
var exists = async (path) => {
|
|
841
|
-
try {
|
|
842
|
-
await stat(path);
|
|
843
|
-
return true;
|
|
844
|
-
} catch {
|
|
845
|
-
return false;
|
|
846
|
-
}
|
|
847
|
-
};
|
|
848
|
-
var resolveSvelte = async (spec, from) => {
|
|
849
|
-
const basePath = resolve(dirname(from), spec);
|
|
850
|
-
const explicit = /\.(svelte|svelte\.(?:ts|js))$/.test(basePath);
|
|
851
|
-
if (!explicit) {
|
|
852
|
-
const extensions = [".svelte", ".svelte.ts", ".svelte.js"];
|
|
853
|
-
const paths = extensions.map((ext) => `${basePath}${ext}`);
|
|
854
|
-
const checks = await Promise.all(paths.map(exists));
|
|
855
|
-
const match = paths.find((_, index) => checks[index]);
|
|
856
|
-
return match ?? null;
|
|
857
|
-
}
|
|
858
|
-
if (await exists(basePath))
|
|
859
|
-
return basePath;
|
|
860
|
-
if (!basePath.endsWith(".svelte"))
|
|
861
|
-
return null;
|
|
862
|
-
const tsPath = `${basePath}.ts`;
|
|
863
|
-
if (await exists(tsPath))
|
|
864
|
-
return tsPath;
|
|
865
|
-
const jsPath = `${basePath}.js`;
|
|
866
|
-
if (await exists(jsPath))
|
|
867
|
-
return jsPath;
|
|
868
|
-
return null;
|
|
869
|
-
};
|
|
870
|
-
var compileSvelte = async (entryPoints, svelteRoot, cache = new Map, isDev = false) => {
|
|
871
|
-
const compiledRoot = join(svelteRoot, "compiled");
|
|
872
|
-
const clientDir = join(compiledRoot, "client");
|
|
873
|
-
const indexDir = join(compiledRoot, "indexes");
|
|
874
|
-
const pagesDir = join(compiledRoot, "pages");
|
|
875
|
-
await Promise.all([clientDir, indexDir, pagesDir].map((dir) => mkdir(dir, { recursive: true })));
|
|
876
|
-
const dev = env.NODE_ENV !== "production";
|
|
877
|
-
const build2 = async (src) => {
|
|
878
|
-
const memoized = cache.get(src);
|
|
879
|
-
if (memoized)
|
|
880
|
-
return memoized;
|
|
881
|
-
const raw = await file(src).text();
|
|
882
|
-
const isModule = src.endsWith(".svelte.ts") || src.endsWith(".svelte.js");
|
|
883
|
-
const preprocessed = isModule ? raw : (await preprocess(raw, {})).code;
|
|
884
|
-
const transpiled = src.endsWith(".ts") || src.endsWith(".svelte.ts") ? transpiler.transformSync(preprocessed) : preprocessed;
|
|
885
|
-
const relDir = dirname(relative(svelteRoot, src)).replace(/\\/g, "/");
|
|
886
|
-
const baseName = basename(src).replace(/\.svelte(\.(ts|js))?$/, "");
|
|
887
|
-
const importPaths = Array.from(transpiled.matchAll(/from\s+['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((path) => path !== undefined);
|
|
888
|
-
const resolvedImports = await Promise.all(importPaths.map((importPath) => resolveSvelte(importPath, src)));
|
|
889
|
-
const childSources = resolvedImports.filter((path) => path !== null);
|
|
890
|
-
await Promise.all(childSources.map((child) => build2(child)));
|
|
891
|
-
const generate = (mode) => (isModule ? compileModule(transpiled, {
|
|
892
|
-
dev: mode === "client" && dev,
|
|
893
|
-
filename: src
|
|
894
|
-
}).js.code : compile(transpiled, {
|
|
895
|
-
css: "injected",
|
|
896
|
-
dev: mode === "client" && dev,
|
|
897
|
-
filename: src,
|
|
898
|
-
generate: mode
|
|
899
|
-
}).js.code).replace(/\.svelte(?:\.(?:ts|js))?(['"])/g, ".js$1");
|
|
900
|
-
const ssrPath = join(pagesDir, relDir, `${baseName}.js`);
|
|
901
|
-
const clientPath = join(clientDir, relDir, `${baseName}.js`);
|
|
902
|
-
await Promise.all([
|
|
903
|
-
mkdir(dirname(ssrPath), { recursive: true }),
|
|
904
|
-
mkdir(dirname(clientPath), { recursive: true })
|
|
905
|
-
]);
|
|
906
|
-
if (isModule) {
|
|
907
|
-
const bundle = generate("client");
|
|
908
|
-
await Promise.all([
|
|
909
|
-
write(ssrPath, bundle),
|
|
910
|
-
write(clientPath, bundle)
|
|
911
|
-
]);
|
|
912
|
-
} else {
|
|
913
|
-
const serverBundle = generate("server");
|
|
914
|
-
const clientBundle = generate("client");
|
|
915
|
-
await Promise.all([
|
|
916
|
-
write(ssrPath, serverBundle),
|
|
917
|
-
write(clientPath, clientBundle)
|
|
918
|
-
]);
|
|
919
|
-
}
|
|
920
|
-
const built = { client: clientPath, ssr: ssrPath };
|
|
921
|
-
cache.set(src, built);
|
|
922
|
-
return built;
|
|
923
|
-
};
|
|
924
|
-
const roots = await Promise.all(entryPoints.map(build2));
|
|
925
|
-
await Promise.all(roots.map(async ({ client: client2 }) => {
|
|
926
|
-
const relClientDir = dirname(relative(clientDir, client2));
|
|
927
|
-
const name = basename(client2, extname(client2));
|
|
928
|
-
const indexPath = join(indexDir, relClientDir, `${name}.js`);
|
|
929
|
-
const importRaw = relative(dirname(indexPath), client2).split(sep).join("/");
|
|
930
|
-
const importPath = importRaw.startsWith(".") || importRaw.startsWith("/") ? importRaw : `./${importRaw}`;
|
|
931
|
-
const hmrImports = isDev ? `window.__HMR_FRAMEWORK__ = "svelte";
|
|
932
|
-
import "${hmrClientPath}";
|
|
933
|
-
` : "";
|
|
934
|
-
const bootstrap = `${hmrImports}import Component from "${importPath}";
|
|
935
|
-
import { hydrate, mount, unmount } from "svelte";
|
|
936
|
-
|
|
937
|
-
var initialProps = (typeof window !== "undefined" && window.__INITIAL_PROPS__) ? window.__INITIAL_PROPS__ : {};
|
|
938
|
-
var isHMR = typeof window !== "undefined" && window.__SVELTE_COMPONENT__ !== undefined;
|
|
939
|
-
var component;
|
|
940
|
-
|
|
941
|
-
if (isHMR) {
|
|
942
|
-
var headLinks = document.querySelectorAll('link[rel="stylesheet"]');
|
|
943
|
-
var preservedLinks = [];
|
|
944
|
-
headLinks.forEach(function(link) {
|
|
945
|
-
var clone = link.cloneNode(true);
|
|
946
|
-
clone.setAttribute("data-hmr-preserve", "true");
|
|
947
|
-
document.head.appendChild(clone);
|
|
948
|
-
preservedLinks.push(clone);
|
|
949
|
-
});
|
|
950
|
-
if (typeof window.__SVELTE_UNMOUNT__ === "function") {
|
|
951
|
-
try { window.__SVELTE_UNMOUNT__(); } catch (err) { console.warn("[HMR] unmount error:", err); }
|
|
952
|
-
}
|
|
953
|
-
var preservedState = window.__HMR_PRESERVED_STATE__;
|
|
954
|
-
if (!preservedState) {
|
|
955
|
-
try {
|
|
956
|
-
var stored = sessionStorage.getItem("__SVELTE_HMR_STATE__");
|
|
957
|
-
if (stored) preservedState = JSON.parse(stored);
|
|
958
|
-
} catch (err) { /* ignore */ }
|
|
959
|
-
}
|
|
960
|
-
var mergedProps = preservedState ? Object.assign({}, initialProps, preservedState) : initialProps;
|
|
961
|
-
component = mount(Component, { target: document.body, props: mergedProps });
|
|
962
|
-
requestAnimationFrame(function() {
|
|
963
|
-
preservedLinks.forEach(function(link) { link.remove(); });
|
|
964
|
-
});
|
|
965
|
-
window.__HMR_PRESERVED_STATE__ = undefined;
|
|
966
|
-
} else {
|
|
967
|
-
component = hydrate(Component, { target: document.body, props: initialProps });
|
|
968
|
-
}
|
|
969
|
-
|
|
970
|
-
if (typeof window !== "undefined") {
|
|
971
|
-
window.__SVELTE_COMPONENT__ = component;
|
|
972
|
-
window.__SVELTE_UNMOUNT__ = function() { unmount(component); };
|
|
973
|
-
}`;
|
|
974
|
-
await mkdir(dirname(indexPath), { recursive: true });
|
|
975
|
-
return write(indexPath, bootstrap);
|
|
976
|
-
}));
|
|
977
|
-
return {
|
|
978
|
-
svelteIndexPaths: roots.map(({ client: client2 }) => {
|
|
979
|
-
const rel = dirname(relative(clientDir, client2));
|
|
980
|
-
return join(indexDir, rel, basename(client2));
|
|
981
|
-
}),
|
|
982
|
-
svelteClientPaths: roots.map(({ client: client2 }) => client2),
|
|
983
|
-
svelteServerPaths: roots.map(({ ssr }) => ssr)
|
|
984
|
-
};
|
|
985
|
-
};
|
|
986
|
-
|
|
987
|
-
// src/core/build.ts
|
|
988
|
-
init_compileVue();
|
|
989
|
-
|
|
990
972
|
// src/build/generateManifest.ts
|
|
991
973
|
init_constants();
|
|
992
|
-
import { extname
|
|
974
|
+
import { extname } from "path";
|
|
993
975
|
|
|
994
976
|
// src/utils/normalizePath.ts
|
|
995
977
|
var normalizePath = (path) => path.replace(/\\/g, "/");
|
|
@@ -998,9 +980,9 @@ var normalizePath = (path) => path.replace(/\\/g, "/");
|
|
|
998
980
|
var generateManifest = (outputs, buildPath) => outputs.reduce((manifest, artifact) => {
|
|
999
981
|
const normalizedArtifactPath = normalizePath(artifact.path);
|
|
1000
982
|
const normalizedBuildPath = normalizePath(buildPath);
|
|
1001
|
-
let
|
|
1002
|
-
|
|
1003
|
-
const segments =
|
|
983
|
+
let relative = normalizedArtifactPath.startsWith(normalizedBuildPath) ? normalizedArtifactPath.slice(normalizedBuildPath.length) : normalizedArtifactPath;
|
|
984
|
+
relative = relative.replace(/^\/+/, "");
|
|
985
|
+
const segments = relative.split("/");
|
|
1004
986
|
const fileWithHash = segments.pop();
|
|
1005
987
|
if (!fileWithHash)
|
|
1006
988
|
return manifest;
|
|
@@ -1008,9 +990,9 @@ var generateManifest = (outputs, buildPath) => outputs.reduce((manifest, artifac
|
|
|
1008
990
|
if (!baseName)
|
|
1009
991
|
return manifest;
|
|
1010
992
|
const pascalName = toPascal(baseName);
|
|
1011
|
-
const ext =
|
|
993
|
+
const ext = extname(fileWithHash);
|
|
1012
994
|
if (ext === ".css") {
|
|
1013
|
-
manifest[`${pascalName}CSS`] = `/${
|
|
995
|
+
manifest[`${pascalName}CSS`] = `/${relative}`;
|
|
1014
996
|
return manifest;
|
|
1015
997
|
}
|
|
1016
998
|
const idx = segments.findIndex((seg) => seg === "indexes" || seg === "pages" || seg === "client");
|
|
@@ -1020,53 +1002,53 @@ var generateManifest = (outputs, buildPath) => outputs.reduce((manifest, artifac
|
|
|
1020
1002
|
const isSvelte = segments.some((seg) => seg === "svelte");
|
|
1021
1003
|
const isClientComponent = segments.includes("client");
|
|
1022
1004
|
if (folder === "indexes") {
|
|
1023
|
-
manifest[`${pascalName}Index`] = `/${
|
|
1005
|
+
manifest[`${pascalName}Index`] = `/${relative}`;
|
|
1024
1006
|
} else if (isClientComponent) {
|
|
1025
|
-
manifest[`${pascalName}Client`] = `/${
|
|
1007
|
+
manifest[`${pascalName}Client`] = `/${relative}`;
|
|
1026
1008
|
} else if (folder === "pages") {
|
|
1027
1009
|
if (isReact) {
|
|
1028
|
-
manifest[`${pascalName}Page`] = `/${
|
|
1010
|
+
manifest[`${pascalName}Page`] = `/${relative}`;
|
|
1029
1011
|
} else if (isVue || isSvelte) {
|
|
1030
|
-
manifest[pascalName] = `/${
|
|
1012
|
+
manifest[pascalName] = `/${relative}`;
|
|
1031
1013
|
} else {
|
|
1032
|
-
manifest[`${pascalName}Page`] = `/${
|
|
1014
|
+
manifest[`${pascalName}Page`] = `/${relative}`;
|
|
1033
1015
|
}
|
|
1034
1016
|
} else {
|
|
1035
|
-
manifest[pascalName] = `/${
|
|
1017
|
+
manifest[pascalName] = `/${relative}`;
|
|
1036
1018
|
}
|
|
1037
1019
|
return manifest;
|
|
1038
1020
|
}, {});
|
|
1039
1021
|
|
|
1040
1022
|
// src/build/generateReactIndexes.ts
|
|
1041
|
-
import { existsSync
|
|
1042
|
-
import { mkdir
|
|
1043
|
-
import { basename
|
|
1023
|
+
import { existsSync } from "fs";
|
|
1024
|
+
import { mkdir, rm, writeFile } from "fs/promises";
|
|
1025
|
+
import { basename, join, resolve } from "path";
|
|
1044
1026
|
var {Glob } = globalThis.Bun;
|
|
1045
|
-
var
|
|
1046
|
-
const fromSource =
|
|
1047
|
-
if (
|
|
1027
|
+
var devClientDir = (() => {
|
|
1028
|
+
const fromSource = resolve(import.meta.dir, "../dev/client");
|
|
1029
|
+
if (existsSync(fromSource))
|
|
1048
1030
|
return fromSource;
|
|
1049
|
-
return
|
|
1031
|
+
return resolve(import.meta.dir, "./dev/client");
|
|
1050
1032
|
})();
|
|
1051
|
-
var errorOverlayPath =
|
|
1052
|
-
var
|
|
1053
|
-
var refreshSetupPath =
|
|
1033
|
+
var errorOverlayPath = join(devClientDir, "errorOverlay.ts").replace(/\\/g, "/");
|
|
1034
|
+
var hmrClientPath = join(devClientDir, "hmrClient.ts").replace(/\\/g, "/");
|
|
1035
|
+
var refreshSetupPath = join(devClientDir, "reactRefreshSetup.ts").replace(/\\/g, "/");
|
|
1054
1036
|
var generateReactIndexFiles = async (reactPagesDirectory, reactIndexesDirectory, isDev = false) => {
|
|
1055
1037
|
await rm(reactIndexesDirectory, { force: true, recursive: true });
|
|
1056
|
-
await
|
|
1038
|
+
await mkdir(reactIndexesDirectory);
|
|
1057
1039
|
const pagesGlob = new Glob("*.*");
|
|
1058
1040
|
const files = [];
|
|
1059
|
-
for await (const
|
|
1060
|
-
files.push(
|
|
1041
|
+
for await (const file of pagesGlob.scan({ cwd: reactPagesDirectory })) {
|
|
1042
|
+
files.push(file);
|
|
1061
1043
|
}
|
|
1062
|
-
const promises = files.map(async (
|
|
1063
|
-
const fileName =
|
|
1044
|
+
const promises = files.map(async (file) => {
|
|
1045
|
+
const fileName = basename(file);
|
|
1064
1046
|
const [componentName] = fileName.split(".");
|
|
1065
1047
|
const hmrPreamble = isDev ? [
|
|
1066
1048
|
`window.__HMR_FRAMEWORK__ = "react";`,
|
|
1067
1049
|
`window.__REACT_COMPONENT_KEY__ = "${componentName}Index";`,
|
|
1068
1050
|
`import '${refreshSetupPath}';`,
|
|
1069
|
-
`import '${
|
|
1051
|
+
`import '${hmrClientPath}';`,
|
|
1070
1052
|
`import { showErrorOverlay, hideErrorOverlay } from '${errorOverlayPath}';
|
|
1071
1053
|
`
|
|
1072
1054
|
] : [];
|
|
@@ -1320,11 +1302,11 @@ var generateReactIndexFiles = async (reactPagesDirectory, reactIndexesDirectory,
|
|
|
1320
1302
|
`}`
|
|
1321
1303
|
].join(`
|
|
1322
1304
|
`);
|
|
1323
|
-
return writeFile(
|
|
1305
|
+
return writeFile(join(reactIndexesDirectory, `${componentName}.tsx`), content);
|
|
1324
1306
|
});
|
|
1325
1307
|
await Promise.all(promises);
|
|
1326
1308
|
if (isDev) {
|
|
1327
|
-
await writeFile(
|
|
1309
|
+
await writeFile(join(reactIndexesDirectory, "_refresh.tsx"), `import 'react';
|
|
1328
1310
|
import 'react-dom/client';
|
|
1329
1311
|
`);
|
|
1330
1312
|
}
|
|
@@ -1388,8 +1370,8 @@ var {Glob: Glob2 } = globalThis.Bun;
|
|
|
1388
1370
|
var scanEntryPoints = async (dir, pattern) => {
|
|
1389
1371
|
const entryPaths = [];
|
|
1390
1372
|
const glob = new Glob2(pattern);
|
|
1391
|
-
for await (const
|
|
1392
|
-
entryPaths.push(
|
|
1373
|
+
for await (const file of glob.scan({ absolute: true, cwd: dir })) {
|
|
1374
|
+
entryPaths.push(file);
|
|
1393
1375
|
}
|
|
1394
1376
|
return entryPaths;
|
|
1395
1377
|
};
|
|
@@ -1431,17 +1413,17 @@ var updateAssetPaths = async (manifest, directory) => {
|
|
|
1431
1413
|
};
|
|
1432
1414
|
|
|
1433
1415
|
// src/dev/buildHMRClient.ts
|
|
1434
|
-
import { existsSync as
|
|
1416
|
+
import { existsSync as existsSync2 } from "fs";
|
|
1435
1417
|
var {build: bunBuild } = globalThis.Bun;
|
|
1436
|
-
import { resolve as
|
|
1437
|
-
var
|
|
1438
|
-
const fromSource =
|
|
1439
|
-
if (
|
|
1418
|
+
import { resolve as resolve2 } from "path";
|
|
1419
|
+
var hmrClientPath2 = (() => {
|
|
1420
|
+
const fromSource = resolve2(import.meta.dir, "client/hmrClient.ts");
|
|
1421
|
+
if (existsSync2(fromSource))
|
|
1440
1422
|
return fromSource;
|
|
1441
|
-
return
|
|
1423
|
+
return resolve2(import.meta.dir, "dev/client/hmrClient.ts");
|
|
1442
1424
|
})();
|
|
1443
1425
|
var buildHMRClient = async () => {
|
|
1444
|
-
const entryPoint =
|
|
1426
|
+
const entryPoint = hmrClientPath2;
|
|
1445
1427
|
const result = await bunBuild({
|
|
1446
1428
|
entrypoints: [entryPoint],
|
|
1447
1429
|
format: "iife",
|
|
@@ -1495,18 +1477,18 @@ var getDevVendorPaths = () => devVendorPaths;
|
|
|
1495
1477
|
|
|
1496
1478
|
// src/utils/cleanup.ts
|
|
1497
1479
|
import { rm as rm2 } from "fs/promises";
|
|
1498
|
-
import { join as
|
|
1480
|
+
import { join as join2 } from "path";
|
|
1499
1481
|
var cleanup = async ({
|
|
1500
1482
|
svelteDir,
|
|
1501
1483
|
vueDir,
|
|
1502
1484
|
reactIndexesPath
|
|
1503
1485
|
}) => {
|
|
1504
1486
|
await Promise.all([
|
|
1505
|
-
svelteDir ? rm2(
|
|
1487
|
+
svelteDir ? rm2(join2(svelteDir, "compiled"), {
|
|
1506
1488
|
force: true,
|
|
1507
1489
|
recursive: true
|
|
1508
1490
|
}) : undefined,
|
|
1509
|
-
vueDir ? rm2(
|
|
1491
|
+
vueDir ? rm2(join2(vueDir, "compiled"), { force: true, recursive: true }) : undefined,
|
|
1510
1492
|
reactIndexesPath ? rm2(reactIndexesPath, { force: true, recursive: true }) : undefined
|
|
1511
1493
|
]);
|
|
1512
1494
|
};
|
|
@@ -1571,12 +1553,12 @@ var formatTimestamp = () => {
|
|
|
1571
1553
|
};
|
|
1572
1554
|
var formatPath = (filePath) => {
|
|
1573
1555
|
const cwd = process.cwd();
|
|
1574
|
-
let
|
|
1575
|
-
|
|
1576
|
-
if (!
|
|
1577
|
-
|
|
1556
|
+
let relative = filePath.startsWith(cwd) ? filePath.slice(cwd.length + 1) : filePath;
|
|
1557
|
+
relative = relative.replace(/\\/g, "/");
|
|
1558
|
+
if (!relative.startsWith("/")) {
|
|
1559
|
+
relative = "/" + relative;
|
|
1578
1560
|
}
|
|
1579
|
-
return
|
|
1561
|
+
return relative;
|
|
1580
1562
|
};
|
|
1581
1563
|
var getFrameworkColor = (framework) => {
|
|
1582
1564
|
return frameworkColors[framework] || colors.white;
|
|
@@ -1648,11 +1630,11 @@ var logger = {
|
|
|
1648
1630
|
ready: startupBanner
|
|
1649
1631
|
};
|
|
1650
1632
|
// src/utils/validateSafePath.ts
|
|
1651
|
-
import { resolve as
|
|
1633
|
+
import { resolve as resolve3, relative } from "path";
|
|
1652
1634
|
var validateSafePath = (targetPath, baseDirectory) => {
|
|
1653
|
-
const absoluteBase =
|
|
1654
|
-
const absoluteTarget =
|
|
1655
|
-
const relativePath = normalizePath(
|
|
1635
|
+
const absoluteBase = resolve3(baseDirectory);
|
|
1636
|
+
const absoluteTarget = resolve3(baseDirectory, targetPath);
|
|
1637
|
+
const relativePath = normalizePath(relative(absoluteBase, absoluteTarget));
|
|
1656
1638
|
if (relativePath.startsWith("../") || relativePath === "..") {
|
|
1657
1639
|
throw new Error(`Unsafe path: ${targetPath}`);
|
|
1658
1640
|
}
|
|
@@ -1804,12 +1786,12 @@ var build2 = async ({
|
|
|
1804
1786
|
{ svelteServerPaths, svelteIndexPaths, svelteClientPaths },
|
|
1805
1787
|
{ vueServerPaths, vueIndexPaths, vueClientPaths, vueCssPaths }
|
|
1806
1788
|
] = await Promise.all([
|
|
1807
|
-
svelteDir ? compileSvelte(svelteEntries, svelteDir, new Map, hmr) : {
|
|
1789
|
+
svelteDir ? Promise.resolve().then(() => (init_compileSvelte(), exports_compileSvelte)).then((mod) => mod.compileSvelte(svelteEntries, svelteDir, new Map, hmr)) : {
|
|
1808
1790
|
svelteClientPaths: [],
|
|
1809
1791
|
svelteIndexPaths: [],
|
|
1810
1792
|
svelteServerPaths: []
|
|
1811
1793
|
},
|
|
1812
|
-
vueDir ? compileVue(vueEntries, vueDir, hmr) : {
|
|
1794
|
+
vueDir ? Promise.resolve().then(() => (init_compileVue(), exports_compileVue)).then((mod) => mod.compileVue(vueEntries, vueDir, hmr)) : {
|
|
1813
1795
|
vueClientPaths: [],
|
|
1814
1796
|
vueCssPaths: [],
|
|
1815
1797
|
vueIndexPaths: [],
|
|
@@ -2885,27 +2867,27 @@ var broadcastToClients = (state, message) => {
|
|
|
2885
2867
|
var parseErrorLocationFromMessage = (msg) => {
|
|
2886
2868
|
const pathLineCol = msg.match(/^([^\s:]+):(\d+)(?::(\d+))?/);
|
|
2887
2869
|
if (pathLineCol) {
|
|
2888
|
-
const [,
|
|
2870
|
+
const [, file3, lineStr, colStr] = pathLineCol;
|
|
2889
2871
|
return {
|
|
2890
|
-
file:
|
|
2872
|
+
file: file3,
|
|
2891
2873
|
line: lineStr ? parseInt(lineStr, 10) : undefined,
|
|
2892
2874
|
column: colStr ? parseInt(colStr, 10) : undefined
|
|
2893
2875
|
};
|
|
2894
2876
|
}
|
|
2895
2877
|
const atMatch = msg.match(/(?:at|in)\s+([^(:\s]+)(?:\s*\([^)]*line\s*(\d+)[^)]*col(?:umn)?\s*(\d+)[^)]*\)|:(\d+):(\d+)?)/i);
|
|
2896
2878
|
if (atMatch) {
|
|
2897
|
-
const [,
|
|
2879
|
+
const [, file3, line1, col1, line2, col2] = atMatch;
|
|
2898
2880
|
return {
|
|
2899
|
-
file:
|
|
2881
|
+
file: file3?.trim(),
|
|
2900
2882
|
line: line1 ? parseInt(line1, 10) : line2 ? parseInt(line2, 10) : undefined,
|
|
2901
2883
|
column: col1 ? parseInt(col1, 10) : col2 ? parseInt(col2, 10) : undefined
|
|
2902
2884
|
};
|
|
2903
2885
|
}
|
|
2904
2886
|
const parenMatch = msg.match(/([^\s(]+)\s*\([^)]*line\s*(\d+)[^)]*col(?:umn)?\s*(\d+)/i);
|
|
2905
2887
|
if (parenMatch) {
|
|
2906
|
-
const [,
|
|
2888
|
+
const [, file3, lineStr, colStr] = parenMatch;
|
|
2907
2889
|
return {
|
|
2908
|
-
file:
|
|
2890
|
+
file: file3 ?? undefined,
|
|
2909
2891
|
line: lineStr ? parseInt(lineStr, 10) : undefined,
|
|
2910
2892
|
column: colStr ? parseInt(colStr, 10) : undefined
|
|
2911
2893
|
};
|
|
@@ -2920,13 +2902,13 @@ var extractBuildErrorDetails = (error, affectedFrameworks, resolvedPaths) => {
|
|
|
2920
2902
|
if (logs && Array.isArray(logs) && logs.length > 0) {
|
|
2921
2903
|
const errLog = logs.find((l) => l.level === "error") ?? logs[0];
|
|
2922
2904
|
const pos = errLog?.position;
|
|
2923
|
-
const
|
|
2905
|
+
const file3 = pos && "file" in pos ? pos.file : undefined;
|
|
2924
2906
|
const line = pos && "line" in pos ? pos.line : undefined;
|
|
2925
2907
|
const column = pos && "column" in pos ? pos.column : undefined;
|
|
2926
2908
|
const lineText = pos && "lineText" in pos ? pos.lineText : undefined;
|
|
2927
|
-
const framework =
|
|
2909
|
+
const framework = file3 && resolvedPaths ? detectFramework(file3, resolvedPaths) : affectedFrameworks[0] ?? "unknown";
|
|
2928
2910
|
return {
|
|
2929
|
-
file:
|
|
2911
|
+
file: file3,
|
|
2930
2912
|
line,
|
|
2931
2913
|
column,
|
|
2932
2914
|
lineText,
|
|
@@ -3085,7 +3067,7 @@ var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) =>
|
|
|
3085
3067
|
if (filesToRebuild && filesToRebuild.length > 0) {
|
|
3086
3068
|
const allModuleUpdates = [];
|
|
3087
3069
|
for (const framework of affectedFrameworks) {
|
|
3088
|
-
const frameworkFiles = filesToRebuild.filter((
|
|
3070
|
+
const frameworkFiles = filesToRebuild.filter((file3) => detectFramework(file3, state.resolvedPaths) === framework);
|
|
3089
3071
|
if (frameworkFiles.length > 0) {
|
|
3090
3072
|
const moduleUpdates = createModuleUpdates(frameworkFiles, framework, manifest, state.resolvedPaths);
|
|
3091
3073
|
if (moduleUpdates.length > 0) {
|
|
@@ -3094,17 +3076,17 @@ var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) =>
|
|
|
3094
3076
|
}
|
|
3095
3077
|
}
|
|
3096
3078
|
if (affectedFrameworks.includes("react") && filesToRebuild && state.resolvedPaths.reactDir) {
|
|
3097
|
-
const reactFiles = filesToRebuild.filter((
|
|
3079
|
+
const reactFiles = filesToRebuild.filter((file3) => detectFramework(file3, state.resolvedPaths) === "react");
|
|
3098
3080
|
if (reactFiles.length > 0) {
|
|
3099
|
-
const reactPageFiles = reactFiles.filter((
|
|
3100
|
-
const normalized =
|
|
3081
|
+
const reactPageFiles = reactFiles.filter((file3) => {
|
|
3082
|
+
const normalized = file3.replace(/\\/g, "/");
|
|
3101
3083
|
return normalized.includes("/pages/");
|
|
3102
3084
|
});
|
|
3103
3085
|
const sourceFiles = reactPageFiles.length > 0 ? reactPageFiles : reactFiles;
|
|
3104
3086
|
const primarySource = sourceFiles[0];
|
|
3105
3087
|
try {
|
|
3106
|
-
const hasComponentChanges = reactFiles.some((
|
|
3107
|
-
const hasCSSChanges = reactFiles.some((
|
|
3088
|
+
const hasComponentChanges = reactFiles.some((file3) => file3.endsWith(".tsx") || file3.endsWith(".ts") || file3.endsWith(".jsx"));
|
|
3089
|
+
const hasCSSChanges = reactFiles.some((file3) => file3.endsWith(".css"));
|
|
3108
3090
|
if (hasCSSChanges && !hasComponentChanges) {
|
|
3109
3091
|
logger.cssUpdate(primarySource ?? reactFiles[0] ?? "", "react", duration);
|
|
3110
3092
|
} else {
|
|
@@ -3125,7 +3107,7 @@ var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) =>
|
|
|
3125
3107
|
}
|
|
3126
3108
|
}
|
|
3127
3109
|
if (affectedFrameworks.includes("html") && filesToRebuild && state.resolvedPaths.htmlDir) {
|
|
3128
|
-
const htmlFrameworkFiles = filesToRebuild.filter((
|
|
3110
|
+
const htmlFrameworkFiles = filesToRebuild.filter((file3) => detectFramework(file3, state.resolvedPaths) === "html");
|
|
3129
3111
|
if (htmlFrameworkFiles.length > 0) {
|
|
3130
3112
|
const scriptFiles = htmlFrameworkFiles.filter((f) => (f.endsWith(".ts") || f.endsWith(".js") || f.endsWith(".tsx") || f.endsWith(".jsx")) && f.replace(/\\/g, "/").includes("/scripts/"));
|
|
3131
3113
|
const htmlPageFiles = htmlFrameworkFiles.filter((f) => f.endsWith(".html"));
|
|
@@ -3156,7 +3138,7 @@ var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) =>
|
|
|
3156
3138
|
}
|
|
3157
3139
|
}
|
|
3158
3140
|
if (affectedFrameworks.includes("html") && filesToRebuild && state.resolvedPaths.htmlDir) {
|
|
3159
|
-
const htmlFrameworkFiles = filesToRebuild.filter((
|
|
3141
|
+
const htmlFrameworkFiles = filesToRebuild.filter((file3) => detectFramework(file3, state.resolvedPaths) === "html");
|
|
3160
3142
|
if (htmlFrameworkFiles.length > 0) {
|
|
3161
3143
|
const htmlPageFiles = htmlFrameworkFiles.filter((f) => f.endsWith(".html"));
|
|
3162
3144
|
const pagesToUpdate = htmlPageFiles;
|
|
@@ -3184,7 +3166,7 @@ var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) =>
|
|
|
3184
3166
|
}
|
|
3185
3167
|
}
|
|
3186
3168
|
if (affectedFrameworks.includes("vue") && filesToRebuild && config.vueDirectory) {
|
|
3187
|
-
const vueFiles = filesToRebuild.filter((
|
|
3169
|
+
const vueFiles = filesToRebuild.filter((file3) => detectFramework(file3, state.resolvedPaths) === "vue");
|
|
3188
3170
|
if (vueFiles.length > 0) {
|
|
3189
3171
|
const vueComponentFiles = vueFiles.filter((f) => f.endsWith(".vue"));
|
|
3190
3172
|
const vueCssFiles = vueFiles.filter((f) => f.endsWith(".css"));
|
|
@@ -3216,13 +3198,13 @@ var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) =>
|
|
|
3216
3198
|
}
|
|
3217
3199
|
for (const vuePagePath of pagesToUpdate) {
|
|
3218
3200
|
try {
|
|
3219
|
-
const { basename: basename9, relative:
|
|
3201
|
+
const { basename: basename9, relative: relative4 } = await import("path");
|
|
3220
3202
|
const { toPascal: toPascal2 } = await Promise.resolve().then(() => exports_stringModifiers);
|
|
3221
3203
|
const fileName = basename9(vuePagePath);
|
|
3222
3204
|
const baseName = fileName.replace(/\.vue$/, "");
|
|
3223
3205
|
const pascalName = toPascal2(baseName);
|
|
3224
3206
|
const vueRoot = config.vueDirectory;
|
|
3225
|
-
const hmrId = vueRoot ?
|
|
3207
|
+
const hmrId = vueRoot ? relative4(vueRoot, vuePagePath).replace(/\\/g, "/").replace(/\.vue$/, "") : baseName;
|
|
3226
3208
|
const cssKey = `${pascalName}CSS`;
|
|
3227
3209
|
const cssUrl = manifest[cssKey] || null;
|
|
3228
3210
|
const { vueHmrMetadata: vueHmrMetadata2 } = await Promise.resolve().then(() => (init_compileVue(), exports_compileVue));
|
|
@@ -3268,7 +3250,7 @@ var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) =>
|
|
|
3268
3250
|
}
|
|
3269
3251
|
}
|
|
3270
3252
|
if (affectedFrameworks.includes("svelte") && filesToRebuild && config.svelteDirectory) {
|
|
3271
|
-
const svelteFiles = filesToRebuild.filter((
|
|
3253
|
+
const svelteFiles = filesToRebuild.filter((file3) => detectFramework(file3, state.resolvedPaths) === "svelte");
|
|
3272
3254
|
if (svelteFiles.length > 0) {
|
|
3273
3255
|
const svelteComponentFiles = svelteFiles.filter((f) => f.endsWith(".svelte"));
|
|
3274
3256
|
const svelteCssFiles = svelteFiles.filter((f) => f.endsWith(".css"));
|
|
@@ -3327,7 +3309,7 @@ var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) =>
|
|
|
3327
3309
|
}
|
|
3328
3310
|
}
|
|
3329
3311
|
if (affectedFrameworks.includes("htmx") && filesToRebuild && state.resolvedPaths.htmxDir) {
|
|
3330
|
-
const htmxFrameworkFiles = filesToRebuild.filter((
|
|
3312
|
+
const htmxFrameworkFiles = filesToRebuild.filter((file3) => detectFramework(file3, state.resolvedPaths) === "htmx");
|
|
3331
3313
|
if (htmxFrameworkFiles.length > 0) {
|
|
3332
3314
|
const htmxScriptFiles = htmxFrameworkFiles.filter((f) => (f.endsWith(".ts") || f.endsWith(".js") || f.endsWith(".tsx") || f.endsWith(".jsx")) && f.replace(/\\/g, "/").includes("/scripts/"));
|
|
3333
3315
|
const htmxHtmlFiles = htmxFrameworkFiles.filter((f) => f.endsWith(".html"));
|
|
@@ -3356,7 +3338,7 @@ var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) =>
|
|
|
3356
3338
|
}
|
|
3357
3339
|
}
|
|
3358
3340
|
if (affectedFrameworks.includes("htmx") && filesToRebuild && state.resolvedPaths.htmxDir) {
|
|
3359
|
-
const htmxFrameworkFiles = filesToRebuild.filter((
|
|
3341
|
+
const htmxFrameworkFiles = filesToRebuild.filter((file3) => detectFramework(file3, state.resolvedPaths) === "htmx");
|
|
3360
3342
|
if (htmxFrameworkFiles.length > 0) {
|
|
3361
3343
|
const htmxPageFiles = htmxFrameworkFiles.filter((f) => f.endsWith(".html"));
|
|
3362
3344
|
const isSingle = !config.reactDirectory && !config.svelteDirectory && !config.vueDirectory && !config.htmlDirectory;
|
|
@@ -3556,9 +3538,10 @@ var asset = (source, name) => {
|
|
|
3556
3538
|
}
|
|
3557
3539
|
return assetPath;
|
|
3558
3540
|
};
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3541
|
+
// src/core/pageHandlers.ts
|
|
3542
|
+
var {file: file3 } = globalThis.Bun;
|
|
3543
|
+
var handleHTMLPageRequest = (pagePath) => file3(pagePath);
|
|
3544
|
+
var handleHTMXPageRequest = (pagePath) => file3(pagePath);
|
|
3562
3545
|
// src/plugins/pageRouter.ts
|
|
3563
3546
|
var pageRouterPlugin = () => {
|
|
3564
3547
|
console.log("Page Router Plugin Not Implemented Yet");
|
|
@@ -3757,10 +3740,6 @@ export {
|
|
|
3757
3740
|
isValidHMRClientMessage,
|
|
3758
3741
|
hmrState,
|
|
3759
3742
|
hmr,
|
|
3760
|
-
handleVuePageRequest,
|
|
3761
|
-
handleSveltePageRequest,
|
|
3762
|
-
handleReactPageRequest,
|
|
3763
|
-
handlePageRequest,
|
|
3764
3743
|
handleHTMXPageRequest,
|
|
3765
3744
|
handleHTMLPageRequest,
|
|
3766
3745
|
getRegisterClientScript,
|
|
@@ -3789,5 +3768,5 @@ export {
|
|
|
3789
3768
|
BUN_BUILD_WARNING_SUPPRESSION
|
|
3790
3769
|
};
|
|
3791
3770
|
|
|
3792
|
-
//# debugId=
|
|
3771
|
+
//# debugId=05B6DFB97B78673E64756E2164756E21
|
|
3793
3772
|
//# sourceMappingURL=index.js.map
|