@absolutejs/absolute 0.19.0-beta.702 → 0.19.0-beta.703

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/cli/index.js CHANGED
@@ -629,7 +629,7 @@ __export(exports_prerender, {
629
629
  });
630
630
  import { mkdirSync as mkdirSync3, readFileSync as readFileSync6 } from "fs";
631
631
  import { join as join5 } from "path";
632
- var MAX_STARTUP_ATTEMPTS = 50, STARTUP_POLL_INTERVAL_MS = 100, PRERENDER_BYPASS_HEADER = "X-Absolute-Prerender-Bypass", routeToFilename = (route) => route === "/" ? "index.html" : `${route.slice(1).replace(/\//g, "-")}.html`, writeTimestamp = async (htmlPath) => {
632
+ var SERVER_OUTPUT_LIMIT = 4000, MAX_STARTUP_ATTEMPTS = 50, STARTUP_POLL_INTERVAL_MS = 100, PRERENDER_BYPASS_HEADER = "X-Absolute-Prerender-Bypass", routeToFilename = (route) => route === "/" ? "index.html" : `${route.slice(1).replace(/\//g, "-")}.html`, writeTimestamp = async (htmlPath) => {
633
633
  const metaPath = htmlPath.replace(/\.html$/, ".meta");
634
634
  await Bun.write(metaPath, String(Date.now()));
635
635
  }, readTimestamp = (htmlPath) => {
@@ -735,17 +735,49 @@ var MAX_STARTUP_ATTEMPTS = 50, STARTUP_POLL_INTERVAL_MS = 100, PRERENDER_BYPASS_
735
735
  await Bun.sleep(STARTUP_POLL_INTERVAL_MS);
736
736
  }
737
737
  return false;
738
+ }, captureStreamOutput = (stream, output) => {
739
+ if (!stream)
740
+ return;
741
+ const reader = stream.getReader();
742
+ const decoder = new TextDecoder;
743
+ const read = () => {
744
+ reader.read().then(({ done, value }) => {
745
+ if (done)
746
+ return;
747
+ output.push(decoder.decode(value, { stream: true }));
748
+ read();
749
+ }).catch(() => {});
750
+ };
751
+ read();
752
+ }, formatServerOutput = (output) => {
753
+ const text = output.join("").trim();
754
+ if (!text)
755
+ return "";
756
+ return text.length > SERVER_OUTPUT_LIMIT ? text.slice(-SERVER_OUTPUT_LIMIT) : text;
757
+ }, createServerStartupError = (output) => {
758
+ const serverOutput = formatServerOutput(output);
759
+ const message = serverOutput ? `Server failed to start for pre-rendering.
760
+
761
+ Server output:
762
+ ${serverOutput}` : "Server failed to start for pre-rendering";
763
+ return new Error(message);
738
764
  }, prerenderWithServer = async (serverBundlePath, port, outDir, staticConfig, env2, log) => {
765
+ const serverOutput = [];
739
766
  const serverProcess = Bun.spawn(["bun", "run", serverBundlePath], {
740
767
  cwd: process.cwd(),
741
768
  env: { ...process.env, ...env2, PORT: String(port) },
742
769
  stderr: "pipe",
743
770
  stdout: "pipe"
744
771
  });
772
+ captureStreamOutput(serverProcess.stdout, serverOutput);
773
+ captureStreamOutput(serverProcess.stderr, serverOutput);
745
774
  const ready = await waitForServerReady(port);
746
775
  if (!ready) {
747
776
  serverProcess.kill();
748
- throw new Error("Server failed to start for pre-rendering");
777
+ await serverProcess.exited.catch(() => {
778
+ return;
779
+ });
780
+ throw createServerStartupError(serverOutput);
749
781
  }
750
782
  const result = await prerender(port, outDir, staticConfig, log);
751
783
  serverProcess.kill();
@@ -762,7 +794,12 @@ __export(exports_compile, {
762
794
  var {env: env3 } = globalThis.Bun;
763
795
  import { existsSync as existsSync9, readdirSync as readdirSync2, readFileSync as readFileSync9, unlinkSync as unlinkSync2 } from "fs";
764
796
  import { basename as basename2, join as join6, relative, resolve as resolve7 } from "path";
765
- var cliTag3 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`, collectFiles2 = (dir) => {
797
+ var cliTag3 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`, compileBanner = (version2) => {
798
+ const resolvedVersion = version2 || "unknown";
799
+ console.log("");
800
+ console.log(` \x1B[36m\x1B[1mABSOLUTEJS\x1B[0m \x1B[2mv${resolvedVersion}\x1B[0m \x1B[2mcompile\x1B[0m`);
801
+ console.log("");
802
+ }, collectFiles2 = (dir) => {
766
803
  const result = [];
767
804
  let pending = readdirSync2(dir, { withFileTypes: true });
768
805
  while (pending.length > 0) {
@@ -951,6 +988,7 @@ console.log(\`
951
988
  resolve7(import.meta.dir, "..", "..", "..", "package.json"),
952
989
  resolve7(import.meta.dir, "..", "..", "package.json")
953
990
  ]);
991
+ compileBanner(absoluteVersion);
954
992
  const totalStart = performance.now();
955
993
  const buildStart = performance.now();
956
994
  process.stdout.write(cliTag3("\x1B[36m", "Building assets"));
package/dist/index.js CHANGED
@@ -2372,6 +2372,22 @@ var frameworks, isRecord4 = (value) => typeof value === "object" && value !== nu
2372
2372
  source
2373
2373
  });
2374
2374
  }
2375
+ }, isIslandRegistryHelperImport = (source) => source === "@absolutejs/absolute/islands" || source.endsWith("/islands") || source.endsWith("/core/islands"), collectRegistryHelperImports = (importClause, source, registryFactoryNames, registryNamespaceNames) => {
2376
+ if (!isIslandRegistryHelperImport(source))
2377
+ return;
2378
+ const bindings = importClause.namedBindings;
2379
+ if (!bindings)
2380
+ return;
2381
+ if (ts.isNamespaceImport(bindings)) {
2382
+ registryNamespaceNames.add(bindings.name.text);
2383
+ return;
2384
+ }
2385
+ for (const element of bindings.elements) {
2386
+ const importedName = element.propertyName?.text ?? element.name.text;
2387
+ if (importedName === "defineIslandRegistry") {
2388
+ registryFactoryNames.add(element.name.text);
2389
+ }
2390
+ }
2375
2391
  }, createRegistryEntryValue = (reference) => ({
2376
2392
  component: reference.source,
2377
2393
  export: reference.export,
@@ -2421,11 +2437,16 @@ var frameworks, isRecord4 = (value) => typeof value === "object" && value !== nu
2421
2437
  continue;
2422
2438
  addRegistryEntries(property.initializer, framework, imports, definitions, registry);
2423
2439
  }
2424
- }, walkRegistryNode = (node, imports, definitions, registry) => {
2425
- if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === "defineIslandRegistry") {
2440
+ }, walkRegistryNode = (node, imports, registryFactoryNames, registryNamespaceNames, definitions, registry) => {
2441
+ if (ts.isCallExpression(node) && isDefineIslandRegistryCall(node.expression, registryFactoryNames, registryNamespaceNames)) {
2426
2442
  processDefineIslandRegistry(node, imports, definitions, registry);
2427
2443
  }
2428
- ts.forEachChild(node, (child) => walkRegistryNode(child, imports, definitions, registry));
2444
+ ts.forEachChild(node, (child) => walkRegistryNode(child, imports, registryFactoryNames, registryNamespaceNames, definitions, registry));
2445
+ }, isDefineIslandRegistryCall = (expression, registryFactoryNames, registryNamespaceNames) => {
2446
+ if (ts.isIdentifier(expression)) {
2447
+ return registryFactoryNames.has(expression.text);
2448
+ }
2449
+ return ts.isPropertyAccessExpression(expression) && expression.name.text === "defineIslandRegistry" && ts.isIdentifier(expression.expression) && registryNamespaceNames.has(expression.expression.text);
2429
2450
  }, hasIslandRegistryNamedExport = (sourceFile) => {
2430
2451
  for (const statement of sourceFile.statements) {
2431
2452
  if (ts.isVariableStatement(statement) && statement.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword) && statement.declarationList.declarations.some((declaration) => ts.isIdentifier(declaration.name) && declaration.name.text === "islandRegistry")) {
@@ -2440,7 +2461,7 @@ var frameworks, isRecord4 = (value) => typeof value === "object" && value !== nu
2440
2461
  }
2441
2462
  }
2442
2463
  return false;
2443
- }, collectImportDeclarations = (sourceFile, registryPath, imports) => {
2464
+ }, collectImportDeclarations = (sourceFile, registryPath, imports, registryFactoryNames, registryNamespaceNames) => {
2444
2465
  for (const statement of sourceFile.statements) {
2445
2466
  if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier))
2446
2467
  continue;
@@ -2450,14 +2471,17 @@ var frameworks, isRecord4 = (value) => typeof value === "object" && value !== nu
2450
2471
  const source = resolveIslandSourcePath(registryPath, statement.moduleSpecifier.text);
2451
2472
  collectDefaultImport(imports, importClause, source);
2452
2473
  collectNamedImports(imports, importClause, source);
2474
+ collectRegistryHelperImports(importClause, statement.moduleSpecifier.text, registryFactoryNames, registryNamespaceNames);
2453
2475
  }
2454
2476
  }, parseIslandRegistryBuildInfo = (registrySource, registryPath) => {
2455
2477
  const sourceFile = ts.createSourceFile(registryPath, registrySource, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
2456
2478
  const imports = new Map;
2479
+ const registryFactoryNames = new Set(["defineIslandRegistry"]);
2480
+ const registryNamespaceNames = new Set;
2457
2481
  const definitions = [];
2458
2482
  const registry = {};
2459
- collectImportDeclarations(sourceFile, registryPath, imports);
2460
- walkRegistryNode(sourceFile, imports, definitions, registry);
2483
+ collectImportDeclarations(sourceFile, registryPath, imports, registryFactoryNames, registryNamespaceNames);
2484
+ walkRegistryNode(sourceFile, imports, registryFactoryNames, registryNamespaceNames, definitions, registry);
2461
2485
  return {
2462
2486
  definitions,
2463
2487
  hasNamedExport: hasIslandRegistryNamedExport(sourceFile),
@@ -50066,7 +50090,7 @@ __export(exports_prerender, {
50066
50090
  });
50067
50091
  import { mkdirSync as mkdirSync13, readFileSync as readFileSync16 } from "fs";
50068
50092
  import { join as join24 } from "path";
50069
- var MAX_STARTUP_ATTEMPTS = 50, STARTUP_POLL_INTERVAL_MS = 100, PRERENDER_BYPASS_HEADER = "X-Absolute-Prerender-Bypass", routeToFilename = (route) => route === "/" ? "index.html" : `${route.slice(1).replace(/\//g, "-")}.html`, writeTimestamp = async (htmlPath) => {
50093
+ var SERVER_OUTPUT_LIMIT = 4000, MAX_STARTUP_ATTEMPTS = 50, STARTUP_POLL_INTERVAL_MS = 100, PRERENDER_BYPASS_HEADER = "X-Absolute-Prerender-Bypass", routeToFilename = (route) => route === "/" ? "index.html" : `${route.slice(1).replace(/\//g, "-")}.html`, writeTimestamp = async (htmlPath) => {
50070
50094
  const metaPath = htmlPath.replace(/\.html$/, ".meta");
50071
50095
  await Bun.write(metaPath, String(Date.now()));
50072
50096
  }, readTimestamp = (htmlPath) => {
@@ -50172,17 +50196,49 @@ var MAX_STARTUP_ATTEMPTS = 50, STARTUP_POLL_INTERVAL_MS = 100, PRERENDER_BYPASS_
50172
50196
  await Bun.sleep(STARTUP_POLL_INTERVAL_MS);
50173
50197
  }
50174
50198
  return false;
50199
+ }, captureStreamOutput = (stream, output) => {
50200
+ if (!stream)
50201
+ return;
50202
+ const reader = stream.getReader();
50203
+ const decoder2 = new TextDecoder;
50204
+ const read = () => {
50205
+ reader.read().then(({ done, value: value2 }) => {
50206
+ if (done)
50207
+ return;
50208
+ output.push(decoder2.decode(value2, { stream: true }));
50209
+ read();
50210
+ }).catch(() => {});
50211
+ };
50212
+ read();
50213
+ }, formatServerOutput = (output) => {
50214
+ const text = output.join("").trim();
50215
+ if (!text)
50216
+ return "";
50217
+ return text.length > SERVER_OUTPUT_LIMIT ? text.slice(-SERVER_OUTPUT_LIMIT) : text;
50218
+ }, createServerStartupError = (output) => {
50219
+ const serverOutput = formatServerOutput(output);
50220
+ const message = serverOutput ? `Server failed to start for pre-rendering.
50221
+
50222
+ Server output:
50223
+ ${serverOutput}` : "Server failed to start for pre-rendering";
50224
+ return new Error(message);
50175
50225
  }, prerenderWithServer = async (serverBundlePath, port, outDir, staticConfig, env4, log2) => {
50226
+ const serverOutput = [];
50176
50227
  const serverProcess = Bun.spawn(["bun", "run", serverBundlePath], {
50177
50228
  cwd: process.cwd(),
50178
50229
  env: { ...process.env, ...env4, PORT: String(port) },
50179
50230
  stderr: "pipe",
50180
50231
  stdout: "pipe"
50181
50232
  });
50233
+ captureStreamOutput(serverProcess.stdout, serverOutput);
50234
+ captureStreamOutput(serverProcess.stderr, serverOutput);
50182
50235
  const ready = await waitForServerReady(port);
50183
50236
  if (!ready) {
50184
50237
  serverProcess.kill();
50185
- throw new Error("Server failed to start for pre-rendering");
50238
+ await serverProcess.exited.catch(() => {
50239
+ return;
50240
+ });
50241
+ throw createServerStartupError(serverOutput);
50186
50242
  }
50187
50243
  const result = await prerender(port, outDir, staticConfig, log2);
50188
50244
  serverProcess.kill();
@@ -57868,5 +57924,5 @@ export {
57868
57924
  ANGULAR_INIT_TIMEOUT_MS
57869
57925
  };
57870
57926
 
57871
- //# debugId=B174A989DC85D95764756E2164756E21
57927
+ //# debugId=C3F27FAFFCF2A8A364756E2164756E21
57872
57928
  //# sourceMappingURL=index.js.map