@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
@@ -1,12 +1,36 @@
1
1
  import { h } from 'vue';
2
- export declare const Island: import("vue").DefineComponent<{
3
- component: string;
4
- framework: import("..").IslandFramework;
5
- hydrate?: import("..").IslandHydrate | undefined;
6
- props: Record<string, unknown>;
7
- }, () => ReturnType<typeof h>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
8
- component: string;
9
- framework: import("..").IslandFramework;
10
- hydrate?: import("..").IslandHydrate | undefined;
11
- props: Record<string, unknown>;
12
- }> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ export declare const Island: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
3
+ component: {
4
+ required: true;
5
+ type: StringConstructor;
6
+ };
7
+ framework: {
8
+ required: true;
9
+ type: StringConstructor;
10
+ };
11
+ hydrate: {
12
+ required: false;
13
+ type: StringConstructor;
14
+ };
15
+ props: {
16
+ required: false;
17
+ type: (ObjectConstructor | StringConstructor)[];
18
+ };
19
+ }>, () => ReturnType<typeof h>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
20
+ component: {
21
+ required: true;
22
+ type: StringConstructor;
23
+ };
24
+ framework: {
25
+ required: true;
26
+ type: StringConstructor;
27
+ };
28
+ hydrate: {
29
+ required: false;
30
+ type: StringConstructor;
31
+ };
32
+ props: {
33
+ required: false;
34
+ type: (ObjectConstructor | StringConstructor)[];
35
+ };
36
+ }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -5,6 +5,14 @@ type VuePageRenderOptions = StreamingSlotEnhancerOptions & {
5
5
  collectStreamingSlots?: boolean;
6
6
  };
7
7
  export type VuePageRequestInput<Component extends VueComponent> = VuePageRenderOptions & {
8
+ /** Hydration mode for the page bundle.
9
+ * - `'auto'` (default): emit `<script>window.__INITIAL_PROPS__=…</script>`
10
+ * plus the page's `<script type="module">` index, mounting Vue on the
11
+ * client.
12
+ * - `'none'`: SSR-only. Skip both scripts entirely so the page ships
13
+ * pure HTML — useful for marketing / docs pages that use Vue
14
+ * templating + Tailwind without paying the runtime cost. */
15
+ client?: 'auto' | 'none';
8
16
  headTag?: `<head>${string}</head>`;
9
17
  indexPath: string;
10
18
  pagePath: string;
@@ -2679,6 +2679,100 @@ var init_islandSsr = __esm(() => {
2679
2679
  renderAngularIslandToHtml2 = renderAngularIslandToHtmlInternal;
2680
2680
  });
2681
2681
 
2682
+ // src/core/vueServerModule.ts
2683
+ import { mkdir as mkdir2 } from "fs/promises";
2684
+ import { dirname as dirname3, join as join5, relative as relative3, resolve as resolve5 } from "path";
2685
+ var {Transpiler } = globalThis.Bun;
2686
+ var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot2, compiledModuleCache2, transpiler2, ensureRelativeImportPath2 = (from, target) => {
2687
+ const importPath = relative3(dirname3(from), target).replace(/\\/g, "/");
2688
+ return importPath.startsWith(".") ? importPath : `./${importPath}`;
2689
+ }, getCachedModulePath2 = (sourcePath) => {
2690
+ const relativeSourcePath = relative3(process.cwd(), sourcePath).replace(/\\/g, "/");
2691
+ const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
2692
+ return join5(serverCacheRoot2, `${normalizedSourcePath}.server.js`);
2693
+ }, writeIfChanged2 = async (path, content) => {
2694
+ const targetFile = Bun.file(path);
2695
+ if (await targetFile.exists()) {
2696
+ const currentContent = await targetFile.text();
2697
+ if (currentContent === content)
2698
+ return;
2699
+ }
2700
+ await Bun.write(path, content);
2701
+ }, stripExports = (code) => code.replace(/export\s+default/, "const script ="), mergeVueImports = (code) => {
2702
+ const lines = code.split(`
2703
+ `);
2704
+ const specifierSet = new Set;
2705
+ const vueImportRegex = /^import\s+{([^}]+)}\s+from\s+['"]vue['"];?$/;
2706
+ lines.forEach((line) => {
2707
+ const match = line.match(vueImportRegex);
2708
+ if (match?.[1])
2709
+ match[1].split(",").forEach((importSpecifier) => specifierSet.add(importSpecifier.trim()));
2710
+ });
2711
+ const nonVueLines = lines.filter((line) => !vueImportRegex.test(line));
2712
+ return specifierSet.size ? [
2713
+ `import { ${[...specifierSet].join(", ")} } from "vue";`,
2714
+ ...nonVueLines
2715
+ ].join(`
2716
+ `) : nonVueLines.join(`
2717
+ `);
2718
+ }, 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) => {
2719
+ const cachedModulePath = compiledModuleCache2.get(sourcePath);
2720
+ if (cachedModulePath)
2721
+ return cachedModulePath;
2722
+ const compiler = await import("@vue/compiler-sfc");
2723
+ const source = await Bun.file(sourcePath).text();
2724
+ const { descriptor } = compiler.parse(source, { filename: sourcePath });
2725
+ const componentId = Bun.hash(sourcePath).toString(BASE_36_RADIX).slice(0, ISLAND_COMPONENT_ID_LENGTH);
2726
+ const hasScript = descriptor.script || descriptor.scriptSetup;
2727
+ const compiledScript = hasScript ? compiler.compileScript(descriptor, {
2728
+ id: componentId,
2729
+ inlineTemplate: false
2730
+ }) : { bindings: {}, content: "export default {};" };
2731
+ const renderCode = descriptor.template ? compiler.compileTemplate({
2732
+ compilerOptions: {
2733
+ bindingMetadata: compiledScript.bindings,
2734
+ expressionPlugins: ["typescript"],
2735
+ prefixIdentifiers: true,
2736
+ isCustomElement: (tag) => tag === "absolute-island"
2737
+ },
2738
+ filename: sourcePath,
2739
+ id: componentId,
2740
+ scoped: descriptor.styles.some((styleBlock) => styleBlock.scoped),
2741
+ source: descriptor.template.content,
2742
+ ssr: true,
2743
+ ssrCssVars: descriptor.cssVars
2744
+ }).code : "const ssrRender = () => {};";
2745
+ const childImportPaths = extractRelativeVueImports(compiledScript.content);
2746
+ const compiledChildren = await Promise.all(childImportPaths.map(async (relativeImport) => ({
2747
+ compiledPath: await compileVueServerModule(resolve5(dirname3(sourcePath), relativeImport)),
2748
+ spec: relativeImport
2749
+ })));
2750
+ const strippedScript = stripExports(compiledScript.content);
2751
+ const transpiledScript = transpiler2.transformSync(strippedScript);
2752
+ const assembled = mergeVueImports([
2753
+ transpiledScript,
2754
+ renderCode,
2755
+ "script.ssrRender = ssrRender;",
2756
+ "export default script;"
2757
+ ].join(`
2758
+ `));
2759
+ const compiledModulePath = getCachedModulePath2(sourcePath);
2760
+ let rewritten = assembled;
2761
+ for (const child of compiledChildren) {
2762
+ rewritten = rewritten.replaceAll(child.spec, ensureRelativeImportPath2(compiledModulePath, child.compiledPath));
2763
+ }
2764
+ await mkdir2(dirname3(compiledModulePath), { recursive: true });
2765
+ await writeIfChanged2(compiledModulePath, rewritten);
2766
+ compiledModuleCache2.set(sourcePath, compiledModulePath);
2767
+ return compiledModulePath;
2768
+ };
2769
+ var init_vueServerModule = __esm(() => {
2770
+ init_constants();
2771
+ serverCacheRoot2 = join5(process.cwd(), ".absolutejs", "islands", "vue");
2772
+ compiledModuleCache2 = new Map;
2773
+ transpiler2 = new Transpiler({ loader: "ts", target: "browser" });
2774
+ });
2775
+
2682
2776
  // src/core/islandManifest.ts
2683
2777
  var toIslandFrameworkSegment = (framework) => framework[0]?.toUpperCase() + framework.slice(1), collectFrameworkIslands = (manifest, prefix) => {
2684
2778
  const entries = {};
@@ -2765,9 +2859,17 @@ var islandSequence = 0, resolvedServerComponentCache, resolvedServerBuildCompone
2765
2859
  const loadPromise = loadAndCompileServerBuildComponent(buildReferencePath);
2766
2860
  resolvedServerBuildComponentCache.set(buildReferencePath, loadPromise);
2767
2861
  return loadPromise;
2862
+ }, resolveRuntimeImportTarget = async (resolvedModulePath) => {
2863
+ if (resolvedModulePath.endsWith(".svelte")) {
2864
+ return compileSvelteServerModule(resolvedModulePath);
2865
+ }
2866
+ if (resolvedModulePath.endsWith(".vue")) {
2867
+ return compileVueServerModule(resolvedModulePath);
2868
+ }
2869
+ return resolvedModulePath;
2768
2870
  }, loadServerImportComponent = async (resolvedComponent, exportName) => {
2769
2871
  const resolvedModulePath = resolvedComponent.startsWith(".") ? new URL(resolvedComponent, import.meta.url).pathname : resolvedComponent;
2770
- const importTarget = resolvedModulePath.endsWith(".svelte") ? await compileSvelteServerModule(resolvedModulePath) : resolvedModulePath;
2872
+ const importTarget = await resolveRuntimeImportTarget(resolvedModulePath);
2771
2873
  const loadedModule = await import(importTarget);
2772
2874
  if (exportName && exportName !== "default" && exportName in loadedModule) {
2773
2875
  return loadedModule[exportName];
@@ -2871,6 +2973,7 @@ var islandSequence = 0, resolvedServerComponentCache, resolvedServerBuildCompone
2871
2973
  var init_renderIslandMarkup = __esm(() => {
2872
2974
  init_islandSsr();
2873
2975
  init_svelteServerModule();
2976
+ init_vueServerModule();
2874
2977
  init_islandMarkupAttributes();
2875
2978
  init_islands2();
2876
2979
  resolvedServerComponentCache = new Map;
@@ -3371,16 +3474,22 @@ var setConventions = (map) => {
3371
3474
  };
3372
3475
  var isDev = () => true;
3373
3476
  var buildErrorProps = (error) => {
3374
- const message = error instanceof Error ? error.message : String(error);
3375
- const stack = isDev() && error instanceof Error ? error.stack : undefined;
3376
- return { error: { message, stack } };
3477
+ if (error instanceof Error) {
3478
+ return {
3479
+ name: error.name,
3480
+ message: error.message,
3481
+ ...isDev() && error.stack ? { stack: error.stack } : {}
3482
+ };
3483
+ }
3484
+ return { name: "Error", message: String(error) };
3377
3485
  };
3378
3486
  var renderReactError = async (conventionPath, errorProps) => {
3379
3487
  const { createElement } = await import("react");
3380
3488
  const { renderToReadableStream } = await import("react-dom/server");
3381
3489
  const mod = await import(conventionPath);
3382
- const [firstKey] = Object.keys(mod);
3383
- const ErrorComponent = mod.default ?? (firstKey ? mod[firstKey] : undefined);
3490
+ const ErrorComponent = mod.default;
3491
+ if (typeof ErrorComponent !== "function")
3492
+ return null;
3384
3493
  const element = createElement(ErrorComponent, errorProps);
3385
3494
  const stream = await renderToReadableStream(element);
3386
3495
  return new Response(stream, {
@@ -3392,6 +3501,8 @@ var renderSvelteError = async (conventionPath, errorProps) => {
3392
3501
  const { render } = await import("svelte/server");
3393
3502
  const mod = await import(conventionPath);
3394
3503
  const ErrorComponent = mod.default;
3504
+ if (!ErrorComponent)
3505
+ return null;
3395
3506
  const { head, body } = render(ErrorComponent, {
3396
3507
  props: errorProps
3397
3508
  });
@@ -3414,6 +3525,8 @@ var renderVueError = async (conventionPath, errorProps) => {
3414
3525
  const { renderToString } = await import("vue/server-renderer");
3415
3526
  const mod = await import(conventionPath);
3416
3527
  const ErrorComponent = mod.default;
3528
+ if (!ErrorComponent)
3529
+ return null;
3417
3530
  const app = createSSRApp({
3418
3531
  render: () => h(ErrorComponent, errorProps)
3419
3532
  });
@@ -3427,10 +3540,20 @@ var renderVueError = async (conventionPath, errorProps) => {
3427
3540
  };
3428
3541
  var renderAngularError = async (conventionPath, errorProps) => {
3429
3542
  const mod = await import(conventionPath);
3430
- const renderError = mod.default ?? mod.renderError;
3431
- if (typeof renderError !== "function")
3543
+ const renderFn = mod.default;
3544
+ if (typeof renderFn !== "function")
3432
3545
  return null;
3433
- const html = renderError(errorProps);
3546
+ const html = renderFn(errorProps);
3547
+ return new Response(html, {
3548
+ headers: { "Content-Type": "text/html" },
3549
+ status: 500
3550
+ });
3551
+ };
3552
+ var escapeHtml = (value) => value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
3553
+ 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) : "");
3554
+ var renderHtmlError = async (conventionPath, errorProps) => {
3555
+ const template = await Bun.file(conventionPath).text();
3556
+ const html = replaceErrorTokens(template, errorProps);
3434
3557
  return new Response(html, {
3435
3558
  headers: { "Content-Type": "text/html" },
3436
3559
  status: 500
@@ -3449,11 +3572,12 @@ var renderEmberNotFound = async () => null;
3449
3572
  var ERROR_RENDERERS = {
3450
3573
  angular: renderAngularError,
3451
3574
  ember: renderEmberError,
3575
+ html: renderHtmlError,
3452
3576
  react: renderReactError,
3453
3577
  svelte: renderSvelteError,
3454
3578
  vue: renderVueError
3455
3579
  };
3456
- var renderConventionError = async (framework, pageName, error) => {
3580
+ var tryFrameworkErrorConvention = async (framework, pageName, errorProps, error) => {
3457
3581
  let conventionPath = resolveErrorConventionPath(framework, pageName);
3458
3582
  if (!conventionPath && error instanceof Error && error.stack) {
3459
3583
  for (const match of error.stack.matchAll(/^\s*at\s+([A-Za-z_$][\w$]*)/gm)) {
@@ -3467,7 +3591,6 @@ var renderConventionError = async (framework, pageName, error) => {
3467
3591
  }
3468
3592
  if (!conventionPath)
3469
3593
  return null;
3470
- const errorProps = buildErrorProps(error);
3471
3594
  const renderer = ERROR_RENDERERS[framework];
3472
3595
  if (!renderer)
3473
3596
  return null;
@@ -3478,12 +3601,25 @@ var renderConventionError = async (framework, pageName, error) => {
3478
3601
  }
3479
3602
  return null;
3480
3603
  };
3604
+ var renderConventionError = async (framework, pageName, error) => {
3605
+ const errorProps = buildErrorProps(error);
3606
+ const frameworkResponse = await tryFrameworkErrorConvention(framework, pageName, errorProps, error);
3607
+ if (frameworkResponse)
3608
+ return frameworkResponse;
3609
+ if (framework !== "html") {
3610
+ const htmlResponse = await tryFrameworkErrorConvention("html", pageName, errorProps, error);
3611
+ if (htmlResponse)
3612
+ return htmlResponse;
3613
+ }
3614
+ return null;
3615
+ };
3481
3616
  var renderReactNotFound = async (conventionPath) => {
3482
3617
  const { createElement } = await import("react");
3483
3618
  const { renderToReadableStream } = await import("react-dom/server");
3484
3619
  const mod = await import(conventionPath);
3485
- const [nfKey] = Object.keys(mod);
3486
- const NotFoundComponent = mod.default ?? (nfKey ? mod[nfKey] : undefined);
3620
+ const NotFoundComponent = mod.default;
3621
+ if (typeof NotFoundComponent !== "function")
3622
+ return null;
3487
3623
  const element = createElement(NotFoundComponent);
3488
3624
  const stream = await renderToReadableStream(element);
3489
3625
  return new Response(stream, {
@@ -3495,6 +3631,8 @@ var renderSvelteNotFound = async (conventionPath) => {
3495
3631
  const { render } = await import("svelte/server");
3496
3632
  const mod = await import(conventionPath);
3497
3633
  const NotFoundComponent = mod.default;
3634
+ if (!NotFoundComponent)
3635
+ return null;
3498
3636
  const { head, body } = render(NotFoundComponent);
3499
3637
  const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
3500
3638
  return new Response(html, {
@@ -3507,6 +3645,8 @@ var renderVueNotFound = async (conventionPath) => {
3507
3645
  const { renderToString } = await import("vue/server-renderer");
3508
3646
  const mod = await import(conventionPath);
3509
3647
  const NotFoundComponent = mod.default;
3648
+ if (!NotFoundComponent)
3649
+ return null;
3510
3650
  const app = createSSRApp({
3511
3651
  render: () => h(NotFoundComponent)
3512
3652
  });
@@ -3520,10 +3660,17 @@ var renderVueNotFound = async (conventionPath) => {
3520
3660
  };
3521
3661
  var renderAngularNotFound = async (conventionPath) => {
3522
3662
  const mod = await import(conventionPath);
3523
- const renderNotFound = mod.default ?? mod.renderNotFound;
3524
- if (typeof renderNotFound !== "function")
3663
+ const renderFn = mod.default;
3664
+ if (typeof renderFn !== "function")
3525
3665
  return null;
3526
- const html = renderNotFound();
3666
+ const html = renderFn();
3667
+ return new Response(html, {
3668
+ headers: { "Content-Type": "text/html" },
3669
+ status: 404
3670
+ });
3671
+ };
3672
+ var renderHtmlNotFound = async (conventionPath) => {
3673
+ const html = await Bun.file(conventionPath).text();
3527
3674
  return new Response(html, {
3528
3675
  headers: { "Content-Type": "text/html" },
3529
3676
  status: 404
@@ -3532,6 +3679,7 @@ var renderAngularNotFound = async (conventionPath) => {
3532
3679
  var NOT_FOUND_RENDERERS = {
3533
3680
  angular: renderAngularNotFound,
3534
3681
  ember: renderEmberNotFound,
3682
+ html: renderHtmlNotFound,
3535
3683
  react: renderReactNotFound,
3536
3684
  svelte: renderSvelteNotFound,
3537
3685
  vue: renderVueNotFound
@@ -3554,7 +3702,8 @@ var NOT_FOUND_PRIORITY = [
3554
3702
  "react",
3555
3703
  "svelte",
3556
3704
  "vue",
3557
- "angular"
3705
+ "angular",
3706
+ "html"
3558
3707
  ];
3559
3708
  var renderFirstNotFound = async () => {
3560
3709
  const renderNext = async (frameworks) => {
@@ -3836,5 +3985,5 @@ export {
3836
3985
  createTypedIsland
3837
3986
  };
3838
3987
 
3839
- //# debugId=95A608C071E9664464756E2164756E21
3988
+ //# debugId=CB4490FD3D9DB75864756E2164756E21
3840
3989
  //# sourceMappingURL=index.js.map