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

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/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, 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, addDevServerHandler, 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.4";
30
+ const version = "5.0.0-beta.7";
31
31
 
32
32
  let _distDir = dirname(fileURLToPath(import.meta.url));
33
33
  if (_distDir.endsWith("chunks"))
@@ -310,14 +310,20 @@ const createClient = async (flow) => {
310
310
  }
311
311
  });
312
312
  const _doReload = () => {
313
- vite.ws.send({ type: "full-reload" });
313
+ try {
314
+ vite.ws.send({ type: "full-reload" });
315
+ } catch (error) {
316
+ }
314
317
  };
315
- const doReload = debounce(_doReload, 50);
318
+ const doReload = debounce(_doReload);
316
319
  flow.hook("bundler:change", () => {
317
320
  doReload();
318
321
  });
319
322
  flow.hook("close", async () => {
320
- await vite.close();
323
+ try {
324
+ await vite?.close();
325
+ } catch (error) {
326
+ }
321
327
  });
322
328
  return vite;
323
329
  };
@@ -345,12 +351,10 @@ const viteModule = defineFlowModule({
345
351
  const runtimeDir = resolve(distDir, "vite-client/runtime");
346
352
  flow.options.alias["#viteManifest"] = resolve(flow.options.buildDir, "viteManifest.mjs");
347
353
  if (flow.options.dev) {
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
- });
354
+ const vite = await createClient(flow);
355
+ addDevServerHandler({
356
+ route: _options.route,
357
+ handler: vite.middlewares
354
358
  });
355
359
  addTemplate({
356
360
  filename: "viteManifest.mjs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monkeyplus/flow",
3
- "version": "5.0.0-beta.4",
3
+ "version": "5.0.0-beta.7",
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.4",
18
- "@monkeyplus/flow-kit": "5.0.0-beta.4",
19
- "@monkeyplus/flow-schema": "5.0.0-beta.4",
17
+ "@monkeyplus/flow-cli": "5.0.0-beta.7",
18
+ "@monkeyplus/flow-kit": "5.0.0-beta.7",
19
+ "@monkeyplus/flow-schema": "5.0.0-beta.7",
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",
@@ -15,10 +15,15 @@ export const createClient = async(flow: Flow) => {
15
15
  },
16
16
  });
17
17
  const _doReload = () => {
18
- vite.ws.send({ type: 'full-reload' });
18
+ try {
19
+ vite.ws.send({ type: 'full-reload' });
20
+ }
21
+ catch (error) {
22
+ //
23
+ }
19
24
  };
20
25
 
21
- const doReload = debounce(_doReload, 50);
26
+ const doReload = debounce(_doReload);
22
27
 
23
28
  // Use this to refresh page
24
29
  flow.hook('bundler:change', () => {
@@ -26,7 +31,12 @@ export const createClient = async(flow: Flow) => {
26
31
  });
27
32
 
28
33
  flow.hook('close', async() => {
29
- await vite.close();
34
+ try {
35
+ await vite?.close();
36
+ }
37
+ catch (error) {
38
+ //
39
+ }
30
40
  });
31
41
 
32
42
  return vite;
@@ -23,12 +23,11 @@ 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
- 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
- });
26
+ const vite = await createClient(flow);
27
+
28
+ addDevServerHandler({
29
+ route: _options.route,
30
+ handler: vite.middlewares,
32
31
  });
33
32
 
34
33
  addTemplate({