@absolutejs/absolute 0.19.0-beta.931 → 0.19.0-beta.933
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 +285 -136
- package/dist/angular/index.js.map +6 -5
- package/dist/angular/server.js +267 -118
- package/dist/angular/server.js.map +6 -5
- package/dist/build.js +807 -584
- package/dist/build.js.map +17 -16
- package/dist/dev/client/handlers/angularHmrShim.ts +4 -1
- package/dist/dev/client/handlers/angularRemount.ts +2 -2
- package/dist/dev/client/handlers/angularRemountWiring.ts +1 -4
- package/dist/dev/client/vendor/lview/lViewOps.ts +8 -6
- package/dist/index.js +925 -651
- package/dist/index.js.map +21 -19
- package/dist/islands/index.js +105 -2
- package/dist/islands/index.js.map +5 -4
- package/dist/react/index.js +167 -18
- package/dist/react/index.js.map +6 -5
- package/dist/react/server.js +63 -17
- package/dist/react/server.js.map +3 -3
- package/dist/src/core/normalizeIslandProps.d.ts +15 -0
- package/dist/src/core/vueServerModule.d.ts +1 -0
- package/dist/src/utils/defineConvention.d.ts +3 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/vue/Island.browser.d.ts +36 -12
- package/dist/src/vue/Island.d.ts +35 -11
- package/dist/src/vue/pageHandler.d.ts +8 -0
- package/dist/svelte/index.js +167 -18
- package/dist/svelte/index.js.map +6 -5
- package/dist/svelte/server.js +63 -17
- package/dist/svelte/server.js.map +3 -3
- package/dist/types/conventions.d.ts +5 -0
- package/dist/vue/browser.js +57 -4
- package/dist/vue/browser.js.map +5 -4
- package/dist/vue/index.js +234 -24
- package/dist/vue/index.js.map +9 -7
- package/dist/vue/server.js +73 -20
- package/dist/vue/server.js.map +4 -4
- package/package.json +1 -1
package/dist/angular/server.js
CHANGED
|
@@ -1725,6 +1725,100 @@ var init_svelteServerModule = __esm(() => {
|
|
|
1725
1725
|
});
|
|
1726
1726
|
});
|
|
1727
1727
|
|
|
1728
|
+
// src/core/vueServerModule.ts
|
|
1729
|
+
import { mkdir as mkdir2 } from "fs/promises";
|
|
1730
|
+
import { dirname as dirname3, join as join5, relative as relative3, resolve as resolve5 } from "path";
|
|
1731
|
+
var {Transpiler } = globalThis.Bun;
|
|
1732
|
+
var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot2, compiledModuleCache2, transpiler2, ensureRelativeImportPath2 = (from, target) => {
|
|
1733
|
+
const importPath = relative3(dirname3(from), target).replace(/\\/g, "/");
|
|
1734
|
+
return importPath.startsWith(".") ? importPath : `./${importPath}`;
|
|
1735
|
+
}, getCachedModulePath2 = (sourcePath) => {
|
|
1736
|
+
const relativeSourcePath = relative3(process.cwd(), sourcePath).replace(/\\/g, "/");
|
|
1737
|
+
const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
|
|
1738
|
+
return join5(serverCacheRoot2, `${normalizedSourcePath}.server.js`);
|
|
1739
|
+
}, writeIfChanged2 = async (path, content) => {
|
|
1740
|
+
const targetFile = Bun.file(path);
|
|
1741
|
+
if (await targetFile.exists()) {
|
|
1742
|
+
const currentContent = await targetFile.text();
|
|
1743
|
+
if (currentContent === content)
|
|
1744
|
+
return;
|
|
1745
|
+
}
|
|
1746
|
+
await Bun.write(path, content);
|
|
1747
|
+
}, stripExports = (code) => code.replace(/export\s+default/, "const script ="), mergeVueImports = (code) => {
|
|
1748
|
+
const lines = code.split(`
|
|
1749
|
+
`);
|
|
1750
|
+
const specifierSet = new Set;
|
|
1751
|
+
const vueImportRegex = /^import\s+{([^}]+)}\s+from\s+['"]vue['"];?$/;
|
|
1752
|
+
lines.forEach((line) => {
|
|
1753
|
+
const match = line.match(vueImportRegex);
|
|
1754
|
+
if (match?.[1])
|
|
1755
|
+
match[1].split(",").forEach((importSpecifier) => specifierSet.add(importSpecifier.trim()));
|
|
1756
|
+
});
|
|
1757
|
+
const nonVueLines = lines.filter((line) => !vueImportRegex.test(line));
|
|
1758
|
+
return specifierSet.size ? [
|
|
1759
|
+
`import { ${[...specifierSet].join(", ")} } from "vue";`,
|
|
1760
|
+
...nonVueLines
|
|
1761
|
+
].join(`
|
|
1762
|
+
`) : nonVueLines.join(`
|
|
1763
|
+
`);
|
|
1764
|
+
}, extractRelativeVueImports = (sourceCode) => Array.from(sourceCode.matchAll(/import\s+[\s\S]+?['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((importPath) => typeof importPath === "string" && importPath.startsWith(".") && importPath.endsWith(".vue")), compileVueServerModule = async (sourcePath) => {
|
|
1765
|
+
const cachedModulePath = compiledModuleCache2.get(sourcePath);
|
|
1766
|
+
if (cachedModulePath)
|
|
1767
|
+
return cachedModulePath;
|
|
1768
|
+
const compiler = await import("@vue/compiler-sfc");
|
|
1769
|
+
const source = await Bun.file(sourcePath).text();
|
|
1770
|
+
const { descriptor } = compiler.parse(source, { filename: sourcePath });
|
|
1771
|
+
const componentId = Bun.hash(sourcePath).toString(BASE_36_RADIX).slice(0, ISLAND_COMPONENT_ID_LENGTH);
|
|
1772
|
+
const hasScript = descriptor.script || descriptor.scriptSetup;
|
|
1773
|
+
const compiledScript = hasScript ? compiler.compileScript(descriptor, {
|
|
1774
|
+
id: componentId,
|
|
1775
|
+
inlineTemplate: false
|
|
1776
|
+
}) : { bindings: {}, content: "export default {};" };
|
|
1777
|
+
const renderCode = descriptor.template ? compiler.compileTemplate({
|
|
1778
|
+
compilerOptions: {
|
|
1779
|
+
bindingMetadata: compiledScript.bindings,
|
|
1780
|
+
expressionPlugins: ["typescript"],
|
|
1781
|
+
prefixIdentifiers: true,
|
|
1782
|
+
isCustomElement: (tag) => tag === "absolute-island"
|
|
1783
|
+
},
|
|
1784
|
+
filename: sourcePath,
|
|
1785
|
+
id: componentId,
|
|
1786
|
+
scoped: descriptor.styles.some((styleBlock) => styleBlock.scoped),
|
|
1787
|
+
source: descriptor.template.content,
|
|
1788
|
+
ssr: true,
|
|
1789
|
+
ssrCssVars: descriptor.cssVars
|
|
1790
|
+
}).code : "const ssrRender = () => {};";
|
|
1791
|
+
const childImportPaths = extractRelativeVueImports(compiledScript.content);
|
|
1792
|
+
const compiledChildren = await Promise.all(childImportPaths.map(async (relativeImport) => ({
|
|
1793
|
+
compiledPath: await compileVueServerModule(resolve5(dirname3(sourcePath), relativeImport)),
|
|
1794
|
+
spec: relativeImport
|
|
1795
|
+
})));
|
|
1796
|
+
const strippedScript = stripExports(compiledScript.content);
|
|
1797
|
+
const transpiledScript = transpiler2.transformSync(strippedScript);
|
|
1798
|
+
const assembled = mergeVueImports([
|
|
1799
|
+
transpiledScript,
|
|
1800
|
+
renderCode,
|
|
1801
|
+
"script.ssrRender = ssrRender;",
|
|
1802
|
+
"export default script;"
|
|
1803
|
+
].join(`
|
|
1804
|
+
`));
|
|
1805
|
+
const compiledModulePath = getCachedModulePath2(sourcePath);
|
|
1806
|
+
let rewritten = assembled;
|
|
1807
|
+
for (const child of compiledChildren) {
|
|
1808
|
+
rewritten = rewritten.replaceAll(child.spec, ensureRelativeImportPath2(compiledModulePath, child.compiledPath));
|
|
1809
|
+
}
|
|
1810
|
+
await mkdir2(dirname3(compiledModulePath), { recursive: true });
|
|
1811
|
+
await writeIfChanged2(compiledModulePath, rewritten);
|
|
1812
|
+
compiledModuleCache2.set(sourcePath, compiledModulePath);
|
|
1813
|
+
return compiledModulePath;
|
|
1814
|
+
};
|
|
1815
|
+
var init_vueServerModule = __esm(() => {
|
|
1816
|
+
init_constants();
|
|
1817
|
+
serverCacheRoot2 = join5(process.cwd(), ".absolutejs", "islands", "vue");
|
|
1818
|
+
compiledModuleCache2 = new Map;
|
|
1819
|
+
transpiler2 = new Transpiler({ loader: "ts", target: "browser" });
|
|
1820
|
+
});
|
|
1821
|
+
|
|
1728
1822
|
// src/core/islandManifest.ts
|
|
1729
1823
|
var toIslandFrameworkSegment = (framework) => framework[0]?.toUpperCase() + framework.slice(1), collectFrameworkIslands = (manifest, prefix) => {
|
|
1730
1824
|
const entries = {};
|
|
@@ -1811,9 +1905,17 @@ var islandSequence = 0, resolvedServerComponentCache, resolvedServerBuildCompone
|
|
|
1811
1905
|
const loadPromise = loadAndCompileServerBuildComponent(buildReferencePath);
|
|
1812
1906
|
resolvedServerBuildComponentCache.set(buildReferencePath, loadPromise);
|
|
1813
1907
|
return loadPromise;
|
|
1908
|
+
}, resolveRuntimeImportTarget = async (resolvedModulePath) => {
|
|
1909
|
+
if (resolvedModulePath.endsWith(".svelte")) {
|
|
1910
|
+
return compileSvelteServerModule(resolvedModulePath);
|
|
1911
|
+
}
|
|
1912
|
+
if (resolvedModulePath.endsWith(".vue")) {
|
|
1913
|
+
return compileVueServerModule(resolvedModulePath);
|
|
1914
|
+
}
|
|
1915
|
+
return resolvedModulePath;
|
|
1814
1916
|
}, loadServerImportComponent = async (resolvedComponent, exportName) => {
|
|
1815
1917
|
const resolvedModulePath = resolvedComponent.startsWith(".") ? new URL(resolvedComponent, import.meta.url).pathname : resolvedComponent;
|
|
1816
|
-
const importTarget =
|
|
1918
|
+
const importTarget = await resolveRuntimeImportTarget(resolvedModulePath);
|
|
1817
1919
|
const loadedModule = await import(importTarget);
|
|
1818
1920
|
if (exportName && exportName !== "default" && exportName in loadedModule) {
|
|
1819
1921
|
return loadedModule[exportName];
|
|
@@ -1917,6 +2019,7 @@ var islandSequence = 0, resolvedServerComponentCache, resolvedServerBuildCompone
|
|
|
1917
2019
|
var init_renderIslandMarkup = __esm(() => {
|
|
1918
2020
|
init_islandSsr();
|
|
1919
2021
|
init_svelteServerModule();
|
|
2022
|
+
init_vueServerModule();
|
|
1920
2023
|
init_islandMarkupAttributes();
|
|
1921
2024
|
init_islands2();
|
|
1922
2025
|
resolvedServerComponentCache = new Map;
|
|
@@ -2759,12 +2862,12 @@ var init_startupBanner = __esm(() => {
|
|
|
2759
2862
|
// src/utils/logger.ts
|
|
2760
2863
|
var colors2, frameworkColors, formatPath = (filePath) => {
|
|
2761
2864
|
const cwd = process.cwd();
|
|
2762
|
-
let
|
|
2763
|
-
|
|
2764
|
-
if (!
|
|
2765
|
-
|
|
2865
|
+
let relative4 = filePath.startsWith(cwd) ? filePath.slice(cwd.length + 1) : filePath;
|
|
2866
|
+
relative4 = relative4.replace(/\\/g, "/");
|
|
2867
|
+
if (!relative4.startsWith("/")) {
|
|
2868
|
+
relative4 = `/${relative4}`;
|
|
2766
2869
|
}
|
|
2767
|
-
return
|
|
2870
|
+
return relative4;
|
|
2768
2871
|
}, getFrameworkColor = (framework) => frameworkColors[framework] || colors2.white, log = (action, options) => {
|
|
2769
2872
|
const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
|
|
2770
2873
|
const tag = `${colors2.cyan}[hmr]${colors2.reset}`;
|
|
@@ -3376,8 +3479,8 @@ __export(exports_generatedDir, {
|
|
|
3376
3479
|
getGeneratedRoot: () => getGeneratedRoot,
|
|
3377
3480
|
getFrameworkGeneratedDir: () => getFrameworkGeneratedDir
|
|
3378
3481
|
});
|
|
3379
|
-
import { join as
|
|
3380
|
-
var GENERATED_DIR_NAME = "generated", ABSOLUTE_CACHE_DIR_NAME = ".absolutejs", getGeneratedRoot = (projectRoot = process.cwd()) =>
|
|
3482
|
+
import { join as join6 } from "path";
|
|
3483
|
+
var GENERATED_DIR_NAME = "generated", ABSOLUTE_CACHE_DIR_NAME = ".absolutejs", getGeneratedRoot = (projectRoot = process.cwd()) => join6(projectRoot, ABSOLUTE_CACHE_DIR_NAME, GENERATED_DIR_NAME), getFrameworkGeneratedDir = (framework, projectRoot = process.cwd()) => join6(getGeneratedRoot(projectRoot), framework);
|
|
3381
3484
|
var init_generatedDir = () => {};
|
|
3382
3485
|
|
|
3383
3486
|
// src/build/compileAngular.ts
|
|
@@ -3389,17 +3492,17 @@ __export(exports_compileAngular, {
|
|
|
3389
3492
|
compileAngular: () => compileAngular
|
|
3390
3493
|
});
|
|
3391
3494
|
import { existsSync as existsSync4, readFileSync as readFileSync4, promises as fs } from "fs";
|
|
3392
|
-
import { join as
|
|
3495
|
+
import { join as join7, basename as basename3, sep, dirname as dirname4, resolve as resolve6, relative as relative4 } from "path";
|
|
3393
3496
|
import ts from "typescript";
|
|
3394
3497
|
var traceAngularPhase = async (name, fn, metadata) => {
|
|
3395
3498
|
const tracePhase = globalThis.__absoluteBuildTracePhase;
|
|
3396
3499
|
return tracePhase ? tracePhase(`compile/angular/${name}`, fn, metadata) : await fn();
|
|
3397
3500
|
}, readTsconfigPathAliases = () => {
|
|
3398
3501
|
try {
|
|
3399
|
-
const configPath =
|
|
3502
|
+
const configPath = resolve6(process.cwd(), "tsconfig.json");
|
|
3400
3503
|
const config = ts.readConfigFile(configPath, ts.sys.readFile).config;
|
|
3401
3504
|
const compilerOptions = config?.compilerOptions ?? {};
|
|
3402
|
-
const baseUrl =
|
|
3505
|
+
const baseUrl = resolve6(process.cwd(), compilerOptions.baseUrl ?? ".");
|
|
3403
3506
|
const aliases = Object.entries(compilerOptions.paths ?? {}).map(([pattern, replacements]) => ({ pattern, replacements }));
|
|
3404
3507
|
return { aliases, baseUrl };
|
|
3405
3508
|
} catch {
|
|
@@ -3419,7 +3522,7 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3419
3522
|
const wildcardValue = exactMatch ? "" : specifier.slice(prefix.length, specifier.length - suffix.length);
|
|
3420
3523
|
for (const replacement of alias.replacements) {
|
|
3421
3524
|
const candidate = replacement.replace("*", wildcardValue);
|
|
3422
|
-
const resolved = resolveSourceFile(
|
|
3525
|
+
const resolved = resolveSourceFile(resolve6(baseUrl, candidate));
|
|
3423
3526
|
if (resolved)
|
|
3424
3527
|
return resolved;
|
|
3425
3528
|
}
|
|
@@ -3431,20 +3534,20 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3431
3534
|
`${candidate}.tsx`,
|
|
3432
3535
|
`${candidate}.js`,
|
|
3433
3536
|
`${candidate}.jsx`,
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3537
|
+
join7(candidate, "index.ts"),
|
|
3538
|
+
join7(candidate, "index.tsx"),
|
|
3539
|
+
join7(candidate, "index.js"),
|
|
3540
|
+
join7(candidate, "index.jsx")
|
|
3438
3541
|
];
|
|
3439
3542
|
return candidates.find((file) => existsSync4(file));
|
|
3440
3543
|
}, createLegacyAngularAnimationUsageResolver = (rootDir) => {
|
|
3441
|
-
const baseDir =
|
|
3544
|
+
const baseDir = resolve6(rootDir);
|
|
3442
3545
|
const tsconfigAliases = readTsconfigPathAliases();
|
|
3443
|
-
const
|
|
3546
|
+
const transpiler3 = new Bun.Transpiler({ loader: "tsx" });
|
|
3444
3547
|
const scanCache = new Map;
|
|
3445
3548
|
const resolveLocalImport = (specifier, fromDir) => {
|
|
3446
3549
|
if (specifier.startsWith(".") || specifier.startsWith("/")) {
|
|
3447
|
-
return resolveSourceFile(
|
|
3550
|
+
return resolveSourceFile(resolve6(fromDir, specifier));
|
|
3448
3551
|
}
|
|
3449
3552
|
const aliased = matchTsconfigAlias(specifier, tsconfigAliases.aliases, tsconfigAliases.baseUrl, resolveSourceFile);
|
|
3450
3553
|
if (aliased)
|
|
@@ -3453,7 +3556,7 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3453
3556
|
const resolved = Bun.resolveSync(specifier, fromDir);
|
|
3454
3557
|
if (resolved.includes("/node_modules/"))
|
|
3455
3558
|
return;
|
|
3456
|
-
const absolute =
|
|
3559
|
+
const absolute = resolve6(resolved);
|
|
3457
3560
|
if (!absolute.startsWith(baseDir))
|
|
3458
3561
|
return;
|
|
3459
3562
|
return resolveSourceFile(absolute);
|
|
@@ -3469,7 +3572,7 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3469
3572
|
usesLegacyAnimations: false
|
|
3470
3573
|
});
|
|
3471
3574
|
}
|
|
3472
|
-
const resolved =
|
|
3575
|
+
const resolved = resolve6(actualPath);
|
|
3473
3576
|
const cached = scanCache.get(resolved);
|
|
3474
3577
|
if (cached)
|
|
3475
3578
|
return cached;
|
|
@@ -3482,7 +3585,7 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3482
3585
|
}
|
|
3483
3586
|
let imports;
|
|
3484
3587
|
try {
|
|
3485
|
-
imports =
|
|
3588
|
+
imports = transpiler3.scanImports(sourceCode);
|
|
3486
3589
|
} catch {
|
|
3487
3590
|
return { imports: [], usesLegacyAnimations: false };
|
|
3488
3591
|
}
|
|
@@ -3498,7 +3601,7 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3498
3601
|
const actualPath = resolveSourceFile(filePath);
|
|
3499
3602
|
if (!actualPath)
|
|
3500
3603
|
return false;
|
|
3501
|
-
const resolved =
|
|
3604
|
+
const resolved = resolve6(actualPath);
|
|
3502
3605
|
if (visited.has(resolved))
|
|
3503
3606
|
return false;
|
|
3504
3607
|
visited.add(resolved);
|
|
@@ -3506,7 +3609,7 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3506
3609
|
if (scan.usesLegacyAnimations)
|
|
3507
3610
|
return true;
|
|
3508
3611
|
for (const specifier of scan.imports) {
|
|
3509
|
-
const importedPath = resolveLocalImport(specifier,
|
|
3612
|
+
const importedPath = resolveLocalImport(specifier, dirname4(resolved));
|
|
3510
3613
|
if (importedPath && await visit(importedPath, visited)) {
|
|
3511
3614
|
return true;
|
|
3512
3615
|
}
|
|
@@ -3516,14 +3619,14 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3516
3619
|
return (entryPath) => visit(entryPath);
|
|
3517
3620
|
}, resolveDevClientDir = () => {
|
|
3518
3621
|
const projectRoot = process.cwd();
|
|
3519
|
-
const fromSource =
|
|
3622
|
+
const fromSource = resolve6(import.meta.dir, "../dev/client");
|
|
3520
3623
|
if (existsSync4(fromSource) && fromSource.startsWith(projectRoot)) {
|
|
3521
3624
|
return fromSource;
|
|
3522
3625
|
}
|
|
3523
|
-
const fromNodeModules =
|
|
3626
|
+
const fromNodeModules = resolve6(projectRoot, "node_modules/@absolutejs/absolute/dist/dev/client");
|
|
3524
3627
|
if (existsSync4(fromNodeModules))
|
|
3525
3628
|
return fromNodeModules;
|
|
3526
|
-
return
|
|
3629
|
+
return resolve6(import.meta.dir, "./dev/client");
|
|
3527
3630
|
}, devClientDir, hmrClientPath, formatDiagnosticMessage = (diagnostic) => {
|
|
3528
3631
|
try {
|
|
3529
3632
|
return ts.flattenDiagnosticMessageText(diagnostic.messageText, `
|
|
@@ -3565,12 +3668,12 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3565
3668
|
return `${path.replace(/\.ts$/, ".js")}${query}`;
|
|
3566
3669
|
if (hasJsLikeExtension(path))
|
|
3567
3670
|
return `${path}${query}`;
|
|
3568
|
-
const importerDir =
|
|
3569
|
-
const fileCandidate =
|
|
3671
|
+
const importerDir = dirname4(importerOutputPath);
|
|
3672
|
+
const fileCandidate = resolve6(importerDir, `${path}.js`);
|
|
3570
3673
|
if (outputFiles?.has(fileCandidate) || existsSync4(fileCandidate)) {
|
|
3571
3674
|
return `${path}.js${query}`;
|
|
3572
3675
|
}
|
|
3573
|
-
const indexCandidate =
|
|
3676
|
+
const indexCandidate = resolve6(importerDir, path, "index.js");
|
|
3574
3677
|
if (outputFiles?.has(indexCandidate) || existsSync4(indexCandidate)) {
|
|
3575
3678
|
return `${path}/index.js${query}`;
|
|
3576
3679
|
}
|
|
@@ -3598,18 +3701,18 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3598
3701
|
}, resolveLocalTsImport = (fromFile, specifier) => {
|
|
3599
3702
|
if (!isRelativeModuleSpecifier(specifier))
|
|
3600
3703
|
return null;
|
|
3601
|
-
const basePath =
|
|
3704
|
+
const basePath = resolve6(dirname4(fromFile), specifier);
|
|
3602
3705
|
const candidates = /\.[cm]?[tj]sx?$/.test(basePath) ? [basePath] : [
|
|
3603
3706
|
`${basePath}.ts`,
|
|
3604
3707
|
`${basePath}.tsx`,
|
|
3605
3708
|
`${basePath}.mts`,
|
|
3606
3709
|
`${basePath}.cts`,
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3710
|
+
join7(basePath, "index.ts"),
|
|
3711
|
+
join7(basePath, "index.tsx"),
|
|
3712
|
+
join7(basePath, "index.mts"),
|
|
3713
|
+
join7(basePath, "index.cts")
|
|
3611
3714
|
];
|
|
3612
|
-
return candidates.map((candidate) =>
|
|
3715
|
+
return candidates.map((candidate) => resolve6(candidate)).find((candidate) => existsSync4(candidate) && !candidate.endsWith(".d.ts")) ?? null;
|
|
3613
3716
|
}, readFileForAotTransform = async (fileName, readFile2) => {
|
|
3614
3717
|
const hostSource = readFile2?.(fileName);
|
|
3615
3718
|
if (typeof hostSource === "string")
|
|
@@ -3633,18 +3736,18 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3633
3736
|
const paths = [];
|
|
3634
3737
|
const templateUrlMatch = findUncommentedMatch(source, /templateUrl\s*:\s*['"]([^'"]+)['"]/);
|
|
3635
3738
|
if (templateUrlMatch?.[1])
|
|
3636
|
-
paths.push(
|
|
3739
|
+
paths.push(join7(fileDir, templateUrlMatch[1]));
|
|
3637
3740
|
const styleUrlMatch = findUncommentedMatch(source, /styleUrl\s*:\s*['"]([^'"]+)['"]/);
|
|
3638
3741
|
if (styleUrlMatch?.[1])
|
|
3639
|
-
paths.push(
|
|
3742
|
+
paths.push(join7(fileDir, styleUrlMatch[1]));
|
|
3640
3743
|
const styleUrlsMatch = findUncommentedMatch(source, /styleUrls\s*:\s*\[([^\]]+)\]/);
|
|
3641
3744
|
const urlMatches = styleUrlsMatch?.[1]?.match(/['"]([^'"]+)['"]/g);
|
|
3642
3745
|
if (urlMatches) {
|
|
3643
3746
|
for (const urlMatch of urlMatches) {
|
|
3644
|
-
paths.push(
|
|
3747
|
+
paths.push(join7(fileDir, urlMatch.replace(/['"]/g, "")));
|
|
3645
3748
|
}
|
|
3646
3749
|
}
|
|
3647
|
-
return paths.map((path) =>
|
|
3750
|
+
return paths.map((path) => resolve6(path));
|
|
3648
3751
|
}, readResourceCacheFile = async (cachePath) => {
|
|
3649
3752
|
try {
|
|
3650
3753
|
const entry = JSON.parse(await fs.readFile(cachePath, "utf-8"));
|
|
@@ -3656,13 +3759,13 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3656
3759
|
return null;
|
|
3657
3760
|
}
|
|
3658
3761
|
}, writeResourceCacheFile = async (cachePath, source) => {
|
|
3659
|
-
await fs.mkdir(
|
|
3762
|
+
await fs.mkdir(dirname4(cachePath), { recursive: true });
|
|
3660
3763
|
await fs.writeFile(cachePath, JSON.stringify({
|
|
3661
3764
|
source,
|
|
3662
3765
|
version: 1
|
|
3663
3766
|
}), "utf-8");
|
|
3664
3767
|
}, resolveResourceTransformCachePath = async (filePath, source, stylePreprocessors) => {
|
|
3665
|
-
const resourcePaths = collectAngularResourcePaths(source,
|
|
3768
|
+
const resourcePaths = collectAngularResourcePaths(source, dirname4(filePath));
|
|
3666
3769
|
const resourceContents = await Promise.all(resourcePaths.map(async (resourcePath) => {
|
|
3667
3770
|
const content = await fs.readFile(resourcePath, "utf-8");
|
|
3668
3771
|
return `${resourcePath}\x00${content}`;
|
|
@@ -3675,7 +3778,7 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3675
3778
|
safeStableStringify(stylePreprocessors ?? null)
|
|
3676
3779
|
].join("\x00");
|
|
3677
3780
|
const cacheKey = Bun.hash(cacheInput).toString(BASE_36_RADIX);
|
|
3678
|
-
return
|
|
3781
|
+
return join7(process.cwd(), ".absolutejs", "cache", "angular-resources", `${cacheKey}.json`);
|
|
3679
3782
|
}, precomputeAotResourceTransforms = async (inputPaths, readFile2, stylePreprocessors) => {
|
|
3680
3783
|
const transformedSources = new Map;
|
|
3681
3784
|
const visited = new Set;
|
|
@@ -3686,7 +3789,7 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3686
3789
|
transformedFiles: 0
|
|
3687
3790
|
};
|
|
3688
3791
|
const transformFile = async (filePath) => {
|
|
3689
|
-
const resolvedPath =
|
|
3792
|
+
const resolvedPath = resolve6(filePath);
|
|
3690
3793
|
if (visited.has(resolvedPath))
|
|
3691
3794
|
return;
|
|
3692
3795
|
visited.add(resolvedPath);
|
|
@@ -3702,7 +3805,7 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3702
3805
|
transformedSource = cached.source;
|
|
3703
3806
|
} else {
|
|
3704
3807
|
stats.cacheMisses += 1;
|
|
3705
|
-
const transformed = await inlineResources(source,
|
|
3808
|
+
const transformed = await inlineResources(source, dirname4(resolvedPath), stylePreprocessors);
|
|
3706
3809
|
transformedSource = transformed.source;
|
|
3707
3810
|
await writeResourceCacheFile(cachePath, transformedSource);
|
|
3708
3811
|
}
|
|
@@ -3721,7 +3824,7 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3721
3824
|
return { stats, transformedSources };
|
|
3722
3825
|
}, compileAngularFiles = async (inputPaths, outDir, stylePreprocessors) => {
|
|
3723
3826
|
const islandMetadataByOutputPath = await traceAngularPhase("aot/island-metadata", () => new Map(inputPaths.map((inputPath) => {
|
|
3724
|
-
const outputPath =
|
|
3827
|
+
const outputPath = resolve6(join7(outDir, relative4(process.cwd(), resolve6(inputPath)).replace(/\.[cm]?[tj]sx?$/, ".js")));
|
|
3725
3828
|
return [
|
|
3726
3829
|
outputPath,
|
|
3727
3830
|
buildIslandMetadataExports(readFileSync4(inputPath, "utf-8"))
|
|
@@ -3731,8 +3834,8 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3731
3834
|
const { readConfiguration, performCompilation, EmitFlags } = await traceAngularPhase("aot/import-compiler-cli", () => import("@angular/compiler-cli"));
|
|
3732
3835
|
const tsLibDir = await traceAngularPhase("aot/resolve-typescript-lib", () => {
|
|
3733
3836
|
const tsPath = __require.resolve("typescript");
|
|
3734
|
-
const tsRootDir =
|
|
3735
|
-
return tsRootDir.endsWith("lib") ? tsRootDir :
|
|
3837
|
+
const tsRootDir = dirname4(tsPath);
|
|
3838
|
+
return tsRootDir.endsWith("lib") ? tsRootDir : resolve6(tsRootDir, "lib");
|
|
3736
3839
|
});
|
|
3737
3840
|
const config = await traceAngularPhase("aot/read-configuration", () => readConfiguration("./tsconfig.json"));
|
|
3738
3841
|
const options = {
|
|
@@ -3768,13 +3871,13 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3768
3871
|
const originalGetSourceFile = host.getSourceFile;
|
|
3769
3872
|
host.getSourceFile = (fileName, languageVersion, onError) => {
|
|
3770
3873
|
if (fileName.startsWith("lib.") && fileName.endsWith(".d.ts") && tsLibDir) {
|
|
3771
|
-
const resolvedPath =
|
|
3874
|
+
const resolvedPath = join7(tsLibDir, fileName);
|
|
3772
3875
|
return originalGetSourceFile?.call(host, resolvedPath, languageVersion, onError);
|
|
3773
3876
|
}
|
|
3774
3877
|
return originalGetSourceFile?.call(host, fileName, languageVersion, onError);
|
|
3775
3878
|
};
|
|
3776
3879
|
const emitted = {};
|
|
3777
|
-
const resolvedOutDir =
|
|
3880
|
+
const resolvedOutDir = resolve6(outDir);
|
|
3778
3881
|
host.writeFile = (fileName, text) => {
|
|
3779
3882
|
const relativePath = resolveRelativePath(fileName, resolvedOutDir, outDir);
|
|
3780
3883
|
emitted[relativePath] = text;
|
|
@@ -3796,12 +3899,12 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3796
3899
|
if (!fileName.endsWith(".ts") || fileName.endsWith(".d.ts")) {
|
|
3797
3900
|
return source;
|
|
3798
3901
|
}
|
|
3799
|
-
const resolvedPath =
|
|
3902
|
+
const resolvedPath = resolve6(fileName);
|
|
3800
3903
|
return transformedSources.get(resolvedPath) ?? source;
|
|
3801
3904
|
};
|
|
3802
3905
|
const originalGetSourceFileForCompile = host.getSourceFile;
|
|
3803
3906
|
host.getSourceFile = (fileName, languageVersion, onError) => {
|
|
3804
|
-
const source = transformedSources.get(
|
|
3907
|
+
const source = transformedSources.get(resolve6(fileName));
|
|
3805
3908
|
if (source) {
|
|
3806
3909
|
return ts.createSourceFile(fileName, source, languageVersion, true);
|
|
3807
3910
|
}
|
|
@@ -3823,9 +3926,9 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3823
3926
|
const entries = await traceAngularPhase("aot/postprocess-emitted-js", () => {
|
|
3824
3927
|
const rawEntries = Object.entries(emitted).filter(([fileName]) => fileName.endsWith(".js")).map(([fileName, content]) => ({
|
|
3825
3928
|
content,
|
|
3826
|
-
target:
|
|
3929
|
+
target: join7(outDir, fileName)
|
|
3827
3930
|
}));
|
|
3828
|
-
const outputFiles = new Set(rawEntries.map(({ target }) =>
|
|
3931
|
+
const outputFiles = new Set(rawEntries.map(({ target }) => resolve6(target)));
|
|
3829
3932
|
return rawEntries.map(({ content, target }) => {
|
|
3830
3933
|
let processedContent = content.replace(/from\s+(['"])(\.\.?\/[^'"]+)(\1)/g, (match, quote, path) => {
|
|
3831
3934
|
const rewritten = rewriteRelativeJsSpecifier(target, path, outputFiles);
|
|
@@ -3840,12 +3943,12 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3840
3943
|
return cleaned ? `import { ${cleaned}, InternalInjectFlags } from '@angular/core'` : `import { InternalInjectFlags } from '@angular/core'`;
|
|
3841
3944
|
});
|
|
3842
3945
|
processedContent = processedContent.replace(/\b(?<!Internal)InjectFlags\b/g, "InternalInjectFlags");
|
|
3843
|
-
processedContent += islandMetadataByOutputPath.get(
|
|
3946
|
+
processedContent += islandMetadataByOutputPath.get(resolve6(target)) ?? "";
|
|
3844
3947
|
return { content: processedContent, target };
|
|
3845
3948
|
});
|
|
3846
3949
|
});
|
|
3847
3950
|
await traceAngularPhase("aot/write-output", () => Promise.all(entries.map(async ({ target, content }) => {
|
|
3848
|
-
await fs.mkdir(
|
|
3951
|
+
await fs.mkdir(dirname4(target), { recursive: true });
|
|
3849
3952
|
await fs.writeFile(target, content, "utf-8");
|
|
3850
3953
|
})), { outputs: entries.length });
|
|
3851
3954
|
return await traceAngularPhase("aot/collect-output-paths", () => entries.map(({ target }) => target), { outputs: entries.length });
|
|
@@ -3861,7 +3964,7 @@ var traceAngularPhase = async (name, fn, metadata) => {
|
|
|
3861
3964
|
}
|
|
3862
3965
|
return null;
|
|
3863
3966
|
}, resolveAngularDeferImportSpecifier = () => {
|
|
3864
|
-
const sourceEntry =
|
|
3967
|
+
const sourceEntry = resolve6(import.meta.dir, "../angular/components/index.ts");
|
|
3865
3968
|
if (existsSync4(sourceEntry)) {
|
|
3866
3969
|
return sourceEntry.replace(/\\/g, "/");
|
|
3867
3970
|
}
|
|
@@ -3998,7 +4101,7 @@ ${fields}
|
|
|
3998
4101
|
}, inlineTemplateAndLowerDefer = async (source, fileDir) => {
|
|
3999
4102
|
const templateUrlMatch = findUncommentedMatch(source, /templateUrl\s*:\s*['"]([^'"]+)['"]/);
|
|
4000
4103
|
if (templateUrlMatch?.[1]) {
|
|
4001
|
-
const templatePath =
|
|
4104
|
+
const templatePath = join7(fileDir, templateUrlMatch[1]);
|
|
4002
4105
|
if (!existsSync4(templatePath)) {
|
|
4003
4106
|
throw new Error(`Unable to inline Angular templateUrl "${templateUrlMatch[1]}": file not found at ${templatePath}`);
|
|
4004
4107
|
}
|
|
@@ -4029,7 +4132,7 @@ ${fields}
|
|
|
4029
4132
|
}, inlineTemplateAndLowerDeferSync = (source, fileDir) => {
|
|
4030
4133
|
const templateUrlMatch = findUncommentedMatch(source, /templateUrl\s*:\s*['"]([^'"]+)['"]/);
|
|
4031
4134
|
if (templateUrlMatch?.[1]) {
|
|
4032
|
-
const templatePath =
|
|
4135
|
+
const templatePath = join7(fileDir, templateUrlMatch[1]);
|
|
4033
4136
|
if (!existsSync4(templatePath)) {
|
|
4034
4137
|
throw new Error(`Unable to inline Angular templateUrl "${templateUrlMatch[1]}": file not found at ${templatePath}`);
|
|
4035
4138
|
}
|
|
@@ -4066,7 +4169,7 @@ ${fields}
|
|
|
4066
4169
|
return source;
|
|
4067
4170
|
const stylePromises = urlMatches.map((urlMatch) => {
|
|
4068
4171
|
const styleUrl = urlMatch.replace(/['"]/g, "");
|
|
4069
|
-
return readAndEscapeFile(
|
|
4172
|
+
return readAndEscapeFile(join7(fileDir, styleUrl), stylePreprocessors);
|
|
4070
4173
|
});
|
|
4071
4174
|
const results = await Promise.all(stylePromises);
|
|
4072
4175
|
const inlinedStyles = results.filter(Boolean).map((escaped) => `\`${escaped}\``);
|
|
@@ -4077,7 +4180,7 @@ ${fields}
|
|
|
4077
4180
|
const styleUrlMatch = findUncommentedMatch(source, /styleUrl\s*:\s*['"]([^'"]+)['"]/);
|
|
4078
4181
|
if (!styleUrlMatch?.[1])
|
|
4079
4182
|
return source;
|
|
4080
|
-
const escaped = await readAndEscapeFile(
|
|
4183
|
+
const escaped = await readAndEscapeFile(join7(fileDir, styleUrlMatch[1]), stylePreprocessors);
|
|
4081
4184
|
if (!escaped)
|
|
4082
4185
|
return source;
|
|
4083
4186
|
return source.slice(0, styleUrlMatch.index) + `styles: [\`${escaped}\`]` + source.slice(styleUrlMatch.index + styleUrlMatch[0].length);
|
|
@@ -4091,10 +4194,10 @@ ${fields}
|
|
|
4091
4194
|
source: result
|
|
4092
4195
|
};
|
|
4093
4196
|
}, compileAngularFileJIT = async (inputPath, outDir, rootDir, stylePreprocessors, cacheBuster) => {
|
|
4094
|
-
const entryPath =
|
|
4197
|
+
const entryPath = resolve6(inputPath);
|
|
4095
4198
|
const allOutputs = [];
|
|
4096
4199
|
const visited = new Set;
|
|
4097
|
-
const baseDir =
|
|
4200
|
+
const baseDir = resolve6(rootDir ?? process.cwd());
|
|
4098
4201
|
let usesLegacyAnimations = false;
|
|
4099
4202
|
const angularTranspiler = new Bun.Transpiler({
|
|
4100
4203
|
loader: "ts",
|
|
@@ -4112,16 +4215,16 @@ ${fields}
|
|
|
4112
4215
|
`${candidate}.tsx`,
|
|
4113
4216
|
`${candidate}.js`,
|
|
4114
4217
|
`${candidate}.jsx`,
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4218
|
+
join7(candidate, "index.ts"),
|
|
4219
|
+
join7(candidate, "index.tsx"),
|
|
4220
|
+
join7(candidate, "index.js"),
|
|
4221
|
+
join7(candidate, "index.jsx")
|
|
4119
4222
|
];
|
|
4120
4223
|
return candidates.find((file) => existsSync4(file));
|
|
4121
4224
|
};
|
|
4122
4225
|
const resolveLocalImport = (specifier, fromDir) => {
|
|
4123
4226
|
if (specifier.startsWith(".") || specifier.startsWith("/")) {
|
|
4124
|
-
return resolveSourceFile2(
|
|
4227
|
+
return resolveSourceFile2(resolve6(fromDir, specifier));
|
|
4125
4228
|
}
|
|
4126
4229
|
const aliased = matchTsconfigAlias(specifier, tsconfigAliases.aliases, tsconfigAliases.baseUrl, resolveSourceFile2);
|
|
4127
4230
|
if (aliased)
|
|
@@ -4130,7 +4233,7 @@ ${fields}
|
|
|
4130
4233
|
const resolved = Bun.resolveSync(specifier, fromDir);
|
|
4131
4234
|
if (resolved.includes("/node_modules/"))
|
|
4132
4235
|
return;
|
|
4133
|
-
const absolute =
|
|
4236
|
+
const absolute = resolve6(resolved);
|
|
4134
4237
|
if (!absolute.startsWith(baseDir))
|
|
4135
4238
|
return;
|
|
4136
4239
|
return resolveSourceFile2(absolute);
|
|
@@ -4139,10 +4242,10 @@ ${fields}
|
|
|
4139
4242
|
}
|
|
4140
4243
|
};
|
|
4141
4244
|
const toOutputPath = (sourcePath) => {
|
|
4142
|
-
const inputDir =
|
|
4245
|
+
const inputDir = dirname4(sourcePath);
|
|
4143
4246
|
const relativeDir = inputDir.startsWith(baseDir) ? inputDir.substring(baseDir.length + 1) : inputDir;
|
|
4144
4247
|
const fileBase = basename3(sourcePath).replace(/\.[cm]?[tj]sx?$/, ".js");
|
|
4145
|
-
return
|
|
4248
|
+
return join7(outDir, relativeDir, fileBase);
|
|
4146
4249
|
};
|
|
4147
4250
|
const withCacheBuster = (specifier) => {
|
|
4148
4251
|
if (!cacheBuster)
|
|
@@ -4179,13 +4282,13 @@ ${fields}
|
|
|
4179
4282
|
return `${prefix}${dots}`;
|
|
4180
4283
|
return `${prefix}../${dots}`;
|
|
4181
4284
|
});
|
|
4182
|
-
if (
|
|
4285
|
+
if (resolve6(actualPath) === entryPath) {
|
|
4183
4286
|
processedContent += buildIslandMetadataExports(sourceCode);
|
|
4184
4287
|
}
|
|
4185
4288
|
return processedContent;
|
|
4186
4289
|
};
|
|
4187
4290
|
const transpileFile = async (filePath) => {
|
|
4188
|
-
const resolved =
|
|
4291
|
+
const resolved = resolve6(filePath);
|
|
4189
4292
|
if (visited.has(resolved))
|
|
4190
4293
|
return;
|
|
4191
4294
|
visited.add(resolved);
|
|
@@ -4195,12 +4298,12 @@ ${fields}
|
|
|
4195
4298
|
if (!existsSync4(actualPath))
|
|
4196
4299
|
return;
|
|
4197
4300
|
let sourceCode = await fs.readFile(actualPath, "utf-8");
|
|
4198
|
-
const inlined = await inlineResources(sourceCode,
|
|
4199
|
-
sourceCode = inlineTemplateAndLowerDeferSync(inlined.source,
|
|
4200
|
-
const inputDir =
|
|
4301
|
+
const inlined = await inlineResources(sourceCode, dirname4(actualPath), stylePreprocessors);
|
|
4302
|
+
sourceCode = inlineTemplateAndLowerDeferSync(inlined.source, dirname4(actualPath)).source;
|
|
4303
|
+
const inputDir = dirname4(actualPath);
|
|
4201
4304
|
const relativeDir = inputDir.startsWith(baseDir) ? inputDir.substring(baseDir.length + 1) : inputDir;
|
|
4202
4305
|
const fileBase = basename3(actualPath).replace(/\.[cm]?[tj]sx?$/, ".js");
|
|
4203
|
-
const targetDir =
|
|
4306
|
+
const targetDir = join7(outDir, relativeDir);
|
|
4204
4307
|
const targetPath = toOutputPath(actualPath);
|
|
4205
4308
|
const localImports = [];
|
|
4206
4309
|
const importRewrites = new Map;
|
|
@@ -4222,12 +4325,12 @@ ${fields}
|
|
|
4222
4325
|
const resolved2 = resolveLocalImport(specifier, inputDir);
|
|
4223
4326
|
if (!resolved2)
|
|
4224
4327
|
return null;
|
|
4225
|
-
const relativeImport =
|
|
4328
|
+
const relativeImport = relative4(targetDir, toOutputPath(resolved2)).replace(/\\/g, "/").replace(/\.js$/, "");
|
|
4226
4329
|
const relativeRewrite = relativeImport.startsWith(".") ? relativeImport : `./${relativeImport}`;
|
|
4227
4330
|
importRewrites.set(specifier, relativeRewrite);
|
|
4228
4331
|
return resolved2;
|
|
4229
4332
|
}).filter((path) => Boolean(path));
|
|
4230
|
-
const isEntry =
|
|
4333
|
+
const isEntry = resolve6(actualPath) === resolve6(entryPath);
|
|
4231
4334
|
const contentHash = Bun.hash(sourceCode).toString(BASE_36_RADIX);
|
|
4232
4335
|
const cacheKey = actualPath;
|
|
4233
4336
|
const shouldWriteFile = cacheBuster && isEntry ? true : jitContentCache.get(cacheKey) !== contentHash || !existsSync4(targetPath);
|
|
@@ -4261,13 +4364,13 @@ export const __ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__ = true;
|
|
|
4261
4364
|
return { clientPaths: [...emptyPaths], serverPaths: [...emptyPaths] };
|
|
4262
4365
|
}
|
|
4263
4366
|
const compiledRoot = compiledParent;
|
|
4264
|
-
const indexesDir =
|
|
4367
|
+
const indexesDir = join7(compiledParent, "indexes");
|
|
4265
4368
|
await traceAngularPhase("setup/create-indexes-dir", () => fs.mkdir(indexesDir, { recursive: true }));
|
|
4266
|
-
const aotOutputs = hmr ? [] : await traceAngularPhase("aot/compile-files", () => compileAngularFiles(entryPoints.map((entry) =>
|
|
4369
|
+
const aotOutputs = hmr ? [] : await traceAngularPhase("aot/compile-files", () => compileAngularFiles(entryPoints.map((entry) => resolve6(entry)), compiledRoot, stylePreprocessors), { entries: entryPoints.length });
|
|
4267
4370
|
const usesLegacyAngularAnimations = await traceAngularPhase("setup/legacy-animation-resolver", () => createLegacyAngularAnimationUsageResolver(outRoot));
|
|
4268
4371
|
const compileTasks = entryPoints.map(async (entry) => {
|
|
4269
|
-
const resolvedEntry =
|
|
4270
|
-
const relativeEntry =
|
|
4372
|
+
const resolvedEntry = resolve6(entry);
|
|
4373
|
+
const relativeEntry = relative4(outRoot, resolvedEntry).replace(/\.[tj]s$/, ".js");
|
|
4271
4374
|
const compileEntry = () => compileAngularFileJIT(resolvedEntry, compiledRoot, outRoot, stylePreprocessors);
|
|
4272
4375
|
let outputs = hmr ? await traceAngularPhase("jit/compile-entry", compileEntry, {
|
|
4273
4376
|
entry: resolvedEntry
|
|
@@ -4275,13 +4378,13 @@ export const __ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__ = true;
|
|
|
4275
4378
|
const fileBase = basename3(resolvedEntry).replace(/\.[tj]s$/, "");
|
|
4276
4379
|
const jsName = `${fileBase}.js`;
|
|
4277
4380
|
const compiledFallbackPaths = [
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
].map((file) =>
|
|
4381
|
+
join7(compiledRoot, relativeEntry),
|
|
4382
|
+
join7(compiledRoot, "pages", jsName),
|
|
4383
|
+
join7(compiledRoot, jsName)
|
|
4384
|
+
].map((file) => resolve6(file));
|
|
4282
4385
|
const resolveRawServerFile = (candidatePaths) => {
|
|
4283
4386
|
const normalizedCandidates = [
|
|
4284
|
-
...candidatePaths.map((file) =>
|
|
4387
|
+
...candidatePaths.map((file) => resolve6(file)),
|
|
4285
4388
|
...compiledFallbackPaths
|
|
4286
4389
|
];
|
|
4287
4390
|
let candidate = normalizedCandidates.find((file) => existsSync4(file) && file.endsWith(`${sep}pages${sep}${jsName}`));
|
|
@@ -4322,7 +4425,7 @@ export const __ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__ = true;
|
|
|
4322
4425
|
const usesLegacyAnimations = await traceAngularPhase("wrapper/detect-legacy-animations", () => usesLegacyAngularAnimations(resolvedEntry), { entry: resolvedEntry });
|
|
4323
4426
|
const serverContentHash = Bun.hash(original).toString(BASE_36_RADIX);
|
|
4324
4427
|
const cachedWrapper = wrapperOutputCache.get(resolvedEntry);
|
|
4325
|
-
const clientFile =
|
|
4428
|
+
const clientFile = join7(indexesDir, jsName);
|
|
4326
4429
|
if (hmr && cachedWrapper && cachedWrapper.serverHash === serverContentHash && existsSync4(clientFile) && (usesLegacyAnimations || !original.includes("__ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__")) && (!usesLegacyAnimations || original.includes("__ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__"))) {
|
|
4327
4430
|
return {
|
|
4328
4431
|
clientPath: clientFile,
|
|
@@ -4349,7 +4452,7 @@ export const __ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__ = true;
|
|
|
4349
4452
|
`;
|
|
4350
4453
|
}
|
|
4351
4454
|
await traceAngularPhase("wrapper/write-server-output", () => fs.writeFile(rawServerFile, rewritten, "utf-8"), { entry: resolvedEntry });
|
|
4352
|
-
const relativePath =
|
|
4455
|
+
const relativePath = relative4(indexesDir, rawServerFile).replace(/\\/g, "/");
|
|
4353
4456
|
const normalizedImportPath = relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
4354
4457
|
const hmrPreamble = hmr ? `window.__HMR_FRAMEWORK__ = "angular";
|
|
4355
4458
|
import "${hmrClientPath}";
|
|
@@ -4553,7 +4656,7 @@ var init_compileAngular = __esm(() => {
|
|
|
4553
4656
|
init_stylePreprocessor();
|
|
4554
4657
|
init_generatedDir();
|
|
4555
4658
|
devClientDir = resolveDevClientDir();
|
|
4556
|
-
hmrClientPath =
|
|
4659
|
+
hmrClientPath = join7(devClientDir, "hmrClient.ts").replace(/\\/g, "/");
|
|
4557
4660
|
jitContentCache = new Map;
|
|
4558
4661
|
wrapperOutputCache = new Map;
|
|
4559
4662
|
});
|
|
@@ -4721,9 +4824,9 @@ var provideDeterministicEnv = (options = {}) => {
|
|
|
4721
4824
|
// src/angular/pageHandler.ts
|
|
4722
4825
|
init_constants();
|
|
4723
4826
|
import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
|
|
4724
|
-
import { mkdir as
|
|
4827
|
+
import { mkdir as mkdir3, symlink } from "fs/promises";
|
|
4725
4828
|
import { tmpdir } from "os";
|
|
4726
|
-
import { basename as basename4, dirname as
|
|
4829
|
+
import { basename as basename4, dirname as dirname5, join as join8, resolve as resolve7 } from "path";
|
|
4727
4830
|
import { pathToFileURL } from "url";
|
|
4728
4831
|
|
|
4729
4832
|
// src/core/islandPageContext.ts
|
|
@@ -4984,16 +5087,22 @@ var setConventions = (map) => {
|
|
|
4984
5087
|
};
|
|
4985
5088
|
var isDev = () => true;
|
|
4986
5089
|
var buildErrorProps = (error) => {
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
5090
|
+
if (error instanceof Error) {
|
|
5091
|
+
return {
|
|
5092
|
+
name: error.name,
|
|
5093
|
+
message: error.message,
|
|
5094
|
+
...isDev() && error.stack ? { stack: error.stack } : {}
|
|
5095
|
+
};
|
|
5096
|
+
}
|
|
5097
|
+
return { name: "Error", message: String(error) };
|
|
4990
5098
|
};
|
|
4991
5099
|
var renderReactError = async (conventionPath, errorProps) => {
|
|
4992
5100
|
const { createElement } = await import("react");
|
|
4993
5101
|
const { renderToReadableStream } = await import("react-dom/server");
|
|
4994
5102
|
const mod = await import(conventionPath);
|
|
4995
|
-
const
|
|
4996
|
-
|
|
5103
|
+
const ErrorComponent = mod.default;
|
|
5104
|
+
if (typeof ErrorComponent !== "function")
|
|
5105
|
+
return null;
|
|
4997
5106
|
const element = createElement(ErrorComponent, errorProps);
|
|
4998
5107
|
const stream = await renderToReadableStream(element);
|
|
4999
5108
|
return new Response(stream, {
|
|
@@ -5005,6 +5114,8 @@ var renderSvelteError = async (conventionPath, errorProps) => {
|
|
|
5005
5114
|
const { render } = await import("svelte/server");
|
|
5006
5115
|
const mod = await import(conventionPath);
|
|
5007
5116
|
const ErrorComponent = mod.default;
|
|
5117
|
+
if (!ErrorComponent)
|
|
5118
|
+
return null;
|
|
5008
5119
|
const { head, body } = render(ErrorComponent, {
|
|
5009
5120
|
props: errorProps
|
|
5010
5121
|
});
|
|
@@ -5027,6 +5138,8 @@ var renderVueError = async (conventionPath, errorProps) => {
|
|
|
5027
5138
|
const { renderToString } = await import("vue/server-renderer");
|
|
5028
5139
|
const mod = await import(conventionPath);
|
|
5029
5140
|
const ErrorComponent = mod.default;
|
|
5141
|
+
if (!ErrorComponent)
|
|
5142
|
+
return null;
|
|
5030
5143
|
const app = createSSRApp({
|
|
5031
5144
|
render: () => h(ErrorComponent, errorProps)
|
|
5032
5145
|
});
|
|
@@ -5040,10 +5153,20 @@ var renderVueError = async (conventionPath, errorProps) => {
|
|
|
5040
5153
|
};
|
|
5041
5154
|
var renderAngularError = async (conventionPath, errorProps) => {
|
|
5042
5155
|
const mod = await import(conventionPath);
|
|
5043
|
-
const
|
|
5044
|
-
if (typeof
|
|
5156
|
+
const renderFn = mod.default;
|
|
5157
|
+
if (typeof renderFn !== "function")
|
|
5045
5158
|
return null;
|
|
5046
|
-
const html =
|
|
5159
|
+
const html = renderFn(errorProps);
|
|
5160
|
+
return new Response(html, {
|
|
5161
|
+
headers: { "Content-Type": "text/html" },
|
|
5162
|
+
status: 500
|
|
5163
|
+
});
|
|
5164
|
+
};
|
|
5165
|
+
var escapeHtml = (value) => value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
5166
|
+
var replaceErrorTokens = (template, errorProps) => template.replace(/\{\{\s*name\s*\}\}/g, escapeHtml(errorProps.name)).replace(/\{\{\s*message\s*\}\}/g, escapeHtml(errorProps.message)).replace(/\{\{\s*stack\s*\}\}/g, errorProps.stack ? escapeHtml(errorProps.stack) : "");
|
|
5167
|
+
var renderHtmlError = async (conventionPath, errorProps) => {
|
|
5168
|
+
const template = await Bun.file(conventionPath).text();
|
|
5169
|
+
const html = replaceErrorTokens(template, errorProps);
|
|
5047
5170
|
return new Response(html, {
|
|
5048
5171
|
headers: { "Content-Type": "text/html" },
|
|
5049
5172
|
status: 500
|
|
@@ -5062,11 +5185,12 @@ var renderEmberNotFound = async () => null;
|
|
|
5062
5185
|
var ERROR_RENDERERS = {
|
|
5063
5186
|
angular: renderAngularError,
|
|
5064
5187
|
ember: renderEmberError,
|
|
5188
|
+
html: renderHtmlError,
|
|
5065
5189
|
react: renderReactError,
|
|
5066
5190
|
svelte: renderSvelteError,
|
|
5067
5191
|
vue: renderVueError
|
|
5068
5192
|
};
|
|
5069
|
-
var
|
|
5193
|
+
var tryFrameworkErrorConvention = async (framework, pageName, errorProps, error) => {
|
|
5070
5194
|
let conventionPath = resolveErrorConventionPath(framework, pageName);
|
|
5071
5195
|
if (!conventionPath && error instanceof Error && error.stack) {
|
|
5072
5196
|
for (const match of error.stack.matchAll(/^\s*at\s+([A-Za-z_$][\w$]*)/gm)) {
|
|
@@ -5080,7 +5204,6 @@ var renderConventionError = async (framework, pageName, error) => {
|
|
|
5080
5204
|
}
|
|
5081
5205
|
if (!conventionPath)
|
|
5082
5206
|
return null;
|
|
5083
|
-
const errorProps = buildErrorProps(error);
|
|
5084
5207
|
const renderer = ERROR_RENDERERS[framework];
|
|
5085
5208
|
if (!renderer)
|
|
5086
5209
|
return null;
|
|
@@ -5091,12 +5214,25 @@ var renderConventionError = async (framework, pageName, error) => {
|
|
|
5091
5214
|
}
|
|
5092
5215
|
return null;
|
|
5093
5216
|
};
|
|
5217
|
+
var renderConventionError = async (framework, pageName, error) => {
|
|
5218
|
+
const errorProps = buildErrorProps(error);
|
|
5219
|
+
const frameworkResponse = await tryFrameworkErrorConvention(framework, pageName, errorProps, error);
|
|
5220
|
+
if (frameworkResponse)
|
|
5221
|
+
return frameworkResponse;
|
|
5222
|
+
if (framework !== "html") {
|
|
5223
|
+
const htmlResponse = await tryFrameworkErrorConvention("html", pageName, errorProps, error);
|
|
5224
|
+
if (htmlResponse)
|
|
5225
|
+
return htmlResponse;
|
|
5226
|
+
}
|
|
5227
|
+
return null;
|
|
5228
|
+
};
|
|
5094
5229
|
var renderReactNotFound = async (conventionPath) => {
|
|
5095
5230
|
const { createElement } = await import("react");
|
|
5096
5231
|
const { renderToReadableStream } = await import("react-dom/server");
|
|
5097
5232
|
const mod = await import(conventionPath);
|
|
5098
|
-
const
|
|
5099
|
-
|
|
5233
|
+
const NotFoundComponent = mod.default;
|
|
5234
|
+
if (typeof NotFoundComponent !== "function")
|
|
5235
|
+
return null;
|
|
5100
5236
|
const element = createElement(NotFoundComponent);
|
|
5101
5237
|
const stream = await renderToReadableStream(element);
|
|
5102
5238
|
return new Response(stream, {
|
|
@@ -5108,6 +5244,8 @@ var renderSvelteNotFound = async (conventionPath) => {
|
|
|
5108
5244
|
const { render } = await import("svelte/server");
|
|
5109
5245
|
const mod = await import(conventionPath);
|
|
5110
5246
|
const NotFoundComponent = mod.default;
|
|
5247
|
+
if (!NotFoundComponent)
|
|
5248
|
+
return null;
|
|
5111
5249
|
const { head, body } = render(NotFoundComponent);
|
|
5112
5250
|
const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
|
|
5113
5251
|
return new Response(html, {
|
|
@@ -5120,6 +5258,8 @@ var renderVueNotFound = async (conventionPath) => {
|
|
|
5120
5258
|
const { renderToString } = await import("vue/server-renderer");
|
|
5121
5259
|
const mod = await import(conventionPath);
|
|
5122
5260
|
const NotFoundComponent = mod.default;
|
|
5261
|
+
if (!NotFoundComponent)
|
|
5262
|
+
return null;
|
|
5123
5263
|
const app = createSSRApp({
|
|
5124
5264
|
render: () => h(NotFoundComponent)
|
|
5125
5265
|
});
|
|
@@ -5133,10 +5273,17 @@ var renderVueNotFound = async (conventionPath) => {
|
|
|
5133
5273
|
};
|
|
5134
5274
|
var renderAngularNotFound = async (conventionPath) => {
|
|
5135
5275
|
const mod = await import(conventionPath);
|
|
5136
|
-
const
|
|
5137
|
-
if (typeof
|
|
5276
|
+
const renderFn = mod.default;
|
|
5277
|
+
if (typeof renderFn !== "function")
|
|
5138
5278
|
return null;
|
|
5139
|
-
const html =
|
|
5279
|
+
const html = renderFn();
|
|
5280
|
+
return new Response(html, {
|
|
5281
|
+
headers: { "Content-Type": "text/html" },
|
|
5282
|
+
status: 404
|
|
5283
|
+
});
|
|
5284
|
+
};
|
|
5285
|
+
var renderHtmlNotFound = async (conventionPath) => {
|
|
5286
|
+
const html = await Bun.file(conventionPath).text();
|
|
5140
5287
|
return new Response(html, {
|
|
5141
5288
|
headers: { "Content-Type": "text/html" },
|
|
5142
5289
|
status: 404
|
|
@@ -5145,6 +5292,7 @@ var renderAngularNotFound = async (conventionPath) => {
|
|
|
5145
5292
|
var NOT_FOUND_RENDERERS = {
|
|
5146
5293
|
angular: renderAngularNotFound,
|
|
5147
5294
|
ember: renderEmberNotFound,
|
|
5295
|
+
html: renderHtmlNotFound,
|
|
5148
5296
|
react: renderReactNotFound,
|
|
5149
5297
|
svelte: renderSvelteNotFound,
|
|
5150
5298
|
vue: renderVueNotFound
|
|
@@ -5167,7 +5315,8 @@ var NOT_FOUND_PRIORITY = [
|
|
|
5167
5315
|
"react",
|
|
5168
5316
|
"svelte",
|
|
5169
5317
|
"vue",
|
|
5170
|
-
"angular"
|
|
5318
|
+
"angular",
|
|
5319
|
+
"html"
|
|
5171
5320
|
];
|
|
5172
5321
|
var renderFirstNotFound = async () => {
|
|
5173
5322
|
const renderNext = async (frameworks) => {
|
|
@@ -5352,7 +5501,7 @@ var lowerAngularServerIslands = async (html) => {
|
|
|
5352
5501
|
init_devRouteRegistrationCallsite();
|
|
5353
5502
|
|
|
5354
5503
|
// src/angular/ssrSanitizer.ts
|
|
5355
|
-
var
|
|
5504
|
+
var escapeHtml2 = (str) => String(str).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
5356
5505
|
var bypassValue = (value) => ({
|
|
5357
5506
|
changingThisBreaksApplicationSecurity: value
|
|
5358
5507
|
});
|
|
@@ -5378,7 +5527,7 @@ var getSsrSanitizer = (deps) => {
|
|
|
5378
5527
|
if (isTrustedHtml) {
|
|
5379
5528
|
return strValue;
|
|
5380
5529
|
}
|
|
5381
|
-
return
|
|
5530
|
+
return escapeHtml2(strValue);
|
|
5382
5531
|
}
|
|
5383
5532
|
return strValue;
|
|
5384
5533
|
}
|
|
@@ -5543,23 +5692,23 @@ var ensureAngularCompiler = () => {
|
|
|
5543
5692
|
return compilerImportPromise;
|
|
5544
5693
|
};
|
|
5545
5694
|
var readAngularPageModule = (value) => isRecord5(value) ? value : null;
|
|
5546
|
-
var resolveAngularSsrOutDir = () => process.env.ABSOLUTE_ANGULAR_SSR_OUTDIR ??
|
|
5695
|
+
var resolveAngularSsrOutDir = () => process.env.ABSOLUTE_ANGULAR_SSR_OUTDIR ?? join8(tmpdir(), "absolutejs", "generated", "angular-ssr");
|
|
5547
5696
|
var createAngularRuntimeCacheBuster = () => `${Date.now().toString(BASE_36_RADIX)}.${Math.random().toString(BASE_36_RADIX).substring(2, RANDOM_ID_END_INDEX)}`;
|
|
5548
5697
|
var ensureAngularSsrNodeModules = async (outDir) => {
|
|
5549
|
-
const outRoot =
|
|
5550
|
-
const nodeModulesLink =
|
|
5698
|
+
const outRoot = resolve7(dirname5(dirname5(outDir)));
|
|
5699
|
+
const nodeModulesLink = join8(outRoot, "node_modules");
|
|
5551
5700
|
if (process.env.ABSOLUTE_ANGULAR_SSR_OUTDIR) {
|
|
5552
5701
|
return;
|
|
5553
5702
|
}
|
|
5554
|
-
if (nodeModulesLink ===
|
|
5703
|
+
if (nodeModulesLink === resolve7(process.cwd(), "node_modules")) {
|
|
5555
5704
|
return;
|
|
5556
5705
|
}
|
|
5557
5706
|
if (await Bun.file(nodeModulesLink).exists()) {
|
|
5558
5707
|
return;
|
|
5559
5708
|
}
|
|
5560
|
-
await
|
|
5709
|
+
await mkdir3(outRoot, { recursive: true });
|
|
5561
5710
|
try {
|
|
5562
|
-
await symlink(
|
|
5711
|
+
await symlink(resolve7(process.cwd(), "node_modules"), nodeModulesLink, "dir");
|
|
5563
5712
|
} catch (error) {
|
|
5564
5713
|
if (!(error instanceof Error) || !("code" in error) || error.code !== "EEXIST") {
|
|
5565
5714
|
throw error;
|
|
@@ -5717,5 +5866,5 @@ export {
|
|
|
5717
5866
|
ABSOLUTE_HTTP_TRANSFER_CACHE_SKIP_HEADER
|
|
5718
5867
|
};
|
|
5719
5868
|
|
|
5720
|
-
//# debugId=
|
|
5869
|
+
//# debugId=73CF4660FF2BF51464756E2164756E21
|
|
5721
5870
|
//# sourceMappingURL=server.js.map
|