@monkeyplus/flow 5.0.0-rc.101 → 5.0.0-rc.102

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.
@@ -231,7 +231,7 @@ async function initViteDevBundler(ctx, onBuild) {
231
231
  await onBuild();
232
232
  ctx.nuxt.callHook("bundler:change", {});
233
233
  };
234
- const doBuild = debounce(_doBuild, 60);
234
+ const doBuild = debounce(_doBuild);
235
235
  await _doBuild();
236
236
  viteServer.watcher.on("all", (_event, file) => {
237
237
  if (file.includes("/pages/"))
@@ -24,7 +24,7 @@ import replace from '@rollup/plugin-replace';
24
24
  import { sanitizeFilePath } from 'mlly';
25
25
  import { resolveTSConfig } from 'pkg-types';
26
26
 
27
- const version = "5.0.0-rc.101";
27
+ const version = "5.0.0-rc.102";
28
28
 
29
29
  let _distDir = dirname(fileURLToPath(import.meta.url));
30
30
  if (_distDir.endsWith("chunks"))
@@ -29,6 +29,16 @@ export default defineFlowPlugin(async (flow) => {
29
29
  });
30
30
  });
31
31
  const cache = {};
32
+ function replacePath(_path, url) {
33
+ if (url === "string") {
34
+ _path = joinURL(_path.replace("/**", ""), url);
35
+ } else {
36
+ Object.entries(url).forEach(([key, value]) => {
37
+ _path = _path.replace(`:${key}`, value);
38
+ });
39
+ }
40
+ return _path;
41
+ }
32
42
  async function getUrl(namePage, localeCode) {
33
43
  const code = localeCode || this?.getLocale()?.code;
34
44
  const [lang, loc] = code.split("-");
@@ -43,14 +53,14 @@ export default defineFlowPlugin(async (flow) => {
43
53
  const fn = cache[path];
44
54
  const list = await fn({ utils: this, locale: this.getLocale() });
45
55
  const dPage = list.find((el) => el.name === params._);
46
- return dPage ? path.replace("**", dPage.url) : "/404";
56
+ return dPage ? replacePath(path, dPage.url) : "/404";
47
57
  }
48
58
  return path || "/404";
49
59
  }
50
60
  async function getUrls(withLocale = false) {
51
61
  const urls = [];
52
62
  for (const page of allPages) {
53
- if (page.path.includes("/**") && page.page.dynamic) {
63
+ if ((page.path.includes("/:") || page.path.includes("/**")) && page.page.dynamic) {
54
64
  const dPages = await page.page.dynamic.method({
55
65
  locale: page.locale,
56
66
  utils: Object.assign({ getLocale: () => page.locale }, flow.app.utils),
@@ -58,7 +68,7 @@ export default defineFlowPlugin(async (flow) => {
58
68
  page: {}
59
69
  });
60
70
  dPages.forEach((dPage) => {
61
- const _path = joinURL(page.path.replace("/**", ""), dPage.url);
71
+ const _path = replacePath(page.path, dPage.url);
62
72
  urls.push(withLocale ? { url: _path, locale: page.locale.code, name: joinURL(page.name, dPage.name) } : _path);
63
73
  });
64
74
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monkeyplus/flow",
3
- "version": "5.0.0-rc.101",
3
+ "version": "5.0.0-rc.102",
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.101",
29
- "@monkeyplus/flow-kit": "5.0.0-rc.101",
30
- "@monkeyplus/flow-schema": "5.0.0-rc.101",
28
+ "@monkeyplus/flow-cli": "5.0.0-rc.102",
29
+ "@monkeyplus/flow-kit": "5.0.0-rc.102",
30
+ "@monkeyplus/flow-schema": "5.0.0-rc.102",
31
31
  "@rollup/plugin-replace": "^4.0.0",
32
32
  "@vueuse/head": "^0.7.6",
33
33
  "c12": "^0.2.8",