@monkeyplus/flow 5.0.0-rc.37 → 5.0.0-rc.39
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/app/flow.d.ts
CHANGED
|
@@ -11,6 +11,10 @@ export interface FlowAppHooks {
|
|
|
11
11
|
bodyStart: string[];
|
|
12
12
|
}) => HookResult;
|
|
13
13
|
'page:links': (links: string[]) => HookResult;
|
|
14
|
+
'page:context': (ctx: {
|
|
15
|
+
page: string;
|
|
16
|
+
localeCode: string;
|
|
17
|
+
}, utils: any, data: Record<string, any>) => HookResult;
|
|
14
18
|
'page:chunks': (bundle: string, scripts: {
|
|
15
19
|
head: string[];
|
|
16
20
|
body: string[];
|
|
@@ -9,7 +9,7 @@ export default eventHandler(async (event) => {
|
|
|
9
9
|
const scripts = { head: [], bodyStart: [], bodyEnd: [] };
|
|
10
10
|
const chunks = { head: [], body: [] };
|
|
11
11
|
const generate = {};
|
|
12
|
-
const { page, locale, params, view } = flow.router.byUrl.lookup(url) || {};
|
|
12
|
+
const { page, locale, params, view, name: pageName } = flow.router.byUrl.lookup(url) || {};
|
|
13
13
|
if (!page)
|
|
14
14
|
return;
|
|
15
15
|
await flow.callHook("page:scripts", scripts);
|
|
@@ -23,6 +23,8 @@ export default eventHandler(async (event) => {
|
|
|
23
23
|
};
|
|
24
24
|
const contextInject = {};
|
|
25
25
|
const utils = Object.assign({ getLocale: () => locale, injectContext: (key, value) => contextInject[key] = value, defineCachedFunction: event.context.defineCachedFunction }, flow.app.utils);
|
|
26
|
+
const contextHooks = {};
|
|
27
|
+
await flow.callHook("page:context", { localeCode: locale.code, page: pageName }, utils, contextHooks);
|
|
26
28
|
templateContext.url = url;
|
|
27
29
|
templateContext.locale = locale;
|
|
28
30
|
templateContext.view = view;
|
|
@@ -36,12 +38,15 @@ export default eventHandler(async (event) => {
|
|
|
36
38
|
contextPage.dynamic = dynamicPage;
|
|
37
39
|
}
|
|
38
40
|
templateContext.seo = {};
|
|
39
|
-
templateContext.context = {};
|
|
40
41
|
const sharedContext = await utils.getSharedContext(utils);
|
|
41
42
|
templateContext.sharedContext = sharedContext || {};
|
|
42
43
|
templateContext.utils = utils;
|
|
43
|
-
templateContext.seo = await page.seo?.({ ...contextPage, utils, sharedContext }) || {};
|
|
44
|
-
|
|
44
|
+
templateContext.seo = await page.seo?.({ ...contextHooks, ...contextPage, utils, sharedContext }) || {};
|
|
45
|
+
const contexData = await page.context?.({ ...contextHooks, ...contextPage, utils, sharedContext }) || {};
|
|
46
|
+
templateContext.context = {
|
|
47
|
+
...contextHooks,
|
|
48
|
+
...contexData
|
|
49
|
+
};
|
|
45
50
|
templateContext.getHeadScripts = () => {
|
|
46
51
|
return scripts.head.join("\n");
|
|
47
52
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -29,7 +29,7 @@ import { isExternal as isExternal$1, ExternalsDefaults } from 'externality';
|
|
|
29
29
|
import { createHash } from 'node:crypto';
|
|
30
30
|
import MagicString from 'magic-string';
|
|
31
31
|
|
|
32
|
-
const version = "5.0.0-rc.
|
|
32
|
+
const version = "5.0.0-rc.39";
|
|
33
33
|
|
|
34
34
|
let _distDir = dirname(fileURLToPath(import.meta.url));
|
|
35
35
|
if (_distDir.endsWith("chunks"))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monkeyplus/flow",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.39",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.mjs",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@monkeyplus/flow-cli": "5.0.0-rc.
|
|
29
|
-
"@monkeyplus/flow-kit": "5.0.0-rc.
|
|
30
|
-
"@monkeyplus/flow-schema": "5.0.0-rc.
|
|
28
|
+
"@monkeyplus/flow-cli": "5.0.0-rc.39",
|
|
29
|
+
"@monkeyplus/flow-kit": "5.0.0-rc.39",
|
|
30
|
+
"@monkeyplus/flow-schema": "5.0.0-rc.39",
|
|
31
31
|
"@rollup/plugin-replace": "^4.0.0",
|
|
32
32
|
"@vueuse/head": "^0.7.6",
|
|
33
33
|
"c12": "^0.2.7",
|