@absolutejs/absolute 0.19.0-beta.1138 → 0.19.0-beta.1139

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
@@ -171164,6 +171164,8 @@ var SERVER_OUTPUT_LIMIT = 4000, STARTUP_POLL_INTERVAL_MS = 100, DEFAULT_STARTUP_
171164
171164
  if (!res.ok)
171165
171165
  return false;
171166
171166
  const html = await res.text();
171167
+ if (!isCompleteHtml(html))
171168
+ return false;
171167
171169
  const fileName = routeToFilename(route);
171168
171170
  const filePath = join9(prerenderDir, fileName);
171169
171171
  await Bun.write(filePath, html);
@@ -171190,6 +171192,10 @@ var SERVER_OUTPUT_LIMIT = 4000, STARTUP_POLL_INTERVAL_MS = 100, DEFAULT_STARTUP_
171190
171192
  return;
171191
171193
  }
171192
171194
  const html = await res.text();
171195
+ if (!isCompleteHtml(html)) {
171196
+ log?.(` Failed to pre-render ${route} (incomplete HTML document)`);
171197
+ return;
171198
+ }
171193
171199
  const fileName = routeToFilename(route);
171194
171200
  const filePath = join9(prerenderDir, fileName);
171195
171201
  await Bun.write(filePath, html);
@@ -171224,7 +171230,7 @@ var SERVER_OUTPUT_LIMIT = 4000, STARTUP_POLL_INTERVAL_MS = 100, DEFAULT_STARTUP_
171224
171230
  }, fetchWithTimeout = (url, init = {}) => fetch(url, {
171225
171231
  ...init,
171226
171232
  signal: init.signal ?? AbortSignal.timeout(getFetchTimeoutMs())
171227
- }), waitForServerReady = async (port) => {
171233
+ }), isCompleteHtml = (html) => !/^(?:\uFEFF)?\s*<!doctype\s+html\b/i.test(html) || /<\/html>\s*$/i.test(html), waitForServerReady = async (port) => {
171228
171234
  const deadline = performance.now() + getStartupTimeoutMs();
171229
171235
  const pollServer = async () => {
171230
171236
  if (performance.now() >= deadline) {
package/dist/index.js CHANGED
@@ -24506,6 +24506,32 @@ var resolveDevClientDir3 = () => {
24506
24506
  ].join(`
24507
24507
  `) : nonVueLines.join(`
24508
24508
  `);
24509
+ }, wrapServerAsyncComponentLoader = (code) => {
24510
+ const vueImportRegex = /import\s+\{([^}]+)\}\s+from\s+['"]vue['"];?/;
24511
+ const match = code.match(vueImportRegex);
24512
+ if (!match?.[1])
24513
+ return code;
24514
+ const specifiers = match[1].split(",").map((specifier) => specifier.trim());
24515
+ const asyncComponentIndex = specifiers.findIndex((specifier) => /^defineAsyncComponent(?:\s+as\s+[A-Za-z_$][\w$]*)?$/.test(specifier));
24516
+ if (asyncComponentIndex === -1)
24517
+ return code;
24518
+ const asyncComponentSpecifier = specifiers[asyncComponentIndex] ?? "";
24519
+ const localName = asyncComponentSpecifier.match(/\s+as\s+([A-Za-z_$][\w$]*)$/)?.[1] ?? "defineAsyncComponent";
24520
+ const importedName = "__absoluteDefineAsyncComponent";
24521
+ specifiers[asyncComponentIndex] = `defineAsyncComponent as ${importedName}`;
24522
+ const wrapper = `
24523
+ const __absoluteResolveAsyncVueComponent = async (loader) => {
24524
+ const loaded = await loader();
24525
+ return loaded && typeof loaded === "object" && "default" in loaded
24526
+ ? loaded.default
24527
+ : loaded;
24528
+ };
24529
+ const ${localName} = (source) => ${importedName}(
24530
+ typeof source === "function"
24531
+ ? () => __absoluteResolveAsyncVueComponent(source)
24532
+ : { ...source, loader: () => __absoluteResolveAsyncVueComponent(source.loader) },
24533
+ );`;
24534
+ return code.replace(vueImportRegex, `import { ${specifiers.join(", ")} } from 'vue';${wrapper}`);
24509
24535
  }, compileVueFile = async (sourceFilePath, outputDirs, cacheMap, isEntryPoint, vueRootDir, compiler, stylePreprocessors) => {
24510
24536
  const cachedResult = cacheMap.get(sourceFilePath);
24511
24537
  if (cachedResult)
@@ -24644,7 +24670,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
24644
24670
  `));
24645
24671
  };
24646
24672
  const clientCode = assembleModule(generateRenderFunction(false), "render", true) + islandMetadataExports;
24647
- const serverCode = assembleModule(generateRenderFunction(true), "ssrRender", false) + islandMetadataExports;
24673
+ const serverCode = wrapServerAsyncComponentLoader(assembleModule(generateRenderFunction(true), "ssrRender", false)) + islandMetadataExports;
24648
24674
  const clientOutputPath = join33(outputDirs.client, `${relativeWithoutExtension}.js`);
24649
24675
  const serverOutputPath = join33(outputDirs.server, `${relativeWithoutExtension}.js`);
24650
24676
  const rewritePackageImports = (code, outputPath, mode) => {
@@ -39767,6 +39793,8 @@ var SERVER_OUTPUT_LIMIT = 4000, STARTUP_POLL_INTERVAL_MS = 100, DEFAULT_STARTUP_
39767
39793
  if (!res.ok)
39768
39794
  return false;
39769
39795
  const html = await res.text();
39796
+ if (!isCompleteHtml(html))
39797
+ return false;
39770
39798
  const fileName = routeToFilename(route);
39771
39799
  const filePath = join48(prerenderDir, fileName);
39772
39800
  await Bun.write(filePath, html);
@@ -39793,6 +39821,10 @@ var SERVER_OUTPUT_LIMIT = 4000, STARTUP_POLL_INTERVAL_MS = 100, DEFAULT_STARTUP_
39793
39821
  return;
39794
39822
  }
39795
39823
  const html = await res.text();
39824
+ if (!isCompleteHtml(html)) {
39825
+ log2?.(` Failed to pre-render ${route} (incomplete HTML document)`);
39826
+ return;
39827
+ }
39796
39828
  const fileName = routeToFilename(route);
39797
39829
  const filePath = join48(prerenderDir, fileName);
39798
39830
  await Bun.write(filePath, html);
@@ -39827,7 +39859,7 @@ var SERVER_OUTPUT_LIMIT = 4000, STARTUP_POLL_INTERVAL_MS = 100, DEFAULT_STARTUP_
39827
39859
  }, fetchWithTimeout = (url2, init = {}) => fetch(url2, {
39828
39860
  ...init,
39829
39861
  signal: init.signal ?? AbortSignal.timeout(getFetchTimeoutMs())
39830
- }), waitForServerReady = async (port) => {
39862
+ }), isCompleteHtml = (html) => !/^(?:\uFEFF)?\s*<!doctype\s+html\b/i.test(html) || /<\/html>\s*$/i.test(html), waitForServerReady = async (port) => {
39831
39863
  const deadline = performance.now() + getStartupTimeoutMs();
39832
39864
  const pollServer = async () => {
39833
39865
  if (performance.now() >= deadline) {
@@ -48062,5 +48094,5 @@ export {
48062
48094
  ANGULAR_INIT_TIMEOUT_MS
48063
48095
  };
48064
48096
 
48065
- //# debugId=2428F637392E781D64756E2164756E21
48097
+ //# debugId=77CD9846833A953D64756E2164756E21
48066
48098
  //# sourceMappingURL=index.js.map