@monkeyplus/flow 5.0.0-beta.3 → 5.0.0-beta.4

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.
@@ -10,12 +10,12 @@ export default eventHandler(async (event) => {
10
10
  const chunks = { head: [], body: [] };
11
11
  const generate = {};
12
12
  const { page, locale, params, view } = flow.router.byUrl.lookup(url) || {};
13
+ if (!page)
14
+ return;
13
15
  await flow.callHook("page:scripts", scripts);
14
16
  if (view.bundle)
15
17
  await flow.callHook("page:chunks", view.bundle, chunks);
16
18
  const templateContext = {};
17
- if (!page)
18
- return;
19
19
  const dynamyc = params?._;
20
20
  const contextPage = {};
21
21
  const utils = Object.assign({ getLocale: () => locale }, flow.app.utils);
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createHooks } from 'hookable';
2
2
  import { dirname, resolve, normalize, join, isAbsolute, relative, extname } from 'pathe';
3
- import { defineFlowModule, addPlugin, defineNuxtModule, logger, addTemplate, addPluginTemplate, addVitePlugin, useNuxt, resolveAlias, resolveFiles, addDevServerHandler, nuxtCtx, installModule, loadFlowConfig, templateUtils, normalizeTemplate, compileTemplate, normalizePlugin, resolveFilesFlow, isIgnoredFlow } from '@monkeyplus/flow-kit';
3
+ import { defineFlowModule, addPlugin, defineNuxtModule, logger, addTemplate, addPluginTemplate, addVitePlugin, useNuxt, resolveAlias, resolveFiles, nuxtCtx, installModule, loadFlowConfig, templateUtils, normalizeTemplate, compileTemplate, normalizePlugin, resolveFilesFlow, isIgnoredFlow } from '@monkeyplus/flow-kit';
4
4
  import { fileURLToPath, pathToFileURL } from 'node:url';
5
5
  import { defineUnimportPreset, createUnimport, toImports, scanDirExports } from 'unimport';
6
6
  import { createUnplugin } from 'unplugin';
@@ -27,7 +27,7 @@ import { isExternal as isExternal$1, ExternalsDefaults } from 'externality';
27
27
  import { createHash } from 'node:crypto';
28
28
  import MagicString from 'magic-string';
29
29
 
30
- const version = "5.0.0-beta.3";
30
+ const version = "5.0.0-beta.4";
31
31
 
32
32
  let _distDir = dirname(fileURLToPath(import.meta.url));
33
33
  if (_distDir.endsWith("chunks"))
@@ -345,10 +345,12 @@ const viteModule = defineFlowModule({
345
345
  const runtimeDir = resolve(distDir, "vite-client/runtime");
346
346
  flow.options.alias["#viteManifest"] = resolve(flow.options.buildDir, "viteManifest.mjs");
347
347
  if (flow.options.dev) {
348
- const _vite = await createClient(flow);
349
- addDevServerHandler({
350
- handler: _vite.middlewares,
351
- route: _options.route
348
+ flow.hook("nitro:init", async (nitro) => {
349
+ const _vite = await createClient(flow);
350
+ nitro.options.devHandlers.push({
351
+ handler: _vite.middlewares,
352
+ route: _options.route
353
+ });
352
354
  });
353
355
  addTemplate({
354
356
  filename: "viteManifest.mjs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monkeyplus/flow",
3
- "version": "5.0.0-beta.3",
3
+ "version": "5.0.0-beta.4",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -14,9 +14,9 @@
14
14
  "flow": "./bin/flow.mjs"
15
15
  },
16
16
  "dependencies": {
17
- "@monkeyplus/flow-cli": "5.0.0-beta.3",
18
- "@monkeyplus/flow-kit": "5.0.0-beta.3",
19
- "@monkeyplus/flow-schema": "5.0.0-beta.3",
17
+ "@monkeyplus/flow-cli": "5.0.0-beta.4",
18
+ "@monkeyplus/flow-kit": "5.0.0-beta.4",
19
+ "@monkeyplus/flow-schema": "5.0.0-beta.4",
20
20
  "@nuxt/vite-builder": "3.0.0-rc.1",
21
21
  "@rollup/plugin-replace": "^4.0.0",
22
22
  "@vueuse/head": "^0.7.6",
@@ -17,12 +17,14 @@ export default eventHandler(async(event) => {
17
17
 
18
18
  // console.log(flow);
19
19
  const { page, locale, params, view } = flow.router.byUrl.lookup(url!) || {};
20
+ // Truncate page
21
+ if (!page) return;
22
+
20
23
  await flow.callHook('page:scripts', scripts);
21
24
  if (view.bundle)
22
25
  await flow.callHook('page:chunks', view.bundle, chunks);
23
26
 
24
27
  const templateContext = {} as any;
25
- if (!page) return;
26
28
 
27
29
  const dynamyc = params?._;
28
30
  const contextPage = {} as any;
@@ -23,11 +23,14 @@ export default defineFlowModule<OptionsViteClient>({
23
23
  flow.options.alias['#viteManifest'] = resolve(flow.options.buildDir, 'viteManifest.mjs');
24
24
 
25
25
  if (flow.options.dev) {
26
- const _vite = await createClient(flow);
27
- addDevServerHandler({
28
- handler: _vite.middlewares,
29
- route: _options.route,
26
+ flow.hook('nitro:init', async(nitro) => {
27
+ const _vite = await createClient(flow);
28
+ nitro.options.devHandlers.push({
29
+ handler: _vite.middlewares,
30
+ route: _options.route,
31
+ });
30
32
  });
33
+
31
34
  addTemplate({
32
35
  filename: 'viteManifest.mjs',
33
36
  async getContents() {