@absolutejs/absolute 0.19.0-beta.689 → 0.19.0-beta.690

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.
@@ -1352,9 +1352,10 @@ var init_lowerAwaitSlotSyntax = __esm(() => {
1352
1352
  });
1353
1353
 
1354
1354
  // src/build/stylePreprocessor.ts
1355
+ import { readFileSync as readFileSync3 } from "fs";
1355
1356
  import { readFile } from "fs/promises";
1356
1357
  import { dirname as dirname2, extname } from "path";
1357
- var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATTERN, importOptionalPeer, isPreprocessableStylePath = (filePath) => STYLE_EXTENSION_PATTERN.test(filePath), isStyleModulePath = (filePath) => STYLE_MODULE_EXTENSION_PATTERN.test(filePath), isStylePath = (filePath) => /\.(css|s[ac]ss|less)$/i.test(filePath), getStyleBaseName = (filePath) => filePath.replace(/\.(css|s[ac]ss|less)$/i, ""), getStyleLanguage = (filePathOrLanguage) => {
1358
+ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATTERN, importOptionalPeer, requireOptionalPeer, isPreprocessableStylePath = (filePath) => STYLE_EXTENSION_PATTERN.test(filePath), isStyleModulePath = (filePath) => STYLE_MODULE_EXTENSION_PATTERN.test(filePath), isStylePath = (filePath) => /\.(css|s[ac]ss|less)$/i.test(filePath), getStyleBaseName = (filePath) => filePath.replace(/\.(css|s[ac]ss|less)$/i, ""), getStyleLanguage = (filePathOrLanguage) => {
1358
1359
  const normalized = filePathOrLanguage.toLowerCase();
1359
1360
  if (normalized === "scss" || normalized.endsWith(".scss"))
1360
1361
  return "scss";
@@ -1418,12 +1419,34 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
1418
1419
  return readFile(filePath, "utf-8");
1419
1420
  }
1420
1421
  return compileStyleSource(filePath);
1422
+ }, compileStyleFileIfNeededSync = (filePath) => {
1423
+ const contents = readFileSync3(filePath, "utf-8");
1424
+ const language = getStyleLanguage(filePath);
1425
+ if (language === "scss" || language === "sass") {
1426
+ let sass;
1427
+ try {
1428
+ sass = requireOptionalPeer("sass");
1429
+ } catch {
1430
+ throw missingDependencyError("sass", filePath);
1431
+ }
1432
+ return sass.compileString(contents, {
1433
+ loadPaths: [dirname2(filePath), process.cwd()],
1434
+ style: "expanded",
1435
+ syntax: language === "sass" ? "indented" : "scss",
1436
+ url: new URL(`file://${filePath}`)
1437
+ }).css;
1438
+ }
1439
+ if (language === "less") {
1440
+ throw new Error(`Unable to compile ${filePath}: Less styleUrl preprocessing is async-only. Import the Less file from a bundled entrypoint or use SCSS/CSS for Angular styleUrl.`);
1441
+ }
1442
+ return contents;
1421
1443
  };
1422
1444
  var init_stylePreprocessor = __esm(() => {
1423
1445
  STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less)$/i;
1424
1446
  STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less)$/i;
1425
1447
  STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less)$/i;
1426
1448
  importOptionalPeer = new Function("specifier", "return import(specifier)");
1449
+ requireOptionalPeer = new Function("specifier", "return require(specifier)");
1427
1450
  stylePreprocessorPlugin = {
1428
1451
  name: "absolute-style-preprocessor",
1429
1452
  setup(build) {
@@ -3515,13 +3538,13 @@ __export(exports_compileAngular, {
3515
3538
  compileAngularFile: () => compileAngularFile,
3516
3539
  compileAngular: () => compileAngular
3517
3540
  });
3518
- import { existsSync as existsSync4, readFileSync as readFileSync3, promises as fs } from "fs";
3541
+ import { existsSync as existsSync4, readFileSync as readFileSync4, promises as fs } from "fs";
3519
3542
  import { join as join4, basename as basename3, sep, dirname as dirname4, resolve as resolve5, relative as relative2 } from "path";
3520
3543
  import ts from "typescript";
3521
3544
  import { createHash } from "crypto";
3522
3545
  var computeConfigHash = () => {
3523
3546
  try {
3524
- const content = readFileSync3("./tsconfig.json", "utf-8");
3547
+ const content = readFileSync4("./tsconfig.json", "utf-8");
3525
3548
  return createHash("md5").update(content).digest("hex");
3526
3549
  } catch {
3527
3550
  return "";
@@ -3579,7 +3602,7 @@ ${registrations}
3579
3602
  return fileName.substring(outDir.length + 1);
3580
3603
  return fileName;
3581
3604
  }, compileAngularFile = async (inputPath, outDir) => {
3582
- const islandMetadataExports = buildIslandMetadataExports(readFileSync3(inputPath, "utf-8"));
3605
+ const islandMetadataExports = buildIslandMetadataExports(readFileSync4(inputPath, "utf-8"));
3583
3606
  const { readConfiguration, performCompilation, EmitFlags } = await import("@angular/compiler-cli");
3584
3607
  const configHash = computeConfigHash();
3585
3608
  const cached = globalThis.__angularCompilerCache;
@@ -3659,7 +3682,7 @@ ${registrations}
3659
3682
  const cached2 = aotTransformCache.get(resolvedPath);
3660
3683
  if (cached2 !== undefined)
3661
3684
  return cached2;
3662
- const transformed = inlineTemplateAndLowerDeferSync(source, dirname4(resolvedPath)).source;
3685
+ const transformed = inlineResourcesSync(source, dirname4(resolvedPath)).source;
3663
3686
  aotTransformCache.set(resolvedPath, transformed);
3664
3687
  return transformed;
3665
3688
  };
@@ -3876,7 +3899,7 @@ ${fields}
3876
3899
  if (!existsSync4(templatePath)) {
3877
3900
  return { deferSlots: [], source };
3878
3901
  }
3879
- const templateRaw2 = readFileSync3(templatePath, "utf-8");
3902
+ const templateRaw2 = readFileSync4(templatePath, "utf-8");
3880
3903
  const lowered2 = lowerAngularDeferSyntax(templateRaw2);
3881
3904
  const escaped2 = escapeTemplateContent(lowered2.template);
3882
3905
  const replacedSource2 = source.replace(/templateUrl\s*:\s*['"][^'"]+['"]/, `template: \`${escaped2}\``);
@@ -3900,6 +3923,42 @@ ${fields}
3900
3923
  deferSlots: lowered.slots,
3901
3924
  source: injectDeferSlotFields(replacedSource, lowered.slots, resolveAngularDeferImportSpecifier())
3902
3925
  };
3926
+ }, readAndEscapeFileSync = (filePath) => {
3927
+ if (!existsSync4(filePath))
3928
+ return null;
3929
+ const content = compileStyleFileIfNeededSync(filePath);
3930
+ return escapeTemplateContent(content);
3931
+ }, inlineStyleUrlsSync = (source, fileDir) => {
3932
+ const styleUrlsMatch = source.match(/styleUrls\s*:\s*\[([^\]]+)\]/);
3933
+ if (!styleUrlsMatch?.[1])
3934
+ return source;
3935
+ const urlMatches = styleUrlsMatch[1].match(/['"]([^'"]+)['"]/g);
3936
+ if (!urlMatches)
3937
+ return source;
3938
+ const inlinedStyles = urlMatches.map((urlMatch) => {
3939
+ const styleUrl = urlMatch.replace(/['"]/g, "");
3940
+ return readAndEscapeFileSync(join4(fileDir, styleUrl));
3941
+ }).filter(Boolean).map((escaped) => `\`${escaped}\``);
3942
+ if (inlinedStyles.length === 0)
3943
+ return source;
3944
+ return source.replace(/styleUrls\s*:\s*\[[^\]]+\]/, `styles: [${inlinedStyles.join(", ")}]`);
3945
+ }, inlineSingleStyleUrlSync = (source, fileDir) => {
3946
+ const styleUrlMatch = source.match(/styleUrl\s*:\s*['"]([^'"]+)['"]/);
3947
+ if (!styleUrlMatch?.[1])
3948
+ return source;
3949
+ const escaped = readAndEscapeFileSync(join4(fileDir, styleUrlMatch[1]));
3950
+ if (!escaped)
3951
+ return source;
3952
+ return source.replace(/styleUrl\s*:\s*['"][^'"]+['"]/, `styles: [\`${escaped}\`]`);
3953
+ }, inlineResourcesSync = (source, fileDir) => {
3954
+ const inlinedTemplate = inlineTemplateAndLowerDeferSync(source, fileDir);
3955
+ let result = inlinedTemplate.source;
3956
+ result = inlineStyleUrlsSync(result, fileDir);
3957
+ result = inlineSingleStyleUrlSync(result, fileDir);
3958
+ return {
3959
+ deferSlots: inlinedTemplate.deferSlots,
3960
+ source: result
3961
+ };
3903
3962
  }, inlineStyleUrls = async (source, fileDir) => {
3904
3963
  const styleUrlsMatch = source.match(/styleUrls\s*:\s*\[([^\]]+)\]/);
3905
3964
  if (!styleUrlsMatch?.[1])
@@ -4420,5 +4479,5 @@ export {
4420
4479
  handleAngularPageRequest
4421
4480
  };
4422
4481
 
4423
- //# debugId=10494DBC5DFCADD564756E2164756E21
4482
+ //# debugId=AAA8CCB71B1BD54264756E2164756E21
4424
4483
  //# sourceMappingURL=server.js.map