@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.
package/dist/vue/index.js CHANGED
@@ -2566,12 +2566,27 @@ var init_lowerAwaitSlotSyntax = __esm(() => {
2566
2566
  });
2567
2567
 
2568
2568
  // src/build/stylePreprocessor.ts
2569
+ var exports_stylePreprocessor = {};
2570
+ __export(exports_stylePreprocessor, {
2571
+ stylePreprocessorPlugin: () => stylePreprocessorPlugin,
2572
+ isStylePath: () => isStylePath,
2573
+ isStyleModulePath: () => isStyleModulePath,
2574
+ isPreprocessableStylePath: () => isPreprocessableStylePath,
2575
+ getStyleBaseName: () => getStyleBaseName,
2576
+ getCssOutputExtension: () => getCssOutputExtension,
2577
+ createSvelteStylePreprocessor: () => createSvelteStylePreprocessor,
2578
+ createStyleTransformConfig: () => createStyleTransformConfig,
2579
+ createStylePreprocessorPlugin: () => createStylePreprocessorPlugin,
2580
+ compileStyleSource: () => compileStyleSource,
2581
+ compileStyleFileIfNeededSync: () => compileStyleFileIfNeededSync,
2582
+ compileStyleFileIfNeeded: () => compileStyleFileIfNeeded
2583
+ });
2569
2584
  import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
2570
2585
  import { readFile } from "fs/promises";
2571
2586
  import { createRequire } from "module";
2572
2587
  import { dirname as dirname3, extname, isAbsolute, join as join3, relative, resolve as resolve4 } from "path";
2573
2588
  import { fileURLToPath } from "url";
2574
- 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) => {
2589
+ 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) => {
2575
2590
  const normalized = filePathOrLanguage.toLowerCase();
2576
2591
  if (normalized === "scss" || normalized.endsWith(".scss"))
2577
2592
  return "scss";
@@ -2582,7 +2597,13 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
2582
2597
  if (normalized === "styl" || normalized === "stylus" || normalized.endsWith(".styl") || normalized.endsWith(".stylus"))
2583
2598
  return "stylus";
2584
2599
  return null;
2585
- }, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), normalizeLoadPaths = (filePath, paths = []) => [
2600
+ }, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), requireOptionalPeerSync = (specifier) => {
2601
+ try {
2602
+ return requireFromCwd(specifier);
2603
+ } catch {
2604
+ return requireOptionalPeer(specifier);
2605
+ }
2606
+ }, normalizeLoadPaths = (filePath, paths = []) => [
2586
2607
  dirname3(filePath),
2587
2608
  process.cwd(),
2588
2609
  ...paths.map((path) => resolve4(process.cwd(), path))
@@ -2711,8 +2732,72 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
2711
2732
  }, getSassOptions = (config, language) => ({
2712
2733
  ...config?.sass ?? {},
2713
2734
  ...language === "scss" ? config?.scss ?? {} : {}
2714
- }), getLessOptions = (config) => config?.less ?? {}, getStylusOptions = (config) => config?.stylus ?? {}, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
2715
- ${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, config) => ({
2735
+ }), getLessOptions = (config) => config?.less ?? {}, getStylusOptions = (config) => config?.stylus ?? {}, createStyleTransformConfig = (stylePreprocessors, postcss) => postcss === undefined ? stylePreprocessors : { ...stylePreprocessors ?? {}, postcss }, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
2736
+ ${contents}` : contents, normalizePostcssModule = (mod) => {
2737
+ if (mod && typeof mod === "object" && "default" in mod) {
2738
+ return mod.default ?? mod;
2739
+ }
2740
+ return mod;
2741
+ }, loadPostcssConfigFile = async (configPath) => {
2742
+ const resolved = resolve4(process.cwd(), configPath);
2743
+ const loaded = resolved.endsWith(".cjs") || resolved.endsWith(".cts") ? requireOptionalPeerSync(resolved) : await importOptionalPeer(`${new URL(`file://${resolved}`).href}?t=${Date.now()}`);
2744
+ const config = normalizePostcssModule(loaded);
2745
+ const value = typeof config === "function" ? await config({
2746
+ cwd: process.cwd(),
2747
+ env: "development"
2748
+ }) : config;
2749
+ return normalizePostcssModule(value) ?? {};
2750
+ }, normalizePostcssPlugins = (plugins) => {
2751
+ if (!plugins)
2752
+ return [];
2753
+ if (Array.isArray(plugins))
2754
+ return plugins.filter(Boolean);
2755
+ const resolved = [];
2756
+ for (const [specifier, options] of Object.entries(plugins)) {
2757
+ if (options === false)
2758
+ continue;
2759
+ const mod = normalizePostcssModule(requireOptionalPeerSync(specifier));
2760
+ const plugin = typeof mod === "function" ? mod(options === true ? undefined : options) : mod;
2761
+ if (plugin)
2762
+ resolved.push(plugin);
2763
+ }
2764
+ return resolved;
2765
+ }, resolvePostcssConfig = async (config) => {
2766
+ const inlineConfig = config?.postcss;
2767
+ if (!inlineConfig)
2768
+ return null;
2769
+ const fileConfig = inlineConfig.config ? await loadPostcssConfigFile(inlineConfig.config) : {};
2770
+ const plugins = [
2771
+ ...normalizePostcssPlugins(fileConfig.plugins),
2772
+ ...normalizePostcssPlugins(inlineConfig.plugins)
2773
+ ];
2774
+ if (plugins.length === 0)
2775
+ return null;
2776
+ return {
2777
+ options: {
2778
+ ...fileConfig.options ?? {},
2779
+ ...inlineConfig.options ?? {}
2780
+ },
2781
+ plugins
2782
+ };
2783
+ }, runPostcss = async (css, filePath, config) => {
2784
+ const postcssConfig = await resolvePostcssConfig(config);
2785
+ if (!postcssConfig)
2786
+ return css;
2787
+ let postcssModule;
2788
+ try {
2789
+ postcssModule = await importOptionalPeer("postcss");
2790
+ } catch {
2791
+ throw missingDependencyError("postcss", filePath);
2792
+ }
2793
+ const postcss = postcssModule.default ?? postcssModule;
2794
+ const result = await postcss(postcssConfig.plugins).process(css, {
2795
+ from: filePath,
2796
+ map: false,
2797
+ ...postcssConfig.options
2798
+ });
2799
+ return result.css;
2800
+ }, createSassImporter = (entryFile, loadPaths, language, config) => ({
2716
2801
  canonicalize(specifier, options) {
2717
2802
  const fromDirectory = options.containingUrl ? dirname3(fileURLToPath(options.containingUrl)) : dirname3(entryFile);
2718
2803
  const resolved = resolveImportPath(specifier, fromDirectory, loadPaths, language, config);
@@ -2791,7 +2876,7 @@ ${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, c
2791
2876
  syntax: language === "sass" ? "indented" : "scss",
2792
2877
  url: new URL(`file://${filePath}`)
2793
2878
  });
2794
- return result.css;
2879
+ return runPostcss(result.css, filePath, config);
2795
2880
  }
2796
2881
  if (language === "less") {
2797
2882
  const options = getLessOptions(config);
@@ -2816,15 +2901,15 @@ ${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, c
2816
2901
  createLessFileManager(filePath, loadPaths, config)
2817
2902
  ]
2818
2903
  });
2819
- return result.css;
2904
+ return runPostcss(result.css, filePath, config);
2820
2905
  }
2821
2906
  if (language === "stylus") {
2822
2907
  const options = getStylusOptions(config);
2823
2908
  const loadPaths = normalizeLoadPaths(filePath, options.paths);
2824
2909
  const contents = withAdditionalData(preprocessLoadedStyle(rawContents, filePath, filePath, loadPaths, "stylus", config), options.additionalData);
2825
- return renderStylus(contents, filePath, loadPaths, options);
2910
+ return runPostcss(await renderStylus(contents, filePath, loadPaths, options), filePath, config);
2826
2911
  }
2827
- return rawContents;
2912
+ return runPostcss(rawContents, filePath, config);
2828
2913
  }, createStylePreprocessorPlugin = (config) => ({
2829
2914
  name: "absolute-style-preprocessor",
2830
2915
  setup(build) {
@@ -2860,6 +2945,10 @@ ${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, c
2860
2945
  loader: "css"
2861
2946
  };
2862
2947
  });
2948
+ build.onLoad({ filter: CSS_EXTENSION_PATTERN }, async ({ path }) => ({
2949
+ contents: await compileStyleSource(path, undefined, undefined, config),
2950
+ loader: "css"
2951
+ }));
2863
2952
  }
2864
2953
  }), stylePreprocessorPlugin, createSvelteStylePreprocessor = (config) => ({
2865
2954
  style: async ({
@@ -2877,11 +2966,46 @@ ${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, c
2877
2966
  }
2878
2967
  }), compileStyleFileIfNeeded = async (filePath, config) => {
2879
2968
  if (!isPreprocessableStylePath(filePath)) {
2880
- return readFile(filePath, "utf-8");
2969
+ return runPostcss(await readFile(filePath, "utf-8"), filePath, config);
2881
2970
  }
2882
2971
  return compileStyleSource(filePath, undefined, undefined, config);
2883
- };
2972
+ }, compileStyleFileIfNeededSync = (filePath, config) => {
2973
+ const rawContents = readFileSync3(filePath, "utf-8");
2974
+ const language = getStyleLanguage(filePath);
2975
+ if (config?.postcss) {
2976
+ throw new Error(`Unable to compile ${filePath}: PostCSS preprocessing is async-only.`);
2977
+ }
2978
+ if (language === "scss" || language === "sass") {
2979
+ const options = getSassOptions(config, language);
2980
+ const packageName = options.implementation ?? "sass";
2981
+ let sass;
2982
+ try {
2983
+ sass = requireOptionalPeerSync(packageName);
2984
+ } catch {
2985
+ throw missingDependencyError(packageName, filePath);
2986
+ }
2987
+ const contents = withAdditionalData(rawContents, options.additionalData);
2988
+ const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
2989
+ return sass.compileString(contents, {
2990
+ importers: [
2991
+ createSassImporter(filePath, loadPaths, language, config)
2992
+ ],
2993
+ loadPaths,
2994
+ style: "expanded",
2995
+ syntax: language === "sass" ? "indented" : "scss",
2996
+ url: new URL(`file://${filePath}`)
2997
+ }).css;
2998
+ }
2999
+ if (language === "less") {
3000
+ 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.`);
3001
+ }
3002
+ if (language === "stylus") {
3003
+ 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.`);
3004
+ }
3005
+ return rawContents;
3006
+ }, getCssOutputExtension = (filePath) => isPreprocessableStylePath(filePath) ? ".css" : extname(filePath);
2884
3007
  var init_stylePreprocessor = __esm(() => {
3008
+ CSS_EXTENSION_PATTERN = /\.css$/i;
2885
3009
  STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less|styl(?:us)?)$/i;
2886
3010
  STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less|styl(?:us)?)$/i;
2887
3011
  STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less|styl(?:us)?)$/i;
@@ -3930,5 +4054,5 @@ export {
3930
4054
  Image_default as Image
3931
4055
  };
3932
4056
 
3933
- //# debugId=07750B0C39CFEF9564756E2164756E21
4057
+ //# debugId=A6AD6AAD03EBAC0964756E2164756E21
3934
4058
  //# sourceMappingURL=index.js.map