@ubean/build 0.4.4 → 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/actions-plugin.d.ts +7 -8
- package/dist/codegen/index.d.ts +31 -31
- package/dist/codegen/index.js +1 -1
- package/dist/{codegen-BqqGw4Dv.js → codegen-B3oGeRtK.js} +2 -1
- package/dist/index.d.ts +19 -19
- package/dist/prerender.d.ts +24 -12
- package/dist/prerender.js +9 -5
- package/dist/production.d.ts +4 -5
- package/dist/production.js +302 -73
- package/dist/static-render.d.ts +100 -0
- package/dist/static-render.js +254 -0
- package/dist/vite.d.ts +3 -4
- package/dist/{vue-DzQKpjU3.js → vue-DcydGsvy.js} +15 -12
- package/dist/vue.d.ts +7 -7
- package/dist/vue.js +1 -1
- package/package.json +20 -16
package/dist/actions-plugin.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Plugin } from "vite";
|
|
2
2
|
//#region src/actions-plugin.d.ts
|
|
3
|
-
interface ServerActionsPluginOptions {
|
|
3
|
+
export interface ServerActionsPluginOptions {
|
|
4
4
|
/**
|
|
5
5
|
* The project root directory (used for computing stable action IDs).
|
|
6
6
|
* Defaults to `process.cwd()` at plugin creation time.
|
|
@@ -32,31 +32,30 @@ interface DefineActionCall {
|
|
|
32
32
|
*
|
|
33
33
|
* 跳过注释内的匹配(如 JSDoc 示例)和函数声明(`function defineAction(`)。
|
|
34
34
|
*/
|
|
35
|
-
declare function findDefineActionCalls(code: string): DefineActionCall[];
|
|
35
|
+
export declare function findDefineActionCalls(code: string): DefineActionCall[];
|
|
36
36
|
/**
|
|
37
37
|
* 检测源码是否包含 `defineAction(` 调用。
|
|
38
38
|
*/
|
|
39
|
-
declare function hasDefineActionCall(code: string): boolean;
|
|
39
|
+
export declare function hasDefineActionCall(code: string): boolean;
|
|
40
40
|
/**
|
|
41
41
|
* 服务端转换:为每个 `defineAction()` 调用注入 `filePath`(以及缺失时的 `name`),
|
|
42
42
|
* 确保 action ID 在 dev / build 之间稳定。
|
|
43
43
|
*
|
|
44
44
|
* 返回转换后的代码;若无 `defineAction` 调用则返回 `null`。
|
|
45
45
|
*/
|
|
46
|
-
declare function transformActionsForServer(code: string, filePath: string, root: string): string | null;
|
|
46
|
+
export declare function transformActionsForServer(code: string, filePath: string, root: string): string | null;
|
|
47
47
|
/**
|
|
48
48
|
* 客户端转换:将每个 `defineAction(...)` 调用替换为
|
|
49
49
|
* `__ubean_createActionStub('<id>')`(别名 import,避免与用户代码冲突)。
|
|
50
50
|
*
|
|
51
51
|
* 返回转换后的代码(含注入的 import);若无 `defineAction` 调用则返回 `null`。
|
|
52
52
|
*/
|
|
53
|
-
declare function transformActionsForClient(code: string, filePath: string, root: string): string | null;
|
|
53
|
+
export declare function transformActionsForClient(code: string, filePath: string, root: string): string | null;
|
|
54
54
|
/**
|
|
55
55
|
* Vite 插件:Server Actions 的客户端/服务端拆分。
|
|
56
56
|
*
|
|
57
57
|
* - 服务端(SSR):注入 `filePath`/`name` 到 `defineAction()` 选项。
|
|
58
58
|
* - 客户端(浏览器):将 `defineAction(...)` 替换为 `createActionStub('<id>')`。
|
|
59
59
|
*/
|
|
60
|
-
declare function ubeanServerActionsPlugin(options?: ServerActionsPluginOptions): Plugin;
|
|
61
|
-
//#endregion
|
|
62
|
-
export { ServerActionsPluginOptions, findDefineActionCalls, hasDefineActionCall, transformActionsForClient, transformActionsForServer, ubeanServerActionsPlugin };
|
|
60
|
+
export declare function ubeanServerActionsPlugin(options?: ServerActionsPluginOptions): Plugin;
|
|
61
|
+
//#endregion
|
package/dist/codegen/index.d.ts
CHANGED
|
@@ -35,9 +35,9 @@ interface ResolvedAutoImports {
|
|
|
35
35
|
options: AutoImportOptions;
|
|
36
36
|
}
|
|
37
37
|
/** 将 `boolean | AutoImportOptions` 归一化为分库开关 + 透传选项。 */
|
|
38
|
-
declare function resolveAutoImportsConfig(input: boolean | AutoImportOptions | undefined): ResolvedAutoImports;
|
|
38
|
+
export declare function resolveAutoImportsConfig(input: boolean | AutoImportOptions | undefined): ResolvedAutoImports;
|
|
39
39
|
/** 按分库开关组装内置预设(顺序稳定:ubean client/server → vue → vue-router → vue-i18n → hono-openapi)。 */
|
|
40
|
-
declare function getAutoImportPresets(resolved: ResolvedAutoImports): InlinePreset[];
|
|
40
|
+
export declare function getAutoImportPresets(resolved: ResolvedAutoImports): InlinePreset[];
|
|
41
41
|
interface ResolvedComponentsAutoImport {
|
|
42
42
|
/** 目录扫描 + dts 总开关(`components: false` 时为 `false`;resolver 仍然生效)。 */
|
|
43
43
|
enabled: boolean;
|
|
@@ -47,28 +47,28 @@ interface ResolvedComponentsAutoImport {
|
|
|
47
47
|
options: ComponentsOptions;
|
|
48
48
|
}
|
|
49
49
|
/** 将 `boolean | ComponentsOptions` 归一化。 */
|
|
50
|
-
declare function resolveComponentsConfig(input: boolean | ComponentsOptions | undefined): ResolvedComponentsAutoImport;
|
|
50
|
+
export declare function resolveComponentsConfig(input: boolean | ComponentsOptions | undefined): ResolvedComponentsAutoImport;
|
|
51
51
|
/** unplugin 系选项普遍使用 `Arrayable<T>`,合并进数组前先归一化。 */
|
|
52
|
-
declare function toArray<T>(value: T | T[] | undefined): T[];
|
|
53
|
-
declare const VUE_PRESET: InlinePreset;
|
|
54
|
-
declare const VUE_MACROS_PRESET: InlinePreset;
|
|
52
|
+
export declare function toArray<T>(value: T | T[] | undefined): T[];
|
|
53
|
+
export declare const VUE_PRESET: InlinePreset;
|
|
54
|
+
export declare const VUE_MACROS_PRESET: InlinePreset;
|
|
55
55
|
/**
|
|
56
56
|
* Client-safe symbols sourced from the first-class `ubean/client` entry.
|
|
57
57
|
* These are safe to auto-import in Vue components (browser-side) because
|
|
58
58
|
* `@ubean/client` has zero build-time dependencies and no `node:*` imports.
|
|
59
59
|
*/
|
|
60
|
-
declare const UBEAN_CLIENT_PRESET: InlinePreset;
|
|
60
|
+
export declare const UBEAN_CLIENT_PRESET: InlinePreset;
|
|
61
61
|
/**
|
|
62
62
|
* vue-router composables, sourced directly from `vue-router` (not re-exported
|
|
63
63
|
* through `ubean/client` — third-party APIs are imported from their own packages).
|
|
64
64
|
*/
|
|
65
|
-
declare const VUE_ROUTER_PRESET: InlinePreset;
|
|
65
|
+
export declare const VUE_ROUTER_PRESET: InlinePreset;
|
|
66
66
|
/**
|
|
67
67
|
* vue-i18n Composition API, sourced directly from `vue-i18n` (ubean no longer
|
|
68
68
|
* wraps `useI18n` — same instance is exposed by the framework-installed
|
|
69
69
|
* vue-i18n plugin; `t` is destructured from the returned composer).
|
|
70
70
|
*/
|
|
71
|
-
declare const VUE_I18N_PRESET: InlinePreset;
|
|
71
|
+
export declare const VUE_I18N_PRESET: InlinePreset;
|
|
72
72
|
/**
|
|
73
73
|
* Server-only symbols sourced from the `ubean/server` aggregation entry
|
|
74
74
|
* (`@ubean/app` + `@ubean/routes` + `@ubean/server` + `@ubean/shared/node`).
|
|
@@ -85,9 +85,9 @@ declare const VUE_I18N_PRESET: InlinePreset;
|
|
|
85
85
|
* unplugin-auto-import emit a "Duplicated imports" warning, so they live in
|
|
86
86
|
* the client preset only.
|
|
87
87
|
*/
|
|
88
|
-
declare const UBEAN_SERVER_PRESET: InlinePreset;
|
|
89
|
-
declare const HONO_OPENAPI_PRESET: InlinePreset;
|
|
90
|
-
declare const BUILTIN_PRESETS: InlinePreset[];
|
|
88
|
+
export declare const UBEAN_SERVER_PRESET: InlinePreset;
|
|
89
|
+
export declare const HONO_OPENAPI_PRESET: InlinePreset;
|
|
90
|
+
export declare const BUILTIN_PRESETS: InlinePreset[];
|
|
91
91
|
interface ComponentInfo {
|
|
92
92
|
name: string;
|
|
93
93
|
filePath: string;
|
|
@@ -100,8 +100,8 @@ interface AutoImportResult {
|
|
|
100
100
|
autoImportsDtsPath: string;
|
|
101
101
|
componentsDtsPath: string;
|
|
102
102
|
}
|
|
103
|
-
declare function generateAutoImports(_scanResult: ScanResult, options: GenerateAutoImportsOptions): Promise<AutoImportResult>;
|
|
104
|
-
declare function getBuiltinComposables(): Import[];
|
|
103
|
+
export declare function generateAutoImports(_scanResult: ScanResult, options: GenerateAutoImportsOptions): Promise<AutoImportResult>;
|
|
104
|
+
export declare function getBuiltinComposables(): Import[];
|
|
105
105
|
/** unplugin-auto-import 的组装结果(透传字段类型直接引用 unplugin 类型,避免跨包类型命名问题)。 */
|
|
106
106
|
interface UbeanAutoImportConfig {
|
|
107
107
|
imports: Options$1['imports'];
|
|
@@ -110,7 +110,7 @@ interface UbeanAutoImportConfig {
|
|
|
110
110
|
vueTemplate: boolean;
|
|
111
111
|
eslintrc: Options$1['eslintrc'];
|
|
112
112
|
}
|
|
113
|
-
declare function getUbeanAutoImportConfig(options?: {
|
|
113
|
+
export declare function getUbeanAutoImportConfig(options?: {
|
|
114
114
|
cwd?: string;
|
|
115
115
|
srcDir?: string;
|
|
116
116
|
buildDir?: string;
|
|
@@ -126,7 +126,7 @@ interface UbeanComponentsConfig {
|
|
|
126
126
|
dts: Options['dts'];
|
|
127
127
|
deep: boolean;
|
|
128
128
|
}
|
|
129
|
-
declare function getUbeanComponentsConfig(options?: {
|
|
129
|
+
export declare function getUbeanComponentsConfig(options?: {
|
|
130
130
|
cwd?: string;
|
|
131
131
|
srcDir?: string;
|
|
132
132
|
buildDir?: string;
|
|
@@ -135,7 +135,7 @@ declare function getUbeanComponentsConfig(options?: {
|
|
|
135
135
|
/** `ubean.config.ts` 的 `components` 配置。 */
|
|
136
136
|
components?: boolean | ComponentsOptions;
|
|
137
137
|
}): UbeanComponentsConfig;
|
|
138
|
-
declare function generateImportsTransform(imports: Import[]): {
|
|
138
|
+
export declare function generateImportsTransform(imports: Import[]): {
|
|
139
139
|
code: string;
|
|
140
140
|
map?: null;
|
|
141
141
|
};
|
|
@@ -147,12 +147,12 @@ interface RouteTypesOptions {
|
|
|
147
147
|
outDir: string;
|
|
148
148
|
fileName?: string;
|
|
149
149
|
}
|
|
150
|
-
declare function generateRouteTypes(result: ScanResult, options: RouteTypesOptions): Promise<string>;
|
|
150
|
+
export declare function generateRouteTypes(result: ScanResult, options: RouteTypesOptions): Promise<string>;
|
|
151
151
|
interface PageTypesOptions {
|
|
152
152
|
outDir: string;
|
|
153
153
|
fileName?: string;
|
|
154
154
|
}
|
|
155
|
-
declare function generatePageTypes(result: ScanResult, options: PageTypesOptions): Promise<string>;
|
|
155
|
+
export declare function generatePageTypes(result: ScanResult, options: PageTypesOptions): Promise<string>;
|
|
156
156
|
//#endregion
|
|
157
157
|
//#region src/codegen/i18n-types.d.ts
|
|
158
158
|
interface I18nTypesOptions {
|
|
@@ -161,13 +161,13 @@ interface I18nTypesOptions {
|
|
|
161
161
|
defaultLocale?: string;
|
|
162
162
|
}
|
|
163
163
|
/** Convert a JSON message tree into a TypeScript object type body. */
|
|
164
|
-
declare function messagesToTsType(value: unknown, indent?: number): string;
|
|
164
|
+
export declare function messagesToTsType(value: unknown, indent?: number): string;
|
|
165
165
|
/**
|
|
166
166
|
* Generate `.ubean/i18n.d.ts` augmenting vue-i18n `DefineLocaleMessage`
|
|
167
167
|
* from the default locale JSON. Users can also hand-write the same
|
|
168
168
|
* module augmentation if they prefer.
|
|
169
169
|
*/
|
|
170
|
-
declare function generateI18nTypes(result: ScanResult, options: I18nTypesOptions): Promise<string | null>;
|
|
170
|
+
export declare function generateI18nTypes(result: ScanResult, options: I18nTypesOptions): Promise<string | null>;
|
|
171
171
|
//#endregion
|
|
172
172
|
//#region src/codegen/openapi-types.d.ts
|
|
173
173
|
/**
|
|
@@ -187,7 +187,7 @@ interface GenerateOpenApiTypesOptions {
|
|
|
187
187
|
/**
|
|
188
188
|
* 从 OpenAPI schema 对象生成 paths 类型声明文件。
|
|
189
189
|
*/
|
|
190
|
-
declare function generateOpenApiTypes(schema: unknown, options: GenerateOpenApiTypesOptions): Promise<string>;
|
|
190
|
+
export declare function generateOpenApiTypes(schema: unknown, options: GenerateOpenApiTypesOptions): Promise<string>;
|
|
191
191
|
/**
|
|
192
192
|
* 从 dev server 的 `/_openapi.json` 路由获取 schema 并生成类型声明文件。
|
|
193
193
|
*
|
|
@@ -195,18 +195,18 @@ declare function generateOpenApiTypes(schema: unknown, options: GenerateOpenApiT
|
|
|
195
195
|
* HTML(页面 fallback)而非 JSON。此时跳过生成并返回 `null`,避免抛出
|
|
196
196
|
* `Unexpected token '<'` 之类的误导性错误。
|
|
197
197
|
*/
|
|
198
|
-
declare function generateOpenApiTypesFromServer(baseUrl: string, options: GenerateOpenApiTypesOptions): Promise<string | null>;
|
|
198
|
+
export declare function generateOpenApiTypesFromServer(baseUrl: string, options: GenerateOpenApiTypesOptions): Promise<string | null>;
|
|
199
199
|
//#endregion
|
|
200
200
|
//#region src/codegen/index.d.ts
|
|
201
|
-
declare const CODEGEN_CONTRACT_VERSION: 1;
|
|
202
|
-
interface CodegenFileContract {
|
|
201
|
+
export declare const CODEGEN_CONTRACT_VERSION: 1;
|
|
202
|
+
export interface CodegenFileContract {
|
|
203
203
|
name: string;
|
|
204
204
|
module: string | null;
|
|
205
205
|
required: boolean;
|
|
206
206
|
types: string[];
|
|
207
207
|
}
|
|
208
|
-
declare const CODEGEN_FILES: readonly CodegenFileContract[];
|
|
209
|
-
interface CodegenManifest {
|
|
208
|
+
export declare const CODEGEN_FILES: readonly CodegenFileContract[];
|
|
209
|
+
export interface CodegenManifest {
|
|
210
210
|
contractVersion: typeof CODEGEN_CONTRACT_VERSION;
|
|
211
211
|
generatedAt: string;
|
|
212
212
|
files: Array<{
|
|
@@ -217,12 +217,12 @@ interface CodegenManifest {
|
|
|
217
217
|
generated: boolean;
|
|
218
218
|
}>;
|
|
219
219
|
}
|
|
220
|
-
interface CodegenOptions extends Omit<GenerateAutoImportsOptions, 'cwd' | 'srcDir' | 'buildDir'> {
|
|
220
|
+
export interface CodegenOptions extends Omit<GenerateAutoImportsOptions, 'cwd' | 'srcDir' | 'buildDir'> {
|
|
221
221
|
cwd: string;
|
|
222
222
|
srcDir: string;
|
|
223
223
|
buildDir: string;
|
|
224
224
|
}
|
|
225
|
-
interface CodegenResult {
|
|
225
|
+
export interface CodegenResult {
|
|
226
226
|
routeTypesPath: string;
|
|
227
227
|
pageTypesPath: string;
|
|
228
228
|
i18nTypesPath?: string | null;
|
|
@@ -230,6 +230,6 @@ interface CodegenResult {
|
|
|
230
230
|
componentsDtsPath?: string;
|
|
231
231
|
generated: string[];
|
|
232
232
|
}
|
|
233
|
-
declare function generateTypes(result: ScanResult, options: CodegenOptions): Promise<CodegenResult>;
|
|
233
|
+
export declare function generateTypes(result: ScanResult, options: CodegenOptions): Promise<CodegenResult>;
|
|
234
234
|
//#endregion
|
|
235
|
-
export {
|
|
235
|
+
export type { AutoImportResult, ComponentInfo, GenerateAutoImportsOptions, GenerateOpenApiTypesOptions, I18nTypesOptions, Import, InlinePreset, PageTypesOptions, ResolvedAutoImports, ResolvedComponentsAutoImport, RouteTypesOptions };
|
package/dist/codegen/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as getUbeanComponentsConfig, E as toArray, S as getUbeanAutoImportConfig, T as resolveComponentsConfig, _ as VUE_ROUTER_PRESET, a as generateOpenApiTypesFromServer, b as getAutoImportPresets, c as generateI18nTypes, d as HONO_OPENAPI_PRESET, f as UBEAN_CLIENT_PRESET, g as VUE_PRESET, h as VUE_MACROS_PRESET, i as generateOpenApiTypes, l as messagesToTsType, m as VUE_I18N_PRESET, n as CODEGEN_FILES, o as generatePageTypes, p as UBEAN_SERVER_PRESET, r as generateTypes, s as generateRouteTypes, t as CODEGEN_CONTRACT_VERSION, u as BUILTIN_PRESETS, v as generateAutoImports, w as resolveAutoImportsConfig, x as getBuiltinComposables, y as generateImportsTransform } from "../codegen-
|
|
1
|
+
import { C as getUbeanComponentsConfig, E as toArray, S as getUbeanAutoImportConfig, T as resolveComponentsConfig, _ as VUE_ROUTER_PRESET, a as generateOpenApiTypesFromServer, b as getAutoImportPresets, c as generateI18nTypes, d as HONO_OPENAPI_PRESET, f as UBEAN_CLIENT_PRESET, g as VUE_PRESET, h as VUE_MACROS_PRESET, i as generateOpenApiTypes, l as messagesToTsType, m as VUE_I18N_PRESET, n as CODEGEN_FILES, o as generatePageTypes, p as UBEAN_SERVER_PRESET, r as generateTypes, s as generateRouteTypes, t as CODEGEN_CONTRACT_VERSION, u as BUILTIN_PRESETS, v as generateAutoImports, w as resolveAutoImportsConfig, x as getBuiltinComposables, y as generateImportsTransform } from "../codegen-B3oGeRtK.js";
|
|
2
2
|
export { BUILTIN_PRESETS, CODEGEN_CONTRACT_VERSION, CODEGEN_FILES, HONO_OPENAPI_PRESET, UBEAN_CLIENT_PRESET, UBEAN_SERVER_PRESET, VUE_I18N_PRESET, VUE_MACROS_PRESET, VUE_PRESET, VUE_ROUTER_PRESET, generateAutoImports, generateI18nTypes, generateImportsTransform, generateOpenApiTypes, generateOpenApiTypesFromServer, generatePageTypes, generateRouteTypes, generateTypes, getAutoImportPresets, getBuiltinComposables, getUbeanAutoImportConfig, getUbeanComponentsConfig, messagesToTsType, resolveAutoImportsConfig, resolveComponentsConfig, toArray };
|
|
@@ -369,7 +369,8 @@ function generateComponentsDts(components, dtsPath) {
|
|
|
369
369
|
for (const name of [
|
|
370
370
|
"Link",
|
|
371
371
|
"Head",
|
|
372
|
-
"PageView"
|
|
372
|
+
"PageView",
|
|
373
|
+
"ClientOnly"
|
|
373
374
|
]) entries.set(name, `typeof import('ubean/client')['${name}']`);
|
|
374
375
|
for (const comp of components) {
|
|
375
376
|
const importPath = `./${toPosixPath(relative(dtsDir, toPosixPath(normalize(comp.filePath))))}`;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { a as defineVirtualModule, c as useVirtualRegistry, i as VirtualModuleTr
|
|
|
2
2
|
import { CompiledLayout, CompiledMiddleware, CompiledPage, CompiledRoute } from "@ubean/routes";
|
|
3
3
|
import { ScannedApiRoute, ScannedLocale, ScannedMiddleware, ScannedPageRoute } from "@ubean/scan";
|
|
4
4
|
//#region src/macros.d.ts
|
|
5
|
-
declare function stripMacros(code: string, macros?: readonly string[]): string;
|
|
6
|
-
declare function transformMacros(code: string, id: string): string | null;
|
|
5
|
+
export declare function stripMacros(code: string, macros?: readonly string[]): string;
|
|
6
|
+
export declare function transformMacros(code: string, id: string): string | null;
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/registry.d.ts
|
|
9
9
|
/**
|
|
@@ -32,28 +32,28 @@ type ComponentResolver = ((name: string) => any) | {
|
|
|
32
32
|
* Register a component resolver (e.g. `UiResolver()` from `@soybeanjs/ui/resolver`).
|
|
33
33
|
* The resolver will be merged into `unplugin-vue-components`'s `resolvers` array.
|
|
34
34
|
*/
|
|
35
|
-
declare function registerComponentResolver(resolver: ComponentResolver): void;
|
|
35
|
+
export declare function registerComponentResolver(resolver: ComponentResolver): void;
|
|
36
36
|
/**
|
|
37
37
|
* Get all registered component resolvers.
|
|
38
38
|
* Called by `ubeanVite` when constructing the `Components()` plugin.
|
|
39
39
|
*/
|
|
40
|
-
declare function getComponentResolvers(): ComponentResolver[];
|
|
40
|
+
export declare function getComponentResolvers(): ComponentResolver[];
|
|
41
41
|
/**
|
|
42
42
|
* Register a CSS import path to be injected into the client entry.
|
|
43
43
|
* e.g. `registerCssImport('@soybeanjs/ui/styles.css')` makes the client
|
|
44
44
|
* entry module prepend `import '@soybeanjs/ui/styles.css'`.
|
|
45
45
|
*/
|
|
46
|
-
declare function registerCssImport(cssPath: string): void;
|
|
46
|
+
export declare function registerCssImport(cssPath: string): void;
|
|
47
47
|
/**
|
|
48
48
|
* Get all registered CSS import paths.
|
|
49
49
|
* Called by `createClientEntryVirtualModule` to prepend CSS imports.
|
|
50
50
|
*/
|
|
51
|
-
declare function getCssImports(): string[];
|
|
51
|
+
export declare function getCssImports(): string[];
|
|
52
52
|
/**
|
|
53
53
|
* Reset the registry (for testing).
|
|
54
54
|
* @internal
|
|
55
55
|
*/
|
|
56
|
-
declare function resetModuleRegistry(): void;
|
|
56
|
+
export declare function resetModuleRegistry(): void;
|
|
57
57
|
//#endregion
|
|
58
58
|
//#region src/ssr-singleton.d.ts
|
|
59
59
|
/**
|
|
@@ -68,10 +68,10 @@ declare function resetModuleRegistry(): void;
|
|
|
68
68
|
* - Prod: `ubean` is bundled (`noExternal`). Do **not** also externalize
|
|
69
69
|
* `@ubean/i18n` — that would create a second copy beside the bundle.
|
|
70
70
|
*/
|
|
71
|
-
declare const SSR_SINGLETON_PACKAGES: readonly ["ubean", "@ubean/client", "@ubean/i18n", "vue-i18n", "@intlify/core", "@intlify/core-base"];
|
|
72
|
-
declare const SSR_SINGLETON_DEDUPE: readonly ["vue", "vue-i18n", "@ubean/client", "@ubean/i18n"];
|
|
73
|
-
declare const SSR_SINGLETON_OPTIMIZE_EXCLUDE: readonly ["ubean", "@ubean/client", "@ubean/i18n"];
|
|
74
|
-
declare function ssrSingletonDevPolicy(): {
|
|
71
|
+
export declare const SSR_SINGLETON_PACKAGES: readonly ["ubean", "@ubean/client", "@ubean/i18n", "vue-i18n", "@intlify/core", "@intlify/core-base"];
|
|
72
|
+
export declare const SSR_SINGLETON_DEDUPE: readonly ["vue", "vue-i18n", "@ubean/client", "@ubean/i18n"];
|
|
73
|
+
export declare const SSR_SINGLETON_OPTIMIZE_EXCLUDE: readonly ["ubean", "@ubean/client", "@ubean/i18n"];
|
|
74
|
+
export declare function ssrSingletonDevPolicy(): {
|
|
75
75
|
resolve: {
|
|
76
76
|
dedupe: string[];
|
|
77
77
|
};
|
|
@@ -84,16 +84,16 @@ declare function ssrSingletonDevPolicy(): {
|
|
|
84
84
|
external: string[];
|
|
85
85
|
};
|
|
86
86
|
};
|
|
87
|
-
declare function ssrSingletonProdSsr(): {
|
|
87
|
+
export declare function ssrSingletonProdSsr(): {
|
|
88
88
|
noExternal: string[];
|
|
89
89
|
};
|
|
90
|
-
declare function ssrSingletonProdOptimizeExclude(extra?: string[]): string[];
|
|
90
|
+
export declare function ssrSingletonProdOptimizeExclude(extra?: string[]): string[];
|
|
91
91
|
//#endregion
|
|
92
92
|
//#region src/virtual-modules.d.ts
|
|
93
|
-
declare function createRoutingVirtualModule(routes: CompiledRoute[], middlewares: CompiledMiddleware[], cwd: string): VirtualModule;
|
|
94
|
-
declare function createPagesVirtualModule(pages: CompiledPage[], layouts: CompiledLayout[], cwd: string): VirtualModule;
|
|
95
|
-
declare function createMetaVirtualModule(): VirtualModule;
|
|
96
|
-
declare function createAppVirtualModule(apiRoutes: ScannedApiRoute[], middlewares: ScannedMiddleware[], pages: ScannedPageRoute[], srcDir: string): VirtualModule;
|
|
97
|
-
declare function createLocalesVirtualModule(_locales: ScannedLocale[], defaultLocale: string | undefined, srcDir?: string, i18nConfigJson?: string): VirtualModule;
|
|
93
|
+
export declare function createRoutingVirtualModule(routes: CompiledRoute[], middlewares: CompiledMiddleware[], cwd: string): VirtualModule;
|
|
94
|
+
export declare function createPagesVirtualModule(pages: CompiledPage[], layouts: CompiledLayout[], cwd: string): VirtualModule;
|
|
95
|
+
export declare function createMetaVirtualModule(): VirtualModule;
|
|
96
|
+
export declare function createAppVirtualModule(apiRoutes: ScannedApiRoute[], middlewares: ScannedMiddleware[], pages: ScannedPageRoute[], srcDir: string): VirtualModule;
|
|
97
|
+
export declare function createLocalesVirtualModule(_locales: ScannedLocale[], defaultLocale: string | undefined, srcDir?: string, i18nConfigJson?: string): VirtualModule;
|
|
98
98
|
//#endregion
|
|
99
|
-
export {
|
|
99
|
+
export { type VirtualModule, type VirtualModuleContext, VirtualModuleRegistry, type VirtualModuleTransform, defineVirtualModule, defineVirtualModulePrefix, resetVirtualRegistry, useVirtualRegistry };
|
package/dist/prerender.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { PrerenderConfig, PrerenderResult, RouteRule } from "@ubean/config";
|
|
|
2
2
|
import { ScannedPageRoute } from "@ubean/scan";
|
|
3
3
|
import { RouteRule as RouteRule$1 } from "@ubean/shared";
|
|
4
4
|
//#region src/prerender.d.ts
|
|
5
|
-
interface PrerendererOptions {
|
|
5
|
+
export interface PrerendererOptions {
|
|
6
6
|
cwd: string;
|
|
7
7
|
outputDir: string;
|
|
8
8
|
pages: ScannedPageRoute[];
|
|
@@ -21,6 +21,18 @@ interface PrerendererOptions {
|
|
|
21
21
|
routeRules?: Record<string, RouteRule$1>;
|
|
22
22
|
/** Content collection URLs merged into `include` (see `extractContentPageRoutes`). */
|
|
23
23
|
contentRoutes?: string[];
|
|
24
|
+
/**
|
|
25
|
+
* 静态 SSG 模式:将 404 哨兵路由加入预渲染队列,产物为 `404.html`
|
|
26
|
+
* (供 GitHub Pages / Netlify 等静态托管平台的自定义 404 页)。
|
|
27
|
+
* fetcher 需识别 `STATIC_NOT_FOUND_ROUTE` 并渲染 notFoundPage。
|
|
28
|
+
*/
|
|
29
|
+
notFoundRoute?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* i18n 多语言展开钩子(docs/adr/0011-lightweight-ssg-direct-render.md):在 `collectPrerenderRoutes`
|
|
32
|
+
* 之后、入队之前应用,把收集到的路由扩展为全语言 URL 列表
|
|
33
|
+
* (如 `/about` → `['/about', '/zh/about']`)。
|
|
34
|
+
*/
|
|
35
|
+
expandRoutes?: (routes: string[]) => string[];
|
|
24
36
|
fetcher?: (url: string) => Promise<{
|
|
25
37
|
html: string;
|
|
26
38
|
statusCode: number;
|
|
@@ -36,7 +48,7 @@ interface PrerendererOptions {
|
|
|
36
48
|
* 返回的路径列表会进一步与 `pages` 候选池匹配(glob 模式)或直接加入(具体路径)。
|
|
37
49
|
* 动态路由的具象值(如 `/blog/hello-world`)可通过具体路径直接加入。
|
|
38
50
|
*/
|
|
39
|
-
declare function extractPrerenderRoutesFromRules(routeRules: Record<string, RouteRule$1> | undefined): string[];
|
|
51
|
+
export declare function extractPrerenderRoutesFromRules(routeRules: Record<string, RouteRule$1> | undefined): string[];
|
|
40
52
|
/**
|
|
41
53
|
* 收集需要预渲染的路由列表。
|
|
42
54
|
*
|
|
@@ -50,7 +62,7 @@ declare function extractPrerenderRoutesFromRules(routeRules: Record<string, Rout
|
|
|
50
62
|
*
|
|
51
63
|
* 返回的 `skipped` 为被 `exclude` 命中的路由集合。
|
|
52
64
|
*/
|
|
53
|
-
declare function collectPrerenderRoutes(pages: ScannedPageRoute[], options?: {
|
|
65
|
+
export declare function collectPrerenderRoutes(pages: ScannedPageRoute[], options?: {
|
|
54
66
|
all?: boolean;
|
|
55
67
|
include?: string[];
|
|
56
68
|
exclude?: string[];
|
|
@@ -62,7 +74,7 @@ declare function collectPrerenderRoutes(pages: ScannedPageRoute[], options?: {
|
|
|
62
74
|
routes: string[];
|
|
63
75
|
skipped: string[];
|
|
64
76
|
};
|
|
65
|
-
declare function extractLinks(html: string, baseUrl?: string): string[];
|
|
77
|
+
export declare function extractLinks(html: string, baseUrl?: string): string[];
|
|
66
78
|
/**
|
|
67
79
|
* 将路由路径映射到磁盘文件路径。
|
|
68
80
|
*
|
|
@@ -75,7 +87,7 @@ declare function extractLinks(html: string, baseUrl?: string): string[];
|
|
|
75
87
|
* 处理带扩展名路由是为了避免 `/robots.txt/index.html`、`/sitemap.xml/index.html`
|
|
76
88
|
* 这种被错误转成目录的产物。
|
|
77
89
|
*/
|
|
78
|
-
declare function routeToFilePath(route: string, outputDir: string): string;
|
|
90
|
+
export declare function routeToFilePath(route: string, outputDir: string): string;
|
|
79
91
|
/**
|
|
80
92
|
* 将路由路径映射到对应的 `__data.json` 文件路径。
|
|
81
93
|
*
|
|
@@ -87,11 +99,11 @@ declare function routeToFilePath(route: string, outputDir: string): string;
|
|
|
87
99
|
* 与 HTML 不同,这里不需要处理扩展名路由(`.html`/`.txt` 等)—— payload
|
|
88
100
|
* 仅对页面路由有意义,扩展名路由(如 `/robots.txt`)不参与 payload 提取。
|
|
89
101
|
*/
|
|
90
|
-
declare function routeToDataFilePath(route: string, outputDir: string): string;
|
|
102
|
+
export declare function routeToDataFilePath(route: string, outputDir: string): string;
|
|
91
103
|
/**
|
|
92
104
|
* `extractDataPayload` 的返回结构。
|
|
93
105
|
*/
|
|
94
|
-
interface ExtractedPayload {
|
|
106
|
+
export interface ExtractedPayload {
|
|
95
107
|
/** 从 `__UBEAN_DATA__` 解析出的 payload 数据。 */
|
|
96
108
|
data: Record<string, unknown>;
|
|
97
109
|
/** 替换内联 script 后的 HTML(包含 preload link + 引导脚本)。 */
|
|
@@ -114,10 +126,10 @@ interface ExtractedPayload {
|
|
|
114
126
|
* @param html 预渲染后的完整 HTML
|
|
115
127
|
* @param route 当前路由路径(用于计算 dataUrl)
|
|
116
128
|
*/
|
|
117
|
-
declare function extractDataPayload(html: string, route: string): ExtractedPayload | null;
|
|
118
|
-
declare function writePrerenderedFile(filePath: string, html: string): Promise<void>;
|
|
119
|
-
declare function prerender(options: PrerendererOptions): Promise<PrerenderResult>;
|
|
120
|
-
declare function generatePrerenderManifest(result: PrerenderResult, baseUrl?: string): {
|
|
129
|
+
export declare function extractDataPayload(html: string, route: string): ExtractedPayload | null;
|
|
130
|
+
export declare function writePrerenderedFile(filePath: string, html: string): Promise<void>;
|
|
131
|
+
export declare function prerender(options: PrerendererOptions): Promise<PrerenderResult>;
|
|
132
|
+
export declare function generatePrerenderManifest(result: PrerenderResult, baseUrl?: string): {
|
|
121
133
|
routes: string[];
|
|
122
134
|
generatedAt: string;
|
|
123
135
|
errors: Array<{
|
|
@@ -126,4 +138,4 @@ declare function generatePrerenderManifest(result: PrerenderResult, baseUrl?: st
|
|
|
126
138
|
}>;
|
|
127
139
|
};
|
|
128
140
|
//#endregion
|
|
129
|
-
export {
|
|
141
|
+
export type { RouteRule };
|
package/dist/prerender.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { STATIC_NOT_FOUND_ROUTE } from "./static-render.js";
|
|
1
2
|
import { dirname, join } from "pathe";
|
|
2
3
|
import { resolvePrerenderConfig } from "@ubean/config";
|
|
3
4
|
import { DATA_PAYLOAD_ID } from "@ubean/pages";
|
|
@@ -127,6 +128,7 @@ function normalizeHref(href, baseUrl) {
|
|
|
127
128
|
*/
|
|
128
129
|
function routeToFilePath(route, outputDir) {
|
|
129
130
|
if (route === "/" || route === "") return join(outputDir, "index.html");
|
|
131
|
+
if (route === "/__ubean_404__") return join(outputDir, "404.html");
|
|
130
132
|
if (route.endsWith(".html")) return join(outputDir, route);
|
|
131
133
|
const lastSegment = route.slice(route.lastIndexOf("/") + 1);
|
|
132
134
|
const dotIdx = lastSegment.lastIndexOf(".");
|
|
@@ -213,7 +215,8 @@ async function prerender(options) {
|
|
|
213
215
|
routeRules: options.routeRules,
|
|
214
216
|
contentRoutes: options.contentRoutes
|
|
215
217
|
});
|
|
216
|
-
const queue = [...initialRoutes];
|
|
218
|
+
const queue = [...options.expandRoutes ? options.expandRoutes(initialRoutes) : initialRoutes];
|
|
219
|
+
if (options.notFoundRoute) queue.unshift(STATIC_NOT_FOUND_ROUTE);
|
|
217
220
|
const visited = /* @__PURE__ */ new Set();
|
|
218
221
|
const results = [];
|
|
219
222
|
const generated = [];
|
|
@@ -223,11 +226,12 @@ async function prerender(options) {
|
|
|
223
226
|
async function processRoute(route) {
|
|
224
227
|
if (visited.has(route)) return;
|
|
225
228
|
visited.add(route);
|
|
226
|
-
if (config.exclude.some((p) => matchGlob(route, p))) {
|
|
229
|
+
if (route !== "/__ubean_404__" && config.exclude.some((p) => matchGlob(route, p))) {
|
|
227
230
|
if (!skipped.includes(route)) skipped.push(route);
|
|
228
231
|
return;
|
|
229
232
|
}
|
|
230
|
-
const
|
|
233
|
+
const displayRoute = route === "/__ubean_404__" ? "/404" : route;
|
|
234
|
+
const result = { route: displayRoute };
|
|
231
235
|
try {
|
|
232
236
|
if (options.fetcher) {
|
|
233
237
|
const resp = await options.fetcher(route);
|
|
@@ -253,7 +257,7 @@ async function prerender(options) {
|
|
|
253
257
|
}
|
|
254
258
|
}
|
|
255
259
|
await writePrerenderedFile(routeToFilePath(route, outputDir), htmlToWrite);
|
|
256
|
-
generated.push(
|
|
260
|
+
generated.push(displayRoute);
|
|
257
261
|
result.html = void 0;
|
|
258
262
|
} else {
|
|
259
263
|
const placeholderHtml = `<!DOCTYPE html>
|
|
@@ -264,7 +268,7 @@ async function prerender(options) {
|
|
|
264
268
|
</body>
|
|
265
269
|
</html>`;
|
|
266
270
|
await writePrerenderedFile(routeToFilePath(route, outputDir), placeholderHtml);
|
|
267
|
-
generated.push(
|
|
271
|
+
generated.push(displayRoute);
|
|
268
272
|
result.statusCode = 200;
|
|
269
273
|
}
|
|
270
274
|
} catch (err) {
|
package/dist/production.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ResolvedConfig } from "@ubean/config";
|
|
|
2
2
|
import { ScanResult } from "@ubean/scan";
|
|
3
3
|
import { Preset } from "@ubean/preset";
|
|
4
4
|
//#region src/production.d.ts
|
|
5
|
-
interface BuildOptions {
|
|
5
|
+
export interface BuildOptions {
|
|
6
6
|
cwd: string;
|
|
7
7
|
config: ResolvedConfig;
|
|
8
8
|
preset: Preset;
|
|
@@ -12,7 +12,7 @@ interface BuildOptions {
|
|
|
12
12
|
/** Inlined content collections for production SSR (`queryCollection`). */
|
|
13
13
|
contentSnapshot?: Record<string, unknown[]>;
|
|
14
14
|
}
|
|
15
|
-
interface BuildManifest {
|
|
15
|
+
export interface BuildManifest {
|
|
16
16
|
assets: Array<{
|
|
17
17
|
file: string;
|
|
18
18
|
src?: string;
|
|
@@ -24,6 +24,5 @@ interface BuildManifest {
|
|
|
24
24
|
serverDir: string;
|
|
25
25
|
preset: string;
|
|
26
26
|
}
|
|
27
|
-
declare function buildProduction(options: BuildOptions): Promise<BuildManifest>;
|
|
28
|
-
//#endregion
|
|
29
|
-
export { BuildManifest, BuildOptions, buildProduction };
|
|
27
|
+
export declare function buildProduction(options: BuildOptions): Promise<BuildManifest>;
|
|
28
|
+
//#endregion
|