@ubean/islands 0.3.7 → 0.4.0
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/server-component.d.ts +1 -1
- package/dist/server-component.js +1 -1
- package/dist/vite.d.ts +7 -5
- package/dist/vite.js +8 -14
- package/package.json +2 -2
|
@@ -12,7 +12,7 @@ declare const SERVER_COMPONENT_RESPONSE_HEADER = "x-ubean-server-component";
|
|
|
12
12
|
* 用法 (通常由 `createUbeanApp()` 自动挂载,用户无需手动调用):
|
|
13
13
|
*
|
|
14
14
|
* ```ts
|
|
15
|
-
* import { createUbeanApp } from 'ubean/
|
|
15
|
+
* import { createUbeanApp } from 'ubean/server';
|
|
16
16
|
* import { createServerComponentMiddleware, SERVER_COMPONENT_ENDPOINT } from '@ubean/islands/server';
|
|
17
17
|
*
|
|
18
18
|
* const app = createUbeanApp();
|
package/dist/server-component.js
CHANGED
|
@@ -12,7 +12,7 @@ const SERVER_COMPONENT_RESPONSE_HEADER = "x-ubean-server-component";
|
|
|
12
12
|
* 用法 (通常由 `createUbeanApp()` 自动挂载,用户无需手动调用):
|
|
13
13
|
*
|
|
14
14
|
* ```ts
|
|
15
|
-
* import { createUbeanApp } from 'ubean/
|
|
15
|
+
* import { createUbeanApp } from 'ubean/server';
|
|
16
16
|
* import { createServerComponentMiddleware, SERVER_COMPONENT_ENDPOINT } from '@ubean/islands/server';
|
|
17
17
|
*
|
|
18
18
|
* const app = createUbeanApp();
|
package/dist/vite.d.ts
CHANGED
|
@@ -118,14 +118,16 @@ declare function collectIslandComponents(code: string, sourceFile: string): Isla
|
|
|
118
118
|
/**
|
|
119
119
|
* 生成 `virtual:ubean-islands-registry` 模块内容。
|
|
120
120
|
*
|
|
121
|
+
* 组件以惰性 loader(`() => import(...)`)形式导出 —— 内核 `hydrateIslands`
|
|
122
|
+
* 的 `components` 类型本就接受 `Component | (() => Promise<Component>)`,
|
|
123
|
+
* `Promise.resolve` 统一解析。惰性加载保证 islands 组件不因注册表被客户端
|
|
124
|
+
* 入口静态导入而进入 entry chunk(islands 按需加载是架构前提)。
|
|
125
|
+
*
|
|
121
126
|
* 输出示例:
|
|
122
127
|
* ```ts
|
|
123
|
-
* import __island_0 from '/src/components/IslandCounter.vue';
|
|
124
|
-
* import __island_1 from '/src/components/IslandMedia.vue';
|
|
125
|
-
*
|
|
126
128
|
* export const islands = {
|
|
127
|
-
* "IslandCounter":
|
|
128
|
-
* "IslandMedia":
|
|
129
|
+
* "IslandCounter": () => import('/src/components/IslandCounter.vue'),
|
|
130
|
+
* "IslandMedia": () => import('/src/components/IslandMedia.vue')
|
|
129
131
|
* };
|
|
130
132
|
* ```
|
|
131
133
|
*
|
package/dist/vite.js
CHANGED
|
@@ -572,14 +572,16 @@ function extractScriptBlock(code) {
|
|
|
572
572
|
/**
|
|
573
573
|
* 生成 `virtual:ubean-islands-registry` 模块内容。
|
|
574
574
|
*
|
|
575
|
+
* 组件以惰性 loader(`() => import(...)`)形式导出 —— 内核 `hydrateIslands`
|
|
576
|
+
* 的 `components` 类型本就接受 `Component | (() => Promise<Component>)`,
|
|
577
|
+
* `Promise.resolve` 统一解析。惰性加载保证 islands 组件不因注册表被客户端
|
|
578
|
+
* 入口静态导入而进入 entry chunk(islands 按需加载是架构前提)。
|
|
579
|
+
*
|
|
575
580
|
* 输出示例:
|
|
576
581
|
* ```ts
|
|
577
|
-
* import __island_0 from '/src/components/IslandCounter.vue';
|
|
578
|
-
* import __island_1 from '/src/components/IslandMedia.vue';
|
|
579
|
-
*
|
|
580
582
|
* export const islands = {
|
|
581
|
-
* "IslandCounter":
|
|
582
|
-
* "IslandMedia":
|
|
583
|
+
* "IslandCounter": () => import('/src/components/IslandCounter.vue'),
|
|
584
|
+
* "IslandMedia": () => import('/src/components/IslandMedia.vue')
|
|
583
585
|
* };
|
|
584
586
|
* ```
|
|
585
587
|
*
|
|
@@ -587,17 +589,9 @@ function extractScriptBlock(code) {
|
|
|
587
589
|
*/
|
|
588
590
|
function generateRegistryModule(components) {
|
|
589
591
|
if (components.size === 0) return "export const islands = {};";
|
|
590
|
-
const imports = [];
|
|
591
592
|
const entries = [];
|
|
592
|
-
|
|
593
|
-
for (const [name, entry] of components) {
|
|
594
|
-
const varName = `__island_${idx++}`;
|
|
595
|
-
imports.push(`import ${varName} from ${JSON.stringify(entry.importPath)};`);
|
|
596
|
-
entries.push(` ${JSON.stringify(name)}: ${varName},`);
|
|
597
|
-
}
|
|
593
|
+
for (const [name, entry] of components) entries.push(` ${JSON.stringify(name)}: () => import(${JSON.stringify(entry.importPath)}),`);
|
|
598
594
|
return [
|
|
599
|
-
...imports,
|
|
600
|
-
"",
|
|
601
595
|
"export const islands = {",
|
|
602
596
|
...entries,
|
|
603
597
|
"};"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ubean/islands",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Islands architecture for ubean (Vite plugin for client:load/idle/visible/media/only directives, bootstrap script, client hydrate runtime)",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@ubean/shared": "0.
|
|
39
|
+
"@ubean/shared": "0.4.0",
|
|
40
40
|
"hono": "4.13.5",
|
|
41
41
|
"vue": "^3.5.42"
|
|
42
42
|
},
|