@absolutejs/absolute 0.15.27 → 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 +396 -421
- package/dist/index.js.map +12 -11
- 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,37 +387,37 @@ 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",
|
|
@@ -342,11 +516,11 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
342
516
|
await Promise.all(Array.from(allTsHelperPaths).map(async (tsPath) => {
|
|
343
517
|
const sourceCode = await file2(tsPath).text();
|
|
344
518
|
const transpiledCode = transpiler2.transformSync(sourceCode);
|
|
345
|
-
const relativeJsPath =
|
|
346
|
-
const outClientPath =
|
|
347
|
-
const outServerPath =
|
|
348
|
-
await
|
|
349
|
-
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 });
|
|
350
524
|
await write2(outClientPath, transpiledCode);
|
|
351
525
|
await write2(outServerPath, transpiledCode);
|
|
352
526
|
}));
|
|
@@ -359,13 +533,13 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
359
533
|
};
|
|
360
534
|
};
|
|
361
535
|
var init_compileVue = __esm(() => {
|
|
362
|
-
|
|
363
|
-
const fromSource =
|
|
364
|
-
if (
|
|
536
|
+
devClientDir3 = (() => {
|
|
537
|
+
const fromSource = resolve5(import.meta.dir, "../dev/client");
|
|
538
|
+
if (existsSync4(fromSource))
|
|
365
539
|
return fromSource;
|
|
366
|
-
return
|
|
540
|
+
return resolve5(import.meta.dir, "./dev/client");
|
|
367
541
|
})();
|
|
368
|
-
|
|
542
|
+
hmrClientPath4 = join4(devClientDir3, "hmrClient.ts").replace(/\\/g, "/");
|
|
369
543
|
transpiler2 = new Transpiler2({ loader: "ts", target: "browser" });
|
|
370
544
|
scriptCache = new Map;
|
|
371
545
|
scriptSetupCache = new Map;
|
|
@@ -405,71 +579,6 @@ var handleHTMLUpdate = async (htmlFilePath) => {
|
|
|
405
579
|
};
|
|
406
580
|
var init_simpleHTMLHMR = () => {};
|
|
407
581
|
|
|
408
|
-
// src/utils/escapeScriptContent.ts
|
|
409
|
-
var ESCAPE_LOOKUP, ESCAPE_REGEX, escapeScriptContent = (content) => content.replace(ESCAPE_REGEX, (char) => {
|
|
410
|
-
const escaped = ESCAPE_LOOKUP[char];
|
|
411
|
-
return escaped !== undefined ? escaped : char;
|
|
412
|
-
});
|
|
413
|
-
var init_escapeScriptContent = __esm(() => {
|
|
414
|
-
ESCAPE_LOOKUP = {
|
|
415
|
-
"\u2028": "\\u2028",
|
|
416
|
-
"\u2029": "\\u2029",
|
|
417
|
-
"&": "\\u0026",
|
|
418
|
-
"<": "\\u003C",
|
|
419
|
-
">": "\\u003E"
|
|
420
|
-
};
|
|
421
|
-
ESCAPE_REGEX = /[&><\u2028\u2029]/g;
|
|
422
|
-
});
|
|
423
|
-
|
|
424
|
-
// src/svelte/renderToReadableStream.ts
|
|
425
|
-
import { render } from "svelte/server";
|
|
426
|
-
var renderToReadableStream = async (component, props, {
|
|
427
|
-
bootstrapScriptContent,
|
|
428
|
-
bootstrapScripts = [],
|
|
429
|
-
bootstrapModules = [],
|
|
430
|
-
nonce,
|
|
431
|
-
onError = console.error,
|
|
432
|
-
progressiveChunkSize = DEFAULT_CHUNK_SIZE,
|
|
433
|
-
signal,
|
|
434
|
-
headContent,
|
|
435
|
-
bodyContent
|
|
436
|
-
} = {}) => {
|
|
437
|
-
try {
|
|
438
|
-
const { head, body } = typeof props === "undefined" ? render(component) : render(component, { props });
|
|
439
|
-
const nonceAttr = nonce ? ` nonce="${nonce}"` : "";
|
|
440
|
-
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("");
|
|
441
|
-
const encoder = new TextEncoder;
|
|
442
|
-
const full = encoder.encode(`<!DOCTYPE html><html lang="en"><head>${head}${headContent ?? ""}</head><body>${body}${scripts}${bodyContent ?? ""}</body></html>`);
|
|
443
|
-
let offset = 0;
|
|
444
|
-
return new ReadableStream({
|
|
445
|
-
type: "bytes",
|
|
446
|
-
cancel(reason) {
|
|
447
|
-
onError?.(reason);
|
|
448
|
-
},
|
|
449
|
-
pull(controller) {
|
|
450
|
-
if (signal?.aborted) {
|
|
451
|
-
controller.close();
|
|
452
|
-
return;
|
|
453
|
-
}
|
|
454
|
-
if (offset >= full.length) {
|
|
455
|
-
controller.close();
|
|
456
|
-
return;
|
|
457
|
-
}
|
|
458
|
-
const end = Math.min(offset + progressiveChunkSize, full.length);
|
|
459
|
-
controller.enqueue(full.subarray(offset, end));
|
|
460
|
-
offset = end;
|
|
461
|
-
}
|
|
462
|
-
});
|
|
463
|
-
} catch (error) {
|
|
464
|
-
onError?.(error);
|
|
465
|
-
throw error;
|
|
466
|
-
}
|
|
467
|
-
};
|
|
468
|
-
var init_renderToReadableStream = __esm(() => {
|
|
469
|
-
init_constants();
|
|
470
|
-
init_escapeScriptContent();
|
|
471
|
-
});
|
|
472
|
-
|
|
473
582
|
// src/utils/ssrErrorPage.ts
|
|
474
583
|
var ssrErrorPage = (framework, error) => {
|
|
475
584
|
const frameworkColors2 = {
|
|
@@ -522,60 +631,14 @@ body{min-height:100vh;background:linear-gradient(135deg,rgba(15,23,42,0.98) 0%,r
|
|
|
522
631
|
</html>`;
|
|
523
632
|
};
|
|
524
633
|
|
|
525
|
-
// src/
|
|
526
|
-
var
|
|
527
|
-
__export(
|
|
528
|
-
handleVuePageRequest: () => handleVuePageRequest
|
|
529
|
-
handleSveltePageRequest: () => handleSveltePageRequest,
|
|
530
|
-
handleReactPageRequest: () => handleReactPageRequest,
|
|
531
|
-
handlePageRequest: () => handlePageRequest,
|
|
532
|
-
handleHTMXPageRequest: () => handleHTMXPageRequest,
|
|
533
|
-
handleHTMLPageRequest: () => handleHTMLPageRequest
|
|
634
|
+
// src/vue/pageHandler.ts
|
|
635
|
+
var exports_pageHandler = {};
|
|
636
|
+
__export(exports_pageHandler, {
|
|
637
|
+
handleVuePageRequest: () => handleVuePageRequest
|
|
534
638
|
});
|
|
535
|
-
var {file: file3 } = globalThis.Bun;
|
|
536
|
-
import { createElement } from "react";
|
|
537
|
-
import { renderToReadableStream as renderReactToReadableStream } from "react-dom/server";
|
|
538
639
|
import { createSSRApp, h } from "vue";
|
|
539
640
|
import { renderToWebStream as renderVueToWebStream } from "vue/server-renderer";
|
|
540
|
-
var
|
|
541
|
-
try {
|
|
542
|
-
const [maybeProps] = props;
|
|
543
|
-
const element = maybeProps !== undefined ? createElement(PageComponent, maybeProps) : createElement(PageComponent);
|
|
544
|
-
const stream = await renderReactToReadableStream(element, {
|
|
545
|
-
bootstrapModules: [index],
|
|
546
|
-
bootstrapScriptContent: maybeProps ? `window.__INITIAL_PROPS__=${JSON.stringify(maybeProps)}` : undefined,
|
|
547
|
-
onError(error) {
|
|
548
|
-
console.error("[SSR] React streaming error:", error);
|
|
549
|
-
}
|
|
550
|
-
});
|
|
551
|
-
return new Response(stream, {
|
|
552
|
-
headers: { "Content-Type": "text/html" }
|
|
553
|
-
});
|
|
554
|
-
} catch (error) {
|
|
555
|
-
console.error("[SSR] React render error:", error);
|
|
556
|
-
return new Response(ssrErrorPage("react", error), {
|
|
557
|
-
status: 500,
|
|
558
|
-
headers: { "Content-Type": "text/html" }
|
|
559
|
-
});
|
|
560
|
-
}
|
|
561
|
-
}, handleSveltePageRequest = async (_PageComponent, pagePath, indexPath, props) => {
|
|
562
|
-
try {
|
|
563
|
-
const { default: ImportedPageComponent } = await import(pagePath);
|
|
564
|
-
const stream = await renderToReadableStream(ImportedPageComponent, props, {
|
|
565
|
-
bootstrapModules: indexPath ? [indexPath] : [],
|
|
566
|
-
bootstrapScriptContent: `window.__INITIAL_PROPS__=${JSON.stringify(props)}`
|
|
567
|
-
});
|
|
568
|
-
return new Response(stream, {
|
|
569
|
-
headers: { "Content-Type": "text/html" }
|
|
570
|
-
});
|
|
571
|
-
} catch (error) {
|
|
572
|
-
console.error("[SSR] Svelte render error:", error);
|
|
573
|
-
return new Response(ssrErrorPage("svelte", error), {
|
|
574
|
-
status: 500,
|
|
575
|
-
headers: { "Content-Type": "text/html" }
|
|
576
|
-
});
|
|
577
|
-
}
|
|
578
|
-
}, handleVuePageRequest = async (_PageComponent, pagePath, indexPath, headTag = "<head></head>", ...props) => {
|
|
641
|
+
var handleVuePageRequest = async (_PageComponent, pagePath, indexPath, headTag = "<head></head>", ...props) => {
|
|
579
642
|
try {
|
|
580
643
|
const [maybeProps] = props;
|
|
581
644
|
const { default: ImportedPageComponent } = await import(pagePath);
|
|
@@ -605,12 +668,8 @@ var handleReactPageRequest = async (PageComponent, index, ...props) => {
|
|
|
605
668
|
headers: { "Content-Type": "text/html" }
|
|
606
669
|
});
|
|
607
670
|
}
|
|
608
|
-
}, handleHTMLPageRequest = (pagePath) => file3(pagePath), handleHTMXPageRequest = (pagePath) => file3(pagePath), handlePageRequest = (PageComponent, ...props) => {
|
|
609
|
-
console.log("handlePageRequest coming soon.", PageComponent, props);
|
|
610
671
|
};
|
|
611
|
-
var
|
|
612
|
-
init_renderToReadableStream();
|
|
613
|
-
});
|
|
672
|
+
var init_pageHandler = () => {};
|
|
614
673
|
|
|
615
674
|
// src/utils/generateHeadElement.ts
|
|
616
675
|
var exports_generateHeadElement = {};
|
|
@@ -668,7 +727,7 @@ var handleVueUpdate = async (vueFilePath, manifest, buildDir) => {
|
|
|
668
727
|
console.warn("[Vue HMR] Index path not found in manifest for:", indexKey);
|
|
669
728
|
return null;
|
|
670
729
|
}
|
|
671
|
-
const { handleVuePageRequest: handleVuePageRequest2 } = await Promise.resolve().then(() => (
|
|
730
|
+
const { handleVuePageRequest: handleVuePageRequest2 } = await Promise.resolve().then(() => (init_pageHandler(), exports_pageHandler));
|
|
672
731
|
const { generateHeadElement: generateHeadElement2 } = await Promise.resolve().then(() => exports_generateHeadElement);
|
|
673
732
|
const response = await handleVuePageRequest2(serverModule.default, serverPath, indexPath, generateHeadElement2({
|
|
674
733
|
cssPath: manifest[cssKey] || "",
|
|
@@ -688,6 +747,98 @@ var handleVueUpdate = async (vueFilePath, manifest, buildDir) => {
|
|
|
688
747
|
};
|
|
689
748
|
var init_simpleVueHMR = () => {};
|
|
690
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
|
+
|
|
691
842
|
// src/dev/simpleSvelteHMR.ts
|
|
692
843
|
var exports_simpleSvelteHMR = {};
|
|
693
844
|
__export(exports_simpleSvelteHMR, {
|
|
@@ -721,7 +872,7 @@ var handleSvelteUpdate = async (svelteFilePath, manifest, buildDir) => {
|
|
|
721
872
|
console.warn("[Svelte HMR] Index path not found in manifest for:", indexKey);
|
|
722
873
|
return null;
|
|
723
874
|
}
|
|
724
|
-
const { handleSveltePageRequest: handleSveltePageRequest2 } = await Promise.resolve().then(() => (
|
|
875
|
+
const { handleSveltePageRequest: handleSveltePageRequest2 } = await Promise.resolve().then(() => (init_pageHandler2(), exports_pageHandler2));
|
|
725
876
|
const response = await handleSveltePageRequest2(serverModule.default, serverPath, indexPath, {
|
|
726
877
|
cssPath: manifest[cssKey] || "",
|
|
727
878
|
initialCount: 0
|
|
@@ -818,182 +969,9 @@ import { basename as basename4, join as join5, resolve as resolve6 } from "path"
|
|
|
818
969
|
import { cwd, env as env2, exit } from "process";
|
|
819
970
|
var {$, build: bunBuild2, Glob: Glob3 } = globalThis.Bun;
|
|
820
971
|
|
|
821
|
-
// src/build/compileSvelte.ts
|
|
822
|
-
import { existsSync } from "fs";
|
|
823
|
-
import { mkdir, stat } from "fs/promises";
|
|
824
|
-
import {
|
|
825
|
-
dirname,
|
|
826
|
-
join,
|
|
827
|
-
basename,
|
|
828
|
-
extname,
|
|
829
|
-
resolve,
|
|
830
|
-
relative,
|
|
831
|
-
sep
|
|
832
|
-
} from "path";
|
|
833
|
-
import { env } from "process";
|
|
834
|
-
var {write, file, Transpiler } = globalThis.Bun;
|
|
835
|
-
import { compile, compileModule, preprocess } from "svelte/compiler";
|
|
836
|
-
var devClientDir = (() => {
|
|
837
|
-
const fromSource = resolve(import.meta.dir, "../dev/client");
|
|
838
|
-
if (existsSync(fromSource))
|
|
839
|
-
return fromSource;
|
|
840
|
-
return resolve(import.meta.dir, "./dev/client");
|
|
841
|
-
})();
|
|
842
|
-
var hmrClientPath = join(devClientDir, "hmrClient.ts").replace(/\\/g, "/");
|
|
843
|
-
var transpiler = new Transpiler({ loader: "ts", target: "browser" });
|
|
844
|
-
var exists = async (path) => {
|
|
845
|
-
try {
|
|
846
|
-
await stat(path);
|
|
847
|
-
return true;
|
|
848
|
-
} catch {
|
|
849
|
-
return false;
|
|
850
|
-
}
|
|
851
|
-
};
|
|
852
|
-
var resolveSvelte = async (spec, from) => {
|
|
853
|
-
const basePath = resolve(dirname(from), spec);
|
|
854
|
-
const explicit = /\.(svelte|svelte\.(?:ts|js))$/.test(basePath);
|
|
855
|
-
if (!explicit) {
|
|
856
|
-
const extensions = [".svelte", ".svelte.ts", ".svelte.js"];
|
|
857
|
-
const paths = extensions.map((ext) => `${basePath}${ext}`);
|
|
858
|
-
const checks = await Promise.all(paths.map(exists));
|
|
859
|
-
const match = paths.find((_, index) => checks[index]);
|
|
860
|
-
return match ?? null;
|
|
861
|
-
}
|
|
862
|
-
if (await exists(basePath))
|
|
863
|
-
return basePath;
|
|
864
|
-
if (!basePath.endsWith(".svelte"))
|
|
865
|
-
return null;
|
|
866
|
-
const tsPath = `${basePath}.ts`;
|
|
867
|
-
if (await exists(tsPath))
|
|
868
|
-
return tsPath;
|
|
869
|
-
const jsPath = `${basePath}.js`;
|
|
870
|
-
if (await exists(jsPath))
|
|
871
|
-
return jsPath;
|
|
872
|
-
return null;
|
|
873
|
-
};
|
|
874
|
-
var compileSvelte = async (entryPoints, svelteRoot, cache = new Map, isDev = false) => {
|
|
875
|
-
const compiledRoot = join(svelteRoot, "compiled");
|
|
876
|
-
const clientDir = join(compiledRoot, "client");
|
|
877
|
-
const indexDir = join(compiledRoot, "indexes");
|
|
878
|
-
const pagesDir = join(compiledRoot, "pages");
|
|
879
|
-
await Promise.all([clientDir, indexDir, pagesDir].map((dir) => mkdir(dir, { recursive: true })));
|
|
880
|
-
const dev = env.NODE_ENV !== "production";
|
|
881
|
-
const build2 = async (src) => {
|
|
882
|
-
const memoized = cache.get(src);
|
|
883
|
-
if (memoized)
|
|
884
|
-
return memoized;
|
|
885
|
-
const raw = await file(src).text();
|
|
886
|
-
const isModule = src.endsWith(".svelte.ts") || src.endsWith(".svelte.js");
|
|
887
|
-
const preprocessed = isModule ? raw : (await preprocess(raw, {})).code;
|
|
888
|
-
const transpiled = src.endsWith(".ts") || src.endsWith(".svelte.ts") ? transpiler.transformSync(preprocessed) : preprocessed;
|
|
889
|
-
const relDir = dirname(relative(svelteRoot, src)).replace(/\\/g, "/");
|
|
890
|
-
const baseName = basename(src).replace(/\.svelte(\.(ts|js))?$/, "");
|
|
891
|
-
const importPaths = Array.from(transpiled.matchAll(/from\s+['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((path) => path !== undefined);
|
|
892
|
-
const resolvedImports = await Promise.all(importPaths.map((importPath) => resolveSvelte(importPath, src)));
|
|
893
|
-
const childSources = resolvedImports.filter((path) => path !== null);
|
|
894
|
-
await Promise.all(childSources.map((child) => build2(child)));
|
|
895
|
-
const generate = (mode) => (isModule ? compileModule(transpiled, {
|
|
896
|
-
dev: mode === "client" && dev,
|
|
897
|
-
filename: src
|
|
898
|
-
}).js.code : compile(transpiled, {
|
|
899
|
-
css: "injected",
|
|
900
|
-
dev: mode === "client" && dev,
|
|
901
|
-
filename: src,
|
|
902
|
-
generate: mode
|
|
903
|
-
}).js.code).replace(/\.svelte(?:\.(?:ts|js))?(['"])/g, ".js$1");
|
|
904
|
-
const ssrPath = join(pagesDir, relDir, `${baseName}.js`);
|
|
905
|
-
const clientPath = join(clientDir, relDir, `${baseName}.js`);
|
|
906
|
-
await Promise.all([
|
|
907
|
-
mkdir(dirname(ssrPath), { recursive: true }),
|
|
908
|
-
mkdir(dirname(clientPath), { recursive: true })
|
|
909
|
-
]);
|
|
910
|
-
if (isModule) {
|
|
911
|
-
const bundle = generate("client");
|
|
912
|
-
await Promise.all([
|
|
913
|
-
write(ssrPath, bundle),
|
|
914
|
-
write(clientPath, bundle)
|
|
915
|
-
]);
|
|
916
|
-
} else {
|
|
917
|
-
const serverBundle = generate("server");
|
|
918
|
-
const clientBundle = generate("client");
|
|
919
|
-
await Promise.all([
|
|
920
|
-
write(ssrPath, serverBundle),
|
|
921
|
-
write(clientPath, clientBundle)
|
|
922
|
-
]);
|
|
923
|
-
}
|
|
924
|
-
const built = { client: clientPath, ssr: ssrPath };
|
|
925
|
-
cache.set(src, built);
|
|
926
|
-
return built;
|
|
927
|
-
};
|
|
928
|
-
const roots = await Promise.all(entryPoints.map(build2));
|
|
929
|
-
await Promise.all(roots.map(async ({ client: client2 }) => {
|
|
930
|
-
const relClientDir = dirname(relative(clientDir, client2));
|
|
931
|
-
const name = basename(client2, extname(client2));
|
|
932
|
-
const indexPath = join(indexDir, relClientDir, `${name}.js`);
|
|
933
|
-
const importRaw = relative(dirname(indexPath), client2).split(sep).join("/");
|
|
934
|
-
const importPath = importRaw.startsWith(".") || importRaw.startsWith("/") ? importRaw : `./${importRaw}`;
|
|
935
|
-
const hmrImports = isDev ? `window.__HMR_FRAMEWORK__ = "svelte";
|
|
936
|
-
import "${hmrClientPath}";
|
|
937
|
-
` : "";
|
|
938
|
-
const bootstrap = `${hmrImports}import Component from "${importPath}";
|
|
939
|
-
import { hydrate, mount, unmount } from "svelte";
|
|
940
|
-
|
|
941
|
-
var initialProps = (typeof window !== "undefined" && window.__INITIAL_PROPS__) ? window.__INITIAL_PROPS__ : {};
|
|
942
|
-
var isHMR = typeof window !== "undefined" && window.__SVELTE_COMPONENT__ !== undefined;
|
|
943
|
-
var component;
|
|
944
|
-
|
|
945
|
-
if (isHMR) {
|
|
946
|
-
var headLinks = document.querySelectorAll('link[rel="stylesheet"]');
|
|
947
|
-
var preservedLinks = [];
|
|
948
|
-
headLinks.forEach(function(link) {
|
|
949
|
-
var clone = link.cloneNode(true);
|
|
950
|
-
clone.setAttribute("data-hmr-preserve", "true");
|
|
951
|
-
document.head.appendChild(clone);
|
|
952
|
-
preservedLinks.push(clone);
|
|
953
|
-
});
|
|
954
|
-
if (typeof window.__SVELTE_UNMOUNT__ === "function") {
|
|
955
|
-
try { window.__SVELTE_UNMOUNT__(); } catch (err) { console.warn("[HMR] unmount error:", err); }
|
|
956
|
-
}
|
|
957
|
-
var preservedState = window.__HMR_PRESERVED_STATE__;
|
|
958
|
-
if (!preservedState) {
|
|
959
|
-
try {
|
|
960
|
-
var stored = sessionStorage.getItem("__SVELTE_HMR_STATE__");
|
|
961
|
-
if (stored) preservedState = JSON.parse(stored);
|
|
962
|
-
} catch (err) { /* ignore */ }
|
|
963
|
-
}
|
|
964
|
-
var mergedProps = preservedState ? Object.assign({}, initialProps, preservedState) : initialProps;
|
|
965
|
-
component = mount(Component, { target: document.body, props: mergedProps });
|
|
966
|
-
requestAnimationFrame(function() {
|
|
967
|
-
preservedLinks.forEach(function(link) { link.remove(); });
|
|
968
|
-
});
|
|
969
|
-
window.__HMR_PRESERVED_STATE__ = undefined;
|
|
970
|
-
} else {
|
|
971
|
-
component = hydrate(Component, { target: document.body, props: initialProps });
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
if (typeof window !== "undefined") {
|
|
975
|
-
window.__SVELTE_COMPONENT__ = component;
|
|
976
|
-
window.__SVELTE_UNMOUNT__ = function() { unmount(component); };
|
|
977
|
-
}`;
|
|
978
|
-
await mkdir(dirname(indexPath), { recursive: true });
|
|
979
|
-
return write(indexPath, bootstrap);
|
|
980
|
-
}));
|
|
981
|
-
return {
|
|
982
|
-
svelteIndexPaths: roots.map(({ client: client2 }) => {
|
|
983
|
-
const rel = dirname(relative(clientDir, client2));
|
|
984
|
-
return join(indexDir, rel, basename(client2));
|
|
985
|
-
}),
|
|
986
|
-
svelteClientPaths: roots.map(({ client: client2 }) => client2),
|
|
987
|
-
svelteServerPaths: roots.map(({ ssr }) => ssr)
|
|
988
|
-
};
|
|
989
|
-
};
|
|
990
|
-
|
|
991
|
-
// src/core/build.ts
|
|
992
|
-
init_compileVue();
|
|
993
|
-
|
|
994
972
|
// src/build/generateManifest.ts
|
|
995
973
|
init_constants();
|
|
996
|
-
import { extname
|
|
974
|
+
import { extname } from "path";
|
|
997
975
|
|
|
998
976
|
// src/utils/normalizePath.ts
|
|
999
977
|
var normalizePath = (path) => path.replace(/\\/g, "/");
|
|
@@ -1002,9 +980,9 @@ var normalizePath = (path) => path.replace(/\\/g, "/");
|
|
|
1002
980
|
var generateManifest = (outputs, buildPath) => outputs.reduce((manifest, artifact) => {
|
|
1003
981
|
const normalizedArtifactPath = normalizePath(artifact.path);
|
|
1004
982
|
const normalizedBuildPath = normalizePath(buildPath);
|
|
1005
|
-
let
|
|
1006
|
-
|
|
1007
|
-
const segments =
|
|
983
|
+
let relative = normalizedArtifactPath.startsWith(normalizedBuildPath) ? normalizedArtifactPath.slice(normalizedBuildPath.length) : normalizedArtifactPath;
|
|
984
|
+
relative = relative.replace(/^\/+/, "");
|
|
985
|
+
const segments = relative.split("/");
|
|
1008
986
|
const fileWithHash = segments.pop();
|
|
1009
987
|
if (!fileWithHash)
|
|
1010
988
|
return manifest;
|
|
@@ -1012,9 +990,9 @@ var generateManifest = (outputs, buildPath) => outputs.reduce((manifest, artifac
|
|
|
1012
990
|
if (!baseName)
|
|
1013
991
|
return manifest;
|
|
1014
992
|
const pascalName = toPascal(baseName);
|
|
1015
|
-
const ext =
|
|
993
|
+
const ext = extname(fileWithHash);
|
|
1016
994
|
if (ext === ".css") {
|
|
1017
|
-
manifest[`${pascalName}CSS`] = `/${
|
|
995
|
+
manifest[`${pascalName}CSS`] = `/${relative}`;
|
|
1018
996
|
return manifest;
|
|
1019
997
|
}
|
|
1020
998
|
const idx = segments.findIndex((seg) => seg === "indexes" || seg === "pages" || seg === "client");
|
|
@@ -1024,53 +1002,53 @@ var generateManifest = (outputs, buildPath) => outputs.reduce((manifest, artifac
|
|
|
1024
1002
|
const isSvelte = segments.some((seg) => seg === "svelte");
|
|
1025
1003
|
const isClientComponent = segments.includes("client");
|
|
1026
1004
|
if (folder === "indexes") {
|
|
1027
|
-
manifest[`${pascalName}Index`] = `/${
|
|
1005
|
+
manifest[`${pascalName}Index`] = `/${relative}`;
|
|
1028
1006
|
} else if (isClientComponent) {
|
|
1029
|
-
manifest[`${pascalName}Client`] = `/${
|
|
1007
|
+
manifest[`${pascalName}Client`] = `/${relative}`;
|
|
1030
1008
|
} else if (folder === "pages") {
|
|
1031
1009
|
if (isReact) {
|
|
1032
|
-
manifest[`${pascalName}Page`] = `/${
|
|
1010
|
+
manifest[`${pascalName}Page`] = `/${relative}`;
|
|
1033
1011
|
} else if (isVue || isSvelte) {
|
|
1034
|
-
manifest[pascalName] = `/${
|
|
1012
|
+
manifest[pascalName] = `/${relative}`;
|
|
1035
1013
|
} else {
|
|
1036
|
-
manifest[`${pascalName}Page`] = `/${
|
|
1014
|
+
manifest[`${pascalName}Page`] = `/${relative}`;
|
|
1037
1015
|
}
|
|
1038
1016
|
} else {
|
|
1039
|
-
manifest[pascalName] = `/${
|
|
1017
|
+
manifest[pascalName] = `/${relative}`;
|
|
1040
1018
|
}
|
|
1041
1019
|
return manifest;
|
|
1042
1020
|
}, {});
|
|
1043
1021
|
|
|
1044
1022
|
// src/build/generateReactIndexes.ts
|
|
1045
|
-
import { existsSync
|
|
1046
|
-
import { mkdir
|
|
1047
|
-
import { basename
|
|
1023
|
+
import { existsSync } from "fs";
|
|
1024
|
+
import { mkdir, rm, writeFile } from "fs/promises";
|
|
1025
|
+
import { basename, join, resolve } from "path";
|
|
1048
1026
|
var {Glob } = globalThis.Bun;
|
|
1049
|
-
var
|
|
1050
|
-
const fromSource =
|
|
1051
|
-
if (
|
|
1027
|
+
var devClientDir = (() => {
|
|
1028
|
+
const fromSource = resolve(import.meta.dir, "../dev/client");
|
|
1029
|
+
if (existsSync(fromSource))
|
|
1052
1030
|
return fromSource;
|
|
1053
|
-
return
|
|
1031
|
+
return resolve(import.meta.dir, "./dev/client");
|
|
1054
1032
|
})();
|
|
1055
|
-
var errorOverlayPath =
|
|
1056
|
-
var
|
|
1057
|
-
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, "/");
|
|
1058
1036
|
var generateReactIndexFiles = async (reactPagesDirectory, reactIndexesDirectory, isDev = false) => {
|
|
1059
1037
|
await rm(reactIndexesDirectory, { force: true, recursive: true });
|
|
1060
|
-
await
|
|
1038
|
+
await mkdir(reactIndexesDirectory);
|
|
1061
1039
|
const pagesGlob = new Glob("*.*");
|
|
1062
1040
|
const files = [];
|
|
1063
|
-
for await (const
|
|
1064
|
-
files.push(
|
|
1041
|
+
for await (const file of pagesGlob.scan({ cwd: reactPagesDirectory })) {
|
|
1042
|
+
files.push(file);
|
|
1065
1043
|
}
|
|
1066
|
-
const promises = files.map(async (
|
|
1067
|
-
const fileName =
|
|
1044
|
+
const promises = files.map(async (file) => {
|
|
1045
|
+
const fileName = basename(file);
|
|
1068
1046
|
const [componentName] = fileName.split(".");
|
|
1069
1047
|
const hmrPreamble = isDev ? [
|
|
1070
1048
|
`window.__HMR_FRAMEWORK__ = "react";`,
|
|
1071
1049
|
`window.__REACT_COMPONENT_KEY__ = "${componentName}Index";`,
|
|
1072
1050
|
`import '${refreshSetupPath}';`,
|
|
1073
|
-
`import '${
|
|
1051
|
+
`import '${hmrClientPath}';`,
|
|
1074
1052
|
`import { showErrorOverlay, hideErrorOverlay } from '${errorOverlayPath}';
|
|
1075
1053
|
`
|
|
1076
1054
|
] : [];
|
|
@@ -1324,11 +1302,11 @@ var generateReactIndexFiles = async (reactPagesDirectory, reactIndexesDirectory,
|
|
|
1324
1302
|
`}`
|
|
1325
1303
|
].join(`
|
|
1326
1304
|
`);
|
|
1327
|
-
return writeFile(
|
|
1305
|
+
return writeFile(join(reactIndexesDirectory, `${componentName}.tsx`), content);
|
|
1328
1306
|
});
|
|
1329
1307
|
await Promise.all(promises);
|
|
1330
1308
|
if (isDev) {
|
|
1331
|
-
await writeFile(
|
|
1309
|
+
await writeFile(join(reactIndexesDirectory, "_refresh.tsx"), `import 'react';
|
|
1332
1310
|
import 'react-dom/client';
|
|
1333
1311
|
`);
|
|
1334
1312
|
}
|
|
@@ -1392,8 +1370,8 @@ var {Glob: Glob2 } = globalThis.Bun;
|
|
|
1392
1370
|
var scanEntryPoints = async (dir, pattern) => {
|
|
1393
1371
|
const entryPaths = [];
|
|
1394
1372
|
const glob = new Glob2(pattern);
|
|
1395
|
-
for await (const
|
|
1396
|
-
entryPaths.push(
|
|
1373
|
+
for await (const file of glob.scan({ absolute: true, cwd: dir })) {
|
|
1374
|
+
entryPaths.push(file);
|
|
1397
1375
|
}
|
|
1398
1376
|
return entryPaths;
|
|
1399
1377
|
};
|
|
@@ -1435,17 +1413,17 @@ var updateAssetPaths = async (manifest, directory) => {
|
|
|
1435
1413
|
};
|
|
1436
1414
|
|
|
1437
1415
|
// src/dev/buildHMRClient.ts
|
|
1438
|
-
import { existsSync as
|
|
1416
|
+
import { existsSync as existsSync2 } from "fs";
|
|
1439
1417
|
var {build: bunBuild } = globalThis.Bun;
|
|
1440
|
-
import { resolve as
|
|
1441
|
-
var
|
|
1442
|
-
const fromSource =
|
|
1443
|
-
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))
|
|
1444
1422
|
return fromSource;
|
|
1445
|
-
return
|
|
1423
|
+
return resolve2(import.meta.dir, "dev/client/hmrClient.ts");
|
|
1446
1424
|
})();
|
|
1447
1425
|
var buildHMRClient = async () => {
|
|
1448
|
-
const entryPoint =
|
|
1426
|
+
const entryPoint = hmrClientPath2;
|
|
1449
1427
|
const result = await bunBuild({
|
|
1450
1428
|
entrypoints: [entryPoint],
|
|
1451
1429
|
format: "iife",
|
|
@@ -1499,18 +1477,18 @@ var getDevVendorPaths = () => devVendorPaths;
|
|
|
1499
1477
|
|
|
1500
1478
|
// src/utils/cleanup.ts
|
|
1501
1479
|
import { rm as rm2 } from "fs/promises";
|
|
1502
|
-
import { join as
|
|
1480
|
+
import { join as join2 } from "path";
|
|
1503
1481
|
var cleanup = async ({
|
|
1504
1482
|
svelteDir,
|
|
1505
1483
|
vueDir,
|
|
1506
1484
|
reactIndexesPath
|
|
1507
1485
|
}) => {
|
|
1508
1486
|
await Promise.all([
|
|
1509
|
-
svelteDir ? rm2(
|
|
1487
|
+
svelteDir ? rm2(join2(svelteDir, "compiled"), {
|
|
1510
1488
|
force: true,
|
|
1511
1489
|
recursive: true
|
|
1512
1490
|
}) : undefined,
|
|
1513
|
-
vueDir ? rm2(
|
|
1491
|
+
vueDir ? rm2(join2(vueDir, "compiled"), { force: true, recursive: true }) : undefined,
|
|
1514
1492
|
reactIndexesPath ? rm2(reactIndexesPath, { force: true, recursive: true }) : undefined
|
|
1515
1493
|
]);
|
|
1516
1494
|
};
|
|
@@ -1575,12 +1553,12 @@ var formatTimestamp = () => {
|
|
|
1575
1553
|
};
|
|
1576
1554
|
var formatPath = (filePath) => {
|
|
1577
1555
|
const cwd = process.cwd();
|
|
1578
|
-
let
|
|
1579
|
-
|
|
1580
|
-
if (!
|
|
1581
|
-
|
|
1556
|
+
let relative = filePath.startsWith(cwd) ? filePath.slice(cwd.length + 1) : filePath;
|
|
1557
|
+
relative = relative.replace(/\\/g, "/");
|
|
1558
|
+
if (!relative.startsWith("/")) {
|
|
1559
|
+
relative = "/" + relative;
|
|
1582
1560
|
}
|
|
1583
|
-
return
|
|
1561
|
+
return relative;
|
|
1584
1562
|
};
|
|
1585
1563
|
var getFrameworkColor = (framework) => {
|
|
1586
1564
|
return frameworkColors[framework] || colors.white;
|
|
@@ -1652,11 +1630,11 @@ var logger = {
|
|
|
1652
1630
|
ready: startupBanner
|
|
1653
1631
|
};
|
|
1654
1632
|
// src/utils/validateSafePath.ts
|
|
1655
|
-
import { resolve as
|
|
1633
|
+
import { resolve as resolve3, relative } from "path";
|
|
1656
1634
|
var validateSafePath = (targetPath, baseDirectory) => {
|
|
1657
|
-
const absoluteBase =
|
|
1658
|
-
const absoluteTarget =
|
|
1659
|
-
const relativePath = normalizePath(
|
|
1635
|
+
const absoluteBase = resolve3(baseDirectory);
|
|
1636
|
+
const absoluteTarget = resolve3(baseDirectory, targetPath);
|
|
1637
|
+
const relativePath = normalizePath(relative(absoluteBase, absoluteTarget));
|
|
1660
1638
|
if (relativePath.startsWith("../") || relativePath === "..") {
|
|
1661
1639
|
throw new Error(`Unsafe path: ${targetPath}`);
|
|
1662
1640
|
}
|
|
@@ -1808,12 +1786,12 @@ var build2 = async ({
|
|
|
1808
1786
|
{ svelteServerPaths, svelteIndexPaths, svelteClientPaths },
|
|
1809
1787
|
{ vueServerPaths, vueIndexPaths, vueClientPaths, vueCssPaths }
|
|
1810
1788
|
] = await Promise.all([
|
|
1811
|
-
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)) : {
|
|
1812
1790
|
svelteClientPaths: [],
|
|
1813
1791
|
svelteIndexPaths: [],
|
|
1814
1792
|
svelteServerPaths: []
|
|
1815
1793
|
},
|
|
1816
|
-
vueDir ? compileVue(vueEntries, vueDir, hmr) : {
|
|
1794
|
+
vueDir ? Promise.resolve().then(() => (init_compileVue(), exports_compileVue)).then((mod) => mod.compileVue(vueEntries, vueDir, hmr)) : {
|
|
1817
1795
|
vueClientPaths: [],
|
|
1818
1796
|
vueCssPaths: [],
|
|
1819
1797
|
vueIndexPaths: [],
|
|
@@ -2889,27 +2867,27 @@ var broadcastToClients = (state, message) => {
|
|
|
2889
2867
|
var parseErrorLocationFromMessage = (msg) => {
|
|
2890
2868
|
const pathLineCol = msg.match(/^([^\s:]+):(\d+)(?::(\d+))?/);
|
|
2891
2869
|
if (pathLineCol) {
|
|
2892
|
-
const [,
|
|
2870
|
+
const [, file3, lineStr, colStr] = pathLineCol;
|
|
2893
2871
|
return {
|
|
2894
|
-
file:
|
|
2872
|
+
file: file3,
|
|
2895
2873
|
line: lineStr ? parseInt(lineStr, 10) : undefined,
|
|
2896
2874
|
column: colStr ? parseInt(colStr, 10) : undefined
|
|
2897
2875
|
};
|
|
2898
2876
|
}
|
|
2899
2877
|
const atMatch = msg.match(/(?:at|in)\s+([^(:\s]+)(?:\s*\([^)]*line\s*(\d+)[^)]*col(?:umn)?\s*(\d+)[^)]*\)|:(\d+):(\d+)?)/i);
|
|
2900
2878
|
if (atMatch) {
|
|
2901
|
-
const [,
|
|
2879
|
+
const [, file3, line1, col1, line2, col2] = atMatch;
|
|
2902
2880
|
return {
|
|
2903
|
-
file:
|
|
2881
|
+
file: file3?.trim(),
|
|
2904
2882
|
line: line1 ? parseInt(line1, 10) : line2 ? parseInt(line2, 10) : undefined,
|
|
2905
2883
|
column: col1 ? parseInt(col1, 10) : col2 ? parseInt(col2, 10) : undefined
|
|
2906
2884
|
};
|
|
2907
2885
|
}
|
|
2908
2886
|
const parenMatch = msg.match(/([^\s(]+)\s*\([^)]*line\s*(\d+)[^)]*col(?:umn)?\s*(\d+)/i);
|
|
2909
2887
|
if (parenMatch) {
|
|
2910
|
-
const [,
|
|
2888
|
+
const [, file3, lineStr, colStr] = parenMatch;
|
|
2911
2889
|
return {
|
|
2912
|
-
file:
|
|
2890
|
+
file: file3 ?? undefined,
|
|
2913
2891
|
line: lineStr ? parseInt(lineStr, 10) : undefined,
|
|
2914
2892
|
column: colStr ? parseInt(colStr, 10) : undefined
|
|
2915
2893
|
};
|
|
@@ -2924,13 +2902,13 @@ var extractBuildErrorDetails = (error, affectedFrameworks, resolvedPaths) => {
|
|
|
2924
2902
|
if (logs && Array.isArray(logs) && logs.length > 0) {
|
|
2925
2903
|
const errLog = logs.find((l) => l.level === "error") ?? logs[0];
|
|
2926
2904
|
const pos = errLog?.position;
|
|
2927
|
-
const
|
|
2905
|
+
const file3 = pos && "file" in pos ? pos.file : undefined;
|
|
2928
2906
|
const line = pos && "line" in pos ? pos.line : undefined;
|
|
2929
2907
|
const column = pos && "column" in pos ? pos.column : undefined;
|
|
2930
2908
|
const lineText = pos && "lineText" in pos ? pos.lineText : undefined;
|
|
2931
|
-
const framework =
|
|
2909
|
+
const framework = file3 && resolvedPaths ? detectFramework(file3, resolvedPaths) : affectedFrameworks[0] ?? "unknown";
|
|
2932
2910
|
return {
|
|
2933
|
-
file:
|
|
2911
|
+
file: file3,
|
|
2934
2912
|
line,
|
|
2935
2913
|
column,
|
|
2936
2914
|
lineText,
|
|
@@ -3089,7 +3067,7 @@ var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) =>
|
|
|
3089
3067
|
if (filesToRebuild && filesToRebuild.length > 0) {
|
|
3090
3068
|
const allModuleUpdates = [];
|
|
3091
3069
|
for (const framework of affectedFrameworks) {
|
|
3092
|
-
const frameworkFiles = filesToRebuild.filter((
|
|
3070
|
+
const frameworkFiles = filesToRebuild.filter((file3) => detectFramework(file3, state.resolvedPaths) === framework);
|
|
3093
3071
|
if (frameworkFiles.length > 0) {
|
|
3094
3072
|
const moduleUpdates = createModuleUpdates(frameworkFiles, framework, manifest, state.resolvedPaths);
|
|
3095
3073
|
if (moduleUpdates.length > 0) {
|
|
@@ -3098,17 +3076,17 @@ var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) =>
|
|
|
3098
3076
|
}
|
|
3099
3077
|
}
|
|
3100
3078
|
if (affectedFrameworks.includes("react") && filesToRebuild && state.resolvedPaths.reactDir) {
|
|
3101
|
-
const reactFiles = filesToRebuild.filter((
|
|
3079
|
+
const reactFiles = filesToRebuild.filter((file3) => detectFramework(file3, state.resolvedPaths) === "react");
|
|
3102
3080
|
if (reactFiles.length > 0) {
|
|
3103
|
-
const reactPageFiles = reactFiles.filter((
|
|
3104
|
-
const normalized =
|
|
3081
|
+
const reactPageFiles = reactFiles.filter((file3) => {
|
|
3082
|
+
const normalized = file3.replace(/\\/g, "/");
|
|
3105
3083
|
return normalized.includes("/pages/");
|
|
3106
3084
|
});
|
|
3107
3085
|
const sourceFiles = reactPageFiles.length > 0 ? reactPageFiles : reactFiles;
|
|
3108
3086
|
const primarySource = sourceFiles[0];
|
|
3109
3087
|
try {
|
|
3110
|
-
const hasComponentChanges = reactFiles.some((
|
|
3111
|
-
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"));
|
|
3112
3090
|
if (hasCSSChanges && !hasComponentChanges) {
|
|
3113
3091
|
logger.cssUpdate(primarySource ?? reactFiles[0] ?? "", "react", duration);
|
|
3114
3092
|
} else {
|
|
@@ -3129,7 +3107,7 @@ var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) =>
|
|
|
3129
3107
|
}
|
|
3130
3108
|
}
|
|
3131
3109
|
if (affectedFrameworks.includes("html") && filesToRebuild && state.resolvedPaths.htmlDir) {
|
|
3132
|
-
const htmlFrameworkFiles = filesToRebuild.filter((
|
|
3110
|
+
const htmlFrameworkFiles = filesToRebuild.filter((file3) => detectFramework(file3, state.resolvedPaths) === "html");
|
|
3133
3111
|
if (htmlFrameworkFiles.length > 0) {
|
|
3134
3112
|
const scriptFiles = htmlFrameworkFiles.filter((f) => (f.endsWith(".ts") || f.endsWith(".js") || f.endsWith(".tsx") || f.endsWith(".jsx")) && f.replace(/\\/g, "/").includes("/scripts/"));
|
|
3135
3113
|
const htmlPageFiles = htmlFrameworkFiles.filter((f) => f.endsWith(".html"));
|
|
@@ -3160,7 +3138,7 @@ var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) =>
|
|
|
3160
3138
|
}
|
|
3161
3139
|
}
|
|
3162
3140
|
if (affectedFrameworks.includes("html") && filesToRebuild && state.resolvedPaths.htmlDir) {
|
|
3163
|
-
const htmlFrameworkFiles = filesToRebuild.filter((
|
|
3141
|
+
const htmlFrameworkFiles = filesToRebuild.filter((file3) => detectFramework(file3, state.resolvedPaths) === "html");
|
|
3164
3142
|
if (htmlFrameworkFiles.length > 0) {
|
|
3165
3143
|
const htmlPageFiles = htmlFrameworkFiles.filter((f) => f.endsWith(".html"));
|
|
3166
3144
|
const pagesToUpdate = htmlPageFiles;
|
|
@@ -3188,7 +3166,7 @@ var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) =>
|
|
|
3188
3166
|
}
|
|
3189
3167
|
}
|
|
3190
3168
|
if (affectedFrameworks.includes("vue") && filesToRebuild && config.vueDirectory) {
|
|
3191
|
-
const vueFiles = filesToRebuild.filter((
|
|
3169
|
+
const vueFiles = filesToRebuild.filter((file3) => detectFramework(file3, state.resolvedPaths) === "vue");
|
|
3192
3170
|
if (vueFiles.length > 0) {
|
|
3193
3171
|
const vueComponentFiles = vueFiles.filter((f) => f.endsWith(".vue"));
|
|
3194
3172
|
const vueCssFiles = vueFiles.filter((f) => f.endsWith(".css"));
|
|
@@ -3220,13 +3198,13 @@ var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) =>
|
|
|
3220
3198
|
}
|
|
3221
3199
|
for (const vuePagePath of pagesToUpdate) {
|
|
3222
3200
|
try {
|
|
3223
|
-
const { basename: basename9, relative:
|
|
3201
|
+
const { basename: basename9, relative: relative4 } = await import("path");
|
|
3224
3202
|
const { toPascal: toPascal2 } = await Promise.resolve().then(() => exports_stringModifiers);
|
|
3225
3203
|
const fileName = basename9(vuePagePath);
|
|
3226
3204
|
const baseName = fileName.replace(/\.vue$/, "");
|
|
3227
3205
|
const pascalName = toPascal2(baseName);
|
|
3228
3206
|
const vueRoot = config.vueDirectory;
|
|
3229
|
-
const hmrId = vueRoot ?
|
|
3207
|
+
const hmrId = vueRoot ? relative4(vueRoot, vuePagePath).replace(/\\/g, "/").replace(/\.vue$/, "") : baseName;
|
|
3230
3208
|
const cssKey = `${pascalName}CSS`;
|
|
3231
3209
|
const cssUrl = manifest[cssKey] || null;
|
|
3232
3210
|
const { vueHmrMetadata: vueHmrMetadata2 } = await Promise.resolve().then(() => (init_compileVue(), exports_compileVue));
|
|
@@ -3272,7 +3250,7 @@ var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) =>
|
|
|
3272
3250
|
}
|
|
3273
3251
|
}
|
|
3274
3252
|
if (affectedFrameworks.includes("svelte") && filesToRebuild && config.svelteDirectory) {
|
|
3275
|
-
const svelteFiles = filesToRebuild.filter((
|
|
3253
|
+
const svelteFiles = filesToRebuild.filter((file3) => detectFramework(file3, state.resolvedPaths) === "svelte");
|
|
3276
3254
|
if (svelteFiles.length > 0) {
|
|
3277
3255
|
const svelteComponentFiles = svelteFiles.filter((f) => f.endsWith(".svelte"));
|
|
3278
3256
|
const svelteCssFiles = svelteFiles.filter((f) => f.endsWith(".css"));
|
|
@@ -3331,7 +3309,7 @@ var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) =>
|
|
|
3331
3309
|
}
|
|
3332
3310
|
}
|
|
3333
3311
|
if (affectedFrameworks.includes("htmx") && filesToRebuild && state.resolvedPaths.htmxDir) {
|
|
3334
|
-
const htmxFrameworkFiles = filesToRebuild.filter((
|
|
3312
|
+
const htmxFrameworkFiles = filesToRebuild.filter((file3) => detectFramework(file3, state.resolvedPaths) === "htmx");
|
|
3335
3313
|
if (htmxFrameworkFiles.length > 0) {
|
|
3336
3314
|
const htmxScriptFiles = htmxFrameworkFiles.filter((f) => (f.endsWith(".ts") || f.endsWith(".js") || f.endsWith(".tsx") || f.endsWith(".jsx")) && f.replace(/\\/g, "/").includes("/scripts/"));
|
|
3337
3315
|
const htmxHtmlFiles = htmxFrameworkFiles.filter((f) => f.endsWith(".html"));
|
|
@@ -3360,7 +3338,7 @@ var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) =>
|
|
|
3360
3338
|
}
|
|
3361
3339
|
}
|
|
3362
3340
|
if (affectedFrameworks.includes("htmx") && filesToRebuild && state.resolvedPaths.htmxDir) {
|
|
3363
|
-
const htmxFrameworkFiles = filesToRebuild.filter((
|
|
3341
|
+
const htmxFrameworkFiles = filesToRebuild.filter((file3) => detectFramework(file3, state.resolvedPaths) === "htmx");
|
|
3364
3342
|
if (htmxFrameworkFiles.length > 0) {
|
|
3365
3343
|
const htmxPageFiles = htmxFrameworkFiles.filter((f) => f.endsWith(".html"));
|
|
3366
3344
|
const isSingle = !config.reactDirectory && !config.svelteDirectory && !config.vueDirectory && !config.htmlDirectory;
|
|
@@ -3560,9 +3538,10 @@ var asset = (source, name) => {
|
|
|
3560
3538
|
}
|
|
3561
3539
|
return assetPath;
|
|
3562
3540
|
};
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3541
|
+
// src/core/pageHandlers.ts
|
|
3542
|
+
var {file: file3 } = globalThis.Bun;
|
|
3543
|
+
var handleHTMLPageRequest = (pagePath) => file3(pagePath);
|
|
3544
|
+
var handleHTMXPageRequest = (pagePath) => file3(pagePath);
|
|
3566
3545
|
// src/plugins/pageRouter.ts
|
|
3567
3546
|
var pageRouterPlugin = () => {
|
|
3568
3547
|
console.log("Page Router Plugin Not Implemented Yet");
|
|
@@ -3761,10 +3740,6 @@ export {
|
|
|
3761
3740
|
isValidHMRClientMessage,
|
|
3762
3741
|
hmrState,
|
|
3763
3742
|
hmr,
|
|
3764
|
-
handleVuePageRequest,
|
|
3765
|
-
handleSveltePageRequest,
|
|
3766
|
-
handleReactPageRequest,
|
|
3767
|
-
handlePageRequest,
|
|
3768
3743
|
handleHTMXPageRequest,
|
|
3769
3744
|
handleHTMLPageRequest,
|
|
3770
3745
|
getRegisterClientScript,
|
|
@@ -3793,5 +3768,5 @@ export {
|
|
|
3793
3768
|
BUN_BUILD_WARNING_SUPPRESSION
|
|
3794
3769
|
};
|
|
3795
3770
|
|
|
3796
|
-
//# debugId=
|
|
3771
|
+
//# debugId=05B6DFB97B78673E64756E2164756E21
|
|
3797
3772
|
//# sourceMappingURL=index.js.map
|