@absolutejs/absolute 0.19.0-beta.852 → 0.19.0-beta.853
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/angular/components/core/streamingSlotRegistrar.js +1 -1
- package/dist/angular/components/core/streamingSlotRegistry.js +2 -2
- package/dist/angular/index.js +3 -1
- package/dist/angular/index.js.map +3 -3
- package/dist/angular/server.js +3 -1
- package/dist/angular/server.js.map +3 -3
- package/dist/build.js +1919 -284
- package/dist/build.js.map +17 -7
- package/dist/dev/client/handlers/angularHmrShim.ts +77 -0
- package/dist/dev/client/hmrClient.ts +21 -0
- package/dist/index.js +2006 -329
- package/dist/index.js.map +18 -8
- package/dist/react/index.js +3 -1
- package/dist/react/index.js.map +2 -2
- package/dist/react/server.js +3 -1
- package/dist/react/server.js.map +2 -2
- package/dist/src/core/prepare.d.ts +25 -0
- package/dist/src/dev/angular/fastHmrCompiler.d.ts +19 -0
- package/dist/src/dev/angular/hmrCompiler.d.ts +18 -0
- package/dist/src/dev/angular/hmrImportGenerator.d.ts +3 -0
- package/dist/src/dev/angular/hmrInjectionPlugin.d.ts +7 -0
- package/dist/src/dev/angular/resolveOwningComponents.d.ts +8 -0
- package/dist/src/dev/angular/vendor/translator/api/ast_factory.d.ts +363 -0
- package/dist/src/dev/angular/vendor/translator/api/import_generator.d.ts +49 -0
- package/dist/src/dev/angular/vendor/translator/context.d.ts +18 -0
- package/dist/src/dev/angular/vendor/translator/translator.d.ts +75 -0
- package/dist/src/dev/angular/vendor/translator/ts_util.d.ts +12 -0
- package/dist/src/dev/angular/vendor/translator/typescript_ast_factory.d.ts +66 -0
- package/dist/src/dev/angular/vendor/translator/typescript_translator.d.ts +13 -0
- package/dist/src/plugins/hmr.d.ts +25 -0
- package/dist/src/vue/components/Image.d.ts +1 -1
- package/dist/svelte/index.js +3 -1
- package/dist/svelte/index.js.map +2 -2
- package/dist/svelte/server.js +3 -1
- package/dist/svelte/server.js.map +2 -2
- package/dist/vue/index.js +3 -1
- package/dist/vue/index.js.map +2 -2
- package/dist/vue/server.js +3 -1
- package/dist/vue/server.js.map +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8573,6 +8573,8 @@ var colors2, frameworkColors, formatPath = (filePath) => {
|
|
|
8573
8573
|
console.error(`${timestamp} ${tag} ${fullMessage}`);
|
|
8574
8574
|
}, logHmrUpdate = (path, framework, duration) => {
|
|
8575
8575
|
log("hmr update", { duration, framework, path });
|
|
8576
|
+
}, logInfo = (message) => {
|
|
8577
|
+
log(message);
|
|
8576
8578
|
}, logScriptUpdate = (path, framework, duration) => {
|
|
8577
8579
|
log("script update", { duration, framework, path });
|
|
8578
8580
|
}, logServerReload = () => {
|
|
@@ -9823,19 +9825,87 @@ var init_angularLinkerPlugin = __esm(() => {
|
|
|
9823
9825
|
angularLinkerPlugin = createAngularLinkerPlugin(false);
|
|
9824
9826
|
});
|
|
9825
9827
|
|
|
9828
|
+
// src/dev/angular/hmrInjectionPlugin.ts
|
|
9829
|
+
var exports_hmrInjectionPlugin = {};
|
|
9830
|
+
__export(exports_hmrInjectionPlugin, {
|
|
9831
|
+
createAngularHmrInjectionPlugin: () => createAngularHmrInjectionPlugin
|
|
9832
|
+
});
|
|
9833
|
+
import { readFile as readFile5 } from "fs/promises";
|
|
9834
|
+
import { relative as relative6, resolve as resolve15 } from "path";
|
|
9835
|
+
var COMPONENT_DECORATOR_RE, buildHmrTail = (className, encodedIdLiteral) => `
|
|
9836
|
+
|
|
9837
|
+
// absolutejs HMR \u2014 auto-generated; mirrors compileHmrInitializer from
|
|
9838
|
+
// @angular/compiler with import.meta.hot adapted to globalThis.__angularHmr.
|
|
9839
|
+
{
|
|
9840
|
+
const __ng_hmr_id = ${encodedIdLiteral};
|
|
9841
|
+
const __ng_hmr_load = async (t) => {
|
|
9842
|
+
const [u, core] = await Promise.all([
|
|
9843
|
+
import('/@ng/component?c=' + encodeURIComponent(__ng_hmr_id) + '&t=' + t),
|
|
9844
|
+
import('@angular/core')
|
|
9845
|
+
]);
|
|
9846
|
+
if (u && typeof u.default === 'function') u.default(${className}, [core]);
|
|
9847
|
+
};
|
|
9848
|
+
if (typeof globalThis !== 'undefined' &&
|
|
9849
|
+
globalThis.__angularHmr &&
|
|
9850
|
+
typeof globalThis.__angularHmr.on === 'function') {
|
|
9851
|
+
globalThis.__angularHmr.on('angular:component-update', (d) => {
|
|
9852
|
+
if (d && d.id === __ng_hmr_id) __ng_hmr_load(d.timestamp);
|
|
9853
|
+
});
|
|
9854
|
+
}
|
|
9855
|
+
}
|
|
9856
|
+
`, createAngularHmrInjectionPlugin = (params) => {
|
|
9857
|
+
const { generatedAngularRoot, userAngularRoot, projectRoot } = params;
|
|
9858
|
+
const normalizedGenRoot = resolve15(generatedAngularRoot).replace(/\\/g, "/");
|
|
9859
|
+
return {
|
|
9860
|
+
name: "absolute-angular-hmr-injection",
|
|
9861
|
+
setup(build2) {
|
|
9862
|
+
build2.onLoad({ filter: /\.component\.js$/ }, async (args) => {
|
|
9863
|
+
const normalizedPath = args.path.replace(/\\/g, "/");
|
|
9864
|
+
if (!normalizedPath.startsWith(normalizedGenRoot + "/"))
|
|
9865
|
+
return;
|
|
9866
|
+
const text = await readFile5(args.path, "utf8");
|
|
9867
|
+
const seen = new Set;
|
|
9868
|
+
const classNames = [];
|
|
9869
|
+
let match;
|
|
9870
|
+
const re2 = new RegExp(COMPONENT_DECORATOR_RE.source, COMPONENT_DECORATOR_RE.flags);
|
|
9871
|
+
while ((match = re2.exec(text)) !== null) {
|
|
9872
|
+
const className = match[1];
|
|
9873
|
+
if (className && !seen.has(className)) {
|
|
9874
|
+
seen.add(className);
|
|
9875
|
+
classNames.push(className);
|
|
9876
|
+
}
|
|
9877
|
+
}
|
|
9878
|
+
if (classNames.length === 0)
|
|
9879
|
+
return;
|
|
9880
|
+
const relFromGenRoot = relative6(generatedAngularRoot, args.path).replace(/\\/g, "/");
|
|
9881
|
+
const userTsPath = resolve15(userAngularRoot, relFromGenRoot.replace(/\.js$/, ".ts"));
|
|
9882
|
+
const projectRel = relative6(projectRoot, userTsPath).replace(/\\/g, "/");
|
|
9883
|
+
const tail = classNames.map((className) => {
|
|
9884
|
+
const id = `${projectRel}@${className}`;
|
|
9885
|
+
return buildHmrTail(className, JSON.stringify(id));
|
|
9886
|
+
}).join("");
|
|
9887
|
+
return { contents: text + tail, loader: "js" };
|
|
9888
|
+
});
|
|
9889
|
+
}
|
|
9890
|
+
};
|
|
9891
|
+
};
|
|
9892
|
+
var init_hmrInjectionPlugin = __esm(() => {
|
|
9893
|
+
COMPONENT_DECORATOR_RE = /([A-Z][A-Za-z0-9_$]*)\s*=\s*__legacyDecorateClassTS[A-Za-z0-9_$]*\s*\(\s*\[[\s\S]*?\bComponent[A-Za-z0-9_$]*\s*\(/g;
|
|
9894
|
+
});
|
|
9895
|
+
|
|
9826
9896
|
// src/utils/cleanStaleOutputs.ts
|
|
9827
9897
|
import { rm as rm2 } from "fs/promises";
|
|
9828
|
-
import { resolve as
|
|
9898
|
+
import { resolve as resolve16 } from "path";
|
|
9829
9899
|
var {Glob: Glob5 } = globalThis.Bun;
|
|
9830
9900
|
var HASHED_FILE_PATTERN, cleanStaleOutputs = async (buildPath, currentOutputPaths) => {
|
|
9831
|
-
const currentPaths = new Set(currentOutputPaths.map((path) =>
|
|
9901
|
+
const currentPaths = new Set(currentOutputPaths.map((path) => resolve16(path)));
|
|
9832
9902
|
const glob = new Glob5("**/*");
|
|
9833
9903
|
const removals = [];
|
|
9834
|
-
for (const
|
|
9835
|
-
const absolute =
|
|
9904
|
+
for (const relative7 of glob.scanSync({ cwd: buildPath })) {
|
|
9905
|
+
const absolute = resolve16(buildPath, relative7);
|
|
9836
9906
|
if (currentPaths.has(absolute))
|
|
9837
9907
|
continue;
|
|
9838
|
-
if (!HASHED_FILE_PATTERN.test(
|
|
9908
|
+
if (!HASHED_FILE_PATTERN.test(relative7))
|
|
9839
9909
|
continue;
|
|
9840
9910
|
removals.push(rm2(absolute, { force: true }));
|
|
9841
9911
|
}
|
|
@@ -10064,11 +10134,11 @@ var init_buildDirectoryLock = __esm(() => {
|
|
|
10064
10134
|
});
|
|
10065
10135
|
|
|
10066
10136
|
// src/utils/validateSafePath.ts
|
|
10067
|
-
import { resolve as
|
|
10137
|
+
import { resolve as resolve17, relative as relative7 } from "path";
|
|
10068
10138
|
var validateSafePath = (targetPath, baseDirectory) => {
|
|
10069
|
-
const absoluteBase =
|
|
10070
|
-
const absoluteTarget =
|
|
10071
|
-
const relativePath = normalizePath(
|
|
10139
|
+
const absoluteBase = resolve17(baseDirectory);
|
|
10140
|
+
const absoluteTarget = resolve17(baseDirectory, targetPath);
|
|
10141
|
+
const relativePath = normalizePath(relative7(absoluteBase, absoluteTarget));
|
|
10072
10142
|
if (relativePath.startsWith("../") || relativePath === "..") {
|
|
10073
10143
|
throw new Error(`Unsafe path: ${targetPath}`);
|
|
10074
10144
|
}
|
|
@@ -10145,22 +10215,22 @@ import {
|
|
|
10145
10215
|
join as join16,
|
|
10146
10216
|
basename as basename5,
|
|
10147
10217
|
extname as extname5,
|
|
10148
|
-
resolve as
|
|
10149
|
-
relative as
|
|
10218
|
+
resolve as resolve18,
|
|
10219
|
+
relative as relative8,
|
|
10150
10220
|
sep as sep2
|
|
10151
10221
|
} from "path";
|
|
10152
10222
|
import { env as env2 } from "process";
|
|
10153
10223
|
var {write, file: file2, Transpiler } = globalThis.Bun;
|
|
10154
10224
|
var resolveDevClientDir2 = () => {
|
|
10155
10225
|
const projectRoot = process.cwd();
|
|
10156
|
-
const fromSource =
|
|
10226
|
+
const fromSource = resolve18(import.meta.dir, "../dev/client");
|
|
10157
10227
|
if (existsSync15(fromSource) && fromSource.startsWith(projectRoot)) {
|
|
10158
10228
|
return fromSource;
|
|
10159
10229
|
}
|
|
10160
|
-
const fromNodeModules =
|
|
10230
|
+
const fromNodeModules = resolve18(projectRoot, "node_modules/@absolutejs/absolute/dist/dev/client");
|
|
10161
10231
|
if (existsSync15(fromNodeModules))
|
|
10162
10232
|
return fromNodeModules;
|
|
10163
|
-
return
|
|
10233
|
+
return resolve18(import.meta.dir, "./dev/client");
|
|
10164
10234
|
}, devClientDir2, hmrClientPath3, persistentCache, sourceHashCache, clearSvelteCompilerCache = () => {
|
|
10165
10235
|
persistentCache.clear();
|
|
10166
10236
|
sourceHashCache.clear();
|
|
@@ -10190,7 +10260,7 @@ var resolveDevClientDir2 = () => {
|
|
|
10190
10260
|
}, resolveRelativeModule2 = async (spec, from) => {
|
|
10191
10261
|
if (!spec.startsWith("."))
|
|
10192
10262
|
return null;
|
|
10193
|
-
const basePath =
|
|
10263
|
+
const basePath = resolve18(dirname11(from), spec);
|
|
10194
10264
|
const candidates = [
|
|
10195
10265
|
basePath,
|
|
10196
10266
|
`${basePath}.ts`,
|
|
@@ -10217,7 +10287,7 @@ var resolveDevClientDir2 = () => {
|
|
|
10217
10287
|
const resolved = resolvePackageImport(spec);
|
|
10218
10288
|
return resolved && /\.svelte(\.(?:ts|js))?$/.test(resolved) ? resolved : null;
|
|
10219
10289
|
}
|
|
10220
|
-
const basePath =
|
|
10290
|
+
const basePath = resolve18(dirname11(from), spec);
|
|
10221
10291
|
const explicit = /\.(svelte|svelte\.(?:ts|js))$/.test(basePath);
|
|
10222
10292
|
if (!explicit) {
|
|
10223
10293
|
const extensions = [".svelte", ".svelte.ts", ".svelte.js"];
|
|
@@ -10238,8 +10308,8 @@ var resolveDevClientDir2 = () => {
|
|
|
10238
10308
|
return jsPath;
|
|
10239
10309
|
return null;
|
|
10240
10310
|
}, addModuleRewrite = (rewrites, rawSpec, resolvedModule, ssrOutputDir, clientOutputDir) => {
|
|
10241
|
-
const toServer =
|
|
10242
|
-
const toClient =
|
|
10311
|
+
const toServer = relative8(ssrOutputDir, resolvedModule).replace(/\\/g, "/");
|
|
10312
|
+
const toClient = relative8(clientOutputDir, resolvedModule).replace(/\\/g, "/");
|
|
10243
10313
|
rewrites.set(rawSpec, {
|
|
10244
10314
|
client: toClient.startsWith(".") || toClient.startsWith("/") ? toClient : `./${toClient}`,
|
|
10245
10315
|
server: toServer.startsWith(".") ? toServer : `./${toServer}`
|
|
@@ -10277,8 +10347,8 @@ var resolveDevClientDir2 = () => {
|
|
|
10277
10347
|
const preprocessedClient = isModule ? loweredClientSource.code : (await preprocess(loweredClientSource.code, svelteStylePreprocessor)).code;
|
|
10278
10348
|
const transpiledServer = src.endsWith(".ts") || src.endsWith(".svelte.ts") ? transpiler2.transformSync(preprocessedServer) : preprocessedServer;
|
|
10279
10349
|
const transpiledClient = src.endsWith(".ts") || src.endsWith(".svelte.ts") ? transpiler2.transformSync(preprocessedClient) : preprocessedClient;
|
|
10280
|
-
const rawRel = dirname11(
|
|
10281
|
-
const relDir = rawRel.startsWith("..") ? `_ext/${
|
|
10350
|
+
const rawRel = dirname11(relative8(svelteRoot, src)).replace(/\\/g, "/");
|
|
10351
|
+
const relDir = rawRel.startsWith("..") ? `_ext/${relative8(process.cwd(), dirname11(src)).replace(/\\/g, "/")}` : rawRel;
|
|
10282
10352
|
const baseName = basename5(src).replace(/\.svelte(\.(ts|js))?$/, "");
|
|
10283
10353
|
const importPaths = Array.from(transpiledServer.matchAll(/from\s+['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((path) => path !== undefined);
|
|
10284
10354
|
const resolvedModuleImports = await Promise.all(importPaths.map((importPath) => resolveRelativeModule2(importPath, src)));
|
|
@@ -10299,15 +10369,15 @@ var resolveDevClientDir2 = () => {
|
|
|
10299
10369
|
addModuleRewrite(externalRewrites, rawSpec, resolvedModule, ssrOutputDir, clientOutputDir);
|
|
10300
10370
|
if (!resolved)
|
|
10301
10371
|
continue;
|
|
10302
|
-
const childRel =
|
|
10372
|
+
const childRel = relative8(svelteRoot, resolved).replace(/\\/g, "/");
|
|
10303
10373
|
if (!childRel.startsWith(".."))
|
|
10304
10374
|
continue;
|
|
10305
10375
|
const childBuilt2 = cache.get(resolved);
|
|
10306
10376
|
if (!childBuilt2)
|
|
10307
10377
|
continue;
|
|
10308
10378
|
const origSpec = rawSpec.replace(/\.svelte(?:\.(?:ts|js))?$/, ".js");
|
|
10309
|
-
const toServer =
|
|
10310
|
-
const toClient =
|
|
10379
|
+
const toServer = relative8(ssrOutputDir, childBuilt2.ssr).replace(/\\/g, "/");
|
|
10380
|
+
const toClient = relative8(clientOutputDir, childBuilt2.client).replace(/\\/g, "/");
|
|
10311
10381
|
externalRewrites.set(origSpec, {
|
|
10312
10382
|
client: toClient.startsWith(".") ? toClient : `./${toClient}`,
|
|
10313
10383
|
server: toServer.startsWith(".") ? toServer : `./${toServer}`
|
|
@@ -10341,7 +10411,7 @@ var resolveDevClientDir2 = () => {
|
|
|
10341
10411
|
}).js.code;
|
|
10342
10412
|
let code = compiled.replace(/\.svelte(?:\.(?:ts|js))?(['"])/g, ".js$1");
|
|
10343
10413
|
if (mode === "client" && isDev2) {
|
|
10344
|
-
const moduleKey = `/@src/${
|
|
10414
|
+
const moduleKey = `/@src/${relative8(process.cwd(), src).replace(/\\/g, "/")}`;
|
|
10345
10415
|
code = code.replace(/if\s*\(import\.meta\.hot\)\s*\{/, `if (typeof window !== "undefined") {
|
|
10346
10416
|
if (!window.__SVELTE_HMR_ACCEPT__) window.__SVELTE_HMR_ACCEPT__ = {};
|
|
10347
10417
|
var __hmr_accept = function(cb) { window.__SVELTE_HMR_ACCEPT__[${JSON.stringify(moduleKey)}] = cb; };`);
|
|
@@ -10384,10 +10454,10 @@ var resolveDevClientDir2 = () => {
|
|
|
10384
10454
|
};
|
|
10385
10455
|
const roots = await Promise.all(entryPoints.map(build2));
|
|
10386
10456
|
await Promise.all(roots.map(async ({ client: client2, hasAwaitSlot }) => {
|
|
10387
|
-
const relClientDir = dirname11(
|
|
10457
|
+
const relClientDir = dirname11(relative8(clientDir, client2));
|
|
10388
10458
|
const name = basename5(client2, extname5(client2));
|
|
10389
10459
|
const indexPath = join16(indexDir, relClientDir, `${name}.js`);
|
|
10390
|
-
const importRaw =
|
|
10460
|
+
const importRaw = relative8(dirname11(indexPath), client2).split(sep2).join("/");
|
|
10391
10461
|
const importPath = importRaw.startsWith(".") || importRaw.startsWith("/") ? importRaw : `./${importRaw}`;
|
|
10392
10462
|
const hmrImports = isDev2 ? `window.__HMR_FRAMEWORK__ = "svelte";
|
|
10393
10463
|
import "${hmrClientPath3}";
|
|
@@ -10464,7 +10534,7 @@ if (typeof window !== "undefined") {
|
|
|
10464
10534
|
return {
|
|
10465
10535
|
svelteClientPaths: roots.map(({ client: client2 }) => client2),
|
|
10466
10536
|
svelteIndexPaths: roots.map(({ client: client2 }) => {
|
|
10467
|
-
const rel = dirname11(
|
|
10537
|
+
const rel = dirname11(relative8(clientDir, client2));
|
|
10468
10538
|
return join16(indexDir, rel, basename5(client2));
|
|
10469
10539
|
}),
|
|
10470
10540
|
svelteServerPaths: roots.map(({ ssr }) => ssr)
|
|
@@ -10553,20 +10623,20 @@ import {
|
|
|
10553
10623
|
dirname as dirname12,
|
|
10554
10624
|
isAbsolute as isAbsolute3,
|
|
10555
10625
|
join as join17,
|
|
10556
|
-
relative as
|
|
10557
|
-
resolve as
|
|
10626
|
+
relative as relative9,
|
|
10627
|
+
resolve as resolve19
|
|
10558
10628
|
} from "path";
|
|
10559
10629
|
var {file: file3, write: write2, Transpiler: Transpiler2 } = globalThis.Bun;
|
|
10560
10630
|
var resolveDevClientDir3 = () => {
|
|
10561
10631
|
const projectRoot = process.cwd();
|
|
10562
|
-
const fromSource =
|
|
10632
|
+
const fromSource = resolve19(import.meta.dir, "../dev/client");
|
|
10563
10633
|
if (existsSync16(fromSource) && fromSource.startsWith(projectRoot)) {
|
|
10564
10634
|
return fromSource;
|
|
10565
10635
|
}
|
|
10566
|
-
const fromNodeModules =
|
|
10636
|
+
const fromNodeModules = resolve19(projectRoot, "node_modules/@absolutejs/absolute/dist/dev/client");
|
|
10567
10637
|
if (existsSync16(fromNodeModules))
|
|
10568
10638
|
return fromNodeModules;
|
|
10569
|
-
return
|
|
10639
|
+
return resolve19(import.meta.dir, "./dev/client");
|
|
10570
10640
|
}, devClientDir3, hmrClientPath4, transpiler3, scriptCache, scriptSetupCache, templateCache, styleCache, persistentBuildCache, vueSourceHashCache, vueHmrMetadata, clearVueHmrCaches = () => {
|
|
10571
10641
|
scriptCache.clear();
|
|
10572
10642
|
scriptSetupCache.clear();
|
|
@@ -10605,14 +10675,14 @@ var resolveDevClientDir3 = () => {
|
|
|
10605
10675
|
return "template-only";
|
|
10606
10676
|
}
|
|
10607
10677
|
return "full";
|
|
10608
|
-
}, generateVueHmrId = (sourceFilePath, vueRootDir) =>
|
|
10678
|
+
}, generateVueHmrId = (sourceFilePath, vueRootDir) => relative9(vueRootDir, sourceFilePath).replace(/\\/g, "/").replace(/\.vue$/, ""), extractImports = (sourceCode) => Array.from(sourceCode.matchAll(/import\s+[\s\S]+?['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((importPath) => importPath !== undefined), toJs = (filePath, sourceDir) => {
|
|
10609
10679
|
if (filePath.endsWith(".vue"))
|
|
10610
10680
|
return filePath.replace(/\.vue$/, ".js");
|
|
10611
10681
|
if (filePath.endsWith(".ts"))
|
|
10612
10682
|
return filePath.replace(/\.ts$/, ".js");
|
|
10613
10683
|
if (isStylePath(filePath)) {
|
|
10614
10684
|
if (sourceDir && (filePath.startsWith("./") || filePath.startsWith("../"))) {
|
|
10615
|
-
return
|
|
10685
|
+
return resolve19(sourceDir, filePath);
|
|
10616
10686
|
}
|
|
10617
10687
|
return filePath;
|
|
10618
10688
|
}
|
|
@@ -10638,7 +10708,7 @@ var resolveDevClientDir3 = () => {
|
|
|
10638
10708
|
const cachedResult = cacheMap.get(sourceFilePath);
|
|
10639
10709
|
if (cachedResult)
|
|
10640
10710
|
return cachedResult;
|
|
10641
|
-
const relativeFilePath =
|
|
10711
|
+
const relativeFilePath = relative9(vueRootDir, sourceFilePath).replace(/\\/g, "/");
|
|
10642
10712
|
const relativeWithoutExtension = relativeFilePath.replace(/\.vue$/, "");
|
|
10643
10713
|
const fileBaseName = basename6(sourceFilePath, ".vue");
|
|
10644
10714
|
const componentId = toKebab(fileBaseName);
|
|
@@ -10676,12 +10746,12 @@ var resolveDevClientDir3 = () => {
|
|
|
10676
10746
|
const childComponentPaths = importPaths.filter((path) => path.startsWith(".") && path.endsWith(".vue"));
|
|
10677
10747
|
const packageComponentPaths = Array.from(resolvedPackageVueImports.entries());
|
|
10678
10748
|
const helperModulePaths = importPaths.filter((path) => path.startsWith(".") && !path.endsWith(".vue") && !isStylePath(path));
|
|
10679
|
-
const stylePathsImported = importPaths.filter((path) => (path.startsWith(".") || isAbsolute3(path)) && isStylePath(path)).map((path) => isAbsolute3(path) ? path :
|
|
10749
|
+
const stylePathsImported = importPaths.filter((path) => (path.startsWith(".") || isAbsolute3(path)) && isStylePath(path)).map((path) => isAbsolute3(path) ? path : resolve19(dirname12(sourceFilePath), path));
|
|
10680
10750
|
for (const stylePath of stylePathsImported) {
|
|
10681
10751
|
addStyleImporter(sourceFilePath, stylePath);
|
|
10682
10752
|
}
|
|
10683
10753
|
const childBuildResults = await Promise.all([
|
|
10684
|
-
...childComponentPaths.map((relativeChildPath) => compileVueFile(
|
|
10754
|
+
...childComponentPaths.map((relativeChildPath) => compileVueFile(resolve19(dirname12(sourceFilePath), relativeChildPath), outputDirs, cacheMap, false, vueRootDir, compiler, stylePreprocessors)),
|
|
10685
10755
|
...packageComponentPaths.map(([, absolutePath]) => compileVueFile(absolutePath, outputDirs, cacheMap, false, vueRootDir, compiler, stylePreprocessors))
|
|
10686
10756
|
]);
|
|
10687
10757
|
const hasScript = descriptor.script || descriptor.scriptSetup;
|
|
@@ -10772,7 +10842,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
10772
10842
|
let result2 = code;
|
|
10773
10843
|
for (const [bareImport, paths] of packageImportRewrites) {
|
|
10774
10844
|
const targetPath = mode === "server" ? paths.server : paths.client;
|
|
10775
|
-
let rel =
|
|
10845
|
+
let rel = relative9(dirname12(outputPath), targetPath).replace(/\\/g, "/");
|
|
10776
10846
|
if (!rel.startsWith("."))
|
|
10777
10847
|
rel = `./${rel}`;
|
|
10778
10848
|
result2 = result2.replaceAll(bareImport, rel);
|
|
@@ -10790,7 +10860,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
10790
10860
|
hmrId,
|
|
10791
10861
|
serverPath: serverOutputPath,
|
|
10792
10862
|
tsHelperPaths: [
|
|
10793
|
-
...helperModulePaths.map((helper) =>
|
|
10863
|
+
...helperModulePaths.map((helper) => resolve19(dirname12(sourceFilePath), helper.endsWith(".ts") ? helper : `${helper}.ts`)),
|
|
10794
10864
|
...childBuildResults.flatMap((child) => child.tsHelperPaths)
|
|
10795
10865
|
]
|
|
10796
10866
|
};
|
|
@@ -10813,7 +10883,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
10813
10883
|
const buildCache = new Map;
|
|
10814
10884
|
const allTsHelperPaths = new Set;
|
|
10815
10885
|
const compiledPages = await Promise.all(entryPoints.map(async (entryPath) => {
|
|
10816
|
-
const result = await compileVueFile(
|
|
10886
|
+
const result = await compileVueFile(resolve19(entryPath), {
|
|
10817
10887
|
client: clientOutputDir,
|
|
10818
10888
|
css: cssOutputDir,
|
|
10819
10889
|
server: serverOutputDir
|
|
@@ -10821,7 +10891,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
10821
10891
|
result.tsHelperPaths.forEach((path) => allTsHelperPaths.add(path));
|
|
10822
10892
|
const entryBaseName = basename6(entryPath, ".vue");
|
|
10823
10893
|
const indexOutputFile = join17(indexOutputDir, `${entryBaseName}.js`);
|
|
10824
|
-
const clientOutputFile = join17(clientOutputDir,
|
|
10894
|
+
const clientOutputFile = join17(clientOutputDir, relative9(vueRootDir, entryPath).replace(/\\/g, "/").replace(/\.vue$/, ".js"));
|
|
10825
10895
|
await mkdir4(dirname12(indexOutputFile), { recursive: true });
|
|
10826
10896
|
const vueHmrImports = isDev2 ? [
|
|
10827
10897
|
`window.__HMR_FRAMEWORK__ = "vue";`,
|
|
@@ -10829,7 +10899,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
10829
10899
|
] : [];
|
|
10830
10900
|
await write2(indexOutputFile, [
|
|
10831
10901
|
...vueHmrImports,
|
|
10832
|
-
`import Comp, * as PageModule from "${
|
|
10902
|
+
`import Comp, * as PageModule from "${relative9(dirname12(indexOutputFile), clientOutputFile).replace(/\\/g, "/")}";`,
|
|
10833
10903
|
'import { createSSRApp, createApp } from "vue";',
|
|
10834
10904
|
"",
|
|
10835
10905
|
"// HMR State Preservation: Check for preserved state from HMR",
|
|
@@ -10973,7 +11043,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
10973
11043
|
await Promise.all(Array.from(allTsHelperPaths).map(async (tsPath) => {
|
|
10974
11044
|
const sourceCode = await file3(tsPath).text();
|
|
10975
11045
|
const transpiledCode = transpiler3.transformSync(sourceCode);
|
|
10976
|
-
const relativeJsPath =
|
|
11046
|
+
const relativeJsPath = relative9(vueRootDir, tsPath).replace(/\.ts$/, ".js");
|
|
10977
11047
|
const outClientPath = join17(clientOutputDir, relativeJsPath);
|
|
10978
11048
|
const outServerPath = join17(serverOutputDir, relativeJsPath);
|
|
10979
11049
|
await mkdir4(dirname12(outClientPath), { recursive: true });
|
|
@@ -11478,17 +11548,17 @@ __export(exports_compileAngular, {
|
|
|
11478
11548
|
compileAngular: () => compileAngular
|
|
11479
11549
|
});
|
|
11480
11550
|
import { existsSync as existsSync17, readFileSync as readFileSync13, promises as fs } from "fs";
|
|
11481
|
-
import { join as join18, basename as basename7, sep as sep3, dirname as dirname13, resolve as
|
|
11551
|
+
import { join as join18, basename as basename7, sep as sep3, dirname as dirname13, resolve as resolve20, relative as relative10 } from "path";
|
|
11482
11552
|
import ts2 from "typescript";
|
|
11483
11553
|
var traceAngularPhase = async (name, fn2, metadata2) => {
|
|
11484
11554
|
const tracePhase = globalThis.__absoluteBuildTracePhase;
|
|
11485
11555
|
return tracePhase ? tracePhase(`compile/angular/${name}`, fn2, metadata2) : await fn2();
|
|
11486
11556
|
}, readTsconfigPathAliases = () => {
|
|
11487
11557
|
try {
|
|
11488
|
-
const configPath2 =
|
|
11558
|
+
const configPath2 = resolve20(process.cwd(), "tsconfig.json");
|
|
11489
11559
|
const config = ts2.readConfigFile(configPath2, ts2.sys.readFile).config;
|
|
11490
11560
|
const compilerOptions = config?.compilerOptions ?? {};
|
|
11491
|
-
const baseUrl =
|
|
11561
|
+
const baseUrl = resolve20(process.cwd(), compilerOptions.baseUrl ?? ".");
|
|
11492
11562
|
const aliases = Object.entries(compilerOptions.paths ?? {}).map(([pattern, replacements]) => ({ pattern, replacements }));
|
|
11493
11563
|
return { aliases, baseUrl };
|
|
11494
11564
|
} catch {
|
|
@@ -11508,7 +11578,7 @@ var traceAngularPhase = async (name, fn2, metadata2) => {
|
|
|
11508
11578
|
const wildcardValue = exactMatch ? "" : specifier.slice(prefix.length, specifier.length - suffix.length);
|
|
11509
11579
|
for (const replacement of alias.replacements) {
|
|
11510
11580
|
const candidate = replacement.replace("*", wildcardValue);
|
|
11511
|
-
const resolved = resolveSourceFile(
|
|
11581
|
+
const resolved = resolveSourceFile(resolve20(baseUrl, candidate));
|
|
11512
11582
|
if (resolved)
|
|
11513
11583
|
return resolved;
|
|
11514
11584
|
}
|
|
@@ -11527,13 +11597,13 @@ var traceAngularPhase = async (name, fn2, metadata2) => {
|
|
|
11527
11597
|
];
|
|
11528
11598
|
return candidates.find((file4) => existsSync17(file4));
|
|
11529
11599
|
}, createLegacyAngularAnimationUsageResolver = (rootDir) => {
|
|
11530
|
-
const baseDir =
|
|
11600
|
+
const baseDir = resolve20(rootDir);
|
|
11531
11601
|
const tsconfigAliases = readTsconfigPathAliases();
|
|
11532
11602
|
const transpiler4 = new Bun.Transpiler({ loader: "tsx" });
|
|
11533
11603
|
const scanCache = new Map;
|
|
11534
11604
|
const resolveLocalImport = (specifier, fromDir) => {
|
|
11535
11605
|
if (specifier.startsWith(".") || specifier.startsWith("/")) {
|
|
11536
|
-
return resolveSourceFile(
|
|
11606
|
+
return resolveSourceFile(resolve20(fromDir, specifier));
|
|
11537
11607
|
}
|
|
11538
11608
|
const aliased = matchTsconfigAlias(specifier, tsconfigAliases.aliases, tsconfigAliases.baseUrl, resolveSourceFile);
|
|
11539
11609
|
if (aliased)
|
|
@@ -11542,7 +11612,7 @@ var traceAngularPhase = async (name, fn2, metadata2) => {
|
|
|
11542
11612
|
const resolved = Bun.resolveSync(specifier, fromDir);
|
|
11543
11613
|
if (resolved.includes("/node_modules/"))
|
|
11544
11614
|
return;
|
|
11545
|
-
const absolute =
|
|
11615
|
+
const absolute = resolve20(resolved);
|
|
11546
11616
|
if (!absolute.startsWith(baseDir))
|
|
11547
11617
|
return;
|
|
11548
11618
|
return resolveSourceFile(absolute);
|
|
@@ -11558,7 +11628,7 @@ var traceAngularPhase = async (name, fn2, metadata2) => {
|
|
|
11558
11628
|
usesLegacyAnimations: false
|
|
11559
11629
|
});
|
|
11560
11630
|
}
|
|
11561
|
-
const resolved =
|
|
11631
|
+
const resolved = resolve20(actualPath);
|
|
11562
11632
|
const cached = scanCache.get(resolved);
|
|
11563
11633
|
if (cached)
|
|
11564
11634
|
return cached;
|
|
@@ -11587,7 +11657,7 @@ var traceAngularPhase = async (name, fn2, metadata2) => {
|
|
|
11587
11657
|
const actualPath = resolveSourceFile(filePath);
|
|
11588
11658
|
if (!actualPath)
|
|
11589
11659
|
return false;
|
|
11590
|
-
const resolved =
|
|
11660
|
+
const resolved = resolve20(actualPath);
|
|
11591
11661
|
if (visited.has(resolved))
|
|
11592
11662
|
return false;
|
|
11593
11663
|
visited.add(resolved);
|
|
@@ -11605,14 +11675,14 @@ var traceAngularPhase = async (name, fn2, metadata2) => {
|
|
|
11605
11675
|
return (entryPath) => visit(entryPath);
|
|
11606
11676
|
}, resolveDevClientDir4 = () => {
|
|
11607
11677
|
const projectRoot = process.cwd();
|
|
11608
|
-
const fromSource =
|
|
11678
|
+
const fromSource = resolve20(import.meta.dir, "../dev/client");
|
|
11609
11679
|
if (existsSync17(fromSource) && fromSource.startsWith(projectRoot)) {
|
|
11610
11680
|
return fromSource;
|
|
11611
11681
|
}
|
|
11612
|
-
const fromNodeModules =
|
|
11682
|
+
const fromNodeModules = resolve20(projectRoot, "node_modules/@absolutejs/absolute/dist/dev/client");
|
|
11613
11683
|
if (existsSync17(fromNodeModules))
|
|
11614
11684
|
return fromNodeModules;
|
|
11615
|
-
return
|
|
11685
|
+
return resolve20(import.meta.dir, "./dev/client");
|
|
11616
11686
|
}, devClientDir4, hmrClientPath5, hmrRuntimePath, injectHMRRegistration = (content, sourceId) => {
|
|
11617
11687
|
const entityClassRegex = /(?:export\s+)?class\s+(\w+(?:Component|Service|Directive|Pipe))\s/g;
|
|
11618
11688
|
const entityNames = [];
|
|
@@ -11674,11 +11744,11 @@ ${registrations}
|
|
|
11674
11744
|
if (hasJsLikeExtension(path))
|
|
11675
11745
|
return `${path}${query}`;
|
|
11676
11746
|
const importerDir = dirname13(importerOutputPath);
|
|
11677
|
-
const fileCandidate =
|
|
11747
|
+
const fileCandidate = resolve20(importerDir, `${path}.js`);
|
|
11678
11748
|
if (outputFiles?.has(fileCandidate) || existsSync17(fileCandidate)) {
|
|
11679
11749
|
return `${path}.js${query}`;
|
|
11680
11750
|
}
|
|
11681
|
-
const indexCandidate =
|
|
11751
|
+
const indexCandidate = resolve20(importerDir, path, "index.js");
|
|
11682
11752
|
if (outputFiles?.has(indexCandidate) || existsSync17(indexCandidate)) {
|
|
11683
11753
|
return `${path}/index.js${query}`;
|
|
11684
11754
|
}
|
|
@@ -11706,7 +11776,7 @@ ${registrations}
|
|
|
11706
11776
|
}, resolveLocalTsImport = (fromFile, specifier) => {
|
|
11707
11777
|
if (!isRelativeModuleSpecifier(specifier))
|
|
11708
11778
|
return null;
|
|
11709
|
-
const basePath =
|
|
11779
|
+
const basePath = resolve20(dirname13(fromFile), specifier);
|
|
11710
11780
|
const candidates = /\.[cm]?[tj]sx?$/.test(basePath) ? [basePath] : [
|
|
11711
11781
|
`${basePath}.ts`,
|
|
11712
11782
|
`${basePath}.tsx`,
|
|
@@ -11717,9 +11787,9 @@ ${registrations}
|
|
|
11717
11787
|
join18(basePath, "index.mts"),
|
|
11718
11788
|
join18(basePath, "index.cts")
|
|
11719
11789
|
];
|
|
11720
|
-
return candidates.map((candidate) =>
|
|
11721
|
-
}, readFileForAotTransform = async (fileName,
|
|
11722
|
-
const hostSource =
|
|
11790
|
+
return candidates.map((candidate) => resolve20(candidate)).find((candidate) => existsSync17(candidate) && !candidate.endsWith(".d.ts")) ?? null;
|
|
11791
|
+
}, readFileForAotTransform = async (fileName, readFile6) => {
|
|
11792
|
+
const hostSource = readFile6?.(fileName);
|
|
11723
11793
|
if (typeof hostSource === "string")
|
|
11724
11794
|
return hostSource;
|
|
11725
11795
|
return fs.readFile(fileName, "utf-8");
|
|
@@ -11752,7 +11822,7 @@ ${registrations}
|
|
|
11752
11822
|
paths.push(join18(fileDir, urlMatch.replace(/['"]/g, "")));
|
|
11753
11823
|
}
|
|
11754
11824
|
}
|
|
11755
|
-
return paths.map((path) =>
|
|
11825
|
+
return paths.map((path) => resolve20(path));
|
|
11756
11826
|
}, readResourceCacheFile = async (cachePath) => {
|
|
11757
11827
|
try {
|
|
11758
11828
|
const entry = JSON.parse(await fs.readFile(cachePath, "utf-8"));
|
|
@@ -11784,7 +11854,7 @@ ${registrations}
|
|
|
11784
11854
|
].join("\x00");
|
|
11785
11855
|
const cacheKey2 = Bun.hash(cacheInput).toString(BASE_36_RADIX);
|
|
11786
11856
|
return join18(process.cwd(), ".absolutejs", "cache", "angular-resources", `${cacheKey2}.json`);
|
|
11787
|
-
}, precomputeAotResourceTransforms = async (inputPaths,
|
|
11857
|
+
}, precomputeAotResourceTransforms = async (inputPaths, readFile6, stylePreprocessors) => {
|
|
11788
11858
|
const transformedSources = new Map;
|
|
11789
11859
|
const visited = new Set;
|
|
11790
11860
|
const stats = {
|
|
@@ -11794,14 +11864,14 @@ ${registrations}
|
|
|
11794
11864
|
transformedFiles: 0
|
|
11795
11865
|
};
|
|
11796
11866
|
const transformFile = async (filePath) => {
|
|
11797
|
-
const resolvedPath =
|
|
11867
|
+
const resolvedPath = resolve20(filePath);
|
|
11798
11868
|
if (visited.has(resolvedPath))
|
|
11799
11869
|
return;
|
|
11800
11870
|
visited.add(resolvedPath);
|
|
11801
11871
|
if (!existsSync17(resolvedPath) || resolvedPath.endsWith(".d.ts"))
|
|
11802
11872
|
return;
|
|
11803
11873
|
stats.filesVisited += 1;
|
|
11804
|
-
const source = await readFileForAotTransform(resolvedPath,
|
|
11874
|
+
const source = await readFileForAotTransform(resolvedPath, readFile6);
|
|
11805
11875
|
const cachePath = await resolveResourceTransformCachePath(resolvedPath, source, stylePreprocessors);
|
|
11806
11876
|
const cached = await readResourceCacheFile(cachePath);
|
|
11807
11877
|
let transformedSource;
|
|
@@ -11829,7 +11899,7 @@ ${registrations}
|
|
|
11829
11899
|
return { stats, transformedSources };
|
|
11830
11900
|
}, compileAngularFiles = async (inputPaths, outDir, stylePreprocessors) => {
|
|
11831
11901
|
const islandMetadataByOutputPath = await traceAngularPhase("aot/island-metadata", () => new Map(inputPaths.map((inputPath) => {
|
|
11832
|
-
const outputPath =
|
|
11902
|
+
const outputPath = resolve20(join18(outDir, relative10(process.cwd(), resolve20(inputPath)).replace(/\.[cm]?[tj]sx?$/, ".js")));
|
|
11833
11903
|
return [
|
|
11834
11904
|
outputPath,
|
|
11835
11905
|
buildIslandMetadataExports(readFileSync13(inputPath, "utf-8"))
|
|
@@ -11840,7 +11910,7 @@ ${registrations}
|
|
|
11840
11910
|
const tsLibDir = await traceAngularPhase("aot/resolve-typescript-lib", () => {
|
|
11841
11911
|
const tsPath = __require.resolve("typescript");
|
|
11842
11912
|
const tsRootDir = dirname13(tsPath);
|
|
11843
|
-
return tsRootDir.endsWith("lib") ? tsRootDir :
|
|
11913
|
+
return tsRootDir.endsWith("lib") ? tsRootDir : resolve20(tsRootDir, "lib");
|
|
11844
11914
|
});
|
|
11845
11915
|
const config = await traceAngularPhase("aot/read-configuration", () => readConfiguration("./tsconfig.json"));
|
|
11846
11916
|
const options = {
|
|
@@ -11882,7 +11952,7 @@ ${registrations}
|
|
|
11882
11952
|
return originalGetSourceFile?.call(host, fileName, languageVersion, onError);
|
|
11883
11953
|
};
|
|
11884
11954
|
const emitted = {};
|
|
11885
|
-
const resolvedOutDir =
|
|
11955
|
+
const resolvedOutDir = resolve20(outDir);
|
|
11886
11956
|
host.writeFile = (fileName, text) => {
|
|
11887
11957
|
const relativePath = resolveRelativePath(fileName, resolvedOutDir, outDir);
|
|
11888
11958
|
emitted[relativePath] = text;
|
|
@@ -11904,12 +11974,12 @@ ${registrations}
|
|
|
11904
11974
|
if (!fileName.endsWith(".ts") || fileName.endsWith(".d.ts")) {
|
|
11905
11975
|
return source;
|
|
11906
11976
|
}
|
|
11907
|
-
const resolvedPath =
|
|
11977
|
+
const resolvedPath = resolve20(fileName);
|
|
11908
11978
|
return transformedSources.get(resolvedPath) ?? source;
|
|
11909
11979
|
};
|
|
11910
11980
|
const originalGetSourceFileForCompile = host.getSourceFile;
|
|
11911
11981
|
host.getSourceFile = (fileName, languageVersion, onError) => {
|
|
11912
|
-
const source = transformedSources.get(
|
|
11982
|
+
const source = transformedSources.get(resolve20(fileName));
|
|
11913
11983
|
if (source) {
|
|
11914
11984
|
return ts2.createSourceFile(fileName, source, languageVersion, true);
|
|
11915
11985
|
}
|
|
@@ -11933,7 +12003,7 @@ ${registrations}
|
|
|
11933
12003
|
content,
|
|
11934
12004
|
target: join18(outDir, fileName)
|
|
11935
12005
|
}));
|
|
11936
|
-
const outputFiles = new Set(rawEntries.map(({ target }) =>
|
|
12006
|
+
const outputFiles = new Set(rawEntries.map(({ target }) => resolve20(target)));
|
|
11937
12007
|
return rawEntries.map(({ content, target }) => {
|
|
11938
12008
|
let processedContent = content.replace(/from\s+(['"])(\.\.?\/[^'"]+)(\1)/g, (match, quote, path) => {
|
|
11939
12009
|
const rewritten = rewriteRelativeJsSpecifier(target, path, outputFiles);
|
|
@@ -11948,7 +12018,7 @@ ${registrations}
|
|
|
11948
12018
|
return cleaned ? `import { ${cleaned}, InternalInjectFlags } from '@angular/core'` : `import { InternalInjectFlags } from '@angular/core'`;
|
|
11949
12019
|
});
|
|
11950
12020
|
processedContent = processedContent.replace(/\b(?<!Internal)InjectFlags\b/g, "InternalInjectFlags");
|
|
11951
|
-
processedContent += islandMetadataByOutputPath.get(
|
|
12021
|
+
processedContent += islandMetadataByOutputPath.get(resolve20(target)) ?? "";
|
|
11952
12022
|
return { content: processedContent, target };
|
|
11953
12023
|
});
|
|
11954
12024
|
});
|
|
@@ -11969,7 +12039,7 @@ ${registrations}
|
|
|
11969
12039
|
}
|
|
11970
12040
|
return null;
|
|
11971
12041
|
}, resolveAngularDeferImportSpecifier = () => {
|
|
11972
|
-
const sourceEntry =
|
|
12042
|
+
const sourceEntry = resolve20(import.meta.dir, "../angular/components/index.ts");
|
|
11973
12043
|
if (existsSync17(sourceEntry)) {
|
|
11974
12044
|
return sourceEntry.replace(/\\/g, "/");
|
|
11975
12045
|
}
|
|
@@ -12199,10 +12269,10 @@ ${fields}
|
|
|
12199
12269
|
source: result
|
|
12200
12270
|
};
|
|
12201
12271
|
}, compileAngularFileJIT = async (inputPath, outDir, rootDir, stylePreprocessors, cacheBuster) => {
|
|
12202
|
-
const entryPath =
|
|
12272
|
+
const entryPath = resolve20(inputPath);
|
|
12203
12273
|
const allOutputs = [];
|
|
12204
12274
|
const visited = new Set;
|
|
12205
|
-
const baseDir =
|
|
12275
|
+
const baseDir = resolve20(rootDir ?? process.cwd());
|
|
12206
12276
|
let usesLegacyAnimations = false;
|
|
12207
12277
|
const angularTranspiler = new Bun.Transpiler({
|
|
12208
12278
|
loader: "ts",
|
|
@@ -12229,7 +12299,7 @@ ${fields}
|
|
|
12229
12299
|
};
|
|
12230
12300
|
const resolveLocalImport = (specifier, fromDir) => {
|
|
12231
12301
|
if (specifier.startsWith(".") || specifier.startsWith("/")) {
|
|
12232
|
-
return resolveSourceFile2(
|
|
12302
|
+
return resolveSourceFile2(resolve20(fromDir, specifier));
|
|
12233
12303
|
}
|
|
12234
12304
|
const aliased = matchTsconfigAlias(specifier, tsconfigAliases.aliases, tsconfigAliases.baseUrl, resolveSourceFile2);
|
|
12235
12305
|
if (aliased)
|
|
@@ -12238,7 +12308,7 @@ ${fields}
|
|
|
12238
12308
|
const resolved = Bun.resolveSync(specifier, fromDir);
|
|
12239
12309
|
if (resolved.includes("/node_modules/"))
|
|
12240
12310
|
return;
|
|
12241
|
-
const absolute =
|
|
12311
|
+
const absolute = resolve20(resolved);
|
|
12242
12312
|
if (!absolute.startsWith(baseDir))
|
|
12243
12313
|
return;
|
|
12244
12314
|
return resolveSourceFile2(absolute);
|
|
@@ -12287,13 +12357,13 @@ ${fields}
|
|
|
12287
12357
|
return `${prefix}${dots}`;
|
|
12288
12358
|
return `${prefix}../${dots}`;
|
|
12289
12359
|
});
|
|
12290
|
-
if (
|
|
12360
|
+
if (resolve20(actualPath) === entryPath) {
|
|
12291
12361
|
processedContent += buildIslandMetadataExports(sourceCode);
|
|
12292
12362
|
}
|
|
12293
12363
|
return processedContent;
|
|
12294
12364
|
};
|
|
12295
12365
|
const transpileFile = async (filePath) => {
|
|
12296
|
-
const resolved =
|
|
12366
|
+
const resolved = resolve20(filePath);
|
|
12297
12367
|
if (visited.has(resolved))
|
|
12298
12368
|
return;
|
|
12299
12369
|
visited.add(resolved);
|
|
@@ -12330,7 +12400,7 @@ ${fields}
|
|
|
12330
12400
|
const resolved2 = resolveLocalImport(specifier, inputDir);
|
|
12331
12401
|
if (!resolved2)
|
|
12332
12402
|
return null;
|
|
12333
|
-
const relativeImport =
|
|
12403
|
+
const relativeImport = relative10(targetDir, toOutputPath(resolved2)).replace(/\\/g, "/").replace(/\.js$/, "");
|
|
12334
12404
|
const relativeRewrite = relativeImport.startsWith(".") ? relativeImport : `./${relativeImport}`;
|
|
12335
12405
|
importRewrites.set(specifier, relativeRewrite);
|
|
12336
12406
|
return resolved2;
|
|
@@ -12370,11 +12440,11 @@ export const __ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__ = true;
|
|
|
12370
12440
|
const compiledRoot = compiledParent;
|
|
12371
12441
|
const indexesDir = join18(compiledParent, "indexes");
|
|
12372
12442
|
await traceAngularPhase("setup/create-indexes-dir", () => fs.mkdir(indexesDir, { recursive: true }));
|
|
12373
|
-
const aotOutputs = hmr ? [] : await traceAngularPhase("aot/compile-files", () => compileAngularFiles(entryPoints.map((entry) =>
|
|
12443
|
+
const aotOutputs = hmr ? [] : await traceAngularPhase("aot/compile-files", () => compileAngularFiles(entryPoints.map((entry) => resolve20(entry)), compiledRoot, stylePreprocessors), { entries: entryPoints.length });
|
|
12374
12444
|
const usesLegacyAngularAnimations = await traceAngularPhase("setup/legacy-animation-resolver", () => createLegacyAngularAnimationUsageResolver(outRoot));
|
|
12375
12445
|
const compileTasks = entryPoints.map(async (entry) => {
|
|
12376
|
-
const resolvedEntry =
|
|
12377
|
-
const relativeEntry =
|
|
12446
|
+
const resolvedEntry = resolve20(entry);
|
|
12447
|
+
const relativeEntry = relative10(outRoot, resolvedEntry).replace(/\.[tj]s$/, ".js");
|
|
12378
12448
|
const compileEntry = () => compileAngularFileJIT(resolvedEntry, compiledRoot, outRoot, stylePreprocessors);
|
|
12379
12449
|
let outputs = hmr ? await traceAngularPhase("jit/compile-entry", compileEntry, {
|
|
12380
12450
|
entry: resolvedEntry
|
|
@@ -12385,10 +12455,10 @@ export const __ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__ = true;
|
|
|
12385
12455
|
join18(compiledRoot, relativeEntry),
|
|
12386
12456
|
join18(compiledRoot, "pages", jsName),
|
|
12387
12457
|
join18(compiledRoot, jsName)
|
|
12388
|
-
].map((file4) =>
|
|
12458
|
+
].map((file4) => resolve20(file4));
|
|
12389
12459
|
const resolveRawServerFile = (candidatePaths) => {
|
|
12390
12460
|
const normalizedCandidates = [
|
|
12391
|
-
...candidatePaths.map((file4) =>
|
|
12461
|
+
...candidatePaths.map((file4) => resolve20(file4)),
|
|
12392
12462
|
...compiledFallbackPaths
|
|
12393
12463
|
];
|
|
12394
12464
|
let candidate = normalizedCandidates.find((file4) => existsSync17(file4) && file4.endsWith(`${sep3}pages${sep3}${jsName}`));
|
|
@@ -12459,7 +12529,7 @@ export const __ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__ = true;
|
|
|
12459
12529
|
rewritten = injectHMRRegistration(rewritten, resolvedEntry);
|
|
12460
12530
|
}
|
|
12461
12531
|
await traceAngularPhase("wrapper/write-server-output", () => fs.writeFile(rawServerFile, rewritten, "utf-8"), { entry: resolvedEntry });
|
|
12462
|
-
const relativePath =
|
|
12532
|
+
const relativePath = relative10(indexesDir, rawServerFile).replace(/\\/g, "/");
|
|
12463
12533
|
const normalizedImportPath = relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
12464
12534
|
const hmrPreamble = hmr ? `window.__HMR_FRAMEWORK__ = "angular";
|
|
12465
12535
|
import "${hmrRuntimePath}";
|
|
@@ -13121,7 +13191,7 @@ __export(exports_compileEmber, {
|
|
|
13121
13191
|
});
|
|
13122
13192
|
import { existsSync as existsSync18 } from "fs";
|
|
13123
13193
|
import { mkdir as mkdir5, rm as rm4 } from "fs/promises";
|
|
13124
|
-
import { basename as basename8, dirname as dirname14, extname as extname6, join as join19, resolve as
|
|
13194
|
+
import { basename as basename8, dirname as dirname14, extname as extname6, join as join19, resolve as resolve21 } from "path";
|
|
13125
13195
|
var {build: bunBuild2, Transpiler: Transpiler3, write: write3, file: file4 } = globalThis.Bun;
|
|
13126
13196
|
var cachedPreprocessor = null, getPreprocessor = async () => {
|
|
13127
13197
|
if (cachedPreprocessor)
|
|
@@ -13217,7 +13287,7 @@ export const importSync = (specifier) => {
|
|
|
13217
13287
|
const originalImporter = stagedSourceMap.get(args.importer);
|
|
13218
13288
|
if (!originalImporter)
|
|
13219
13289
|
return;
|
|
13220
|
-
const candidateBase =
|
|
13290
|
+
const candidateBase = resolve21(dirname14(originalImporter), args.path);
|
|
13221
13291
|
const extensionsToTry = ["", ".gts", ".gjs", ".ts", ".js"];
|
|
13222
13292
|
for (const ext of extensionsToTry) {
|
|
13223
13293
|
const candidate = candidateBase + ext;
|
|
@@ -13276,7 +13346,7 @@ export const renderToHTML = (props = {}) => {
|
|
|
13276
13346
|
export { PageComponent };
|
|
13277
13347
|
export default PageComponent;
|
|
13278
13348
|
`, compileEmberFile = async (entry, compiledRoot, cwd = process.cwd()) => {
|
|
13279
|
-
const resolvedEntry =
|
|
13349
|
+
const resolvedEntry = resolve21(entry);
|
|
13280
13350
|
const source = await file4(resolvedEntry).text();
|
|
13281
13351
|
let preprocessed = source;
|
|
13282
13352
|
if (isTemplateTagFile(resolvedEntry)) {
|
|
@@ -13296,8 +13366,8 @@ export default PageComponent;
|
|
|
13296
13366
|
mkdir5(serverDir, { recursive: true }),
|
|
13297
13367
|
mkdir5(clientDir, { recursive: true })
|
|
13298
13368
|
]);
|
|
13299
|
-
const tmpPagePath =
|
|
13300
|
-
const tmpHarnessPath =
|
|
13369
|
+
const tmpPagePath = resolve21(join19(tmpDir, `${baseName}.module.js`));
|
|
13370
|
+
const tmpHarnessPath = resolve21(join19(tmpDir, `${baseName}.harness.js`));
|
|
13301
13371
|
await Promise.all([
|
|
13302
13372
|
write3(tmpPagePath, transpiled),
|
|
13303
13373
|
write3(tmpHarnessPath, generateServerHarness(tmpPagePath))
|
|
@@ -13339,7 +13409,7 @@ export default PageComponent;
|
|
|
13339
13409
|
serverPaths: outputs.map((o) => o.serverPath)
|
|
13340
13410
|
};
|
|
13341
13411
|
}, compileEmberFileSource = async (entry) => {
|
|
13342
|
-
const resolvedEntry =
|
|
13412
|
+
const resolvedEntry = resolve21(entry);
|
|
13343
13413
|
const source = await file4(resolvedEntry).text();
|
|
13344
13414
|
let preprocessed = source;
|
|
13345
13415
|
if (isTemplateTagFile(resolvedEntry)) {
|
|
@@ -13372,24 +13442,24 @@ __export(exports_buildReactVendor, {
|
|
|
13372
13442
|
buildReactVendor: () => buildReactVendor
|
|
13373
13443
|
});
|
|
13374
13444
|
import { existsSync as existsSync19, mkdirSync as mkdirSync7 } from "fs";
|
|
13375
|
-
import { join as join20, resolve as
|
|
13445
|
+
import { join as join20, resolve as resolve22 } from "path";
|
|
13376
13446
|
import { rm as rm5 } from "fs/promises";
|
|
13377
13447
|
var {build: bunBuild3 } = globalThis.Bun;
|
|
13378
13448
|
var resolveJsxDevRuntimeCompatPath = () => {
|
|
13379
13449
|
const candidates = [
|
|
13380
|
-
|
|
13381
|
-
|
|
13382
|
-
|
|
13383
|
-
|
|
13384
|
-
|
|
13385
|
-
|
|
13450
|
+
resolve22(import.meta.dir, "react", "jsxDevRuntimeCompat.js"),
|
|
13451
|
+
resolve22(import.meta.dir, "src", "react", "jsxDevRuntimeCompat.ts"),
|
|
13452
|
+
resolve22(import.meta.dir, "..", "react", "jsxDevRuntimeCompat.js"),
|
|
13453
|
+
resolve22(import.meta.dir, "..", "src", "react", "jsxDevRuntimeCompat.ts"),
|
|
13454
|
+
resolve22(import.meta.dir, "..", "..", "dist", "react", "jsxDevRuntimeCompat.js"),
|
|
13455
|
+
resolve22(import.meta.dir, "..", "..", "src", "react", "jsxDevRuntimeCompat.ts")
|
|
13386
13456
|
];
|
|
13387
13457
|
for (const candidate of candidates) {
|
|
13388
13458
|
if (existsSync19(candidate)) {
|
|
13389
13459
|
return candidate.replace(/\\/g, "/");
|
|
13390
13460
|
}
|
|
13391
13461
|
}
|
|
13392
|
-
return (candidates[0] ??
|
|
13462
|
+
return (candidates[0] ?? resolve22(import.meta.dir, "react", "jsxDevRuntimeCompat.js")).replace(/\\/g, "/");
|
|
13393
13463
|
}, jsxDevRuntimeCompatPath, reactSpecifiers, isResolvable = (specifier) => {
|
|
13394
13464
|
try {
|
|
13395
13465
|
Bun.resolveSync(specifier, process.cwd());
|
|
@@ -14039,7 +14109,7 @@ import {
|
|
|
14039
14109
|
statSync,
|
|
14040
14110
|
writeFileSync as writeFileSync8
|
|
14041
14111
|
} from "fs";
|
|
14042
|
-
import { basename as basename9, dirname as dirname15, extname as extname7, join as join25, relative as
|
|
14112
|
+
import { basename as basename9, dirname as dirname15, extname as extname7, join as join25, relative as relative11, resolve as resolve23 } from "path";
|
|
14043
14113
|
import { cwd, env as env3, exit } from "process";
|
|
14044
14114
|
var {build: bunBuild7, Glob: Glob7 } = globalThis.Bun;
|
|
14045
14115
|
var isDev2, isBuildTraceEnabled = () => {
|
|
@@ -14130,8 +14200,8 @@ var isDev2, isBuildTraceEnabled = () => {
|
|
|
14130
14200
|
}
|
|
14131
14201
|
}, resolveAbsoluteVersion = async () => {
|
|
14132
14202
|
const candidates = [
|
|
14133
|
-
|
|
14134
|
-
|
|
14203
|
+
resolve23(import.meta.dir, "..", "..", "package.json"),
|
|
14204
|
+
resolve23(import.meta.dir, "..", "package.json")
|
|
14135
14205
|
];
|
|
14136
14206
|
const resolveCandidate = async (remaining) => {
|
|
14137
14207
|
const [candidate, ...rest] = remaining;
|
|
@@ -14147,7 +14217,7 @@ var isDev2, isBuildTraceEnabled = () => {
|
|
|
14147
14217
|
};
|
|
14148
14218
|
await resolveCandidate(candidates);
|
|
14149
14219
|
}, SKIP_DIRS, addWorkerPathIfExists = (file5, relPath, workerPaths) => {
|
|
14150
|
-
const absPath =
|
|
14220
|
+
const absPath = resolve23(file5, "..", relPath);
|
|
14151
14221
|
try {
|
|
14152
14222
|
statSync(absPath);
|
|
14153
14223
|
workerPaths.add(absPath);
|
|
@@ -14209,7 +14279,7 @@ var isDev2, isBuildTraceEnabled = () => {
|
|
|
14209
14279
|
return;
|
|
14210
14280
|
}
|
|
14211
14281
|
const indexFiles = readDir(reactIndexesPath).filter((file5) => file5.endsWith(".tsx"));
|
|
14212
|
-
const pagesRel =
|
|
14282
|
+
const pagesRel = relative11(process.cwd(), resolve23(reactPagesPath)).replace(/\\/g, "/");
|
|
14213
14283
|
for (const file5 of indexFiles) {
|
|
14214
14284
|
let content = readFileSync14(join25(reactIndexesPath, file5), "utf-8");
|
|
14215
14285
|
content = content.replace(/from\s*['"]([^'"]*\/pages\/([^'"]+))['"]/g, (_match, _fullPath, componentName) => `from '/@src/${pagesRel}/${componentName}'`);
|
|
@@ -14217,27 +14287,27 @@ var isDev2, isBuildTraceEnabled = () => {
|
|
|
14217
14287
|
}
|
|
14218
14288
|
}, copySvelteDevIndexes = (svelteDir, sveltePagesPath, svelteEntries, devIndexDir) => {
|
|
14219
14289
|
const svelteIndexDir = join25(getFrameworkGeneratedDir("svelte"), "indexes");
|
|
14220
|
-
const sveltePageEntries = svelteEntries.filter((file5) =>
|
|
14290
|
+
const sveltePageEntries = svelteEntries.filter((file5) => resolve23(file5).startsWith(resolve23(sveltePagesPath)));
|
|
14221
14291
|
for (const entry of sveltePageEntries) {
|
|
14222
14292
|
const name = basename9(entry).replace(/\.svelte(\.(ts|js))?$/, "");
|
|
14223
14293
|
const indexFile = join25(svelteIndexDir, "pages", `${name}.js`);
|
|
14224
14294
|
if (!existsSync20(indexFile))
|
|
14225
14295
|
continue;
|
|
14226
14296
|
let content = readFileSync14(indexFile, "utf-8");
|
|
14227
|
-
const srcRel =
|
|
14297
|
+
const srcRel = relative11(process.cwd(), resolve23(entry)).replace(/\\/g, "/");
|
|
14228
14298
|
content = content.replace(/import\s+Component\s+from\s+['"]([^'"]+)['"]/, `import Component from "/@src/${srcRel}"`);
|
|
14229
14299
|
writeFileSync8(join25(devIndexDir, `${name}.svelte.js`), content);
|
|
14230
14300
|
}
|
|
14231
14301
|
}, copyVueDevIndexes = (vueDir, vuePagesPath, vueEntries, devIndexDir) => {
|
|
14232
14302
|
const vueIndexDir = join25(getFrameworkGeneratedDir("vue"), "indexes");
|
|
14233
|
-
const vuePageEntries = vueEntries.filter((file5) =>
|
|
14303
|
+
const vuePageEntries = vueEntries.filter((file5) => resolve23(file5).startsWith(resolve23(vuePagesPath)));
|
|
14234
14304
|
for (const entry of vuePageEntries) {
|
|
14235
14305
|
const name = basename9(entry, ".vue");
|
|
14236
14306
|
const indexFile = join25(vueIndexDir, `${name}.js`);
|
|
14237
14307
|
if (!existsSync20(indexFile))
|
|
14238
14308
|
continue;
|
|
14239
14309
|
let content = readFileSync14(indexFile, "utf-8");
|
|
14240
|
-
const srcRel =
|
|
14310
|
+
const srcRel = relative11(process.cwd(), resolve23(entry)).replace(/\\/g, "/");
|
|
14241
14311
|
content = content.replace(/import\s+Comp(?:\s*,\s*\*\s+as\s+\w+)?\s+from\s+['"]([^'"]+)['"]/, (match) => match.replace(/from\s+['"][^'"]+['"]/, `from "/@src/${srcRel}"`));
|
|
14242
14312
|
writeFileSync8(join25(devIndexDir, `${name}.vue.js`), content);
|
|
14243
14313
|
}
|
|
@@ -14250,7 +14320,7 @@ var isDev2, isBuildTraceEnabled = () => {
|
|
|
14250
14320
|
const last = allComments[allComments.length - 1];
|
|
14251
14321
|
if (!last?.[1])
|
|
14252
14322
|
return JSON.stringify(outputPath);
|
|
14253
|
-
const srcPath =
|
|
14323
|
+
const srcPath = resolve23(projectRoot, last[1].replace("/client/", "/").replace(/\.js$/, ".ts"));
|
|
14254
14324
|
return JSON.stringify(srcPath);
|
|
14255
14325
|
}, QUOTE_CHARS, OPEN_BRACES, CLOSE_BRACES, findFunctionExpressionEnd = (content, startPos) => {
|
|
14256
14326
|
let depth = 0;
|
|
@@ -14312,7 +14382,7 @@ ${content.slice(firstUseIdx)}`;
|
|
|
14312
14382
|
}, buildDevUrlFileMap = (urlReferencedFiles, projectRoot) => {
|
|
14313
14383
|
const urlFileMap = new Map;
|
|
14314
14384
|
for (const srcPath of urlReferencedFiles) {
|
|
14315
|
-
const rel =
|
|
14385
|
+
const rel = relative11(projectRoot, srcPath).replace(/\\/g, "/");
|
|
14316
14386
|
const name = basename9(srcPath);
|
|
14317
14387
|
const mtime = Math.round(statSync(srcPath).mtimeMs);
|
|
14318
14388
|
const url = `/@src/${rel}?v=${mtime}`;
|
|
@@ -14327,7 +14397,7 @@ ${content.slice(firstUseIdx)}`;
|
|
|
14327
14397
|
const output = nonReactClientOutputs.find((artifact) => basename9(artifact.path).startsWith(`${srcBase}.`));
|
|
14328
14398
|
if (!output)
|
|
14329
14399
|
continue;
|
|
14330
|
-
urlFileMap.set(basename9(srcPath), `/${
|
|
14400
|
+
urlFileMap.set(basename9(srcPath), `/${relative11(buildPath, output.path).replace(/\\/g, "/")}`);
|
|
14331
14401
|
}
|
|
14332
14402
|
return urlFileMap;
|
|
14333
14403
|
}, buildUrlFileMap = (urlReferencedFiles, hmr, projectRoot, buildPath, nonReactClientOutputs) => {
|
|
@@ -14575,13 +14645,13 @@ ${content.slice(firstUseIdx)}`;
|
|
|
14575
14645
|
const filterToIncrementalEntries = (entryPoints, mapToSource) => {
|
|
14576
14646
|
if (!isIncremental || !incrementalFiles)
|
|
14577
14647
|
return entryPoints;
|
|
14578
|
-
const normalizedIncremental = new Set(incrementalFiles.map((f2) =>
|
|
14648
|
+
const normalizedIncremental = new Set(incrementalFiles.map((f2) => resolve23(f2)));
|
|
14579
14649
|
const matchingEntries = [];
|
|
14580
14650
|
for (const entry of entryPoints) {
|
|
14581
14651
|
const sourceFile = mapToSource(entry);
|
|
14582
14652
|
if (!sourceFile)
|
|
14583
14653
|
continue;
|
|
14584
|
-
if (!normalizedIncremental.has(
|
|
14654
|
+
if (!normalizedIncremental.has(resolve23(sourceFile)))
|
|
14585
14655
|
continue;
|
|
14586
14656
|
matchingEntries.push(entry);
|
|
14587
14657
|
}
|
|
@@ -14643,7 +14713,7 @@ ${content.slice(firstUseIdx)}`;
|
|
|
14643
14713
|
}
|
|
14644
14714
|
const shouldIncludeHtmlAssets = !isIncremental || normalizedIncrementalFiles?.some((f2) => f2.includes("/html/") && (f2.endsWith(".html") || isStylePath(f2)));
|
|
14645
14715
|
const reactEntries = isIncremental && reactIndexesPath && reactPagesPath ? filterToIncrementalEntries(allReactEntries, (entry) => {
|
|
14646
|
-
if (entry.startsWith(
|
|
14716
|
+
if (entry.startsWith(resolve23(reactIndexesPath))) {
|
|
14647
14717
|
const pageName = basename9(entry, ".tsx");
|
|
14648
14718
|
return join25(reactPagesPath, `${pageName}.tsx`);
|
|
14649
14719
|
}
|
|
@@ -14722,7 +14792,7 @@ ${content.slice(firstUseIdx)}`;
|
|
|
14722
14792
|
const clientPath = islandSvelteClientPaths[idx];
|
|
14723
14793
|
if (!sourcePath || !clientPath)
|
|
14724
14794
|
continue;
|
|
14725
|
-
islandSvelteClientPathMap.set(
|
|
14795
|
+
islandSvelteClientPathMap.set(resolve23(sourcePath), clientPath);
|
|
14726
14796
|
}
|
|
14727
14797
|
const islandVueClientPathMap = new Map;
|
|
14728
14798
|
for (let idx = 0;idx < islandVueSources.length; idx++) {
|
|
@@ -14730,7 +14800,7 @@ ${content.slice(firstUseIdx)}`;
|
|
|
14730
14800
|
const clientPath = islandVueClientPaths[idx];
|
|
14731
14801
|
if (!sourcePath || !clientPath)
|
|
14732
14802
|
continue;
|
|
14733
|
-
islandVueClientPathMap.set(
|
|
14803
|
+
islandVueClientPathMap.set(resolve23(sourcePath), clientPath);
|
|
14734
14804
|
}
|
|
14735
14805
|
const islandAngularClientPathMap = new Map;
|
|
14736
14806
|
for (let idx = 0;idx < islandAngularSources.length; idx++) {
|
|
@@ -14738,7 +14808,7 @@ ${content.slice(firstUseIdx)}`;
|
|
|
14738
14808
|
const clientPath = islandAngularClientPaths[idx];
|
|
14739
14809
|
if (!sourcePath || !clientPath)
|
|
14740
14810
|
continue;
|
|
14741
|
-
islandAngularClientPathMap.set(
|
|
14811
|
+
islandAngularClientPathMap.set(resolve23(sourcePath), clientPath);
|
|
14742
14812
|
}
|
|
14743
14813
|
const reactConventionSources = collectConventionSourceFiles(conventionsMap.react);
|
|
14744
14814
|
const svelteConventionSources = collectConventionSourceFiles(conventionsMap.svelte);
|
|
@@ -15051,6 +15121,13 @@ ${content.slice(firstUseIdx)}`;
|
|
|
15051
15121
|
outdir: buildPath,
|
|
15052
15122
|
plugins: [
|
|
15053
15123
|
stylePreprocessorPlugin2,
|
|
15124
|
+
...angularDir && hmr ? [
|
|
15125
|
+
createAngularHmrInjectionPlugin({
|
|
15126
|
+
generatedAngularRoot: getFrameworkGeneratedDir("angular", projectRoot),
|
|
15127
|
+
projectRoot,
|
|
15128
|
+
userAngularRoot: angularDir
|
|
15129
|
+
})
|
|
15130
|
+
] : [],
|
|
15054
15131
|
...angularDir ? [createAngularLinkerPlugin(hmr)] : [],
|
|
15055
15132
|
...htmlScriptPlugin ? [htmlScriptPlugin] : []
|
|
15056
15133
|
],
|
|
@@ -15071,6 +15148,13 @@ ${content.slice(firstUseIdx)}`;
|
|
|
15071
15148
|
outdir: buildPath,
|
|
15072
15149
|
plugins: [
|
|
15073
15150
|
stylePreprocessorPlugin2,
|
|
15151
|
+
...angularDir && hmr ? [
|
|
15152
|
+
createAngularHmrInjectionPlugin({
|
|
15153
|
+
generatedAngularRoot: getFrameworkGeneratedDir("angular", projectRoot),
|
|
15154
|
+
projectRoot,
|
|
15155
|
+
userAngularRoot: angularDir
|
|
15156
|
+
})
|
|
15157
|
+
] : [],
|
|
15074
15158
|
...angularDir ? [createAngularLinkerPlugin(hmr)] : []
|
|
15075
15159
|
],
|
|
15076
15160
|
root: islandEntryResult.generatedRoot,
|
|
@@ -15161,7 +15245,7 @@ ${content.slice(firstUseIdx)}`;
|
|
|
15161
15245
|
const fileDir = dirname15(artifact.path);
|
|
15162
15246
|
const relativePaths = {};
|
|
15163
15247
|
for (const [specifier, absolute] of Object.entries(angularServerVendorPaths2)) {
|
|
15164
|
-
const rel =
|
|
15248
|
+
const rel = relative11(fileDir, absolute);
|
|
15165
15249
|
relativePaths[specifier] = rel.startsWith(".") ? rel : `./${rel}`;
|
|
15166
15250
|
}
|
|
15167
15251
|
return relativePaths;
|
|
@@ -15366,6 +15450,7 @@ var init_build = __esm(() => {
|
|
|
15366
15450
|
init_rewriteReactImports();
|
|
15367
15451
|
init_telemetryEvent();
|
|
15368
15452
|
init_angularLinkerPlugin();
|
|
15453
|
+
init_hmrInjectionPlugin();
|
|
15369
15454
|
init_cleanStaleOutputs();
|
|
15370
15455
|
init_cleanup();
|
|
15371
15456
|
init_commonAncestor();
|
|
@@ -15580,7 +15665,7 @@ var init_buildEmberVendor = __esm(() => {
|
|
|
15580
15665
|
// src/dev/dependencyGraph.ts
|
|
15581
15666
|
import { existsSync as existsSync22, readFileSync as readFileSync15 } from "fs";
|
|
15582
15667
|
var {Glob: Glob8 } = globalThis.Bun;
|
|
15583
|
-
import { resolve as
|
|
15668
|
+
import { resolve as resolve24 } from "path";
|
|
15584
15669
|
var emptyDependencyGraph, tsTranspiler, jsTranspiler, loaderForFile = (filePath) => {
|
|
15585
15670
|
const lower = filePath.toLowerCase();
|
|
15586
15671
|
if (lower.endsWith(".ts") || lower.endsWith(".tsx") || lower.endsWith(".jsx"))
|
|
@@ -15594,8 +15679,8 @@ var emptyDependencyGraph, tsTranspiler, jsTranspiler, loaderForFile = (filePath)
|
|
|
15594
15679
|
if (!importPath.startsWith(".") && !importPath.startsWith("/")) {
|
|
15595
15680
|
return null;
|
|
15596
15681
|
}
|
|
15597
|
-
const fromDir =
|
|
15598
|
-
const normalized =
|
|
15682
|
+
const fromDir = resolve24(fromFile, "..");
|
|
15683
|
+
const normalized = resolve24(fromDir, importPath);
|
|
15599
15684
|
const extensions = [
|
|
15600
15685
|
".ts",
|
|
15601
15686
|
".tsx",
|
|
@@ -15625,7 +15710,7 @@ var emptyDependencyGraph, tsTranspiler, jsTranspiler, loaderForFile = (filePath)
|
|
|
15625
15710
|
dependents.delete(normalizedPath);
|
|
15626
15711
|
}
|
|
15627
15712
|
}, addFileToGraph = (graph, filePath) => {
|
|
15628
|
-
const normalizedPath =
|
|
15713
|
+
const normalizedPath = resolve24(filePath);
|
|
15629
15714
|
if (!existsSync22(normalizedPath))
|
|
15630
15715
|
return;
|
|
15631
15716
|
const dependencies = extractDependencies(normalizedPath);
|
|
@@ -15642,10 +15727,10 @@ var emptyDependencyGraph, tsTranspiler, jsTranspiler, loaderForFile = (filePath)
|
|
|
15642
15727
|
}, IGNORED_SEGMENTS, buildInitialDependencyGraph = (graph, directories) => {
|
|
15643
15728
|
const processedFiles = new Set;
|
|
15644
15729
|
const glob = new Glob8("**/*.{ts,tsx,js,jsx,vue,svelte,html,htm}");
|
|
15645
|
-
const resolvedDirs = directories.map((dir) =>
|
|
15730
|
+
const resolvedDirs = directories.map((dir) => resolve24(dir)).filter((dir) => existsSync22(dir));
|
|
15646
15731
|
const allFiles = resolvedDirs.flatMap((dir) => Array.from(glob.scanSync({ absolute: true, cwd: dir })));
|
|
15647
15732
|
for (const file5 of allFiles) {
|
|
15648
|
-
const fullPath =
|
|
15733
|
+
const fullPath = resolve24(file5);
|
|
15649
15734
|
if (IGNORED_SEGMENTS.some((seg) => fullPath.includes(seg)))
|
|
15650
15735
|
continue;
|
|
15651
15736
|
if (processedFiles.has(fullPath))
|
|
@@ -15758,7 +15843,7 @@ var emptyDependencyGraph, tsTranspiler, jsTranspiler, loaderForFile = (filePath)
|
|
|
15758
15843
|
return [];
|
|
15759
15844
|
}
|
|
15760
15845
|
}, getAffectedFiles = (graph, changedFile) => {
|
|
15761
|
-
const normalizedPath =
|
|
15846
|
+
const normalizedPath = resolve24(changedFile);
|
|
15762
15847
|
const affected = new Set;
|
|
15763
15848
|
const toProcess = [normalizedPath];
|
|
15764
15849
|
const processNode = (current) => {
|
|
@@ -15798,7 +15883,7 @@ var emptyDependencyGraph, tsTranspiler, jsTranspiler, loaderForFile = (filePath)
|
|
|
15798
15883
|
}
|
|
15799
15884
|
graph.dependents.delete(normalizedPath);
|
|
15800
15885
|
}, removeFileFromGraph = (graph, filePath) => {
|
|
15801
|
-
const normalizedPath =
|
|
15886
|
+
const normalizedPath = resolve24(filePath);
|
|
15802
15887
|
removeDepsForFile(graph, normalizedPath);
|
|
15803
15888
|
removeDependentsForFile(graph, normalizedPath);
|
|
15804
15889
|
};
|
|
@@ -15841,12 +15926,12 @@ var globalVersionCounter = 0, createModuleVersionTracker = () => new Map, getNex
|
|
|
15841
15926
|
};
|
|
15842
15927
|
|
|
15843
15928
|
// src/dev/configResolver.ts
|
|
15844
|
-
import { resolve as
|
|
15929
|
+
import { resolve as resolve25 } from "path";
|
|
15845
15930
|
var resolveBuildPaths = (config) => {
|
|
15846
15931
|
const cwd2 = process.cwd();
|
|
15847
15932
|
const normalize = (path) => path.replace(/\\/g, "/");
|
|
15848
|
-
const withDefault = (value, fallback) => normalize(
|
|
15849
|
-
const optional = (value) => value ? normalize(
|
|
15933
|
+
const withDefault = (value, fallback) => normalize(resolve25(cwd2, value ?? fallback));
|
|
15934
|
+
const optional = (value) => value ? normalize(resolve25(cwd2, value)) : undefined;
|
|
15850
15935
|
return {
|
|
15851
15936
|
angularDir: optional(config.angularDirectory),
|
|
15852
15937
|
assetsDir: optional(config.assetsDirectory),
|
|
@@ -15898,8 +15983,8 @@ var init_clientManager = __esm(() => {
|
|
|
15898
15983
|
});
|
|
15899
15984
|
|
|
15900
15985
|
// src/dev/pathUtils.ts
|
|
15901
|
-
import { existsSync as existsSync23 } from "fs";
|
|
15902
|
-
import { resolve as
|
|
15986
|
+
import { existsSync as existsSync23, readdirSync, readFileSync as readFileSync16 } from "fs";
|
|
15987
|
+
import { dirname as dirname16, resolve as resolve26 } from "path";
|
|
15903
15988
|
var STYLE_EXTENSION_PATTERN2, detectFramework = (filePath, resolved) => {
|
|
15904
15989
|
if (shouldIgnorePath(filePath, resolved)) {
|
|
15905
15990
|
return "ignored";
|
|
@@ -15973,13 +16058,80 @@ var STYLE_EXTENSION_PATTERN2, detectFramework = (filePath, resolved) => {
|
|
|
15973
16058
|
return "assets";
|
|
15974
16059
|
}
|
|
15975
16060
|
return "unknown";
|
|
16061
|
+
}, collectAngularResourceDirs = (angularDir) => {
|
|
16062
|
+
const out = new Set;
|
|
16063
|
+
const angularRoot = resolve26(angularDir);
|
|
16064
|
+
const angularRootNormalized = normalizePath(angularRoot);
|
|
16065
|
+
const walk = (dir) => {
|
|
16066
|
+
let entries;
|
|
16067
|
+
try {
|
|
16068
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
16069
|
+
} catch {
|
|
16070
|
+
return;
|
|
16071
|
+
}
|
|
16072
|
+
for (const entry of entries) {
|
|
16073
|
+
if (entry.name.startsWith(".") || entry.name === "node_modules") {
|
|
16074
|
+
continue;
|
|
16075
|
+
}
|
|
16076
|
+
const full = resolve26(dir, entry.name);
|
|
16077
|
+
if (entry.isDirectory()) {
|
|
16078
|
+
walk(full);
|
|
16079
|
+
continue;
|
|
16080
|
+
}
|
|
16081
|
+
if (!entry.isFile() || !entry.name.endsWith(".component.ts")) {
|
|
16082
|
+
continue;
|
|
16083
|
+
}
|
|
16084
|
+
let source;
|
|
16085
|
+
try {
|
|
16086
|
+
source = readFileSync16(full, "utf8");
|
|
16087
|
+
} catch {
|
|
16088
|
+
continue;
|
|
16089
|
+
}
|
|
16090
|
+
const refs = [];
|
|
16091
|
+
const tplRe = /templateUrl\s*:\s*['"]([^'"]+)['"]/g;
|
|
16092
|
+
const styleRe = /styleUrl\s*:\s*['"]([^'"]+)['"]/g;
|
|
16093
|
+
const stylesArrRe = /styleUrls\s*:\s*\[([^\]]*)\]/g;
|
|
16094
|
+
const literalRe = /['"]([^'"]+)['"]/g;
|
|
16095
|
+
let match;
|
|
16096
|
+
while ((match = tplRe.exec(source)) !== null) {
|
|
16097
|
+
if (match[1])
|
|
16098
|
+
refs.push(match[1]);
|
|
16099
|
+
}
|
|
16100
|
+
while ((match = styleRe.exec(source)) !== null) {
|
|
16101
|
+
if (match[1])
|
|
16102
|
+
refs.push(match[1]);
|
|
16103
|
+
}
|
|
16104
|
+
while ((match = stylesArrRe.exec(source)) !== null) {
|
|
16105
|
+
const inner = match[1];
|
|
16106
|
+
if (!inner)
|
|
16107
|
+
continue;
|
|
16108
|
+
let strMatch;
|
|
16109
|
+
const innerRe = new RegExp(literalRe.source, literalRe.flags);
|
|
16110
|
+
while ((strMatch = innerRe.exec(inner)) !== null) {
|
|
16111
|
+
if (strMatch[1])
|
|
16112
|
+
refs.push(strMatch[1]);
|
|
16113
|
+
}
|
|
16114
|
+
}
|
|
16115
|
+
const componentDir = dirname16(full);
|
|
16116
|
+
for (const ref of refs) {
|
|
16117
|
+
const refAbs = normalizePath(resolve26(componentDir, ref));
|
|
16118
|
+
const refDir = normalizePath(dirname16(refAbs));
|
|
16119
|
+
if (refDir === angularRootNormalized || refDir.startsWith(angularRootNormalized + "/")) {
|
|
16120
|
+
continue;
|
|
16121
|
+
}
|
|
16122
|
+
out.add(refDir);
|
|
16123
|
+
}
|
|
16124
|
+
}
|
|
16125
|
+
};
|
|
16126
|
+
walk(angularRoot);
|
|
16127
|
+
return Array.from(out);
|
|
15976
16128
|
}, collectPositiveWatchRoots = (config, resolved) => {
|
|
15977
16129
|
const cwd2 = process.cwd();
|
|
15978
16130
|
const roots = [];
|
|
15979
16131
|
const push = (path) => {
|
|
15980
16132
|
if (!path)
|
|
15981
16133
|
return;
|
|
15982
|
-
const abs = normalizePath(
|
|
16134
|
+
const abs = normalizePath(resolve26(cwd2, path));
|
|
15983
16135
|
if (!roots.includes(abs))
|
|
15984
16136
|
roots.push(abs);
|
|
15985
16137
|
};
|
|
@@ -16004,13 +16156,20 @@ var STYLE_EXTENSION_PATTERN2, detectFramework = (filePath, resolved) => {
|
|
|
16004
16156
|
push(cfg.assetsDir);
|
|
16005
16157
|
push(cfg.stylesDir);
|
|
16006
16158
|
for (const candidate of ["src", "db", "assets", "styles"]) {
|
|
16007
|
-
const abs = normalizePath(
|
|
16159
|
+
const abs = normalizePath(resolve26(cwd2, candidate));
|
|
16008
16160
|
if (existsSync23(abs) && !roots.includes(abs))
|
|
16009
16161
|
roots.push(abs);
|
|
16010
16162
|
}
|
|
16011
16163
|
const extraDirs = config.dev?.watchDirs ?? [];
|
|
16012
16164
|
for (const dir of extraDirs)
|
|
16013
16165
|
push(dir);
|
|
16166
|
+
if (cfg.angularDir) {
|
|
16167
|
+
const resourceDirs = collectAngularResourceDirs(cfg.angularDir);
|
|
16168
|
+
for (const dir of resourceDirs) {
|
|
16169
|
+
if (!roots.includes(dir))
|
|
16170
|
+
roots.push(dir);
|
|
16171
|
+
}
|
|
16172
|
+
}
|
|
16014
16173
|
return roots;
|
|
16015
16174
|
}, getWatchPaths = (config, resolved) => {
|
|
16016
16175
|
const roots = collectPositiveWatchRoots(config, resolved);
|
|
@@ -16068,7 +16227,7 @@ var init_pathUtils = __esm(() => {
|
|
|
16068
16227
|
// src/dev/fileWatcher.ts
|
|
16069
16228
|
import { watch } from "fs";
|
|
16070
16229
|
import { existsSync as existsSync24 } from "fs";
|
|
16071
|
-
import { join as join27, resolve as
|
|
16230
|
+
import { join as join27, resolve as resolve27 } from "path";
|
|
16072
16231
|
var safeRemoveFromGraph = (graph, fullPath) => {
|
|
16073
16232
|
try {
|
|
16074
16233
|
removeFileFromGraph(graph, fullPath);
|
|
@@ -16113,7 +16272,7 @@ var safeRemoveFromGraph = (graph, fullPath) => {
|
|
|
16113
16272
|
}, addFileWatchers = (state, paths, onFileChange) => {
|
|
16114
16273
|
const stylesDir = state.resolvedPaths?.stylesDir;
|
|
16115
16274
|
paths.forEach((path) => {
|
|
16116
|
-
const absolutePath =
|
|
16275
|
+
const absolutePath = resolve27(path).replace(/\\/g, "/");
|
|
16117
16276
|
if (!existsSync24(absolutePath)) {
|
|
16118
16277
|
return;
|
|
16119
16278
|
}
|
|
@@ -16124,7 +16283,7 @@ var safeRemoveFromGraph = (graph, fullPath) => {
|
|
|
16124
16283
|
const watchPaths = getWatchPaths(config, state.resolvedPaths);
|
|
16125
16284
|
const stylesDir = state.resolvedPaths?.stylesDir;
|
|
16126
16285
|
watchPaths.forEach((path) => {
|
|
16127
|
-
const absolutePath =
|
|
16286
|
+
const absolutePath = resolve27(path).replace(/\\/g, "/");
|
|
16128
16287
|
if (!existsSync24(absolutePath)) {
|
|
16129
16288
|
return;
|
|
16130
16289
|
}
|
|
@@ -16139,13 +16298,13 @@ var init_fileWatcher = __esm(() => {
|
|
|
16139
16298
|
});
|
|
16140
16299
|
|
|
16141
16300
|
// src/dev/assetStore.ts
|
|
16142
|
-
import { resolve as
|
|
16301
|
+
import { resolve as resolve28 } from "path";
|
|
16143
16302
|
import { readdir as readdir4, unlink } from "fs/promises";
|
|
16144
16303
|
var mimeTypes, getMimeType = (filePath) => {
|
|
16145
16304
|
const ext = filePath.slice(filePath.lastIndexOf("."));
|
|
16146
16305
|
return mimeTypes[ext] ?? "application/octet-stream";
|
|
16147
16306
|
}, HASHED_FILE_RE, stripHash = (webPath) => webPath.replace(/\.[a-z0-9]{8}(\.(js|css|mjs))$/, "$1"), processWalkEntry = (entry, dir, liveByIdentity, walkAndClean) => {
|
|
16148
|
-
const fullPath =
|
|
16307
|
+
const fullPath = resolve28(dir, entry.name);
|
|
16149
16308
|
if (entry.isDirectory()) {
|
|
16150
16309
|
return walkAndClean(fullPath);
|
|
16151
16310
|
}
|
|
@@ -16161,10 +16320,10 @@ var mimeTypes, getMimeType = (filePath) => {
|
|
|
16161
16320
|
}, cleanStaleAssets = async (store, manifest, buildDir) => {
|
|
16162
16321
|
const liveByIdentity = new Map;
|
|
16163
16322
|
for (const webPath of store.keys()) {
|
|
16164
|
-
const diskPath =
|
|
16323
|
+
const diskPath = resolve28(buildDir, webPath.slice(1));
|
|
16165
16324
|
liveByIdentity.set(stripHash(diskPath), diskPath);
|
|
16166
16325
|
}
|
|
16167
|
-
const absBuildDir =
|
|
16326
|
+
const absBuildDir = resolve28(buildDir);
|
|
16168
16327
|
Object.values(manifest).forEach((val) => {
|
|
16169
16328
|
if (!HASHED_FILE_RE.test(val))
|
|
16170
16329
|
return;
|
|
@@ -16182,7 +16341,7 @@ var mimeTypes, getMimeType = (filePath) => {
|
|
|
16182
16341
|
} catch {}
|
|
16183
16342
|
}, lookupAsset = (store, path) => store.get(path), processScanEntry = (entry, dir, prefix, store, scanDir) => {
|
|
16184
16343
|
if (entry.isDirectory()) {
|
|
16185
|
-
return scanDir(
|
|
16344
|
+
return scanDir(resolve28(dir, entry.name), `${prefix}${entry.name}/`);
|
|
16186
16345
|
}
|
|
16187
16346
|
if (!entry.name.startsWith("chunk-")) {
|
|
16188
16347
|
return null;
|
|
@@ -16191,7 +16350,7 @@ var mimeTypes, getMimeType = (filePath) => {
|
|
|
16191
16350
|
if (store.has(webPath)) {
|
|
16192
16351
|
return null;
|
|
16193
16352
|
}
|
|
16194
|
-
return Bun.file(
|
|
16353
|
+
return Bun.file(resolve28(dir, entry.name)).bytes().then((bytes) => {
|
|
16195
16354
|
store.set(webPath, bytes);
|
|
16196
16355
|
return;
|
|
16197
16356
|
}).catch(() => {});
|
|
@@ -16213,7 +16372,7 @@ var mimeTypes, getMimeType = (filePath) => {
|
|
|
16213
16372
|
for (const webPath of newIdentities.values()) {
|
|
16214
16373
|
if (store.has(webPath))
|
|
16215
16374
|
continue;
|
|
16216
|
-
loadPromises.push(Bun.file(
|
|
16375
|
+
loadPromises.push(Bun.file(resolve28(buildDir, webPath.slice(1))).bytes().then((bytes) => {
|
|
16217
16376
|
store.set(webPath, bytes);
|
|
16218
16377
|
return;
|
|
16219
16378
|
}).catch(() => {}));
|
|
@@ -16243,10 +16402,10 @@ var init_assetStore = __esm(() => {
|
|
|
16243
16402
|
});
|
|
16244
16403
|
|
|
16245
16404
|
// src/dev/fileHashTracker.ts
|
|
16246
|
-
import { readFileSync as
|
|
16405
|
+
import { readFileSync as readFileSync17 } from "fs";
|
|
16247
16406
|
var computeFileHash = (filePath) => {
|
|
16248
16407
|
try {
|
|
16249
|
-
const fileContent =
|
|
16408
|
+
const fileContent = readFileSync17(filePath);
|
|
16250
16409
|
return Number(Bun.hash(fileContent));
|
|
16251
16410
|
} catch {
|
|
16252
16411
|
return UNFOUND_INDEX;
|
|
@@ -16326,9 +16485,9 @@ var init_transformCache = __esm(() => {
|
|
|
16326
16485
|
});
|
|
16327
16486
|
|
|
16328
16487
|
// src/dev/reactComponentClassifier.ts
|
|
16329
|
-
import { resolve as
|
|
16488
|
+
import { resolve as resolve29 } from "path";
|
|
16330
16489
|
var classifyComponent = (filePath) => {
|
|
16331
|
-
const normalizedPath =
|
|
16490
|
+
const normalizedPath = resolve29(filePath);
|
|
16332
16491
|
if (normalizedPath.includes("/react/pages/")) {
|
|
16333
16492
|
return "server";
|
|
16334
16493
|
}
|
|
@@ -16340,7 +16499,7 @@ var classifyComponent = (filePath) => {
|
|
|
16340
16499
|
var init_reactComponentClassifier = () => {};
|
|
16341
16500
|
|
|
16342
16501
|
// src/dev/moduleMapper.ts
|
|
16343
|
-
import { basename as basename10, resolve as
|
|
16502
|
+
import { basename as basename10, resolve as resolve30 } from "path";
|
|
16344
16503
|
var buildModulePaths = (moduleKeys, manifest) => {
|
|
16345
16504
|
const modulePaths = {};
|
|
16346
16505
|
moduleKeys.forEach((key) => {
|
|
@@ -16350,7 +16509,7 @@ var buildModulePaths = (moduleKeys, manifest) => {
|
|
|
16350
16509
|
});
|
|
16351
16510
|
return modulePaths;
|
|
16352
16511
|
}, processChangedFile = (sourceFile, framework, manifest, resolvedPaths, processedFiles) => {
|
|
16353
|
-
const normalizedFile =
|
|
16512
|
+
const normalizedFile = resolve30(sourceFile);
|
|
16354
16513
|
const normalizedPath = normalizedFile.replace(/\\/g, "/");
|
|
16355
16514
|
if (processedFiles.has(normalizedFile)) {
|
|
16356
16515
|
return null;
|
|
@@ -16386,7 +16545,7 @@ var buildModulePaths = (moduleKeys, manifest) => {
|
|
|
16386
16545
|
});
|
|
16387
16546
|
return grouped;
|
|
16388
16547
|
}, mapSourceFileToManifestKeys = (sourceFile, framework, resolvedPaths) => {
|
|
16389
|
-
const normalizedFile =
|
|
16548
|
+
const normalizedFile = resolve30(sourceFile);
|
|
16390
16549
|
const fileName = basename10(normalizedFile);
|
|
16391
16550
|
const baseName = fileName.replace(/\.(tsx?|jsx?|vue|svelte|css|html)$/, "");
|
|
16392
16551
|
const pascalName = toPascal(baseName);
|
|
@@ -16546,7 +16705,7 @@ var init_ssrCache = __esm(() => {
|
|
|
16546
16705
|
});
|
|
16547
16706
|
|
|
16548
16707
|
// src/dev/angular/editTypeDetection.ts
|
|
16549
|
-
import { readFileSync as
|
|
16708
|
+
import { readFileSync as readFileSync18 } from "fs";
|
|
16550
16709
|
import { basename as basename11 } from "path";
|
|
16551
16710
|
import * as ts3 from "typescript";
|
|
16552
16711
|
var TYPE_PRIORITY, STYLE_EXT_RE, COMPONENT_STYLE_RE, TEMPLATE_RE, COMPONENT_CLASS_RE, SERVICE_RE, ROUTES_RE, PAGE_TS_RE, SIDE_EFFECT_CALL_NAMES, SIDE_EFFECT_NEW_NAMES, getCalleeName = (node) => {
|
|
@@ -16626,7 +16785,7 @@ var TYPE_PRIORITY, STYLE_EXT_RE, COMPONENT_STYLE_RE, TEMPLATE_RE, COMPONENT_CLAS
|
|
|
16626
16785
|
}, analyzeServiceFile = (file5) => {
|
|
16627
16786
|
let source;
|
|
16628
16787
|
try {
|
|
16629
|
-
source =
|
|
16788
|
+
source = readFileSync18(file5, "utf8");
|
|
16630
16789
|
} catch {
|
|
16631
16790
|
return {
|
|
16632
16791
|
hasSideEffectCtor: true,
|
|
@@ -16797,8 +16956,8 @@ __export(exports_moduleServer, {
|
|
|
16797
16956
|
createModuleServer: () => createModuleServer,
|
|
16798
16957
|
SRC_URL_PREFIX: () => SRC_URL_PREFIX
|
|
16799
16958
|
});
|
|
16800
|
-
import { existsSync as existsSync25, readFileSync as
|
|
16801
|
-
import { basename as basename12, dirname as
|
|
16959
|
+
import { existsSync as existsSync25, readFileSync as readFileSync19, statSync as statSync2 } from "fs";
|
|
16960
|
+
import { basename as basename12, dirname as dirname17, extname as extname8, join as join28, resolve as resolve31, relative as relative12 } from "path";
|
|
16802
16961
|
var SRC_PREFIX = "/@src/", jsTranspiler2, tsTranspiler2, tsxTranspiler, TRANSPILABLE, ALL_EXPORTS_RE, STRING_CONTENTS_RE, preserveTypeExports = (originalSource, transpiled, valueExports) => {
|
|
16803
16962
|
const codeOnly = originalSource.replace(STRING_CONTENTS_RE, '""');
|
|
16804
16963
|
const allExports = [];
|
|
@@ -16818,7 +16977,7 @@ var SRC_PREFIX = "/@src/", jsTranspiler2, tsTranspiler2, tsxTranspiler, TRANSPIL
|
|
|
16818
16977
|
${stubs}
|
|
16819
16978
|
`;
|
|
16820
16979
|
}, resolveRelativeExtension = (srcPath, projectRoot, extensions) => {
|
|
16821
|
-
const found = extensions.find((ext) => existsSync25(
|
|
16980
|
+
const found = extensions.find((ext) => existsSync25(resolve31(projectRoot, srcPath + ext)));
|
|
16822
16981
|
return found ? srcPath + found : srcPath;
|
|
16823
16982
|
}, IMPORT_EXTENSIONS, SIDE_EFFECT_EXTENSIONS, MODULE_EXTENSIONS, RESOLVED_MODULE_EXTENSIONS, REACT_EXTENSIONS, escapeRegex3 = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), buildImportRewriter = (vendorPaths) => {
|
|
16824
16983
|
const entries = Object.entries(vendorPaths).sort(([a], [b2]) => b2.length - a.length);
|
|
@@ -16833,7 +16992,7 @@ ${stubs}
|
|
|
16833
16992
|
return invalidationVersion > 0 ? `${mtime}.${invalidationVersion}` : `${mtime}`;
|
|
16834
16993
|
}, srcUrl = (relPath, projectRoot) => {
|
|
16835
16994
|
const base = `${SRC_PREFIX}${relPath.replace(/\\/g, "/")}`;
|
|
16836
|
-
const absPath =
|
|
16995
|
+
const absPath = resolve31(projectRoot, relPath);
|
|
16837
16996
|
const cached = mtimeCache.get(absPath);
|
|
16838
16997
|
if (cached !== undefined)
|
|
16839
16998
|
return `${base}?v=${buildVersion(cached, absPath)}`;
|
|
@@ -16845,12 +17004,12 @@ ${stubs}
|
|
|
16845
17004
|
return base;
|
|
16846
17005
|
}
|
|
16847
17006
|
}, resolveRelativeImport = (relPath, fileDir, projectRoot, extensions) => {
|
|
16848
|
-
const absPath =
|
|
16849
|
-
const rel =
|
|
17007
|
+
const absPath = resolve31(fileDir, relPath);
|
|
17008
|
+
const rel = relative12(projectRoot, absPath);
|
|
16850
17009
|
const extension = extname8(rel);
|
|
16851
17010
|
let srcPath = RESOLVED_MODULE_EXTENSIONS.has(extension) ? rel : resolveRelativeExtension(rel, projectRoot, extensions);
|
|
16852
17011
|
if (extname8(srcPath) === ".svelte") {
|
|
16853
|
-
srcPath =
|
|
17012
|
+
srcPath = relative12(projectRoot, resolveSvelteModulePath(resolve31(projectRoot, srcPath)));
|
|
16854
17013
|
}
|
|
16855
17014
|
return srcUrl(srcPath, projectRoot);
|
|
16856
17015
|
}, resolveAbsoluteSpecifier = (specifier, projectRoot) => {
|
|
@@ -16860,27 +17019,27 @@ ${stubs}
|
|
|
16860
17019
|
"import"
|
|
16861
17020
|
]);
|
|
16862
17021
|
if (fromExports)
|
|
16863
|
-
return
|
|
17022
|
+
return relative12(projectRoot, fromExports);
|
|
16864
17023
|
try {
|
|
16865
17024
|
const isScoped = specifier.startsWith("@");
|
|
16866
17025
|
const parts = specifier.split("/");
|
|
16867
17026
|
const packageName = isScoped ? `${parts[0]}/${parts[1]}` : parts[0];
|
|
16868
17027
|
const subpath = isScoped ? parts.slice(2).join("/") : parts.slice(1).join("/");
|
|
16869
17028
|
if (!subpath) {
|
|
16870
|
-
const pkgDir =
|
|
17029
|
+
const pkgDir = resolve31(projectRoot, "node_modules", packageName ?? "");
|
|
16871
17030
|
const pkgJsonPath = join28(pkgDir, "package.json");
|
|
16872
17031
|
if (existsSync25(pkgJsonPath)) {
|
|
16873
|
-
const pkg = JSON.parse(
|
|
17032
|
+
const pkg = JSON.parse(readFileSync19(pkgJsonPath, "utf-8"));
|
|
16874
17033
|
const esmEntry = typeof pkg.module === "string" && pkg.module || typeof pkg.browser === "string" && pkg.browser;
|
|
16875
17034
|
if (esmEntry) {
|
|
16876
|
-
const resolved =
|
|
17035
|
+
const resolved = resolve31(pkgDir, esmEntry);
|
|
16877
17036
|
if (existsSync25(resolved))
|
|
16878
|
-
return
|
|
17037
|
+
return relative12(projectRoot, resolved);
|
|
16879
17038
|
}
|
|
16880
17039
|
}
|
|
16881
17040
|
}
|
|
16882
17041
|
} catch {}
|
|
16883
|
-
return
|
|
17042
|
+
return relative12(projectRoot, Bun.resolveSync(specifier, projectRoot));
|
|
16884
17043
|
} catch {
|
|
16885
17044
|
return;
|
|
16886
17045
|
}
|
|
@@ -16905,26 +17064,26 @@ ${stubs}
|
|
|
16905
17064
|
};
|
|
16906
17065
|
result = result.replace(/^((?:import\s+[\s\S]+?\s+from|export\s+[\s\S]+?\s+from|import)\s*["'])([^"'./][^"']*)(["'])/gm, stubReplace);
|
|
16907
17066
|
result = result.replace(/(import\s*\(\s*["'])([^"'./][^"']*)(["']\s*\))/g, stubReplace);
|
|
16908
|
-
const fileDir =
|
|
17067
|
+
const fileDir = dirname17(filePath);
|
|
16909
17068
|
result = result.replace(/(from\s*["'])(\.\.?\/[^"']+)(["'])/g, (_match, prefix, relPath, suffix) => `${prefix}${resolveRelativeImport(relPath, fileDir, projectRoot, IMPORT_EXTENSIONS)}${suffix}`);
|
|
16910
17069
|
result = result.replace(/(import\s*\(\s*["'])(\.\.?\/[^"']+)(["']\s*\))/g, (_match, prefix, relPath, suffix) => `${prefix}${resolveRelativeImport(relPath, fileDir, projectRoot, IMPORT_EXTENSIONS)}${suffix}`);
|
|
16911
17070
|
result = result.replace(/(import\s*["'])(\.\.?\/[^"']+)(["']\s*;?)/g, (_match, prefix, relPath, suffix) => `${prefix}${resolveRelativeImport(relPath, fileDir, projectRoot, SIDE_EFFECT_EXTENSIONS)}${suffix}`);
|
|
16912
17071
|
result = result.replace(/((?:from|import)\s*["'])(\/[^"']+\.(tsx?|jsx?|ts))(["'])/g, (_match, prefix, absPath, _ext, suffix) => {
|
|
16913
17072
|
if (absPath.startsWith(projectRoot)) {
|
|
16914
|
-
const rel2 =
|
|
17073
|
+
const rel2 = relative12(projectRoot, absPath).replace(/\\/g, "/");
|
|
16915
17074
|
return `${prefix}${srcUrl(rel2, projectRoot)}${suffix}`;
|
|
16916
17075
|
}
|
|
16917
|
-
const rel =
|
|
17076
|
+
const rel = relative12(projectRoot, absPath).replace(/\\/g, "/");
|
|
16918
17077
|
return `${prefix}${srcUrl(rel, projectRoot)}${suffix}`;
|
|
16919
17078
|
});
|
|
16920
17079
|
result = result.replace(/new\s+URL\(\s*["'](\.\.?\/[^"']+)["']\s*,\s*import\.meta\.url\s*\)/g, (_match, relPath) => {
|
|
16921
|
-
const absPath =
|
|
16922
|
-
const rel =
|
|
17080
|
+
const absPath = resolve31(fileDir, relPath);
|
|
17081
|
+
const rel = relative12(projectRoot, absPath);
|
|
16923
17082
|
return `new URL('${srcUrl(rel, projectRoot)}', import.meta.url)`;
|
|
16924
17083
|
});
|
|
16925
17084
|
result = result.replace(/import\.meta\.resolve\(\s*["'](\.\.?\/[^"']+)["']\s*\)/g, (_match, relPath) => {
|
|
16926
|
-
const absPath =
|
|
16927
|
-
const rel =
|
|
17085
|
+
const absPath = resolve31(fileDir, relPath);
|
|
17086
|
+
const rel = relative12(projectRoot, absPath);
|
|
16928
17087
|
return `'${srcUrl(rel, projectRoot)}'`;
|
|
16929
17088
|
});
|
|
16930
17089
|
return result;
|
|
@@ -16969,7 +17128,7 @@ ${code}`;
|
|
|
16969
17128
|
reactFastRefreshWarningEmitted = true;
|
|
16970
17129
|
logWarn("React HMR is blocked: this Bun build ignores " + "`reactFastRefresh` on Bun.Transpiler, so component state " + "cannot be preserved across edits. Tracking " + "https://github.com/oven-sh/bun/pull/28312 \u2014 if it still has " + "not merged, leave a \uD83D\uDC4D on the PR so the Bun team knows it " + "is blocking you. Until then, React edits trigger a full " + "reload instead of a fast refresh.");
|
|
16971
17130
|
}, transformReactFile = (filePath, projectRoot, rewriter) => {
|
|
16972
|
-
const raw =
|
|
17131
|
+
const raw = readFileSync19(filePath, "utf-8");
|
|
16973
17132
|
const valueExports = tsxTranspiler.scan(raw).exports;
|
|
16974
17133
|
let transpiled = reactTranspiler.transformSync(raw);
|
|
16975
17134
|
transpiled = preserveTypeExports(raw, transpiled, valueExports);
|
|
@@ -16980,12 +17139,12 @@ ${code}`;
|
|
|
16980
17139
|
transpiled = `var $RefreshReg$ = window.$RefreshReg$ || function(){};
|
|
16981
17140
|
` + `var $RefreshSig$ = window.$RefreshSig$ || function(){ return function(t){ return t; }; };
|
|
16982
17141
|
${transpiled}`;
|
|
16983
|
-
const relPath =
|
|
17142
|
+
const relPath = relative12(projectRoot, filePath).replace(/\\/g, "/");
|
|
16984
17143
|
transpiled = transpiled.replace(/\binput\.tsx:/g, `${relPath}:`);
|
|
16985
17144
|
transpiled += buildIslandMetadataExports(raw);
|
|
16986
17145
|
return rewriteImports(transpiled, filePath, projectRoot, rewriter);
|
|
16987
17146
|
}, transformPlainFile = (filePath, projectRoot, rewriter, vueDir) => {
|
|
16988
|
-
const raw =
|
|
17147
|
+
const raw = readFileSync19(filePath, "utf-8");
|
|
16989
17148
|
const ext = extname8(filePath);
|
|
16990
17149
|
const isTS = ext === ".ts" || ext === ".tsx";
|
|
16991
17150
|
const isTSX = ext === ".tsx" || ext === ".jsx";
|
|
@@ -17141,17 +17300,17 @@ ${code}`;
|
|
|
17141
17300
|
if (compiled.css?.code) {
|
|
17142
17301
|
const cssPath = `${filePath}.css`;
|
|
17143
17302
|
svelteExternalCss.set(cssPath, compiled.css.code);
|
|
17144
|
-
const cssUrl = srcUrl(
|
|
17303
|
+
const cssUrl = srcUrl(relative12(projectRoot, cssPath), projectRoot);
|
|
17145
17304
|
code = `import "${cssUrl}";
|
|
17146
17305
|
${code}`;
|
|
17147
17306
|
}
|
|
17148
|
-
const moduleUrl = `${SRC_PREFIX}${
|
|
17307
|
+
const moduleUrl = `${SRC_PREFIX}${relative12(projectRoot, filePath).replace(/\\/g, "/")}`;
|
|
17149
17308
|
code = code.replace(/if\s*\(import\.meta\.hot\)\s*\{/, `if (typeof window !== "undefined") {
|
|
17150
17309
|
` + ` if (!window.__SVELTE_HMR_ACCEPT__) window.__SVELTE_HMR_ACCEPT__ = {};
|
|
17151
17310
|
` + ` var __hmr_accept = function(cb) { window.__SVELTE_HMR_ACCEPT__[${JSON.stringify(moduleUrl)}] = cb; };`);
|
|
17152
17311
|
return code.replace(/import\.meta\.hot\.accept\(/g, "__hmr_accept(");
|
|
17153
17312
|
}, transformSvelteFile = async (filePath, projectRoot, rewriter, stylePreprocessors) => {
|
|
17154
|
-
const raw =
|
|
17313
|
+
const raw = readFileSync19(filePath, "utf-8");
|
|
17155
17314
|
if (!svelteCompiler) {
|
|
17156
17315
|
svelteCompiler = await import("svelte/compiler");
|
|
17157
17316
|
}
|
|
@@ -17211,7 +17370,7 @@ export default __script__;`;
|
|
|
17211
17370
|
return `${cssInjection}
|
|
17212
17371
|
${code}`;
|
|
17213
17372
|
}, transformVueFile = async (filePath, projectRoot, rewriter, vueDir, stylePreprocessors) => {
|
|
17214
|
-
const rawSource =
|
|
17373
|
+
const rawSource = readFileSync19(filePath, "utf-8");
|
|
17215
17374
|
const raw = addAutoRouterSetupApp(rawSource);
|
|
17216
17375
|
if (!vueCompiler) {
|
|
17217
17376
|
vueCompiler = await import("@vue/compiler-sfc");
|
|
@@ -17234,8 +17393,8 @@ ${code}`;
|
|
|
17234
17393
|
code = injectVueHmr(code, filePath, projectRoot, vueDir);
|
|
17235
17394
|
return rewriteImports(code, filePath, projectRoot, rewriter);
|
|
17236
17395
|
}, injectVueHmr = (code, filePath, projectRoot, vueDir) => {
|
|
17237
|
-
const hmrBase = vueDir ?
|
|
17238
|
-
const hmrId =
|
|
17396
|
+
const hmrBase = vueDir ? resolve31(vueDir) : projectRoot;
|
|
17397
|
+
const hmrId = relative12(hmrBase, filePath).replace(/\\/g, "/").replace(/\.vue$/, "");
|
|
17239
17398
|
let result = code.replace(/export\s+default\s+/, "var __hmr_comp__ = ");
|
|
17240
17399
|
result += [
|
|
17241
17400
|
"",
|
|
@@ -17266,7 +17425,7 @@ ${code}`;
|
|
|
17266
17425
|
}
|
|
17267
17426
|
});
|
|
17268
17427
|
}, handleCssRequest = (filePath) => {
|
|
17269
|
-
const raw =
|
|
17428
|
+
const raw = readFileSync19(filePath, "utf-8");
|
|
17270
17429
|
const escaped = raw.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$/g, "\\$");
|
|
17271
17430
|
return [
|
|
17272
17431
|
`const style = document.createElement('style');`,
|
|
@@ -17393,7 +17552,7 @@ export default {};
|
|
|
17393
17552
|
const escaped = virtualCss.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$/g, "\\$");
|
|
17394
17553
|
return jsResponse(`var s=document.createElement('style');s.textContent=\`${escaped}\`;s.dataset.svelteHmr=${JSON.stringify(cssCheckPath)};var p=document.querySelector('style[data-svelte-hmr="${cssCheckPath}"]');if(p)p.remove();document.head.appendChild(s);`);
|
|
17395
17554
|
}, resolveSourcePath = (relPath, projectRoot) => {
|
|
17396
|
-
const filePath =
|
|
17555
|
+
const filePath = resolve31(projectRoot, relPath);
|
|
17397
17556
|
const ext = extname8(filePath);
|
|
17398
17557
|
if (ext === ".svelte")
|
|
17399
17558
|
return { ext, filePath: resolveSvelteModulePath(filePath) };
|
|
@@ -17420,7 +17579,7 @@ export default {};
|
|
|
17420
17579
|
if (!TRANSPILABLE.has(ext))
|
|
17421
17580
|
return;
|
|
17422
17581
|
const stat3 = statSync2(filePath);
|
|
17423
|
-
const resolvedVueDir = vueDir ?
|
|
17582
|
+
const resolvedVueDir = vueDir ? resolve31(vueDir) : undefined;
|
|
17424
17583
|
const content = REACT_EXTENSIONS.has(ext) ? transformReactFile(filePath, projectRoot, rewriter) : transformPlainFile(filePath, projectRoot, rewriter, resolvedVueDir);
|
|
17425
17584
|
setTransformed(filePath, content, stat3.mtimeMs, extractImportedFiles(content, projectRoot));
|
|
17426
17585
|
return jsResponse(content);
|
|
@@ -17451,7 +17610,7 @@ export default {};
|
|
|
17451
17610
|
if (!pathname.startsWith(SRC_PREFIX))
|
|
17452
17611
|
return;
|
|
17453
17612
|
const relPath = pathname.slice(SRC_PREFIX.length);
|
|
17454
|
-
const virtualCssResponse = handleVirtualSvelteCss(
|
|
17613
|
+
const virtualCssResponse = handleVirtualSvelteCss(resolve31(projectRoot, relPath));
|
|
17455
17614
|
if (virtualCssResponse)
|
|
17456
17615
|
return virtualCssResponse;
|
|
17457
17616
|
const { filePath, ext } = resolveSourcePath(relPath, projectRoot);
|
|
@@ -17467,11 +17626,11 @@ export default {};
|
|
|
17467
17626
|
SRC_IMPORT_RE.lastIndex = 0;
|
|
17468
17627
|
while ((match = SRC_IMPORT_RE.exec(content)) !== null) {
|
|
17469
17628
|
if (match[1])
|
|
17470
|
-
files.push(
|
|
17629
|
+
files.push(resolve31(projectRoot, match[1]));
|
|
17471
17630
|
}
|
|
17472
17631
|
return files;
|
|
17473
17632
|
}, invalidateModule = (filePath) => {
|
|
17474
|
-
const resolved =
|
|
17633
|
+
const resolved = resolve31(filePath);
|
|
17475
17634
|
invalidate(filePath);
|
|
17476
17635
|
if (resolved !== filePath)
|
|
17477
17636
|
invalidate(resolved);
|
|
@@ -17586,6 +17745,1441 @@ var init_rewriteImports = __esm(() => {
|
|
|
17586
17745
|
rewriteVendorDirectories2 = rewriteVendorDirectories;
|
|
17587
17746
|
});
|
|
17588
17747
|
|
|
17748
|
+
// src/dev/angular/resolveOwningComponents.ts
|
|
17749
|
+
var exports_resolveOwningComponents = {};
|
|
17750
|
+
__export(exports_resolveOwningComponents, {
|
|
17751
|
+
resolveOwningComponents: () => resolveOwningComponents
|
|
17752
|
+
});
|
|
17753
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync20, statSync as statSync3 } from "fs";
|
|
17754
|
+
import { dirname as dirname18, extname as extname9, join as join29, resolve as resolve32 } from "path";
|
|
17755
|
+
import ts4 from "typescript";
|
|
17756
|
+
var isComponentTsFile = (file5) => file5.endsWith(".component.ts") || file5.endsWith(".component.tsx"), walkComponentTsFiles = (root) => {
|
|
17757
|
+
const out = [];
|
|
17758
|
+
const visit = (dir) => {
|
|
17759
|
+
let entries;
|
|
17760
|
+
try {
|
|
17761
|
+
entries = readdirSync2(dir, { withFileTypes: true });
|
|
17762
|
+
} catch {
|
|
17763
|
+
return;
|
|
17764
|
+
}
|
|
17765
|
+
for (const entry of entries) {
|
|
17766
|
+
if (entry.name.startsWith(".") || entry.name === "node_modules") {
|
|
17767
|
+
continue;
|
|
17768
|
+
}
|
|
17769
|
+
const full = join29(dir, entry.name);
|
|
17770
|
+
if (entry.isDirectory()) {
|
|
17771
|
+
visit(full);
|
|
17772
|
+
} else if (entry.isFile() && isComponentTsFile(entry.name)) {
|
|
17773
|
+
out.push(full);
|
|
17774
|
+
}
|
|
17775
|
+
}
|
|
17776
|
+
};
|
|
17777
|
+
visit(root);
|
|
17778
|
+
return out;
|
|
17779
|
+
}, getStringPropertyValue = (obj, name) => {
|
|
17780
|
+
for (const prop of obj.properties) {
|
|
17781
|
+
if (!ts4.isPropertyAssignment(prop))
|
|
17782
|
+
continue;
|
|
17783
|
+
const propName = ts4.isIdentifier(prop.name) ? prop.name.text : ts4.isStringLiteral(prop.name) ? prop.name.text : null;
|
|
17784
|
+
if (propName !== name)
|
|
17785
|
+
continue;
|
|
17786
|
+
const init = prop.initializer;
|
|
17787
|
+
if (ts4.isStringLiteral(init) || ts4.isNoSubstitutionTemplateLiteral(init)) {
|
|
17788
|
+
return init.text;
|
|
17789
|
+
}
|
|
17790
|
+
}
|
|
17791
|
+
return null;
|
|
17792
|
+
}, getStringArrayProperty = (obj, name) => {
|
|
17793
|
+
const out = [];
|
|
17794
|
+
for (const prop of obj.properties) {
|
|
17795
|
+
if (!ts4.isPropertyAssignment(prop))
|
|
17796
|
+
continue;
|
|
17797
|
+
const propName = ts4.isIdentifier(prop.name) ? prop.name.text : ts4.isStringLiteral(prop.name) ? prop.name.text : null;
|
|
17798
|
+
if (propName !== name)
|
|
17799
|
+
continue;
|
|
17800
|
+
const init = prop.initializer;
|
|
17801
|
+
if (!ts4.isArrayLiteralExpression(init))
|
|
17802
|
+
continue;
|
|
17803
|
+
for (const element of init.elements) {
|
|
17804
|
+
if (ts4.isStringLiteral(element) || ts4.isNoSubstitutionTemplateLiteral(element)) {
|
|
17805
|
+
out.push(element.text);
|
|
17806
|
+
}
|
|
17807
|
+
}
|
|
17808
|
+
}
|
|
17809
|
+
return out;
|
|
17810
|
+
}, parseComponentRefs = (filePath) => {
|
|
17811
|
+
const refs = {
|
|
17812
|
+
classNames: [],
|
|
17813
|
+
templateUrls: [],
|
|
17814
|
+
styleUrls: []
|
|
17815
|
+
};
|
|
17816
|
+
let source;
|
|
17817
|
+
try {
|
|
17818
|
+
source = readFileSync20(filePath, "utf8");
|
|
17819
|
+
} catch {
|
|
17820
|
+
return refs;
|
|
17821
|
+
}
|
|
17822
|
+
const sourceFile = ts4.createSourceFile(filePath, source, ts4.ScriptTarget.ES2022, true, ts4.ScriptKind.TS);
|
|
17823
|
+
const visit = (node) => {
|
|
17824
|
+
if (ts4.isClassDeclaration(node) && node.name) {
|
|
17825
|
+
const decorators = ts4.getDecorators(node) ?? [];
|
|
17826
|
+
for (const decorator of decorators) {
|
|
17827
|
+
const expr = decorator.expression;
|
|
17828
|
+
if (!ts4.isCallExpression(expr))
|
|
17829
|
+
continue;
|
|
17830
|
+
const fn2 = expr.expression;
|
|
17831
|
+
if (!ts4.isIdentifier(fn2) || fn2.text !== "Component")
|
|
17832
|
+
continue;
|
|
17833
|
+
refs.classNames.push(node.name.text);
|
|
17834
|
+
const arg = expr.arguments[0];
|
|
17835
|
+
if (!arg || !ts4.isObjectLiteralExpression(arg))
|
|
17836
|
+
continue;
|
|
17837
|
+
const tplUrl = getStringPropertyValue(arg, "templateUrl");
|
|
17838
|
+
if (tplUrl)
|
|
17839
|
+
refs.templateUrls.push(tplUrl);
|
|
17840
|
+
const styleUrl = getStringPropertyValue(arg, "styleUrl");
|
|
17841
|
+
if (styleUrl)
|
|
17842
|
+
refs.styleUrls.push(styleUrl);
|
|
17843
|
+
refs.styleUrls.push(...getStringArrayProperty(arg, "styleUrls"));
|
|
17844
|
+
}
|
|
17845
|
+
}
|
|
17846
|
+
ts4.forEachChild(node, visit);
|
|
17847
|
+
};
|
|
17848
|
+
visit(sourceFile);
|
|
17849
|
+
return refs;
|
|
17850
|
+
}, safeNormalize = (path) => resolve32(path).replace(/\\/g, "/"), resolveOwningComponents = (params) => {
|
|
17851
|
+
const { changedFilePath, userAngularRoot } = params;
|
|
17852
|
+
const changedAbs = safeNormalize(changedFilePath);
|
|
17853
|
+
const out = [];
|
|
17854
|
+
if (changedAbs.endsWith(".component.ts")) {
|
|
17855
|
+
const refs = parseComponentRefs(changedAbs);
|
|
17856
|
+
for (const className of refs.classNames) {
|
|
17857
|
+
out.push({ componentFilePath: changedAbs, className });
|
|
17858
|
+
}
|
|
17859
|
+
return out;
|
|
17860
|
+
}
|
|
17861
|
+
const ext = extname9(changedAbs).toLowerCase();
|
|
17862
|
+
if (ext !== ".html" && ext !== ".css" && ext !== ".scss" && ext !== ".sass") {
|
|
17863
|
+
return out;
|
|
17864
|
+
}
|
|
17865
|
+
let rootStat;
|
|
17866
|
+
try {
|
|
17867
|
+
rootStat = statSync3(userAngularRoot);
|
|
17868
|
+
} catch {
|
|
17869
|
+
return out;
|
|
17870
|
+
}
|
|
17871
|
+
if (!rootStat.isDirectory())
|
|
17872
|
+
return out;
|
|
17873
|
+
for (const componentTsPath of walkComponentTsFiles(userAngularRoot)) {
|
|
17874
|
+
const refs = parseComponentRefs(componentTsPath);
|
|
17875
|
+
const componentDir = dirname18(componentTsPath);
|
|
17876
|
+
const matchesResource = (relativeUrl) => {
|
|
17877
|
+
const abs = safeNormalize(resolve32(componentDir, relativeUrl));
|
|
17878
|
+
return abs === changedAbs;
|
|
17879
|
+
};
|
|
17880
|
+
const referencesChanged = refs.templateUrls.some(matchesResource) || refs.styleUrls.some(matchesResource);
|
|
17881
|
+
if (!referencesChanged)
|
|
17882
|
+
continue;
|
|
17883
|
+
for (const className of refs.classNames) {
|
|
17884
|
+
out.push({
|
|
17885
|
+
componentFilePath: componentTsPath,
|
|
17886
|
+
className
|
|
17887
|
+
});
|
|
17888
|
+
}
|
|
17889
|
+
}
|
|
17890
|
+
return out;
|
|
17891
|
+
};
|
|
17892
|
+
var init_resolveOwningComponents = () => {};
|
|
17893
|
+
|
|
17894
|
+
// src/dev/angular/hmrImportGenerator.ts
|
|
17895
|
+
import ts5 from "typescript";
|
|
17896
|
+
var createHmrImportGenerator = (namespaceMap) => ({
|
|
17897
|
+
addImport(request) {
|
|
17898
|
+
const ns = namespaceMap.get(request.exportModuleSpecifier);
|
|
17899
|
+
if (!ns) {
|
|
17900
|
+
throw new Error(`HMR import generator has no namespace mapping for ${request.exportModuleSpecifier}. ` + `Add it to namespaceDependencies before calling compileHmrUpdateCallback.`);
|
|
17901
|
+
}
|
|
17902
|
+
const namespaceId = ts5.factory.createIdentifier(ns);
|
|
17903
|
+
if (request.exportSymbolName === null) {
|
|
17904
|
+
return namespaceId;
|
|
17905
|
+
}
|
|
17906
|
+
return ts5.factory.createPropertyAccessExpression(namespaceId, ts5.factory.createIdentifier(request.exportSymbolName));
|
|
17907
|
+
}
|
|
17908
|
+
});
|
|
17909
|
+
var init_hmrImportGenerator = () => {};
|
|
17910
|
+
|
|
17911
|
+
// src/dev/angular/vendor/translator/context.ts
|
|
17912
|
+
class Context {
|
|
17913
|
+
isStatement;
|
|
17914
|
+
constructor(isStatement) {
|
|
17915
|
+
this.isStatement = isStatement;
|
|
17916
|
+
}
|
|
17917
|
+
get withExpressionMode() {
|
|
17918
|
+
return this.isStatement ? new Context(false) : this;
|
|
17919
|
+
}
|
|
17920
|
+
get withStatementMode() {
|
|
17921
|
+
return !this.isStatement ? new Context(true) : this;
|
|
17922
|
+
}
|
|
17923
|
+
}
|
|
17924
|
+
|
|
17925
|
+
// src/dev/angular/vendor/translator/translator.ts
|
|
17926
|
+
import * as o from "@angular/compiler";
|
|
17927
|
+
|
|
17928
|
+
class ExpressionTranslatorVisitor {
|
|
17929
|
+
factory;
|
|
17930
|
+
imports;
|
|
17931
|
+
contextFile;
|
|
17932
|
+
downlevelTaggedTemplates;
|
|
17933
|
+
downlevelVariableDeclarations;
|
|
17934
|
+
recordWrappedNode;
|
|
17935
|
+
constructor(factory, imports, contextFile, options) {
|
|
17936
|
+
this.factory = factory;
|
|
17937
|
+
this.imports = imports;
|
|
17938
|
+
this.contextFile = contextFile;
|
|
17939
|
+
this.downlevelTaggedTemplates = options.downlevelTaggedTemplates === true;
|
|
17940
|
+
this.downlevelVariableDeclarations = options.downlevelVariableDeclarations === true;
|
|
17941
|
+
this.recordWrappedNode = options.recordWrappedNode || (() => {});
|
|
17942
|
+
}
|
|
17943
|
+
visitDeclareVarStmt(stmt, context) {
|
|
17944
|
+
const varType = this.downlevelVariableDeclarations ? "var" : stmt.hasModifier(o.StmtModifier.Final) ? "const" : "let";
|
|
17945
|
+
return this.attachComments(this.factory.createVariableDeclaration(stmt.name, stmt.value?.visitExpression(this, context.withExpressionMode), varType, stmt.type?.visitType(this, context)), stmt.leadingComments);
|
|
17946
|
+
}
|
|
17947
|
+
visitDeclareFunctionStmt(stmt, context) {
|
|
17948
|
+
return this.attachComments(this.factory.createFunctionDeclaration(stmt.name, this.translateParams(stmt.params, context), this.factory.createBlock(this.visitStatements(stmt.statements, context.withStatementMode))), stmt.leadingComments);
|
|
17949
|
+
}
|
|
17950
|
+
visitExpressionStmt(stmt, context) {
|
|
17951
|
+
return this.attachComments(this.factory.createExpressionStatement(stmt.expr.visitExpression(this, context.withStatementMode)), stmt.leadingComments);
|
|
17952
|
+
}
|
|
17953
|
+
visitReturnStmt(stmt, context) {
|
|
17954
|
+
return this.attachComments(this.factory.createReturnStatement(stmt.value.visitExpression(this, context.withExpressionMode)), stmt.leadingComments);
|
|
17955
|
+
}
|
|
17956
|
+
visitIfStmt(stmt, context) {
|
|
17957
|
+
return this.attachComments(this.factory.createIfStatement(stmt.condition.visitExpression(this, context), this.factory.createBlock(this.visitStatements(stmt.trueCase, context.withStatementMode)), stmt.falseCase.length > 0 ? this.factory.createBlock(this.visitStatements(stmt.falseCase, context.withStatementMode)) : null), stmt.leadingComments);
|
|
17958
|
+
}
|
|
17959
|
+
visitReadVarExpr(ast, _context) {
|
|
17960
|
+
const identifier = this.factory.createIdentifier(ast.name);
|
|
17961
|
+
this.setSourceMapRange(identifier, ast.sourceSpan);
|
|
17962
|
+
return identifier;
|
|
17963
|
+
}
|
|
17964
|
+
visitInvokeFunctionExpr(ast, context) {
|
|
17965
|
+
return this.setSourceMapRange(this.factory.createCallExpression(ast.fn.visitExpression(this, context), ast.args.map((arg) => arg.visitExpression(this, context)), ast.pure), ast.sourceSpan);
|
|
17966
|
+
}
|
|
17967
|
+
visitTaggedTemplateLiteralExpr(ast, context) {
|
|
17968
|
+
return this.setSourceMapRange(this.createTaggedTemplateExpression(ast.tag.visitExpression(this, context), this.getTemplateLiteralFromAst(ast.template, context)), ast.sourceSpan);
|
|
17969
|
+
}
|
|
17970
|
+
visitTemplateLiteralExpr(ast, context) {
|
|
17971
|
+
return this.setSourceMapRange(this.factory.createTemplateLiteral(this.getTemplateLiteralFromAst(ast, context)), ast.sourceSpan);
|
|
17972
|
+
}
|
|
17973
|
+
visitInstantiateExpr(ast, context) {
|
|
17974
|
+
return this.factory.createNewExpression(ast.classExpr.visitExpression(this, context), ast.args.map((arg) => arg.visitExpression(this, context)));
|
|
17975
|
+
}
|
|
17976
|
+
visitLiteralExpr(ast, _context) {
|
|
17977
|
+
return this.setSourceMapRange(this.factory.createLiteral(ast.value), ast.sourceSpan);
|
|
17978
|
+
}
|
|
17979
|
+
visitRegularExpressionLiteral(ast, context) {
|
|
17980
|
+
return this.setSourceMapRange(this.factory.createRegularExpressionLiteral(ast.body, ast.flags), ast.sourceSpan);
|
|
17981
|
+
}
|
|
17982
|
+
visitLocalizedString(ast, context) {
|
|
17983
|
+
const elements = [createTemplateElement(ast.serializeI18nHead())];
|
|
17984
|
+
const expressions = [];
|
|
17985
|
+
for (let i = 0;i < ast.expressions.length; i++) {
|
|
17986
|
+
const placeholder = this.setSourceMapRange(ast.expressions[i].visitExpression(this, context), ast.getPlaceholderSourceSpan(i));
|
|
17987
|
+
expressions.push(placeholder);
|
|
17988
|
+
elements.push(createTemplateElement(ast.serializeI18nTemplatePart(i + 1)));
|
|
17989
|
+
}
|
|
17990
|
+
const localizeTag = this.factory.createIdentifier("$localize");
|
|
17991
|
+
return this.setSourceMapRange(this.createTaggedTemplateExpression(localizeTag, { elements, expressions }), ast.sourceSpan);
|
|
17992
|
+
}
|
|
17993
|
+
visitBuiltinType(ast) {
|
|
17994
|
+
let builtInType;
|
|
17995
|
+
switch (ast.name) {
|
|
17996
|
+
case o.BuiltinTypeName.Bool:
|
|
17997
|
+
builtInType = "boolean";
|
|
17998
|
+
break;
|
|
17999
|
+
case o.BuiltinTypeName.String:
|
|
18000
|
+
builtInType = "string";
|
|
18001
|
+
break;
|
|
18002
|
+
case o.BuiltinTypeName.Dynamic:
|
|
18003
|
+
builtInType = "any";
|
|
18004
|
+
break;
|
|
18005
|
+
case o.BuiltinTypeName.Number:
|
|
18006
|
+
case o.BuiltinTypeName.Int:
|
|
18007
|
+
builtInType = "number";
|
|
18008
|
+
break;
|
|
18009
|
+
case o.BuiltinTypeName.Function:
|
|
18010
|
+
builtInType = "function";
|
|
18011
|
+
break;
|
|
18012
|
+
case o.BuiltinTypeName.None:
|
|
18013
|
+
builtInType = "never";
|
|
18014
|
+
break;
|
|
18015
|
+
case o.BuiltinTypeName.Inferred:
|
|
18016
|
+
return null;
|
|
18017
|
+
}
|
|
18018
|
+
return this.factory.createBuiltInType(builtInType);
|
|
18019
|
+
}
|
|
18020
|
+
visitExpressionType(ast, context) {
|
|
18021
|
+
return this.factory.createExpressionType(ast.value.visitExpression(this, context), ast.typeParams === null || ast.typeParams.length === 0 ? null : ast.typeParams.map((param) => param.visitType(this, context)));
|
|
18022
|
+
}
|
|
18023
|
+
visitArrayType(ast, context) {
|
|
18024
|
+
return this.factory.createArrayType(ast.of.visitType(this, context));
|
|
18025
|
+
}
|
|
18026
|
+
visitMapType(ast, context) {
|
|
18027
|
+
const valueType = ast.valueType === null ? this.factory.createBuiltInType("unknown") : ast.valueType.visitType(this, context);
|
|
18028
|
+
return this.factory.createMapType(valueType);
|
|
18029
|
+
}
|
|
18030
|
+
visitTransplantedType(type) {
|
|
18031
|
+
return this.factory.transplantType(type.type);
|
|
18032
|
+
}
|
|
18033
|
+
createTaggedTemplateExpression(tag, template) {
|
|
18034
|
+
return this.downlevelTaggedTemplates ? this.createES5TaggedTemplateFunctionCall(tag, template) : this.factory.createTaggedTemplate(tag, template);
|
|
18035
|
+
}
|
|
18036
|
+
createES5TaggedTemplateFunctionCall(tagHandler, { elements, expressions }) {
|
|
18037
|
+
const __makeTemplateObjectHelper = this.imports.addImport({
|
|
18038
|
+
exportModuleSpecifier: "tslib",
|
|
18039
|
+
exportSymbolName: "__makeTemplateObject",
|
|
18040
|
+
requestedFile: this.contextFile
|
|
18041
|
+
});
|
|
18042
|
+
const cooked = [];
|
|
18043
|
+
const raw = [];
|
|
18044
|
+
for (const element of elements) {
|
|
18045
|
+
cooked.push(this.factory.setSourceMapRange(this.factory.createLiteral(element.cooked), element.range));
|
|
18046
|
+
raw.push(this.factory.setSourceMapRange(this.factory.createLiteral(element.raw), element.range));
|
|
18047
|
+
}
|
|
18048
|
+
const templateHelperCall = this.factory.createCallExpression(__makeTemplateObjectHelper, [this.factory.createArrayLiteral(cooked), this.factory.createArrayLiteral(raw)], false);
|
|
18049
|
+
return this.factory.createCallExpression(tagHandler, [templateHelperCall, ...expressions], false);
|
|
18050
|
+
}
|
|
18051
|
+
visitExternalExpr(ast, _context) {
|
|
18052
|
+
if (ast.value.name === null) {
|
|
18053
|
+
if (ast.value.moduleName === null) {
|
|
18054
|
+
throw new Error("Invalid import without name nor moduleName");
|
|
18055
|
+
}
|
|
18056
|
+
return this.imports.addImport({
|
|
18057
|
+
exportModuleSpecifier: ast.value.moduleName,
|
|
18058
|
+
exportSymbolName: null,
|
|
18059
|
+
requestedFile: this.contextFile
|
|
18060
|
+
});
|
|
18061
|
+
}
|
|
18062
|
+
if (ast.value.moduleName !== null) {
|
|
18063
|
+
return this.imports.addImport({
|
|
18064
|
+
exportModuleSpecifier: ast.value.moduleName,
|
|
18065
|
+
exportSymbolName: ast.value.name,
|
|
18066
|
+
requestedFile: this.contextFile
|
|
18067
|
+
});
|
|
18068
|
+
} else {
|
|
18069
|
+
return this.factory.createIdentifier(ast.value.name);
|
|
18070
|
+
}
|
|
18071
|
+
}
|
|
18072
|
+
visitConditionalExpr(ast, context) {
|
|
18073
|
+
return this.factory.createConditional(ast.condition.visitExpression(this, context), ast.trueCase.visitExpression(this, context), ast.falseCase.visitExpression(this, context));
|
|
18074
|
+
}
|
|
18075
|
+
visitDynamicImportExpr(ast, context) {
|
|
18076
|
+
const urlExpression = typeof ast.url === "string" ? this.factory.createLiteral(ast.url) : ast.url.visitExpression(this, context);
|
|
18077
|
+
if (ast.urlComment) {
|
|
18078
|
+
this.factory.attachComments(urlExpression, [o.leadingComment(ast.urlComment, true)]);
|
|
18079
|
+
}
|
|
18080
|
+
return this.factory.createDynamicImport(urlExpression);
|
|
18081
|
+
}
|
|
18082
|
+
visitNotExpr(ast, context) {
|
|
18083
|
+
return this.factory.createUnaryExpression("!", ast.condition.visitExpression(this, context));
|
|
18084
|
+
}
|
|
18085
|
+
visitFunctionExpr(ast, context) {
|
|
18086
|
+
return this.factory.createFunctionExpression(ast.name ?? null, this.translateParams(ast.params, context), this.factory.createBlock(this.visitStatements(ast.statements, context)));
|
|
18087
|
+
}
|
|
18088
|
+
visitArrowFunctionExpr(ast, context) {
|
|
18089
|
+
return this.factory.createArrowFunctionExpression(this.translateParams(ast.params, context), Array.isArray(ast.body) ? this.factory.createBlock(this.visitStatements(ast.body, context)) : ast.body.visitExpression(this, context));
|
|
18090
|
+
}
|
|
18091
|
+
visitBinaryOperatorExpr(ast, context) {
|
|
18092
|
+
if (!BINARY_OPERATORS.has(ast.operator)) {
|
|
18093
|
+
throw new Error(`Unknown binary operator: ${o.BinaryOperator[ast.operator]}`);
|
|
18094
|
+
}
|
|
18095
|
+
const operator = BINARY_OPERATORS.get(ast.operator);
|
|
18096
|
+
if (ast.isAssignment()) {
|
|
18097
|
+
return this.factory.createAssignment(ast.lhs.visitExpression(this, context), operator, ast.rhs.visitExpression(this, context));
|
|
18098
|
+
}
|
|
18099
|
+
return this.factory.createBinaryExpression(ast.lhs.visitExpression(this, context), operator, ast.rhs.visitExpression(this, context));
|
|
18100
|
+
}
|
|
18101
|
+
visitReadPropExpr(ast, context) {
|
|
18102
|
+
return this.factory.createPropertyAccess(ast.receiver.visitExpression(this, context), ast.name);
|
|
18103
|
+
}
|
|
18104
|
+
visitReadKeyExpr(ast, context) {
|
|
18105
|
+
return this.factory.createElementAccess(ast.receiver.visitExpression(this, context), ast.index.visitExpression(this, context));
|
|
18106
|
+
}
|
|
18107
|
+
visitLiteralArrayExpr(ast, context) {
|
|
18108
|
+
return this.factory.createArrayLiteral(ast.entries.map((expr) => this.setSourceMapRange(expr.visitExpression(this, context), ast.sourceSpan)));
|
|
18109
|
+
}
|
|
18110
|
+
visitLiteralMapExpr(ast, context) {
|
|
18111
|
+
const properties = ast.entries.map((entry) => {
|
|
18112
|
+
return entry instanceof o.LiteralMapPropertyAssignment ? {
|
|
18113
|
+
kind: "property",
|
|
18114
|
+
propertyName: entry.key,
|
|
18115
|
+
quoted: entry.quoted,
|
|
18116
|
+
value: entry.value.visitExpression(this, context)
|
|
18117
|
+
} : {
|
|
18118
|
+
kind: "spread",
|
|
18119
|
+
expression: entry.expression.visitExpression(this, context)
|
|
18120
|
+
};
|
|
18121
|
+
});
|
|
18122
|
+
return this.setSourceMapRange(this.factory.createObjectLiteral(properties), ast.sourceSpan);
|
|
18123
|
+
}
|
|
18124
|
+
visitCommaExpr(ast, context) {
|
|
18125
|
+
throw new Error("Method not implemented.");
|
|
18126
|
+
}
|
|
18127
|
+
visitTemplateLiteralElementExpr(ast, context) {
|
|
18128
|
+
throw new Error("Method not implemented");
|
|
18129
|
+
}
|
|
18130
|
+
visitSpreadElementExpr(ast, context) {
|
|
18131
|
+
const expression = ast.expression.visitExpression(this, context);
|
|
18132
|
+
return this.setSourceMapRange(this.factory.createSpreadElement(expression), ast.sourceSpan);
|
|
18133
|
+
}
|
|
18134
|
+
visitWrappedNodeExpr(ast, _context) {
|
|
18135
|
+
this.recordWrappedNode(ast);
|
|
18136
|
+
return ast.node;
|
|
18137
|
+
}
|
|
18138
|
+
visitTypeofExpr(ast, context) {
|
|
18139
|
+
return this.factory.createTypeOfExpression(ast.expr.visitExpression(this, context));
|
|
18140
|
+
}
|
|
18141
|
+
visitVoidExpr(ast, context) {
|
|
18142
|
+
return this.factory.createVoidExpression(ast.expr.visitExpression(this, context));
|
|
18143
|
+
}
|
|
18144
|
+
visitUnaryOperatorExpr(ast, context) {
|
|
18145
|
+
if (!UNARY_OPERATORS.has(ast.operator)) {
|
|
18146
|
+
throw new Error(`Unknown unary operator: ${o.UnaryOperator[ast.operator]}`);
|
|
18147
|
+
}
|
|
18148
|
+
return this.factory.createUnaryExpression(UNARY_OPERATORS.get(ast.operator), ast.expr.visitExpression(this, context));
|
|
18149
|
+
}
|
|
18150
|
+
visitParenthesizedExpr(ast, context) {
|
|
18151
|
+
const result = ast.expr.visitExpression(this, context);
|
|
18152
|
+
return this.factory.createParenthesizedExpression(result);
|
|
18153
|
+
}
|
|
18154
|
+
visitStatements(statements, context) {
|
|
18155
|
+
return statements.map((stmt) => stmt.visitStatement(this, context)).filter((stmt) => stmt !== undefined);
|
|
18156
|
+
}
|
|
18157
|
+
setSourceMapRange(ast, span) {
|
|
18158
|
+
return this.factory.setSourceMapRange(ast, createRange(span));
|
|
18159
|
+
}
|
|
18160
|
+
attachComments(statement, leadingComments) {
|
|
18161
|
+
if (leadingComments !== undefined) {
|
|
18162
|
+
this.factory.attachComments(statement, leadingComments);
|
|
18163
|
+
}
|
|
18164
|
+
return statement;
|
|
18165
|
+
}
|
|
18166
|
+
getTemplateLiteralFromAst(ast, context) {
|
|
18167
|
+
return {
|
|
18168
|
+
elements: ast.elements.map((e) => createTemplateElement({
|
|
18169
|
+
cooked: e.text,
|
|
18170
|
+
raw: e.rawText,
|
|
18171
|
+
range: e.sourceSpan ?? ast.sourceSpan
|
|
18172
|
+
})),
|
|
18173
|
+
expressions: ast.expressions.map((e) => e.visitExpression(this, context))
|
|
18174
|
+
};
|
|
18175
|
+
}
|
|
18176
|
+
translateParams(params, context) {
|
|
18177
|
+
return params.map((param) => ({
|
|
18178
|
+
name: param.name,
|
|
18179
|
+
type: param.type?.visitType(this, context)
|
|
18180
|
+
}));
|
|
18181
|
+
}
|
|
18182
|
+
}
|
|
18183
|
+
function createTemplateElement({
|
|
18184
|
+
cooked,
|
|
18185
|
+
raw,
|
|
18186
|
+
range
|
|
18187
|
+
}) {
|
|
18188
|
+
return { cooked, raw, range: createRange(range) };
|
|
18189
|
+
}
|
|
18190
|
+
function createRange(span) {
|
|
18191
|
+
if (span === null) {
|
|
18192
|
+
return null;
|
|
18193
|
+
}
|
|
18194
|
+
const { start, end } = span;
|
|
18195
|
+
const { url, content } = start.file;
|
|
18196
|
+
if (!url) {
|
|
18197
|
+
return null;
|
|
18198
|
+
}
|
|
18199
|
+
return {
|
|
18200
|
+
url,
|
|
18201
|
+
content,
|
|
18202
|
+
start: { offset: start.offset, line: start.line, column: start.col },
|
|
18203
|
+
end: { offset: end.offset, line: end.line, column: end.col }
|
|
18204
|
+
};
|
|
18205
|
+
}
|
|
18206
|
+
var UNARY_OPERATORS, BINARY_OPERATORS;
|
|
18207
|
+
var init_translator = __esm(() => {
|
|
18208
|
+
UNARY_OPERATORS = /* @__PURE__ */ new Map([
|
|
18209
|
+
[o.UnaryOperator.Minus, "-"],
|
|
18210
|
+
[o.UnaryOperator.Plus, "+"]
|
|
18211
|
+
]);
|
|
18212
|
+
BINARY_OPERATORS = /* @__PURE__ */ new Map([
|
|
18213
|
+
[o.BinaryOperator.And, "&&"],
|
|
18214
|
+
[o.BinaryOperator.Bigger, ">"],
|
|
18215
|
+
[o.BinaryOperator.BiggerEquals, ">="],
|
|
18216
|
+
[o.BinaryOperator.BitwiseAnd, "&"],
|
|
18217
|
+
[o.BinaryOperator.BitwiseOr, "|"],
|
|
18218
|
+
[o.BinaryOperator.Divide, "/"],
|
|
18219
|
+
[o.BinaryOperator.Equals, "=="],
|
|
18220
|
+
[o.BinaryOperator.Identical, "==="],
|
|
18221
|
+
[o.BinaryOperator.Lower, "<"],
|
|
18222
|
+
[o.BinaryOperator.LowerEquals, "<="],
|
|
18223
|
+
[o.BinaryOperator.Minus, "-"],
|
|
18224
|
+
[o.BinaryOperator.Modulo, "%"],
|
|
18225
|
+
[o.BinaryOperator.Multiply, "*"],
|
|
18226
|
+
[o.BinaryOperator.NotEquals, "!="],
|
|
18227
|
+
[o.BinaryOperator.NotIdentical, "!=="],
|
|
18228
|
+
[o.BinaryOperator.Or, "||"],
|
|
18229
|
+
[o.BinaryOperator.Plus, "+"],
|
|
18230
|
+
[o.BinaryOperator.NullishCoalesce, "??"],
|
|
18231
|
+
[o.BinaryOperator.Exponentiation, "**"],
|
|
18232
|
+
[o.BinaryOperator.In, "in"],
|
|
18233
|
+
[o.BinaryOperator.InstanceOf, "instanceof"],
|
|
18234
|
+
[o.BinaryOperator.Assign, "="],
|
|
18235
|
+
[o.BinaryOperator.AdditionAssignment, "+="],
|
|
18236
|
+
[o.BinaryOperator.SubtractionAssignment, "-="],
|
|
18237
|
+
[o.BinaryOperator.MultiplicationAssignment, "*="],
|
|
18238
|
+
[o.BinaryOperator.DivisionAssignment, "/="],
|
|
18239
|
+
[o.BinaryOperator.RemainderAssignment, "%="],
|
|
18240
|
+
[o.BinaryOperator.ExponentiationAssignment, "**="],
|
|
18241
|
+
[o.BinaryOperator.AndAssignment, "&&="],
|
|
18242
|
+
[o.BinaryOperator.OrAssignment, "||="],
|
|
18243
|
+
[o.BinaryOperator.NullishCoalesceAssignment, "??="]
|
|
18244
|
+
]);
|
|
18245
|
+
});
|
|
18246
|
+
|
|
18247
|
+
// src/dev/angular/vendor/translator/ts_util.ts
|
|
18248
|
+
import ts6 from "typescript";
|
|
18249
|
+
function tsNumericExpression(value) {
|
|
18250
|
+
if (value < 0) {
|
|
18251
|
+
const operand = ts6.factory.createNumericLiteral(Math.abs(value));
|
|
18252
|
+
return ts6.factory.createPrefixUnaryExpression(ts6.SyntaxKind.MinusToken, operand);
|
|
18253
|
+
}
|
|
18254
|
+
return ts6.factory.createNumericLiteral(value);
|
|
18255
|
+
}
|
|
18256
|
+
var init_ts_util = __esm(() => {
|
|
18257
|
+
/*!
|
|
18258
|
+
* @license
|
|
18259
|
+
* Copyright Google LLC All Rights Reserved.
|
|
18260
|
+
*
|
|
18261
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
18262
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
18263
|
+
*/
|
|
18264
|
+
});
|
|
18265
|
+
|
|
18266
|
+
// src/dev/angular/vendor/translator/typescript_ast_factory.ts
|
|
18267
|
+
import ts7 from "typescript";
|
|
18268
|
+
|
|
18269
|
+
class TypeScriptAstFactory {
|
|
18270
|
+
annotateForClosureCompiler;
|
|
18271
|
+
externalSourceFiles = new Map;
|
|
18272
|
+
UNARY_OPERATORS = /* @__PURE__ */ (() => ({
|
|
18273
|
+
"+": ts7.SyntaxKind.PlusToken,
|
|
18274
|
+
"-": ts7.SyntaxKind.MinusToken,
|
|
18275
|
+
"!": ts7.SyntaxKind.ExclamationToken
|
|
18276
|
+
}))();
|
|
18277
|
+
BINARY_OPERATORS = /* @__PURE__ */ (() => ({
|
|
18278
|
+
"&&": ts7.SyntaxKind.AmpersandAmpersandToken,
|
|
18279
|
+
">": ts7.SyntaxKind.GreaterThanToken,
|
|
18280
|
+
">=": ts7.SyntaxKind.GreaterThanEqualsToken,
|
|
18281
|
+
"&": ts7.SyntaxKind.AmpersandToken,
|
|
18282
|
+
"|": ts7.SyntaxKind.BarToken,
|
|
18283
|
+
"/": ts7.SyntaxKind.SlashToken,
|
|
18284
|
+
"==": ts7.SyntaxKind.EqualsEqualsToken,
|
|
18285
|
+
"===": ts7.SyntaxKind.EqualsEqualsEqualsToken,
|
|
18286
|
+
"<": ts7.SyntaxKind.LessThanToken,
|
|
18287
|
+
"<=": ts7.SyntaxKind.LessThanEqualsToken,
|
|
18288
|
+
"-": ts7.SyntaxKind.MinusToken,
|
|
18289
|
+
"%": ts7.SyntaxKind.PercentToken,
|
|
18290
|
+
"*": ts7.SyntaxKind.AsteriskToken,
|
|
18291
|
+
"**": ts7.SyntaxKind.AsteriskAsteriskToken,
|
|
18292
|
+
"!=": ts7.SyntaxKind.ExclamationEqualsToken,
|
|
18293
|
+
"!==": ts7.SyntaxKind.ExclamationEqualsEqualsToken,
|
|
18294
|
+
"||": ts7.SyntaxKind.BarBarToken,
|
|
18295
|
+
"+": ts7.SyntaxKind.PlusToken,
|
|
18296
|
+
"??": ts7.SyntaxKind.QuestionQuestionToken,
|
|
18297
|
+
"=": ts7.SyntaxKind.EqualsToken,
|
|
18298
|
+
"+=": ts7.SyntaxKind.PlusEqualsToken,
|
|
18299
|
+
"-=": ts7.SyntaxKind.MinusEqualsToken,
|
|
18300
|
+
"*=": ts7.SyntaxKind.AsteriskEqualsToken,
|
|
18301
|
+
"/=": ts7.SyntaxKind.SlashEqualsToken,
|
|
18302
|
+
"%=": ts7.SyntaxKind.PercentEqualsToken,
|
|
18303
|
+
"**=": ts7.SyntaxKind.AsteriskAsteriskEqualsToken,
|
|
18304
|
+
"&&=": ts7.SyntaxKind.AmpersandAmpersandEqualsToken,
|
|
18305
|
+
"||=": ts7.SyntaxKind.BarBarEqualsToken,
|
|
18306
|
+
"??=": ts7.SyntaxKind.QuestionQuestionEqualsToken,
|
|
18307
|
+
in: ts7.SyntaxKind.InKeyword,
|
|
18308
|
+
instanceof: ts7.SyntaxKind.InstanceOfKeyword
|
|
18309
|
+
}))();
|
|
18310
|
+
VAR_TYPES = /* @__PURE__ */ (() => ({
|
|
18311
|
+
const: ts7.NodeFlags.Const,
|
|
18312
|
+
let: ts7.NodeFlags.Let,
|
|
18313
|
+
var: ts7.NodeFlags.None
|
|
18314
|
+
}))();
|
|
18315
|
+
constructor(annotateForClosureCompiler) {
|
|
18316
|
+
this.annotateForClosureCompiler = annotateForClosureCompiler;
|
|
18317
|
+
}
|
|
18318
|
+
attachComments = attachComments;
|
|
18319
|
+
createArrayLiteral = ts7.factory.createArrayLiteralExpression;
|
|
18320
|
+
createAssignment(target, operator, value) {
|
|
18321
|
+
return ts7.factory.createBinaryExpression(target, this.BINARY_OPERATORS[operator], value);
|
|
18322
|
+
}
|
|
18323
|
+
createBinaryExpression(leftOperand, operator, rightOperand) {
|
|
18324
|
+
return ts7.factory.createBinaryExpression(leftOperand, this.BINARY_OPERATORS[operator], rightOperand);
|
|
18325
|
+
}
|
|
18326
|
+
createBlock(body) {
|
|
18327
|
+
return ts7.factory.createBlock(body);
|
|
18328
|
+
}
|
|
18329
|
+
createCallExpression(callee, args, pure) {
|
|
18330
|
+
const call = ts7.factory.createCallExpression(callee, undefined, args);
|
|
18331
|
+
if (pure) {
|
|
18332
|
+
ts7.addSyntheticLeadingComment(call, ts7.SyntaxKind.MultiLineCommentTrivia, this.annotateForClosureCompiler ? "* @pureOrBreakMyCode " /* CLOSURE */ : "@__PURE__" /* TERSER */, false);
|
|
18333
|
+
}
|
|
18334
|
+
return call;
|
|
18335
|
+
}
|
|
18336
|
+
createConditional(condition, whenTrue, whenFalse) {
|
|
18337
|
+
return ts7.factory.createConditionalExpression(condition, undefined, whenTrue, undefined, whenFalse);
|
|
18338
|
+
}
|
|
18339
|
+
createElementAccess = ts7.factory.createElementAccessExpression;
|
|
18340
|
+
createExpressionStatement = ts7.factory.createExpressionStatement;
|
|
18341
|
+
createDynamicImport(url) {
|
|
18342
|
+
return ts7.factory.createCallExpression(ts7.factory.createToken(ts7.SyntaxKind.ImportKeyword), undefined, [typeof url === "string" ? ts7.factory.createStringLiteral(url) : url]);
|
|
18343
|
+
}
|
|
18344
|
+
createFunctionDeclaration(functionName, parameters, body) {
|
|
18345
|
+
if (!ts7.isBlock(body)) {
|
|
18346
|
+
throw new Error(`Invalid syntax, expected a block, but got ${ts7.SyntaxKind[body.kind]}.`);
|
|
18347
|
+
}
|
|
18348
|
+
return ts7.factory.createFunctionDeclaration(undefined, undefined, functionName, undefined, parameters.map((param) => this.createParameter(param)), undefined, body);
|
|
18349
|
+
}
|
|
18350
|
+
createFunctionExpression(functionName, parameters, body) {
|
|
18351
|
+
if (!ts7.isBlock(body)) {
|
|
18352
|
+
throw new Error(`Invalid syntax, expected a block, but got ${ts7.SyntaxKind[body.kind]}.`);
|
|
18353
|
+
}
|
|
18354
|
+
return ts7.factory.createFunctionExpression(undefined, undefined, functionName ?? undefined, undefined, parameters.map((param) => this.createParameter(param)), undefined, body);
|
|
18355
|
+
}
|
|
18356
|
+
createArrowFunctionExpression(parameters, body) {
|
|
18357
|
+
if (ts7.isStatement(body) && !ts7.isBlock(body)) {
|
|
18358
|
+
throw new Error(`Invalid syntax, expected a block, but got ${ts7.SyntaxKind[body.kind]}.`);
|
|
18359
|
+
}
|
|
18360
|
+
return ts7.factory.createArrowFunction(undefined, undefined, parameters.map((param) => this.createParameter(param)), undefined, undefined, body);
|
|
18361
|
+
}
|
|
18362
|
+
createParameter(param) {
|
|
18363
|
+
return ts7.factory.createParameterDeclaration(undefined, undefined, param.name, undefined, param.type ?? undefined);
|
|
18364
|
+
}
|
|
18365
|
+
createIdentifier = ts7.factory.createIdentifier;
|
|
18366
|
+
createIfStatement(condition, thenStatement, elseStatement) {
|
|
18367
|
+
return ts7.factory.createIfStatement(condition, thenStatement, elseStatement ?? undefined);
|
|
18368
|
+
}
|
|
18369
|
+
createLiteral(value) {
|
|
18370
|
+
if (value === undefined) {
|
|
18371
|
+
return ts7.factory.createIdentifier("undefined");
|
|
18372
|
+
} else if (value === null) {
|
|
18373
|
+
return ts7.factory.createNull();
|
|
18374
|
+
} else if (typeof value === "boolean") {
|
|
18375
|
+
return value ? ts7.factory.createTrue() : ts7.factory.createFalse();
|
|
18376
|
+
} else if (typeof value === "number") {
|
|
18377
|
+
return tsNumericExpression(value);
|
|
18378
|
+
} else {
|
|
18379
|
+
return ts7.factory.createStringLiteral(value);
|
|
18380
|
+
}
|
|
18381
|
+
}
|
|
18382
|
+
createNewExpression(expression, args) {
|
|
18383
|
+
return ts7.factory.createNewExpression(expression, undefined, args);
|
|
18384
|
+
}
|
|
18385
|
+
createObjectLiteral(properties) {
|
|
18386
|
+
return ts7.factory.createObjectLiteralExpression(properties.map((prop) => {
|
|
18387
|
+
if (prop.kind === "spread") {
|
|
18388
|
+
return ts7.factory.createSpreadAssignment(prop.expression);
|
|
18389
|
+
}
|
|
18390
|
+
return ts7.factory.createPropertyAssignment(prop.quoted ? ts7.factory.createStringLiteral(prop.propertyName) : ts7.factory.createIdentifier(prop.propertyName), prop.value);
|
|
18391
|
+
}));
|
|
18392
|
+
}
|
|
18393
|
+
createParenthesizedExpression = ts7.factory.createParenthesizedExpression;
|
|
18394
|
+
createPropertyAccess = ts7.factory.createPropertyAccessExpression;
|
|
18395
|
+
createSpreadElement = ts7.factory.createSpreadElement;
|
|
18396
|
+
createReturnStatement(expression) {
|
|
18397
|
+
return ts7.factory.createReturnStatement(expression ?? undefined);
|
|
18398
|
+
}
|
|
18399
|
+
createTaggedTemplate(tag, template) {
|
|
18400
|
+
return ts7.factory.createTaggedTemplateExpression(tag, undefined, this.createTemplateLiteral(template));
|
|
18401
|
+
}
|
|
18402
|
+
createTemplateLiteral(template) {
|
|
18403
|
+
let templateLiteral;
|
|
18404
|
+
const length = template.elements.length;
|
|
18405
|
+
const head = template.elements[0];
|
|
18406
|
+
if (length === 1) {
|
|
18407
|
+
templateLiteral = ts7.factory.createNoSubstitutionTemplateLiteral(head.cooked, head.raw);
|
|
18408
|
+
} else {
|
|
18409
|
+
const spans = [];
|
|
18410
|
+
for (let i = 1;i < length - 1; i++) {
|
|
18411
|
+
const { cooked, raw, range } = template.elements[i];
|
|
18412
|
+
const middle = createTemplateMiddle(cooked, raw);
|
|
18413
|
+
if (range !== null) {
|
|
18414
|
+
this.setSourceMapRange(middle, range);
|
|
18415
|
+
}
|
|
18416
|
+
spans.push(ts7.factory.createTemplateSpan(template.expressions[i - 1], middle));
|
|
18417
|
+
}
|
|
18418
|
+
const resolvedExpression = template.expressions[length - 2];
|
|
18419
|
+
const templatePart = template.elements[length - 1];
|
|
18420
|
+
const templateTail = createTemplateTail(templatePart.cooked, templatePart.raw);
|
|
18421
|
+
if (templatePart.range !== null) {
|
|
18422
|
+
this.setSourceMapRange(templateTail, templatePart.range);
|
|
18423
|
+
}
|
|
18424
|
+
spans.push(ts7.factory.createTemplateSpan(resolvedExpression, templateTail));
|
|
18425
|
+
templateLiteral = ts7.factory.createTemplateExpression(ts7.factory.createTemplateHead(head.cooked, head.raw), spans);
|
|
18426
|
+
}
|
|
18427
|
+
if (head.range !== null) {
|
|
18428
|
+
this.setSourceMapRange(templateLiteral, head.range);
|
|
18429
|
+
}
|
|
18430
|
+
return templateLiteral;
|
|
18431
|
+
}
|
|
18432
|
+
createThrowStatement = ts7.factory.createThrowStatement;
|
|
18433
|
+
createTypeOfExpression = ts7.factory.createTypeOfExpression;
|
|
18434
|
+
createVoidExpression = ts7.factory.createVoidExpression;
|
|
18435
|
+
createUnaryExpression(operator, operand) {
|
|
18436
|
+
return ts7.factory.createPrefixUnaryExpression(this.UNARY_OPERATORS[operator], operand);
|
|
18437
|
+
}
|
|
18438
|
+
createVariableDeclaration(variableName, initializer, variableType, type) {
|
|
18439
|
+
return ts7.factory.createVariableStatement(undefined, ts7.factory.createVariableDeclarationList([
|
|
18440
|
+
ts7.factory.createVariableDeclaration(variableName, undefined, type ?? undefined, initializer ?? undefined)
|
|
18441
|
+
], this.VAR_TYPES[variableType]));
|
|
18442
|
+
}
|
|
18443
|
+
createRegularExpressionLiteral(body, flags) {
|
|
18444
|
+
return ts7.factory.createRegularExpressionLiteral(`/${body}/${flags ?? ""}`);
|
|
18445
|
+
}
|
|
18446
|
+
setSourceMapRange(node, sourceMapRange) {
|
|
18447
|
+
if (sourceMapRange === null) {
|
|
18448
|
+
return node;
|
|
18449
|
+
}
|
|
18450
|
+
const url = sourceMapRange.url;
|
|
18451
|
+
if (!this.externalSourceFiles.has(url)) {
|
|
18452
|
+
this.externalSourceFiles.set(url, ts7.createSourceMapSource(url, sourceMapRange.content, (pos) => pos));
|
|
18453
|
+
}
|
|
18454
|
+
const source = this.externalSourceFiles.get(url);
|
|
18455
|
+
ts7.setSourceMapRange(node, {
|
|
18456
|
+
pos: sourceMapRange.start.offset,
|
|
18457
|
+
end: sourceMapRange.end.offset,
|
|
18458
|
+
source
|
|
18459
|
+
});
|
|
18460
|
+
return node;
|
|
18461
|
+
}
|
|
18462
|
+
createBuiltInType(type) {
|
|
18463
|
+
switch (type) {
|
|
18464
|
+
case "any":
|
|
18465
|
+
return ts7.factory.createKeywordTypeNode(ts7.SyntaxKind.AnyKeyword);
|
|
18466
|
+
case "boolean":
|
|
18467
|
+
return ts7.factory.createKeywordTypeNode(ts7.SyntaxKind.BooleanKeyword);
|
|
18468
|
+
case "number":
|
|
18469
|
+
return ts7.factory.createKeywordTypeNode(ts7.SyntaxKind.NumberKeyword);
|
|
18470
|
+
case "string":
|
|
18471
|
+
return ts7.factory.createKeywordTypeNode(ts7.SyntaxKind.StringKeyword);
|
|
18472
|
+
case "function":
|
|
18473
|
+
return ts7.factory.createTypeReferenceNode(ts7.factory.createIdentifier("Function"));
|
|
18474
|
+
case "never":
|
|
18475
|
+
return ts7.factory.createKeywordTypeNode(ts7.SyntaxKind.NeverKeyword);
|
|
18476
|
+
case "unknown":
|
|
18477
|
+
return ts7.factory.createKeywordTypeNode(ts7.SyntaxKind.UnknownKeyword);
|
|
18478
|
+
}
|
|
18479
|
+
}
|
|
18480
|
+
createExpressionType(expression, typeParams) {
|
|
18481
|
+
const typeName = getEntityTypeFromExpression(expression);
|
|
18482
|
+
return ts7.factory.createTypeReferenceNode(typeName, typeParams ?? undefined);
|
|
18483
|
+
}
|
|
18484
|
+
createArrayType(elementType) {
|
|
18485
|
+
return ts7.factory.createArrayTypeNode(elementType);
|
|
18486
|
+
}
|
|
18487
|
+
createMapType(valueType) {
|
|
18488
|
+
return ts7.factory.createTypeLiteralNode([
|
|
18489
|
+
ts7.factory.createIndexSignature(undefined, [
|
|
18490
|
+
ts7.factory.createParameterDeclaration(undefined, undefined, "key", undefined, ts7.factory.createKeywordTypeNode(ts7.SyntaxKind.StringKeyword))
|
|
18491
|
+
], valueType)
|
|
18492
|
+
]);
|
|
18493
|
+
}
|
|
18494
|
+
transplantType(type) {
|
|
18495
|
+
if (typeof type.kind === "number" && typeof type.getSourceFile === "function" && ts7.isTypeNode(type)) {
|
|
18496
|
+
return type;
|
|
18497
|
+
}
|
|
18498
|
+
throw new Error("Attempting to transplant a type node from a non-TypeScript AST: " + type);
|
|
18499
|
+
}
|
|
18500
|
+
}
|
|
18501
|
+
function createTemplateMiddle(cooked, raw) {
|
|
18502
|
+
const node = ts7.factory.createTemplateHead(cooked, raw);
|
|
18503
|
+
node.kind = ts7.SyntaxKind.TemplateMiddle;
|
|
18504
|
+
return node;
|
|
18505
|
+
}
|
|
18506
|
+
function createTemplateTail(cooked, raw) {
|
|
18507
|
+
const node = ts7.factory.createTemplateHead(cooked, raw);
|
|
18508
|
+
node.kind = ts7.SyntaxKind.TemplateTail;
|
|
18509
|
+
return node;
|
|
18510
|
+
}
|
|
18511
|
+
function attachComments(statement, leadingComments) {
|
|
18512
|
+
for (const comment of leadingComments) {
|
|
18513
|
+
const commentKind = comment.multiline ? ts7.SyntaxKind.MultiLineCommentTrivia : ts7.SyntaxKind.SingleLineCommentTrivia;
|
|
18514
|
+
if (comment.multiline) {
|
|
18515
|
+
ts7.addSyntheticLeadingComment(statement, commentKind, comment.toString(), comment.trailingNewline);
|
|
18516
|
+
} else {
|
|
18517
|
+
for (const line of comment.toString().split(`
|
|
18518
|
+
`)) {
|
|
18519
|
+
ts7.addSyntheticLeadingComment(statement, commentKind, line, comment.trailingNewline);
|
|
18520
|
+
}
|
|
18521
|
+
}
|
|
18522
|
+
}
|
|
18523
|
+
}
|
|
18524
|
+
function getEntityTypeFromExpression(expression) {
|
|
18525
|
+
if (ts7.isIdentifier(expression)) {
|
|
18526
|
+
return expression;
|
|
18527
|
+
}
|
|
18528
|
+
if (ts7.isPropertyAccessExpression(expression)) {
|
|
18529
|
+
const left = getEntityTypeFromExpression(expression.expression);
|
|
18530
|
+
if (!ts7.isIdentifier(expression.name)) {
|
|
18531
|
+
throw new Error(`Unsupported property access for type reference: ${expression.name.text}`);
|
|
18532
|
+
}
|
|
18533
|
+
return ts7.factory.createQualifiedName(left, expression.name);
|
|
18534
|
+
}
|
|
18535
|
+
throw new Error(`Unsupported expression for type reference: ${ts7.SyntaxKind[expression.kind]}`);
|
|
18536
|
+
}
|
|
18537
|
+
var init_typescript_ast_factory = __esm(() => {
|
|
18538
|
+
init_ts_util();
|
|
18539
|
+
});
|
|
18540
|
+
|
|
18541
|
+
// src/dev/angular/vendor/translator/typescript_translator.ts
|
|
18542
|
+
function translateStatement(contextFile, statement, imports, options = {}) {
|
|
18543
|
+
return statement.visitStatement(new ExpressionTranslatorVisitor(new TypeScriptAstFactory(options.annotateForClosureCompiler === true), imports, contextFile, options), new Context(true));
|
|
18544
|
+
}
|
|
18545
|
+
var init_typescript_translator = __esm(() => {
|
|
18546
|
+
init_translator();
|
|
18547
|
+
init_typescript_ast_factory();
|
|
18548
|
+
});
|
|
18549
|
+
|
|
18550
|
+
// src/dev/angular/fastHmrCompiler.ts
|
|
18551
|
+
import { existsSync as existsSync26, readFileSync as readFileSync21 } from "fs";
|
|
18552
|
+
import { dirname as dirname19, relative as relative13, resolve as resolve33 } from "path";
|
|
18553
|
+
import ts8 from "typescript";
|
|
18554
|
+
var fail = (reason, detail) => ({ ok: false, reason, detail }), findClassDeclaration = (sourceFile, className) => {
|
|
18555
|
+
let found = null;
|
|
18556
|
+
const walk = (node) => {
|
|
18557
|
+
if (found)
|
|
18558
|
+
return;
|
|
18559
|
+
if (ts8.isClassDeclaration(node) && node.name?.text === className) {
|
|
18560
|
+
found = node;
|
|
18561
|
+
return;
|
|
18562
|
+
}
|
|
18563
|
+
ts8.forEachChild(node, walk);
|
|
18564
|
+
};
|
|
18565
|
+
walk(sourceFile);
|
|
18566
|
+
return found;
|
|
18567
|
+
}, getClassDecorators = (cls) => {
|
|
18568
|
+
const modifiers = ts8.getDecorators(cls) ?? [];
|
|
18569
|
+
return [...modifiers];
|
|
18570
|
+
}, findComponentDecorator = (cls) => {
|
|
18571
|
+
for (const decorator of getClassDecorators(cls)) {
|
|
18572
|
+
const expr = decorator.expression;
|
|
18573
|
+
if (ts8.isCallExpression(expr)) {
|
|
18574
|
+
const fn2 = expr.expression;
|
|
18575
|
+
if (ts8.isIdentifier(fn2) && fn2.text === "Component") {
|
|
18576
|
+
return decorator;
|
|
18577
|
+
}
|
|
18578
|
+
}
|
|
18579
|
+
}
|
|
18580
|
+
return null;
|
|
18581
|
+
}, getDecoratorArgsObject = (decorator) => {
|
|
18582
|
+
const call = decorator.expression;
|
|
18583
|
+
if (!ts8.isCallExpression(call))
|
|
18584
|
+
return null;
|
|
18585
|
+
const arg = call.arguments[0];
|
|
18586
|
+
if (!arg || !ts8.isObjectLiteralExpression(arg))
|
|
18587
|
+
return null;
|
|
18588
|
+
return arg;
|
|
18589
|
+
}, getProperty = (obj, name) => {
|
|
18590
|
+
for (const prop of obj.properties) {
|
|
18591
|
+
if (ts8.isPropertyAssignment(prop) && (ts8.isIdentifier(prop.name) && prop.name.text === name || ts8.isStringLiteral(prop.name) && prop.name.text === name)) {
|
|
18592
|
+
return prop.initializer;
|
|
18593
|
+
}
|
|
18594
|
+
}
|
|
18595
|
+
return null;
|
|
18596
|
+
}, getStringProperty = (obj, name) => {
|
|
18597
|
+
const expr = getProperty(obj, name);
|
|
18598
|
+
if (!expr)
|
|
18599
|
+
return null;
|
|
18600
|
+
if (ts8.isStringLiteral(expr) || ts8.isNoSubstitutionTemplateLiteral(expr)) {
|
|
18601
|
+
return expr.text;
|
|
18602
|
+
}
|
|
18603
|
+
return null;
|
|
18604
|
+
}, getBooleanProperty = (obj, name) => {
|
|
18605
|
+
const expr = getProperty(obj, name);
|
|
18606
|
+
if (!expr)
|
|
18607
|
+
return null;
|
|
18608
|
+
if (expr.kind === ts8.SyntaxKind.TrueKeyword)
|
|
18609
|
+
return true;
|
|
18610
|
+
if (expr.kind === ts8.SyntaxKind.FalseKeyword)
|
|
18611
|
+
return false;
|
|
18612
|
+
return null;
|
|
18613
|
+
}, inheritsDecoratedClass = (cls) => {
|
|
18614
|
+
const heritage = cls.heritageClauses ?? [];
|
|
18615
|
+
for (const clause of heritage) {
|
|
18616
|
+
if (clause.token !== ts8.SyntaxKind.ExtendsKeyword)
|
|
18617
|
+
continue;
|
|
18618
|
+
if (clause.types.length > 0)
|
|
18619
|
+
return true;
|
|
18620
|
+
}
|
|
18621
|
+
return false;
|
|
18622
|
+
}, readDecoratorMeta = (args) => {
|
|
18623
|
+
const styleUrlsExpr = getProperty(args, "styleUrls");
|
|
18624
|
+
const stylesExpr = getProperty(args, "styles");
|
|
18625
|
+
const importsExpr = getProperty(args, "imports");
|
|
18626
|
+
const styleUrls = [];
|
|
18627
|
+
if (styleUrlsExpr && ts8.isArrayLiteralExpression(styleUrlsExpr)) {
|
|
18628
|
+
for (const el of styleUrlsExpr.elements) {
|
|
18629
|
+
if (ts8.isStringLiteral(el))
|
|
18630
|
+
styleUrls.push(el.text);
|
|
18631
|
+
}
|
|
18632
|
+
}
|
|
18633
|
+
const styles = [];
|
|
18634
|
+
if (stylesExpr) {
|
|
18635
|
+
if (ts8.isArrayLiteralExpression(stylesExpr)) {
|
|
18636
|
+
for (const el of stylesExpr.elements) {
|
|
18637
|
+
if (ts8.isStringLiteral(el) || ts8.isNoSubstitutionTemplateLiteral(el)) {
|
|
18638
|
+
styles.push(el.text);
|
|
18639
|
+
}
|
|
18640
|
+
}
|
|
18641
|
+
} else if (ts8.isStringLiteral(stylesExpr) || ts8.isNoSubstitutionTemplateLiteral(stylesExpr)) {
|
|
18642
|
+
styles.push(stylesExpr.text);
|
|
18643
|
+
}
|
|
18644
|
+
}
|
|
18645
|
+
return {
|
|
18646
|
+
selector: getStringProperty(args, "selector"),
|
|
18647
|
+
templateUrl: getStringProperty(args, "templateUrl"),
|
|
18648
|
+
template: getStringProperty(args, "template"),
|
|
18649
|
+
styleUrl: getStringProperty(args, "styleUrl"),
|
|
18650
|
+
styleUrls,
|
|
18651
|
+
styles,
|
|
18652
|
+
standalone: getBooleanProperty(args, "standalone") ?? true,
|
|
18653
|
+
preserveWhitespaces: getBooleanProperty(args, "preserveWhitespaces") ?? false,
|
|
18654
|
+
importsExpr: importsExpr && ts8.isArrayLiteralExpression(importsExpr) ? importsExpr : null
|
|
18655
|
+
};
|
|
18656
|
+
}, extractDecoratorInput = (prop) => {
|
|
18657
|
+
const decorators = ts8.getDecorators(prop) ?? [];
|
|
18658
|
+
for (const decorator of decorators) {
|
|
18659
|
+
const expr = decorator.expression;
|
|
18660
|
+
if (!ts8.isCallExpression(expr))
|
|
18661
|
+
continue;
|
|
18662
|
+
const fn2 = expr.expression;
|
|
18663
|
+
if (!ts8.isIdentifier(fn2) || fn2.text !== "Input")
|
|
18664
|
+
continue;
|
|
18665
|
+
const classPropertyName = prop.name.getText();
|
|
18666
|
+
let bindingPropertyName = classPropertyName;
|
|
18667
|
+
let required = false;
|
|
18668
|
+
const arg = expr.arguments[0];
|
|
18669
|
+
if (arg) {
|
|
18670
|
+
if (ts8.isStringLiteral(arg)) {
|
|
18671
|
+
bindingPropertyName = arg.text;
|
|
18672
|
+
} else if (ts8.isObjectLiteralExpression(arg)) {
|
|
18673
|
+
const aliasNode = getStringProperty(arg, "alias");
|
|
18674
|
+
if (aliasNode !== null)
|
|
18675
|
+
bindingPropertyName = aliasNode;
|
|
18676
|
+
required = getBooleanProperty(arg, "required") ?? false;
|
|
18677
|
+
}
|
|
18678
|
+
}
|
|
18679
|
+
return {
|
|
18680
|
+
classPropertyName,
|
|
18681
|
+
meta: {
|
|
18682
|
+
classPropertyName,
|
|
18683
|
+
bindingPropertyName,
|
|
18684
|
+
required,
|
|
18685
|
+
isSignal: false,
|
|
18686
|
+
transformFunction: null
|
|
18687
|
+
}
|
|
18688
|
+
};
|
|
18689
|
+
}
|
|
18690
|
+
return null;
|
|
18691
|
+
}, isInputSignalCall = (init) => {
|
|
18692
|
+
if (ts8.isCallExpression(init)) {
|
|
18693
|
+
const fn2 = init.expression;
|
|
18694
|
+
if (ts8.isIdentifier(fn2) && fn2.text === "input")
|
|
18695
|
+
return true;
|
|
18696
|
+
if (ts8.isPropertyAccessExpression(fn2) && ts8.isIdentifier(fn2.expression) && fn2.expression.text === "input") {
|
|
18697
|
+
return true;
|
|
18698
|
+
}
|
|
18699
|
+
}
|
|
18700
|
+
return false;
|
|
18701
|
+
}, extractSignalInput = (prop) => {
|
|
18702
|
+
if (!prop.initializer || !isInputSignalCall(prop.initializer))
|
|
18703
|
+
return null;
|
|
18704
|
+
const classPropertyName = prop.name.getText();
|
|
18705
|
+
const call = prop.initializer;
|
|
18706
|
+
let required = false;
|
|
18707
|
+
if (ts8.isPropertyAccessExpression(call.expression) && ts8.isIdentifier(call.expression.name) && call.expression.name.text === "required") {
|
|
18708
|
+
required = true;
|
|
18709
|
+
}
|
|
18710
|
+
let bindingPropertyName = classPropertyName;
|
|
18711
|
+
const optsArg = call.arguments[required ? 0 : 1];
|
|
18712
|
+
if (optsArg && ts8.isObjectLiteralExpression(optsArg)) {
|
|
18713
|
+
const aliasNode = getStringProperty(optsArg, "alias");
|
|
18714
|
+
if (aliasNode !== null)
|
|
18715
|
+
bindingPropertyName = aliasNode;
|
|
18716
|
+
}
|
|
18717
|
+
return {
|
|
18718
|
+
classPropertyName,
|
|
18719
|
+
meta: {
|
|
18720
|
+
classPropertyName,
|
|
18721
|
+
bindingPropertyName,
|
|
18722
|
+
required,
|
|
18723
|
+
isSignal: true,
|
|
18724
|
+
transformFunction: null
|
|
18725
|
+
}
|
|
18726
|
+
};
|
|
18727
|
+
}, extractDecoratorOutput = (prop) => {
|
|
18728
|
+
const decorators = ts8.getDecorators(prop) ?? [];
|
|
18729
|
+
for (const decorator of decorators) {
|
|
18730
|
+
const expr = decorator.expression;
|
|
18731
|
+
if (!ts8.isCallExpression(expr))
|
|
18732
|
+
continue;
|
|
18733
|
+
const fn2 = expr.expression;
|
|
18734
|
+
if (!ts8.isIdentifier(fn2) || fn2.text !== "Output")
|
|
18735
|
+
continue;
|
|
18736
|
+
const classPropertyName = prop.name.getText();
|
|
18737
|
+
let bindingName = classPropertyName;
|
|
18738
|
+
const arg = expr.arguments[0];
|
|
18739
|
+
if (arg && ts8.isStringLiteral(arg))
|
|
18740
|
+
bindingName = arg.text;
|
|
18741
|
+
return { classPropertyName, bindingName };
|
|
18742
|
+
}
|
|
18743
|
+
return null;
|
|
18744
|
+
}, isOutputSignalCall = (init) => {
|
|
18745
|
+
if (ts8.isCallExpression(init)) {
|
|
18746
|
+
const fn2 = init.expression;
|
|
18747
|
+
if (ts8.isIdentifier(fn2) && fn2.text === "output")
|
|
18748
|
+
return true;
|
|
18749
|
+
if (ts8.isPropertyAccessExpression(fn2) && ts8.isIdentifier(fn2.expression) && fn2.expression.text === "output") {
|
|
18750
|
+
return true;
|
|
18751
|
+
}
|
|
18752
|
+
}
|
|
18753
|
+
return false;
|
|
18754
|
+
}, extractSignalOutput = (prop) => {
|
|
18755
|
+
if (!prop.initializer || !isOutputSignalCall(prop.initializer))
|
|
18756
|
+
return null;
|
|
18757
|
+
const classPropertyName = prop.name.getText();
|
|
18758
|
+
const call = prop.initializer;
|
|
18759
|
+
let bindingName = classPropertyName;
|
|
18760
|
+
const optsArg = call.arguments[0];
|
|
18761
|
+
if (optsArg && ts8.isObjectLiteralExpression(optsArg)) {
|
|
18762
|
+
const aliasNode = getStringProperty(optsArg, "alias");
|
|
18763
|
+
if (aliasNode !== null)
|
|
18764
|
+
bindingName = aliasNode;
|
|
18765
|
+
}
|
|
18766
|
+
return { classPropertyName, bindingName };
|
|
18767
|
+
}, extractInputsAndOutputs = (cls) => {
|
|
18768
|
+
const inputs = {};
|
|
18769
|
+
const outputs = {};
|
|
18770
|
+
for (const member of cls.members) {
|
|
18771
|
+
if (!ts8.isPropertyDeclaration(member))
|
|
18772
|
+
continue;
|
|
18773
|
+
const decoratorIn = extractDecoratorInput(member);
|
|
18774
|
+
if (decoratorIn) {
|
|
18775
|
+
inputs[decoratorIn.classPropertyName] = decoratorIn.meta;
|
|
18776
|
+
continue;
|
|
18777
|
+
}
|
|
18778
|
+
const signalIn = extractSignalInput(member);
|
|
18779
|
+
if (signalIn) {
|
|
18780
|
+
inputs[signalIn.classPropertyName] = signalIn.meta;
|
|
18781
|
+
continue;
|
|
18782
|
+
}
|
|
18783
|
+
const decoratorOut = extractDecoratorOutput(member);
|
|
18784
|
+
if (decoratorOut) {
|
|
18785
|
+
outputs[decoratorOut.classPropertyName] = decoratorOut.bindingName;
|
|
18786
|
+
continue;
|
|
18787
|
+
}
|
|
18788
|
+
const signalOut = extractSignalOutput(member);
|
|
18789
|
+
if (signalOut) {
|
|
18790
|
+
outputs[signalOut.classPropertyName] = signalOut.bindingName;
|
|
18791
|
+
}
|
|
18792
|
+
}
|
|
18793
|
+
return { inputs, outputs };
|
|
18794
|
+
}, resolveAndReadResource = (componentDir, url) => {
|
|
18795
|
+
const abs = resolve33(componentDir, url);
|
|
18796
|
+
if (!existsSync26(abs))
|
|
18797
|
+
return null;
|
|
18798
|
+
return readFileSync21(abs, "utf8");
|
|
18799
|
+
}, collectStyles = (decoratorMeta, componentDir) => {
|
|
18800
|
+
const styles = [...decoratorMeta.styles];
|
|
18801
|
+
const urls = [];
|
|
18802
|
+
if (decoratorMeta.styleUrl)
|
|
18803
|
+
urls.push(decoratorMeta.styleUrl);
|
|
18804
|
+
urls.push(...decoratorMeta.styleUrls);
|
|
18805
|
+
for (const url of urls) {
|
|
18806
|
+
const css = resolveAndReadResource(componentDir, url);
|
|
18807
|
+
if (css === null)
|
|
18808
|
+
return { styles, missing: url };
|
|
18809
|
+
styles.push(css);
|
|
18810
|
+
}
|
|
18811
|
+
return { styles, missing: null };
|
|
18812
|
+
}, tryFastHmr = async (params) => {
|
|
18813
|
+
const { componentFilePath, className } = params;
|
|
18814
|
+
const projectRoot = params.projectRoot ?? process.cwd();
|
|
18815
|
+
if (!existsSync26(componentFilePath)) {
|
|
18816
|
+
return fail("file-not-found", componentFilePath);
|
|
18817
|
+
}
|
|
18818
|
+
let compiler;
|
|
18819
|
+
try {
|
|
18820
|
+
compiler = await import("@angular/compiler");
|
|
18821
|
+
} catch (err) {
|
|
18822
|
+
return fail("unexpected-error", `import @angular/compiler: ${err}`);
|
|
18823
|
+
}
|
|
18824
|
+
const tsSource = readFileSync21(componentFilePath, "utf8");
|
|
18825
|
+
const sourceFile = ts8.createSourceFile(componentFilePath, tsSource, ts8.ScriptTarget.ES2022, true, ts8.ScriptKind.TS);
|
|
18826
|
+
const classNode = findClassDeclaration(sourceFile, className);
|
|
18827
|
+
if (!classNode) {
|
|
18828
|
+
return fail("class-not-found", `${className} in ${componentFilePath}`);
|
|
18829
|
+
}
|
|
18830
|
+
if (inheritsDecoratedClass(classNode)) {
|
|
18831
|
+
return fail("inherits-decorated-class");
|
|
18832
|
+
}
|
|
18833
|
+
const decorator = findComponentDecorator(classNode);
|
|
18834
|
+
if (!decorator)
|
|
18835
|
+
return fail("no-component-decorator");
|
|
18836
|
+
const decoratorArgs = getDecoratorArgsObject(decorator);
|
|
18837
|
+
if (!decoratorArgs)
|
|
18838
|
+
return fail("unsupported-decorator-args");
|
|
18839
|
+
const decoratorMeta = readDecoratorMeta(decoratorArgs);
|
|
18840
|
+
if (!decoratorMeta.standalone)
|
|
18841
|
+
return fail("not-standalone");
|
|
18842
|
+
const componentDir = dirname19(componentFilePath);
|
|
18843
|
+
let templateText;
|
|
18844
|
+
let templatePath;
|
|
18845
|
+
if (decoratorMeta.template !== null) {
|
|
18846
|
+
templateText = decoratorMeta.template;
|
|
18847
|
+
templatePath = componentFilePath;
|
|
18848
|
+
} else if (decoratorMeta.templateUrl) {
|
|
18849
|
+
const tplAbs = resolve33(componentDir, decoratorMeta.templateUrl);
|
|
18850
|
+
if (!existsSync26(tplAbs)) {
|
|
18851
|
+
return fail("template-resource-not-found", tplAbs);
|
|
18852
|
+
}
|
|
18853
|
+
templateText = readFileSync21(tplAbs, "utf8");
|
|
18854
|
+
templatePath = tplAbs;
|
|
18855
|
+
} else {
|
|
18856
|
+
return fail("unsupported-decorator-args", "missing template/templateUrl");
|
|
18857
|
+
}
|
|
18858
|
+
const { styles, missing: missingStyle } = collectStyles(decoratorMeta, componentDir);
|
|
18859
|
+
if (missingStyle) {
|
|
18860
|
+
return fail("style-resource-not-found", missingStyle);
|
|
18861
|
+
}
|
|
18862
|
+
let parsed;
|
|
18863
|
+
try {
|
|
18864
|
+
parsed = compiler.parseTemplate(templateText, templatePath, {
|
|
18865
|
+
preserveWhitespaces: decoratorMeta.preserveWhitespaces
|
|
18866
|
+
});
|
|
18867
|
+
} catch (err) {
|
|
18868
|
+
return fail("template-parse-error", String(err));
|
|
18869
|
+
}
|
|
18870
|
+
if (parsed.errors && parsed.errors.length > 0) {
|
|
18871
|
+
return fail("template-parse-error", parsed.errors.map((e) => e.toString()).join(`
|
|
18872
|
+
`));
|
|
18873
|
+
}
|
|
18874
|
+
const className_ = classNode.name;
|
|
18875
|
+
if (!className_)
|
|
18876
|
+
return fail("class-not-found", "anonymous class");
|
|
18877
|
+
const wrappedClass = new compiler.WrappedNodeExpr(className_);
|
|
18878
|
+
const { inputs, outputs } = extractInputsAndOutputs(classNode);
|
|
18879
|
+
const projectRelPath = relative13(projectRoot, componentFilePath).replace(/\\/g, "/");
|
|
18880
|
+
const sourceFileObj = new compiler.ParseSourceFile(tsSource, componentFilePath);
|
|
18881
|
+
const zeroLoc = new compiler.ParseLocation(sourceFileObj, 0, 0, 0);
|
|
18882
|
+
const typeSourceSpan = new compiler.ParseSourceSpan(zeroLoc, zeroLoc);
|
|
18883
|
+
const importsArray = [];
|
|
18884
|
+
if (decoratorMeta.importsExpr) {
|
|
18885
|
+
for (const el of decoratorMeta.importsExpr.elements) {
|
|
18886
|
+
importsArray.push(new compiler.WrappedNodeExpr(el));
|
|
18887
|
+
}
|
|
18888
|
+
}
|
|
18889
|
+
const declarations = importsArray.map((expr) => ({
|
|
18890
|
+
kind: 0,
|
|
18891
|
+
type: expr,
|
|
18892
|
+
selector: "",
|
|
18893
|
+
inputs: [],
|
|
18894
|
+
outputs: [],
|
|
18895
|
+
exportAs: null,
|
|
18896
|
+
isComponent: false
|
|
18897
|
+
}));
|
|
18898
|
+
const meta = {
|
|
18899
|
+
name: className,
|
|
18900
|
+
type: { value: wrappedClass, type: wrappedClass },
|
|
18901
|
+
typeArgumentCount: 0,
|
|
18902
|
+
typeSourceSpan,
|
|
18903
|
+
deps: null,
|
|
18904
|
+
selector: decoratorMeta.selector,
|
|
18905
|
+
queries: [],
|
|
18906
|
+
viewQueries: [],
|
|
18907
|
+
host: {
|
|
18908
|
+
attributes: {},
|
|
18909
|
+
listeners: {},
|
|
18910
|
+
properties: {},
|
|
18911
|
+
specialAttributes: {}
|
|
18912
|
+
},
|
|
18913
|
+
lifecycle: { usesOnChanges: false },
|
|
18914
|
+
inputs,
|
|
18915
|
+
outputs,
|
|
18916
|
+
usesInheritance: false,
|
|
18917
|
+
controlCreate: null,
|
|
18918
|
+
exportAs: null,
|
|
18919
|
+
providers: null,
|
|
18920
|
+
isStandalone: true,
|
|
18921
|
+
isSignal: false,
|
|
18922
|
+
hostDirectives: null,
|
|
18923
|
+
template: {
|
|
18924
|
+
nodes: parsed.nodes,
|
|
18925
|
+
ngContentSelectors: parsed.ngContentSelectors ?? [],
|
|
18926
|
+
preserveWhitespaces: decoratorMeta.preserveWhitespaces
|
|
18927
|
+
},
|
|
18928
|
+
declarations,
|
|
18929
|
+
defer: { mode: 0, blocks: new Map },
|
|
18930
|
+
declarationListEmitMode: 0,
|
|
18931
|
+
styles,
|
|
18932
|
+
encapsulation: 0,
|
|
18933
|
+
animations: null,
|
|
18934
|
+
viewProviders: null,
|
|
18935
|
+
relativeContextFilePath: projectRelPath,
|
|
18936
|
+
i18nUseExternalIds: false,
|
|
18937
|
+
changeDetection: null,
|
|
18938
|
+
relativeTemplatePath: null,
|
|
18939
|
+
hasDirectiveDependencies: importsArray.length > 0
|
|
18940
|
+
};
|
|
18941
|
+
let compiled;
|
|
18942
|
+
try {
|
|
18943
|
+
const pool = new compiler.ConstantPool;
|
|
18944
|
+
const bindingParser = compiler.makeBindingParser();
|
|
18945
|
+
compiled = compiler.compileComponentFromMetadata(meta, pool, bindingParser);
|
|
18946
|
+
const namespaceDependencies = [
|
|
18947
|
+
{ moduleName: "@angular/core", assignedName: "\u0275hmr0" }
|
|
18948
|
+
];
|
|
18949
|
+
const callback = compiler.compileHmrUpdateCallback([
|
|
18950
|
+
{
|
|
18951
|
+
name: "\u0275cmp",
|
|
18952
|
+
initializer: compiled.expression,
|
|
18953
|
+
statements: compiled.statements ?? []
|
|
18954
|
+
}
|
|
18955
|
+
], pool.statements, {
|
|
18956
|
+
type: wrappedClass,
|
|
18957
|
+
className,
|
|
18958
|
+
filePath: projectRelPath,
|
|
18959
|
+
namespaceDependencies,
|
|
18960
|
+
localDependencies: []
|
|
18961
|
+
});
|
|
18962
|
+
const namespaceMap = new Map;
|
|
18963
|
+
for (const dep of namespaceDependencies) {
|
|
18964
|
+
namespaceMap.set(dep.moduleName, dep.assignedName);
|
|
18965
|
+
}
|
|
18966
|
+
const importGenerator = createHmrImportGenerator(namespaceMap);
|
|
18967
|
+
const tsFunctionDecl = translateStatement(sourceFile, callback, importGenerator);
|
|
18968
|
+
const exportedDecl = ts8.factory.updateFunctionDeclaration(tsFunctionDecl, [
|
|
18969
|
+
ts8.factory.createToken(ts8.SyntaxKind.ExportKeyword),
|
|
18970
|
+
ts8.factory.createToken(ts8.SyntaxKind.DefaultKeyword)
|
|
18971
|
+
], tsFunctionDecl.asteriskToken, tsFunctionDecl.name, tsFunctionDecl.typeParameters, tsFunctionDecl.parameters, tsFunctionDecl.type, tsFunctionDecl.body);
|
|
18972
|
+
const printer = ts8.createPrinter({
|
|
18973
|
+
newLine: ts8.NewLineKind.LineFeed,
|
|
18974
|
+
removeComments: false
|
|
18975
|
+
});
|
|
18976
|
+
const tsSourceText = printer.printNode(ts8.EmitHint.Unspecified, exportedDecl, sourceFile);
|
|
18977
|
+
const moduleText = ts8.transpileModule(tsSourceText, {
|
|
18978
|
+
compilerOptions: {
|
|
18979
|
+
module: ts8.ModuleKind.ES2022,
|
|
18980
|
+
target: ts8.ScriptTarget.ES2022
|
|
18981
|
+
},
|
|
18982
|
+
fileName: componentFilePath,
|
|
18983
|
+
reportDiagnostics: false
|
|
18984
|
+
}).outputText;
|
|
18985
|
+
return { ok: true, moduleText, componentSource: sourceFile };
|
|
18986
|
+
} catch (err) {
|
|
18987
|
+
return fail("unexpected-error", String(err));
|
|
18988
|
+
}
|
|
18989
|
+
};
|
|
18990
|
+
var init_fastHmrCompiler = __esm(() => {
|
|
18991
|
+
init_hmrImportGenerator();
|
|
18992
|
+
init_typescript_translator();
|
|
18993
|
+
});
|
|
18994
|
+
|
|
18995
|
+
// src/dev/angular/hmrCompiler.ts
|
|
18996
|
+
var exports_hmrCompiler = {};
|
|
18997
|
+
__export(exports_hmrCompiler, {
|
|
18998
|
+
getCachedHmrProgram: () => getCachedHmrProgram,
|
|
18999
|
+
getApplyMetadataModule: () => getApplyMetadataModule,
|
|
19000
|
+
findClassNodeById: () => findClassNodeById,
|
|
19001
|
+
encodeHmrComponentId: () => encodeHmrComponentId,
|
|
19002
|
+
compileAngularForHmr: () => compileAngularForHmr
|
|
19003
|
+
});
|
|
19004
|
+
import { existsSync as existsSync27 } from "fs";
|
|
19005
|
+
import { basename as basename13, dirname as dirname20, join as join30, relative as relative14, resolve as resolve34 } from "path";
|
|
19006
|
+
import { performance as performance2 } from "perf_hooks";
|
|
19007
|
+
import ts9 from "typescript";
|
|
19008
|
+
var globalCache, getCachedHmrProgram = () => globalCache.__ABSOLUTE_ANGULAR_HMR_PROGRAM__ ?? null, setCachedHmrProgram = (program) => {
|
|
19009
|
+
globalCache.__ABSOLUTE_ANGULAR_HMR_PROGRAM__ = program;
|
|
19010
|
+
}, resolveTypescriptLibDirCached = null, resolveTypescriptLibDir = () => {
|
|
19011
|
+
if (resolveTypescriptLibDirCached)
|
|
19012
|
+
return resolveTypescriptLibDirCached;
|
|
19013
|
+
const tsPath = __require.resolve("typescript");
|
|
19014
|
+
const tsRootDir = dirname20(tsPath);
|
|
19015
|
+
resolveTypescriptLibDirCached = tsRootDir.endsWith("lib") ? tsRootDir : resolve34(tsRootDir, "lib");
|
|
19016
|
+
return resolveTypescriptLibDirCached;
|
|
19017
|
+
}, buildHmrCompilerOptions = (base) => ({
|
|
19018
|
+
...base,
|
|
19019
|
+
emitDecoratorMetadata: true,
|
|
19020
|
+
esModuleInterop: true,
|
|
19021
|
+
experimentalDecorators: true,
|
|
19022
|
+
module: ts9.ModuleKind.ESNext,
|
|
19023
|
+
moduleResolution: ts9.ModuleResolutionKind.Bundler,
|
|
19024
|
+
newLine: ts9.NewLineKind.LineFeed,
|
|
19025
|
+
noEmit: false,
|
|
19026
|
+
noLib: false,
|
|
19027
|
+
rootDir: process.cwd(),
|
|
19028
|
+
skipLibCheck: true,
|
|
19029
|
+
target: ts9.ScriptTarget.ES2022,
|
|
19030
|
+
_enableHmr: true,
|
|
19031
|
+
enableHmr: true
|
|
19032
|
+
}), ANGULAR_COMPILER_OPTIONS_CACHE, loadAngularCompilerOptions = async () => {
|
|
19033
|
+
if (ANGULAR_COMPILER_OPTIONS_CACHE.value) {
|
|
19034
|
+
return ANGULAR_COMPILER_OPTIONS_CACHE.value;
|
|
19035
|
+
}
|
|
19036
|
+
const { readConfiguration } = await import("@angular/compiler-cli");
|
|
19037
|
+
const config = readConfiguration("./tsconfig.json");
|
|
19038
|
+
ANGULAR_COMPILER_OPTIONS_CACHE.value = config.options;
|
|
19039
|
+
return config.options;
|
|
19040
|
+
}, cachedTsconfigMtime = 0, refreshAngularCompilerOptionsIfStale = async () => {
|
|
19041
|
+
const tsconfigPath = resolve34(process.cwd(), "tsconfig.json");
|
|
19042
|
+
if (!existsSync27(tsconfigPath))
|
|
19043
|
+
return;
|
|
19044
|
+
const stat3 = await import("fs/promises").then((m) => m.stat(tsconfigPath));
|
|
19045
|
+
if (stat3.mtimeMs > cachedTsconfigMtime) {
|
|
19046
|
+
ANGULAR_COMPILER_OPTIONS_CACHE.value = null;
|
|
19047
|
+
cachedTsconfigMtime = stat3.mtimeMs;
|
|
19048
|
+
}
|
|
19049
|
+
}, compileAngularForHmr = async (inputPaths, outDir, modifiedResourceFiles = null) => {
|
|
19050
|
+
await refreshAngularCompilerOptionsIfStale();
|
|
19051
|
+
await import("@angular/compiler");
|
|
19052
|
+
const { performCompilation, EmitFlags } = await import("@angular/compiler-cli");
|
|
19053
|
+
const baseOptions = await loadAngularCompilerOptions();
|
|
19054
|
+
const options = buildHmrCompilerOptions(baseOptions);
|
|
19055
|
+
options.outDir = outDir;
|
|
19056
|
+
options.target = ts9.ScriptTarget.ES2022;
|
|
19057
|
+
options.experimentalDecorators = true;
|
|
19058
|
+
options.emitDecoratorMetadata = true;
|
|
19059
|
+
options.newLine = ts9.NewLineKind.LineFeed;
|
|
19060
|
+
options.incremental = false;
|
|
19061
|
+
options.tsBuildInfoFile = undefined;
|
|
19062
|
+
const tsLibDir = resolveTypescriptLibDir();
|
|
19063
|
+
const host = ts9.createCompilerHost(options);
|
|
19064
|
+
const originalGetDefaultLibLocation = host.getDefaultLibLocation;
|
|
19065
|
+
host.getDefaultLibLocation = () => tsLibDir || (originalGetDefaultLibLocation ? originalGetDefaultLibLocation() : "");
|
|
19066
|
+
const originalGetDefaultLibFileName = host.getDefaultLibFileName;
|
|
19067
|
+
host.getDefaultLibFileName = (opts) => {
|
|
19068
|
+
const fileName = originalGetDefaultLibFileName ? originalGetDefaultLibFileName(opts) : "lib.d.ts";
|
|
19069
|
+
return basename13(fileName);
|
|
19070
|
+
};
|
|
19071
|
+
const originalGetSourceFile = host.getSourceFile;
|
|
19072
|
+
host.getSourceFile = (fileName, languageVersion, onError) => {
|
|
19073
|
+
if (fileName.startsWith("lib.") && fileName.endsWith(".d.ts") && tsLibDir) {
|
|
19074
|
+
return originalGetSourceFile?.call(host, join30(tsLibDir, fileName), languageVersion, onError);
|
|
19075
|
+
}
|
|
19076
|
+
return originalGetSourceFile?.call(host, fileName, languageVersion, onError);
|
|
19077
|
+
};
|
|
19078
|
+
const emitted = {};
|
|
19079
|
+
const resolvedOutDir = resolve34(outDir);
|
|
19080
|
+
host.writeFile = (fileName, text) => {
|
|
19081
|
+
const normalized = fileName.replace(/\\/g, "/");
|
|
19082
|
+
const rel = normalized.startsWith(resolvedOutDir.replace(/\\/g, "/")) ? relative14(resolvedOutDir, normalized).replace(/\\/g, "/") : relative14(process.cwd(), normalized).replace(/\\/g, "/");
|
|
19083
|
+
emitted[rel] = text;
|
|
19084
|
+
};
|
|
19085
|
+
const oldProgram = getCachedHmrProgram();
|
|
19086
|
+
const performArgs = {
|
|
19087
|
+
emitFlags: EmitFlags.Default,
|
|
19088
|
+
forceEmit: true,
|
|
19089
|
+
host,
|
|
19090
|
+
options,
|
|
19091
|
+
rootNames: inputPaths
|
|
19092
|
+
};
|
|
19093
|
+
if (modifiedResourceFiles && modifiedResourceFiles.size > 0) {
|
|
19094
|
+
performArgs.modifiedResourceFiles = new Set(modifiedResourceFiles);
|
|
19095
|
+
}
|
|
19096
|
+
if (oldProgram) {
|
|
19097
|
+
performArgs.oldProgram = oldProgram;
|
|
19098
|
+
}
|
|
19099
|
+
const compileResult = performCompilation(performArgs);
|
|
19100
|
+
const program = compileResult.program;
|
|
19101
|
+
if (program)
|
|
19102
|
+
setCachedHmrProgram(program);
|
|
19103
|
+
return {
|
|
19104
|
+
program,
|
|
19105
|
+
emitted,
|
|
19106
|
+
diagnostics: compileResult.diagnostics ?? []
|
|
19107
|
+
};
|
|
19108
|
+
}, findClassNodeById = (program, encodedId) => {
|
|
19109
|
+
const decoded = decodeURIComponent(encodedId);
|
|
19110
|
+
const at2 = decoded.lastIndexOf("@");
|
|
19111
|
+
if (at2 === -1)
|
|
19112
|
+
return null;
|
|
19113
|
+
const filePath = decoded.slice(0, at2);
|
|
19114
|
+
const className = decoded.slice(at2 + 1);
|
|
19115
|
+
const tsProgram = program.compiler.getCurrentProgram();
|
|
19116
|
+
const absoluteCandidate = resolve34(process.cwd(), filePath).replace(/\\/g, "/");
|
|
19117
|
+
const matchesPath = (sourceFileName) => {
|
|
19118
|
+
const normalized = sourceFileName.replace(/\\/g, "/");
|
|
19119
|
+
if (normalized === absoluteCandidate)
|
|
19120
|
+
return true;
|
|
19121
|
+
if (normalized === filePath)
|
|
19122
|
+
return true;
|
|
19123
|
+
return normalized.endsWith("/" + filePath) || normalized.endsWith(filePath);
|
|
19124
|
+
};
|
|
19125
|
+
let sourceFile = tsProgram.getSourceFile(absoluteCandidate) ?? null;
|
|
19126
|
+
if (!sourceFile) {
|
|
19127
|
+
for (const candidate of tsProgram.getSourceFiles()) {
|
|
19128
|
+
if (matchesPath(candidate.fileName)) {
|
|
19129
|
+
sourceFile = candidate;
|
|
19130
|
+
break;
|
|
19131
|
+
}
|
|
19132
|
+
}
|
|
19133
|
+
}
|
|
19134
|
+
if (!sourceFile)
|
|
19135
|
+
return null;
|
|
19136
|
+
let found = null;
|
|
19137
|
+
const walk = (node) => {
|
|
19138
|
+
if (found)
|
|
19139
|
+
return;
|
|
19140
|
+
if (ts9.isClassDeclaration(node) && node.name?.text === className) {
|
|
19141
|
+
found = node;
|
|
19142
|
+
return;
|
|
19143
|
+
}
|
|
19144
|
+
ts9.forEachChild(node, walk);
|
|
19145
|
+
};
|
|
19146
|
+
walk(sourceFile);
|
|
19147
|
+
return found;
|
|
19148
|
+
}, getApplyMetadataModule = async (encodedId) => {
|
|
19149
|
+
const decoded = decodeURIComponent(encodedId);
|
|
19150
|
+
const at2 = decoded.lastIndexOf("@");
|
|
19151
|
+
if (at2 === -1)
|
|
19152
|
+
return null;
|
|
19153
|
+
const filePathRel = decoded.slice(0, at2);
|
|
19154
|
+
const className = decoded.slice(at2 + 1);
|
|
19155
|
+
const componentFilePath = resolve34(process.cwd(), filePathRel);
|
|
19156
|
+
const fastStart = performance2.now();
|
|
19157
|
+
const fast = await tryFastHmr({ componentFilePath, className });
|
|
19158
|
+
if (fast.ok) {
|
|
19159
|
+
logInfo(`[ng-hmr fast] ${className} ${(performance2.now() - fastStart).toFixed(1)}ms`);
|
|
19160
|
+
return fast.moduleText;
|
|
19161
|
+
}
|
|
19162
|
+
logWarn(`[ng-hmr slow] ${className} fast path bailed (${fast.reason}${fast.detail ? `: ${fast.detail}` : ""}), falling back to ngtsc`);
|
|
19163
|
+
const program = getCachedHmrProgram();
|
|
19164
|
+
if (!program)
|
|
19165
|
+
return null;
|
|
19166
|
+
const node = findClassNodeById(program, encodedId);
|
|
19167
|
+
if (!node)
|
|
19168
|
+
return null;
|
|
19169
|
+
return program.compiler.emitHmrUpdateModule(node);
|
|
19170
|
+
}, encodeHmrComponentId = (absoluteFilePath, className) => {
|
|
19171
|
+
const projectRel = relative14(process.cwd(), absoluteFilePath).replace(/\\/g, "/");
|
|
19172
|
+
return encodeURIComponent(`${projectRel}@${className}`);
|
|
19173
|
+
};
|
|
19174
|
+
var init_hmrCompiler = __esm(() => {
|
|
19175
|
+
init_logger();
|
|
19176
|
+
init_fastHmrCompiler();
|
|
19177
|
+
globalCache = globalThis;
|
|
19178
|
+
ANGULAR_COMPILER_OPTIONS_CACHE = {
|
|
19179
|
+
value: null
|
|
19180
|
+
};
|
|
19181
|
+
});
|
|
19182
|
+
|
|
17589
19183
|
// src/utils/ssrErrorPage.ts
|
|
17590
19184
|
var ssrErrorPage = (framework, error) => {
|
|
17591
19185
|
const frameworkColors2 = {
|
|
@@ -17717,11 +19311,11 @@ var exports_simpleHTMLHMR = {};
|
|
|
17717
19311
|
__export(exports_simpleHTMLHMR, {
|
|
17718
19312
|
handleHTMLUpdate: () => handleHTMLUpdate
|
|
17719
19313
|
});
|
|
17720
|
-
import { resolve as
|
|
19314
|
+
import { resolve as resolve35 } from "path";
|
|
17721
19315
|
var handleHTMLUpdate = async (htmlFilePath) => {
|
|
17722
19316
|
let htmlContent;
|
|
17723
19317
|
try {
|
|
17724
|
-
const resolvedPath =
|
|
19318
|
+
const resolvedPath = resolve35(htmlFilePath);
|
|
17725
19319
|
const file5 = Bun.file(resolvedPath);
|
|
17726
19320
|
if (!await file5.exists()) {
|
|
17727
19321
|
return null;
|
|
@@ -17747,11 +19341,11 @@ var exports_simpleHTMXHMR = {};
|
|
|
17747
19341
|
__export(exports_simpleHTMXHMR, {
|
|
17748
19342
|
handleHTMXUpdate: () => handleHTMXUpdate
|
|
17749
19343
|
});
|
|
17750
|
-
import { resolve as
|
|
19344
|
+
import { resolve as resolve36 } from "path";
|
|
17751
19345
|
var handleHTMXUpdate = async (htmxFilePath) => {
|
|
17752
19346
|
let htmlContent;
|
|
17753
19347
|
try {
|
|
17754
|
-
const resolvedPath =
|
|
19348
|
+
const resolvedPath = resolve36(htmxFilePath);
|
|
17755
19349
|
const file5 = Bun.file(resolvedPath);
|
|
17756
19350
|
if (!await file5.exists()) {
|
|
17757
19351
|
return null;
|
|
@@ -17773,8 +19367,8 @@ var handleHTMXUpdate = async (htmxFilePath) => {
|
|
|
17773
19367
|
var init_simpleHTMXHMR = () => {};
|
|
17774
19368
|
|
|
17775
19369
|
// src/dev/rebuildTrigger.ts
|
|
17776
|
-
import { existsSync as
|
|
17777
|
-
import { basename as
|
|
19370
|
+
import { existsSync as existsSync28 } from "fs";
|
|
19371
|
+
import { basename as basename14, dirname as dirname21, relative as relative15, resolve as resolve37 } from "path";
|
|
17778
19372
|
var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequentially = (items, action) => items.reduce((chain, item) => chain.then(() => action(item)), Promise.resolve()), getStyleTransformConfig = (config) => createStyleTransformConfig(config.stylePreprocessors, config.postcss), recompileTailwindForFastPath = async (state, config, files) => {
|
|
17779
19373
|
if (!config.tailwind)
|
|
17780
19374
|
return;
|
|
@@ -17862,11 +19456,11 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
17862
19456
|
detectedFw = detected !== "ignored" ? detected : affectedFrameworks[0];
|
|
17863
19457
|
}
|
|
17864
19458
|
return { ...parsed, framework: detectedFw };
|
|
17865
|
-
}, isValidDeletedAffectedFile = (affectedFile, deletedPathResolved, processedFiles) => affectedFile !== deletedPathResolved && !processedFiles.has(affectedFile) &&
|
|
19459
|
+
}, isValidDeletedAffectedFile = (affectedFile, deletedPathResolved, processedFiles) => affectedFile !== deletedPathResolved && !processedFiles.has(affectedFile) && existsSync28(affectedFile), collectDeletedFileAffected = (state, filePathInSet, processedFiles, validFiles) => {
|
|
17866
19460
|
state.fileHashes.delete(filePathInSet);
|
|
17867
19461
|
try {
|
|
17868
19462
|
const affectedFiles = getAffectedFiles(state.dependencyGraph, filePathInSet);
|
|
17869
|
-
const deletedPathResolved =
|
|
19463
|
+
const deletedPathResolved = resolve37(filePathInSet);
|
|
17870
19464
|
affectedFiles.forEach((affectedFile) => {
|
|
17871
19465
|
if (isValidDeletedAffectedFile(affectedFile, deletedPathResolved, processedFiles)) {
|
|
17872
19466
|
validFiles.push(affectedFile);
|
|
@@ -17880,7 +19474,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
17880
19474
|
if (!dependents || dependents.size === 0) {
|
|
17881
19475
|
return;
|
|
17882
19476
|
}
|
|
17883
|
-
const dependentFiles = Array.from(dependents).filter((file5) =>
|
|
19477
|
+
const dependentFiles = Array.from(dependents).filter((file5) => existsSync28(file5));
|
|
17884
19478
|
if (dependentFiles.length === 0) {
|
|
17885
19479
|
return;
|
|
17886
19480
|
}
|
|
@@ -17896,7 +19490,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
17896
19490
|
try {
|
|
17897
19491
|
const affectedFiles = getAffectedFiles(state.dependencyGraph, normalizedFilePath);
|
|
17898
19492
|
affectedFiles.forEach((affectedFile) => {
|
|
17899
|
-
if (!processedFiles.has(affectedFile) && affectedFile !== normalizedFilePath &&
|
|
19493
|
+
if (!processedFiles.has(affectedFile) && affectedFile !== normalizedFilePath && existsSync28(affectedFile)) {
|
|
17900
19494
|
validFiles.push(affectedFile);
|
|
17901
19495
|
processedFiles.add(affectedFile);
|
|
17902
19496
|
}
|
|
@@ -17910,7 +19504,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
17910
19504
|
if (storedHash !== undefined && storedHash === fileHash) {
|
|
17911
19505
|
return;
|
|
17912
19506
|
}
|
|
17913
|
-
const normalizedFilePath =
|
|
19507
|
+
const normalizedFilePath = resolve37(filePathInSet);
|
|
17914
19508
|
if (!processedFiles.has(normalizedFilePath)) {
|
|
17915
19509
|
validFiles.push(normalizedFilePath);
|
|
17916
19510
|
processedFiles.add(normalizedFilePath);
|
|
@@ -17921,7 +19515,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
17921
19515
|
collectChangedFileAffected(state, normalizedFilePath, processedFiles, validFiles);
|
|
17922
19516
|
}, processFilePathSet = (state, filePathSet, processedFiles, validFiles) => {
|
|
17923
19517
|
filePathSet.forEach((filePathInSet) => {
|
|
17924
|
-
if (!
|
|
19518
|
+
if (!existsSync28(filePathInSet)) {
|
|
17925
19519
|
collectDeletedFileAffected(state, filePathInSet, processedFiles, validFiles);
|
|
17926
19520
|
return;
|
|
17927
19521
|
}
|
|
@@ -18014,8 +19608,8 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18014
19608
|
return;
|
|
18015
19609
|
}
|
|
18016
19610
|
if (framework === "unknown") {
|
|
18017
|
-
invalidate(
|
|
18018
|
-
const relPath =
|
|
19611
|
+
invalidate(resolve37(filePath));
|
|
19612
|
+
const relPath = relative15(process.cwd(), filePath);
|
|
18019
19613
|
logHmrUpdate(relPath);
|
|
18020
19614
|
return;
|
|
18021
19615
|
}
|
|
@@ -18041,7 +19635,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18041
19635
|
const userEditedFiles = new Set;
|
|
18042
19636
|
state.fileChangeQueue.forEach((filePaths) => {
|
|
18043
19637
|
for (const filePath2 of filePaths) {
|
|
18044
|
-
userEditedFiles.add(
|
|
19638
|
+
userEditedFiles.add(resolve37(filePath2));
|
|
18045
19639
|
}
|
|
18046
19640
|
});
|
|
18047
19641
|
state.lastUserEditedFiles = userEditedFiles;
|
|
@@ -18065,12 +19659,12 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18065
19659
|
return componentFile;
|
|
18066
19660
|
}
|
|
18067
19661
|
const tsCounterpart = componentFile.replace(/\.html$/, ".ts");
|
|
18068
|
-
if (
|
|
19662
|
+
if (existsSync28(tsCounterpart)) {
|
|
18069
19663
|
return tsCounterpart;
|
|
18070
19664
|
}
|
|
18071
19665
|
if (!graph)
|
|
18072
19666
|
return componentFile;
|
|
18073
|
-
const dependents = graph.dependents.get(
|
|
19667
|
+
const dependents = graph.dependents.get(resolve37(componentFile));
|
|
18074
19668
|
if (!dependents)
|
|
18075
19669
|
return componentFile;
|
|
18076
19670
|
for (const dep of dependents) {
|
|
@@ -18079,7 +19673,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18079
19673
|
}
|
|
18080
19674
|
return componentFile;
|
|
18081
19675
|
}, resolveAngularPageEntries = (state, angularFiles, angularPagesPath) => {
|
|
18082
|
-
const pageEntries = angularFiles.filter((file5) => file5.endsWith(".ts") &&
|
|
19676
|
+
const pageEntries = angularFiles.filter((file5) => file5.endsWith(".ts") && resolve37(file5).startsWith(angularPagesPath));
|
|
18083
19677
|
if (pageEntries.length > 0 || !state.dependencyGraph) {
|
|
18084
19678
|
return pageEntries;
|
|
18085
19679
|
}
|
|
@@ -18088,7 +19682,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18088
19682
|
const lookupFile = resolveComponentLookupFile(componentFile, state.dependencyGraph);
|
|
18089
19683
|
const affected = getAffectedFiles(state.dependencyGraph, lookupFile);
|
|
18090
19684
|
affected.forEach((file5) => {
|
|
18091
|
-
if (file5.endsWith(".ts") &&
|
|
19685
|
+
if (file5.endsWith(".ts") && resolve37(file5).startsWith(angularPagesPath)) {
|
|
18092
19686
|
resolvedPages.add(file5);
|
|
18093
19687
|
}
|
|
18094
19688
|
});
|
|
@@ -18107,18 +19701,21 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18107
19701
|
const { commonAncestor: commonAncestor2 } = await Promise.resolve().then(() => (init_commonAncestor(), exports_commonAncestor));
|
|
18108
19702
|
return clientRoots.length === 1 ? clientRoots[0] ?? projectRoot : commonAncestor2(clientRoots, projectRoot);
|
|
18109
19703
|
}, updateServerManifestEntry = (state, artifact) => {
|
|
18110
|
-
const fileWithHash =
|
|
19704
|
+
const fileWithHash = basename14(artifact.path);
|
|
18111
19705
|
const [baseName] = fileWithHash.split(`.${artifact.hash}.`);
|
|
18112
19706
|
if (!baseName) {
|
|
18113
19707
|
return;
|
|
18114
19708
|
}
|
|
18115
19709
|
state.manifest[toPascal(baseName)] = artifact.path;
|
|
18116
|
-
}, bundleAngularClient = async (state, clientPaths, buildDir) => {
|
|
19710
|
+
}, bundleAngularClient = async (state, clientPaths, buildDir, userAngularRoot) => {
|
|
18117
19711
|
const { build: bunBuild9 } = await Promise.resolve(globalThis.Bun);
|
|
18118
19712
|
const { generateManifest: generateManifest2 } = await Promise.resolve().then(() => (init_generateManifest(), exports_generateManifest));
|
|
18119
19713
|
const { getAngularVendorPaths: getAngularVendorPaths2 } = await Promise.resolve().then(() => exports_devVendorPaths);
|
|
19714
|
+
const { getFrameworkGeneratedDir: getFrameworkGeneratedDir2 } = await Promise.resolve().then(() => (init_generatedDir(), exports_generatedDir));
|
|
19715
|
+
const { createAngularHmrInjectionPlugin: createAngularHmrInjectionPlugin2 } = await Promise.resolve().then(() => (init_hmrInjectionPlugin(), exports_hmrInjectionPlugin));
|
|
18120
19716
|
const clientRoot = await computeClientRoot(state.resolvedPaths);
|
|
18121
19717
|
const depVendorPaths = globalThis.__depVendorPaths ?? {};
|
|
19718
|
+
const generatedAngularRoot = getFrameworkGeneratedDir2("angular");
|
|
18122
19719
|
let angVendorPaths = getAngularVendorPaths2();
|
|
18123
19720
|
if (!angVendorPaths) {
|
|
18124
19721
|
const { computeAngularVendorPaths: computeAngularVendorPaths2 } = await Promise.resolve().then(() => (init_buildAngularVendor(), exports_buildAngularVendor));
|
|
@@ -18141,7 +19738,12 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18141
19738
|
naming: "[dir]/[name].[hash].[ext]",
|
|
18142
19739
|
outdir: buildDir,
|
|
18143
19740
|
plugins: [
|
|
18144
|
-
createStylePreprocessorPlugin(getStyleTransformConfig(state.config))
|
|
19741
|
+
createStylePreprocessorPlugin(getStyleTransformConfig(state.config)),
|
|
19742
|
+
createAngularHmrInjectionPlugin2({
|
|
19743
|
+
generatedAngularRoot,
|
|
19744
|
+
userAngularRoot,
|
|
19745
|
+
projectRoot: process.cwd()
|
|
19746
|
+
})
|
|
18145
19747
|
],
|
|
18146
19748
|
root: clientRoot,
|
|
18147
19749
|
target: "browser",
|
|
@@ -18163,11 +19765,36 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18163
19765
|
}, filterToUserEdits = (candidates, userEditedFiles) => {
|
|
18164
19766
|
if (!userEditedFiles || userEditedFiles.size === 0)
|
|
18165
19767
|
return candidates;
|
|
18166
|
-
const filtered = candidates.filter((file5) => userEditedFiles.has(
|
|
19768
|
+
const filtered = candidates.filter((file5) => userEditedFiles.has(resolve37(file5)));
|
|
18167
19769
|
return filtered.length > 0 ? filtered : candidates;
|
|
19770
|
+
}, broadcastAngularComponentUpdates = async (state, angularDir) => {
|
|
19771
|
+
const userEdited = state.lastUserEditedFiles ?? new Set;
|
|
19772
|
+
if (userEdited.size === 0)
|
|
19773
|
+
return;
|
|
19774
|
+
const { resolveOwningComponents: resolveOwningComponents2 } = await Promise.resolve().then(() => (init_resolveOwningComponents(), exports_resolveOwningComponents));
|
|
19775
|
+
const { encodeHmrComponentId: encodeHmrComponentId2 } = await Promise.resolve().then(() => (init_hmrCompiler(), exports_hmrCompiler));
|
|
19776
|
+
const broadcastedIds = new Set;
|
|
19777
|
+
const broadcastTimestamp = Date.now();
|
|
19778
|
+
for (const editedFile of userEdited) {
|
|
19779
|
+
const owners = resolveOwningComponents2({
|
|
19780
|
+
changedFilePath: editedFile,
|
|
19781
|
+
userAngularRoot: angularDir
|
|
19782
|
+
});
|
|
19783
|
+
for (const { componentFilePath, className } of owners) {
|
|
19784
|
+
const id = encodeHmrComponentId2(componentFilePath, className);
|
|
19785
|
+
if (broadcastedIds.has(id))
|
|
19786
|
+
continue;
|
|
19787
|
+
broadcastedIds.add(id);
|
|
19788
|
+
broadcastToClients(state, {
|
|
19789
|
+
data: { id, timestamp: broadcastTimestamp },
|
|
19790
|
+
type: "angular:component-update"
|
|
19791
|
+
});
|
|
19792
|
+
logInfo(`[ng-hmr broadcast] ${className}`);
|
|
19793
|
+
}
|
|
19794
|
+
}
|
|
18168
19795
|
}, broadcastAngularPageUpdates = (state, pagesToUpdate, manifest, startTime, classification) => {
|
|
18169
19796
|
pagesToUpdate.forEach((angularPagePath) => {
|
|
18170
|
-
const fileName =
|
|
19797
|
+
const fileName = basename14(angularPagePath);
|
|
18171
19798
|
const baseName = fileName.replace(/\.[tj]s$/, "");
|
|
18172
19799
|
const pascalName = toPascal(baseName);
|
|
18173
19800
|
const cssKey = `${pascalName}CSS`;
|
|
@@ -18191,6 +19818,12 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18191
19818
|
}, compileAndBundleAngular = async (state, pageEntries, angularDir) => {
|
|
18192
19819
|
const { compileAngular: compileAngular2 } = await Promise.resolve().then(() => (init_compileAngular(), exports_compileAngular));
|
|
18193
19820
|
const { clientPaths, serverPaths } = await compileAngular2(pageEntries, angularDir, true, getStyleTransformConfig(state.config));
|
|
19821
|
+
try {
|
|
19822
|
+
const { compileAngularForHmr: compileAngularForHmr2 } = await Promise.resolve().then(() => (init_hmrCompiler(), exports_hmrCompiler));
|
|
19823
|
+
await compileAngularForHmr2(pageEntries, state.resolvedPaths.buildDir, state.lastUserEditedFiles ?? null);
|
|
19824
|
+
} catch (err) {
|
|
19825
|
+
logWarn(`[hmr] surgical-HMR shadow compile skipped: ${err instanceof Error ? err.message : String(err)}`);
|
|
19826
|
+
}
|
|
18194
19827
|
const { getAngularServerVendorPaths: getAngularServerVendorPaths2 } = await Promise.resolve().then(() => exports_devVendorPaths);
|
|
18195
19828
|
const angServerVendorPaths = getAngularServerVendorPaths2();
|
|
18196
19829
|
const ssrPaths = angServerVendorPaths ? serverPaths.map((serverPath) => serverPath.replace(/\.js$/, ".ssr.js")) : serverPaths;
|
|
@@ -18206,20 +19839,20 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18206
19839
|
await rewriteImports3(ssrPaths, angServerVendorPaths);
|
|
18207
19840
|
}
|
|
18208
19841
|
serverPaths.forEach((serverPath, idx) => {
|
|
18209
|
-
const fileBase =
|
|
19842
|
+
const fileBase = basename14(serverPath, ".js");
|
|
18210
19843
|
const ssrPath = ssrPaths[idx] ?? serverPath;
|
|
18211
|
-
state.manifest[toPascal(fileBase)] =
|
|
19844
|
+
state.manifest[toPascal(fileBase)] = resolve37(ssrPath);
|
|
18212
19845
|
});
|
|
18213
19846
|
if (clientPaths.length > 0) {
|
|
18214
|
-
await bundleAngularClient(state, clientPaths, state.resolvedPaths.buildDir);
|
|
19847
|
+
await bundleAngularClient(state, clientPaths, state.resolvedPaths.buildDir, angularDir);
|
|
18215
19848
|
}
|
|
18216
19849
|
}, handleAngularFastPath = async (state, config, filesToRebuild, startTime, onRebuildComplete) => {
|
|
18217
19850
|
const angularDir = config.angularDirectory ?? "";
|
|
18218
19851
|
const angularFiles = filesToRebuild.filter((file5) => detectFramework(file5, state.resolvedPaths) === "angular");
|
|
18219
19852
|
for (const file5 of angularFiles) {
|
|
18220
|
-
state.fileHashes.set(
|
|
19853
|
+
state.fileHashes.set(resolve37(file5), computeFileHash(file5));
|
|
18221
19854
|
}
|
|
18222
|
-
const angularPagesPath =
|
|
19855
|
+
const angularPagesPath = resolve37(angularDir, "pages");
|
|
18223
19856
|
const pageEntries = resolveAngularPageEntries(state, angularFiles, angularPagesPath);
|
|
18224
19857
|
if (pageEntries.length > 0) {
|
|
18225
19858
|
await compileAndBundleAngular(state, pageEntries, angularDir);
|
|
@@ -18232,12 +19865,13 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18232
19865
|
const filesToClassify = filterToUserEdits(angularFiles, state.lastUserEditedFiles);
|
|
18233
19866
|
const classification = collapseClassifications(filesToClassify.map(classifyAngularEdit));
|
|
18234
19867
|
broadcastAngularPageUpdates(state, pagesToUpdate, manifest, startTime, classification);
|
|
19868
|
+
await broadcastAngularComponentUpdates(state, angularDir);
|
|
18235
19869
|
onRebuildComplete({ hmrState: state, manifest });
|
|
18236
19870
|
return manifest;
|
|
18237
19871
|
}, getModuleUrl = async (pageFile) => {
|
|
18238
19872
|
const { invalidateModule: invalidateModule2, warmCache: warmCache2, SRC_URL_PREFIX: SRC_URL_PREFIX2 } = await Promise.resolve().then(() => (init_moduleServer(), exports_moduleServer));
|
|
18239
19873
|
invalidateModule2(pageFile);
|
|
18240
|
-
const rel =
|
|
19874
|
+
const rel = relative15(process.cwd(), pageFile).replace(/\\/g, "/");
|
|
18241
19875
|
const url = `${SRC_URL_PREFIX2}${rel}`;
|
|
18242
19876
|
warmCache2(url);
|
|
18243
19877
|
return url;
|
|
@@ -18246,11 +19880,11 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18246
19880
|
if (isComponentFile2)
|
|
18247
19881
|
return primaryFile;
|
|
18248
19882
|
const { findNearestComponent: findNearestComponent2 } = await Promise.resolve().then(() => (init_transformCache(), exports_transformCache));
|
|
18249
|
-
const nearest = findNearestComponent2(
|
|
19883
|
+
const nearest = findNearestComponent2(resolve37(primaryFile));
|
|
18250
19884
|
return nearest ?? primaryFile;
|
|
18251
19885
|
}, handleReactModuleServerPath = async (state, reactFiles, startTime, onRebuildComplete) => {
|
|
18252
19886
|
for (const file5 of reactFiles) {
|
|
18253
|
-
state.fileHashes.set(
|
|
19887
|
+
state.fileHashes.set(resolve37(file5), computeFileHash(file5));
|
|
18254
19888
|
}
|
|
18255
19889
|
markSsrCacheDirty("react");
|
|
18256
19890
|
const primaryFile = reactFiles.find((file5) => !file5.replace(/\\/g, "/").includes("/pages/")) ?? reactFiles[0];
|
|
@@ -18269,7 +19903,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18269
19903
|
const pageModuleUrl = await getReactModuleUrl(broadcastTarget);
|
|
18270
19904
|
if (pageModuleUrl) {
|
|
18271
19905
|
const serverDuration = Date.now() - startTime;
|
|
18272
|
-
state.lastHmrPath =
|
|
19906
|
+
state.lastHmrPath = relative15(process.cwd(), primaryFile).replace(/\\/g, "/");
|
|
18273
19907
|
state.lastHmrFramework = "react";
|
|
18274
19908
|
broadcastToClients(state, {
|
|
18275
19909
|
data: {
|
|
@@ -18332,7 +19966,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18332
19966
|
});
|
|
18333
19967
|
}, handleSvelteModuleServerPath = async (state, svelteFiles, startTime, onRebuildComplete) => {
|
|
18334
19968
|
for (const file5 of svelteFiles) {
|
|
18335
|
-
state.fileHashes.set(
|
|
19969
|
+
state.fileHashes.set(resolve37(file5), computeFileHash(file5));
|
|
18336
19970
|
}
|
|
18337
19971
|
markSsrCacheDirty("svelte");
|
|
18338
19972
|
const serverDuration = Date.now() - startTime;
|
|
@@ -18357,8 +19991,8 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18357
19991
|
const serverEntries = [...svelteServerPaths];
|
|
18358
19992
|
const clientEntries = [...svelteIndexPaths, ...svelteClientPaths];
|
|
18359
19993
|
const { getFrameworkGeneratedDir: getFrameworkGeneratedDir2 } = await Promise.resolve().then(() => (init_generatedDir(), exports_generatedDir));
|
|
18360
|
-
const serverRoot =
|
|
18361
|
-
const serverOutDir =
|
|
19994
|
+
const serverRoot = resolve37(getFrameworkGeneratedDir2("svelte"), "server");
|
|
19995
|
+
const serverOutDir = resolve37(buildDir, basename14(svelteDir));
|
|
18362
19996
|
const [serverResult, clientResult] = await Promise.all([
|
|
18363
19997
|
serverEntries.length > 0 ? bunBuild9({
|
|
18364
19998
|
entrypoints: serverEntries,
|
|
@@ -18400,7 +20034,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18400
20034
|
const duration = Date.now() - startTime;
|
|
18401
20035
|
const broadcastFiles = svelteFiles.length > 0 ? svelteFiles : filesToRebuild;
|
|
18402
20036
|
broadcastFiles.forEach((sveltePagePath) => {
|
|
18403
|
-
const fileName =
|
|
20037
|
+
const fileName = basename14(sveltePagePath);
|
|
18404
20038
|
const baseName = fileName.replace(/\.svelte$/, "");
|
|
18405
20039
|
const pascalName = toPascal(baseName);
|
|
18406
20040
|
const cssKey = `${pascalName}CSS`;
|
|
@@ -18455,7 +20089,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18455
20089
|
});
|
|
18456
20090
|
}, handleVueModuleServerPath = async (state, vueFiles, nonVueFiles, startTime, onRebuildComplete) => {
|
|
18457
20091
|
for (const file5 of [...vueFiles, ...nonVueFiles]) {
|
|
18458
|
-
state.fileHashes.set(
|
|
20092
|
+
state.fileHashes.set(resolve37(file5), computeFileHash(file5));
|
|
18459
20093
|
}
|
|
18460
20094
|
markSsrCacheDirty("vue");
|
|
18461
20095
|
await invalidateNonVueModules(nonVueFiles);
|
|
@@ -18483,7 +20117,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18483
20117
|
recursive: true,
|
|
18484
20118
|
withFileTypes: true
|
|
18485
20119
|
});
|
|
18486
|
-
return entries.filter((entry) => entry.isFile() && EMBER_PAGE_EXTENSIONS.some((ext) => entry.name.endsWith(ext))).map((entry) =>
|
|
20120
|
+
return entries.filter((entry) => entry.isFile() && EMBER_PAGE_EXTENSIONS.some((ext) => entry.name.endsWith(ext))).map((entry) => resolve37(emberPagesPath, entry.name));
|
|
18487
20121
|
} catch {
|
|
18488
20122
|
return [];
|
|
18489
20123
|
}
|
|
@@ -18495,10 +20129,10 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18495
20129
|
return state.manifest;
|
|
18496
20130
|
}
|
|
18497
20131
|
for (const file5 of emberFiles) {
|
|
18498
|
-
state.fileHashes.set(
|
|
20132
|
+
state.fileHashes.set(resolve37(file5), computeFileHash(file5));
|
|
18499
20133
|
}
|
|
18500
|
-
const emberPagesPath =
|
|
18501
|
-
const directPageEntries = emberFiles.filter((file5) =>
|
|
20134
|
+
const emberPagesPath = resolve37(emberDir, "pages");
|
|
20135
|
+
const directPageEntries = emberFiles.filter((file5) => resolve37(file5).startsWith(emberPagesPath));
|
|
18502
20136
|
const allPageEntries = directPageEntries.length > 0 ? directPageEntries : await collectAllEmberPages(emberPagesPath);
|
|
18503
20137
|
if (allPageEntries.length === 0) {
|
|
18504
20138
|
onRebuildComplete({ hmrState: state, manifest: state.manifest });
|
|
@@ -18507,15 +20141,15 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18507
20141
|
const { compileEmber: compileEmber2 } = await Promise.resolve().then(() => (init_compileEmber(), exports_compileEmber));
|
|
18508
20142
|
const { serverPaths } = await compileEmber2(allPageEntries, emberDir, process.cwd(), true);
|
|
18509
20143
|
for (const serverPath of serverPaths) {
|
|
18510
|
-
const fileBase =
|
|
18511
|
-
state.manifest[toPascal(fileBase)] =
|
|
20144
|
+
const fileBase = basename14(serverPath, ".js");
|
|
20145
|
+
state.manifest[toPascal(fileBase)] = resolve37(serverPath);
|
|
18512
20146
|
}
|
|
18513
20147
|
const { invalidateEmberSsrCache: invalidateEmberSsrCache2 } = await Promise.resolve().then(() => (init_ember(), exports_ember));
|
|
18514
20148
|
invalidateEmberSsrCache2();
|
|
18515
20149
|
const duration = Date.now() - startTime;
|
|
18516
20150
|
const [primary] = emberFiles;
|
|
18517
20151
|
if (primary) {
|
|
18518
|
-
state.lastHmrPath =
|
|
20152
|
+
state.lastHmrPath = relative15(process.cwd(), primary).replace(/\\/g, "/");
|
|
18519
20153
|
state.lastHmrFramework = "ember";
|
|
18520
20154
|
logHmrUpdate(primary, "ember", duration);
|
|
18521
20155
|
}
|
|
@@ -18578,7 +20212,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18578
20212
|
});
|
|
18579
20213
|
}
|
|
18580
20214
|
}, handleScriptUpdate = (state, scriptFile, manifest, framework, duration) => {
|
|
18581
|
-
const scriptBaseName =
|
|
20215
|
+
const scriptBaseName = basename14(scriptFile).replace(/\.(ts|js|tsx|jsx)$/, "");
|
|
18582
20216
|
const pascalName = toPascal(scriptBaseName);
|
|
18583
20217
|
const scriptPath = manifest[pascalName] || null;
|
|
18584
20218
|
if (!scriptPath) {
|
|
@@ -18600,8 +20234,8 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18600
20234
|
if (!buildReference?.source) {
|
|
18601
20235
|
return;
|
|
18602
20236
|
}
|
|
18603
|
-
const sourcePath = buildReference.source.startsWith("file://") ? new URL(buildReference.source).pathname :
|
|
18604
|
-
islandFiles.add(
|
|
20237
|
+
const sourcePath = buildReference.source.startsWith("file://") ? new URL(buildReference.source).pathname : resolve37(dirname21(buildInfo.resolvedRegistryPath), buildReference.source);
|
|
20238
|
+
islandFiles.add(resolve37(sourcePath));
|
|
18605
20239
|
}, resolveIslandSourceFiles = async (config) => {
|
|
18606
20240
|
const registryPath = config.islands?.registry;
|
|
18607
20241
|
if (!registryPath) {
|
|
@@ -18609,7 +20243,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18609
20243
|
}
|
|
18610
20244
|
const buildInfo = await loadIslandRegistryBuildInfo(registryPath);
|
|
18611
20245
|
const islandFiles = new Set([
|
|
18612
|
-
|
|
20246
|
+
resolve37(buildInfo.resolvedRegistryPath)
|
|
18613
20247
|
]);
|
|
18614
20248
|
for (const definition of buildInfo.definitions) {
|
|
18615
20249
|
resolveIslandDefinitionSource(definition, buildInfo, islandFiles);
|
|
@@ -18620,7 +20254,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18620
20254
|
if (islandFiles.size === 0) {
|
|
18621
20255
|
return false;
|
|
18622
20256
|
}
|
|
18623
|
-
return filesToRebuild.some((file5) => islandFiles.has(
|
|
20257
|
+
return filesToRebuild.some((file5) => islandFiles.has(resolve37(file5)));
|
|
18624
20258
|
}, handleIslandSourceReload = async (state, config, filesToRebuild, manifest) => {
|
|
18625
20259
|
const shouldReload = await didStaticPagesNeedIslandRefresh(config, filesToRebuild);
|
|
18626
20260
|
if (!shouldReload) {
|
|
@@ -18655,10 +20289,10 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18655
20289
|
}, computeOutputPagesDir = (state, config, framework) => {
|
|
18656
20290
|
const isSingle = !config.reactDirectory && !config.svelteDirectory && !config.vueDirectory && (framework === "html" ? !config.htmxDirectory : !config.htmlDirectory);
|
|
18657
20291
|
if (isSingle) {
|
|
18658
|
-
return
|
|
20292
|
+
return resolve37(state.resolvedPaths.buildDir, "pages");
|
|
18659
20293
|
}
|
|
18660
|
-
const dirName = framework === "html" ?
|
|
18661
|
-
return
|
|
20294
|
+
const dirName = framework === "html" ? basename14(config.htmlDirectory ?? "html") : basename14(config.htmxDirectory ?? "htmx");
|
|
20295
|
+
return resolve37(state.resolvedPaths.buildDir, dirName, "pages");
|
|
18662
20296
|
}, processHtmlPageUpdate = async (state, pageFile, builtHtmlPagePath, manifest, duration) => {
|
|
18663
20297
|
try {
|
|
18664
20298
|
const { handleHTMLUpdate: handleHTMLUpdate2 } = await Promise.resolve().then(() => (init_simpleHTMLHMR(), exports_simpleHTMLHMR));
|
|
@@ -18696,8 +20330,8 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18696
20330
|
const shouldRefreshAllPages = htmlPageFiles.length === 0 && shouldRefreshFromIslandChange;
|
|
18697
20331
|
const pageFilesToUpdate = shouldRefreshAllPages ? await scanEntryPoints(outputHtmlPages, "*.html") : htmlPageFiles;
|
|
18698
20332
|
await runSequentially(pageFilesToUpdate, async (pageFile) => {
|
|
18699
|
-
const htmlPageName =
|
|
18700
|
-
const builtHtmlPagePath =
|
|
20333
|
+
const htmlPageName = basename14(pageFile);
|
|
20334
|
+
const builtHtmlPagePath = resolve37(outputHtmlPages, htmlPageName);
|
|
18701
20335
|
await processHtmlPageUpdate(state, pageFile, builtHtmlPagePath, manifest, duration);
|
|
18702
20336
|
});
|
|
18703
20337
|
}, handleVueCssOnlyUpdate = (state, vueCssFiles, manifest, duration) => {
|
|
@@ -18705,7 +20339,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18705
20339
|
if (!cssFile) {
|
|
18706
20340
|
return;
|
|
18707
20341
|
}
|
|
18708
|
-
const cssBaseName =
|
|
20342
|
+
const cssBaseName = basename14(getStyleBaseName(cssFile));
|
|
18709
20343
|
const cssPascalName = toPascal(cssBaseName);
|
|
18710
20344
|
const cssKey = `${cssPascalName}CSS`;
|
|
18711
20345
|
const cssUrl = manifest[cssKey] || null;
|
|
@@ -18754,15 +20388,15 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18754
20388
|
type: "vue-update"
|
|
18755
20389
|
});
|
|
18756
20390
|
}, broadcastVuePageChange = async (state, config, vuePagePath, manifest, duration) => {
|
|
18757
|
-
const fileName =
|
|
20391
|
+
const fileName = basename14(vuePagePath);
|
|
18758
20392
|
const baseName = fileName.replace(/\.vue$/, "");
|
|
18759
20393
|
const pascalName = toPascal(baseName);
|
|
18760
20394
|
const vueRoot = config.vueDirectory;
|
|
18761
|
-
const hmrId = vueRoot ?
|
|
20395
|
+
const hmrId = vueRoot ? relative15(vueRoot, vuePagePath).replace(/\\/g, "/").replace(/\.vue$/, "") : baseName;
|
|
18762
20396
|
const cssKey = `${pascalName}CSS`;
|
|
18763
20397
|
const cssUrl = manifest[cssKey] || null;
|
|
18764
20398
|
const { vueHmrMetadata: vueHmrMetadata2 } = await Promise.resolve().then(() => (init_compileVue(), exports_compileVue));
|
|
18765
|
-
const hmrMeta = vueHmrMetadata2.get(
|
|
20399
|
+
const hmrMeta = vueHmrMetadata2.get(resolve37(vuePagePath));
|
|
18766
20400
|
const changeType = hmrMeta?.changeType ?? "full";
|
|
18767
20401
|
if (changeType === "style-only") {
|
|
18768
20402
|
broadcastVueStyleOnly(state, vuePagePath, baseName, cssUrl, hmrId, manifest, duration);
|
|
@@ -18800,7 +20434,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18800
20434
|
if (!cssFile) {
|
|
18801
20435
|
return;
|
|
18802
20436
|
}
|
|
18803
|
-
const cssBaseName =
|
|
20437
|
+
const cssBaseName = basename14(getStyleBaseName(cssFile));
|
|
18804
20438
|
const cssPascalName = toPascal(cssBaseName);
|
|
18805
20439
|
const cssKey = `${cssPascalName}CSS`;
|
|
18806
20440
|
const cssUrl = manifest[cssKey] || null;
|
|
@@ -18818,7 +20452,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18818
20452
|
});
|
|
18819
20453
|
}, broadcastSveltePageUpdate = (state, sveltePagePath, manifest, duration) => {
|
|
18820
20454
|
try {
|
|
18821
|
-
const fileName =
|
|
20455
|
+
const fileName = basename14(sveltePagePath);
|
|
18822
20456
|
const baseName = fileName.replace(/\.svelte$/, "");
|
|
18823
20457
|
const pascalName = toPascal(baseName);
|
|
18824
20458
|
const cssKey = `${pascalName}CSS`;
|
|
@@ -18880,7 +20514,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18880
20514
|
if (!cssFile) {
|
|
18881
20515
|
return;
|
|
18882
20516
|
}
|
|
18883
|
-
const cssBaseName =
|
|
20517
|
+
const cssBaseName = basename14(getStyleBaseName(cssFile));
|
|
18884
20518
|
const cssPascalName = toPascal(cssBaseName);
|
|
18885
20519
|
const cssKey = `${cssPascalName}CSS`;
|
|
18886
20520
|
const cssUrl = manifest[cssKey] || null;
|
|
@@ -18898,7 +20532,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18898
20532
|
});
|
|
18899
20533
|
}, broadcastAngularPageHmrUpdate = (state, angularPagePath, manifest, duration, classification) => {
|
|
18900
20534
|
try {
|
|
18901
|
-
const fileName =
|
|
20535
|
+
const fileName = basename14(angularPagePath);
|
|
18902
20536
|
const baseName = fileName.replace(/\.[tj]s$/, "");
|
|
18903
20537
|
const pascalName = toPascal(baseName);
|
|
18904
20538
|
const cssKey = `${pascalName}CSS`;
|
|
@@ -18931,6 +20565,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
18931
20565
|
if (angularFiles.length === 0) {
|
|
18932
20566
|
return;
|
|
18933
20567
|
}
|
|
20568
|
+
broadcastAngularComponentUpdates(state, config.angularDirectory);
|
|
18934
20569
|
const angularCssFiles = angularFiles.filter(isStylePath);
|
|
18935
20570
|
const isCssOnlyChange = angularFiles.every(isStylePath) && angularCssFiles.length > 0;
|
|
18936
20571
|
const angularPageFiles = angularFiles.filter((file5) => file5.replace(/\\/g, "/").includes("/pages/"));
|
|
@@ -19000,8 +20635,8 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
19000
20635
|
const shouldRefreshAllPages = htmxPageFiles.length === 0 && shouldRefreshFromIslandChange;
|
|
19001
20636
|
const pageFilesToUpdate = shouldRefreshAllPages ? await scanEntryPoints(outputHtmxPages, "*.html") : htmxPageFiles;
|
|
19002
20637
|
await runSequentially(pageFilesToUpdate, async (htmxPageFile) => {
|
|
19003
|
-
const htmxPageName =
|
|
19004
|
-
const builtHtmxPagePath =
|
|
20638
|
+
const htmxPageName = basename14(htmxPageFile);
|
|
20639
|
+
const builtHtmxPagePath = resolve37(outputHtmxPages, htmxPageName);
|
|
19005
20640
|
await processHtmxPageUpdate(state, htmxPageFile, builtHtmxPagePath, manifest, duration);
|
|
19006
20641
|
});
|
|
19007
20642
|
}, collectUpdatedModulePaths = (allModuleUpdates) => {
|
|
@@ -19110,7 +20745,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
|
|
|
19110
20745
|
html = html.slice(0, bodyClose.index) + hmrScript + html.slice(bodyClose.index);
|
|
19111
20746
|
writeFs(destPath, html);
|
|
19112
20747
|
}, processMarkupFileFastPath = async (state, sourceFile, outputDir, framework, startTime, updateAssetPaths2, handleUpdate, readFs, writeFs) => {
|
|
19113
|
-
const destPath =
|
|
20748
|
+
const destPath = resolve37(outputDir, basename14(sourceFile));
|
|
19114
20749
|
const hmrScript = extractHmrScript(destPath, readFs);
|
|
19115
20750
|
const source = await Bun.file(sourceFile).text();
|
|
19116
20751
|
await Bun.write(destPath, source);
|
|
@@ -19370,7 +21005,7 @@ __export(exports_buildDepVendor, {
|
|
|
19370
21005
|
buildDepVendor: () => buildDepVendor
|
|
19371
21006
|
});
|
|
19372
21007
|
import { mkdirSync as mkdirSync13 } from "fs";
|
|
19373
|
-
import { join as
|
|
21008
|
+
import { join as join31 } from "path";
|
|
19374
21009
|
import { rm as rm10 } from "fs/promises";
|
|
19375
21010
|
var {build: bunBuild9, Glob: Glob9 } = globalThis.Bun;
|
|
19376
21011
|
var toSafeFileName6 = (specifier) => {
|
|
@@ -19424,7 +21059,7 @@ var toSafeFileName6 = (specifier) => {
|
|
|
19424
21059
|
framework: Array.from(framework).filter(isResolvable4)
|
|
19425
21060
|
};
|
|
19426
21061
|
}, collectTransitiveImports = async (specs, alreadyVendored, alreadyScanned) => {
|
|
19427
|
-
const { readFileSync:
|
|
21062
|
+
const { readFileSync: readFileSync22 } = await import("fs");
|
|
19428
21063
|
const transpiler5 = new Bun.Transpiler({ loader: "js" });
|
|
19429
21064
|
const newSpecs = new Set;
|
|
19430
21065
|
for (const spec of specs) {
|
|
@@ -19439,7 +21074,7 @@ var toSafeFileName6 = (specifier) => {
|
|
|
19439
21074
|
}
|
|
19440
21075
|
let content;
|
|
19441
21076
|
try {
|
|
19442
|
-
content =
|
|
21077
|
+
content = readFileSync22(resolved, "utf-8");
|
|
19443
21078
|
} catch {
|
|
19444
21079
|
continue;
|
|
19445
21080
|
}
|
|
@@ -19481,7 +21116,7 @@ var toSafeFileName6 = (specifier) => {
|
|
|
19481
21116
|
}), buildDepVendorPass = async (specifiers, vendorDir, tmpDir) => {
|
|
19482
21117
|
const entries = await Promise.all(specifiers.map(async (specifier) => {
|
|
19483
21118
|
const safeName = toSafeFileName6(specifier);
|
|
19484
|
-
const entryPath =
|
|
21119
|
+
const entryPath = join31(tmpDir, `${safeName}.ts`);
|
|
19485
21120
|
await Bun.write(entryPath, await generateVendorEntrySource(specifier));
|
|
19486
21121
|
return { entryPath, specifier };
|
|
19487
21122
|
}));
|
|
@@ -19542,9 +21177,9 @@ var toSafeFileName6 = (specifier) => {
|
|
|
19542
21177
|
const { dep: initialSpecs, framework: frameworkRoots } = await scanBareImports(directories);
|
|
19543
21178
|
if (initialSpecs.length === 0 && frameworkRoots.length === 0)
|
|
19544
21179
|
return {};
|
|
19545
|
-
const vendorDir =
|
|
21180
|
+
const vendorDir = join31(buildDir, "vendor");
|
|
19546
21181
|
mkdirSync13(vendorDir, { recursive: true });
|
|
19547
|
-
const tmpDir =
|
|
21182
|
+
const tmpDir = join31(buildDir, "_dep_vendor_tmp");
|
|
19548
21183
|
mkdirSync13(tmpDir, { recursive: true });
|
|
19549
21184
|
const allSpecs = new Set(initialSpecs);
|
|
19550
21185
|
const alreadyScanned = new Set;
|
|
@@ -19626,8 +21261,8 @@ __export(exports_devBuild, {
|
|
|
19626
21261
|
devBuild: () => devBuild
|
|
19627
21262
|
});
|
|
19628
21263
|
import { readdir as readdir5 } from "fs/promises";
|
|
19629
|
-
import { statSync as
|
|
19630
|
-
import { resolve as
|
|
21264
|
+
import { statSync as statSync4 } from "fs";
|
|
21265
|
+
import { resolve as resolve38 } from "path";
|
|
19631
21266
|
var FRAMEWORK_DIR_KEYS, collectDepVendorSourceDirs = (config) => {
|
|
19632
21267
|
const configuredDirs = [
|
|
19633
21268
|
config.reactDirectory,
|
|
@@ -19650,7 +21285,7 @@ var FRAMEWORK_DIR_KEYS, collectDepVendorSourceDirs = (config) => {
|
|
|
19650
21285
|
return Object.keys(config).length > 0 ? config : null;
|
|
19651
21286
|
}, reloadConfig = async () => {
|
|
19652
21287
|
try {
|
|
19653
|
-
const configPath2 =
|
|
21288
|
+
const configPath2 = resolve38(process.env.ABSOLUTE_CONFIG ?? "absolute.config.ts");
|
|
19654
21289
|
const source = await Bun.file(configPath2).text();
|
|
19655
21290
|
return parseDirectoryConfig(source);
|
|
19656
21291
|
} catch {
|
|
@@ -19735,7 +21370,7 @@ var FRAMEWORK_DIR_KEYS, collectDepVendorSourceDirs = (config) => {
|
|
|
19735
21370
|
state.fileChangeQueue.clear();
|
|
19736
21371
|
}
|
|
19737
21372
|
}, handleCachedReload = async () => {
|
|
19738
|
-
const serverMtime =
|
|
21373
|
+
const serverMtime = statSync4(resolve38(Bun.main)).mtimeMs;
|
|
19739
21374
|
const lastMtime = globalThis.__hmrServerMtime;
|
|
19740
21375
|
globalThis.__hmrServerMtime = serverMtime;
|
|
19741
21376
|
const cached = globalThis.__hmrDevResult;
|
|
@@ -19772,8 +21407,8 @@ var FRAMEWORK_DIR_KEYS, collectDepVendorSourceDirs = (config) => {
|
|
|
19772
21407
|
return true;
|
|
19773
21408
|
}, resolveAbsoluteVersion2 = async () => {
|
|
19774
21409
|
const candidates = [
|
|
19775
|
-
|
|
19776
|
-
|
|
21410
|
+
resolve38(import.meta.dir, "..", "..", "package.json"),
|
|
21411
|
+
resolve38(import.meta.dir, "..", "package.json")
|
|
19777
21412
|
];
|
|
19778
21413
|
const [candidate, ...remaining] = candidates;
|
|
19779
21414
|
if (!candidate) {
|
|
@@ -19799,7 +21434,7 @@ var FRAMEWORK_DIR_KEYS, collectDepVendorSourceDirs = (config) => {
|
|
|
19799
21434
|
const entries = await readdir5(vendorDir).catch(() => emptyStringArray);
|
|
19800
21435
|
await Promise.all(entries.filter((entry) => entry.endsWith(".js")).map(async (entry) => {
|
|
19801
21436
|
const webPath = `/${framework}/vendor/${entry}`;
|
|
19802
|
-
const bytes = await Bun.file(
|
|
21437
|
+
const bytes = await Bun.file(resolve38(vendorDir, entry)).bytes();
|
|
19803
21438
|
assetStore.set(webPath, bytes);
|
|
19804
21439
|
}));
|
|
19805
21440
|
}, devBuild = async (config) => {
|
|
@@ -19867,11 +21502,11 @@ var FRAMEWORK_DIR_KEYS, collectDepVendorSourceDirs = (config) => {
|
|
|
19867
21502
|
cleanStaleAssets(state.assetStore, manifest, state.resolvedPaths.buildDir);
|
|
19868
21503
|
recordStep("populate asset store", stepStartedAt);
|
|
19869
21504
|
stepStartedAt = performance.now();
|
|
19870
|
-
const reactVendorDir =
|
|
19871
|
-
const angularVendorDir =
|
|
19872
|
-
const svelteVendorDir =
|
|
19873
|
-
const vueVendorDir =
|
|
19874
|
-
const depVendorDir =
|
|
21505
|
+
const reactVendorDir = resolve38(state.resolvedPaths.buildDir, "react", "vendor");
|
|
21506
|
+
const angularVendorDir = resolve38(state.resolvedPaths.buildDir, "angular", "vendor");
|
|
21507
|
+
const svelteVendorDir = resolve38(state.resolvedPaths.buildDir, "svelte", "vendor");
|
|
21508
|
+
const vueVendorDir = resolve38(state.resolvedPaths.buildDir, "vue", "vendor");
|
|
21509
|
+
const depVendorDir = resolve38(state.resolvedPaths.buildDir, "vendor");
|
|
19875
21510
|
const { buildDepVendor: buildDepVendor2 } = await Promise.resolve().then(() => (init_buildDepVendor(), exports_buildDepVendor));
|
|
19876
21511
|
const [, angularSpecs, , , , , depPaths] = await Promise.all([
|
|
19877
21512
|
config.reactDirectory ? buildReactVendor(state.resolvedPaths.buildDir) : Promise.resolve(undefined),
|
|
@@ -19949,7 +21584,7 @@ var FRAMEWORK_DIR_KEYS, collectDepVendorSourceDirs = (config) => {
|
|
|
19949
21584
|
manifest
|
|
19950
21585
|
};
|
|
19951
21586
|
globalThis.__hmrDevResult = result;
|
|
19952
|
-
globalThis.__hmrServerMtime =
|
|
21587
|
+
globalThis.__hmrServerMtime = statSync4(resolve38(Bun.main)).mtimeMs;
|
|
19953
21588
|
return result;
|
|
19954
21589
|
};
|
|
19955
21590
|
var init_devBuild = __esm(() => {
|
|
@@ -20095,7 +21730,49 @@ var STORE_KEY = "__elysiaStore", getGlobalValue = (key) => Reflect.get(globalThi
|
|
|
20095
21730
|
await bridgeReactInternals();
|
|
20096
21731
|
}
|
|
20097
21732
|
return resolveDevAssetResponse(request, hmrState2, moduleServerHandler);
|
|
20098
|
-
}).get("/@src/*", ({ request }) => resolveDevAssetResponse(request, hmrState2, moduleServerHandler)).get("/@stub/*", ({ request }) => resolveDevAssetResponse(request, hmrState2, moduleServerHandler)).get("/@hmr/*", ({ request }) => resolveDevAssetResponse(request, hmrState2, moduleServerHandler)).
|
|
21733
|
+
}).get("/@src/*", ({ request }) => resolveDevAssetResponse(request, hmrState2, moduleServerHandler)).get("/@stub/*", ({ request }) => resolveDevAssetResponse(request, hmrState2, moduleServerHandler)).get("/@hmr/*", ({ request }) => resolveDevAssetResponse(request, hmrState2, moduleServerHandler)).get("/@ng/*", async ({ request, query }) => {
|
|
21734
|
+
const url = new URL(request.url);
|
|
21735
|
+
const subPath = url.pathname.slice("/@ng/".length);
|
|
21736
|
+
if (subPath === "debug") {
|
|
21737
|
+
const { getCachedHmrProgram: getCachedHmrProgram2 } = await Promise.resolve().then(() => (init_hmrCompiler(), exports_hmrCompiler));
|
|
21738
|
+
const program = getCachedHmrProgram2();
|
|
21739
|
+
if (!program) {
|
|
21740
|
+
return new Response(JSON.stringify({ error: "No cached program" }), {
|
|
21741
|
+
headers: { "Content-Type": "application/json" },
|
|
21742
|
+
status: 404
|
|
21743
|
+
});
|
|
21744
|
+
}
|
|
21745
|
+
const tsProgram = program.compiler.getCurrentProgram();
|
|
21746
|
+
const sourceFiles = tsProgram.getSourceFiles().map((sf) => sf.fileName).filter((fn2) => !fn2.includes("node_modules") && !fn2.endsWith(".d.ts")).slice(0, 50);
|
|
21747
|
+
return new Response(JSON.stringify({
|
|
21748
|
+
hasProgram: true,
|
|
21749
|
+
sampleSourceFiles: sourceFiles,
|
|
21750
|
+
totalSourceFiles: tsProgram.getSourceFiles().length
|
|
21751
|
+
}, null, 2), {
|
|
21752
|
+
headers: {
|
|
21753
|
+
"Content-Type": "application/json"
|
|
21754
|
+
}
|
|
21755
|
+
});
|
|
21756
|
+
}
|
|
21757
|
+
if (subPath === "component") {
|
|
21758
|
+
const id = typeof query.c === "string" ? query.c : null;
|
|
21759
|
+
if (!id) {
|
|
21760
|
+
return new Response("Missing ?c=<id>", { status: 400 });
|
|
21761
|
+
}
|
|
21762
|
+
const { getApplyMetadataModule: getApplyMetadataModule2 } = await Promise.resolve().then(() => (init_hmrCompiler(), exports_hmrCompiler));
|
|
21763
|
+
const module = await getApplyMetadataModule2(id);
|
|
21764
|
+
if (module === null) {
|
|
21765
|
+
return new Response(`No HMR module for id=${id}. The component may not be in the current program, or the program isn't built yet (rebuild on first save).`, { status: 404 });
|
|
21766
|
+
}
|
|
21767
|
+
return new Response(module, {
|
|
21768
|
+
headers: {
|
|
21769
|
+
"Cache-Control": "no-store",
|
|
21770
|
+
"Content-Type": "text/javascript; charset=utf-8"
|
|
21771
|
+
}
|
|
21772
|
+
});
|
|
21773
|
+
}
|
|
21774
|
+
return new Response("Unknown @ng route", { status: 404 });
|
|
21775
|
+
}).ws("/hmr", {
|
|
20099
21776
|
close: (ws) => handleClientDisconnect(hmrState2, ws),
|
|
20100
21777
|
message: (ws, msg) => handleHMRMessage(hmrState2, ws, msg),
|
|
20101
21778
|
open: (ws) => handleClientConnect(hmrState2, ws, manifest)
|
|
@@ -20122,17 +21799,17 @@ __export(exports_devtoolsJson, {
|
|
|
20122
21799
|
normalizeDevtoolsWorkspaceRoot: () => normalizeDevtoolsWorkspaceRoot,
|
|
20123
21800
|
devtoolsJson: () => devtoolsJson
|
|
20124
21801
|
});
|
|
20125
|
-
import { existsSync as
|
|
20126
|
-
import { dirname as
|
|
21802
|
+
import { existsSync as existsSync29, mkdirSync as mkdirSync14, readFileSync as readFileSync22, writeFileSync as writeFileSync9 } from "fs";
|
|
21803
|
+
import { dirname as dirname22, join as join32, resolve as resolve39 } from "path";
|
|
20127
21804
|
import { Elysia as Elysia3 } from "elysia";
|
|
20128
21805
|
var ENDPOINT = "/.well-known/appspecific/com.chrome.devtools.json", UUID_CACHE_KEY = "__absoluteDevtoolsWorkspaceUuid", getGlobalUuid = () => Reflect.get(globalThis, UUID_CACHE_KEY), setGlobalUuid = (uuid) => {
|
|
20129
21806
|
Reflect.set(globalThis, UUID_CACHE_KEY, uuid);
|
|
20130
21807
|
return uuid;
|
|
20131
|
-
}, isUuidV4 = (value) => /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value), resolveDevtoolsUuidCachePath = (buildDir, uuidCachePath) =>
|
|
20132
|
-
if (!
|
|
21808
|
+
}, isUuidV4 = (value) => /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value), resolveDevtoolsUuidCachePath = (buildDir, uuidCachePath) => resolve39(uuidCachePath ?? join32(buildDir, ".absolute", "chrome-devtools-workspace-uuid")), readCachedUuid = (cachePath) => {
|
|
21809
|
+
if (!existsSync29(cachePath))
|
|
20133
21810
|
return null;
|
|
20134
21811
|
try {
|
|
20135
|
-
const value =
|
|
21812
|
+
const value = readFileSync22(cachePath, "utf-8").trim();
|
|
20136
21813
|
return isUuidV4(value) ? value : null;
|
|
20137
21814
|
} catch {
|
|
20138
21815
|
return null;
|
|
@@ -20150,11 +21827,11 @@ var ENDPOINT = "/.well-known/appspecific/com.chrome.devtools.json", UUID_CACHE_K
|
|
|
20150
21827
|
if (cachedUuid)
|
|
20151
21828
|
return setGlobalUuid(cachedUuid);
|
|
20152
21829
|
const uuid = crypto.randomUUID();
|
|
20153
|
-
mkdirSync14(
|
|
21830
|
+
mkdirSync14(dirname22(cachePath), { recursive: true });
|
|
20154
21831
|
writeFileSync9(cachePath, uuid, "utf-8");
|
|
20155
21832
|
return setGlobalUuid(uuid);
|
|
20156
21833
|
}, devtoolsJson = (buildDir, options = {}) => {
|
|
20157
|
-
const rootPath =
|
|
21834
|
+
const rootPath = resolve39(options.projectRoot ?? process.cwd());
|
|
20158
21835
|
const root = options.normalizeForWindowsContainer === false ? rootPath : normalizeDevtoolsWorkspaceRoot(rootPath);
|
|
20159
21836
|
const uuid = getOrCreateUuid(buildDir, options);
|
|
20160
21837
|
return new Elysia3({ name: "absolute-devtools-json" }).get(ENDPOINT, () => ({
|
|
@@ -20167,11 +21844,11 @@ var ENDPOINT = "/.well-known/appspecific/com.chrome.devtools.json", UUID_CACHE_K
|
|
|
20167
21844
|
if (process.env.WSL_DISTRO_NAME) {
|
|
20168
21845
|
const distro = process.env.WSL_DISTRO_NAME;
|
|
20169
21846
|
const withoutLeadingSlash = root.replace(/^\//, "");
|
|
20170
|
-
return
|
|
21847
|
+
return join32("\\\\wsl.localhost", distro, withoutLeadingSlash).replace(/\//g, "\\");
|
|
20171
21848
|
}
|
|
20172
21849
|
if (process.env.DOCKER_DESKTOP && !root.startsWith("\\\\")) {
|
|
20173
21850
|
const withoutLeadingSlash = root.replace(/^\//, "");
|
|
20174
|
-
return
|
|
21851
|
+
return join32("\\\\wsl.localhost", "docker-desktop-data", withoutLeadingSlash).replace(/\//g, "\\");
|
|
20175
21852
|
}
|
|
20176
21853
|
return root;
|
|
20177
21854
|
};
|
|
@@ -20182,13 +21859,13 @@ var exports_imageOptimizer = {};
|
|
|
20182
21859
|
__export(exports_imageOptimizer, {
|
|
20183
21860
|
imageOptimizer: () => imageOptimizer
|
|
20184
21861
|
});
|
|
20185
|
-
import { existsSync as
|
|
20186
|
-
import { resolve as
|
|
21862
|
+
import { existsSync as existsSync30 } from "fs";
|
|
21863
|
+
import { resolve as resolve40 } from "path";
|
|
20187
21864
|
import { Elysia as Elysia4 } from "elysia";
|
|
20188
21865
|
var DEFAULT_CACHE_TTL_SECONDS = 60, MS_PER_SECOND = 1000, MAX_QUALITY = 100, avifInProgress, safeResolve = (path, baseDir) => {
|
|
20189
21866
|
try {
|
|
20190
21867
|
const resolved = validateSafePath(path, baseDir);
|
|
20191
|
-
if (
|
|
21868
|
+
if (existsSync30(resolved))
|
|
20192
21869
|
return resolved;
|
|
20193
21870
|
return null;
|
|
20194
21871
|
} catch {
|
|
@@ -20196,7 +21873,7 @@ var DEFAULT_CACHE_TTL_SECONDS = 60, MS_PER_SECOND = 1000, MAX_QUALITY = 100, avi
|
|
|
20196
21873
|
}
|
|
20197
21874
|
}, resolveLocalImage = (url, buildDir) => {
|
|
20198
21875
|
const cleanPath = url.startsWith("/") ? url.slice(1) : url;
|
|
20199
|
-
return safeResolve(cleanPath, buildDir) ?? safeResolve(cleanPath,
|
|
21876
|
+
return safeResolve(cleanPath, buildDir) ?? safeResolve(cleanPath, resolve40(process.cwd()));
|
|
20200
21877
|
}, parseQueryParams = (query, allowedSizes, defaultQuality) => {
|
|
20201
21878
|
const url = typeof query["url"] === "string" ? query["url"] : undefined;
|
|
20202
21879
|
const wParam = typeof query["w"] === "string" ? query["w"] : undefined;
|
|
@@ -20487,15 +22164,15 @@ __export(exports_prerender, {
|
|
|
20487
22164
|
prerender: () => prerender,
|
|
20488
22165
|
PRERENDER_BYPASS_HEADER: () => PRERENDER_BYPASS_HEADER
|
|
20489
22166
|
});
|
|
20490
|
-
import { mkdirSync as mkdirSync15, readFileSync as
|
|
20491
|
-
import { join as
|
|
22167
|
+
import { mkdirSync as mkdirSync15, readFileSync as readFileSync23 } from "fs";
|
|
22168
|
+
import { join as join33 } from "path";
|
|
20492
22169
|
var SERVER_OUTPUT_LIMIT = 4000, STARTUP_POLL_INTERVAL_MS = 100, DEFAULT_STARTUP_TIMEOUT_MS = 30000, PRERENDER_BYPASS_HEADER = "X-Absolute-Prerender-Bypass", routeToFilename = (route) => route === "/" ? "index.html" : `${route.slice(1).replace(/\//g, "-")}.html`, writeTimestamp = async (htmlPath) => {
|
|
20493
22170
|
const metaPath = htmlPath.replace(/\.html$/, ".meta");
|
|
20494
22171
|
await Bun.write(metaPath, String(Date.now()));
|
|
20495
22172
|
}, readTimestamp = (htmlPath) => {
|
|
20496
22173
|
const metaPath = htmlPath.replace(/\.html$/, ".meta");
|
|
20497
22174
|
try {
|
|
20498
|
-
const content =
|
|
22175
|
+
const content = readFileSync23(metaPath, "utf-8");
|
|
20499
22176
|
return Number(content) || 0;
|
|
20500
22177
|
} catch {
|
|
20501
22178
|
return 0;
|
|
@@ -20554,7 +22231,7 @@ var SERVER_OUTPUT_LIMIT = 4000, STARTUP_POLL_INTERVAL_MS = 100, DEFAULT_STARTUP_
|
|
|
20554
22231
|
return false;
|
|
20555
22232
|
const html = await res.text();
|
|
20556
22233
|
const fileName = routeToFilename(route);
|
|
20557
|
-
const filePath =
|
|
22234
|
+
const filePath = join33(prerenderDir, fileName);
|
|
20558
22235
|
await Bun.write(filePath, html);
|
|
20559
22236
|
await writeTimestamp(filePath);
|
|
20560
22237
|
return true;
|
|
@@ -20580,13 +22257,13 @@ var SERVER_OUTPUT_LIMIT = 4000, STARTUP_POLL_INTERVAL_MS = 100, DEFAULT_STARTUP_
|
|
|
20580
22257
|
}
|
|
20581
22258
|
const html = await res.text();
|
|
20582
22259
|
const fileName = routeToFilename(route);
|
|
20583
|
-
const filePath =
|
|
22260
|
+
const filePath = join33(prerenderDir, fileName);
|
|
20584
22261
|
await Bun.write(filePath, html);
|
|
20585
22262
|
await writeTimestamp(filePath);
|
|
20586
22263
|
result.routes.set(route, filePath);
|
|
20587
22264
|
log2?.(` Pre-rendered ${route} \u2192 ${fileName} (${html.length} bytes)`);
|
|
20588
22265
|
}, prerender = async (port, outDir, staticConfig, log2) => {
|
|
20589
|
-
const prerenderDir =
|
|
22266
|
+
const prerenderDir = join33(outDir, "_prerendered");
|
|
20590
22267
|
mkdirSync15(prerenderDir, { recursive: true });
|
|
20591
22268
|
const baseUrl = `http://localhost:${port}`;
|
|
20592
22269
|
let routes;
|
|
@@ -21182,8 +22859,8 @@ var handleHTMXPageRequest = async (pagePath) => {
|
|
|
21182
22859
|
});
|
|
21183
22860
|
};
|
|
21184
22861
|
// src/core/prepare.ts
|
|
21185
|
-
import { existsSync as
|
|
21186
|
-
import { basename as
|
|
22862
|
+
import { existsSync as existsSync31, readdirSync as readdirSync3, readFileSync as readFileSync24 } from "fs";
|
|
22863
|
+
import { basename as basename15, join as join34, relative as relative16, resolve as resolve41 } from "path";
|
|
21187
22864
|
import { Elysia as Elysia5 } from "elysia";
|
|
21188
22865
|
|
|
21189
22866
|
// src/utils/loadConfig.ts
|
|
@@ -21606,7 +23283,7 @@ var collectPrewarmFiles = async (prewarmDirs) => {
|
|
|
21606
23283
|
for (const { dir, pattern } of prewarmDirs) {
|
|
21607
23284
|
const glob = new Glob10(pattern);
|
|
21608
23285
|
const matches = [
|
|
21609
|
-
...glob.scanSync({ absolute: true, cwd:
|
|
23286
|
+
...glob.scanSync({ absolute: true, cwd: resolve41(dir) })
|
|
21610
23287
|
];
|
|
21611
23288
|
files.push(...matches);
|
|
21612
23289
|
}
|
|
@@ -21617,7 +23294,7 @@ var warmPrewarmDirs = async (prewarmDirs, warmCache2, SRC_URL_PREFIX2) => {
|
|
|
21617
23294
|
for (const file5 of files) {
|
|
21618
23295
|
if (file5.includes("/node_modules/"))
|
|
21619
23296
|
continue;
|
|
21620
|
-
const rel =
|
|
23297
|
+
const rel = relative16(process.cwd(), file5).replace(/\\/g, "/");
|
|
21621
23298
|
warmCache2(`${SRC_URL_PREFIX2}${rel}`);
|
|
21622
23299
|
}
|
|
21623
23300
|
};
|
|
@@ -21642,10 +23319,10 @@ var patchManifestIndexes = (manifest, devIndexDir, SRC_URL_PREFIX2) => {
|
|
|
21642
23319
|
const fileName = resolveDevIndexFileName(manifest[key], baseName);
|
|
21643
23320
|
if (!fileName)
|
|
21644
23321
|
continue;
|
|
21645
|
-
const srcPath =
|
|
21646
|
-
if (!
|
|
23322
|
+
const srcPath = resolve41(devIndexDir, fileName);
|
|
23323
|
+
if (!existsSync31(srcPath))
|
|
21647
23324
|
continue;
|
|
21648
|
-
const rel =
|
|
23325
|
+
const rel = relative16(process.cwd(), srcPath).replace(/\\/g, "/");
|
|
21649
23326
|
manifest[key] = `${SRC_URL_PREFIX2}${rel}`;
|
|
21650
23327
|
}
|
|
21651
23328
|
};
|
|
@@ -21715,7 +23392,7 @@ var prepareDev = async (config, buildDir) => {
|
|
|
21715
23392
|
stepStartedAt = performance.now();
|
|
21716
23393
|
const hmrPlugin = hmr2(result.hmrState, result.manifest, moduleHandler);
|
|
21717
23394
|
const { devtoolsJson: devtoolsJson2 } = await Promise.resolve().then(() => (init_devtoolsJson(), exports_devtoolsJson));
|
|
21718
|
-
const devIndexDir =
|
|
23395
|
+
const devIndexDir = resolve41(buildDir, "_src_indexes");
|
|
21719
23396
|
patchManifestIndexes(result.manifest, devIndexDir, SRC_URL_PREFIX2);
|
|
21720
23397
|
recordStep("configure dev plugins", stepStartedAt);
|
|
21721
23398
|
stepStartedAt = performance.now();
|
|
@@ -21751,20 +23428,20 @@ var prepareDev = async (config, buildDir) => {
|
|
|
21751
23428
|
};
|
|
21752
23429
|
var loadPrerenderMap = (prerenderDir) => {
|
|
21753
23430
|
const map = new Map;
|
|
21754
|
-
if (!
|
|
23431
|
+
if (!existsSync31(prerenderDir))
|
|
21755
23432
|
return map;
|
|
21756
23433
|
let entries;
|
|
21757
23434
|
try {
|
|
21758
|
-
entries =
|
|
23435
|
+
entries = readdirSync3(prerenderDir);
|
|
21759
23436
|
} catch {
|
|
21760
23437
|
return map;
|
|
21761
23438
|
}
|
|
21762
23439
|
for (const entry of entries) {
|
|
21763
23440
|
if (!entry.endsWith(".html"))
|
|
21764
23441
|
continue;
|
|
21765
|
-
const name =
|
|
23442
|
+
const name = basename15(entry, ".html");
|
|
21766
23443
|
const route = name === "index" ? "/" : `/${name}`;
|
|
21767
|
-
map.set(route,
|
|
23444
|
+
map.set(route, join34(prerenderDir, entry));
|
|
21768
23445
|
}
|
|
21769
23446
|
return map;
|
|
21770
23447
|
};
|
|
@@ -21796,7 +23473,7 @@ var prepare = async (configOrPath) => {
|
|
|
21796
23473
|
recordStep("load config", stepStartedAt);
|
|
21797
23474
|
const nodeEnv = process.env["NODE_ENV"];
|
|
21798
23475
|
const isDev3 = nodeEnv === "development";
|
|
21799
|
-
const buildDir =
|
|
23476
|
+
const buildDir = resolve41(process.env.ABSOLUTE_BUILD_DIR ?? config.buildDirectory ?? "build");
|
|
21800
23477
|
if (isDev3) {
|
|
21801
23478
|
stepStartedAt = performance.now();
|
|
21802
23479
|
const result = await prepareDev(config, buildDir);
|
|
@@ -21805,7 +23482,7 @@ var prepare = async (configOrPath) => {
|
|
|
21805
23482
|
return result;
|
|
21806
23483
|
}
|
|
21807
23484
|
stepStartedAt = performance.now();
|
|
21808
|
-
const manifest = JSON.parse(
|
|
23485
|
+
const manifest = JSON.parse(readFileSync24(`${buildDir}/manifest.json`, "utf-8"));
|
|
21809
23486
|
setCurrentIslandManifest(manifest);
|
|
21810
23487
|
if (config.islands?.registry) {
|
|
21811
23488
|
setCurrentIslandRegistry(await loadIslandRegistry(config.islands.registry));
|
|
@@ -21813,9 +23490,9 @@ var prepare = async (configOrPath) => {
|
|
|
21813
23490
|
setCurrentPageIslandMetadata(await loadPageIslandMetadata(config));
|
|
21814
23491
|
recordStep("load production manifest and island metadata", stepStartedAt);
|
|
21815
23492
|
stepStartedAt = performance.now();
|
|
21816
|
-
const conventionsPath =
|
|
21817
|
-
if (
|
|
21818
|
-
const conventions2 = JSON.parse(
|
|
23493
|
+
const conventionsPath = join34(buildDir, "conventions.json");
|
|
23494
|
+
if (existsSync31(conventionsPath)) {
|
|
23495
|
+
const conventions2 = JSON.parse(readFileSync24(conventionsPath, "utf-8"));
|
|
21819
23496
|
setConventions(conventions2);
|
|
21820
23497
|
}
|
|
21821
23498
|
recordStep("load production conventions", stepStartedAt);
|
|
@@ -21829,7 +23506,7 @@ var prepare = async (configOrPath) => {
|
|
|
21829
23506
|
});
|
|
21830
23507
|
recordStep("create static plugin", stepStartedAt);
|
|
21831
23508
|
stepStartedAt = performance.now();
|
|
21832
|
-
const prerenderDir =
|
|
23509
|
+
const prerenderDir = join34(buildDir, "_prerendered");
|
|
21833
23510
|
const prerenderMap = loadPrerenderMap(prerenderDir);
|
|
21834
23511
|
recordStep("load prerender map", stepStartedAt);
|
|
21835
23512
|
if (prerenderMap.size > 0) {
|
|
@@ -21887,18 +23564,18 @@ import { argv } from "process";
|
|
|
21887
23564
|
var {env: env4 } = globalThis.Bun;
|
|
21888
23565
|
|
|
21889
23566
|
// src/dev/devCert.ts
|
|
21890
|
-
import { existsSync as
|
|
21891
|
-
import { join as
|
|
21892
|
-
var CERT_DIR =
|
|
21893
|
-
var CERT_PATH =
|
|
21894
|
-
var KEY_PATH =
|
|
23567
|
+
import { existsSync as existsSync32, mkdirSync as mkdirSync16, readFileSync as readFileSync25, rmSync as rmSync3 } from "fs";
|
|
23568
|
+
import { join as join35 } from "path";
|
|
23569
|
+
var CERT_DIR = join35(process.cwd(), ".absolutejs");
|
|
23570
|
+
var CERT_PATH = join35(CERT_DIR, "cert.pem");
|
|
23571
|
+
var KEY_PATH = join35(CERT_DIR, "key.pem");
|
|
21895
23572
|
var CERT_VALIDITY_DAYS = 365;
|
|
21896
23573
|
var devLog = (msg) => console.log(`\x1B[2m${new Date().toLocaleTimeString()}\x1B[0m \x1B[36m[dev]\x1B[0m ${msg}`);
|
|
21897
23574
|
var devWarn = (msg) => console.log(`\x1B[2m${new Date().toLocaleTimeString()}\x1B[0m \x1B[33m[dev]\x1B[0m \x1B[33m${msg}\x1B[0m`);
|
|
21898
|
-
var certFilesExist = () =>
|
|
23575
|
+
var certFilesExist = () => existsSync32(CERT_PATH) && existsSync32(KEY_PATH);
|
|
21899
23576
|
var isCertExpired = () => {
|
|
21900
23577
|
try {
|
|
21901
|
-
const certPem =
|
|
23578
|
+
const certPem = readFileSync25(CERT_PATH, "utf-8");
|
|
21902
23579
|
const proc = Bun.spawnSync(["openssl", "x509", "-enddate", "-noout"], {
|
|
21903
23580
|
stdin: new TextEncoder().encode(certPem)
|
|
21904
23581
|
});
|
|
@@ -21994,8 +23671,8 @@ var loadDevCert = () => {
|
|
|
21994
23671
|
return null;
|
|
21995
23672
|
try {
|
|
21996
23673
|
return {
|
|
21997
|
-
cert:
|
|
21998
|
-
key:
|
|
23674
|
+
cert: readFileSync25(paths.cert, "utf-8"),
|
|
23675
|
+
key: readFileSync25(paths.key, "utf-8")
|
|
21999
23676
|
};
|
|
22000
23677
|
} catch {
|
|
22001
23678
|
return null;
|
|
@@ -22223,8 +23900,8 @@ var jsonLd2 = (schema) => {
|
|
|
22223
23900
|
};
|
|
22224
23901
|
// src/utils/defineEnv.ts
|
|
22225
23902
|
var {env: bunEnv } = globalThis.Bun;
|
|
22226
|
-
import { existsSync as
|
|
22227
|
-
import { resolve as
|
|
23903
|
+
import { existsSync as existsSync33, readFileSync as readFileSync26 } from "fs";
|
|
23904
|
+
import { resolve as resolve42 } from "path";
|
|
22228
23905
|
|
|
22229
23906
|
// node_modules/@sinclair/typebox/build/esm/type/guard/value.mjs
|
|
22230
23907
|
var exports_value = {};
|
|
@@ -28259,19 +29936,19 @@ ${lines.join(`
|
|
|
28259
29936
|
};
|
|
28260
29937
|
var checkEnvFileSecurity = (properties) => {
|
|
28261
29938
|
const cwd2 = process.cwd();
|
|
28262
|
-
const envPath =
|
|
28263
|
-
if (!
|
|
29939
|
+
const envPath = resolve42(cwd2, ".env");
|
|
29940
|
+
if (!existsSync33(envPath))
|
|
28264
29941
|
return;
|
|
28265
29942
|
const sensitiveKeys = Object.keys(properties).filter(isSensitive);
|
|
28266
29943
|
if (sensitiveKeys.length === 0)
|
|
28267
29944
|
return;
|
|
28268
|
-
const envContent =
|
|
29945
|
+
const envContent = readFileSync26(envPath, "utf-8");
|
|
28269
29946
|
const presentKeys = sensitiveKeys.filter((key) => envContent.includes(`${key}=`));
|
|
28270
29947
|
if (presentKeys.length === 0)
|
|
28271
29948
|
return;
|
|
28272
|
-
const gitignorePath =
|
|
28273
|
-
if (
|
|
28274
|
-
const gitignore =
|
|
29949
|
+
const gitignorePath = resolve42(cwd2, ".gitignore");
|
|
29950
|
+
if (existsSync33(gitignorePath)) {
|
|
29951
|
+
const gitignore = readFileSync26(gitignorePath, "utf-8");
|
|
28275
29952
|
if (gitignore.split(`
|
|
28276
29953
|
`).some((line) => line.trim() === ".env"))
|
|
28277
29954
|
return;
|
|
@@ -28509,5 +30186,5 @@ export {
|
|
|
28509
30186
|
ANGULAR_INIT_TIMEOUT_MS
|
|
28510
30187
|
};
|
|
28511
30188
|
|
|
28512
|
-
//# debugId=
|
|
30189
|
+
//# debugId=7343965EF08E9CF664756E2164756E21
|
|
28513
30190
|
//# sourceMappingURL=index.js.map
|