@absolutejs/absolute 0.19.0-beta.931 → 0.19.0-beta.933

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.
Files changed (39) hide show
  1. package/dist/angular/components/core/streamingSlotRegistrar.js +1 -1
  2. package/dist/angular/components/core/streamingSlotRegistry.js +2 -2
  3. package/dist/angular/index.js +285 -136
  4. package/dist/angular/index.js.map +6 -5
  5. package/dist/angular/server.js +267 -118
  6. package/dist/angular/server.js.map +6 -5
  7. package/dist/build.js +807 -584
  8. package/dist/build.js.map +17 -16
  9. package/dist/dev/client/handlers/angularHmrShim.ts +4 -1
  10. package/dist/dev/client/handlers/angularRemount.ts +2 -2
  11. package/dist/dev/client/handlers/angularRemountWiring.ts +1 -4
  12. package/dist/dev/client/vendor/lview/lViewOps.ts +8 -6
  13. package/dist/index.js +925 -651
  14. package/dist/index.js.map +21 -19
  15. package/dist/islands/index.js +105 -2
  16. package/dist/islands/index.js.map +5 -4
  17. package/dist/react/index.js +167 -18
  18. package/dist/react/index.js.map +6 -5
  19. package/dist/react/server.js +63 -17
  20. package/dist/react/server.js.map +3 -3
  21. package/dist/src/core/normalizeIslandProps.d.ts +15 -0
  22. package/dist/src/core/vueServerModule.d.ts +1 -0
  23. package/dist/src/utils/defineConvention.d.ts +3 -0
  24. package/dist/src/utils/index.d.ts +1 -0
  25. package/dist/src/vue/Island.browser.d.ts +36 -12
  26. package/dist/src/vue/Island.d.ts +35 -11
  27. package/dist/src/vue/pageHandler.d.ts +8 -0
  28. package/dist/svelte/index.js +167 -18
  29. package/dist/svelte/index.js.map +6 -5
  30. package/dist/svelte/server.js +63 -17
  31. package/dist/svelte/server.js.map +3 -3
  32. package/dist/types/conventions.d.ts +5 -0
  33. package/dist/vue/browser.js +57 -4
  34. package/dist/vue/browser.js.map +5 -4
  35. package/dist/vue/index.js +234 -24
  36. package/dist/vue/index.js.map +9 -7
  37. package/dist/vue/server.js +73 -20
  38. package/dist/vue/server.js.map +4 -4
  39. package/package.json +1 -1
@@ -2698,6 +2698,100 @@ var init_svelteServerModule = __esm(() => {
2698
2698
  });
2699
2699
  });
2700
2700
 
2701
+ // src/core/vueServerModule.ts
2702
+ import { mkdir as mkdir2 } from "fs/promises";
2703
+ import { dirname as dirname3, join as join5, relative as relative3, resolve as resolve5 } from "path";
2704
+ var {Transpiler } = globalThis.Bun;
2705
+ var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot2, compiledModuleCache2, transpiler2, ensureRelativeImportPath2 = (from, target) => {
2706
+ const importPath = relative3(dirname3(from), target).replace(/\\/g, "/");
2707
+ return importPath.startsWith(".") ? importPath : `./${importPath}`;
2708
+ }, getCachedModulePath2 = (sourcePath) => {
2709
+ const relativeSourcePath = relative3(process.cwd(), sourcePath).replace(/\\/g, "/");
2710
+ const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
2711
+ return join5(serverCacheRoot2, `${normalizedSourcePath}.server.js`);
2712
+ }, writeIfChanged2 = async (path, content) => {
2713
+ const targetFile = Bun.file(path);
2714
+ if (await targetFile.exists()) {
2715
+ const currentContent = await targetFile.text();
2716
+ if (currentContent === content)
2717
+ return;
2718
+ }
2719
+ await Bun.write(path, content);
2720
+ }, stripExports = (code) => code.replace(/export\s+default/, "const script ="), mergeVueImports = (code) => {
2721
+ const lines = code.split(`
2722
+ `);
2723
+ const specifierSet = new Set;
2724
+ const vueImportRegex = /^import\s+{([^}]+)}\s+from\s+['"]vue['"];?$/;
2725
+ lines.forEach((line) => {
2726
+ const match = line.match(vueImportRegex);
2727
+ if (match?.[1])
2728
+ match[1].split(",").forEach((importSpecifier) => specifierSet.add(importSpecifier.trim()));
2729
+ });
2730
+ const nonVueLines = lines.filter((line) => !vueImportRegex.test(line));
2731
+ return specifierSet.size ? [
2732
+ `import { ${[...specifierSet].join(", ")} } from "vue";`,
2733
+ ...nonVueLines
2734
+ ].join(`
2735
+ `) : nonVueLines.join(`
2736
+ `);
2737
+ }, extractRelativeVueImports = (sourceCode) => Array.from(sourceCode.matchAll(/import\s+[\s\S]+?['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((importPath) => typeof importPath === "string" && importPath.startsWith(".") && importPath.endsWith(".vue")), compileVueServerModule = async (sourcePath) => {
2738
+ const cachedModulePath = compiledModuleCache2.get(sourcePath);
2739
+ if (cachedModulePath)
2740
+ return cachedModulePath;
2741
+ const compiler = await import("@vue/compiler-sfc");
2742
+ const source = await Bun.file(sourcePath).text();
2743
+ const { descriptor } = compiler.parse(source, { filename: sourcePath });
2744
+ const componentId = Bun.hash(sourcePath).toString(BASE_36_RADIX).slice(0, ISLAND_COMPONENT_ID_LENGTH);
2745
+ const hasScript = descriptor.script || descriptor.scriptSetup;
2746
+ const compiledScript = hasScript ? compiler.compileScript(descriptor, {
2747
+ id: componentId,
2748
+ inlineTemplate: false
2749
+ }) : { bindings: {}, content: "export default {};" };
2750
+ const renderCode = descriptor.template ? compiler.compileTemplate({
2751
+ compilerOptions: {
2752
+ bindingMetadata: compiledScript.bindings,
2753
+ expressionPlugins: ["typescript"],
2754
+ prefixIdentifiers: true,
2755
+ isCustomElement: (tag) => tag === "absolute-island"
2756
+ },
2757
+ filename: sourcePath,
2758
+ id: componentId,
2759
+ scoped: descriptor.styles.some((styleBlock) => styleBlock.scoped),
2760
+ source: descriptor.template.content,
2761
+ ssr: true,
2762
+ ssrCssVars: descriptor.cssVars
2763
+ }).code : "const ssrRender = () => {};";
2764
+ const childImportPaths = extractRelativeVueImports(compiledScript.content);
2765
+ const compiledChildren = await Promise.all(childImportPaths.map(async (relativeImport) => ({
2766
+ compiledPath: await compileVueServerModule(resolve5(dirname3(sourcePath), relativeImport)),
2767
+ spec: relativeImport
2768
+ })));
2769
+ const strippedScript = stripExports(compiledScript.content);
2770
+ const transpiledScript = transpiler2.transformSync(strippedScript);
2771
+ const assembled = mergeVueImports([
2772
+ transpiledScript,
2773
+ renderCode,
2774
+ "script.ssrRender = ssrRender;",
2775
+ "export default script;"
2776
+ ].join(`
2777
+ `));
2778
+ const compiledModulePath = getCachedModulePath2(sourcePath);
2779
+ let rewritten = assembled;
2780
+ for (const child of compiledChildren) {
2781
+ rewritten = rewritten.replaceAll(child.spec, ensureRelativeImportPath2(compiledModulePath, child.compiledPath));
2782
+ }
2783
+ await mkdir2(dirname3(compiledModulePath), { recursive: true });
2784
+ await writeIfChanged2(compiledModulePath, rewritten);
2785
+ compiledModuleCache2.set(sourcePath, compiledModulePath);
2786
+ return compiledModulePath;
2787
+ };
2788
+ var init_vueServerModule = __esm(() => {
2789
+ init_constants();
2790
+ serverCacheRoot2 = join5(process.cwd(), ".absolutejs", "islands", "vue");
2791
+ compiledModuleCache2 = new Map;
2792
+ transpiler2 = new Transpiler({ loader: "ts", target: "browser" });
2793
+ });
2794
+
2701
2795
  // src/core/renderIslandMarkup.ts
2702
2796
  var islandSequence = 0, resolvedServerComponentCache, resolvedServerBuildComponentCache, nextIslandId = () => {
2703
2797
  islandSequence += 1;
@@ -2720,9 +2814,17 @@ var islandSequence = 0, resolvedServerComponentCache, resolvedServerBuildCompone
2720
2814
  const loadPromise = loadAndCompileServerBuildComponent(buildReferencePath);
2721
2815
  resolvedServerBuildComponentCache.set(buildReferencePath, loadPromise);
2722
2816
  return loadPromise;
2817
+ }, resolveRuntimeImportTarget = async (resolvedModulePath) => {
2818
+ if (resolvedModulePath.endsWith(".svelte")) {
2819
+ return compileSvelteServerModule(resolvedModulePath);
2820
+ }
2821
+ if (resolvedModulePath.endsWith(".vue")) {
2822
+ return compileVueServerModule(resolvedModulePath);
2823
+ }
2824
+ return resolvedModulePath;
2723
2825
  }, loadServerImportComponent = async (resolvedComponent, exportName) => {
2724
2826
  const resolvedModulePath = resolvedComponent.startsWith(".") ? new URL(resolvedComponent, import.meta.url).pathname : resolvedComponent;
2725
- const importTarget = resolvedModulePath.endsWith(".svelte") ? await compileSvelteServerModule(resolvedModulePath) : resolvedModulePath;
2827
+ const importTarget = await resolveRuntimeImportTarget(resolvedModulePath);
2726
2828
  const loadedModule = await import(importTarget);
2727
2829
  if (exportName && exportName !== "default" && exportName in loadedModule) {
2728
2830
  return loadedModule[exportName];
@@ -2826,6 +2928,7 @@ var islandSequence = 0, resolvedServerComponentCache, resolvedServerBuildCompone
2826
2928
  var init_renderIslandMarkup = __esm(() => {
2827
2929
  init_islandSsr();
2828
2930
  init_svelteServerModule();
2931
+ init_vueServerModule();
2829
2932
  init_islandMarkupAttributes();
2830
2933
  init_islands();
2831
2934
  resolvedServerComponentCache = new Map;
@@ -3312,16 +3415,22 @@ var setConventions = (map) => {
3312
3415
  };
3313
3416
  var isDev = () => true;
3314
3417
  var buildErrorProps = (error) => {
3315
- const message = error instanceof Error ? error.message : String(error);
3316
- const stack = isDev() && error instanceof Error ? error.stack : undefined;
3317
- return { error: { message, stack } };
3418
+ if (error instanceof Error) {
3419
+ return {
3420
+ name: error.name,
3421
+ message: error.message,
3422
+ ...isDev() && error.stack ? { stack: error.stack } : {}
3423
+ };
3424
+ }
3425
+ return { name: "Error", message: String(error) };
3318
3426
  };
3319
3427
  var renderReactError = async (conventionPath, errorProps) => {
3320
3428
  const { createElement } = await import("react");
3321
3429
  const { renderToReadableStream } = await import("react-dom/server");
3322
3430
  const mod = await import(conventionPath);
3323
- const [firstKey] = Object.keys(mod);
3324
- const ErrorComponent = mod.default ?? (firstKey ? mod[firstKey] : undefined);
3431
+ const ErrorComponent = mod.default;
3432
+ if (typeof ErrorComponent !== "function")
3433
+ return null;
3325
3434
  const element = createElement(ErrorComponent, errorProps);
3326
3435
  const stream = await renderToReadableStream(element);
3327
3436
  return new Response(stream, {
@@ -3333,6 +3442,8 @@ var renderSvelteError = async (conventionPath, errorProps) => {
3333
3442
  const { render } = await import("svelte/server");
3334
3443
  const mod = await import(conventionPath);
3335
3444
  const ErrorComponent = mod.default;
3445
+ if (!ErrorComponent)
3446
+ return null;
3336
3447
  const { head, body } = render(ErrorComponent, {
3337
3448
  props: errorProps
3338
3449
  });
@@ -3355,6 +3466,8 @@ var renderVueError = async (conventionPath, errorProps) => {
3355
3466
  const { renderToString } = await import("vue/server-renderer");
3356
3467
  const mod = await import(conventionPath);
3357
3468
  const ErrorComponent = mod.default;
3469
+ if (!ErrorComponent)
3470
+ return null;
3358
3471
  const app = createSSRApp({
3359
3472
  render: () => h(ErrorComponent, errorProps)
3360
3473
  });
@@ -3368,10 +3481,20 @@ var renderVueError = async (conventionPath, errorProps) => {
3368
3481
  };
3369
3482
  var renderAngularError = async (conventionPath, errorProps) => {
3370
3483
  const mod = await import(conventionPath);
3371
- const renderError = mod.default ?? mod.renderError;
3372
- if (typeof renderError !== "function")
3484
+ const renderFn = mod.default;
3485
+ if (typeof renderFn !== "function")
3373
3486
  return null;
3374
- const html = renderError(errorProps);
3487
+ const html = renderFn(errorProps);
3488
+ return new Response(html, {
3489
+ headers: { "Content-Type": "text/html" },
3490
+ status: 500
3491
+ });
3492
+ };
3493
+ var escapeHtml = (value) => value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
3494
+ var replaceErrorTokens = (template, errorProps) => template.replace(/\{\{\s*name\s*\}\}/g, escapeHtml(errorProps.name)).replace(/\{\{\s*message\s*\}\}/g, escapeHtml(errorProps.message)).replace(/\{\{\s*stack\s*\}\}/g, errorProps.stack ? escapeHtml(errorProps.stack) : "");
3495
+ var renderHtmlError = async (conventionPath, errorProps) => {
3496
+ const template = await Bun.file(conventionPath).text();
3497
+ const html = replaceErrorTokens(template, errorProps);
3375
3498
  return new Response(html, {
3376
3499
  headers: { "Content-Type": "text/html" },
3377
3500
  status: 500
@@ -3390,11 +3513,12 @@ var renderEmberNotFound = async () => null;
3390
3513
  var ERROR_RENDERERS = {
3391
3514
  angular: renderAngularError,
3392
3515
  ember: renderEmberError,
3516
+ html: renderHtmlError,
3393
3517
  react: renderReactError,
3394
3518
  svelte: renderSvelteError,
3395
3519
  vue: renderVueError
3396
3520
  };
3397
- var renderConventionError = async (framework, pageName, error) => {
3521
+ var tryFrameworkErrorConvention = async (framework, pageName, errorProps, error) => {
3398
3522
  let conventionPath = resolveErrorConventionPath(framework, pageName);
3399
3523
  if (!conventionPath && error instanceof Error && error.stack) {
3400
3524
  for (const match of error.stack.matchAll(/^\s*at\s+([A-Za-z_$][\w$]*)/gm)) {
@@ -3408,7 +3532,6 @@ var renderConventionError = async (framework, pageName, error) => {
3408
3532
  }
3409
3533
  if (!conventionPath)
3410
3534
  return null;
3411
- const errorProps = buildErrorProps(error);
3412
3535
  const renderer = ERROR_RENDERERS[framework];
3413
3536
  if (!renderer)
3414
3537
  return null;
@@ -3419,12 +3542,25 @@ var renderConventionError = async (framework, pageName, error) => {
3419
3542
  }
3420
3543
  return null;
3421
3544
  };
3545
+ var renderConventionError = async (framework, pageName, error) => {
3546
+ const errorProps = buildErrorProps(error);
3547
+ const frameworkResponse = await tryFrameworkErrorConvention(framework, pageName, errorProps, error);
3548
+ if (frameworkResponse)
3549
+ return frameworkResponse;
3550
+ if (framework !== "html") {
3551
+ const htmlResponse = await tryFrameworkErrorConvention("html", pageName, errorProps, error);
3552
+ if (htmlResponse)
3553
+ return htmlResponse;
3554
+ }
3555
+ return null;
3556
+ };
3422
3557
  var renderReactNotFound = async (conventionPath) => {
3423
3558
  const { createElement } = await import("react");
3424
3559
  const { renderToReadableStream } = await import("react-dom/server");
3425
3560
  const mod = await import(conventionPath);
3426
- const [nfKey] = Object.keys(mod);
3427
- const NotFoundComponent = mod.default ?? (nfKey ? mod[nfKey] : undefined);
3561
+ const NotFoundComponent = mod.default;
3562
+ if (typeof NotFoundComponent !== "function")
3563
+ return null;
3428
3564
  const element = createElement(NotFoundComponent);
3429
3565
  const stream = await renderToReadableStream(element);
3430
3566
  return new Response(stream, {
@@ -3436,6 +3572,8 @@ var renderSvelteNotFound = async (conventionPath) => {
3436
3572
  const { render } = await import("svelte/server");
3437
3573
  const mod = await import(conventionPath);
3438
3574
  const NotFoundComponent = mod.default;
3575
+ if (!NotFoundComponent)
3576
+ return null;
3439
3577
  const { head, body } = render(NotFoundComponent);
3440
3578
  const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
3441
3579
  return new Response(html, {
@@ -3448,6 +3586,8 @@ var renderVueNotFound = async (conventionPath) => {
3448
3586
  const { renderToString } = await import("vue/server-renderer");
3449
3587
  const mod = await import(conventionPath);
3450
3588
  const NotFoundComponent = mod.default;
3589
+ if (!NotFoundComponent)
3590
+ return null;
3451
3591
  const app = createSSRApp({
3452
3592
  render: () => h(NotFoundComponent)
3453
3593
  });
@@ -3461,10 +3601,17 @@ var renderVueNotFound = async (conventionPath) => {
3461
3601
  };
3462
3602
  var renderAngularNotFound = async (conventionPath) => {
3463
3603
  const mod = await import(conventionPath);
3464
- const renderNotFound = mod.default ?? mod.renderNotFound;
3465
- if (typeof renderNotFound !== "function")
3604
+ const renderFn = mod.default;
3605
+ if (typeof renderFn !== "function")
3466
3606
  return null;
3467
- const html = renderNotFound();
3607
+ const html = renderFn();
3608
+ return new Response(html, {
3609
+ headers: { "Content-Type": "text/html" },
3610
+ status: 404
3611
+ });
3612
+ };
3613
+ var renderHtmlNotFound = async (conventionPath) => {
3614
+ const html = await Bun.file(conventionPath).text();
3468
3615
  return new Response(html, {
3469
3616
  headers: { "Content-Type": "text/html" },
3470
3617
  status: 404
@@ -3473,6 +3620,7 @@ var renderAngularNotFound = async (conventionPath) => {
3473
3620
  var NOT_FOUND_RENDERERS = {
3474
3621
  angular: renderAngularNotFound,
3475
3622
  ember: renderEmberNotFound,
3623
+ html: renderHtmlNotFound,
3476
3624
  react: renderReactNotFound,
3477
3625
  svelte: renderSvelteNotFound,
3478
3626
  vue: renderVueNotFound
@@ -3495,7 +3643,8 @@ var NOT_FOUND_PRIORITY = [
3495
3643
  "react",
3496
3644
  "svelte",
3497
3645
  "vue",
3498
- "angular"
3646
+ "angular",
3647
+ "html"
3499
3648
  ];
3500
3649
  var renderFirstNotFound = async () => {
3501
3650
  const renderNext = async (frameworks) => {
@@ -3783,5 +3932,5 @@ export {
3783
3932
  Island
3784
3933
  };
3785
3934
 
3786
- //# debugId=80AC5EFAD2AD7A5B64756E2164756E21
3935
+ //# debugId=1094272B47C7C77164756E2164756E21
3787
3936
  //# sourceMappingURL=index.js.map