@ubean/islands 0.4.5 → 0.4.6
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/directive.d.ts +15 -16
- package/dist/index.d.ts +9 -9
- package/dist/runtime.d.ts +23 -24
- package/dist/server-component.d.ts +5 -5
- package/dist/vite.d.ts +18 -19
- package/package.json +6 -6
package/dist/directive.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { DirectiveBinding, ObjectDirective } from "vue";
|
|
|
9
9
|
* - `media`: Hydrate when a CSS media query matches (`matchMedia`).
|
|
10
10
|
* - `only`: Skip SSR entirely — render placeholder during SSR, hydrate on client.
|
|
11
11
|
*/
|
|
12
|
-
type ClientStrategy = 'load' | 'idle' | 'visible' | 'media' | 'only';
|
|
12
|
+
export type ClientStrategy = 'load' | 'idle' | 'visible' | 'media' | 'only';
|
|
13
13
|
/**
|
|
14
14
|
* Modifiers for the `v-client` directive.
|
|
15
15
|
*
|
|
@@ -17,7 +17,7 @@ type ClientStrategy = 'load' | 'idle' | 'visible' | 'media' | 'only';
|
|
|
17
17
|
* matching strategy in priority order (load → idle → visible → media → only)
|
|
18
18
|
* is used.
|
|
19
19
|
*/
|
|
20
|
-
interface ClientDirectiveModifiers {
|
|
20
|
+
export interface ClientDirectiveModifiers {
|
|
21
21
|
/** Hydrate immediately on page load. */
|
|
22
22
|
load?: boolean;
|
|
23
23
|
/** Hydrate when the browser is idle. */
|
|
@@ -40,7 +40,7 @@ interface ClientDirectiveModifiers {
|
|
|
40
40
|
* <Comp v-client.media="isMobile ? '(max-width: 768px)' : '(min-width: 769px)'" />
|
|
41
41
|
* ```
|
|
42
42
|
*/
|
|
43
|
-
type ClientDirectiveValue = string | undefined;
|
|
43
|
+
export type ClientDirectiveValue = string | undefined;
|
|
44
44
|
/**
|
|
45
45
|
* The full directive binding for `v-client`.
|
|
46
46
|
*
|
|
@@ -48,7 +48,7 @@ type ClientDirectiveValue = string | undefined;
|
|
|
48
48
|
* Modifiers are cast to `ClientDirectiveModifiers` at runtime since Vue's
|
|
49
49
|
* `DirectiveBinding` types them as `Record<string, boolean>`.
|
|
50
50
|
*/
|
|
51
|
-
type ClientDirectiveBinding = DirectiveBinding<ClientDirectiveValue>;
|
|
51
|
+
export type ClientDirectiveBinding = DirectiveBinding<ClientDirectiveValue>;
|
|
52
52
|
/**
|
|
53
53
|
* The `v-client` directive type.
|
|
54
54
|
*
|
|
@@ -57,34 +57,34 @@ type ClientDirectiveBinding = DirectiveBinding<ClientDirectiveValue>;
|
|
|
57
57
|
* app.directive('client', vClient);
|
|
58
58
|
* ```
|
|
59
59
|
*/
|
|
60
|
-
type VClientDirective = ObjectDirective<HTMLElement, ClientDirectiveValue, ClientStrategy>;
|
|
60
|
+
export type VClientDirective = ObjectDirective<HTMLElement, ClientDirectiveValue, ClientStrategy>;
|
|
61
61
|
/**
|
|
62
62
|
* Resolve the hydration strategy from directive modifiers.
|
|
63
63
|
*
|
|
64
64
|
* Priority: load → idle → visible → media → only.
|
|
65
65
|
* If no modifier is present, defaults to `'load'`.
|
|
66
66
|
*/
|
|
67
|
-
declare function resolveClientStrategy(modifiers: ClientDirectiveModifiers): ClientStrategy;
|
|
67
|
+
export declare function resolveClientStrategy(modifiers: ClientDirectiveModifiers): ClientStrategy;
|
|
68
68
|
/**
|
|
69
69
|
* Map a `ClientStrategy` to the legacy `ClientDirective` string.
|
|
70
70
|
*
|
|
71
71
|
* Used internally by the Vite plugin to maintain backward compatibility
|
|
72
72
|
* with the `<ubean-island data-directive="client:load">` format.
|
|
73
73
|
*/
|
|
74
|
-
declare function strategyToLegacyDirective(strategy: ClientStrategy): string;
|
|
74
|
+
export declare function strategyToLegacyDirective(strategy: ClientStrategy): string;
|
|
75
75
|
/**
|
|
76
76
|
* Parse a directive string (legacy `client:xxx` or new `v-client.xxx`) into
|
|
77
77
|
* a `ClientStrategy`.
|
|
78
78
|
*
|
|
79
79
|
* @internal Used by the Vite plugin to unify old and new syntax.
|
|
80
80
|
*/
|
|
81
|
-
declare function legacyDirectiveToStrategy(directive: string): ClientStrategy | null;
|
|
81
|
+
export declare function legacyDirectiveToStrategy(directive: string): ClientStrategy | null;
|
|
82
82
|
/** Data attribute used to mark elements for the Islands hydration system. */
|
|
83
|
-
declare const CLIENT_DIRECTIVE_ATTR = "data-client-directive";
|
|
83
|
+
export declare const CLIENT_DIRECTIVE_ATTR = "data-client-directive";
|
|
84
84
|
/** Data attribute for the media query (used with `v-client.media`). */
|
|
85
|
-
declare const CLIENT_MEDIA_ATTR = "data-media";
|
|
85
|
+
export declare const CLIENT_MEDIA_ATTR = "data-media";
|
|
86
86
|
/** Data attribute marking a client-only element (skip SSR). */
|
|
87
|
-
declare const CLIENT_ONLY_ATTR = "data-client-only";
|
|
87
|
+
export declare const CLIENT_ONLY_ATTR = "data-client-only";
|
|
88
88
|
/**
|
|
89
89
|
* The `v-client` Vue custom directive.
|
|
90
90
|
*
|
|
@@ -97,7 +97,7 @@ declare const CLIENT_ONLY_ATTR = "data-client-only";
|
|
|
97
97
|
* so `hydrateIslands()` can discover it, and directly applies the hydration
|
|
98
98
|
* strategy (idle/visible/media) for immediate effect.
|
|
99
99
|
*/
|
|
100
|
-
declare const vClient: VClientDirective;
|
|
100
|
+
export declare const vClient: VClientDirective;
|
|
101
101
|
/**
|
|
102
102
|
* Apply a hydration deferral strategy directly to a DOM element.
|
|
103
103
|
*
|
|
@@ -110,13 +110,13 @@ declare const vClient: VClientDirective;
|
|
|
110
110
|
* - `media`: Defers visibility until `matchMedia` matches.
|
|
111
111
|
* - `only`: No deferral (element is already on client).
|
|
112
112
|
*/
|
|
113
|
-
declare function applyStrategy(el: HTMLElement, strategy: ClientStrategy, mediaQuery?: string): void;
|
|
113
|
+
export declare function applyStrategy(el: HTMLElement, strategy: ClientStrategy, mediaQuery?: string): void;
|
|
114
114
|
/**
|
|
115
115
|
* Clean up all strategy resources for an element.
|
|
116
116
|
*
|
|
117
117
|
* Exported for wrapper components that manage elements manually.
|
|
118
118
|
*/
|
|
119
|
-
declare function cleanupStrategy(el: HTMLElement): void;
|
|
119
|
+
export declare function cleanupStrategy(el: HTMLElement): void;
|
|
120
120
|
/**
|
|
121
121
|
* Augment Vue's type system to recognize `v-client` in templates.
|
|
122
122
|
*
|
|
@@ -145,5 +145,4 @@ declare module 'vue' {
|
|
|
145
145
|
clientDirective?: boolean;
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
//#endregion
|
|
149
|
-
export { CLIENT_DIRECTIVE_ATTR, CLIENT_MEDIA_ATTR, CLIENT_ONLY_ATTR, ClientDirectiveBinding, ClientDirectiveModifiers, ClientDirectiveValue, ClientStrategy, VClientDirective, applyStrategy, cleanupStrategy, legacyDirectiveToStrategy, resolveClientStrategy, strategyToLegacyDirective, vClient };
|
|
148
|
+
//#endregion
|
package/dist/index.d.ts
CHANGED
|
@@ -24,18 +24,18 @@ interface IslandSsrOptions {
|
|
|
24
24
|
mediaQuery?: string;
|
|
25
25
|
children?: string;
|
|
26
26
|
}
|
|
27
|
-
declare function createIslandsContext(): IslandsContext;
|
|
28
|
-
declare function registerIsland(ctx: IslandsContext, component: string, directive: ClientDirective, props: Record<string, unknown>, mediaQuery?: string): string;
|
|
29
|
-
declare function getIslandsScript(islands: IslandDefinition[]): string;
|
|
30
|
-
declare function generateIslandPlaceholder(id: string, component: string, directive: ClientDirective, props: Record<string, unknown>, renderedHtml: string, mediaQuery?: string): string;
|
|
31
|
-
declare function renderIslandPlaceholder(options: IslandSsrOptions): string;
|
|
32
|
-
declare const hydrationStrategyMeta: Record<ClientDirective, {
|
|
27
|
+
export declare function createIslandsContext(): IslandsContext;
|
|
28
|
+
export declare function registerIsland(ctx: IslandsContext, component: string, directive: ClientDirective, props: Record<string, unknown>, mediaQuery?: string): string;
|
|
29
|
+
export declare function getIslandsScript(islands: IslandDefinition[]): string;
|
|
30
|
+
export declare function generateIslandPlaceholder(id: string, component: string, directive: ClientDirective, props: Record<string, unknown>, renderedHtml: string, mediaQuery?: string): string;
|
|
31
|
+
export declare function renderIslandPlaceholder(options: IslandSsrOptions): string;
|
|
32
|
+
export declare const hydrationStrategyMeta: Record<ClientDirective, {
|
|
33
33
|
directive: ClientDirective;
|
|
34
34
|
requiresMediaQuery?: boolean;
|
|
35
35
|
}>;
|
|
36
36
|
//#endregion
|
|
37
37
|
//#region src/bootstrap.d.ts
|
|
38
|
-
declare function getIslandsBootstrapScript(): string;
|
|
39
|
-
declare function getIslandsClearScript(): string;
|
|
38
|
+
export declare function getIslandsBootstrapScript(): string;
|
|
39
|
+
export declare function getIslandsClearScript(): string;
|
|
40
40
|
//#endregion
|
|
41
|
-
export { CLIENT_DIRECTIVE_ATTR, CLIENT_MEDIA_ATTR, CLIENT_ONLY_ATTR, ClientComponentPlaceholder, type ClientDirective, type ClientDirectiveBinding, type ClientDirectiveModifiers, type ClientDirectiveValue, type ClientHydrationStrategy, type ClientStrategy, type IslandDefinition, type IslandOptions, type IslandSsrOptions, type IslandStrategy, type IslandsContext, SERVER_COMPONENT_ENDPOINT, ServerComponentStub, type ServerIslandOptions, type VClientDirective, applyStrategy, cleanupStrategy,
|
|
41
|
+
export { CLIENT_DIRECTIVE_ATTR, CLIENT_MEDIA_ATTR, CLIENT_ONLY_ATTR, ClientComponentPlaceholder, type ClientDirective, type ClientDirectiveBinding, type ClientDirectiveModifiers, type ClientDirectiveValue, type ClientHydrationStrategy, type ClientStrategy, type IslandDefinition, type IslandOptions, type IslandSsrOptions, type IslandStrategy, type IslandsContext, SERVER_COMPONENT_ENDPOINT, ServerComponentStub, type ServerIslandOptions, type VClientDirective, applyStrategy, cleanupStrategy, defineClientComponent, defineIsland, definePairedComponent, defineServerIsland, getServerComponent, legacyDirectiveToStrategy, registerServerComponent, resolveClientStrategy, strategyToLegacyDirective, vClient };
|
package/dist/runtime.d.ts
CHANGED
|
@@ -12,12 +12,12 @@ interface NodeListOf<T> {
|
|
|
12
12
|
interface DomParentNode {
|
|
13
13
|
querySelectorAll(selector: string): NodeListOf<DomElement>;
|
|
14
14
|
}
|
|
15
|
-
interface IslandHydrateOptions {
|
|
15
|
+
export interface IslandHydrateOptions {
|
|
16
16
|
getComponent?: (name: string) => Component | Promise<Component> | null;
|
|
17
17
|
appContext?: App;
|
|
18
18
|
onHydrated?: (el: DomElement, component: Component) => void;
|
|
19
19
|
}
|
|
20
|
-
interface IslandRecord {
|
|
20
|
+
export interface IslandRecord {
|
|
21
21
|
el: DomElement;
|
|
22
22
|
id: string;
|
|
23
23
|
componentName: string;
|
|
@@ -30,8 +30,8 @@ interface IslandRecord {
|
|
|
30
30
|
* Used by the client entry to skip the second rAF on SPA navigations
|
|
31
31
|
* that did not introduce new islands.
|
|
32
32
|
*/
|
|
33
|
-
declare function hasPendingIslands(root?: DomParentNode | null): boolean;
|
|
34
|
-
interface IslandHydrationScheduler {
|
|
33
|
+
export declare function hasPendingIslands(root?: DomParentNode | null): boolean;
|
|
34
|
+
export interface IslandHydrationScheduler {
|
|
35
35
|
requestAnimationFrame: (cb: () => void) => unknown;
|
|
36
36
|
hasPending: () => boolean;
|
|
37
37
|
hydrate: () => void;
|
|
@@ -43,34 +43,34 @@ interface IslandHydrationScheduler {
|
|
|
43
43
|
*/
|
|
44
44
|
forceDoubleFrame?: boolean;
|
|
45
45
|
}
|
|
46
|
-
declare function scheduleIslandHydration(options: IslandHydrationScheduler): void;
|
|
47
|
-
declare function collectIslands(root?: DomParentNode): IslandRecord[];
|
|
48
|
-
declare function hydrateIsland(record: IslandRecord, component: Component, options?: IslandHydrateOptions): void;
|
|
49
|
-
interface HydrateIslandsOptions extends IslandHydrateOptions {
|
|
46
|
+
export declare function scheduleIslandHydration(options: IslandHydrationScheduler): void;
|
|
47
|
+
export declare function collectIslands(root?: DomParentNode): IslandRecord[];
|
|
48
|
+
export declare function hydrateIsland(record: IslandRecord, component: Component, options?: IslandHydrateOptions): void;
|
|
49
|
+
export interface HydrateIslandsOptions extends IslandHydrateOptions {
|
|
50
50
|
root?: DomParentNode;
|
|
51
51
|
components?: Record<string, Component | (() => Promise<Component>)>;
|
|
52
52
|
}
|
|
53
|
-
declare function hydrateIslands(options?: HydrateIslandsOptions): void;
|
|
53
|
+
export declare function hydrateIslands(options?: HydrateIslandsOptions): void;
|
|
54
54
|
/**
|
|
55
55
|
* `POST /__server-component` 端点 — 接收 `{ path, props }`,在服务端用注册表中的
|
|
56
56
|
* 组件重新渲染并返回 HTML 片段。由 `createServerComponentMiddleware()` 处理。
|
|
57
57
|
*/
|
|
58
|
-
declare const SERVER_COMPONENT_ENDPOINT = "/__server-component";
|
|
58
|
+
export declare const SERVER_COMPONENT_ENDPOINT = "/__server-component";
|
|
59
59
|
/**
|
|
60
60
|
* 注册服务端组件到全局注册表 (SSR 构建中由 `defineServerIsland` 自动调用)。
|
|
61
61
|
*/
|
|
62
|
-
declare function registerServerComponent(path: string, component: Component): void;
|
|
62
|
+
export declare function registerServerComponent(path: string, component: Component): void;
|
|
63
63
|
/**
|
|
64
64
|
* 从全局注册表取出服务端组件 (由 `createServerComponentMiddleware` 调用)。
|
|
65
65
|
* 未注册时返回 `undefined`。
|
|
66
66
|
*/
|
|
67
|
-
declare function getServerComponent(path: string): Component | undefined;
|
|
67
|
+
export declare function getServerComponent(path: string): Component | undefined;
|
|
68
68
|
/** 清空注册表 (仅用于测试)。 */
|
|
69
|
-
declare function _clearServerComponentRegistry(): void;
|
|
69
|
+
export declare function _clearServerComponentRegistry(): void;
|
|
70
70
|
/**
|
|
71
71
|
* `defineServerIsland` 的选项。
|
|
72
72
|
*/
|
|
73
|
-
interface ServerIslandOptions {
|
|
73
|
+
export interface ServerIslandOptions {
|
|
74
74
|
/**
|
|
75
75
|
* Suspense fallback 内容。
|
|
76
76
|
*
|
|
@@ -184,15 +184,15 @@ interface ServerIslandOptions {
|
|
|
184
184
|
* @param options 选项
|
|
185
185
|
* @param __serverComponentPath 组件绝对路径 (由 Vite 插件自动注入,勿手动传)
|
|
186
186
|
*/
|
|
187
|
-
declare function defineServerIsland(Component: Component, options?: ServerIslandOptions, __serverComponentPath?: string): Component;
|
|
187
|
+
export declare function defineServerIsland(Component: Component, options?: ServerIslandOptions, __serverComponentPath?: string): Component;
|
|
188
188
|
/**
|
|
189
189
|
* 客户端 island 水合策略(与 `v-client.*` 的 modifier 一一对应)。
|
|
190
190
|
*/
|
|
191
|
-
type IslandStrategy = 'load' | 'idle' | 'visible' | 'media' | 'only';
|
|
191
|
+
export type IslandStrategy = 'load' | 'idle' | 'visible' | 'media' | 'only';
|
|
192
192
|
/**
|
|
193
193
|
* `defineIsland` 的选项。
|
|
194
194
|
*/
|
|
195
|
-
interface IslandOptions {
|
|
195
|
+
export interface IslandOptions {
|
|
196
196
|
/**
|
|
197
197
|
* 媒体查询字符串(仅 `strategy: 'media'` 时使用)。
|
|
198
198
|
*
|
|
@@ -263,7 +263,7 @@ interface IslandOptions {
|
|
|
263
263
|
* </template>
|
|
264
264
|
* ```
|
|
265
265
|
*/
|
|
266
|
-
declare function defineIsland(Component: Component, strategy: IslandStrategy, options?: IslandOptions): Component;
|
|
266
|
+
export declare function defineIsland(Component: Component, strategy: IslandStrategy, options?: IslandOptions): Component;
|
|
267
267
|
/**
|
|
268
268
|
* `.server.vue` 组件在客户端 bundle 中的占位 stub (Task 9.1)。
|
|
269
269
|
*
|
|
@@ -274,7 +274,7 @@ declare function defineIsland(Component: Component, strategy: IslandStrategy, op
|
|
|
274
274
|
*
|
|
275
275
|
* 这保证了 `.server.vue` 组件的 JS 不会发送到客户端 —— 客户端只导入此 stub。
|
|
276
276
|
*/
|
|
277
|
-
declare const ServerComponentStub: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
277
|
+
export declare const ServerComponentStub: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
278
278
|
[key: string]: any;
|
|
279
279
|
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
280
280
|
/**
|
|
@@ -287,7 +287,7 @@ declare const ServerComponentStub: import("vue").DefineComponent<{}, () => impor
|
|
|
287
287
|
* SSR 使用通用占位符(而非真实组件)避免了在服务端导入可能含浏览器 API
|
|
288
288
|
* 的 `.client.vue` 组件代码。
|
|
289
289
|
*/
|
|
290
|
-
declare const ClientComponentPlaceholder: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
290
|
+
export declare const ClientComponentPlaceholder: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
291
291
|
[key: string]: any;
|
|
292
292
|
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
293
293
|
/**
|
|
@@ -320,7 +320,7 @@ declare const ClientComponentPlaceholder: import("vue").DefineComponent<{}, () =
|
|
|
320
320
|
* const WidgetClient = defineClientComponent(Widget);
|
|
321
321
|
* ```
|
|
322
322
|
*/
|
|
323
|
-
declare function defineClientComponent(component: Component): Component;
|
|
323
|
+
export declare function defineClientComponent(component: Component): Component;
|
|
324
324
|
/**
|
|
325
325
|
* 定义配对组件 — `Foo.vue` 同时存在 `.server.vue` + `.client.vue` 兄弟文件时,
|
|
326
326
|
* Vite 插件生成的虚拟包装模块调用此函数 (Task 9.3)。
|
|
@@ -352,6 +352,5 @@ declare function defineClientComponent(component: Component): Component;
|
|
|
352
352
|
* const Foo = definePairedComponent(ServerComp, ClientComp);
|
|
353
353
|
* ```
|
|
354
354
|
*/
|
|
355
|
-
declare function definePairedComponent(ServerComp: Component, ClientComp: Component): Component;
|
|
356
|
-
//#endregion
|
|
357
|
-
export { ClientComponentPlaceholder, HydrateIslandsOptions, IslandHydrateOptions, IslandHydrationScheduler, IslandOptions, IslandRecord, IslandStrategy, SERVER_COMPONENT_ENDPOINT, ServerComponentStub, ServerIslandOptions, _clearServerComponentRegistry, collectIslands, defineClientComponent, defineIsland, definePairedComponent, defineServerIsland, getServerComponent, hasPendingIslands, hydrateIsland, hydrateIslands, registerServerComponent, scheduleIslandHydration };
|
|
355
|
+
export declare function definePairedComponent(ServerComp: Component, ClientComp: Component): Component;
|
|
356
|
+
//#endregion
|
|
@@ -5,7 +5,7 @@ import { MiddlewareHandler } from "hono";
|
|
|
5
5
|
/**
|
|
6
6
|
* 响应头:标识来自 server-component 中间件的响应。
|
|
7
7
|
*/
|
|
8
|
-
declare const SERVER_COMPONENT_RESPONSE_HEADER = "x-ubean-server-component";
|
|
8
|
+
export declare const SERVER_COMPONENT_RESPONSE_HEADER = "x-ubean-server-component";
|
|
9
9
|
/**
|
|
10
10
|
* 创建 server-component 中间件 — 处理 `POST /__server-component` 请求。
|
|
11
11
|
*
|
|
@@ -19,13 +19,13 @@ declare const SERVER_COMPONENT_RESPONSE_HEADER = "x-ubean-server-component";
|
|
|
19
19
|
* app.on('POST', SERVER_COMPONENT_ENDPOINT, createServerComponentMiddleware());
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
|
-
declare function createServerComponentMiddleware(): MiddlewareHandler<UbeanEnv>;
|
|
22
|
+
export declare function createServerComponentMiddleware(): MiddlewareHandler<UbeanEnv>;
|
|
23
23
|
/**
|
|
24
24
|
* 检查请求是否指向 server-component 端点。
|
|
25
25
|
*
|
|
26
26
|
* 供路由注册器跳过将该路径注册为普通 API 路由。
|
|
27
27
|
*/
|
|
28
|
-
declare function isServerComponentRequest(c: {
|
|
28
|
+
export declare function isServerComponentRequest(c: {
|
|
29
29
|
req: {
|
|
30
30
|
path: string;
|
|
31
31
|
method: string;
|
|
@@ -34,6 +34,6 @@ declare function isServerComponentRequest(c: {
|
|
|
34
34
|
/**
|
|
35
35
|
* 检查响应是否来自 server-component 中间件。
|
|
36
36
|
*/
|
|
37
|
-
declare function isServerComponentResponse(response: Response): boolean;
|
|
37
|
+
export declare function isServerComponentResponse(response: Response): boolean;
|
|
38
38
|
//#endregion
|
|
39
|
-
export { SERVER_COMPONENT_ENDPOINT
|
|
39
|
+
export { SERVER_COMPONENT_ENDPOINT };
|
package/dist/vite.d.ts
CHANGED
|
@@ -5,18 +5,18 @@ import { Plugin } from "vite";
|
|
|
5
5
|
*
|
|
6
6
|
* 仅检查路径部分(忽略 `?query`),避免 `?vue&type=template` 子查询误匹配。
|
|
7
7
|
*/
|
|
8
|
-
declare function isServerComponentFile(id: string): boolean;
|
|
8
|
+
export declare function isServerComponentFile(id: string): boolean;
|
|
9
9
|
/**
|
|
10
10
|
* 判断 id 是否为 `.client.vue` 文件 (Task 9.2)。
|
|
11
11
|
*
|
|
12
12
|
* 仅检查路径部分(忽略 `?query`)。注意:从虚拟包装模块内部对真实文件的
|
|
13
13
|
* import 不会被此函数拦截(由 `resolveId` 中的 importer 检查排除)。
|
|
14
14
|
*/
|
|
15
|
-
declare function isClientComponentFile(id: string): boolean;
|
|
15
|
+
export declare function isClientComponentFile(id: string): boolean;
|
|
16
16
|
/** `.server.vue` 在 client 构建中的通用虚拟 stub 模块 ID */
|
|
17
|
-
declare const SERVER_COMPONENT_STUB_VIRTUAL_ID = "virtual:ubean-server-component-stub";
|
|
17
|
+
export declare const SERVER_COMPONENT_STUB_VIRTUAL_ID = "virtual:ubean-server-component-stub";
|
|
18
18
|
/** `.client.vue` 在 SSR 构建中的通用占位符虚拟模块 ID */
|
|
19
|
-
declare const CLIENT_COMPONENT_PLACEHOLDER_VIRTUAL_ID = "virtual:ubean-client-component-placeholder";
|
|
19
|
+
export declare const CLIENT_COMPONENT_PLACEHOLDER_VIRTUAL_ID = "virtual:ubean-client-component-placeholder";
|
|
20
20
|
/**
|
|
21
21
|
* 将 `.server.vue` SFC 的 `<template>` 内容包裹在 `<ubean-server-only v-once>` 中。
|
|
22
22
|
*
|
|
@@ -27,7 +27,7 @@ declare const CLIENT_COMPONENT_PLACEHOLDER_VIRTUAL_ID = "virtual:ubean-client-co
|
|
|
27
27
|
* 仅在 SSR 上下文运行(client 构建中 `.server.vue` 被 `resolveId` 重定向到 stub,
|
|
28
28
|
* 真实文件不会被加载/转换)。
|
|
29
29
|
*/
|
|
30
|
-
declare function wrapServerComponentTemplate(code: string): string | null;
|
|
30
|
+
export declare function wrapServerComponentTemplate(code: string): string | null;
|
|
31
31
|
/**
|
|
32
32
|
* 一个 island 组件的注册条目。
|
|
33
33
|
*
|
|
@@ -35,13 +35,13 @@ declare function wrapServerComponentTemplate(code: string): string | null;
|
|
|
35
35
|
* - `importPath`:组件文件的绝对路径或 bare specifier(来自 `<script setup>` 的 import)
|
|
36
36
|
* - `sourceFile`:发现该 island 的源文件绝对路径,用于调试与 HMR 失效
|
|
37
37
|
*/
|
|
38
|
-
interface IslandComponentEntry {
|
|
38
|
+
export interface IslandComponentEntry {
|
|
39
39
|
name: string;
|
|
40
40
|
importPath: string;
|
|
41
41
|
sourceFile: string;
|
|
42
42
|
}
|
|
43
43
|
/** Plugin 内部的 island 组件收集表:组件名 → 条目 */
|
|
44
|
-
type IslandComponentMap = Map<string, IslandComponentEntry>;
|
|
44
|
+
export type IslandComponentMap = Map<string, IslandComponentEntry>;
|
|
45
45
|
/**
|
|
46
46
|
* 从 `<script setup>` / `<script>` 内容中解析 default import 与 `default as` 别名,
|
|
47
47
|
* 建立 { 局部名 → import 路径 } 映射。
|
|
@@ -56,7 +56,7 @@ type IslandComponentMap = Map<string, IslandComponentEntry>;
|
|
|
56
56
|
* import { default as Foo, bar } from './Foo.vue'
|
|
57
57
|
* import { default as Foo } from './Foo.vue'
|
|
58
58
|
*/
|
|
59
|
-
declare function parseScriptImports(scriptContent: string): Map<string, string>;
|
|
59
|
+
export declare function parseScriptImports(scriptContent: string): Map<string, string>;
|
|
60
60
|
/**
|
|
61
61
|
* Task 9.4: 扫描代码中的 `defineServerIsland(Identifier, { ... rerenderOnPropsChange: true ... })`
|
|
62
62
|
* 调用,解析 `Identifier` 的 import 路径,将其作为第 3 个参数注入:
|
|
@@ -84,7 +84,7 @@ declare function parseScriptImports(scriptContent: string): Map<string, string>;
|
|
|
84
84
|
* @param sourceFile 源文件绝对路径(用于解析相对 import)
|
|
85
85
|
* @returns 修改后的源码,或 `null` 表示无修改
|
|
86
86
|
*/
|
|
87
|
-
declare function injectServerComponentPath(code: string, sourceFile: string): string | null;
|
|
87
|
+
export declare function injectServerComponentPath(code: string, sourceFile: string): string | null;
|
|
88
88
|
/**
|
|
89
89
|
* 扫描模板内容,返回所有带 `v-client.*` 指令的组件标签名集合。
|
|
90
90
|
*
|
|
@@ -96,11 +96,11 @@ declare function injectServerComponentPath(code: string, sourceFile: string): st
|
|
|
96
96
|
*
|
|
97
97
|
* Phase 4: 仅识别 `v-client.*`(旧的 `client:*` 语法已移除)。
|
|
98
98
|
*/
|
|
99
|
-
declare function scanIslandDirectiveNames(template: string): Set<string>;
|
|
99
|
+
export declare function scanIslandDirectiveNames(template: string): Set<string>;
|
|
100
100
|
/**
|
|
101
101
|
* 将相对 import 路径解析为绝对路径;bare specifier(如 `vue`、`some-lib`)原样返回。
|
|
102
102
|
*/
|
|
103
|
-
declare function resolveIslandImportPath(importPath: string, sourceFile: string): string;
|
|
103
|
+
export declare function resolveIslandImportPath(importPath: string, sourceFile: string): string;
|
|
104
104
|
/**
|
|
105
105
|
* 从 Vue SFC 源码中收集 island 组件信息。
|
|
106
106
|
*
|
|
@@ -114,7 +114,7 @@ declare function resolveIslandImportPath(importPath: string, sourceFile: string)
|
|
|
114
114
|
* 对未在 import 映射中的 island 组件(如全局注册、动态 import、defineAsyncComponent),
|
|
115
115
|
* 输出警告,提示用户手动注册。
|
|
116
116
|
*/
|
|
117
|
-
declare function collectIslandComponents(code: string, sourceFile: string): IslandComponentEntry[];
|
|
117
|
+
export declare function collectIslandComponents(code: string, sourceFile: string): IslandComponentEntry[];
|
|
118
118
|
/**
|
|
119
119
|
* 生成 `virtual:ubean-islands-registry` 模块内容。
|
|
120
120
|
*
|
|
@@ -133,16 +133,15 @@ declare function collectIslandComponents(code: string, sourceFile: string): Isla
|
|
|
133
133
|
*
|
|
134
134
|
* 当 map 为空时,返回 `export const islands = {};` 保证下游 import 不会因模块缺失而报错。
|
|
135
135
|
*/
|
|
136
|
-
declare function generateRegistryModule(components: IslandComponentMap): string;
|
|
137
|
-
declare function transformVueSfcIslands(code: string, filePath: string): {
|
|
136
|
+
export declare function generateRegistryModule(components: IslandComponentMap): string;
|
|
137
|
+
export declare function transformVueSfcIslands(code: string, filePath: string): {
|
|
138
138
|
code: string;
|
|
139
139
|
islandCount: number;
|
|
140
140
|
};
|
|
141
|
-
interface UbeanIslandsPluginOptions {
|
|
141
|
+
export interface UbeanIslandsPluginOptions {
|
|
142
142
|
enabled?: boolean;
|
|
143
143
|
}
|
|
144
144
|
/** virtual:ubean-islands-registry 的虚拟模块 ID(遵循 AGENTS.md §8 教训 #7:用 `virtual:ubean-` 前缀) */
|
|
145
|
-
declare const ISLANDS_REGISTRY_VIRTUAL_ID = "virtual:ubean-islands-registry";
|
|
146
|
-
declare function ubeanIslandsPlugin(_options?: UbeanIslandsPluginOptions): Plugin;
|
|
147
|
-
//#endregion
|
|
148
|
-
export { CLIENT_COMPONENT_PLACEHOLDER_VIRTUAL_ID, ISLANDS_REGISTRY_VIRTUAL_ID, IslandComponentEntry, IslandComponentMap, SERVER_COMPONENT_STUB_VIRTUAL_ID, UbeanIslandsPluginOptions, collectIslandComponents, generateRegistryModule, injectServerComponentPath, isClientComponentFile, isServerComponentFile, parseScriptImports, resolveIslandImportPath, scanIslandDirectiveNames, transformVueSfcIslands, ubeanIslandsPlugin, wrapServerComponentTemplate };
|
|
145
|
+
export declare const ISLANDS_REGISTRY_VIRTUAL_ID = "virtual:ubean-islands-registry";
|
|
146
|
+
export declare function ubeanIslandsPlugin(_options?: UbeanIslandsPluginOptions): Plugin;
|
|
147
|
+
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ubean/islands",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
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,18 +36,18 @@
|
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@ubean/shared": "0.4.
|
|
39
|
+
"@ubean/shared": "0.4.6",
|
|
40
40
|
"hono": "4.13.7",
|
|
41
41
|
"vue": "^3.5.42"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/node": "^26.5.0",
|
|
45
|
-
"typescript": "
|
|
46
|
-
"vite": "npm:@voidzero-dev/vite-plus-core@0.3.
|
|
47
|
-
"vite-plus": "0.3.
|
|
45
|
+
"typescript": "npm:typescript-native-bridge@latest",
|
|
46
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@0.3.1",
|
|
47
|
+
"vite-plus": "0.3.1"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"vite": "npm:@voidzero-dev/vite-plus-core@0.3.
|
|
50
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@0.3.1"
|
|
51
51
|
},
|
|
52
52
|
"peerDependenciesMeta": {
|
|
53
53
|
"vite": {
|