@monkeyplus/flow 5.0.0-rc.128 → 5.0.0-rc.129

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.
@@ -14,6 +14,7 @@ export interface FlowAppHooks {
14
14
  'page:context': (ctx: {
15
15
  page: string;
16
16
  localeCode: string;
17
+ ctx: any;
17
18
  }, utils: any, data: Record<string, any>) => HookResult;
18
19
  'page:chunks': (bundle: string, scripts: {
19
20
  head: string[];
@@ -42,6 +42,7 @@ export default eventHandler(async (event) => {
42
42
  };
43
43
  const contextInject = {};
44
44
  const utils = Object.assign({ getLocale: () => locale, injectContext: (key, value) => contextInject[key] = value, defineCachedFunction: event.context.defineCachedFunction }, flow.app.utils);
45
+ const contextHooks = {};
45
46
  if (event.node.req.method.toLowerCase() === "post") {
46
47
  const body = await readBody(event);
47
48
  contextPage._post = body;
@@ -72,17 +73,19 @@ export default eventHandler(async (event) => {
72
73
  templateContext[page.dynamic.assign] = dynamicPage.context;
73
74
  contextPage.dynamic = dynamicPage;
74
75
  }
75
- await flow.callHook("page:context", { localeCode: locale.code, page: pageName }, utils, contextPage);
76
+ await flow.callHook("page:context", { localeCode: locale.code, page: pageName, ctx: contextPage }, utils, contextHooks);
76
77
  templateContext.seo = {};
77
78
  const sharedContext = await utils.getSharedContext({
79
+ ...contextHooks,
78
80
  ...contextPage,
79
81
  utils
80
82
  });
81
83
  templateContext.sharedContext = sharedContext || {};
82
84
  templateContext.utils = utils;
83
- templateContext.seo = await normalizeCall(page?.seo, { ...contextPage, utils, sharedContext });
84
- const contexData = await page.context?.({ ...contextPage, utils, sharedContext }) || {};
85
+ templateContext.seo = await normalizeCall(page?.seo, { ...contextHooks, ...contextPage, utils, sharedContext });
86
+ const contexData = await page.context?.({ ...contextHooks, ...contextPage, utils, sharedContext }) || {};
85
87
  templateContext.context = {
88
+ ...contextHooks,
86
89
  ...contexData
87
90
  };
88
91
  await flow.callHook("page:scripts", scripts, templateContext);
package/dist/index.mjs CHANGED
@@ -24,7 +24,7 @@ import replace from '@rollup/plugin-replace';
24
24
  import { resolveTSConfig } from 'pkg-types';
25
25
  import fse from 'fs-extra';
26
26
 
27
- const version = "5.0.0-rc.128";
27
+ const version = "5.0.0-rc.129";
28
28
 
29
29
  let _distDir = dirname(fileURLToPath(import.meta.url));
30
30
  if (_distDir.match(/(chunks|shared)$/))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monkeyplus/flow",
3
- "version": "5.0.0-rc.128",
3
+ "version": "5.0.0-rc.129",
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.128",
29
- "@monkeyplus/flow-kit": "5.0.0-rc.128",
30
- "@monkeyplus/flow-schema": "5.0.0-rc.128",
28
+ "@monkeyplus/flow-cli": "5.0.0-rc.129",
29
+ "@monkeyplus/flow-kit": "5.0.0-rc.129",
30
+ "@monkeyplus/flow-schema": "5.0.0-rc.129",
31
31
  "@rollup/plugin-replace": "^4.0.0",
32
32
  "@vueuse/head": "^1.0.16",
33
33
  "c12": "^1.0.1",