@monkeyplus/flow 6.0.53 → 6.0.55
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
CHANGED
package/server/lib/pages.mjs
CHANGED
|
@@ -4,6 +4,36 @@ import pageDefinitions from "virtual:flow/pages";
|
|
|
4
4
|
import { getFlowImageRuntimeUtils } from "../../modules/images/runtime/server.mjs";
|
|
5
5
|
import { mergeLayoutContextValues } from "../../src/runtime/layout-context.mjs";
|
|
6
6
|
import { localizeRoutePattern, normalizePath, toPublicRoute } from "../../src/runtime/locale-routing.mjs";
|
|
7
|
+
function mergeHeadDefinitions(...heads) {
|
|
8
|
+
const result = {};
|
|
9
|
+
for (const head of heads) {
|
|
10
|
+
if (!head)
|
|
11
|
+
continue;
|
|
12
|
+
for (const [key, value] of Object.entries(head)) {
|
|
13
|
+
if (["meta", "link", "script", "style", "noscript"].includes(key)) {
|
|
14
|
+
result[key] = [...result[key] || [], ...Array.isArray(value) ? value : []];
|
|
15
|
+
} else if (["htmlAttrs", "bodyAttrs"].includes(key)) {
|
|
16
|
+
result[key] = { ...result[key], ...value };
|
|
17
|
+
} else if (key === "templateParams") {
|
|
18
|
+
result.templateParams = result.templateParams || {};
|
|
19
|
+
for (const [tpKey, tpValue] of Object.entries(value || {})) {
|
|
20
|
+
if (typeof tpValue === "object" && tpValue !== null && !Array.isArray(tpValue)) {
|
|
21
|
+
result.templateParams[tpKey] = {
|
|
22
|
+
...result.templateParams[tpKey] || {},
|
|
23
|
+
...tpValue
|
|
24
|
+
};
|
|
25
|
+
} else {
|
|
26
|
+
result.templateParams[tpKey] = tpValue;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
} else {
|
|
30
|
+
result[key] = value;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
console.log("mergeHeadDefinitions", result);
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
7
37
|
const dynamicRouteCache = /* @__PURE__ */ new Map();
|
|
8
38
|
let runtimeConfigRequire;
|
|
9
39
|
function getFlowRuntimeConfig() {
|
|
@@ -101,7 +131,12 @@ async function resolveLayoutContext(definition, ctx) {
|
|
|
101
131
|
const layoutContext = layoutKey === "global" ? void 0 : layoutContexts[layoutKey];
|
|
102
132
|
const resolvedGlobalContext = globalLayoutContext?.setup ? asContextRecord(await globalLayoutContext.setup(ctx)) : void 0;
|
|
103
133
|
const resolvedLayoutContext = layoutContext?.setup ? asContextRecord(await layoutContext.setup(ctx)) : void 0;
|
|
104
|
-
|
|
134
|
+
const resolvedGlobalHead = globalLayoutContext?.head ? await globalLayoutContext.head(ctx) : void 0;
|
|
135
|
+
const resolvedLayoutHead = layoutContext?.head ? await layoutContext.head(ctx) : void 0;
|
|
136
|
+
return {
|
|
137
|
+
context: mergeLayoutContextValues(resolvedGlobalContext, resolvedLayoutContext),
|
|
138
|
+
head: { global: resolvedGlobalHead, layout: resolvedLayoutHead }
|
|
139
|
+
};
|
|
105
140
|
}
|
|
106
141
|
function mergeResolvedContext(context, layoutContext, dynamic, assign) {
|
|
107
142
|
const resolvedContext = assign && dynamic?.context ? { ...context, [assign]: dynamic.context, dynamic } : dynamic ? { ...context, dynamic } : context;
|
|
@@ -277,11 +312,12 @@ export async function resolvePage(pathname, request) {
|
|
|
277
312
|
continue;
|
|
278
313
|
}
|
|
279
314
|
const ctx = createContext(match.definition, locale, match.localePage, pathname, match.params, dynamic, request);
|
|
280
|
-
const
|
|
315
|
+
const pageHead = match.localePage.head ? await match.localePage.head(ctx) : match.localePage.seo ? await match.localePage.seo(ctx) : {};
|
|
281
316
|
const layoutContext = await resolveLayoutContext(match.definition, ctx);
|
|
282
317
|
const context = match.localePage.context ? await match.localePage.context(ctx) : {};
|
|
283
318
|
const assign = match.localePage.dynamic?.assign;
|
|
284
|
-
const resolvedContext = mergeResolvedContext(context, layoutContext, dynamic, assign);
|
|
319
|
+
const resolvedContext = mergeResolvedContext(context, layoutContext.context, dynamic, assign);
|
|
320
|
+
const head = mergeHeadDefinitions(layoutContext.head.global, layoutContext.head.layout, pageHead);
|
|
285
321
|
return {
|
|
286
322
|
definition: match.definition,
|
|
287
323
|
locale,
|
|
@@ -311,9 +347,10 @@ export async function resolvePageByName(name, pathname, request) {
|
|
|
311
347
|
const locale = createLocale(localeCode);
|
|
312
348
|
const params = {};
|
|
313
349
|
const ctx = createContext(definition, locale, localePage, pathname, params, void 0, request);
|
|
314
|
-
const
|
|
350
|
+
const pageHead = localePage.head ? await localePage.head(ctx) : localePage.seo ? await localePage.seo(ctx) : {};
|
|
315
351
|
const layoutContext = await resolveLayoutContext(definition, ctx);
|
|
316
352
|
const context = localePage.context ? await localePage.context(ctx) : {};
|
|
353
|
+
const head = mergeHeadDefinitions(layoutContext.head.global, layoutContext.head.layout, pageHead);
|
|
317
354
|
return {
|
|
318
355
|
definition,
|
|
319
356
|
locale,
|
|
@@ -323,7 +360,7 @@ export async function resolvePageByName(name, pathname, request) {
|
|
|
323
360
|
params,
|
|
324
361
|
head,
|
|
325
362
|
seo: head,
|
|
326
|
-
context: mergeResolvedContext(context, layoutContext)
|
|
363
|
+
context: mergeResolvedContext(context, layoutContext.context)
|
|
327
364
|
};
|
|
328
365
|
}
|
|
329
366
|
return void 0;
|
package/server/lib/render.mjs
CHANGED
|
@@ -135,7 +135,7 @@ async function renderBody(page) {
|
|
|
135
135
|
const app = createSSRApp(TemplateRoot);
|
|
136
136
|
app.config.warnHandler = (msg, instance, trace) => {
|
|
137
137
|
const cleanTrace = trace.split("\n").map((line) => {
|
|
138
|
-
return line.length > 200 ? line.substring(0, 200)
|
|
138
|
+
return line.length > 200 ? `${line.substring(0, 200)} ... >` : line;
|
|
139
139
|
}).join("\n");
|
|
140
140
|
console.warn(`[Vue warn]: ${msg}
|
|
141
141
|
${cleanTrace}`);
|
|
@@ -150,6 +150,7 @@ ${cleanTrace}`);
|
|
|
150
150
|
}
|
|
151
151
|
});
|
|
152
152
|
head.push(normalizeSeoToHead(page.head, fallbackTitle, fallbackDescription));
|
|
153
|
+
console.log("head", head);
|
|
153
154
|
app.use(head);
|
|
154
155
|
installFlowVuePlugins(app);
|
|
155
156
|
return {
|
package/src/public/vite.mjs
CHANGED
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
import { createFlowNitroConfig } from "./nitro.mjs";
|
|
25
25
|
let schemaOrgImports = {};
|
|
26
26
|
try {
|
|
27
|
-
const pkg = await import("@unhead/schema-org
|
|
27
|
+
const pkg = await import("@unhead/schema-org/vue");
|
|
28
28
|
schemaOrgImports = pkg.schemaOrgAutoImports || {};
|
|
29
29
|
console.log("--- SCHEMA ORG IMPORTS LOADED ---", typeof schemaOrgImports, Array.isArray(schemaOrgImports));
|
|
30
30
|
} catch (e) {
|
package/src/runtime/head.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useSchemaOrg } from '@unhead/schema-org
|
|
1
|
+
import { useSchemaOrg } from '@unhead/schema-org/vue';
|
|
2
2
|
import { useHead, useSeoMeta } from '@unhead/vue';
|
|
3
3
|
export declare function getClientHead(): import("@unhead/vue").VueHeadClient<import("@unhead/vue").UseHeadInput<_Deprecated>, boolean>;
|
|
4
4
|
export { useHead, useSchemaOrg, useSeoMeta };
|
package/src/runtime/head.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UnheadSchemaOrg } from "@unhead/schema-org";
|
|
2
|
-
import { useSchemaOrg } from "@unhead/schema-org
|
|
2
|
+
import { useSchemaOrg } from "@unhead/schema-org/vue";
|
|
3
3
|
import { useHead, useSeoMeta } from "@unhead/vue";
|
|
4
4
|
import { createHead } from "@unhead/vue/client";
|
|
5
5
|
const clientHead = createHead();
|
package/src/runtime/islands.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import islands from "virtual:flow/islands";
|
|
2
|
-
import { createSSRApp,
|
|
2
|
+
import { createSSRApp, defineComponent, h } from "vue";
|
|
3
3
|
import { createBootImageUtils } from "./components/image-shared.mjs";
|
|
4
4
|
import { getClientHead } from "./head.mjs";
|
|
5
5
|
import { installFlowVuePlugins } from "./vue.mjs";
|
|
@@ -47,7 +47,7 @@ async function hydrateIsland(element, boot) {
|
|
|
47
47
|
const slotEl = element.querySelector(`div[data-flow-slot-template="${name}"]`);
|
|
48
48
|
if (slotEl) {
|
|
49
49
|
const html = slotEl.innerHTML;
|
|
50
|
-
clientSlots[name] = () => h("div", { "data-flow-slot": name, style: "display: contents;", innerHTML: html });
|
|
50
|
+
clientSlots[name] = () => h("div", { "data-flow-slot": name, "style": "display: contents;", "innerHTML": html });
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { MaybePromise, PageContextInput } from './pages.ts';
|
|
1
|
+
import type { HeadDefinition, MaybePromise, PageContextInput } from './pages.ts';
|
|
2
2
|
export interface LayoutContextDefinition {
|
|
3
|
-
setup
|
|
3
|
+
setup?: (ctx: PageContextInput) => MaybePromise<Record<string, unknown>>;
|
|
4
|
+
head?: (ctx: PageContextInput) => MaybePromise<HeadDefinition>;
|
|
4
5
|
}
|
|
5
|
-
export type LayoutContextValue<T extends LayoutContextDefinition> = Awaited<ReturnType<T['setup']
|
|
6
|
+
export type LayoutContextValue<T extends LayoutContextDefinition> = T['setup'] extends (...args: any) => any ? Awaited<ReturnType<T['setup']>> : Record<string, unknown>;
|
|
6
7
|
export declare function defineLayoutContext(context: LayoutContextDefinition): LayoutContextDefinition;
|
|
7
8
|
export declare function mergeLayoutContextValues(...contexts: Array<Record<string, unknown> | undefined>): Record<string, unknown>;
|