@absolutejs/absolute 0.19.0-beta.694 → 0.19.0-beta.695

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.
@@ -1640,6 +1640,11 @@ var init_resolveConvention = __esm(() => {
1640
1640
  });
1641
1641
 
1642
1642
  // src/react/pageHandler.ts
1643
+ var exports_pageHandler = {};
1644
+ __export(exports_pageHandler, {
1645
+ invalidateReactSsrCache: () => invalidateReactSsrCache,
1646
+ handleReactPageRequest: () => handleReactPageRequest
1647
+ });
1643
1648
  var ssrDirty = false, buildRefreshSetup = () => {
1644
1649
  if (false) {}
1645
1650
  return "window.__REFRESH_BUFFER__=[];" + "window.$RefreshReg$=function(t,i){window.__REFRESH_BUFFER__.push([t,i])};" + "window.$RefreshSig$=function(){return function(t){return t}};";
@@ -2502,12 +2507,27 @@ var init_lowerAwaitSlotSyntax = __esm(() => {
2502
2507
  });
2503
2508
 
2504
2509
  // src/build/stylePreprocessor.ts
2510
+ var exports_stylePreprocessor = {};
2511
+ __export(exports_stylePreprocessor, {
2512
+ stylePreprocessorPlugin: () => stylePreprocessorPlugin,
2513
+ isStylePath: () => isStylePath,
2514
+ isStyleModulePath: () => isStyleModulePath,
2515
+ isPreprocessableStylePath: () => isPreprocessableStylePath,
2516
+ getStyleBaseName: () => getStyleBaseName,
2517
+ getCssOutputExtension: () => getCssOutputExtension,
2518
+ createSvelteStylePreprocessor: () => createSvelteStylePreprocessor,
2519
+ createStyleTransformConfig: () => createStyleTransformConfig,
2520
+ createStylePreprocessorPlugin: () => createStylePreprocessorPlugin,
2521
+ compileStyleSource: () => compileStyleSource,
2522
+ compileStyleFileIfNeededSync: () => compileStyleFileIfNeededSync,
2523
+ compileStyleFileIfNeeded: () => compileStyleFileIfNeeded
2524
+ });
2505
2525
  import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
2506
2526
  import { readFile } from "fs/promises";
2507
2527
  import { createRequire } from "module";
2508
2528
  import { dirname as dirname2, extname, isAbsolute, join as join3, relative, resolve as resolve4 } from "path";
2509
2529
  import { fileURLToPath } from "url";
2510
- 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) => {
2530
+ var CSS_EXTENSION_PATTERN, 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) => {
2511
2531
  const normalized = filePathOrLanguage.toLowerCase();
2512
2532
  if (normalized === "scss" || normalized.endsWith(".scss"))
2513
2533
  return "scss";
@@ -2518,7 +2538,13 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
2518
2538
  if (normalized === "styl" || normalized === "stylus" || normalized.endsWith(".styl") || normalized.endsWith(".stylus"))
2519
2539
  return "stylus";
2520
2540
  return null;
2521
- }, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), normalizeLoadPaths = (filePath, paths = []) => [
2541
+ }, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), requireOptionalPeerSync = (specifier) => {
2542
+ try {
2543
+ return requireFromCwd(specifier);
2544
+ } catch {
2545
+ return requireOptionalPeer(specifier);
2546
+ }
2547
+ }, normalizeLoadPaths = (filePath, paths = []) => [
2522
2548
  dirname2(filePath),
2523
2549
  process.cwd(),
2524
2550
  ...paths.map((path) => resolve4(process.cwd(), path))
@@ -2647,8 +2673,72 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
2647
2673
  }, getSassOptions = (config, language) => ({
2648
2674
  ...config?.sass ?? {},
2649
2675
  ...language === "scss" ? config?.scss ?? {} : {}
2650
- }), getLessOptions = (config) => config?.less ?? {}, getStylusOptions = (config) => config?.stylus ?? {}, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
2651
- ${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, config) => ({
2676
+ }), getLessOptions = (config) => config?.less ?? {}, getStylusOptions = (config) => config?.stylus ?? {}, createStyleTransformConfig = (stylePreprocessors, postcss) => postcss === undefined ? stylePreprocessors : { ...stylePreprocessors ?? {}, postcss }, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
2677
+ ${contents}` : contents, normalizePostcssModule = (mod) => {
2678
+ if (mod && typeof mod === "object" && "default" in mod) {
2679
+ return mod.default ?? mod;
2680
+ }
2681
+ return mod;
2682
+ }, loadPostcssConfigFile = async (configPath) => {
2683
+ const resolved = resolve4(process.cwd(), configPath);
2684
+ const loaded = resolved.endsWith(".cjs") || resolved.endsWith(".cts") ? requireOptionalPeerSync(resolved) : await importOptionalPeer(`${new URL(`file://${resolved}`).href}?t=${Date.now()}`);
2685
+ const config = normalizePostcssModule(loaded);
2686
+ const value = typeof config === "function" ? await config({
2687
+ cwd: process.cwd(),
2688
+ env: "development"
2689
+ }) : config;
2690
+ return normalizePostcssModule(value) ?? {};
2691
+ }, normalizePostcssPlugins = (plugins) => {
2692
+ if (!plugins)
2693
+ return [];
2694
+ if (Array.isArray(plugins))
2695
+ return plugins.filter(Boolean);
2696
+ const resolved = [];
2697
+ for (const [specifier, options] of Object.entries(plugins)) {
2698
+ if (options === false)
2699
+ continue;
2700
+ const mod = normalizePostcssModule(requireOptionalPeerSync(specifier));
2701
+ const plugin = typeof mod === "function" ? mod(options === true ? undefined : options) : mod;
2702
+ if (plugin)
2703
+ resolved.push(plugin);
2704
+ }
2705
+ return resolved;
2706
+ }, resolvePostcssConfig = async (config) => {
2707
+ const inlineConfig = config?.postcss;
2708
+ if (!inlineConfig)
2709
+ return null;
2710
+ const fileConfig = inlineConfig.config ? await loadPostcssConfigFile(inlineConfig.config) : {};
2711
+ const plugins = [
2712
+ ...normalizePostcssPlugins(fileConfig.plugins),
2713
+ ...normalizePostcssPlugins(inlineConfig.plugins)
2714
+ ];
2715
+ if (plugins.length === 0)
2716
+ return null;
2717
+ return {
2718
+ options: {
2719
+ ...fileConfig.options ?? {},
2720
+ ...inlineConfig.options ?? {}
2721
+ },
2722
+ plugins
2723
+ };
2724
+ }, runPostcss = async (css, filePath, config) => {
2725
+ const postcssConfig = await resolvePostcssConfig(config);
2726
+ if (!postcssConfig)
2727
+ return css;
2728
+ let postcssModule;
2729
+ try {
2730
+ postcssModule = await importOptionalPeer("postcss");
2731
+ } catch {
2732
+ throw missingDependencyError("postcss", filePath);
2733
+ }
2734
+ const postcss = postcssModule.default ?? postcssModule;
2735
+ const result = await postcss(postcssConfig.plugins).process(css, {
2736
+ from: filePath,
2737
+ map: false,
2738
+ ...postcssConfig.options
2739
+ });
2740
+ return result.css;
2741
+ }, createSassImporter = (entryFile, loadPaths, language, config) => ({
2652
2742
  canonicalize(specifier, options) {
2653
2743
  const fromDirectory = options.containingUrl ? dirname2(fileURLToPath(options.containingUrl)) : dirname2(entryFile);
2654
2744
  const resolved = resolveImportPath(specifier, fromDirectory, loadPaths, language, config);
@@ -2727,7 +2817,7 @@ ${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, c
2727
2817
  syntax: language === "sass" ? "indented" : "scss",
2728
2818
  url: new URL(`file://${filePath}`)
2729
2819
  });
2730
- return result.css;
2820
+ return runPostcss(result.css, filePath, config);
2731
2821
  }
2732
2822
  if (language === "less") {
2733
2823
  const options = getLessOptions(config);
@@ -2752,15 +2842,15 @@ ${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, c
2752
2842
  createLessFileManager(filePath, loadPaths, config)
2753
2843
  ]
2754
2844
  });
2755
- return result.css;
2845
+ return runPostcss(result.css, filePath, config);
2756
2846
  }
2757
2847
  if (language === "stylus") {
2758
2848
  const options = getStylusOptions(config);
2759
2849
  const loadPaths = normalizeLoadPaths(filePath, options.paths);
2760
2850
  const contents = withAdditionalData(preprocessLoadedStyle(rawContents, filePath, filePath, loadPaths, "stylus", config), options.additionalData);
2761
- return renderStylus(contents, filePath, loadPaths, options);
2851
+ return runPostcss(await renderStylus(contents, filePath, loadPaths, options), filePath, config);
2762
2852
  }
2763
- return rawContents;
2853
+ return runPostcss(rawContents, filePath, config);
2764
2854
  }, createStylePreprocessorPlugin = (config) => ({
2765
2855
  name: "absolute-style-preprocessor",
2766
2856
  setup(build) {
@@ -2796,6 +2886,10 @@ ${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, c
2796
2886
  loader: "css"
2797
2887
  };
2798
2888
  });
2889
+ build.onLoad({ filter: CSS_EXTENSION_PATTERN }, async ({ path }) => ({
2890
+ contents: await compileStyleSource(path, undefined, undefined, config),
2891
+ loader: "css"
2892
+ }));
2799
2893
  }
2800
2894
  }), stylePreprocessorPlugin, createSvelteStylePreprocessor = (config) => ({
2801
2895
  style: async ({
@@ -2813,11 +2907,46 @@ ${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, c
2813
2907
  }
2814
2908
  }), compileStyleFileIfNeeded = async (filePath, config) => {
2815
2909
  if (!isPreprocessableStylePath(filePath)) {
2816
- return readFile(filePath, "utf-8");
2910
+ return runPostcss(await readFile(filePath, "utf-8"), filePath, config);
2817
2911
  }
2818
2912
  return compileStyleSource(filePath, undefined, undefined, config);
2819
- };
2913
+ }, compileStyleFileIfNeededSync = (filePath, config) => {
2914
+ const rawContents = readFileSync3(filePath, "utf-8");
2915
+ const language = getStyleLanguage(filePath);
2916
+ if (config?.postcss) {
2917
+ throw new Error(`Unable to compile ${filePath}: PostCSS preprocessing is async-only.`);
2918
+ }
2919
+ if (language === "scss" || language === "sass") {
2920
+ const options = getSassOptions(config, language);
2921
+ const packageName = options.implementation ?? "sass";
2922
+ let sass;
2923
+ try {
2924
+ sass = requireOptionalPeerSync(packageName);
2925
+ } catch {
2926
+ throw missingDependencyError(packageName, filePath);
2927
+ }
2928
+ const contents = withAdditionalData(rawContents, options.additionalData);
2929
+ const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
2930
+ return sass.compileString(contents, {
2931
+ importers: [
2932
+ createSassImporter(filePath, loadPaths, language, config)
2933
+ ],
2934
+ loadPaths,
2935
+ style: "expanded",
2936
+ syntax: language === "sass" ? "indented" : "scss",
2937
+ url: new URL(`file://${filePath}`)
2938
+ }).css;
2939
+ }
2940
+ if (language === "less") {
2941
+ 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.`);
2942
+ }
2943
+ if (language === "stylus") {
2944
+ throw new Error(`Unable to compile ${filePath}: Stylus styleUrl preprocessing is async-only. Import the Stylus file from a bundled entrypoint or use SCSS/CSS for Angular styleUrl.`);
2945
+ }
2946
+ return rawContents;
2947
+ }, getCssOutputExtension = (filePath) => isPreprocessableStylePath(filePath) ? ".css" : extname(filePath);
2820
2948
  var init_stylePreprocessor = __esm(() => {
2949
+ CSS_EXTENSION_PATTERN = /\.css$/i;
2821
2950
  STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less|styl(?:us)?)$/i;
2822
2951
  STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less|styl(?:us)?)$/i;
2823
2952
  STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less|styl(?:us)?)$/i;
@@ -3302,5 +3431,5 @@ export {
3302
3431
  Island
3303
3432
  };
3304
3433
 
3305
- //# debugId=93D61437E7D290D564756E2164756E21
3434
+ //# debugId=25DC64FB167A008E64756E2164756E21
3306
3435
  //# sourceMappingURL=index.js.map