@absolutejs/absolute 0.19.0-beta.953 → 0.19.0-beta.954
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 +10490 -17400
- package/dist/angular/index.js.map +9 -19
- package/dist/angular/server.js +2531 -18377
- package/dist/angular/server.js.map +5 -238
- package/dist/build.js +4 -26
- package/dist/build.js.map +4 -5
- package/dist/index.js +336 -137
- package/dist/index.js.map +7 -8
- package/dist/src/angular/index.d.ts +0 -1
- package/dist/src/angular/staticAnalyzeSpaRoutes.d.ts +26 -0
- package/dist/src/utils/generateSitemap.d.ts +3 -4
- package/package.json +1 -1
- package/dist/src/angular/enumerateSpaRoutes.d.ts +0 -6
- package/dist/src/angular/internal/captureProvideRouter.d.ts +0 -11
- package/dist/src/build/rewriteProvideRouter.d.ts +0 -5
- package/dist/src/utils/spaRouteEnumeration.d.ts +0 -23
package/dist/index.js
CHANGED
|
@@ -11996,24 +11996,6 @@ var init_compileVue = __esm(() => {
|
|
|
11996
11996
|
vueHmrMetadata = new Map;
|
|
11997
11997
|
});
|
|
11998
11998
|
|
|
11999
|
-
// src/build/rewriteProvideRouter.ts
|
|
12000
|
-
var ROUTER_IMPORT_PATTERN, PROVIDE_ROUTER_CALL_PATTERN, CAPTURE_IMPORT_STATEMENT = `import { __abs_provideRouter } from '@absolutejs/absolute/angular';
|
|
12001
|
-
`, SHIM_MARKER = "__abs_provideRouter", rewriteAngularProvideRouter = (source) => {
|
|
12002
|
-
if (source.includes(SHIM_MARKER))
|
|
12003
|
-
return source;
|
|
12004
|
-
if (!ROUTER_IMPORT_PATTERN.test(source))
|
|
12005
|
-
return source;
|
|
12006
|
-
if (!PROVIDE_ROUTER_CALL_PATTERN.test(source))
|
|
12007
|
-
return source;
|
|
12008
|
-
PROVIDE_ROUTER_CALL_PATTERN.lastIndex = 0;
|
|
12009
|
-
const rewritten = source.replace(PROVIDE_ROUTER_CALL_PATTERN, "__abs_provideRouter(");
|
|
12010
|
-
return `${CAPTURE_IMPORT_STATEMENT}${rewritten}`;
|
|
12011
|
-
};
|
|
12012
|
-
var init_rewriteProvideRouter = __esm(() => {
|
|
12013
|
-
ROUTER_IMPORT_PATTERN = /import\s*(?:type\s+)?\{[^}]*\bprovideRouter\b[^}]*\}\s*from\s*['"]@angular\/router['"]/;
|
|
12014
|
-
PROVIDE_ROUTER_CALL_PATTERN = /\bprovideRouter\s*\(/g;
|
|
12015
|
-
});
|
|
12016
|
-
|
|
12017
11999
|
// src/angular/lowerDeferSyntax.ts
|
|
12018
12000
|
var isInterpolatedExpressionStart = (value, index) => value[index] === "{" && value[index + 1] === "{", skipInterpolatedExpression = (value, start) => {
|
|
12019
12001
|
const cursor = start + 2;
|
|
@@ -12709,11 +12691,9 @@ var traceAngularPhase = async (name, fn2, metadata2) => {
|
|
|
12709
12691
|
return candidates.map((candidate) => resolve24(candidate)).find((candidate) => existsSync18(candidate) && !candidate.endsWith(".d.ts")) ?? null;
|
|
12710
12692
|
}, readFileForAotTransform = async (fileName, readFile6) => {
|
|
12711
12693
|
const hostSource = readFile6?.(fileName);
|
|
12712
|
-
if (typeof hostSource === "string")
|
|
12713
|
-
return
|
|
12714
|
-
|
|
12715
|
-
const raw = await fs.readFile(fileName, "utf-8");
|
|
12716
|
-
return rewriteAngularProvideRouter(raw);
|
|
12694
|
+
if (typeof hostSource === "string")
|
|
12695
|
+
return hostSource;
|
|
12696
|
+
return fs.readFile(fileName, "utf-8");
|
|
12717
12697
|
}, safeStableStringify = (value) => {
|
|
12718
12698
|
const seen = new WeakSet;
|
|
12719
12699
|
return JSON.stringify(value, (_key, entry) => {
|
|
@@ -13307,7 +13287,6 @@ ${fields}
|
|
|
13307
13287
|
if (!existsSync18(actualPath))
|
|
13308
13288
|
return;
|
|
13309
13289
|
let sourceCode = await fs.readFile(actualPath, "utf-8");
|
|
13310
|
-
sourceCode = rewriteAngularProvideRouter(sourceCode);
|
|
13311
13290
|
const inlined = await inlineResources(sourceCode, dirname15(actualPath), stylePreprocessors);
|
|
13312
13291
|
sourceCode = inlineTemplateAndLowerDeferSync(inlined.source, dirname15(actualPath)).source;
|
|
13313
13292
|
const inputDir = dirname15(actualPath);
|
|
@@ -13681,7 +13660,6 @@ if (pageHasRawStreamingSlots) {
|
|
|
13681
13660
|
};
|
|
13682
13661
|
};
|
|
13683
13662
|
var init_compileAngular = __esm(() => {
|
|
13684
|
-
init_rewriteProvideRouter();
|
|
13685
13663
|
init_constants();
|
|
13686
13664
|
init_sourceMetadata();
|
|
13687
13665
|
init_lowerDeferSyntax();
|
|
@@ -25620,27 +25598,229 @@ var init_imageOptimizer = __esm(() => {
|
|
|
25620
25598
|
avifInProgress = new Set;
|
|
25621
25599
|
});
|
|
25622
25600
|
|
|
25623
|
-
// src/
|
|
25624
|
-
import {
|
|
25625
|
-
|
|
25626
|
-
|
|
25627
|
-
|
|
25628
|
-
|
|
25629
|
-
|
|
25630
|
-
|
|
25631
|
-
|
|
25632
|
-
|
|
25633
|
-
|
|
25634
|
-
|
|
25601
|
+
// src/angular/staticAnalyzeSpaRoutes.ts
|
|
25602
|
+
import { existsSync as existsSync31, promises as fs2 } from "fs";
|
|
25603
|
+
import { join as join35 } from "path";
|
|
25604
|
+
import ts8 from "typescript";
|
|
25605
|
+
var DYNAMIC_SEGMENT_PATTERN, pathHasDynamic = (path) => path.split("/").some((seg) => DYNAMIC_SEGMENT_PATTERN.test(seg) || seg === "**"), importsSymbolFrom = (sf, localName, moduleSpecifier) => {
|
|
25606
|
+
for (const statement of sf.statements) {
|
|
25607
|
+
if (!ts8.isImportDeclaration(statement))
|
|
25608
|
+
continue;
|
|
25609
|
+
if (!ts8.isStringLiteral(statement.moduleSpecifier))
|
|
25610
|
+
continue;
|
|
25611
|
+
if (statement.moduleSpecifier.text !== moduleSpecifier)
|
|
25612
|
+
continue;
|
|
25613
|
+
const named = statement.importClause?.namedBindings;
|
|
25614
|
+
if (!named || !ts8.isNamedImports(named))
|
|
25615
|
+
continue;
|
|
25616
|
+
for (const element of named.elements) {
|
|
25617
|
+
if (element.name.text === localName)
|
|
25618
|
+
return true;
|
|
25619
|
+
}
|
|
25620
|
+
}
|
|
25621
|
+
return false;
|
|
25622
|
+
}, readStringLiteral = (expression) => {
|
|
25623
|
+
if (ts8.isStringLiteral(expression) || ts8.isNoSubstitutionTemplateLiteral(expression)) {
|
|
25624
|
+
return expression.text;
|
|
25625
|
+
}
|
|
25626
|
+
return null;
|
|
25627
|
+
}, readPropertyKey = (property) => {
|
|
25628
|
+
if (!ts8.isPropertyAssignment(property))
|
|
25629
|
+
return null;
|
|
25630
|
+
const name = property.name;
|
|
25631
|
+
if (ts8.isIdentifier(name) || ts8.isStringLiteral(name))
|
|
25632
|
+
return name.text;
|
|
25633
|
+
return null;
|
|
25634
|
+
}, findRoutesArrayDeclaration = (sf, identifierName) => {
|
|
25635
|
+
let found = null;
|
|
25636
|
+
const visit = (node) => {
|
|
25637
|
+
if (found)
|
|
25638
|
+
return;
|
|
25639
|
+
if (ts8.isVariableDeclaration(node) && ts8.isIdentifier(node.name) && node.name.text === identifierName && node.initializer && ts8.isArrayLiteralExpression(node.initializer)) {
|
|
25640
|
+
found = node.initializer;
|
|
25641
|
+
return;
|
|
25642
|
+
}
|
|
25643
|
+
ts8.forEachChild(node, visit);
|
|
25644
|
+
};
|
|
25645
|
+
ts8.forEachChild(sf, visit);
|
|
25646
|
+
return found;
|
|
25647
|
+
}, extractSitemapData = (dataLiteral) => {
|
|
25648
|
+
for (const prop of dataLiteral.properties) {
|
|
25649
|
+
const key = readPropertyKey(prop);
|
|
25650
|
+
if (key !== "sitemap")
|
|
25651
|
+
continue;
|
|
25652
|
+
if (!ts8.isPropertyAssignment(prop))
|
|
25653
|
+
continue;
|
|
25654
|
+
const value = readStringLiteral(prop.initializer);
|
|
25655
|
+
if (value === "exclude")
|
|
25656
|
+
return true;
|
|
25657
|
+
}
|
|
25658
|
+
return false;
|
|
25659
|
+
}, joinSegments = (parent, child) => {
|
|
25660
|
+
if (!child)
|
|
25661
|
+
return parent;
|
|
25662
|
+
if (!parent)
|
|
25663
|
+
return child;
|
|
25664
|
+
return `${parent.replace(/\/+$/, "")}/${child.replace(/^\/+/, "")}`;
|
|
25665
|
+
}, extractRoutePaths = (arr, parentPath, parentExcluded, out) => {
|
|
25666
|
+
for (const element of arr.elements) {
|
|
25667
|
+
if (!ts8.isObjectLiteralExpression(element))
|
|
25668
|
+
continue;
|
|
25669
|
+
let pathSegment = null;
|
|
25670
|
+
let redirected = false;
|
|
25671
|
+
let sitemapExcluded = parentExcluded;
|
|
25672
|
+
let childrenLiteral = null;
|
|
25673
|
+
for (const property of element.properties) {
|
|
25674
|
+
const key = readPropertyKey(property);
|
|
25675
|
+
if (!key)
|
|
25676
|
+
continue;
|
|
25677
|
+
if (!ts8.isPropertyAssignment(property))
|
|
25678
|
+
continue;
|
|
25679
|
+
if (key === "path") {
|
|
25680
|
+
pathSegment = readStringLiteral(property.initializer);
|
|
25681
|
+
} else if (key === "redirectTo") {
|
|
25682
|
+
redirected = true;
|
|
25683
|
+
} else if (key === "data" && ts8.isObjectLiteralExpression(property.initializer)) {
|
|
25684
|
+
if (extractSitemapData(property.initializer))
|
|
25685
|
+
sitemapExcluded = true;
|
|
25686
|
+
} else if (key === "children" && ts8.isArrayLiteralExpression(property.initializer)) {
|
|
25687
|
+
childrenLiteral = property.initializer;
|
|
25688
|
+
}
|
|
25689
|
+
}
|
|
25690
|
+
if (pathSegment === null)
|
|
25691
|
+
continue;
|
|
25692
|
+
const joined = joinSegments(parentPath, pathSegment);
|
|
25693
|
+
if (childrenLiteral) {
|
|
25694
|
+
extractRoutePaths(childrenLiteral, joined, sitemapExcluded, out);
|
|
25695
|
+
continue;
|
|
25696
|
+
}
|
|
25697
|
+
if (redirected)
|
|
25698
|
+
continue;
|
|
25699
|
+
if (joined === "")
|
|
25700
|
+
continue;
|
|
25701
|
+
out.push({
|
|
25702
|
+
dynamic: pathHasDynamic(joined),
|
|
25703
|
+
path: joined,
|
|
25704
|
+
redirected,
|
|
25705
|
+
sitemapExcluded
|
|
25706
|
+
});
|
|
25707
|
+
}
|
|
25708
|
+
}, findProvideRouterFirstArg = (sf) => {
|
|
25709
|
+
let found = null;
|
|
25710
|
+
const visit = (node) => {
|
|
25711
|
+
if (found)
|
|
25712
|
+
return;
|
|
25713
|
+
if (ts8.isCallExpression(node) && ts8.isIdentifier(node.expression) && node.expression.text === "provideRouter") {
|
|
25714
|
+
found = node.arguments[0] ?? null;
|
|
25715
|
+
return;
|
|
25716
|
+
}
|
|
25717
|
+
ts8.forEachChild(node, visit);
|
|
25718
|
+
};
|
|
25719
|
+
ts8.forEachChild(sf, visit);
|
|
25720
|
+
return found;
|
|
25721
|
+
}, findAppBaseHrefValue = (sf) => {
|
|
25722
|
+
let found = null;
|
|
25723
|
+
const visit = (node) => {
|
|
25724
|
+
if (found)
|
|
25725
|
+
return;
|
|
25726
|
+
if (ts8.isObjectLiteralExpression(node)) {
|
|
25727
|
+
let isAppBaseHref = false;
|
|
25728
|
+
let value = null;
|
|
25729
|
+
for (const property of node.properties) {
|
|
25730
|
+
const key = readPropertyKey(property);
|
|
25731
|
+
if (!key)
|
|
25732
|
+
continue;
|
|
25733
|
+
if (!ts8.isPropertyAssignment(property))
|
|
25734
|
+
continue;
|
|
25735
|
+
if (key === "provide" && ts8.isIdentifier(property.initializer) && property.initializer.text === "APP_BASE_HREF") {
|
|
25736
|
+
isAppBaseHref = true;
|
|
25737
|
+
} else if (key === "useValue") {
|
|
25738
|
+
value = readStringLiteral(property.initializer);
|
|
25739
|
+
}
|
|
25740
|
+
}
|
|
25741
|
+
if (isAppBaseHref && value !== null) {
|
|
25742
|
+
found = value;
|
|
25743
|
+
return;
|
|
25744
|
+
}
|
|
25745
|
+
}
|
|
25746
|
+
ts8.forEachChild(node, visit);
|
|
25747
|
+
};
|
|
25748
|
+
ts8.forEachChild(sf, visit);
|
|
25749
|
+
return found;
|
|
25750
|
+
}, analyzeFile = async (filePath) => {
|
|
25751
|
+
let source;
|
|
25752
|
+
try {
|
|
25753
|
+
source = await fs2.readFile(filePath, "utf-8");
|
|
25754
|
+
} catch {
|
|
25755
|
+
return null;
|
|
25756
|
+
}
|
|
25757
|
+
if (!source.includes("APP_BASE_HREF") || !source.includes("provideRouter")) {
|
|
25758
|
+
return null;
|
|
25759
|
+
}
|
|
25760
|
+
const sf = ts8.createSourceFile(filePath, source, ts8.ScriptTarget.Latest, true, ts8.ScriptKind.TS);
|
|
25761
|
+
if (!importsSymbolFrom(sf, "APP_BASE_HREF", "@angular/common"))
|
|
25762
|
+
return null;
|
|
25763
|
+
if (!importsSymbolFrom(sf, "provideRouter", "@angular/router"))
|
|
25764
|
+
return null;
|
|
25765
|
+
const baseHref = findAppBaseHrefValue(sf);
|
|
25766
|
+
if (!baseHref)
|
|
25767
|
+
return null;
|
|
25768
|
+
const firstArg = findProvideRouterFirstArg(sf);
|
|
25769
|
+
if (!firstArg)
|
|
25770
|
+
return null;
|
|
25771
|
+
let routesArray = null;
|
|
25772
|
+
if (ts8.isIdentifier(firstArg)) {
|
|
25773
|
+
routesArray = findRoutesArrayDeclaration(sf, firstArg.text);
|
|
25774
|
+
} else if (ts8.isArrayLiteralExpression(firstArg)) {
|
|
25775
|
+
routesArray = firstArg;
|
|
25776
|
+
}
|
|
25777
|
+
if (!routesArray)
|
|
25778
|
+
return null;
|
|
25779
|
+
const routes = [];
|
|
25780
|
+
extractRoutePaths(routesArray, "", false, routes);
|
|
25781
|
+
return {
|
|
25782
|
+
baseHref,
|
|
25783
|
+
routes,
|
|
25784
|
+
sourceFile: filePath
|
|
25785
|
+
};
|
|
25786
|
+
}, walkTsFiles = async (dir, out) => {
|
|
25787
|
+
let items;
|
|
25788
|
+
try {
|
|
25789
|
+
items = await fs2.readdir(dir, { withFileTypes: true });
|
|
25790
|
+
} catch {
|
|
25635
25791
|
return;
|
|
25636
|
-
|
|
25637
|
-
|
|
25638
|
-
|
|
25639
|
-
|
|
25640
|
-
|
|
25792
|
+
}
|
|
25793
|
+
for (const item of items) {
|
|
25794
|
+
if (item.name === "node_modules")
|
|
25795
|
+
continue;
|
|
25796
|
+
if (item.name.startsWith("."))
|
|
25797
|
+
continue;
|
|
25798
|
+
const full = join35(dir, item.name);
|
|
25799
|
+
if (item.isDirectory()) {
|
|
25800
|
+
await walkTsFiles(full, out);
|
|
25801
|
+
} else if (item.isFile() && item.name.endsWith(".ts") && !item.name.endsWith(".d.ts")) {
|
|
25802
|
+
out.push(full);
|
|
25803
|
+
}
|
|
25804
|
+
}
|
|
25805
|
+
}, analyzeAngularSpaRoutes = async (angularDirectory) => {
|
|
25806
|
+
if (!existsSync31(angularDirectory))
|
|
25807
|
+
return [];
|
|
25808
|
+
const tsFiles = [];
|
|
25809
|
+
await walkTsFiles(angularDirectory, tsFiles);
|
|
25810
|
+
const pages = [];
|
|
25811
|
+
await Promise.all(tsFiles.map(async (file5) => {
|
|
25812
|
+
try {
|
|
25813
|
+
const page = await analyzeFile(file5);
|
|
25814
|
+
if (page)
|
|
25815
|
+
pages.push(page);
|
|
25816
|
+
} catch (err) {
|
|
25817
|
+
console.warn(`[sitemap] Angular SPA analysis failed for ${file5}:`, err);
|
|
25818
|
+
}
|
|
25819
|
+
}));
|
|
25820
|
+
return pages;
|
|
25641
25821
|
};
|
|
25642
|
-
var
|
|
25643
|
-
|
|
25822
|
+
var init_staticAnalyzeSpaRoutes = __esm(() => {
|
|
25823
|
+
DYNAMIC_SEGMENT_PATTERN = /^[:*]/;
|
|
25644
25824
|
});
|
|
25645
25825
|
|
|
25646
25826
|
// src/utils/generateSitemap.ts
|
|
@@ -25657,22 +25837,31 @@ var DEFAULT_PRIORITY = 0.8, escapeXml = (str) => str.replace(/&/g, "&").repl
|
|
|
25657
25837
|
return true;
|
|
25658
25838
|
}
|
|
25659
25839
|
return false;
|
|
25660
|
-
}, discoverPageRoutes = (routes, exclude) => {
|
|
25840
|
+
}, stripTrailingWildcard = (path) => path.replace(/\/\*+$/, ""), isWildcardPagePath = (path) => path.endsWith("/*") || path.endsWith("*"), discoverPageRoutes = (routes, exclude) => {
|
|
25661
25841
|
const seen = new Set;
|
|
25662
|
-
|
|
25842
|
+
const out = [];
|
|
25843
|
+
for (const route of routes) {
|
|
25663
25844
|
if (route.method !== "GET")
|
|
25664
|
-
|
|
25665
|
-
if (route.path.includes("
|
|
25666
|
-
|
|
25667
|
-
|
|
25668
|
-
|
|
25669
|
-
|
|
25670
|
-
return false;
|
|
25845
|
+
continue;
|
|
25846
|
+
if (route.path.includes(":"))
|
|
25847
|
+
continue;
|
|
25848
|
+
const mountPath = stripTrailingWildcard(route.path);
|
|
25849
|
+
if (mountPath.includes("*"))
|
|
25850
|
+
continue;
|
|
25671
25851
|
if (!isPageHandler(route.handler))
|
|
25672
|
-
|
|
25673
|
-
seen.
|
|
25674
|
-
|
|
25675
|
-
|
|
25852
|
+
continue;
|
|
25853
|
+
if (seen.has(mountPath))
|
|
25854
|
+
continue;
|
|
25855
|
+
if (isExcluded(mountPath, exclude))
|
|
25856
|
+
continue;
|
|
25857
|
+
seen.add(mountPath);
|
|
25858
|
+
out.push({
|
|
25859
|
+
emitTopLevel: !isWildcardPagePath(route.path),
|
|
25860
|
+
mountPath,
|
|
25861
|
+
rawPath: route.path
|
|
25862
|
+
});
|
|
25863
|
+
}
|
|
25864
|
+
return out;
|
|
25676
25865
|
}, joinMountAndSubPath = (mount, sub) => {
|
|
25677
25866
|
const trimmedMount = mount.replace(/\/+$/, "");
|
|
25678
25867
|
const trimmedSub = sub.replace(/^\/+/, "");
|
|
@@ -25681,27 +25870,30 @@ var DEFAULT_PRIORITY = 0.8, escapeXml = (str) => str.replace(/&/g, "&").repl
|
|
|
25681
25870
|
if (!trimmedMount)
|
|
25682
25871
|
return `/${trimmedSub}`;
|
|
25683
25872
|
return `${trimmedMount}/${trimmedSub}`;
|
|
25873
|
+
}, normalizeMountFromBaseHref = (baseHref) => {
|
|
25874
|
+
const stripped = baseHref.replace(/\/+$/, "");
|
|
25875
|
+
return stripped === "" ? "/" : stripped;
|
|
25684
25876
|
}, buildSitemapXml = (entries, baseUrl, config) => {
|
|
25685
25877
|
const normalizedBase = baseUrl.replace(/\/$/, "");
|
|
25686
25878
|
const xml = [];
|
|
25687
25879
|
for (const entry of entries) {
|
|
25688
25880
|
const override = config.overrides?.[entry.path];
|
|
25689
|
-
const changefreq = override?.changefreq ??
|
|
25690
|
-
const priority = override?.priority ??
|
|
25691
|
-
const lastmod = override?.lastmod
|
|
25881
|
+
const changefreq = override?.changefreq ?? config.defaultChangefreq ?? "weekly";
|
|
25882
|
+
const priority = override?.priority ?? config.defaultPriority ?? DEFAULT_PRIORITY;
|
|
25883
|
+
const lastmod = override?.lastmod;
|
|
25692
25884
|
const url = escapeXml(`${normalizedBase}${entry.path}`);
|
|
25693
|
-
let
|
|
25885
|
+
let block = ` <url>
|
|
25694
25886
|
<loc>${url}</loc>`;
|
|
25695
25887
|
if (lastmod)
|
|
25696
|
-
|
|
25888
|
+
block += `
|
|
25697
25889
|
<lastmod>${lastmod}</lastmod>`;
|
|
25698
|
-
|
|
25890
|
+
block += `
|
|
25699
25891
|
<changefreq>${changefreq}</changefreq>`;
|
|
25700
|
-
|
|
25892
|
+
block += `
|
|
25701
25893
|
<priority>${priority}</priority>`;
|
|
25702
|
-
|
|
25894
|
+
block += `
|
|
25703
25895
|
</url>`;
|
|
25704
|
-
xml.push(
|
|
25896
|
+
xml.push(block);
|
|
25705
25897
|
}
|
|
25706
25898
|
return [
|
|
25707
25899
|
'<?xml version="1.0" encoding="UTF-8"?>',
|
|
@@ -25710,59 +25902,60 @@ var DEFAULT_PRIORITY = 0.8, escapeXml = (str) => str.replace(/&/g, "&").repl
|
|
|
25710
25902
|
"</urlset>"
|
|
25711
25903
|
].join(`
|
|
25712
25904
|
`);
|
|
25713
|
-
},
|
|
25714
|
-
|
|
25715
|
-
|
|
25716
|
-
|
|
25717
|
-
|
|
25718
|
-
|
|
25719
|
-
|
|
25720
|
-
|
|
25721
|
-
|
|
25722
|
-
|
|
25723
|
-
|
|
25724
|
-
method: "GET"
|
|
25725
|
-
});
|
|
25726
|
-
return collectSpaRoutes(async () => {
|
|
25727
|
-
try {
|
|
25728
|
-
await app.handle(request);
|
|
25729
|
-
} catch (err) {
|
|
25730
|
-
console.warn(`[sitemap] enumeration request failed for ${route.path}:`, err);
|
|
25731
|
-
}
|
|
25732
|
-
});
|
|
25733
|
-
}, generateSitemap = async (app, serverUrl, outDir, config = {}) => {
|
|
25734
|
-
const exclude = config.exclude ?? [];
|
|
25735
|
-
const pageRoutes = discoverPageRoutes(app.routes, exclude);
|
|
25736
|
-
const entries = [];
|
|
25737
|
-
const seenPaths = new Set;
|
|
25738
|
-
for (const route of pageRoutes) {
|
|
25739
|
-
if (!seenPaths.has(route.path)) {
|
|
25740
|
-
entries.push({ path: route.path });
|
|
25741
|
-
seenPaths.add(route.path);
|
|
25742
|
-
}
|
|
25743
|
-
const subRoutes = await collectPageSubRoutes(app, route, serverUrl);
|
|
25744
|
-
for (const sub of subRoutes) {
|
|
25745
|
-
if (sub.dynamic)
|
|
25905
|
+
}, collectAngularSpaEntries = async (pages, discovered, exclude, seenPaths) => {
|
|
25906
|
+
const wildcardMounts = new Set(discovered.filter((page) => !page.emitTopLevel).map((page) => page.mountPath));
|
|
25907
|
+
const out = [];
|
|
25908
|
+
for (const page of pages) {
|
|
25909
|
+
const mount = normalizeMountFromBaseHref(page.baseHref);
|
|
25910
|
+
if (!wildcardMounts.has(mount))
|
|
25911
|
+
continue;
|
|
25912
|
+
for (const route of page.routes) {
|
|
25913
|
+
if (route.dynamic)
|
|
25914
|
+
continue;
|
|
25915
|
+
if (route.redirected)
|
|
25746
25916
|
continue;
|
|
25747
|
-
if (
|
|
25917
|
+
if (route.sitemapExcluded)
|
|
25748
25918
|
continue;
|
|
25749
|
-
const fullPath = joinMountAndSubPath(
|
|
25919
|
+
const fullPath = joinMountAndSubPath(mount, route.path);
|
|
25750
25920
|
if (seenPaths.has(fullPath))
|
|
25751
25921
|
continue;
|
|
25752
25922
|
if (isExcluded(fullPath, exclude))
|
|
25753
25923
|
continue;
|
|
25754
|
-
entries.push({ path: fullPath, ...resolveSpaEntryMetadata(sub) });
|
|
25755
25924
|
seenPaths.add(fullPath);
|
|
25925
|
+
out.push({ path: fullPath });
|
|
25756
25926
|
}
|
|
25757
25927
|
}
|
|
25758
|
-
|
|
25759
|
-
|
|
25928
|
+
return out;
|
|
25929
|
+
}, generateSitemap = async (routes, serverUrl, outDir, config = {}, pipelineConfig = {}) => {
|
|
25930
|
+
const exclude = config.exclude ?? [];
|
|
25931
|
+
const discoveredPages = discoverPageRoutes(routes, exclude);
|
|
25932
|
+
const seenPaths = new Set;
|
|
25933
|
+
const entries = [];
|
|
25934
|
+
for (const page of discoveredPages) {
|
|
25935
|
+
if (!page.emitTopLevel)
|
|
25936
|
+
continue;
|
|
25937
|
+
if (seenPaths.has(page.mountPath))
|
|
25938
|
+
continue;
|
|
25939
|
+
seenPaths.add(page.mountPath);
|
|
25940
|
+
entries.push({ path: page.mountPath });
|
|
25941
|
+
}
|
|
25942
|
+
if (pipelineConfig.angularDirectory) {
|
|
25943
|
+
try {
|
|
25944
|
+
const angularPages = await analyzeAngularSpaRoutes(pipelineConfig.angularDirectory);
|
|
25945
|
+
const spaEntries = await collectAngularSpaEntries(angularPages, discoveredPages, exclude, seenPaths);
|
|
25946
|
+
entries.push(...spaEntries);
|
|
25947
|
+
} catch (err) {
|
|
25948
|
+
console.warn("[sitemap] Angular SPA analysis failed:", err);
|
|
25949
|
+
}
|
|
25950
|
+
}
|
|
25951
|
+
const dynamicRoutes = config.routes ? await config.routes() : [];
|
|
25952
|
+
for (const path of dynamicRoutes) {
|
|
25760
25953
|
if (seenPaths.has(path))
|
|
25761
25954
|
continue;
|
|
25762
25955
|
if (isExcluded(path, exclude))
|
|
25763
25956
|
continue;
|
|
25764
|
-
entries.push({ path });
|
|
25765
25957
|
seenPaths.add(path);
|
|
25958
|
+
entries.push({ path });
|
|
25766
25959
|
}
|
|
25767
25960
|
const baseUrl = config.baseUrl ?? serverUrl;
|
|
25768
25961
|
const xml = buildSitemapXml(entries, baseUrl, config);
|
|
@@ -25770,7 +25963,7 @@ var DEFAULT_PRIORITY = 0.8, escapeXml = (str) => str.replace(/&/g, "&").repl
|
|
|
25770
25963
|
};
|
|
25771
25964
|
var init_generateSitemap = __esm(() => {
|
|
25772
25965
|
init_devRouteRegistrationCallsite();
|
|
25773
|
-
|
|
25966
|
+
init_staticAnalyzeSpaRoutes();
|
|
25774
25967
|
});
|
|
25775
25968
|
|
|
25776
25969
|
// src/core/prerender.ts
|
|
@@ -25784,7 +25977,7 @@ __export(exports_prerender, {
|
|
|
25784
25977
|
PRERENDER_BYPASS_HEADER: () => PRERENDER_BYPASS_HEADER
|
|
25785
25978
|
});
|
|
25786
25979
|
import { mkdirSync as mkdirSync16, readFileSync as readFileSync23 } from "fs";
|
|
25787
|
-
import { join as
|
|
25980
|
+
import { join as join36 } from "path";
|
|
25788
25981
|
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) => {
|
|
25789
25982
|
const metaPath = htmlPath.replace(/\.html$/, ".meta");
|
|
25790
25983
|
await Bun.write(metaPath, String(Date.now()));
|
|
@@ -25850,7 +26043,7 @@ var SERVER_OUTPUT_LIMIT = 4000, STARTUP_POLL_INTERVAL_MS = 100, DEFAULT_STARTUP_
|
|
|
25850
26043
|
return false;
|
|
25851
26044
|
const html = await res.text();
|
|
25852
26045
|
const fileName = routeToFilename(route);
|
|
25853
|
-
const filePath =
|
|
26046
|
+
const filePath = join36(prerenderDir, fileName);
|
|
25854
26047
|
await Bun.write(filePath, html);
|
|
25855
26048
|
await writeTimestamp(filePath);
|
|
25856
26049
|
return true;
|
|
@@ -25876,13 +26069,13 @@ var SERVER_OUTPUT_LIMIT = 4000, STARTUP_POLL_INTERVAL_MS = 100, DEFAULT_STARTUP_
|
|
|
25876
26069
|
}
|
|
25877
26070
|
const html = await res.text();
|
|
25878
26071
|
const fileName = routeToFilename(route);
|
|
25879
|
-
const filePath =
|
|
26072
|
+
const filePath = join36(prerenderDir, fileName);
|
|
25880
26073
|
await Bun.write(filePath, html);
|
|
25881
26074
|
await writeTimestamp(filePath);
|
|
25882
26075
|
result.routes.set(route, filePath);
|
|
25883
26076
|
log2?.(` Pre-rendered ${route} \u2192 ${fileName} (${html.length} bytes)`);
|
|
25884
26077
|
}, prerender = async (port, outDir, staticConfig, log2) => {
|
|
25885
|
-
const prerenderDir =
|
|
26078
|
+
const prerenderDir = join36(outDir, "_prerendered");
|
|
25886
26079
|
mkdirSync16(prerenderDir, { recursive: true });
|
|
25887
26080
|
const baseUrl = `http://localhost:${port}`;
|
|
25888
26081
|
let routes;
|
|
@@ -25982,14 +26175,14 @@ __export(exports_serverEntryWatcher, {
|
|
|
25982
26175
|
startServerEntryWatcher: () => startServerEntryWatcher,
|
|
25983
26176
|
isAtomicWriteTemp: () => isAtomicWriteTemp
|
|
25984
26177
|
});
|
|
25985
|
-
import { existsSync as
|
|
26178
|
+
import { existsSync as existsSync34, statSync as statSync8, watch as watch2 } from "fs";
|
|
25986
26179
|
import { createRequire as createRequire2 } from "module";
|
|
25987
|
-
import { dirname as dirname26, join as
|
|
26180
|
+
import { dirname as dirname26, join as join39, resolve as resolve46 } from "path";
|
|
25988
26181
|
var ATOMIC_RECOVERY_WINDOW_MS = 1000, RELOAD_DEBOUNCE_MS = 80, ATOMIC_WRITE_TEMP_PATTERNS2, isAtomicWriteTemp = (filename) => filename.endsWith(".tmp") || filename.includes(".tmp.") || filename.endsWith("~") || filename.startsWith(".#") || ATOMIC_WRITE_TEMP_PATTERNS2.some((re2) => re2.test(filename)), startServerEntryWatcher = () => {
|
|
25989
26182
|
if (globalThis.__absoluteEntryWatcherStarted)
|
|
25990
26183
|
return;
|
|
25991
26184
|
const main = Bun.main;
|
|
25992
|
-
if (!main || !
|
|
26185
|
+
if (!main || !existsSync34(main))
|
|
25993
26186
|
return;
|
|
25994
26187
|
globalThis.__absoluteEntryWatcherStarted = true;
|
|
25995
26188
|
const entryPath = resolve46(main);
|
|
@@ -26087,7 +26280,7 @@ var ATOMIC_RECOVERY_WINDOW_MS = 1000, RELOAD_DEBOUNCE_MS = 80, ATOMIC_WRITE_TEMP
|
|
|
26087
26280
|
continue;
|
|
26088
26281
|
let st2;
|
|
26089
26282
|
try {
|
|
26090
|
-
st2 = statSync8(
|
|
26283
|
+
st2 = statSync8(join39(dir, entry.name));
|
|
26091
26284
|
} catch {
|
|
26092
26285
|
continue;
|
|
26093
26286
|
}
|
|
@@ -26642,8 +26835,8 @@ var handleHTMXPageRequest = async (pagePath) => {
|
|
|
26642
26835
|
};
|
|
26643
26836
|
// src/core/prepare.ts
|
|
26644
26837
|
init_loadConfig();
|
|
26645
|
-
import { existsSync as
|
|
26646
|
-
import { basename as basename14, join as
|
|
26838
|
+
import { existsSync as existsSync32, readdirSync as readdirSync4, readFileSync as readFileSync24 } from "fs";
|
|
26839
|
+
import { basename as basename14, join as join37, relative as relative17, resolve as resolve45 } from "path";
|
|
26647
26840
|
import { Elysia as Elysia5 } from "elysia";
|
|
26648
26841
|
|
|
26649
26842
|
// src/core/loadIslandRegistry.ts
|
|
@@ -27042,7 +27235,7 @@ var patchManifestIndexes = (manifest, devIndexDir, SRC_URL_PREFIX2) => {
|
|
|
27042
27235
|
if (!fileName)
|
|
27043
27236
|
continue;
|
|
27044
27237
|
const srcPath = resolve45(devIndexDir, fileName);
|
|
27045
|
-
if (!
|
|
27238
|
+
if (!existsSync32(srcPath))
|
|
27046
27239
|
continue;
|
|
27047
27240
|
const rel = relative17(process.cwd(), srcPath).replace(/\\/g, "/");
|
|
27048
27241
|
manifest[key] = `${SRC_URL_PREFIX2}${rel}`;
|
|
@@ -27140,7 +27333,9 @@ var prepareDev = async (config, buildDir) => {
|
|
|
27140
27333
|
maxAge: null,
|
|
27141
27334
|
prefix: "",
|
|
27142
27335
|
staticLimit: MAX_STATIC_ROUTE_COUNT
|
|
27143
|
-
})).use(hmrPlugin).use(createSitemapPlugin(buildDir, config.sitemap
|
|
27336
|
+
})).use(hmrPlugin).use(createSitemapPlugin(buildDir, config.sitemap, {
|
|
27337
|
+
angularDirectory: config.angularDirectory
|
|
27338
|
+
})).use(createBuildErrorRecoveryPlugin()).use(createNotFoundPlugin());
|
|
27144
27339
|
recordStep("assemble dev runtime", stepStartedAt);
|
|
27145
27340
|
logStartupTimingBlock("AbsoluteJS prepareDev timing", startupSteps);
|
|
27146
27341
|
return {
|
|
@@ -27150,7 +27345,7 @@ var prepareDev = async (config, buildDir) => {
|
|
|
27150
27345
|
};
|
|
27151
27346
|
var loadPrerenderMap = (prerenderDir) => {
|
|
27152
27347
|
const map = new Map;
|
|
27153
|
-
if (!
|
|
27348
|
+
if (!existsSync32(prerenderDir))
|
|
27154
27349
|
return map;
|
|
27155
27350
|
let entries;
|
|
27156
27351
|
try {
|
|
@@ -27163,15 +27358,15 @@ var loadPrerenderMap = (prerenderDir) => {
|
|
|
27163
27358
|
continue;
|
|
27164
27359
|
const name = basename14(entry, ".html");
|
|
27165
27360
|
const route = name === "index" ? "/" : `/${name}`;
|
|
27166
|
-
map.set(route,
|
|
27361
|
+
map.set(route, join37(prerenderDir, entry));
|
|
27167
27362
|
}
|
|
27168
27363
|
return map;
|
|
27169
27364
|
};
|
|
27170
|
-
var createSitemapPlugin = (buildDir, sitemapConfig) => new Elysia5({ name: "absolutejs-sitemap" }).onStart((started) => {
|
|
27365
|
+
var createSitemapPlugin = (buildDir, sitemapConfig, pipelineConfig) => new Elysia5({ name: "absolutejs-sitemap" }).onStart((started) => {
|
|
27171
27366
|
const { server } = started;
|
|
27172
27367
|
if (!server)
|
|
27173
27368
|
return;
|
|
27174
|
-
Promise.resolve().then(() => (init_generateSitemap(), exports_generateSitemap)).then(({ generateSitemap: generateSitemap2 }) => generateSitemap2(started, server.url.origin, buildDir, sitemapConfig)).catch((err) => console.error("[sitemap] Generation failed:", err));
|
|
27369
|
+
Promise.resolve().then(() => (init_generateSitemap(), exports_generateSitemap)).then(({ generateSitemap: generateSitemap2 }) => generateSitemap2(started.routes, server.url.origin, buildDir, sitemapConfig, pipelineConfig)).catch((err) => console.error("[sitemap] Generation failed:", err));
|
|
27175
27370
|
});
|
|
27176
27371
|
var createNotFoundPlugin = () => new Elysia5({ name: "absolutejs-not-found" }).onError({ as: "global" }, async ({ code }) => {
|
|
27177
27372
|
if (code !== "NOT_FOUND")
|
|
@@ -27229,8 +27424,8 @@ var prepare = async (configOrPath) => {
|
|
|
27229
27424
|
setCurrentPageIslandMetadata(await loadPageIslandMetadata(config));
|
|
27230
27425
|
recordStep("load production manifest and island metadata", stepStartedAt);
|
|
27231
27426
|
stepStartedAt = performance.now();
|
|
27232
|
-
const conventionsPath =
|
|
27233
|
-
if (
|
|
27427
|
+
const conventionsPath = join37(buildDir, "conventions.json");
|
|
27428
|
+
if (existsSync32(conventionsPath)) {
|
|
27234
27429
|
const conventions2 = JSON.parse(readFileSync24(conventionsPath, "utf-8"));
|
|
27235
27430
|
setConventions(conventions2);
|
|
27236
27431
|
}
|
|
@@ -27245,7 +27440,7 @@ var prepare = async (configOrPath) => {
|
|
|
27245
27440
|
});
|
|
27246
27441
|
recordStep("create static plugin", stepStartedAt);
|
|
27247
27442
|
stepStartedAt = performance.now();
|
|
27248
|
-
const prerenderDir =
|
|
27443
|
+
const prerenderDir = join37(buildDir, "_prerendered");
|
|
27249
27444
|
const prerenderMap = loadPrerenderMap(prerenderDir);
|
|
27250
27445
|
recordStep("load prerender map", stepStartedAt);
|
|
27251
27446
|
if (prerenderMap.size > 0) {
|
|
@@ -27276,14 +27471,18 @@ var prepare = async (configOrPath) => {
|
|
|
27276
27471
|
});
|
|
27277
27472
|
stepStartedAt = performance.now();
|
|
27278
27473
|
const { imageOptimizer: imageOptimizer3 } = await Promise.resolve().then(() => (init_imageOptimizer(), exports_imageOptimizer));
|
|
27279
|
-
const absolutejs2 = new Elysia5({ name: "absolutejs-runtime" }).use(imageOptimizer3(config.images, buildDir)).use(prerenderPlugin).use(staticFiles).use(createSitemapPlugin(buildDir, config.sitemap
|
|
27474
|
+
const absolutejs2 = new Elysia5({ name: "absolutejs-runtime" }).use(imageOptimizer3(config.images, buildDir)).use(prerenderPlugin).use(staticFiles).use(createSitemapPlugin(buildDir, config.sitemap, {
|
|
27475
|
+
angularDirectory: config.angularDirectory
|
|
27476
|
+
})).use(createNotFoundPlugin());
|
|
27280
27477
|
recordStep("assemble production runtime", stepStartedAt);
|
|
27281
27478
|
logStartupTimingBlock("AbsoluteJS prepare timing", startupSteps);
|
|
27282
27479
|
return { absolutejs: absolutejs2, manifest };
|
|
27283
27480
|
}
|
|
27284
27481
|
stepStartedAt = performance.now();
|
|
27285
27482
|
const { imageOptimizer: imageOptimizer2 } = await Promise.resolve().then(() => (init_imageOptimizer(), exports_imageOptimizer));
|
|
27286
|
-
const absolutejs = new Elysia5({ name: "absolutejs-runtime" }).use(imageOptimizer2(config.images, buildDir)).use(staticFiles).use(createSitemapPlugin(buildDir, config.sitemap
|
|
27483
|
+
const absolutejs = new Elysia5({ name: "absolutejs-runtime" }).use(imageOptimizer2(config.images, buildDir)).use(staticFiles).use(createSitemapPlugin(buildDir, config.sitemap, {
|
|
27484
|
+
angularDirectory: config.angularDirectory
|
|
27485
|
+
})).use(createNotFoundPlugin());
|
|
27287
27486
|
recordStep("assemble production runtime", stepStartedAt);
|
|
27288
27487
|
logStartupTimingBlock("AbsoluteJS prepare timing", startupSteps);
|
|
27289
27488
|
return { absolutejs, manifest };
|
|
@@ -27303,15 +27502,15 @@ import { argv } from "process";
|
|
|
27303
27502
|
var {env: env4 } = globalThis.Bun;
|
|
27304
27503
|
|
|
27305
27504
|
// src/dev/devCert.ts
|
|
27306
|
-
import { existsSync as
|
|
27307
|
-
import { join as
|
|
27308
|
-
var CERT_DIR =
|
|
27309
|
-
var CERT_PATH =
|
|
27310
|
-
var KEY_PATH =
|
|
27505
|
+
import { existsSync as existsSync33, mkdirSync as mkdirSync17, readFileSync as readFileSync25, rmSync as rmSync4 } from "fs";
|
|
27506
|
+
import { join as join38 } from "path";
|
|
27507
|
+
var CERT_DIR = join38(process.cwd(), ".absolutejs");
|
|
27508
|
+
var CERT_PATH = join38(CERT_DIR, "cert.pem");
|
|
27509
|
+
var KEY_PATH = join38(CERT_DIR, "key.pem");
|
|
27311
27510
|
var CERT_VALIDITY_DAYS = 365;
|
|
27312
27511
|
var devLog = (msg) => console.log(`\x1B[2m${new Date().toLocaleTimeString()}\x1B[0m \x1B[36m[dev]\x1B[0m ${msg}`);
|
|
27313
27512
|
var devWarn = (msg) => console.log(`\x1B[2m${new Date().toLocaleTimeString()}\x1B[0m \x1B[33m[dev]\x1B[0m \x1B[33m${msg}\x1B[0m`);
|
|
27314
|
-
var certFilesExist = () =>
|
|
27513
|
+
var certFilesExist = () => existsSync33(CERT_PATH) && existsSync33(KEY_PATH);
|
|
27315
27514
|
var isCertExpired = () => {
|
|
27316
27515
|
try {
|
|
27317
27516
|
const certPem = readFileSync25(CERT_PATH, "utf-8");
|
|
@@ -27686,7 +27885,7 @@ var generateHeadElement = ({
|
|
|
27686
27885
|
};
|
|
27687
27886
|
// src/utils/defineEnv.ts
|
|
27688
27887
|
var {env: bunEnv } = globalThis.Bun;
|
|
27689
|
-
import { existsSync as
|
|
27888
|
+
import { existsSync as existsSync35, readFileSync as readFileSync26 } from "fs";
|
|
27690
27889
|
import { resolve as resolve47 } from "path";
|
|
27691
27890
|
|
|
27692
27891
|
// node_modules/@sinclair/typebox/build/esm/type/guard/value.mjs
|
|
@@ -33723,7 +33922,7 @@ ${lines.join(`
|
|
|
33723
33922
|
var checkEnvFileSecurity = (properties) => {
|
|
33724
33923
|
const cwd2 = process.cwd();
|
|
33725
33924
|
const envPath = resolve47(cwd2, ".env");
|
|
33726
|
-
if (!
|
|
33925
|
+
if (!existsSync35(envPath))
|
|
33727
33926
|
return;
|
|
33728
33927
|
const sensitiveKeys = Object.keys(properties).filter(isSensitive);
|
|
33729
33928
|
if (sensitiveKeys.length === 0)
|
|
@@ -33733,7 +33932,7 @@ var checkEnvFileSecurity = (properties) => {
|
|
|
33733
33932
|
if (presentKeys.length === 0)
|
|
33734
33933
|
return;
|
|
33735
33934
|
const gitignorePath = resolve47(cwd2, ".gitignore");
|
|
33736
|
-
if (
|
|
33935
|
+
if (existsSync35(gitignorePath)) {
|
|
33737
33936
|
const gitignore = readFileSync26(gitignorePath, "utf-8");
|
|
33738
33937
|
if (gitignore.split(`
|
|
33739
33938
|
`).some((line) => line.trim() === ".env"))
|
|
@@ -33975,5 +34174,5 @@ export {
|
|
|
33975
34174
|
ANGULAR_INIT_TIMEOUT_MS
|
|
33976
34175
|
};
|
|
33977
34176
|
|
|
33978
|
-
//# debugId=
|
|
34177
|
+
//# debugId=CBA359F82BDAEEE464756E2164756E21
|
|
33979
34178
|
//# sourceMappingURL=index.js.map
|