@absolutejs/absolute 0.19.0-beta.686 → 0.19.0-beta.688
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 +145 -27
- package/dist/angular/index.js.map +6 -5
- package/dist/angular/server.js +145 -27
- package/dist/angular/server.js.map +6 -5
- package/dist/build.js +237 -105
- package/dist/build.js.map +13 -12
- package/dist/index.js +252 -120
- package/dist/index.js.map +13 -12
- package/dist/islands/index.js +118 -8
- package/dist/islands/index.js.map +5 -4
- package/dist/react/index.js +118 -8
- package/dist/react/index.js.map +5 -4
- package/dist/src/build/stylePreprocessor.d.ts +18 -0
- package/dist/svelte/index.js +120 -10
- package/dist/svelte/index.js.map +5 -4
- package/dist/svelte/server.js +118 -8
- package/dist/svelte/server.js.map +5 -4
- package/dist/vue/index.js +118 -8
- package/dist/vue/index.js.map +5 -4
- package/package.json +17 -7
package/dist/vue/index.js
CHANGED
|
@@ -2565,11 +2565,120 @@ var init_lowerAwaitSlotSyntax = __esm(() => {
|
|
|
2565
2565
|
AWAIT_BLOCK_RE = /\{#await\s+([^}]+)\}([\s\S]*?)\{:then(?:\s+([A-Za-z_$][\w$]*))?\}([\s\S]*?)(?:\{:catch(?:\s+([A-Za-z_$][\w$]*))?\}([\s\S]*?))?\{\/await\}/g;
|
|
2566
2566
|
});
|
|
2567
2567
|
|
|
2568
|
+
// src/build/stylePreprocessor.ts
|
|
2569
|
+
import { readFile } from "fs/promises";
|
|
2570
|
+
import { dirname as dirname3, extname } from "path";
|
|
2571
|
+
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) => {
|
|
2572
|
+
const normalized = filePathOrLanguage.toLowerCase();
|
|
2573
|
+
if (normalized === "scss" || normalized.endsWith(".scss"))
|
|
2574
|
+
return "scss";
|
|
2575
|
+
if (normalized === "sass" || normalized.endsWith(".sass"))
|
|
2576
|
+
return "sass";
|
|
2577
|
+
if (normalized === "less" || normalized.endsWith(".less"))
|
|
2578
|
+
return "less";
|
|
2579
|
+
return null;
|
|
2580
|
+
}, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), compileStyleSource = async (filePath, source, languageHint) => {
|
|
2581
|
+
const language = getStyleLanguage(languageHint ?? filePath);
|
|
2582
|
+
const contents = source ?? await readFile(filePath, "utf-8");
|
|
2583
|
+
if (language === "scss" || language === "sass") {
|
|
2584
|
+
let sass;
|
|
2585
|
+
try {
|
|
2586
|
+
sass = await importOptionalPeer("sass");
|
|
2587
|
+
} catch {
|
|
2588
|
+
throw missingDependencyError("sass", filePath);
|
|
2589
|
+
}
|
|
2590
|
+
const result = sass.compileString(contents, {
|
|
2591
|
+
loadPaths: [dirname3(filePath), process.cwd()],
|
|
2592
|
+
style: "expanded",
|
|
2593
|
+
syntax: language === "sass" ? "indented" : "scss",
|
|
2594
|
+
url: new URL(`file://${filePath}`)
|
|
2595
|
+
});
|
|
2596
|
+
return result.css;
|
|
2597
|
+
}
|
|
2598
|
+
if (language === "less") {
|
|
2599
|
+
let lessModule;
|
|
2600
|
+
try {
|
|
2601
|
+
lessModule = await importOptionalPeer("less");
|
|
2602
|
+
} catch {
|
|
2603
|
+
throw missingDependencyError("less", filePath);
|
|
2604
|
+
}
|
|
2605
|
+
const less = lessModule.render ? lessModule : lessModule.default;
|
|
2606
|
+
const render = less?.render;
|
|
2607
|
+
if (!render)
|
|
2608
|
+
throw missingDependencyError("less", filePath);
|
|
2609
|
+
const result = await render(contents, {
|
|
2610
|
+
filename: filePath,
|
|
2611
|
+
paths: [dirname3(filePath), process.cwd()]
|
|
2612
|
+
});
|
|
2613
|
+
return result.css;
|
|
2614
|
+
}
|
|
2615
|
+
return contents;
|
|
2616
|
+
}, stylePreprocessorPlugin, createSvelteStylePreprocessor = () => ({
|
|
2617
|
+
style: async ({
|
|
2618
|
+
attributes,
|
|
2619
|
+
content,
|
|
2620
|
+
filename
|
|
2621
|
+
}) => {
|
|
2622
|
+
const language = typeof attributes.lang === "string" ? attributes.lang : typeof attributes.type === "string" ? attributes.type.replace(/^text\//, "") : null;
|
|
2623
|
+
if (!language || !STYLE_LANGUAGE_PATTERN.test(language))
|
|
2624
|
+
return;
|
|
2625
|
+
const path = filename ?? `style.${language}`;
|
|
2626
|
+
return {
|
|
2627
|
+
code: await compileStyleSource(path, content, language)
|
|
2628
|
+
};
|
|
2629
|
+
}
|
|
2630
|
+
}), compileStyleFileIfNeeded = async (filePath) => {
|
|
2631
|
+
if (!isPreprocessableStylePath(filePath)) {
|
|
2632
|
+
return readFile(filePath, "utf-8");
|
|
2633
|
+
}
|
|
2634
|
+
return compileStyleSource(filePath);
|
|
2635
|
+
};
|
|
2636
|
+
var init_stylePreprocessor = __esm(() => {
|
|
2637
|
+
STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less)$/i;
|
|
2638
|
+
STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less)$/i;
|
|
2639
|
+
STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less)$/i;
|
|
2640
|
+
importOptionalPeer = new Function("specifier", "return import(specifier)");
|
|
2641
|
+
stylePreprocessorPlugin = {
|
|
2642
|
+
name: "absolute-style-preprocessor",
|
|
2643
|
+
setup(build) {
|
|
2644
|
+
const cssModuleSources = new Map;
|
|
2645
|
+
build.onResolve({ filter: /^absolute-style-module:/ }, ({ path }) => ({
|
|
2646
|
+
namespace: "absolute-style-module",
|
|
2647
|
+
path: path.slice("absolute-style-module:".length)
|
|
2648
|
+
}));
|
|
2649
|
+
build.onLoad({ filter: /\.module\.css$/i, namespace: "absolute-style-module" }, async ({ path }) => {
|
|
2650
|
+
const sourcePath = cssModuleSources.get(path);
|
|
2651
|
+
if (!sourcePath) {
|
|
2652
|
+
throw new Error(`Unable to resolve CSS module source for ${path}`);
|
|
2653
|
+
}
|
|
2654
|
+
return {
|
|
2655
|
+
contents: await compileStyleSource(sourcePath),
|
|
2656
|
+
loader: "css"
|
|
2657
|
+
};
|
|
2658
|
+
});
|
|
2659
|
+
build.onLoad({ filter: STYLE_EXTENSION_PATTERN }, async ({ path }) => {
|
|
2660
|
+
if (isStyleModulePath(path)) {
|
|
2661
|
+
const cssModulePath = path.replace(STYLE_EXTENSION_PATTERN, ".css");
|
|
2662
|
+
cssModuleSources.set(cssModulePath, path);
|
|
2663
|
+
return {
|
|
2664
|
+
contents: `export { default } from ${JSON.stringify(`absolute-style-module:${cssModulePath}`)};`,
|
|
2665
|
+
loader: "js"
|
|
2666
|
+
};
|
|
2667
|
+
}
|
|
2668
|
+
return {
|
|
2669
|
+
contents: await compileStyleSource(path),
|
|
2670
|
+
loader: "css"
|
|
2671
|
+
};
|
|
2672
|
+
});
|
|
2673
|
+
}
|
|
2674
|
+
};
|
|
2675
|
+
});
|
|
2676
|
+
|
|
2568
2677
|
// src/core/svelteServerModule.ts
|
|
2569
2678
|
import { mkdir, readdir as readdir2 } from "fs/promises";
|
|
2570
|
-
import { basename as basename3, dirname as
|
|
2679
|
+
import { basename as basename3, dirname as dirname4, extname as extname2, join as join3, relative, resolve as resolve4 } from "path";
|
|
2571
2680
|
var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, ensureRelativeImportPath = (from, target) => {
|
|
2572
|
-
const importPath = relative(
|
|
2681
|
+
const importPath = relative(dirname4(from), target).replace(/\\/g, "/");
|
|
2573
2682
|
return importPath.startsWith(".") ? importPath : `./${importPath}`;
|
|
2574
2683
|
}, processDirectoryEntries = (entries, dir, targetFileName, stack) => {
|
|
2575
2684
|
for (const entry of entries) {
|
|
@@ -2615,7 +2724,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
2615
2724
|
if (!spec.startsWith(".")) {
|
|
2616
2725
|
return null;
|
|
2617
2726
|
}
|
|
2618
|
-
const basePath = resolve4(
|
|
2727
|
+
const basePath = resolve4(dirname4(from), spec);
|
|
2619
2728
|
const candidates = [
|
|
2620
2729
|
basePath,
|
|
2621
2730
|
`${basePath}.ts`,
|
|
@@ -2647,8 +2756,8 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
2647
2756
|
if (!spec.startsWith(".")) {
|
|
2648
2757
|
return null;
|
|
2649
2758
|
}
|
|
2650
|
-
const explicitPath = resolve4(
|
|
2651
|
-
if (
|
|
2759
|
+
const explicitPath = resolve4(dirname4(from), spec);
|
|
2760
|
+
if (extname2(explicitPath) === ".svelte") {
|
|
2652
2761
|
return explicitPath;
|
|
2653
2762
|
}
|
|
2654
2763
|
const candidate = `${explicitPath}.svelte`;
|
|
@@ -2676,7 +2785,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
2676
2785
|
const { compile, preprocess } = await import("svelte/compiler");
|
|
2677
2786
|
const loweredAwaitSource = lowerSvelteAwaitSlotSyntax(source);
|
|
2678
2787
|
const loweredSource = lowerSvelteIslandSyntax(loweredAwaitSource.code, "server");
|
|
2679
|
-
const preprocessed = await preprocess(loweredSource.code,
|
|
2788
|
+
const preprocessed = await preprocess(loweredSource.code, createSvelteStylePreprocessor());
|
|
2680
2789
|
let transpiled = sourcePath.endsWith(".ts") || sourcePath.endsWith(".svelte.ts") ? transpiler.transformSync(preprocessed.code) : preprocessed.code;
|
|
2681
2790
|
const childImportSpecs = Array.from(transpiled.matchAll(/from\s+['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((value) => value !== undefined);
|
|
2682
2791
|
const resolvedChildModules = await Promise.all(childImportSpecs.map((spec) => resolveSvelteImport(spec, resolutionSourcePath)));
|
|
@@ -2726,7 +2835,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
2726
2835
|
compiledCode = compiledCode.replaceAll(spec, resolvedModuleImport);
|
|
2727
2836
|
}
|
|
2728
2837
|
const compiledModulePath = getCachedModulePath(sourcePath);
|
|
2729
|
-
await mkdir(
|
|
2838
|
+
await mkdir(dirname4(compiledModulePath), { recursive: true });
|
|
2730
2839
|
await writeIfChanged(compiledModulePath, compiledCode);
|
|
2731
2840
|
compiledModuleCache.set(sourcePath, compiledModulePath);
|
|
2732
2841
|
return compiledModulePath;
|
|
@@ -2735,6 +2844,7 @@ var init_svelteServerModule = __esm(() => {
|
|
|
2735
2844
|
init_resolvePackageImport();
|
|
2736
2845
|
init_lowerIslandSyntax();
|
|
2737
2846
|
init_lowerAwaitSlotSyntax();
|
|
2847
|
+
init_stylePreprocessor();
|
|
2738
2848
|
serverCacheRoot = join3(process.cwd(), ".absolutejs", "islands", "svelte");
|
|
2739
2849
|
compiledModuleCache = new Map;
|
|
2740
2850
|
originalSourcePathCache = new Map;
|
|
@@ -3603,5 +3713,5 @@ export {
|
|
|
3603
3713
|
Image_default as Image
|
|
3604
3714
|
};
|
|
3605
3715
|
|
|
3606
|
-
//# debugId=
|
|
3716
|
+
//# debugId=06E121A885ECE00A64756E2164756E21
|
|
3607
3717
|
//# sourceMappingURL=index.js.map
|