@monkeyplus/flow 5.0.0-beta.10 → 5.0.0-beta.12

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, resolveFilesFlow, nuxtCtx, installModule, loadFlowConfig, templateUtils, normalizeTemplate, compileTemplate, normalizePlugin, 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.10";
30
+ const version = "5.0.0-beta.12";
31
31
 
32
32
  let _distDir = dirname(fileURLToPath(import.meta.url));
33
33
  if (_distDir.endsWith("chunks"))
@@ -225,7 +225,7 @@ async function resolvePagesRoutes() {
225
225
  const nuxt = useNuxt();
226
226
  const pagesDirs = [...new Set(nuxt.options._layers.map((layer) => resolve(layer.config.srcDir, layer.config.dir?.pages || "pages")))];
227
227
  const allRoutes = (await Promise.all(pagesDirs.map(async (dir) => {
228
- const files = await resolveFiles(dir, `**/*{${nuxt.options.extensions.join(",")}}`);
228
+ const files = await resolveFilesFlow(dir, `**/*{${nuxt.options.extensions.join(",")}}`);
229
229
  files.sort();
230
230
  return files.map((file) => {
231
231
  const segments = relative(dir, file).replace(new RegExp(`${escapeRE(extname(file))}$`), "").split("/").join("_");
@@ -316,7 +316,7 @@ const createClient = async (flow) => {
316
316
  if (vite)
317
317
  vite?.ws?.send({ type: "full-reload" });
318
318
  };
319
- const doReload = debounce(_doReload, 50);
319
+ const doReload = debounce(_doReload, 60);
320
320
  flow.hook("bundler:change", () => {
321
321
  doReload();
322
322
  });
@@ -340,14 +340,17 @@ const builClient = async (flow) => {
340
340
 
341
341
  const viteModule = defineFlowModule({
342
342
  meta: {
343
- name: "viteClient"
343
+ name: "vite-client",
344
+ configKey: "bundle"
344
345
  },
345
346
  defaults: {
346
- route: "/_vite/"
347
+ route: "/_vite/",
348
+ dir: "/client/pages"
347
349
  },
348
350
  async setup(_options, flow) {
349
351
  const runtimeDir = resolve(distDir, "vite-client/runtime");
350
352
  flow.options.alias["#viteManifest"] = resolve(flow.options.buildDir, "viteManifest.mjs");
353
+ console.log(_options);
351
354
  let vite;
352
355
  if (flow.options.dev) {
353
356
  flow.hook("nitro:init", async (nitro) => {
@@ -362,9 +365,9 @@ const viteModule = defineFlowModule({
362
365
  async getContents() {
363
366
  return [
364
367
  "export default {",
365
- 'head:()=>`<script type="module" src="/_vite/@vite/client"><\/script>`',
368
+ `head:()=>'<script type="module" src="${joinURL("/", _options.route, "/@vite/client")}"><\/script>'`,
366
369
  ",",
367
- 'body: (bundle)=>`<script type="module" src="/_vite/client/pages/${bundle}.ts"><\/script>`',
370
+ `body: (bundle)=>\`<script type="module" src="${joinURL("/", _options.route, _options.dir)}/\${bundle}.ts"><\/script>\``,
368
371
  "}"
369
372
  ].join("\n");
370
373
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monkeyplus/flow",
3
- "version": "5.0.0-beta.10",
3
+ "version": "5.0.0-beta.12",
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.10",
18
- "@monkeyplus/flow-kit": "5.0.0-beta.10",
19
- "@monkeyplus/flow-schema": "5.0.0-beta.10",
17
+ "@monkeyplus/flow-cli": "5.0.0-beta.12",
18
+ "@monkeyplus/flow-kit": "5.0.0-beta.12",
19
+ "@monkeyplus/flow-schema": "5.0.0-beta.12",
20
20
  "@rollup/plugin-replace": "^4.0.0",
21
21
  "@vueuse/head": "^0.7.6",
22
22
  "c12": "^0.2.7",
@@ -25,7 +25,7 @@ export const createClient = async(flow: Flow) => {
25
25
  vite?.ws?.send({ type: 'full-reload' });
26
26
  };
27
27
 
28
- const doReload = debounce(_doReload, 50);
28
+ const doReload = debounce(_doReload, 60);
29
29
 
30
30
  // Use this to refresh page
31
31
  flow.hook('bundler:change', () => {
@@ -1,5 +1,5 @@
1
1
 
2
- import { resolveFiles, useNuxt } from '@monkeyplus/flow-kit';
2
+ import { resolveFilesFlow, useNuxt } from '@monkeyplus/flow-kit';
3
3
  import { extname, relative, resolve } from 'pathe';
4
4
  import escapeRE from 'escape-string-regexp';
5
5
  import { camelCase } from 'scule';
@@ -17,7 +17,7 @@ export async function resolvePagesRoutes(): Promise<Pages[]> {
17
17
 
18
18
  const allRoutes: Pages[] = (await Promise.all(
19
19
  pagesDirs.map(async(dir) => {
20
- const files = await resolveFiles(dir, `**/*{${nuxt.options.extensions.join(',')}}`);
20
+ const files = await resolveFilesFlow(dir, `**/*{${nuxt.options.extensions.join(',')}}`);
21
21
 
22
22
  // Sort to make sure parent are listed first
23
23
 
@@ -4,23 +4,28 @@ import { resolve } from 'pathe';
4
4
  // import { genImport } from 'knitwork';
5
5
  import fse from 'fs-extra';
6
6
  import logger from 'consola';
7
+ import { joinURL } from 'ufo';
7
8
  import { builClient, createClient } from '../core/vite/client';
8
9
  import { distDir } from '../dirs';
9
10
 
10
11
  interface OptionsViteClient{
11
12
  route: string
13
+ dir: string
12
14
  }
13
15
  export default defineFlowModule<OptionsViteClient>({
14
16
 
15
17
  meta: {
16
- name: 'viteClient',
18
+ name: 'vite-client',
19
+ configKey: 'bundle',
17
20
  },
18
21
  defaults: {
19
22
  route: '/_vite/',
23
+ dir: '/client/pages',
20
24
  },
21
25
  async setup(_options, flow) {
22
26
  const runtimeDir = resolve(distDir, 'vite-client/runtime');
23
27
  flow.options.alias['#viteManifest'] = resolve(flow.options.buildDir, 'viteManifest.mjs');
28
+ console.log(_options);
24
29
 
25
30
  let vite: any;
26
31
  if (flow.options.dev) {
@@ -43,10 +48,10 @@ export default defineFlowModule<OptionsViteClient>({
43
48
  filename: 'viteManifest.mjs',
44
49
  async getContents() {
45
50
  return ['export default {',
46
- 'head:()=>`<script type="module" src="/_vite/@vite/client"></script>`',
51
+ `head:()=>'<script type="module" src="${joinURL('/', _options.route, '/@vite/client')}"></script>'`,
47
52
  ',',
48
53
  // eslint-disable-next-line no-template-curly-in-string
49
- 'body: (bundle)=>`<script type="module" src="/_vite/client/pages/${bundle}.ts"></script>`',
54
+ `body: (bundle)=>\`<script type="module" src="${joinURL('/', _options.route, _options.dir)}/\${bundle}.ts"></script>\``,
50
55
  '}',
51
56
  ].join('\n');
52
57
  },