@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
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { BunPlugin } from 'bun';
|
|
2
|
+
export declare const isPreprocessableStylePath: (filePath: string) => boolean;
|
|
3
|
+
export declare const isStyleModulePath: (filePath: string) => boolean;
|
|
4
|
+
export declare const isStylePath: (filePath: string) => boolean;
|
|
5
|
+
export declare const getStyleBaseName: (filePath: string) => string;
|
|
6
|
+
export declare const compileStyleSource: (filePath: string, source?: string, languageHint?: string) => Promise<string>;
|
|
7
|
+
export declare const stylePreprocessorPlugin: BunPlugin;
|
|
8
|
+
export declare const createSvelteStylePreprocessor: () => {
|
|
9
|
+
style: ({ attributes, content, filename }: {
|
|
10
|
+
attributes: Record<string, string | boolean>;
|
|
11
|
+
content: string;
|
|
12
|
+
filename?: string;
|
|
13
|
+
}) => Promise<{
|
|
14
|
+
code: string;
|
|
15
|
+
} | undefined>;
|
|
16
|
+
};
|
|
17
|
+
export declare const compileStyleFileIfNeeded: (filePath: string) => Promise<string>;
|
|
18
|
+
export declare const getCssOutputExtension: (filePath: string) => string;
|
package/dist/svelte/index.js
CHANGED
|
@@ -358,11 +358,120 @@ var init_lowerAwaitSlotSyntax = __esm(() => {
|
|
|
358
358
|
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;
|
|
359
359
|
});
|
|
360
360
|
|
|
361
|
+
// src/build/stylePreprocessor.ts
|
|
362
|
+
import { readFile } from "fs/promises";
|
|
363
|
+
import { dirname, extname } from "path";
|
|
364
|
+
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) => {
|
|
365
|
+
const normalized = filePathOrLanguage.toLowerCase();
|
|
366
|
+
if (normalized === "scss" || normalized.endsWith(".scss"))
|
|
367
|
+
return "scss";
|
|
368
|
+
if (normalized === "sass" || normalized.endsWith(".sass"))
|
|
369
|
+
return "sass";
|
|
370
|
+
if (normalized === "less" || normalized.endsWith(".less"))
|
|
371
|
+
return "less";
|
|
372
|
+
return null;
|
|
373
|
+
}, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), compileStyleSource = async (filePath, source, languageHint) => {
|
|
374
|
+
const language = getStyleLanguage(languageHint ?? filePath);
|
|
375
|
+
const contents = source ?? await readFile(filePath, "utf-8");
|
|
376
|
+
if (language === "scss" || language === "sass") {
|
|
377
|
+
let sass;
|
|
378
|
+
try {
|
|
379
|
+
sass = await importOptionalPeer("sass");
|
|
380
|
+
} catch {
|
|
381
|
+
throw missingDependencyError("sass", filePath);
|
|
382
|
+
}
|
|
383
|
+
const result = sass.compileString(contents, {
|
|
384
|
+
loadPaths: [dirname(filePath), process.cwd()],
|
|
385
|
+
style: "expanded",
|
|
386
|
+
syntax: language === "sass" ? "indented" : "scss",
|
|
387
|
+
url: new URL(`file://${filePath}`)
|
|
388
|
+
});
|
|
389
|
+
return result.css;
|
|
390
|
+
}
|
|
391
|
+
if (language === "less") {
|
|
392
|
+
let lessModule;
|
|
393
|
+
try {
|
|
394
|
+
lessModule = await importOptionalPeer("less");
|
|
395
|
+
} catch {
|
|
396
|
+
throw missingDependencyError("less", filePath);
|
|
397
|
+
}
|
|
398
|
+
const less = lessModule.render ? lessModule : lessModule.default;
|
|
399
|
+
const render = less?.render;
|
|
400
|
+
if (!render)
|
|
401
|
+
throw missingDependencyError("less", filePath);
|
|
402
|
+
const result = await render(contents, {
|
|
403
|
+
filename: filePath,
|
|
404
|
+
paths: [dirname(filePath), process.cwd()]
|
|
405
|
+
});
|
|
406
|
+
return result.css;
|
|
407
|
+
}
|
|
408
|
+
return contents;
|
|
409
|
+
}, stylePreprocessorPlugin, createSvelteStylePreprocessor = () => ({
|
|
410
|
+
style: async ({
|
|
411
|
+
attributes,
|
|
412
|
+
content,
|
|
413
|
+
filename
|
|
414
|
+
}) => {
|
|
415
|
+
const language = typeof attributes.lang === "string" ? attributes.lang : typeof attributes.type === "string" ? attributes.type.replace(/^text\//, "") : null;
|
|
416
|
+
if (!language || !STYLE_LANGUAGE_PATTERN.test(language))
|
|
417
|
+
return;
|
|
418
|
+
const path = filename ?? `style.${language}`;
|
|
419
|
+
return {
|
|
420
|
+
code: await compileStyleSource(path, content, language)
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
}), compileStyleFileIfNeeded = async (filePath) => {
|
|
424
|
+
if (!isPreprocessableStylePath(filePath)) {
|
|
425
|
+
return readFile(filePath, "utf-8");
|
|
426
|
+
}
|
|
427
|
+
return compileStyleSource(filePath);
|
|
428
|
+
};
|
|
429
|
+
var init_stylePreprocessor = __esm(() => {
|
|
430
|
+
STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less)$/i;
|
|
431
|
+
STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less)$/i;
|
|
432
|
+
STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less)$/i;
|
|
433
|
+
importOptionalPeer = new Function("specifier", "return import(specifier)");
|
|
434
|
+
stylePreprocessorPlugin = {
|
|
435
|
+
name: "absolute-style-preprocessor",
|
|
436
|
+
setup(build) {
|
|
437
|
+
const cssModuleSources = new Map;
|
|
438
|
+
build.onResolve({ filter: /^absolute-style-module:/ }, ({ path }) => ({
|
|
439
|
+
namespace: "absolute-style-module",
|
|
440
|
+
path: path.slice("absolute-style-module:".length)
|
|
441
|
+
}));
|
|
442
|
+
build.onLoad({ filter: /\.module\.css$/i, namespace: "absolute-style-module" }, async ({ path }) => {
|
|
443
|
+
const sourcePath = cssModuleSources.get(path);
|
|
444
|
+
if (!sourcePath) {
|
|
445
|
+
throw new Error(`Unable to resolve CSS module source for ${path}`);
|
|
446
|
+
}
|
|
447
|
+
return {
|
|
448
|
+
contents: await compileStyleSource(sourcePath),
|
|
449
|
+
loader: "css"
|
|
450
|
+
};
|
|
451
|
+
});
|
|
452
|
+
build.onLoad({ filter: STYLE_EXTENSION_PATTERN }, async ({ path }) => {
|
|
453
|
+
if (isStyleModulePath(path)) {
|
|
454
|
+
const cssModulePath = path.replace(STYLE_EXTENSION_PATTERN, ".css");
|
|
455
|
+
cssModuleSources.set(cssModulePath, path);
|
|
456
|
+
return {
|
|
457
|
+
contents: `export { default } from ${JSON.stringify(`absolute-style-module:${cssModulePath}`)};`,
|
|
458
|
+
loader: "js"
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
return {
|
|
462
|
+
contents: await compileStyleSource(path),
|
|
463
|
+
loader: "css"
|
|
464
|
+
};
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
};
|
|
468
|
+
});
|
|
469
|
+
|
|
361
470
|
// src/core/svelteServerModule.ts
|
|
362
471
|
import { mkdir, readdir } from "fs/promises";
|
|
363
|
-
import { basename, dirname, extname, join as join2, relative, resolve as resolve2 } from "path";
|
|
472
|
+
import { basename, dirname as dirname2, extname as extname2, join as join2, relative, resolve as resolve2 } from "path";
|
|
364
473
|
var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, ensureRelativeImportPath = (from, target) => {
|
|
365
|
-
const importPath = relative(
|
|
474
|
+
const importPath = relative(dirname2(from), target).replace(/\\/g, "/");
|
|
366
475
|
return importPath.startsWith(".") ? importPath : `./${importPath}`;
|
|
367
476
|
}, processDirectoryEntries = (entries, dir, targetFileName, stack) => {
|
|
368
477
|
for (const entry of entries) {
|
|
@@ -408,7 +517,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
408
517
|
if (!spec.startsWith(".")) {
|
|
409
518
|
return null;
|
|
410
519
|
}
|
|
411
|
-
const basePath = resolve2(
|
|
520
|
+
const basePath = resolve2(dirname2(from), spec);
|
|
412
521
|
const candidates = [
|
|
413
522
|
basePath,
|
|
414
523
|
`${basePath}.ts`,
|
|
@@ -440,8 +549,8 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
440
549
|
if (!spec.startsWith(".")) {
|
|
441
550
|
return null;
|
|
442
551
|
}
|
|
443
|
-
const explicitPath = resolve2(
|
|
444
|
-
if (
|
|
552
|
+
const explicitPath = resolve2(dirname2(from), spec);
|
|
553
|
+
if (extname2(explicitPath) === ".svelte") {
|
|
445
554
|
return explicitPath;
|
|
446
555
|
}
|
|
447
556
|
const candidate = `${explicitPath}.svelte`;
|
|
@@ -469,7 +578,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
469
578
|
const { compile, preprocess } = await import("svelte/compiler");
|
|
470
579
|
const loweredAwaitSource = lowerSvelteAwaitSlotSyntax(source);
|
|
471
580
|
const loweredSource = lowerSvelteIslandSyntax(loweredAwaitSource.code, "server");
|
|
472
|
-
const preprocessed = await preprocess(loweredSource.code,
|
|
581
|
+
const preprocessed = await preprocess(loweredSource.code, createSvelteStylePreprocessor());
|
|
473
582
|
let transpiled = sourcePath.endsWith(".ts") || sourcePath.endsWith(".svelte.ts") ? transpiler.transformSync(preprocessed.code) : preprocessed.code;
|
|
474
583
|
const childImportSpecs = Array.from(transpiled.matchAll(/from\s+['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((value) => value !== undefined);
|
|
475
584
|
const resolvedChildModules = await Promise.all(childImportSpecs.map((spec) => resolveSvelteImport(spec, resolutionSourcePath)));
|
|
@@ -519,7 +628,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
519
628
|
compiledCode = compiledCode.replaceAll(spec, resolvedModuleImport);
|
|
520
629
|
}
|
|
521
630
|
const compiledModulePath = getCachedModulePath(sourcePath);
|
|
522
|
-
await mkdir(
|
|
631
|
+
await mkdir(dirname2(compiledModulePath), { recursive: true });
|
|
523
632
|
await writeIfChanged(compiledModulePath, compiledCode);
|
|
524
633
|
compiledModuleCache.set(sourcePath, compiledModulePath);
|
|
525
634
|
return compiledModulePath;
|
|
@@ -528,6 +637,7 @@ var init_svelteServerModule = __esm(() => {
|
|
|
528
637
|
init_resolvePackageImport();
|
|
529
638
|
init_lowerIslandSyntax();
|
|
530
639
|
init_lowerAwaitSlotSyntax();
|
|
640
|
+
init_stylePreprocessor();
|
|
531
641
|
serverCacheRoot = join2(process.cwd(), ".absolutejs", "islands", "svelte");
|
|
532
642
|
compiledModuleCache = new Map;
|
|
533
643
|
originalSourcePathCache = new Map;
|
|
@@ -2170,7 +2280,7 @@ var init_pageHandler = __esm(() => {
|
|
|
2170
2280
|
|
|
2171
2281
|
// src/angular/injectorPatch.ts
|
|
2172
2282
|
import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync } from "fs";
|
|
2173
|
-
import { dirname as
|
|
2283
|
+
import { dirname as dirname3, join as join3, resolve as resolve3 } from "path";
|
|
2174
2284
|
var applyInjectorPatch = (chunkPath, content) => {
|
|
2175
2285
|
if (content.includes('Symbol.for("angular.currentInjector")')) {
|
|
2176
2286
|
return;
|
|
@@ -2210,7 +2320,7 @@ var applyInjectorPatch = (chunkPath, content) => {
|
|
|
2210
2320
|
if (existsSync2(join3(fromProject, "package.json"))) {
|
|
2211
2321
|
return fromProject;
|
|
2212
2322
|
}
|
|
2213
|
-
return
|
|
2323
|
+
return dirname3(__require.resolve("@angular/core/package.json"));
|
|
2214
2324
|
}, patchAngularInjectorSingleton = () => {
|
|
2215
2325
|
try {
|
|
2216
2326
|
const coreDir = resolveAngularCoreDir();
|
|
@@ -3047,5 +3157,5 @@ export {
|
|
|
3047
3157
|
createTypedIsland
|
|
3048
3158
|
};
|
|
3049
3159
|
|
|
3050
|
-
//# debugId=
|
|
3160
|
+
//# debugId=2EBA4427D1B8908864756E2164756E21
|
|
3051
3161
|
//# sourceMappingURL=index.js.map
|