@monkeyplus/flow 6.0.61 → 6.0.63
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/package.json +1 -1
- package/server/lib/pages.d.ts +1 -1
- package/server/lib/pages.mjs +23 -6
- package/server/test-nitro.d.ts +1 -0
- package/server/test-nitro.mjs +14 -0
- package/src/public/nitro.mjs +8 -0
- package/src/public/vite.mjs +3 -1
- package/src/runtime/pages.d.ts +6 -1
- package/src/runtime/virtual-pages.d.ts +1 -0
- package/src/runtime/virtual-pages.mjs +7 -0
package/package.json
CHANGED
package/server/lib/pages.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DynamicRouteEntry, FlowLocale, GetUrlOptions, HeadDefinition, PageDefinition, PageLocaleDefinition, PageUrlInfo
|
|
1
|
+
import type { BreadcrumbItem, DynamicRouteEntry, FlowLocale, GetUrlOptions, HeadDefinition, PageDefinition, PageLocaleDefinition, PageUrlInfo } from '../../src/runtime/pages';
|
|
2
2
|
export interface ResolvedPage {
|
|
3
3
|
definition: PageDefinition;
|
|
4
4
|
locale: FlowLocale;
|
package/server/lib/pages.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
+
import flowVirtualConfig from "virtual:flow/config";
|
|
2
3
|
import layoutContexts from "virtual:flow/layout-contexts";
|
|
3
4
|
import pageDefinitions from "virtual:flow/pages";
|
|
4
5
|
import { getFlowImageRuntimeUtils } from "../../modules/images/runtime/server.mjs";
|
|
@@ -39,9 +40,21 @@ function getFlowRuntimeConfig() {
|
|
|
39
40
|
try {
|
|
40
41
|
runtimeConfigRequire ??= createRequire(import.meta.url);
|
|
41
42
|
const runtime = runtimeConfigRequire("nitro/runtime-config");
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
let config = {};
|
|
44
|
+
if (typeof runtime.useRuntimeConfig === "function") {
|
|
45
|
+
config = runtime.useRuntimeConfig() || {};
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
...config,
|
|
49
|
+
flow: {
|
|
50
|
+
...flowVirtualConfig,
|
|
51
|
+
...config.public?.flow || {},
|
|
52
|
+
...config.flow || {}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
} catch (e) {
|
|
56
|
+
console.error("--- getFlowRuntimeConfig crashed:", e);
|
|
57
|
+
return { flow: flowVirtualConfig };
|
|
45
58
|
}
|
|
46
59
|
}
|
|
47
60
|
function scorePattern(pattern) {
|
|
@@ -106,6 +119,7 @@ function createContext(definition, locale, localePage, pathname, params, dynamic
|
|
|
106
119
|
locale,
|
|
107
120
|
path: pathname,
|
|
108
121
|
fullPath,
|
|
122
|
+
siteUrl,
|
|
109
123
|
name: definition.name,
|
|
110
124
|
page: localePage,
|
|
111
125
|
params,
|
|
@@ -378,9 +392,11 @@ export async function resolveBreadcrumbs(pageName, pathname, localeCode, params,
|
|
|
378
392
|
}
|
|
379
393
|
visited.add(pageName);
|
|
380
394
|
const definition = pageDefinitions.find((candidate) => candidate.name === pageName);
|
|
381
|
-
if (!definition)
|
|
395
|
+
if (!definition)
|
|
396
|
+
return [];
|
|
382
397
|
const localePage = definition.locales[localeCode];
|
|
383
|
-
if (!localePage || !localePage.breadcrumb)
|
|
398
|
+
if (!localePage || !localePage.breadcrumb)
|
|
399
|
+
return [];
|
|
384
400
|
const locale = createLocale(localeCode);
|
|
385
401
|
const ctx = createContext(definition, locale, localePage, pathname, params, dynamic, request);
|
|
386
402
|
const pageContext = localePage.context ? await localePage.context(ctx) : {};
|
|
@@ -392,7 +408,8 @@ export async function resolveBreadcrumbs(pageName, pathname, localeCode, params,
|
|
|
392
408
|
seo: pageHead.seo || pageHead
|
|
393
409
|
};
|
|
394
410
|
const result = await localePage.breadcrumb(breadcrumbCtx);
|
|
395
|
-
if (!result)
|
|
411
|
+
if (!result)
|
|
412
|
+
return [];
|
|
396
413
|
let currentItems = [];
|
|
397
414
|
if (result.items) {
|
|
398
415
|
currentItems = result.items;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
const req = createRequire(import.meta.url);
|
|
3
|
+
try {
|
|
4
|
+
const nitro = req('#internal/nitro');
|
|
5
|
+
console.log('nitro', nitro);
|
|
6
|
+
} catch (e) {
|
|
7
|
+
console.log('error #internal/nitro', e.message);
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
const nitro2 = req('nitro/runtime-config');
|
|
11
|
+
console.log('nitro2', nitro2);
|
|
12
|
+
} catch (e) {
|
|
13
|
+
console.log('error nitro/runtime-config', e.message);
|
|
14
|
+
}
|
package/src/public/nitro.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { loadFlowModules } from "../runtime/modules.mjs";
|
|
|
5
5
|
import { createFlowBuildHooks } from "../runtime/ssg.mjs";
|
|
6
6
|
import {
|
|
7
7
|
createVirtualBaseTemplatesModule,
|
|
8
|
+
createVirtualConfigModule,
|
|
8
9
|
createVirtualIslandsModule,
|
|
9
10
|
createVirtualLayoutContextsModule,
|
|
10
11
|
createVirtualLayoutsModule,
|
|
@@ -54,6 +55,7 @@ export function createFlowNitroConfig(options = {}) {
|
|
|
54
55
|
"virtual:flow/layouts": createVirtualLayoutsModule(projectRoot),
|
|
55
56
|
"virtual:flow/layout-contexts": createVirtualLayoutContextsModule(projectRoot),
|
|
56
57
|
"virtual:flow/bases": createVirtualBaseTemplatesModule(projectRoot),
|
|
58
|
+
"virtual:flow/config": createVirtualConfigModule(flowConfig),
|
|
57
59
|
...flowModules.nitro.virtual
|
|
58
60
|
},
|
|
59
61
|
hooks: createFlowBuildHooks({
|
|
@@ -88,6 +90,12 @@ export function createFlowNitroConfig(options = {}) {
|
|
|
88
90
|
name: "Flow Next",
|
|
89
91
|
version: "0.1.0"
|
|
90
92
|
},
|
|
93
|
+
public: {
|
|
94
|
+
flow: {
|
|
95
|
+
siteUrl: flowConfig.siteUrl,
|
|
96
|
+
locale: flowConfig.locale
|
|
97
|
+
}
|
|
98
|
+
},
|
|
91
99
|
flow: {
|
|
92
100
|
build: flowConfig.build,
|
|
93
101
|
dir: flowConfig.dir,
|
package/src/public/vite.mjs
CHANGED
|
@@ -12,6 +12,7 @@ import { loadFlowModules } from "../runtime/modules.mjs";
|
|
|
12
12
|
import { getPrerenderRoutes } from "../runtime/page-discovery.mjs";
|
|
13
13
|
import {
|
|
14
14
|
createVirtualBaseTemplatesModule,
|
|
15
|
+
createVirtualConfigModule,
|
|
15
16
|
createVirtualClientPageAssetsModule,
|
|
16
17
|
createVirtualClientPagesModule,
|
|
17
18
|
createVirtualIslandsModule,
|
|
@@ -212,7 +213,8 @@ function createFlowVirtualServerModules(projectRoot, flowConfig) {
|
|
|
212
213
|
["virtual:flow/layouts", () => createVirtualLayoutsModule(projectRoot)],
|
|
213
214
|
["virtual:flow/layout-contexts", () => createVirtualLayoutContextsModule(projectRoot)],
|
|
214
215
|
["virtual:flow/bases", () => createVirtualBaseTemplatesModule(projectRoot)],
|
|
215
|
-
["virtual:flow/server-styles", () => createVirtualServerStylesModule(projectRoot)]
|
|
216
|
+
["virtual:flow/server-styles", () => createVirtualServerStylesModule(projectRoot)],
|
|
217
|
+
["virtual:flow/config", () => createVirtualConfigModule(flowConfig)]
|
|
216
218
|
]);
|
|
217
219
|
return {
|
|
218
220
|
name: "flow:server-virtuals",
|
package/src/runtime/pages.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { WebPage } from '@unhead/schema-org';
|
|
1
2
|
import type { UseHeadInput, UseSeoMetaInput } from '@unhead/vue';
|
|
2
3
|
export type MaybePromise<T> = T | Promise<T>;
|
|
3
4
|
export interface FlowLocale {
|
|
@@ -37,7 +38,10 @@ export interface LegacySeoDefinition {
|
|
|
37
38
|
facebook?: boolean;
|
|
38
39
|
}
|
|
39
40
|
export type HeadDefinition = UseHeadInput & LegacySeoDefinition & {
|
|
40
|
-
seo: UseSeoMetaInput
|
|
41
|
+
seo: UseSeoMetaInput & {
|
|
42
|
+
webType: WebPage['@type'];
|
|
43
|
+
custom?: any;
|
|
44
|
+
};
|
|
41
45
|
};
|
|
42
46
|
/**
|
|
43
47
|
* @deprecated Use HeadDefinition.
|
|
@@ -101,6 +105,7 @@ export interface PageContextInput {
|
|
|
101
105
|
path: string;
|
|
102
106
|
fullPath?: string;
|
|
103
107
|
name: string;
|
|
108
|
+
siteUrl: string;
|
|
104
109
|
view: PageViewDefinition;
|
|
105
110
|
page: PageLocaleDefinition;
|
|
106
111
|
params: Record<string, string>;
|
|
@@ -8,3 +8,4 @@ export declare function createVirtualIslandsModule(projectRoot: string): string;
|
|
|
8
8
|
export declare function createVirtualClientPagesModule(projectRoot: string): string;
|
|
9
9
|
export declare function createVirtualClientPageAssetsModule(projectRoot: string): string;
|
|
10
10
|
export declare function createVirtualServerStylesModule(projectRoot: string): string;
|
|
11
|
+
export declare function createVirtualConfigModule(flowConfig: import('./config').FlowConfig): string;
|
|
@@ -188,3 +188,10 @@ export function createVirtualServerStylesModule(projectRoot) {
|
|
|
188
188
|
""
|
|
189
189
|
].join("\n");
|
|
190
190
|
}
|
|
191
|
+
export function createVirtualConfigModule(flowConfig) {
|
|
192
|
+
return [
|
|
193
|
+
`export const siteUrl = ${JSON.stringify(flowConfig.siteUrl)};`,
|
|
194
|
+
`export const locale = ${JSON.stringify(flowConfig.locale)};`,
|
|
195
|
+
`export default { siteUrl, locale };`
|
|
196
|
+
].join("\n");
|
|
197
|
+
}
|