@absolutejs/absolute 0.19.0-beta.928 → 0.19.0-beta.929

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.
@@ -0,0 +1,15 @@
1
+ import type { IslandFramework, IslandHydrate } from '../../types/island';
2
+ type RawIslandProps = {
3
+ component: string;
4
+ framework: string;
5
+ hydrate?: string | undefined;
6
+ props: unknown;
7
+ };
8
+ export declare const normalizeRuntimeIslandRenderProps: (raw: RawIslandProps) => {
9
+ component: string;
10
+ framework: IslandFramework;
11
+ hydrate: IslandHydrate | undefined;
12
+ props: Record<string, unknown>;
13
+ };
14
+ export declare const normalizeIslandProps: (value: unknown) => Record<string, unknown>;
15
+ export {};
@@ -0,0 +1 @@
1
+ export declare const compileVueServerModule: (sourcePath: string) => Promise<string>;
@@ -1,13 +1,37 @@
1
- export declare const Island: import("vue").DefineComponent<{
2
- component: string;
3
- framework: import("..").IslandFramework;
4
- hydrate?: import("..").IslandHydrate | undefined;
5
- props: Record<string, unknown>;
6
- }, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
1
+ export declare const Island: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
+ component: {
3
+ required: true;
4
+ type: StringConstructor;
5
+ };
6
+ framework: {
7
+ required: true;
8
+ type: StringConstructor;
9
+ };
10
+ hydrate: {
11
+ required: false;
12
+ type: StringConstructor;
13
+ };
14
+ props: {
15
+ required: false;
16
+ type: (ObjectConstructor | StringConstructor)[];
17
+ };
18
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
7
19
  [key: string]: any;
8
- }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
9
- component: string;
10
- framework: import("..").IslandFramework;
11
- hydrate?: import("..").IslandHydrate | undefined;
12
- props: Record<string, unknown>;
13
- }> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
20
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
21
+ component: {
22
+ required: true;
23
+ type: StringConstructor;
24
+ };
25
+ framework: {
26
+ required: true;
27
+ type: StringConstructor;
28
+ };
29
+ hydrate: {
30
+ required: false;
31
+ type: StringConstructor;
32
+ };
33
+ props: {
34
+ required: false;
35
+ type: (ObjectConstructor | StringConstructor)[];
36
+ };
37
+ }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -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;
@@ -3836,5 +3939,5 @@ export {
3836
3939
  createTypedIsland
3837
3940
  };
3838
3941
 
3839
- //# debugId=95A608C071E9664464756E2164756E21
3942
+ //# debugId=76F703206AC2F94E64756E2164756E21
3840
3943
  //# sourceMappingURL=index.js.map