@absolutejs/absolute 0.19.0-beta.692 → 0.19.0-beta.694
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/index.js +354 -140
- package/dist/angular/index.js.map +4 -4
- package/dist/angular/server.js +336 -122
- package/dist/angular/server.js.map +4 -4
- package/dist/build.js +667 -442
- package/dist/build.js.map +11 -11
- package/dist/index.js +736 -510
- package/dist/index.js.map +12 -12
- package/dist/islands/index.js +270 -56
- package/dist/islands/index.js.map +3 -3
- package/dist/react/index.js +270 -56
- package/dist/react/index.js.map +3 -3
- package/dist/src/build/compileAngular.d.ts +4 -3
- package/dist/src/build/compileSvelte.d.ts +2 -1
- package/dist/src/build/compileVue.d.ts +2 -1
- package/dist/src/build/stylePreprocessor.d.ts +6 -4
- package/dist/src/core/build.d.ts +1 -1
- package/dist/src/dev/moduleServer.d.ts +2 -0
- package/dist/svelte/index.js +284 -70
- package/dist/svelte/index.js.map +3 -3
- package/dist/svelte/server.js +275 -61
- package/dist/svelte/server.js.map +3 -3
- package/dist/types/build.d.ts +45 -0
- package/dist/vue/index.js +270 -56
- package/dist/vue/index.js.map +3 -3
- package/package.json +12 -7
package/dist/angular/index.js
CHANGED
|
@@ -1352,10 +1352,12 @@ var init_lowerAwaitSlotSyntax = __esm(() => {
|
|
|
1352
1352
|
});
|
|
1353
1353
|
|
|
1354
1354
|
// src/build/stylePreprocessor.ts
|
|
1355
|
+
import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
|
|
1355
1356
|
import { readFile } from "fs/promises";
|
|
1356
1357
|
import { createRequire } from "module";
|
|
1357
|
-
import { dirname as dirname2, extname, join as join3 } from "path";
|
|
1358
|
-
|
|
1358
|
+
import { dirname as dirname2, extname, isAbsolute, join as join3, relative, resolve as resolve4 } from "path";
|
|
1359
|
+
import { fileURLToPath } from "url";
|
|
1360
|
+
var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATTERN, importOptionalPeer, requireOptionalPeer, requireFromCwd, isPreprocessableStylePath = (filePath) => STYLE_EXTENSION_PATTERN.test(filePath), isStyleModulePath = (filePath) => STYLE_MODULE_EXTENSION_PATTERN.test(filePath), isStylePath = (filePath) => /\.(css|s[ac]ss|less|styl(?:us)?)$/i.test(filePath), getStyleBaseName = (filePath) => filePath.replace(/\.(css|s[ac]ss|less|styl(?:us)?)$/i, ""), getStyleLanguage = (filePathOrLanguage) => {
|
|
1359
1361
|
const normalized = filePathOrLanguage.toLowerCase();
|
|
1360
1362
|
if (normalized === "scss" || normalized.endsWith(".scss"))
|
|
1361
1363
|
return "scss";
|
|
@@ -1363,19 +1365,214 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
|
|
|
1363
1365
|
return "sass";
|
|
1364
1366
|
if (normalized === "less" || normalized.endsWith(".less"))
|
|
1365
1367
|
return "less";
|
|
1368
|
+
if (normalized === "styl" || normalized === "stylus" || normalized.endsWith(".styl") || normalized.endsWith(".stylus"))
|
|
1369
|
+
return "stylus";
|
|
1366
1370
|
return null;
|
|
1367
|
-
}, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`),
|
|
1371
|
+
}, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), normalizeLoadPaths = (filePath, paths = []) => [
|
|
1372
|
+
dirname2(filePath),
|
|
1373
|
+
process.cwd(),
|
|
1374
|
+
...paths.map((path) => resolve4(process.cwd(), path))
|
|
1375
|
+
], tsconfigAliasCache, stripJsonComments = (source) => source.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1"), normalizeAliasEntries = (aliases) => Object.entries(aliases ?? {}).map(([pattern, value]) => ({
|
|
1376
|
+
pattern,
|
|
1377
|
+
replacements: Array.isArray(value) ? value : [value]
|
|
1378
|
+
})), readTsconfigAliases = () => {
|
|
1379
|
+
const cwd = process.cwd();
|
|
1380
|
+
if (tsconfigAliasCache?.cwd === cwd)
|
|
1381
|
+
return tsconfigAliasCache;
|
|
1382
|
+
const tsconfigPath = resolve4(cwd, "tsconfig.json");
|
|
1383
|
+
const empty = { aliases: [], baseUrl: cwd, cwd };
|
|
1384
|
+
if (!existsSync4(tsconfigPath)) {
|
|
1385
|
+
tsconfigAliasCache = empty;
|
|
1386
|
+
return empty;
|
|
1387
|
+
}
|
|
1388
|
+
try {
|
|
1389
|
+
const parsed = JSON.parse(stripJsonComments(readFileSync3(tsconfigPath, "utf-8")));
|
|
1390
|
+
const compilerOptions = parsed.compilerOptions ?? {};
|
|
1391
|
+
const baseUrl = resolve4(cwd, compilerOptions.baseUrl ?? ".");
|
|
1392
|
+
tsconfigAliasCache = {
|
|
1393
|
+
aliases: normalizeAliasEntries(compilerOptions.paths),
|
|
1394
|
+
baseUrl,
|
|
1395
|
+
cwd
|
|
1396
|
+
};
|
|
1397
|
+
} catch {
|
|
1398
|
+
tsconfigAliasCache = empty;
|
|
1399
|
+
}
|
|
1400
|
+
return tsconfigAliasCache;
|
|
1401
|
+
}, getAliasEntries = (config) => {
|
|
1402
|
+
const tsconfig = readTsconfigAliases();
|
|
1403
|
+
return {
|
|
1404
|
+
aliases: [...normalizeAliasEntries(config?.aliases), ...tsconfig.aliases],
|
|
1405
|
+
baseUrl: tsconfig.baseUrl
|
|
1406
|
+
};
|
|
1407
|
+
}, aliasPatternToRegExp = (pattern) => new RegExp(`^${pattern.split("*").map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("(.+)")}$`), resolveAliasTargets = (specifier, config) => {
|
|
1408
|
+
const { aliases, baseUrl } = getAliasEntries(config);
|
|
1409
|
+
const targets = [];
|
|
1410
|
+
for (const alias of aliases) {
|
|
1411
|
+
const match = specifier.match(aliasPatternToRegExp(alias.pattern));
|
|
1412
|
+
if (!match)
|
|
1413
|
+
continue;
|
|
1414
|
+
const wildcard = match[1] ?? "";
|
|
1415
|
+
for (const replacement of alias.replacements) {
|
|
1416
|
+
targets.push(resolve4(baseUrl, replacement.replace("*", wildcard)));
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
return targets;
|
|
1420
|
+
}, getLanguageExtensions = (language) => {
|
|
1421
|
+
if (language === "less")
|
|
1422
|
+
return [".less", ".css"];
|
|
1423
|
+
if (language === "stylus")
|
|
1424
|
+
return [".styl", ".stylus", ".css"];
|
|
1425
|
+
return [".scss", ".sass", ".css"];
|
|
1426
|
+
}, getCandidatePaths = (basePath, language) => {
|
|
1427
|
+
const ext = extname(basePath);
|
|
1428
|
+
const paths = ext ? [basePath] : getLanguageExtensions(language).flatMap((extension) => [
|
|
1429
|
+
`${basePath}${extension}`,
|
|
1430
|
+
join3(basePath, `index${extension}`)
|
|
1431
|
+
]);
|
|
1432
|
+
if (language === "scss" || language === "sass") {
|
|
1433
|
+
return paths.flatMap((path) => {
|
|
1434
|
+
const dir = dirname2(path);
|
|
1435
|
+
const base = path.slice(dir.length + 1);
|
|
1436
|
+
return [path, join3(dir, `_${base}`)];
|
|
1437
|
+
});
|
|
1438
|
+
}
|
|
1439
|
+
return paths;
|
|
1440
|
+
}, resolveImportPath = (specifier, fromDirectory, loadPaths, language, config) => {
|
|
1441
|
+
const rawCandidates = [
|
|
1442
|
+
...resolveAliasTargets(specifier, config),
|
|
1443
|
+
isAbsolute(specifier) ? specifier : resolve4(fromDirectory, specifier),
|
|
1444
|
+
...loadPaths.map((path) => resolve4(path, specifier))
|
|
1445
|
+
];
|
|
1446
|
+
for (const candidate of rawCandidates.flatMap((path) => getCandidatePaths(path, language))) {
|
|
1447
|
+
if (existsSync4(candidate))
|
|
1448
|
+
return candidate;
|
|
1449
|
+
}
|
|
1450
|
+
return null;
|
|
1451
|
+
}, isExternalCssUrl = (url) => /^(?:[a-z][a-z0-9+.-]*:|\/\/|#|\/)/i.test(url), splitCssUrl = (url) => {
|
|
1452
|
+
const markerIndex = url.search(/[?#]/);
|
|
1453
|
+
if (markerIndex === -1)
|
|
1454
|
+
return { marker: "", path: url };
|
|
1455
|
+
return {
|
|
1456
|
+
marker: url.slice(markerIndex),
|
|
1457
|
+
path: url.slice(0, markerIndex)
|
|
1458
|
+
};
|
|
1459
|
+
}, rebaseCssUrls = (contents, sourceFile, entryFile) => {
|
|
1460
|
+
const sourceDir = dirname2(sourceFile);
|
|
1461
|
+
const entryDir = dirname2(entryFile);
|
|
1462
|
+
if (sourceDir === entryDir)
|
|
1463
|
+
return contents;
|
|
1464
|
+
return contents.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi, (match, quote, rawUrl) => {
|
|
1465
|
+
const trimmedUrl = rawUrl.trim();
|
|
1466
|
+
if (!trimmedUrl || isExternalCssUrl(trimmedUrl))
|
|
1467
|
+
return match;
|
|
1468
|
+
const { marker, path } = splitCssUrl(trimmedUrl);
|
|
1469
|
+
const rebased = relative(entryDir, resolve4(sourceDir, path)).replace(/\\/g, "/");
|
|
1470
|
+
const normalized = rebased.startsWith(".") ? rebased : `./${rebased}`;
|
|
1471
|
+
const nextQuote = quote || '"';
|
|
1472
|
+
return `url(${nextQuote}${normalized}${marker}${nextQuote})`;
|
|
1473
|
+
});
|
|
1474
|
+
}, rewriteAliasedStyleImports = (contents, sourceFile, loadPaths, language, config) => contents.replace(/(@(?:use|forward|import|require)\s+)(["'])([^"']+)\2/g, (match, prefix, quote, specifier) => {
|
|
1475
|
+
if (specifier.startsWith(".") || isAbsolute(specifier) || isExternalCssUrl(specifier))
|
|
1476
|
+
return match;
|
|
1477
|
+
const resolved = resolveImportPath(specifier, dirname2(sourceFile), loadPaths, language, config);
|
|
1478
|
+
return resolved ? `${prefix}${quote}${resolved}${quote}` : match;
|
|
1479
|
+
}), preprocessLoadedStyle = (contents, sourceFile, entryFile, loadPaths = [], language, config) => {
|
|
1480
|
+
const rebased = rebaseCssUrls(contents, sourceFile, entryFile);
|
|
1481
|
+
return language ? rewriteAliasedStyleImports(rebased, sourceFile, loadPaths, language, config) : rebased;
|
|
1482
|
+
}, extractCssModuleExports = (css) => {
|
|
1483
|
+
const exports = {};
|
|
1484
|
+
const nextCss = css.replace(/:export\s*\{([^}]*)\}/g, (_, body) => {
|
|
1485
|
+
for (const declaration of body.split(";")) {
|
|
1486
|
+
const separator = declaration.indexOf(":");
|
|
1487
|
+
if (separator === -1)
|
|
1488
|
+
continue;
|
|
1489
|
+
const key = declaration.slice(0, separator).trim();
|
|
1490
|
+
const value = declaration.slice(separator + 1).trim();
|
|
1491
|
+
if (key && value)
|
|
1492
|
+
exports[key] = value;
|
|
1493
|
+
}
|
|
1494
|
+
return "";
|
|
1495
|
+
});
|
|
1496
|
+
return { css: nextCss, exports };
|
|
1497
|
+
}, getSassOptions = (config, language) => ({
|
|
1498
|
+
...config?.sass ?? {},
|
|
1499
|
+
...language === "scss" ? config?.scss ?? {} : {}
|
|
1500
|
+
}), getLessOptions = (config) => config?.less ?? {}, getStylusOptions = (config) => config?.stylus ?? {}, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
|
|
1501
|
+
${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, config) => ({
|
|
1502
|
+
canonicalize(specifier, options) {
|
|
1503
|
+
const fromDirectory = options.containingUrl ? dirname2(fileURLToPath(options.containingUrl)) : dirname2(entryFile);
|
|
1504
|
+
const resolved = resolveImportPath(specifier, fromDirectory, loadPaths, language, config);
|
|
1505
|
+
return resolved ? new URL(`file://${resolved}`) : null;
|
|
1506
|
+
},
|
|
1507
|
+
load(canonicalUrl) {
|
|
1508
|
+
const filePath = fileURLToPath(canonicalUrl);
|
|
1509
|
+
const fileLanguage = getStyleLanguage(filePath);
|
|
1510
|
+
if (fileLanguage !== "scss" && fileLanguage !== "sass" && fileLanguage !== null)
|
|
1511
|
+
return null;
|
|
1512
|
+
return {
|
|
1513
|
+
contents: preprocessLoadedStyle(readFileSync3(filePath, "utf-8"), filePath, entryFile, loadPaths, language, config),
|
|
1514
|
+
syntax: filePath.endsWith(".sass") ? "indented" : "scss"
|
|
1515
|
+
};
|
|
1516
|
+
}
|
|
1517
|
+
}), createLessFileManager = (entryFile, loadPaths, config) => ({
|
|
1518
|
+
install(less, pluginManager) {
|
|
1519
|
+
const baseManager = new less.FileManager;
|
|
1520
|
+
const manager = Object.create(baseManager);
|
|
1521
|
+
manager.supports = (filename, currentDirectory) => Boolean(resolveImportPath(filename, resolve4(currentDirectory), loadPaths, "less", config));
|
|
1522
|
+
manager.loadFile = async (filename, currentDirectory) => {
|
|
1523
|
+
const resolved = resolveImportPath(filename, resolve4(currentDirectory), loadPaths, "less", config);
|
|
1524
|
+
if (!resolved) {
|
|
1525
|
+
throw new Error(`Unable to resolve Less import "${filename}"`);
|
|
1526
|
+
}
|
|
1527
|
+
return {
|
|
1528
|
+
contents: preprocessLoadedStyle(await readFile(resolved, "utf-8"), resolved, entryFile, loadPaths, "less", config),
|
|
1529
|
+
filename: resolved
|
|
1530
|
+
};
|
|
1531
|
+
};
|
|
1532
|
+
pluginManager.addFileManager(manager);
|
|
1533
|
+
}
|
|
1534
|
+
}), renderStylus = async (contents, filePath, loadPaths, options) => {
|
|
1535
|
+
let stylus;
|
|
1536
|
+
try {
|
|
1537
|
+
const stylusModule = await importOptionalPeer("stylus");
|
|
1538
|
+
stylus = stylusModule.default ?? stylusModule;
|
|
1539
|
+
} catch {
|
|
1540
|
+
throw missingDependencyError("stylus", filePath);
|
|
1541
|
+
}
|
|
1542
|
+
return new Promise((resolveCss, reject) => {
|
|
1543
|
+
const renderer = stylus(contents);
|
|
1544
|
+
renderer.set("filename", filePath);
|
|
1545
|
+
for (const [key, value] of Object.entries(options.options ?? {})) {
|
|
1546
|
+
renderer.set(key, value);
|
|
1547
|
+
}
|
|
1548
|
+
for (const path of loadPaths)
|
|
1549
|
+
renderer.include(path);
|
|
1550
|
+
renderer.render((error, css) => {
|
|
1551
|
+
if (error)
|
|
1552
|
+
reject(error);
|
|
1553
|
+
else
|
|
1554
|
+
resolveCss(css ?? "");
|
|
1555
|
+
});
|
|
1556
|
+
});
|
|
1557
|
+
}, compileStyleSource = async (filePath, source, languageHint, config) => {
|
|
1368
1558
|
const language = getStyleLanguage(languageHint ?? filePath);
|
|
1369
|
-
const
|
|
1559
|
+
const rawContents = source ?? await readFile(filePath, "utf-8");
|
|
1370
1560
|
if (language === "scss" || language === "sass") {
|
|
1561
|
+
const options = getSassOptions(config, language);
|
|
1562
|
+
const packageName = options.implementation ?? "sass";
|
|
1371
1563
|
let sass;
|
|
1372
1564
|
try {
|
|
1373
|
-
sass = await importOptionalPeer(
|
|
1565
|
+
sass = await importOptionalPeer(packageName);
|
|
1374
1566
|
} catch {
|
|
1375
|
-
throw missingDependencyError(
|
|
1567
|
+
throw missingDependencyError(packageName, filePath);
|
|
1376
1568
|
}
|
|
1569
|
+
const contents = withAdditionalData(rawContents, options.additionalData);
|
|
1570
|
+
const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
|
|
1377
1571
|
const result = sass.compileString(contents, {
|
|
1378
|
-
|
|
1572
|
+
importers: [
|
|
1573
|
+
createSassImporter(filePath, loadPaths, language, config)
|
|
1574
|
+
],
|
|
1575
|
+
loadPaths,
|
|
1379
1576
|
style: "expanded",
|
|
1380
1577
|
syntax: language === "sass" ? "indented" : "scss",
|
|
1381
1578
|
url: new URL(`file://${filePath}`)
|
|
@@ -1383,6 +1580,7 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
|
|
|
1383
1580
|
return result.css;
|
|
1384
1581
|
}
|
|
1385
1582
|
if (language === "less") {
|
|
1583
|
+
const options = getLessOptions(config);
|
|
1386
1584
|
let lessModule;
|
|
1387
1585
|
try {
|
|
1388
1586
|
lessModule = await importOptionalPeer("less");
|
|
@@ -1393,14 +1591,63 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
|
|
|
1393
1591
|
const render = less?.render;
|
|
1394
1592
|
if (!render)
|
|
1395
1593
|
throw missingDependencyError("less", filePath);
|
|
1594
|
+
const contents = withAdditionalData(rawContents, options.additionalData);
|
|
1595
|
+
const loadPaths = normalizeLoadPaths(filePath, options.paths);
|
|
1396
1596
|
const result = await render(contents, {
|
|
1597
|
+
...options.options ?? {},
|
|
1397
1598
|
filename: filePath,
|
|
1398
|
-
paths:
|
|
1599
|
+
paths: loadPaths,
|
|
1600
|
+
plugins: [
|
|
1601
|
+
...options.options?.plugins ?? [],
|
|
1602
|
+
createLessFileManager(filePath, loadPaths, config)
|
|
1603
|
+
]
|
|
1399
1604
|
});
|
|
1400
1605
|
return result.css;
|
|
1401
1606
|
}
|
|
1402
|
-
|
|
1403
|
-
|
|
1607
|
+
if (language === "stylus") {
|
|
1608
|
+
const options = getStylusOptions(config);
|
|
1609
|
+
const loadPaths = normalizeLoadPaths(filePath, options.paths);
|
|
1610
|
+
const contents = withAdditionalData(preprocessLoadedStyle(rawContents, filePath, filePath, loadPaths, "stylus", config), options.additionalData);
|
|
1611
|
+
return renderStylus(contents, filePath, loadPaths, options);
|
|
1612
|
+
}
|
|
1613
|
+
return rawContents;
|
|
1614
|
+
}, createStylePreprocessorPlugin = (config) => ({
|
|
1615
|
+
name: "absolute-style-preprocessor",
|
|
1616
|
+
setup(build) {
|
|
1617
|
+
const cssModuleSources = new Map;
|
|
1618
|
+
build.onResolve({ filter: /^absolute-style-module:/ }, ({ path }) => ({
|
|
1619
|
+
namespace: "absolute-style-module",
|
|
1620
|
+
path: path.slice("absolute-style-module:".length)
|
|
1621
|
+
}));
|
|
1622
|
+
build.onLoad({ filter: /\.module\.css$/i, namespace: "absolute-style-module" }, async ({ path }) => {
|
|
1623
|
+
const source = cssModuleSources.get(path);
|
|
1624
|
+
if (!source) {
|
|
1625
|
+
throw new Error(`Unable to resolve CSS module source for ${path}`);
|
|
1626
|
+
}
|
|
1627
|
+
return {
|
|
1628
|
+
contents: source.css,
|
|
1629
|
+
loader: "css"
|
|
1630
|
+
};
|
|
1631
|
+
});
|
|
1632
|
+
build.onLoad({ filter: STYLE_EXTENSION_PATTERN }, async ({ path }) => {
|
|
1633
|
+
if (isStyleModulePath(path)) {
|
|
1634
|
+
const cssModulePath = path.replace(STYLE_EXTENSION_PATTERN, ".css");
|
|
1635
|
+
const compiled = await compileStyleSource(path, undefined, undefined, config);
|
|
1636
|
+
const { css, exports } = extractCssModuleExports(compiled);
|
|
1637
|
+
cssModuleSources.set(cssModulePath, { css, exports });
|
|
1638
|
+
const exportSource = Object.keys(exports).length > 0 ? `import styles from ${JSON.stringify(`absolute-style-module:${cssModulePath}`)}; export default Object.assign({}, styles, ${JSON.stringify(exports)});` : `export { default } from ${JSON.stringify(`absolute-style-module:${cssModulePath}`)};`;
|
|
1639
|
+
return {
|
|
1640
|
+
contents: exportSource,
|
|
1641
|
+
loader: "js"
|
|
1642
|
+
};
|
|
1643
|
+
}
|
|
1644
|
+
return {
|
|
1645
|
+
contents: await compileStyleSource(path, undefined, undefined, config),
|
|
1646
|
+
loader: "css"
|
|
1647
|
+
};
|
|
1648
|
+
});
|
|
1649
|
+
}
|
|
1650
|
+
}), stylePreprocessorPlugin, createSvelteStylePreprocessor = (config) => ({
|
|
1404
1651
|
style: async ({
|
|
1405
1652
|
attributes,
|
|
1406
1653
|
content,
|
|
@@ -1411,63 +1658,30 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
|
|
|
1411
1658
|
return;
|
|
1412
1659
|
const path = filename ?? `style.${language}`;
|
|
1413
1660
|
return {
|
|
1414
|
-
code: await compileStyleSource(path, content, language)
|
|
1661
|
+
code: await compileStyleSource(path, content, language, config)
|
|
1415
1662
|
};
|
|
1416
1663
|
}
|
|
1417
|
-
}), compileStyleFileIfNeeded = async (filePath) => {
|
|
1664
|
+
}), compileStyleFileIfNeeded = async (filePath, config) => {
|
|
1418
1665
|
if (!isPreprocessableStylePath(filePath)) {
|
|
1419
1666
|
return readFile(filePath, "utf-8");
|
|
1420
1667
|
}
|
|
1421
|
-
return compileStyleSource(filePath);
|
|
1668
|
+
return compileStyleSource(filePath, undefined, undefined, config);
|
|
1422
1669
|
};
|
|
1423
1670
|
var init_stylePreprocessor = __esm(() => {
|
|
1424
|
-
STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less)$/i;
|
|
1425
|
-
STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less)$/i;
|
|
1426
|
-
STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less)$/i;
|
|
1671
|
+
STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less|styl(?:us)?)$/i;
|
|
1672
|
+
STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less|styl(?:us)?)$/i;
|
|
1673
|
+
STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less|styl(?:us)?)$/i;
|
|
1427
1674
|
importOptionalPeer = new Function("specifier", "return import(specifier)");
|
|
1428
1675
|
requireOptionalPeer = new Function("specifier", "return require(specifier)");
|
|
1429
1676
|
requireFromCwd = createRequire(join3(process.cwd(), "package.json"));
|
|
1430
|
-
stylePreprocessorPlugin =
|
|
1431
|
-
name: "absolute-style-preprocessor",
|
|
1432
|
-
setup(build) {
|
|
1433
|
-
const cssModuleSources = new Map;
|
|
1434
|
-
build.onResolve({ filter: /^absolute-style-module:/ }, ({ path }) => ({
|
|
1435
|
-
namespace: "absolute-style-module",
|
|
1436
|
-
path: path.slice("absolute-style-module:".length)
|
|
1437
|
-
}));
|
|
1438
|
-
build.onLoad({ filter: /\.module\.css$/i, namespace: "absolute-style-module" }, async ({ path }) => {
|
|
1439
|
-
const sourcePath = cssModuleSources.get(path);
|
|
1440
|
-
if (!sourcePath) {
|
|
1441
|
-
throw new Error(`Unable to resolve CSS module source for ${path}`);
|
|
1442
|
-
}
|
|
1443
|
-
return {
|
|
1444
|
-
contents: await compileStyleSource(sourcePath),
|
|
1445
|
-
loader: "css"
|
|
1446
|
-
};
|
|
1447
|
-
});
|
|
1448
|
-
build.onLoad({ filter: STYLE_EXTENSION_PATTERN }, async ({ path }) => {
|
|
1449
|
-
if (isStyleModulePath(path)) {
|
|
1450
|
-
const cssModulePath = path.replace(STYLE_EXTENSION_PATTERN, ".css");
|
|
1451
|
-
cssModuleSources.set(cssModulePath, path);
|
|
1452
|
-
return {
|
|
1453
|
-
contents: `export { default } from ${JSON.stringify(`absolute-style-module:${cssModulePath}`)};`,
|
|
1454
|
-
loader: "js"
|
|
1455
|
-
};
|
|
1456
|
-
}
|
|
1457
|
-
return {
|
|
1458
|
-
contents: await compileStyleSource(path),
|
|
1459
|
-
loader: "css"
|
|
1460
|
-
};
|
|
1461
|
-
});
|
|
1462
|
-
}
|
|
1463
|
-
};
|
|
1677
|
+
stylePreprocessorPlugin = createStylePreprocessorPlugin();
|
|
1464
1678
|
});
|
|
1465
1679
|
|
|
1466
1680
|
// src/core/svelteServerModule.ts
|
|
1467
1681
|
import { mkdir, readdir } from "fs/promises";
|
|
1468
|
-
import { basename as basename2, dirname as dirname3, extname as extname2, join as join4, relative, resolve as
|
|
1682
|
+
import { basename as basename2, dirname as dirname3, extname as extname2, join as join4, relative as relative2, resolve as resolve5 } from "path";
|
|
1469
1683
|
var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, ensureRelativeImportPath = (from, target) => {
|
|
1470
|
-
const importPath =
|
|
1684
|
+
const importPath = relative2(dirname3(from), target).replace(/\\/g, "/");
|
|
1471
1685
|
return importPath.startsWith(".") ? importPath : `./${importPath}`;
|
|
1472
1686
|
}, processDirectoryEntries = (entries, dir, targetFileName, stack) => {
|
|
1473
1687
|
for (const entry of entries) {
|
|
@@ -1513,7 +1727,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
1513
1727
|
if (!spec.startsWith(".")) {
|
|
1514
1728
|
return null;
|
|
1515
1729
|
}
|
|
1516
|
-
const basePath =
|
|
1730
|
+
const basePath = resolve5(dirname3(from), spec);
|
|
1517
1731
|
const candidates = [
|
|
1518
1732
|
basePath,
|
|
1519
1733
|
`${basePath}.ts`,
|
|
@@ -1531,7 +1745,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
1531
1745
|
const foundIndex = existResults.indexOf(true);
|
|
1532
1746
|
return foundIndex >= 0 ? candidates[foundIndex] ?? null : null;
|
|
1533
1747
|
}, getCachedModulePath = (sourcePath) => {
|
|
1534
|
-
const relativeSourcePath =
|
|
1748
|
+
const relativeSourcePath = relative2(process.cwd(), sourcePath).replace(/\\/g, "/");
|
|
1535
1749
|
const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
|
|
1536
1750
|
return join4(serverCacheRoot, `${normalizedSourcePath}.server.js`);
|
|
1537
1751
|
}, resolveSvelteImport = async (spec, from) => {
|
|
@@ -1545,7 +1759,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
1545
1759
|
if (!spec.startsWith(".")) {
|
|
1546
1760
|
return null;
|
|
1547
1761
|
}
|
|
1548
|
-
const explicitPath =
|
|
1762
|
+
const explicitPath = resolve5(dirname3(from), spec);
|
|
1549
1763
|
if (extname2(explicitPath) === ".svelte") {
|
|
1550
1764
|
return explicitPath;
|
|
1551
1765
|
}
|
|
@@ -2851,12 +3065,12 @@ var init_startupBanner = __esm(() => {
|
|
|
2851
3065
|
// src/utils/logger.ts
|
|
2852
3066
|
var colors2, frameworkColors, formatPath = (filePath) => {
|
|
2853
3067
|
const cwd = process.cwd();
|
|
2854
|
-
let
|
|
2855
|
-
|
|
2856
|
-
if (!
|
|
2857
|
-
|
|
3068
|
+
let relative3 = filePath.startsWith(cwd) ? filePath.slice(cwd.length + 1) : filePath;
|
|
3069
|
+
relative3 = relative3.replace(/\\/g, "/");
|
|
3070
|
+
if (!relative3.startsWith("/")) {
|
|
3071
|
+
relative3 = `/${relative3}`;
|
|
2858
3072
|
}
|
|
2859
|
-
return
|
|
3073
|
+
return relative3;
|
|
2860
3074
|
}, getFrameworkColor = (framework) => frameworkColors[framework] || colors2.white, log = (action, options) => {
|
|
2861
3075
|
const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
|
|
2862
3076
|
const tag = `${colors2.cyan}[hmr]${colors2.reset}`;
|
|
@@ -3518,27 +3732,27 @@ __export(exports_compileAngular, {
|
|
|
3518
3732
|
compileAngularFile: () => compileAngularFile,
|
|
3519
3733
|
compileAngular: () => compileAngular
|
|
3520
3734
|
});
|
|
3521
|
-
import { existsSync as
|
|
3522
|
-
import { join as join5, basename as basename3, sep, dirname as dirname4, resolve as
|
|
3735
|
+
import { existsSync as existsSync5, readFileSync as readFileSync4, promises as fs } from "fs";
|
|
3736
|
+
import { join as join5, basename as basename3, sep, dirname as dirname4, resolve as resolve6, relative as relative3 } from "path";
|
|
3523
3737
|
import ts from "typescript";
|
|
3524
3738
|
import { createHash } from "crypto";
|
|
3525
3739
|
var computeConfigHash = () => {
|
|
3526
3740
|
try {
|
|
3527
|
-
const content =
|
|
3741
|
+
const content = readFileSync4("./tsconfig.json", "utf-8");
|
|
3528
3742
|
return createHash("md5").update(content).digest("hex");
|
|
3529
3743
|
} catch {
|
|
3530
3744
|
return "";
|
|
3531
3745
|
}
|
|
3532
3746
|
}, resolveDevClientDir = () => {
|
|
3533
3747
|
const projectRoot = process.cwd();
|
|
3534
|
-
const fromSource =
|
|
3535
|
-
if (
|
|
3748
|
+
const fromSource = resolve6(import.meta.dir, "../dev/client");
|
|
3749
|
+
if (existsSync5(fromSource) && fromSource.startsWith(projectRoot)) {
|
|
3536
3750
|
return fromSource;
|
|
3537
3751
|
}
|
|
3538
|
-
const fromNodeModules =
|
|
3539
|
-
if (
|
|
3752
|
+
const fromNodeModules = resolve6(projectRoot, "node_modules/@absolutejs/absolute/dist/dev/client");
|
|
3753
|
+
if (existsSync5(fromNodeModules))
|
|
3540
3754
|
return fromNodeModules;
|
|
3541
|
-
return
|
|
3755
|
+
return resolve6(import.meta.dir, "./dev/client");
|
|
3542
3756
|
}, devClientDir, hmrClientPath, hmrRuntimePath, injectHMRRegistration = (content, sourceId) => {
|
|
3543
3757
|
const componentClassRegex = /(?:export\s+)?class\s+(\w+Component)\s/g;
|
|
3544
3758
|
const componentNames = [];
|
|
@@ -3604,7 +3818,7 @@ ${registrations}
|
|
|
3604
3818
|
}, resolveLocalTsImport = (fromFile, specifier) => {
|
|
3605
3819
|
if (!isRelativeModuleSpecifier(specifier))
|
|
3606
3820
|
return null;
|
|
3607
|
-
const basePath =
|
|
3821
|
+
const basePath = resolve6(dirname4(fromFile), specifier);
|
|
3608
3822
|
const candidates = /\.[cm]?[tj]sx?$/.test(basePath) ? [basePath] : [
|
|
3609
3823
|
`${basePath}.ts`,
|
|
3610
3824
|
`${basePath}.tsx`,
|
|
@@ -3615,24 +3829,24 @@ ${registrations}
|
|
|
3615
3829
|
join5(basePath, "index.mts"),
|
|
3616
3830
|
join5(basePath, "index.cts")
|
|
3617
3831
|
];
|
|
3618
|
-
return candidates.map((candidate) =>
|
|
3832
|
+
return candidates.map((candidate) => resolve6(candidate)).find((candidate) => existsSync5(candidate) && !candidate.endsWith(".d.ts")) ?? null;
|
|
3619
3833
|
}, readFileForAotTransform = async (fileName, readFile2) => {
|
|
3620
3834
|
const hostSource = readFile2?.(fileName);
|
|
3621
3835
|
if (typeof hostSource === "string")
|
|
3622
3836
|
return hostSource;
|
|
3623
3837
|
return fs.readFile(fileName, "utf-8");
|
|
3624
|
-
}, precomputeAotResourceTransforms = async (inputPath, readFile2) => {
|
|
3838
|
+
}, precomputeAotResourceTransforms = async (inputPath, readFile2, stylePreprocessors) => {
|
|
3625
3839
|
const transformedSources = new Map;
|
|
3626
3840
|
const visited = new Set;
|
|
3627
3841
|
const transformFile = async (filePath) => {
|
|
3628
|
-
const resolvedPath =
|
|
3842
|
+
const resolvedPath = resolve6(filePath);
|
|
3629
3843
|
if (visited.has(resolvedPath))
|
|
3630
3844
|
return;
|
|
3631
3845
|
visited.add(resolvedPath);
|
|
3632
|
-
if (!
|
|
3846
|
+
if (!existsSync5(resolvedPath) || resolvedPath.endsWith(".d.ts"))
|
|
3633
3847
|
return;
|
|
3634
3848
|
const source = await readFileForAotTransform(resolvedPath, readFile2);
|
|
3635
|
-
const transformed = await inlineResources(source, dirname4(resolvedPath));
|
|
3849
|
+
const transformed = await inlineResources(source, dirname4(resolvedPath), stylePreprocessors);
|
|
3636
3850
|
transformedSources.set(resolvedPath, transformed.source);
|
|
3637
3851
|
const imports = extractLocalImportSpecifiers(source, resolvedPath);
|
|
3638
3852
|
await Promise.all(imports.map(async (specifier) => {
|
|
@@ -3643,8 +3857,8 @@ ${registrations}
|
|
|
3643
3857
|
};
|
|
3644
3858
|
await transformFile(inputPath);
|
|
3645
3859
|
return transformedSources;
|
|
3646
|
-
}, compileAngularFile = async (inputPath, outDir) => {
|
|
3647
|
-
const islandMetadataExports = buildIslandMetadataExports(
|
|
3860
|
+
}, compileAngularFile = async (inputPath, outDir, stylePreprocessors) => {
|
|
3861
|
+
const islandMetadataExports = buildIslandMetadataExports(readFileSync4(inputPath, "utf-8"));
|
|
3648
3862
|
const { readConfiguration, performCompilation, EmitFlags } = await import("@angular/compiler-cli");
|
|
3649
3863
|
const configHash = computeConfigHash();
|
|
3650
3864
|
const cached = globalThis.__angularCompilerCache;
|
|
@@ -3659,7 +3873,7 @@ ${registrations}
|
|
|
3659
3873
|
} else {
|
|
3660
3874
|
const tsPath = __require.resolve("typescript");
|
|
3661
3875
|
const tsRootDir = dirname4(tsPath);
|
|
3662
|
-
tsLibDir = tsRootDir.endsWith("lib") ? tsRootDir :
|
|
3876
|
+
tsLibDir = tsRootDir.endsWith("lib") ? tsRootDir : resolve6(tsRootDir, "lib");
|
|
3663
3877
|
const config = readConfiguration("./tsconfig.json");
|
|
3664
3878
|
options = {
|
|
3665
3879
|
emitDecoratorMetadata: true,
|
|
@@ -3706,13 +3920,13 @@ ${registrations}
|
|
|
3706
3920
|
};
|
|
3707
3921
|
}
|
|
3708
3922
|
const emitted = {};
|
|
3709
|
-
const resolvedOutDir =
|
|
3923
|
+
const resolvedOutDir = resolve6(outDir);
|
|
3710
3924
|
host.writeFile = (fileName, text) => {
|
|
3711
3925
|
const relativePath = resolveRelativePath(fileName, resolvedOutDir, outDir);
|
|
3712
3926
|
emitted[relativePath] = text;
|
|
3713
3927
|
};
|
|
3714
3928
|
const originalReadFile = host.readFile;
|
|
3715
|
-
const aotTransformedSources = await precomputeAotResourceTransforms(inputPath, originalReadFile?.bind(host));
|
|
3929
|
+
const aotTransformedSources = await precomputeAotResourceTransforms(inputPath, originalReadFile?.bind(host), stylePreprocessors);
|
|
3716
3930
|
host.readFile = (fileName) => {
|
|
3717
3931
|
const source = originalReadFile ? originalReadFile.call(host, fileName) : undefined;
|
|
3718
3932
|
if (typeof source !== "string")
|
|
@@ -3720,7 +3934,7 @@ ${registrations}
|
|
|
3720
3934
|
if (!fileName.endsWith(".ts") || fileName.endsWith(".d.ts")) {
|
|
3721
3935
|
return source;
|
|
3722
3936
|
}
|
|
3723
|
-
const resolvedPath =
|
|
3937
|
+
const resolvedPath = resolve6(fileName);
|
|
3724
3938
|
return aotTransformedSources.get(resolvedPath) ?? source;
|
|
3725
3939
|
};
|
|
3726
3940
|
const originalGetSourceFileForCompile = host.getSourceFile;
|
|
@@ -3765,8 +3979,8 @@ ${registrations}
|
|
|
3765
3979
|
await Promise.all(entries.map(({ target, content }) => fs.writeFile(target, content, "utf-8")));
|
|
3766
3980
|
return entries.map(({ target }) => target);
|
|
3767
3981
|
}, jitContentCache, wrapperOutputCache, escapeTemplateContent = (content) => content.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${"), resolveAngularDeferImportSpecifier = () => {
|
|
3768
|
-
const sourceEntry =
|
|
3769
|
-
if (
|
|
3982
|
+
const sourceEntry = resolve6(import.meta.dir, "../angular/components/index.ts");
|
|
3983
|
+
if (existsSync5(sourceEntry)) {
|
|
3770
3984
|
return sourceEntry.replace(/\\/g, "/");
|
|
3771
3985
|
}
|
|
3772
3986
|
return "@absolutejs/absolute/angular/components";
|
|
@@ -3893,16 +4107,16 @@ ${slot.resolvedBindings.map((binding) => ` "${binding.key}": this.__absoluteDef
|
|
|
3893
4107
|
return rewritten.replace(/export(?:\s+default)?\s+class\s+([A-Za-z_$][\w$]*)\s*{/, (match) => `${match}
|
|
3894
4108
|
${fields}
|
|
3895
4109
|
`);
|
|
3896
|
-
}, readAndEscapeFile = async (filePath) => {
|
|
3897
|
-
if (!
|
|
4110
|
+
}, readAndEscapeFile = async (filePath, stylePreprocessors) => {
|
|
4111
|
+
if (!existsSync5(filePath))
|
|
3898
4112
|
return null;
|
|
3899
|
-
const content = await compileStyleFileIfNeeded(filePath);
|
|
4113
|
+
const content = await compileStyleFileIfNeeded(filePath, stylePreprocessors);
|
|
3900
4114
|
return escapeTemplateContent(content);
|
|
3901
4115
|
}, inlineTemplateAndLowerDefer = async (source, fileDir) => {
|
|
3902
4116
|
const templateUrlMatch = source.match(/templateUrl\s*:\s*['"]([^'"]+)['"]/);
|
|
3903
4117
|
if (templateUrlMatch?.[1]) {
|
|
3904
4118
|
const templatePath = join5(fileDir, templateUrlMatch[1]);
|
|
3905
|
-
if (!
|
|
4119
|
+
if (!existsSync5(templatePath)) {
|
|
3906
4120
|
return { deferSlots: [], source };
|
|
3907
4121
|
}
|
|
3908
4122
|
const templateRaw2 = await fs.readFile(templatePath, "utf-8");
|
|
@@ -3933,10 +4147,10 @@ ${fields}
|
|
|
3933
4147
|
const templateUrlMatch = source.match(/templateUrl\s*:\s*['"]([^'"]+)['"]/);
|
|
3934
4148
|
if (templateUrlMatch?.[1]) {
|
|
3935
4149
|
const templatePath = join5(fileDir, templateUrlMatch[1]);
|
|
3936
|
-
if (!
|
|
4150
|
+
if (!existsSync5(templatePath)) {
|
|
3937
4151
|
return { deferSlots: [], source };
|
|
3938
4152
|
}
|
|
3939
|
-
const templateRaw2 =
|
|
4153
|
+
const templateRaw2 = readFileSync4(templatePath, "utf-8");
|
|
3940
4154
|
const lowered2 = lowerAngularDeferSyntax(templateRaw2);
|
|
3941
4155
|
const escaped2 = escapeTemplateContent(lowered2.template);
|
|
3942
4156
|
const replacedSource2 = source.replace(/templateUrl\s*:\s*['"][^'"]+['"]/, `template: \`${escaped2}\``);
|
|
@@ -3960,7 +4174,7 @@ ${fields}
|
|
|
3960
4174
|
deferSlots: lowered.slots,
|
|
3961
4175
|
source: injectDeferSlotFields(replacedSource, lowered.slots, resolveAngularDeferImportSpecifier())
|
|
3962
4176
|
};
|
|
3963
|
-
}, inlineStyleUrls = async (source, fileDir) => {
|
|
4177
|
+
}, inlineStyleUrls = async (source, fileDir, stylePreprocessors) => {
|
|
3964
4178
|
const styleUrlsMatch = source.match(/styleUrls\s*:\s*\[([^\]]+)\]/);
|
|
3965
4179
|
if (!styleUrlsMatch?.[1])
|
|
3966
4180
|
return source;
|
|
@@ -3969,35 +4183,35 @@ ${fields}
|
|
|
3969
4183
|
return source;
|
|
3970
4184
|
const stylePromises = urlMatches.map((urlMatch) => {
|
|
3971
4185
|
const styleUrl = urlMatch.replace(/['"]/g, "");
|
|
3972
|
-
return readAndEscapeFile(join5(fileDir, styleUrl));
|
|
4186
|
+
return readAndEscapeFile(join5(fileDir, styleUrl), stylePreprocessors);
|
|
3973
4187
|
});
|
|
3974
4188
|
const results = await Promise.all(stylePromises);
|
|
3975
4189
|
const inlinedStyles = results.filter(Boolean).map((escaped) => `\`${escaped}\``);
|
|
3976
4190
|
if (inlinedStyles.length === 0)
|
|
3977
4191
|
return source;
|
|
3978
4192
|
return source.replace(/styleUrls\s*:\s*\[[^\]]+\]/, `styles: [${inlinedStyles.join(", ")}]`);
|
|
3979
|
-
}, inlineSingleStyleUrl = async (source, fileDir) => {
|
|
4193
|
+
}, inlineSingleStyleUrl = async (source, fileDir, stylePreprocessors) => {
|
|
3980
4194
|
const styleUrlMatch = source.match(/styleUrl\s*:\s*['"]([^'"]+)['"]/);
|
|
3981
4195
|
if (!styleUrlMatch?.[1])
|
|
3982
4196
|
return source;
|
|
3983
|
-
const escaped = await readAndEscapeFile(join5(fileDir, styleUrlMatch[1]));
|
|
4197
|
+
const escaped = await readAndEscapeFile(join5(fileDir, styleUrlMatch[1]), stylePreprocessors);
|
|
3984
4198
|
if (!escaped)
|
|
3985
4199
|
return source;
|
|
3986
4200
|
return source.replace(/styleUrl\s*:\s*['"][^'"]+['"]/, `styles: [\`${escaped}\`]`);
|
|
3987
|
-
}, inlineResources = async (source, fileDir) => {
|
|
4201
|
+
}, inlineResources = async (source, fileDir, stylePreprocessors) => {
|
|
3988
4202
|
const inlinedTemplate = await inlineTemplateAndLowerDefer(source, fileDir);
|
|
3989
4203
|
let result = inlinedTemplate.source;
|
|
3990
|
-
result = await inlineStyleUrls(result, fileDir);
|
|
3991
|
-
result = await inlineSingleStyleUrl(result, fileDir);
|
|
4204
|
+
result = await inlineStyleUrls(result, fileDir, stylePreprocessors);
|
|
4205
|
+
result = await inlineSingleStyleUrl(result, fileDir, stylePreprocessors);
|
|
3992
4206
|
return {
|
|
3993
4207
|
deferSlots: inlinedTemplate.deferSlots,
|
|
3994
4208
|
source: result
|
|
3995
4209
|
};
|
|
3996
|
-
}, compileAngularFileJIT = async (inputPath, outDir, rootDir) => {
|
|
3997
|
-
const entryPath =
|
|
4210
|
+
}, compileAngularFileJIT = async (inputPath, outDir, rootDir, stylePreprocessors) => {
|
|
4211
|
+
const entryPath = resolve6(inputPath);
|
|
3998
4212
|
const allOutputs = [];
|
|
3999
4213
|
const visited = new Set;
|
|
4000
|
-
const baseDir =
|
|
4214
|
+
const baseDir = resolve6(rootDir ?? process.cwd());
|
|
4001
4215
|
const angularTranspiler = new Bun.Transpiler({
|
|
4002
4216
|
loader: "ts",
|
|
4003
4217
|
tsconfig: JSON.stringify({
|
|
@@ -4034,23 +4248,23 @@ ${fields}
|
|
|
4034
4248
|
return `${prefix}${dots}`;
|
|
4035
4249
|
return `${prefix}../${dots}`;
|
|
4036
4250
|
});
|
|
4037
|
-
if (
|
|
4251
|
+
if (resolve6(actualPath) === entryPath) {
|
|
4038
4252
|
processedContent += buildIslandMetadataExports(sourceCode);
|
|
4039
4253
|
}
|
|
4040
4254
|
return processedContent;
|
|
4041
4255
|
};
|
|
4042
4256
|
const transpileFile = async (filePath) => {
|
|
4043
|
-
const resolved =
|
|
4257
|
+
const resolved = resolve6(filePath);
|
|
4044
4258
|
if (visited.has(resolved))
|
|
4045
4259
|
return;
|
|
4046
4260
|
visited.add(resolved);
|
|
4047
4261
|
let actualPath = resolved;
|
|
4048
4262
|
if (!actualPath.endsWith(".ts"))
|
|
4049
4263
|
actualPath += ".ts";
|
|
4050
|
-
if (!
|
|
4264
|
+
if (!existsSync5(actualPath))
|
|
4051
4265
|
return;
|
|
4052
4266
|
let sourceCode = await fs.readFile(actualPath, "utf-8");
|
|
4053
|
-
const inlined = await inlineResources(sourceCode, dirname4(actualPath));
|
|
4267
|
+
const inlined = await inlineResources(sourceCode, dirname4(actualPath), stylePreprocessors);
|
|
4054
4268
|
sourceCode = inlineTemplateAndLowerDeferSync(inlined.source, dirname4(actualPath)).source;
|
|
4055
4269
|
const inputDir = dirname4(actualPath);
|
|
4056
4270
|
const relativeDir = inputDir.startsWith(baseDir) ? inputDir.substring(baseDir.length + 1) : inputDir;
|
|
@@ -4071,7 +4285,7 @@ ${fields}
|
|
|
4071
4285
|
}
|
|
4072
4286
|
const contentHash = Bun.hash(sourceCode).toString(BASE_36_RADIX);
|
|
4073
4287
|
const cacheKey = actualPath;
|
|
4074
|
-
if (jitContentCache.get(cacheKey) === contentHash &&
|
|
4288
|
+
if (jitContentCache.get(cacheKey) === contentHash && existsSync5(targetPath)) {
|
|
4075
4289
|
allOutputs.push(targetPath);
|
|
4076
4290
|
} else {
|
|
4077
4291
|
const processedContent = transpileAndRewrite(sourceCode, relativeDir, actualPath);
|
|
@@ -4082,13 +4296,13 @@ ${fields}
|
|
|
4082
4296
|
}
|
|
4083
4297
|
const inputDirForResolve = dirname4(actualPath);
|
|
4084
4298
|
await Promise.all(localImports.map((imp) => {
|
|
4085
|
-
const importPath =
|
|
4299
|
+
const importPath = resolve6(inputDirForResolve, imp);
|
|
4086
4300
|
return transpileFile(importPath);
|
|
4087
4301
|
}));
|
|
4088
4302
|
};
|
|
4089
4303
|
await transpileFile(inputPath);
|
|
4090
4304
|
return allOutputs;
|
|
4091
|
-
}, compileAngular = async (entryPoints, outRoot, hmr = false) => {
|
|
4305
|
+
}, compileAngular = async (entryPoints, outRoot, hmr = false, stylePreprocessors) => {
|
|
4092
4306
|
const compiledParent = join5(outRoot, "generated");
|
|
4093
4307
|
if (entryPoints.length === 0) {
|
|
4094
4308
|
const emptyPaths = [];
|
|
@@ -4098,9 +4312,9 @@ ${fields}
|
|
|
4098
4312
|
const indexesDir = join5(compiledParent, "indexes");
|
|
4099
4313
|
await fs.mkdir(indexesDir, { recursive: true });
|
|
4100
4314
|
const compileTasks = entryPoints.map(async (entry) => {
|
|
4101
|
-
const resolvedEntry =
|
|
4102
|
-
const relativeEntry =
|
|
4103
|
-
const compileEntry = () => hmr ? compileAngularFileJIT(resolvedEntry, compiledRoot, outRoot) : compileAngularFile(resolvedEntry, compiledRoot);
|
|
4315
|
+
const resolvedEntry = resolve6(entry);
|
|
4316
|
+
const relativeEntry = relative3(outRoot, resolvedEntry).replace(/\.[tj]s$/, ".js");
|
|
4317
|
+
const compileEntry = () => hmr ? compileAngularFileJIT(resolvedEntry, compiledRoot, outRoot, stylePreprocessors) : compileAngularFile(resolvedEntry, compiledRoot, stylePreprocessors);
|
|
4104
4318
|
let outputs = await compileEntry();
|
|
4105
4319
|
const fileBase = basename3(resolvedEntry).replace(/\.[tj]s$/, "");
|
|
4106
4320
|
const jsName = `${fileBase}.js`;
|
|
@@ -4108,18 +4322,18 @@ ${fields}
|
|
|
4108
4322
|
join5(compiledRoot, relativeEntry),
|
|
4109
4323
|
join5(compiledRoot, "pages", jsName),
|
|
4110
4324
|
join5(compiledRoot, jsName)
|
|
4111
|
-
].map((file) =>
|
|
4325
|
+
].map((file) => resolve6(file));
|
|
4112
4326
|
const resolveRawServerFile = (candidatePaths) => {
|
|
4113
4327
|
const normalizedCandidates = [
|
|
4114
|
-
...candidatePaths.map((file) =>
|
|
4328
|
+
...candidatePaths.map((file) => resolve6(file)),
|
|
4115
4329
|
...compiledFallbackPaths
|
|
4116
4330
|
];
|
|
4117
|
-
let candidate = normalizedCandidates.find((file) =>
|
|
4331
|
+
let candidate = normalizedCandidates.find((file) => existsSync5(file) && file.endsWith(`${sep}pages${sep}${jsName}`));
|
|
4118
4332
|
if (!candidate) {
|
|
4119
|
-
candidate = normalizedCandidates.find((file) =>
|
|
4333
|
+
candidate = normalizedCandidates.find((file) => existsSync5(file) && file.endsWith(`${sep}${jsName}`));
|
|
4120
4334
|
}
|
|
4121
4335
|
if (!candidate) {
|
|
4122
|
-
candidate = normalizedCandidates.find((file) =>
|
|
4336
|
+
candidate = normalizedCandidates.find((file) => existsSync5(file));
|
|
4123
4337
|
}
|
|
4124
4338
|
return candidate;
|
|
4125
4339
|
};
|
|
@@ -4127,11 +4341,11 @@ ${fields}
|
|
|
4127
4341
|
if (!rawServerFile) {
|
|
4128
4342
|
rawServerFile = resolveRawServerFile([]);
|
|
4129
4343
|
}
|
|
4130
|
-
if (rawServerFile && !
|
|
4344
|
+
if (rawServerFile && !existsSync5(rawServerFile)) {
|
|
4131
4345
|
outputs = await compileEntry();
|
|
4132
4346
|
rawServerFile = resolveRawServerFile(outputs);
|
|
4133
4347
|
}
|
|
4134
|
-
if (!rawServerFile || !
|
|
4348
|
+
if (!rawServerFile || !existsSync5(rawServerFile)) {
|
|
4135
4349
|
throw new Error(`Compiled output not found for ${entry}. Looking for: ${jsName}. Available: ${[
|
|
4136
4350
|
...outputs,
|
|
4137
4351
|
...compiledFallbackPaths
|
|
@@ -4142,7 +4356,7 @@ ${fields}
|
|
|
4142
4356
|
const serverContentHash = Bun.hash(original).toString(BASE_36_RADIX);
|
|
4143
4357
|
const cachedWrapper = wrapperOutputCache.get(resolvedEntry);
|
|
4144
4358
|
const clientFile = join5(indexesDir, jsName);
|
|
4145
|
-
if (hmr && cachedWrapper && cachedWrapper.serverHash === serverContentHash &&
|
|
4359
|
+
if (hmr && cachedWrapper && cachedWrapper.serverHash === serverContentHash && existsSync5(clientFile)) {
|
|
4146
4360
|
return {
|
|
4147
4361
|
clientPath: clientFile,
|
|
4148
4362
|
indexUnchanged: true,
|
|
@@ -4176,7 +4390,7 @@ export default ${componentClassName};
|
|
|
4176
4390
|
await fs.writeFile(ssrDepsFile, ssrDepsContent, "utf-8");
|
|
4177
4391
|
}
|
|
4178
4392
|
await fs.writeFile(rawServerFile, rewritten, "utf-8");
|
|
4179
|
-
const relativePath =
|
|
4393
|
+
const relativePath = relative3(indexesDir, rawServerFile).replace(/\\/g, "/");
|
|
4180
4394
|
const normalizedImportPath = relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
4181
4395
|
const hmrPreamble = hmr ? `window.__HMR_FRAMEWORK__ = "angular";
|
|
4182
4396
|
import "${hmrRuntimePath}";
|
|
@@ -4339,19 +4553,19 @@ var init_compileAngular = __esm(() => {
|
|
|
4339
4553
|
import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
|
|
4340
4554
|
import { mkdir as mkdir2, symlink } from "fs/promises";
|
|
4341
4555
|
import { tmpdir } from "os";
|
|
4342
|
-
import { basename as basename4, dirname as dirname5, join as join6, resolve as
|
|
4556
|
+
import { basename as basename4, dirname as dirname5, join as join6, resolve as resolve7 } from "path";
|
|
4343
4557
|
var ssrDirty = false, lastSelector = "angular-page", isRecord5 = (value) => typeof value === "object" && value !== null, isAngularComponent = (value) => typeof value === "function", compilerImportPromise = null, ensureAngularCompiler = () => {
|
|
4344
4558
|
if (!compilerImportPromise) {
|
|
4345
4559
|
compilerImportPromise = import("@angular/compiler");
|
|
4346
4560
|
}
|
|
4347
4561
|
return compilerImportPromise;
|
|
4348
4562
|
}, readAngularPageModule = (value) => isRecord5(value) ? value : null, resolveAngularSsrOutDir = () => process.env.ABSOLUTE_ANGULAR_SSR_OUTDIR ?? join6(tmpdir(), "absolutejs", "generated", "angular-ssr"), ensureAngularSsrNodeModules = async (outDir) => {
|
|
4349
|
-
const outRoot =
|
|
4563
|
+
const outRoot = resolve7(dirname5(dirname5(outDir)));
|
|
4350
4564
|
const nodeModulesLink = join6(outRoot, "node_modules");
|
|
4351
4565
|
if (process.env.ABSOLUTE_ANGULAR_SSR_OUTDIR) {
|
|
4352
4566
|
return;
|
|
4353
4567
|
}
|
|
4354
|
-
if (nodeModulesLink ===
|
|
4568
|
+
if (nodeModulesLink === resolve7(process.cwd(), "node_modules")) {
|
|
4355
4569
|
return;
|
|
4356
4570
|
}
|
|
4357
4571
|
if (await Bun.file(nodeModulesLink).exists()) {
|
|
@@ -4359,7 +4573,7 @@ var ssrDirty = false, lastSelector = "angular-page", isRecord5 = (value) => type
|
|
|
4359
4573
|
}
|
|
4360
4574
|
await mkdir2(outRoot, { recursive: true });
|
|
4361
4575
|
try {
|
|
4362
|
-
await symlink(
|
|
4576
|
+
await symlink(resolve7(process.cwd(), "node_modules"), nodeModulesLink, "dir");
|
|
4363
4577
|
} catch (error) {
|
|
4364
4578
|
if (!(error instanceof Error) || !("code" in error) || error.code !== "EEXIST") {
|
|
4365
4579
|
throw error;
|
|
@@ -5158,7 +5372,7 @@ var require_Observable = __commonJS((exports) => {
|
|
|
5158
5372
|
Observable2.prototype.forEach = function(next, promiseCtor) {
|
|
5159
5373
|
var _this = this;
|
|
5160
5374
|
promiseCtor = getPromiseCtor(promiseCtor);
|
|
5161
|
-
return new promiseCtor(function(
|
|
5375
|
+
return new promiseCtor(function(resolve8, reject) {
|
|
5162
5376
|
var subscriber = new Subscriber_1.SafeSubscriber({
|
|
5163
5377
|
next: function(value) {
|
|
5164
5378
|
try {
|
|
@@ -5169,7 +5383,7 @@ var require_Observable = __commonJS((exports) => {
|
|
|
5169
5383
|
}
|
|
5170
5384
|
},
|
|
5171
5385
|
error: reject,
|
|
5172
|
-
complete:
|
|
5386
|
+
complete: resolve8
|
|
5173
5387
|
});
|
|
5174
5388
|
_this.subscribe(subscriber);
|
|
5175
5389
|
});
|
|
@@ -5191,14 +5405,14 @@ var require_Observable = __commonJS((exports) => {
|
|
|
5191
5405
|
Observable2.prototype.toPromise = function(promiseCtor) {
|
|
5192
5406
|
var _this = this;
|
|
5193
5407
|
promiseCtor = getPromiseCtor(promiseCtor);
|
|
5194
|
-
return new promiseCtor(function(
|
|
5408
|
+
return new promiseCtor(function(resolve8, reject) {
|
|
5195
5409
|
var value;
|
|
5196
5410
|
_this.subscribe(function(x) {
|
|
5197
5411
|
return value = x;
|
|
5198
5412
|
}, function(err) {
|
|
5199
5413
|
return reject(err);
|
|
5200
5414
|
}, function() {
|
|
5201
|
-
return
|
|
5415
|
+
return resolve8(value);
|
|
5202
5416
|
});
|
|
5203
5417
|
});
|
|
5204
5418
|
};
|
|
@@ -7226,11 +7440,11 @@ var require_isReadableStreamLike = __commonJS((exports) => {
|
|
|
7226
7440
|
var require_innerFrom = __commonJS((exports) => {
|
|
7227
7441
|
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
7228
7442
|
function adopt(value) {
|
|
7229
|
-
return value instanceof P ? value : new P(function(
|
|
7230
|
-
|
|
7443
|
+
return value instanceof P ? value : new P(function(resolve8) {
|
|
7444
|
+
resolve8(value);
|
|
7231
7445
|
});
|
|
7232
7446
|
}
|
|
7233
|
-
return new (P || (P = Promise))(function(
|
|
7447
|
+
return new (P || (P = Promise))(function(resolve8, reject) {
|
|
7234
7448
|
function fulfilled(value) {
|
|
7235
7449
|
try {
|
|
7236
7450
|
step(generator.next(value));
|
|
@@ -7246,7 +7460,7 @@ var require_innerFrom = __commonJS((exports) => {
|
|
|
7246
7460
|
}
|
|
7247
7461
|
}
|
|
7248
7462
|
function step(result) {
|
|
7249
|
-
result.done ?
|
|
7463
|
+
result.done ? resolve8(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
7250
7464
|
}
|
|
7251
7465
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
7252
7466
|
});
|
|
@@ -7336,14 +7550,14 @@ var require_innerFrom = __commonJS((exports) => {
|
|
|
7336
7550
|
}, i);
|
|
7337
7551
|
function verb(n) {
|
|
7338
7552
|
i[n] = o[n] && function(v) {
|
|
7339
|
-
return new Promise(function(
|
|
7340
|
-
v = o[n](v), settle(
|
|
7553
|
+
return new Promise(function(resolve8, reject) {
|
|
7554
|
+
v = o[n](v), settle(resolve8, reject, v.done, v.value);
|
|
7341
7555
|
});
|
|
7342
7556
|
};
|
|
7343
7557
|
}
|
|
7344
|
-
function settle(
|
|
7558
|
+
function settle(resolve8, reject, d, v) {
|
|
7345
7559
|
Promise.resolve(v).then(function(v2) {
|
|
7346
|
-
|
|
7560
|
+
resolve8({ value: v2, done: d });
|
|
7347
7561
|
}, reject);
|
|
7348
7562
|
}
|
|
7349
7563
|
};
|
|
@@ -7919,7 +8133,7 @@ var require_lastValueFrom = __commonJS((exports) => {
|
|
|
7919
8133
|
var EmptyError_1 = require_EmptyError();
|
|
7920
8134
|
function lastValueFrom(source, config) {
|
|
7921
8135
|
var hasConfig = typeof config === "object";
|
|
7922
|
-
return new Promise(function(
|
|
8136
|
+
return new Promise(function(resolve8, reject) {
|
|
7923
8137
|
var _hasValue = false;
|
|
7924
8138
|
var _value;
|
|
7925
8139
|
source.subscribe({
|
|
@@ -7930,9 +8144,9 @@ var require_lastValueFrom = __commonJS((exports) => {
|
|
|
7930
8144
|
error: reject,
|
|
7931
8145
|
complete: function() {
|
|
7932
8146
|
if (_hasValue) {
|
|
7933
|
-
|
|
8147
|
+
resolve8(_value);
|
|
7934
8148
|
} else if (hasConfig) {
|
|
7935
|
-
|
|
8149
|
+
resolve8(config.defaultValue);
|
|
7936
8150
|
} else {
|
|
7937
8151
|
reject(new EmptyError_1.EmptyError);
|
|
7938
8152
|
}
|
|
@@ -7951,16 +8165,16 @@ var require_firstValueFrom = __commonJS((exports) => {
|
|
|
7951
8165
|
var Subscriber_1 = require_Subscriber();
|
|
7952
8166
|
function firstValueFrom(source, config) {
|
|
7953
8167
|
var hasConfig = typeof config === "object";
|
|
7954
|
-
return new Promise(function(
|
|
8168
|
+
return new Promise(function(resolve8, reject) {
|
|
7955
8169
|
var subscriber = new Subscriber_1.SafeSubscriber({
|
|
7956
8170
|
next: function(value) {
|
|
7957
|
-
|
|
8171
|
+
resolve8(value);
|
|
7958
8172
|
subscriber.unsubscribe();
|
|
7959
8173
|
},
|
|
7960
8174
|
error: reject,
|
|
7961
8175
|
complete: function() {
|
|
7962
8176
|
if (hasConfig) {
|
|
7963
|
-
|
|
8177
|
+
resolve8(config.defaultValue);
|
|
7964
8178
|
} else {
|
|
7965
8179
|
reject(new EmptyError_1.EmptyError);
|
|
7966
8180
|
}
|
|
@@ -13722,5 +13936,5 @@ export {
|
|
|
13722
13936
|
Island
|
|
13723
13937
|
};
|
|
13724
13938
|
|
|
13725
|
-
//# debugId=
|
|
13939
|
+
//# debugId=996E4E3B3568CFA564756E2164756E21
|
|
13726
13940
|
//# sourceMappingURL=index.js.map
|