@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.
@@ -1351,11 +1351,120 @@ var init_lowerAwaitSlotSyntax = __esm(() => {
1351
1351
  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;
1352
1352
  });
1353
1353
 
1354
+ // src/build/stylePreprocessor.ts
1355
+ import { readFile } from "fs/promises";
1356
+ 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
+ const normalized = filePathOrLanguage.toLowerCase();
1359
+ if (normalized === "scss" || normalized.endsWith(".scss"))
1360
+ return "scss";
1361
+ if (normalized === "sass" || normalized.endsWith(".sass"))
1362
+ return "sass";
1363
+ if (normalized === "less" || normalized.endsWith(".less"))
1364
+ return "less";
1365
+ return null;
1366
+ }, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), compileStyleSource = async (filePath, source, languageHint) => {
1367
+ const language = getStyleLanguage(languageHint ?? filePath);
1368
+ const contents = source ?? await readFile(filePath, "utf-8");
1369
+ if (language === "scss" || language === "sass") {
1370
+ let sass;
1371
+ try {
1372
+ sass = await importOptionalPeer("sass");
1373
+ } catch {
1374
+ throw missingDependencyError("sass", filePath);
1375
+ }
1376
+ const result = sass.compileString(contents, {
1377
+ loadPaths: [dirname2(filePath), process.cwd()],
1378
+ style: "expanded",
1379
+ syntax: language === "sass" ? "indented" : "scss",
1380
+ url: new URL(`file://${filePath}`)
1381
+ });
1382
+ return result.css;
1383
+ }
1384
+ if (language === "less") {
1385
+ let lessModule;
1386
+ try {
1387
+ lessModule = await importOptionalPeer("less");
1388
+ } catch {
1389
+ throw missingDependencyError("less", filePath);
1390
+ }
1391
+ const less = lessModule.render ? lessModule : lessModule.default;
1392
+ const render = less?.render;
1393
+ if (!render)
1394
+ throw missingDependencyError("less", filePath);
1395
+ const result = await render(contents, {
1396
+ filename: filePath,
1397
+ paths: [dirname2(filePath), process.cwd()]
1398
+ });
1399
+ return result.css;
1400
+ }
1401
+ return contents;
1402
+ }, stylePreprocessorPlugin, createSvelteStylePreprocessor = () => ({
1403
+ style: async ({
1404
+ attributes,
1405
+ content,
1406
+ filename
1407
+ }) => {
1408
+ const language = typeof attributes.lang === "string" ? attributes.lang : typeof attributes.type === "string" ? attributes.type.replace(/^text\//, "") : null;
1409
+ if (!language || !STYLE_LANGUAGE_PATTERN.test(language))
1410
+ return;
1411
+ const path = filename ?? `style.${language}`;
1412
+ return {
1413
+ code: await compileStyleSource(path, content, language)
1414
+ };
1415
+ }
1416
+ }), compileStyleFileIfNeeded = async (filePath) => {
1417
+ if (!isPreprocessableStylePath(filePath)) {
1418
+ return readFile(filePath, "utf-8");
1419
+ }
1420
+ return compileStyleSource(filePath);
1421
+ };
1422
+ var init_stylePreprocessor = __esm(() => {
1423
+ STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less)$/i;
1424
+ STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less)$/i;
1425
+ STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less)$/i;
1426
+ importOptionalPeer = new Function("specifier", "return import(specifier)");
1427
+ stylePreprocessorPlugin = {
1428
+ name: "absolute-style-preprocessor",
1429
+ setup(build) {
1430
+ const cssModuleSources = new Map;
1431
+ build.onResolve({ filter: /^absolute-style-module:/ }, ({ path }) => ({
1432
+ namespace: "absolute-style-module",
1433
+ path: path.slice("absolute-style-module:".length)
1434
+ }));
1435
+ build.onLoad({ filter: /\.module\.css$/i, namespace: "absolute-style-module" }, async ({ path }) => {
1436
+ const sourcePath = cssModuleSources.get(path);
1437
+ if (!sourcePath) {
1438
+ throw new Error(`Unable to resolve CSS module source for ${path}`);
1439
+ }
1440
+ return {
1441
+ contents: await compileStyleSource(sourcePath),
1442
+ loader: "css"
1443
+ };
1444
+ });
1445
+ build.onLoad({ filter: STYLE_EXTENSION_PATTERN }, async ({ path }) => {
1446
+ if (isStyleModulePath(path)) {
1447
+ const cssModulePath = path.replace(STYLE_EXTENSION_PATTERN, ".css");
1448
+ cssModuleSources.set(cssModulePath, path);
1449
+ return {
1450
+ contents: `export { default } from ${JSON.stringify(`absolute-style-module:${cssModulePath}`)};`,
1451
+ loader: "js"
1452
+ };
1453
+ }
1454
+ return {
1455
+ contents: await compileStyleSource(path),
1456
+ loader: "css"
1457
+ };
1458
+ });
1459
+ }
1460
+ };
1461
+ });
1462
+
1354
1463
  // src/core/svelteServerModule.ts
1355
1464
  import { mkdir, readdir } from "fs/promises";
1356
- import { basename as basename2, dirname as dirname2, extname, join as join3, relative, resolve as resolve4 } from "path";
1465
+ import { basename as basename2, dirname as dirname3, extname as extname2, join as join3, relative, resolve as resolve4 } from "path";
1357
1466
  var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, ensureRelativeImportPath = (from, target) => {
1358
- const importPath = relative(dirname2(from), target).replace(/\\/g, "/");
1467
+ const importPath = relative(dirname3(from), target).replace(/\\/g, "/");
1359
1468
  return importPath.startsWith(".") ? importPath : `./${importPath}`;
1360
1469
  }, processDirectoryEntries = (entries, dir, targetFileName, stack) => {
1361
1470
  for (const entry of entries) {
@@ -1401,7 +1510,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
1401
1510
  if (!spec.startsWith(".")) {
1402
1511
  return null;
1403
1512
  }
1404
- const basePath = resolve4(dirname2(from), spec);
1513
+ const basePath = resolve4(dirname3(from), spec);
1405
1514
  const candidates = [
1406
1515
  basePath,
1407
1516
  `${basePath}.ts`,
@@ -1433,8 +1542,8 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
1433
1542
  if (!spec.startsWith(".")) {
1434
1543
  return null;
1435
1544
  }
1436
- const explicitPath = resolve4(dirname2(from), spec);
1437
- if (extname(explicitPath) === ".svelte") {
1545
+ const explicitPath = resolve4(dirname3(from), spec);
1546
+ if (extname2(explicitPath) === ".svelte") {
1438
1547
  return explicitPath;
1439
1548
  }
1440
1549
  const candidate = `${explicitPath}.svelte`;
@@ -1462,7 +1571,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
1462
1571
  const { compile, preprocess } = await import("svelte/compiler");
1463
1572
  const loweredAwaitSource = lowerSvelteAwaitSlotSyntax(source);
1464
1573
  const loweredSource = lowerSvelteIslandSyntax(loweredAwaitSource.code, "server");
1465
- const preprocessed = await preprocess(loweredSource.code, {});
1574
+ const preprocessed = await preprocess(loweredSource.code, createSvelteStylePreprocessor());
1466
1575
  let transpiled = sourcePath.endsWith(".ts") || sourcePath.endsWith(".svelte.ts") ? transpiler.transformSync(preprocessed.code) : preprocessed.code;
1467
1576
  const childImportSpecs = Array.from(transpiled.matchAll(/from\s+['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((value) => value !== undefined);
1468
1577
  const resolvedChildModules = await Promise.all(childImportSpecs.map((spec) => resolveSvelteImport(spec, resolutionSourcePath)));
@@ -1512,7 +1621,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
1512
1621
  compiledCode = compiledCode.replaceAll(spec, resolvedModuleImport);
1513
1622
  }
1514
1623
  const compiledModulePath = getCachedModulePath(sourcePath);
1515
- await mkdir(dirname2(compiledModulePath), { recursive: true });
1624
+ await mkdir(dirname3(compiledModulePath), { recursive: true });
1516
1625
  await writeIfChanged(compiledModulePath, compiledCode);
1517
1626
  compiledModuleCache.set(sourcePath, compiledModulePath);
1518
1627
  return compiledModulePath;
@@ -1521,6 +1630,7 @@ var init_svelteServerModule = __esm(() => {
1521
1630
  init_resolvePackageImport();
1522
1631
  init_lowerIslandSyntax();
1523
1632
  init_lowerAwaitSlotSyntax();
1633
+ init_stylePreprocessor();
1524
1634
  serverCacheRoot = join3(process.cwd(), ".absolutejs", "islands", "svelte");
1525
1635
  compiledModuleCache = new Map;
1526
1636
  originalSourcePathCache = new Map;
@@ -3406,7 +3516,7 @@ __export(exports_compileAngular, {
3406
3516
  compileAngular: () => compileAngular
3407
3517
  });
3408
3518
  import { existsSync as existsSync4, readFileSync as readFileSync3, promises as fs } from "fs";
3409
- import { join as join4, basename as basename3, sep, dirname as dirname3, resolve as resolve5, relative as relative2 } from "path";
3519
+ import { join as join4, basename as basename3, sep, dirname as dirname4, resolve as resolve5, relative as relative2 } from "path";
3410
3520
  import ts from "typescript";
3411
3521
  import { createHash } from "crypto";
3412
3522
  var computeConfigHash = () => {
@@ -3470,11 +3580,7 @@ ${registrations}
3470
3580
  return fileName;
3471
3581
  }, compileAngularFile = async (inputPath, outDir) => {
3472
3582
  const islandMetadataExports = buildIslandMetadataExports(readFileSync3(inputPath, "utf-8"));
3473
- const {
3474
- readConfiguration,
3475
- performCompilation,
3476
- EmitFlags
3477
- } = await import("@angular/compiler-cli");
3583
+ const { readConfiguration, performCompilation, EmitFlags } = await import("@angular/compiler-cli");
3478
3584
  const configHash = computeConfigHash();
3479
3585
  const cached = globalThis.__angularCompilerCache;
3480
3586
  let host;
@@ -3487,7 +3593,7 @@ ${registrations}
3487
3593
  cached.lastUsed = Date.now();
3488
3594
  } else {
3489
3595
  const tsPath = __require.resolve("typescript");
3490
- const tsRootDir = dirname3(tsPath);
3596
+ const tsRootDir = dirname4(tsPath);
3491
3597
  tsLibDir = tsRootDir.endsWith("lib") ? tsRootDir : resolve5(tsRootDir, "lib");
3492
3598
  const config = readConfiguration("./tsconfig.json");
3493
3599
  options = {
@@ -3553,7 +3659,7 @@ ${registrations}
3553
3659
  const cached2 = aotTransformCache.get(resolvedPath);
3554
3660
  if (cached2 !== undefined)
3555
3661
  return cached2;
3556
- const transformed = inlineTemplateAndLowerDeferSync(source, dirname3(resolvedPath)).source;
3662
+ const transformed = inlineTemplateAndLowerDeferSync(source, dirname4(resolvedPath)).source;
3557
3663
  aotTransformCache.set(resolvedPath, transformed);
3558
3664
  return transformed;
3559
3665
  };
@@ -3595,7 +3701,7 @@ ${registrations}
3595
3701
  processedContent += islandMetadataExports;
3596
3702
  return { content: processedContent, target };
3597
3703
  });
3598
- await Promise.all(entries.map(({ target }) => fs.mkdir(dirname3(target), { recursive: true })));
3704
+ await Promise.all(entries.map(({ target }) => fs.mkdir(dirname4(target), { recursive: true })));
3599
3705
  await Promise.all(entries.map(({ target, content }) => fs.writeFile(target, content, "utf-8")));
3600
3706
  return entries.map(({ target }) => target);
3601
3707
  }, jitContentCache, wrapperOutputCache, escapeTemplateContent = (content) => content.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${"), resolveAngularDeferImportSpecifier = () => {
@@ -3730,7 +3836,7 @@ ${fields}
3730
3836
  }, readAndEscapeFile = async (filePath) => {
3731
3837
  if (!existsSync4(filePath))
3732
3838
  return null;
3733
- const content = await fs.readFile(filePath, "utf-8");
3839
+ const content = await compileStyleFileIfNeeded(filePath);
3734
3840
  return escapeTemplateContent(content);
3735
3841
  }, inlineTemplateAndLowerDefer = async (source, fileDir) => {
3736
3842
  const templateUrlMatch = source.match(/templateUrl\s*:\s*['"]([^'"]+)['"]/);
@@ -3884,9 +3990,9 @@ ${fields}
3884
3990
  if (!existsSync4(actualPath))
3885
3991
  return;
3886
3992
  let sourceCode = await fs.readFile(actualPath, "utf-8");
3887
- const inlined = await inlineResources(sourceCode, dirname3(actualPath));
3888
- sourceCode = inlineTemplateAndLowerDeferSync(inlined.source, dirname3(actualPath)).source;
3889
- const inputDir = dirname3(actualPath);
3993
+ const inlined = await inlineResources(sourceCode, dirname4(actualPath));
3994
+ sourceCode = inlineTemplateAndLowerDeferSync(inlined.source, dirname4(actualPath)).source;
3995
+ const inputDir = dirname4(actualPath);
3890
3996
  const relativeDir = inputDir.startsWith(baseDir) ? inputDir.substring(baseDir.length + 1) : inputDir;
3891
3997
  const fileBase = basename3(actualPath).replace(/\.ts$/, ".js");
3892
3998
  const targetDir = join4(outDir, relativeDir);
@@ -3914,7 +4020,7 @@ ${fields}
3914
4020
  allOutputs.push(targetPath);
3915
4021
  jitContentCache.set(cacheKey, contentHash);
3916
4022
  }
3917
- const inputDirForResolve = dirname3(actualPath);
4023
+ const inputDirForResolve = dirname4(actualPath);
3918
4024
  await Promise.all(localImports.map((imp) => {
3919
4025
  const importPath = resolve5(inputDirForResolve, imp);
3920
4026
  return transpileFile(importPath);
@@ -3977,7 +4083,11 @@ ${fields}
3977
4083
  const cachedWrapper = wrapperOutputCache.get(resolvedEntry);
3978
4084
  const clientFile = join4(indexesDir, jsName);
3979
4085
  if (hmr && cachedWrapper && cachedWrapper.serverHash === serverContentHash && existsSync4(clientFile)) {
3980
- return { clientPath: clientFile, indexUnchanged: true, serverPath: rawServerFile };
4086
+ return {
4087
+ clientPath: clientFile,
4088
+ indexUnchanged: true,
4089
+ serverPath: rawServerFile
4090
+ };
3981
4091
  }
3982
4092
  let rewritten = original;
3983
4093
  if (!rewritten.includes(`import '@angular/compiler';`)) {
@@ -4134,8 +4244,15 @@ if (pageHasRawStreamingSlots) {
4134
4244
  const indexHash = Bun.hash(hydration).toString(BASE_36_RADIX);
4135
4245
  const indexUnchanged = cachedWrapper?.indexHash === indexHash;
4136
4246
  await fs.writeFile(clientFile, hydration, "utf-8");
4137
- wrapperOutputCache.set(resolvedEntry, { indexHash, serverHash: serverContentHash });
4138
- return { clientPath: clientFile, indexUnchanged, serverPath: rawServerFile };
4247
+ wrapperOutputCache.set(resolvedEntry, {
4248
+ indexHash,
4249
+ serverHash: serverContentHash
4250
+ });
4251
+ return {
4252
+ clientPath: clientFile,
4253
+ indexUnchanged,
4254
+ serverPath: rawServerFile
4255
+ };
4139
4256
  });
4140
4257
  const results = await Promise.all(compileTasks);
4141
4258
  const serverPaths = results.map((r) => r.serverPath);
@@ -4150,6 +4267,7 @@ var init_compileAngular = __esm(() => {
4150
4267
  init_constants();
4151
4268
  init_sourceMetadata();
4152
4269
  init_lowerDeferSyntax();
4270
+ init_stylePreprocessor();
4153
4271
  devClientDir = resolveDevClientDir();
4154
4272
  hmrClientPath = join4(devClientDir, "hmrClient.ts").replace(/\\/g, "/");
4155
4273
  hmrRuntimePath = join4(devClientDir, "handlers", "angularRuntime.ts").replace(/\\/g, "/");
@@ -4161,14 +4279,14 @@ var init_compileAngular = __esm(() => {
4161
4279
  import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
4162
4280
  import { mkdir as mkdir2, symlink } from "fs/promises";
4163
4281
  import { tmpdir } from "os";
4164
- import { basename as basename4, dirname as dirname4, join as join5, resolve as resolve6 } from "path";
4282
+ import { basename as basename4, dirname as dirname5, join as join5, resolve as resolve6 } from "path";
4165
4283
  var ssrDirty = false, lastSelector = "angular-page", isRecord5 = (value) => typeof value === "object" && value !== null, isAngularComponent = (value) => typeof value === "function", compilerImportPromise = null, ensureAngularCompiler = () => {
4166
4284
  if (!compilerImportPromise) {
4167
4285
  compilerImportPromise = import("@angular/compiler");
4168
4286
  }
4169
4287
  return compilerImportPromise;
4170
4288
  }, readAngularPageModule = (value) => isRecord5(value) ? value : null, resolveAngularSsrOutDir = () => process.env.ABSOLUTE_ANGULAR_SSR_OUTDIR ?? join5(tmpdir(), "absolutejs", "generated", "angular-ssr"), ensureAngularSsrNodeModules = async (outDir) => {
4171
- const outRoot = resolve6(dirname4(dirname4(outDir)));
4289
+ const outRoot = resolve6(dirname5(dirname5(outDir)));
4172
4290
  const nodeModulesLink = join5(outRoot, "node_modules");
4173
4291
  if (process.env.ABSOLUTE_ANGULAR_SSR_OUTDIR) {
4174
4292
  return;
@@ -13544,5 +13662,5 @@ export {
13544
13662
  Island
13545
13663
  };
13546
13664
 
13547
- //# debugId=962248461B9BD20764756E2164756E21
13665
+ //# debugId=430C10B9B0F9B06E64756E2164756E21
13548
13666
  //# sourceMappingURL=index.js.map