@monkeyplus/flow 5.0.0-rc.2 → 5.0.0-rc.200

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.
Files changed (81) hide show
  1. package/dist/app/entry.async.d.ts +3 -0
  2. package/dist/app/entry.async.mjs +1 -0
  3. package/dist/app/entry.d.ts +2 -2
  4. package/dist/app/entry.mjs +3 -2
  5. package/dist/app/flow.d.ts +12 -3
  6. package/dist/app/flow.mjs +3 -0
  7. package/dist/chunks/dev-bundler.mjs +277 -0
  8. package/dist/core/runtime/client.manifest.d.mts +2 -0
  9. package/dist/core/runtime/client.manifest.mjs +6 -0
  10. package/dist/core/runtime/nitro/flow.d.ts +1 -0
  11. package/dist/core/runtime/nitro/flow.mjs +9 -14
  12. package/dist/core/runtime/nitro/renderer.mjs +82 -18
  13. package/dist/core/runtime/vite-node-shared.d.mts +1 -0
  14. package/dist/core/runtime/vite-node-shared.d.ts +8 -0
  15. package/dist/core/runtime/vite-node-shared.mjs +3 -0
  16. package/dist/core/runtime/vite-node.d.mts +2 -0
  17. package/dist/core/runtime/vite-node.mjs +41 -0
  18. package/dist/head/runtime/plugin.mjs +0 -1
  19. package/dist/index.mjs +543 -772
  20. package/dist/pages/runtime/helpers/index.d.ts +1 -1
  21. package/dist/pages/runtime/helpers/index.mjs +14 -3
  22. package/dist/pages/runtime/index.d.ts +10 -3
  23. package/dist/pages/runtime/index.mjs +12 -4
  24. package/dist/pages/runtime/pages.mjs +123 -0
  25. package/package.json +55 -40
  26. package/build.config.ts +0 -25
  27. package/dist/pages/runtime/plugin.mjs +0 -53
  28. package/dist/vite-client/runtime/injectManifest.d.ts +0 -26
  29. package/dist/vite-client/runtime/injectManifest.mjs +0 -104
  30. package/dist/vite-client/runtime/plugin.d.ts +0 -2
  31. package/dist/vite-client/runtime/plugin.mjs +0 -27
  32. package/src/app/composables/index.ts +0 -20
  33. package/src/app/entry.ts +0 -36
  34. package/src/app/flow.ts +0 -157
  35. package/src/app/index.ts +0 -5
  36. package/src/auto-imports/module.ts +0 -143
  37. package/src/auto-imports/presets.ts +0 -49
  38. package/src/auto-imports/transform.ts +0 -48
  39. package/src/core/app.ts +0 -90
  40. package/src/core/builder.ts +0 -60
  41. package/src/core/flow.ts +0 -93
  42. package/src/core/modules.ts +0 -32
  43. package/src/core/nitro.ts +0 -206
  44. package/src/core/plugins/import-protection.ts +0 -49
  45. package/src/core/plugins/unctx.ts +0 -31
  46. package/src/core/runtime/nitro/flow.ts +0 -43
  47. package/src/core/runtime/nitro/paths.ts +0 -20
  48. package/src/core/runtime/nitro/renderer.ts +0 -74
  49. package/src/core/templates.ts +0 -119
  50. package/src/core/vite/builder/css.ts +0 -28
  51. package/src/core/vite/builder/dev-bundler.ts +0 -248
  52. package/src/core/vite/builder/index.ts +0 -96
  53. package/src/core/vite/builder/manifest.ts +0 -33
  54. package/src/core/vite/builder/plugins/analyze.ts +0 -32
  55. package/src/core/vite/builder/plugins/cache-dir.ts +0 -13
  56. package/src/core/vite/builder/plugins/dynamic-base.ts +0 -64
  57. package/src/core/vite/builder/plugins/virtual.ts +0 -45
  58. package/src/core/vite/builder/server.ts +0 -164
  59. package/src/core/vite/builder/types/index.ts +0 -13
  60. package/src/core/vite/builder/utils/index.ts +0 -53
  61. package/src/core/vite/builder/utils/warmup.ts +0 -27
  62. package/src/core/vite/builder/utils/wpfs.ts +0 -7
  63. package/src/core/vite/builder/vite-node.ts +0 -110
  64. package/src/core/vite/client/index.ts +0 -63
  65. package/src/dirs.ts +0 -8
  66. package/src/head/module.ts +0 -37
  67. package/src/head/runtime/composables.ts +0 -16
  68. package/src/head/runtime/index.ts +0 -1
  69. package/src/head/runtime/plugin.ts +0 -12
  70. package/src/index.ts +0 -2
  71. package/src/pages/module.ts +0 -55
  72. package/src/pages/runtime/helpers/chunks.ts +0 -0
  73. package/src/pages/runtime/helpers/index.ts +0 -33
  74. package/src/pages/runtime/index.ts +0 -9
  75. package/src/pages/runtime/plugin.ts +0 -65
  76. package/src/pages/templates.ts +0 -20
  77. package/src/pages/utils.ts +0 -49
  78. package/src/vite-client/module.ts +0 -84
  79. package/src/vite-client/runtime/injectManifest.ts +0 -188
  80. package/src/vite-client/runtime/plugin.ts +0 -33
  81. /package/dist/pages/runtime/{plugin.d.ts → pages.d.ts} +0 -0
@@ -1,5 +1,5 @@
1
1
  import type { GetPages, PageDefinition } from '@monkeyplus/flow-schema';
2
2
  export declare function definePage(page: PageDefinition): {
3
- pages: any[];
3
+ pages: never[];
4
4
  getPages: GetPages;
5
5
  };
@@ -1,6 +1,9 @@
1
1
  import { joinURL, withTrailingSlash } from "ufo";
2
- const buildPages = (page) => (location, language) => {
3
- const locales = Object.entries(page.locales);
2
+ const buildPages = (page) => (location, language, _locales) => {
3
+ const locales = _locales.map((key) => {
4
+ const _page = page.locales[key];
5
+ return [key, _page];
6
+ }).filter((el) => !!el[1]);
4
7
  return locales.map(([locale, localePage]) => {
5
8
  const [_language, _location] = locale.split("-");
6
9
  const name = joinURL("/", _location, _language, page.name);
@@ -16,7 +19,15 @@ const buildPages = (page) => (location, language) => {
16
19
  return {
17
20
  name,
18
21
  url: path,
19
- context: { page: localePage, locale: _locale, path, view: page.view, name: page.name }
22
+ context: {
23
+ page: localePage,
24
+ locale: _locale,
25
+ path,
26
+ view: page.view,
27
+ name: page.name,
28
+ noPublish: page.noPublish
29
+ }
30
+ // locale: _locale,
20
31
  };
21
32
  });
22
33
  };
@@ -1,3 +1,10 @@
1
- import type { DynamicPage, SimplePage } from '@monkeyplus/flow-schema';
2
- export declare function definePage(page: SimplePage): SimplePage;
3
- export declare function defineDinamycPage(page: DynamicPage): DynamicPage;
1
+ import type { DynamicPage, PageCtx, SimplePage } from '@monkeyplus/flow-schema';
2
+ export declare function definePage<T>(...pages: SimplePage<T>[]): SimplePage<T>[];
3
+ export declare function defineDynamicPage<T>(...pages: DynamicPage<T>[]): DynamicPage<T>[];
4
+ export interface SharedContext {
5
+ assign?: 'global' | 'local';
6
+ merge?: boolean;
7
+ setup: (cxt: PageCtx) => any;
8
+ locales?: Record<string, (ctx: PageCtx) => any>;
9
+ }
10
+ export declare function defineSharedContext(shared: SharedContext): SharedContext;
@@ -1,6 +1,14 @@
1
- export function definePage(page) {
2
- return page;
1
+ export function definePage(...pages) {
2
+ return pages;
3
3
  }
4
- export function defineDinamycPage(page) {
5
- return page;
4
+ export function defineDynamicPage(...pages) {
5
+ return pages.map((page) => {
6
+ page.originalName = page.name;
7
+ if (!page.name.endsWith("/**"))
8
+ page.name = `${page.name}/**`;
9
+ return page;
10
+ });
11
+ }
12
+ export function defineSharedContext(shared) {
13
+ return shared;
6
14
  }
@@ -0,0 +1,123 @@
1
+ import { joinURL } from "ufo";
2
+ import consola from "consola";
3
+ import { definePage } from "./helpers/index.mjs";
4
+ import { defineFlowPlugin, useRuntimeConfig } from "#app";
5
+ import pages from "#build/pages";
6
+ import contexts from "#build/pages.contexts";
7
+ export default defineFlowPlugin(async (flow) => {
8
+ const { app } = useRuntimeConfig();
9
+ const allPages = [];
10
+ const basePages = Object.entries(pages);
11
+ consola.success("Parsed %i pages files", basePages.length);
12
+ basePages.forEach(([name, _pages]) => {
13
+ const __pages = Array.isArray(_pages) ? _pages : [_pages];
14
+ __pages.forEach((page) => {
15
+ const { getPages } = definePage({
16
+ name,
17
+ ...page
18
+ });
19
+ const _pages2 = getPages(
20
+ app.locale.location,
21
+ app.locale.language,
22
+ app.locale.locales
23
+ );
24
+ _pages2.forEach((page2) => {
25
+ flow.router.byUrl.insert(page2.url, page2.context);
26
+ if (page2.url.includes("**") && !page2.context.page.dynamic) {
27
+ const _url = page2.url.replaceAll("*", "");
28
+ flow.router.byUrl.insert(_url, {
29
+ ...page2.context,
30
+ path: _url
31
+ });
32
+ }
33
+ flow.router.byName.insert(page2.name, page2.context);
34
+ allPages.push(page2.context);
35
+ });
36
+ });
37
+ });
38
+ const cache = {};
39
+ function replacePath(_path, url) {
40
+ if (typeof url === "string") {
41
+ _path = joinURL(_path.replace("/**", ""), url);
42
+ } else {
43
+ Object.entries(url).forEach(([key, value]) => {
44
+ _path = _path.replace(`:${key}`, value);
45
+ });
46
+ if (url._ && _path.endsWith("**"))
47
+ _path = joinURL(_path.replace("/**", ""), url._);
48
+ }
49
+ return _path;
50
+ }
51
+ async function getUrl(namePage, localeCode) {
52
+ const code = localeCode || this?.getLocale()?.code;
53
+ const [lang, loc] = code.split("-");
54
+ const name = joinURL("/", loc, lang, namePage);
55
+ const baseHome = joinURL("/", loc, lang, "home");
56
+ const { path, params, page } = flow.router.byName.lookup(name) || {};
57
+ const h = flow.router.byName.lookup(baseHome);
58
+ const base404 = h?.path || "/";
59
+ if (params?._ && page.dynamic) {
60
+ if (!cache[path + code]) {
61
+ cache[path + code] = this.defineCachedFunction(async (_ctx) => {
62
+ return await page.dynamic.method(_ctx);
63
+ }, { maxAge: 8, getKey: () => path, swr: false });
64
+ }
65
+ const fn = cache[path + code];
66
+ const list = await fn({ utils: this, locale: { ...this.getLocale(), code } });
67
+ const dPage = list.find((el) => el.name === params._);
68
+ return dPage ? replacePath(path, dPage.url) : `${base404}404`;
69
+ }
70
+ return path?.replaceAll("*", "") || `${base404}404`;
71
+ }
72
+ async function getUrls(withLocale = false, omitNoPublish = false) {
73
+ const urls = [];
74
+ const _allPages = allPages.filter((p) => omitNoPublish ? !p.noPublish : true);
75
+ for (const page of _allPages) {
76
+ if ((page.path.includes("/:") || page.path.includes("/**")) && page.page.dynamic) {
77
+ const dPages = await page.page.dynamic.method({
78
+ locale: page.locale,
79
+ utils: Object.assign({ getLocale: () => page.locale }, flow.app.utils),
80
+ chunks: {},
81
+ page: {}
82
+ });
83
+ dPages.forEach((dPage) => {
84
+ const _path = replacePath(page.path, dPage.url);
85
+ urls.push(withLocale ? { url: _path, locale: page.locale.code, name: joinURL(page.name?.replaceAll("*", ""), dPage.name) } : _path);
86
+ });
87
+ } else {
88
+ const url = page.path.replaceAll("*", "");
89
+ urls.push(withLocale ? { url, locale: page.locale.code, name: page.name } : url);
90
+ }
91
+ }
92
+ return urls.sort();
93
+ }
94
+ async function getSharedContext(ctx) {
95
+ const entries = Object.entries(contexts);
96
+ if (!entries.length)
97
+ return {};
98
+ const _contexts = await Promise.all(entries.map(async ([key, method]) => {
99
+ const data = await method.setup(ctx);
100
+ const setupLocal = method?.locales?.[ctx.locale.code];
101
+ let dataLocal = {};
102
+ if (setupLocal)
103
+ dataLocal = await setupLocal(ctx);
104
+ const obj = method.merge ? { ...data, ...dataLocal } : { [key]: { ...data, ...dataLocal } };
105
+ return obj;
106
+ }));
107
+ return _contexts.reduce((acc, curr) => {
108
+ return {
109
+ ...acc,
110
+ ...curr
111
+ };
112
+ }, {});
113
+ }
114
+ flow.setUtil("getUrl", getUrl);
115
+ flow.setUtil("getUrls", getUrls);
116
+ flow.setUtil("getPages", () => allPages);
117
+ flow.setUtil("getSharedContext", getSharedContext);
118
+ return {
119
+ provide: {
120
+ pages: { allPages }
121
+ }
122
+ };
123
+ });
package/package.json CHANGED
@@ -1,65 +1,80 @@
1
1
  {
2
2
  "name": "@monkeyplus/flow",
3
- "version": "5.0.0-rc.2",
3
+ "version": "5.0.0-rc.200",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
+ "main": "./dist/index.mjs",
7
+ "types": "./types.d.ts",
8
+ "bin": {
9
+ "flow": "./bin/flow.mjs"
10
+ },
6
11
  "exports": {
7
12
  ".": "./dist/index.mjs",
8
13
  "./app": "./dist/app/index.mjs",
9
14
  "./package.json": "./package.json"
10
15
  },
11
- "main": "./dist/index.mjs",
12
- "types": "./types.d.ts",
13
- "bin": {
14
- "flow": "./bin/flow.mjs"
16
+ "imports": {
17
+ "#app": "./dist/app/index.mjs",
18
+ "#head": "./dist/head/runtime/index.mjs",
19
+ "#pages": "./dist/pages/runtime/index.mjs"
15
20
  },
21
+ "files": [
22
+ "app.d.ts",
23
+ "bin",
24
+ "types.d.ts",
25
+ "dist"
26
+ ],
16
27
  "dependencies": {
17
- "@monkeyplus/flow-cli": "5.0.0-rc.2",
18
- "@monkeyplus/flow-kit": "5.0.0-rc.2",
19
- "@monkeyplus/flow-schema": "5.0.0-rc.2",
20
28
  "@rollup/plugin-replace": "^4.0.0",
21
- "@vueuse/head": "^0.7.6",
22
- "c12": "^0.2.7",
29
+ "@vueuse/head": "^1.0.16",
30
+ "c12": "^1.0.1",
23
31
  "chokidar": "^3.5.3",
24
32
  "consola": "^2.15.3",
25
- "defu": "^6.0.0",
26
- "esbuild": "^0.14.38",
33
+ "defu": "^6.1.0",
34
+ "esbuild": "^0.15.13",
27
35
  "escape-string-regexp": "^5.0.0",
28
- "esno": "^0.14.1",
36
+ "esno": "^0.16.3",
29
37
  "eta": "^1.12.3",
30
- "externality": "^0.2.1",
38
+ "externality": "^1.0.0",
31
39
  "fs-extra": "^10.1.0",
32
- "get-port-please": "^2.5.0",
33
- "globby": "^13.1.1",
34
- "h3": "^0.7.4",
35
- "hookable": "^5.1.1",
36
- "jiti": "^1.13.0",
37
- "knitwork": "^0.1.1",
38
- "listhen": "^0.2.10",
39
- "magic-string": "^0.26.2",
40
- "mlly": "^0.5.2",
40
+ "globby": "^13.1.2",
41
+ "h3": "^1.5.0",
42
+ "hookable": "^5.4.2",
43
+ "jiti": "^1.16.0",
44
+ "ohash": "^1.0.0",
45
+ "knitwork": "^1.0.0",
46
+ "listhen": "^1.0.0",
47
+ "magic-string": "^0.26.7",
48
+ "mlly": "^1.0.0",
41
49
  "mri": "^1.2.0",
42
- "nitropack": "^0.4.4",
43
- "pathe": "^0.2.0",
50
+ "nitropack": "^1.0.0",
51
+ "pathe": "^1.0.0",
44
52
  "perfect-debounce": "^0.1.3",
45
- "radix3": "^0.1.2",
46
- "unenv": "^0.5.2",
47
- "ohmyfetch": "^0.4.18",
48
- "node-fetch-native": "^0.1.3",
49
- "rollup": "^2.72.1",
50
- "rollup-plugin-visualizer": "^5.6.0",
51
- "scule": "^0.2.1",
52
- "ufo": "^0.8.3",
53
- "unctx": "^1.1.4",
54
- "unimport": "^0.2.1",
55
- "unplugin": "^0.6.3",
56
- "untyped": "^0.4.4",
57
- "vite": "^2.9.9",
58
- "vue": "^3.2.33"
53
+ "radix3": "^1.0.0",
54
+ "unenv": "^1.0.0",
55
+ "ohmyfetch": "^0.4.21",
56
+ "node-fetch-native": "^1.0.1",
57
+ "rollup": "^3.10.1",
58
+ "rollup-plugin-visualizer": "^5.8.3",
59
+ "scule": "^1.0.0",
60
+ "ufo": "^1.0.0",
61
+ "unctx": "^2.1.0",
62
+ "unimport": "^1.0.1",
63
+ "unplugin": "^1.0.0",
64
+ "untyped": "^1.0.0",
65
+ "pkg-types": "^1.0.1",
66
+ "vite": "~4.0.4",
67
+ "vite-node": "^0.24.5",
68
+ "vite-plugin-checker": "^0.5.1",
69
+ "vue-bundle-renderer": "^1.0.0",
70
+ "vue": "^3.2.41",
71
+ "@monkeyplus/flow-schema": "5.0.0-rc.200",
72
+ "@monkeyplus/flow-cli": "5.0.0-rc.200",
73
+ "@monkeyplus/flow-kit": "5.0.0-rc.200"
59
74
  },
60
75
  "devDependencies": {
61
76
  "@types/fs-extra": "^9.0.13",
62
- "vue-router": "^4.0.15"
77
+ "vue-router": "^4.1.6"
63
78
  },
64
79
  "engines": {
65
80
  "node": "^16.11.0 || ^17.0.0 || ^18.0.0"
package/build.config.ts DELETED
@@ -1,25 +0,0 @@
1
- import type { BuildEntry } from 'unbuild';
2
- import { defineBuildConfig } from 'unbuild';
3
-
4
- export default defineBuildConfig({
5
- declaration: true,
6
- entries: [
7
- 'src/index',
8
- { input: 'src/app/', outDir: 'dist/app/' },
9
- ...[
10
- 'core',
11
- 'head',
12
- 'pages',
13
- 'vite-client',
14
- ].map((name) => ({ input: `src/${name}/runtime/`, outDir: `dist/${name}/runtime`, format: 'esm' } as BuildEntry)),
15
- // { input: 'src/runtime/', outDir: 'dist/runtime', format: 'esm' },
16
- ],
17
- dependencies: [
18
- '@monkeyplus/flow-cli',
19
- 'ohmyfetch',
20
-
21
- ],
22
- externals: [
23
-
24
- ],
25
- });
@@ -1,53 +0,0 @@
1
- import { joinURL } from "ufo";
2
- import { definePage } from "./helpers/index.mjs";
3
- import { defineFlowPlugin, useRuntimeConfig } from "#app";
4
- import pages from "#pages";
5
- export default defineFlowPlugin(async (flow) => {
6
- const { app } = useRuntimeConfig();
7
- const allPages = [];
8
- Object.entries(pages).forEach(([name, page]) => {
9
- const { getPages } = definePage({
10
- name,
11
- ...page
12
- });
13
- const _pages = getPages(app.locale.location, app.locale.language);
14
- _pages.forEach((page2) => {
15
- flow.router.byUrl.insert(page2.url, page2.context);
16
- flow.router.byName.insert(page2.name, page2.context);
17
- allPages.push(page2.context);
18
- });
19
- });
20
- function getUrl(namePage, localeCode) {
21
- const code = localeCode || this?.getLocale()?.code;
22
- const [lang, loc] = code.split("-");
23
- const name = joinURL("/", loc, lang, namePage);
24
- const { path } = flow.router.byName.lookup(name) || {};
25
- return path || "/404";
26
- }
27
- async function getUrls(withLocale = false) {
28
- const urls = [];
29
- for (const page of allPages) {
30
- if (!page.path.includes("/**")) {
31
- urls.push(withLocale ? { url: page.path, locale: page.locale.code, name: page.name } : page.path);
32
- } else {
33
- const dPages = await page.page.dynamic.method({
34
- locale: page.locale,
35
- utils: Object.assign({ getLocale: () => page.locale }, flow.app.utils)
36
- });
37
- dPages.forEach((dPage) => {
38
- const _path = joinURL(page.path.replace("/**", ""), dPage.url);
39
- urls.push(withLocale ? { url: _path, locale: page.locale.code, name: joinURL(page.name, dPage.name) } : _path);
40
- });
41
- }
42
- }
43
- return urls.sort();
44
- }
45
- flow.setUtil("getUrl", getUrl);
46
- flow.setUtil("getUrls", getUrls);
47
- flow.setUtil("getPages", () => allPages);
48
- return {
49
- provide: {
50
- pages: { allPages }
51
- }
52
- };
53
- });
@@ -1,26 +0,0 @@
1
- export declare type Manifest = Record<string, ManifestChunk>;
2
- export interface ManifestChunk {
3
- src?: string;
4
- file: string;
5
- css?: string[];
6
- assets?: string[];
7
- isEntry?: boolean;
8
- isDynamicEntry?: boolean;
9
- imports?: string[];
10
- dynamicImports?: string[];
11
- }
12
- export interface HtmlTagDescriptor {
13
- tag: string;
14
- attrs?: Record<string, string | boolean | undefined>;
15
- children?: string | HtmlTagDescriptor[];
16
- /**
17
- * default: 'head-prepend'
18
- */
19
- injectTo?: 'head' | 'body' | 'head-prepend' | 'body-prepend';
20
- }
21
- export declare const generateBundle: (config: any, bundle: Manifest, _id: string) => {
22
- head: string;
23
- body: string;
24
- };
25
- export declare const externalRE: RegExp;
26
- export declare const isExternalUrl: (url: string) => boolean;
@@ -1,104 +0,0 @@
1
- import { joinURL } from "ufo";
2
- export const generateBundle = (config, bundle, _id) => {
3
- const analyzedChunk = new Map();
4
- const getImportedChunks = (chunk2, seen = new Set()) => {
5
- const chunks = [];
6
- chunk2.imports?.forEach((file) => {
7
- const importee = bundle[file];
8
- if (file.startsWith("_") && !seen.has(file)) {
9
- seen.add(file);
10
- chunks.push(...getImportedChunks(importee, seen));
11
- chunks.push(importee);
12
- }
13
- });
14
- return chunks;
15
- };
16
- const toScriptTag = (chunk2, publicBase2, isAsync2) => ({
17
- tag: "script",
18
- attrs: {
19
- ...isAsync2 ? { async: true } : {},
20
- type: "module",
21
- crossorigin: true,
22
- src: toPublicPath(chunk2.file, publicBase2)
23
- }
24
- });
25
- const toPreloadTag = (chunk2, publicBase2) => ({
26
- tag: "link",
27
- attrs: {
28
- rel: "modulepreload",
29
- crossorigin: true,
30
- href: toPublicPath(chunk2.file, publicBase2)
31
- }
32
- });
33
- const getCssTagsForChunk = (chunk2, publicBase2, seen = new Set()) => {
34
- const tags = [];
35
- if (!analyzedChunk.has(chunk2)) {
36
- analyzedChunk.set(chunk2, 1);
37
- chunk2.imports?.forEach((file) => {
38
- const importee = bundle[file];
39
- if (file.startsWith("_"))
40
- tags.push(...getCssTagsForChunk(importee, publicBase2, seen));
41
- });
42
- }
43
- chunk2.css?.forEach((file) => {
44
- if (!seen.has(file)) {
45
- seen.add(file);
46
- tags.push({
47
- tag: "link",
48
- attrs: {
49
- rel: "stylesheet",
50
- href: toPublicPath(file, publicBase2)
51
- }
52
- });
53
- }
54
- });
55
- return tags;
56
- };
57
- const publicBase = config.baseURL || "/";
58
- const isAsync = false;
59
- const chunk = Object.values(bundle).find((chunk2) => chunk2.isEntry && chunk2.src === _id);
60
- if (chunk) {
61
- const imports = getImportedChunks(chunk);
62
- const assetTags = [
63
- toScriptTag(chunk, publicBase, isAsync),
64
- ...imports.map((i) => toPreloadTag(i, publicBase))
65
- ];
66
- assetTags.push(...getCssTagsForChunk(chunk, publicBase));
67
- const tags = serializeTags(assetTags);
68
- return { head: tags, body: "" };
69
- }
70
- };
71
- export const externalRE = /^(https?:)?\/\//;
72
- export const isExternalUrl = (url) => externalRE.test(url);
73
- function toPublicPath(filename, publicBase) {
74
- return isExternalUrl(filename) ? filename : joinURL(publicBase, filename.replace("scripts", "assets"));
75
- }
76
- const unaryTags = new Set(["link", "meta", "base"]);
77
- function serializeTag({ tag, attrs, children }, indent = "") {
78
- if (unaryTags.has(tag)) {
79
- return `<${tag}${serializeAttrs(attrs)}>`;
80
- } else {
81
- return `<${tag}${serializeAttrs(attrs)}>${serializeTags(children, incrementIndent(indent))}</${tag}>`;
82
- }
83
- }
84
- function serializeTags(tags, indent = "") {
85
- if (typeof tags === "string")
86
- return tags;
87
- else if (tags && tags.length)
88
- return tags.map((tag) => `${indent}${serializeTag(tag, indent)}
89
- `).join("");
90
- return "";
91
- }
92
- function serializeAttrs(attrs) {
93
- let res = "";
94
- for (const key in attrs) {
95
- if (typeof attrs[key] === "boolean")
96
- res += attrs[key] ? ` ${key}` : "";
97
- else
98
- res += ` ${key}=${JSON.stringify(attrs[key])}`;
99
- }
100
- return res;
101
- }
102
- function incrementIndent(indent = "") {
103
- return `${indent}${indent[0] === " " ? " " : " "}`;
104
- }
@@ -1,2 +0,0 @@
1
- declare const _default: any;
2
- export default _default;
@@ -1,27 +0,0 @@
1
- import logger from "consola";
2
- import { generateBundle } from "./injectManifest.mjs";
3
- import { defineFlowPlugin } from "#app";
4
- import manifest from "#viteManifest";
5
- export default defineFlowPlugin((flow) => {
6
- if (typeof manifest === "function") {
7
- const _manifest = manifest();
8
- flow.hook("page:chunks", (bundle, chunks) => {
9
- try {
10
- const chunk = generateBundle(flow.$config.app || {}, _manifest, `client/pages/${bundle}.ts`);
11
- if (chunk) {
12
- chunks.head.push(chunk.head);
13
- chunks.body.push(chunk.body);
14
- } else {
15
- logger.warn('Entry "%s" not found ', bundle);
16
- }
17
- } catch (error) {
18
- logger.error("Error in inject %s ", bundle);
19
- }
20
- });
21
- } else {
22
- flow.hook("page:chunks", (bundle, chunks) => {
23
- chunks.head.push(manifest.head());
24
- chunks.body.push(manifest.body(bundle));
25
- });
26
- }
27
- });
@@ -1,20 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unused-vars */
2
- //* fake to nuxt Compatibilities
3
- import type { RouteLocationNormalizedLoaded } from 'vue-router';
4
- export function useCookie(name: string, _opts?: any) {
5
- // console.log('Cookie', name, _opts);
6
-
7
- return {};
8
- }
9
-
10
- export function refreshNuxtData(keys?: string | string[]): Promise<void> {
11
- return Promise.resolve();
12
- }
13
-
14
- export function useAsyncData(key: string, handlers: () => Promise<any>) {
15
- return handlers();
16
- }
17
-
18
- export function useRoute(): RouteLocationNormalizedLoaded {
19
- return {} as any;
20
- }
package/src/app/entry.ts DELETED
@@ -1,36 +0,0 @@
1
-
2
- import type { RuntimeConfig } from '@monkeyplus/flow-schema';
3
- import { config, configure, render } from 'eta';
4
- import { applyPlugins, createFlowApp } from './flow';
5
- // @ts-ignore
6
- import plugins from '#build/plugins';
7
-
8
- export default async(runtimeConfig: RuntimeConfig) => {
9
- const flow = createFlowApp({ runtimeConfig });
10
- try {
11
- await applyPlugins(flow, plugins);
12
- // console.log(flow.eta);
13
-
14
- configure(flow.eta);
15
- flow.render = (view: Record<string, string>, data: any) => {
16
- // eslint-disable-next-line no-template-curly-in-string
17
- const layout = '<%layout(`layouts/${it.view?.layout||\'default\'}`)%>';
18
- const getTemplate = flow.engines[view.engine || flow.engine];
19
- const base = `${layout}
20
- ${getTemplate(view.template)}`;
21
- return render(base, data || {}, {
22
- ...config,
23
- async: true,
24
- });
25
- };
26
-
27
- // await flow.hooks.callHook('app:created', vueApp);
28
- }
29
- catch (err) {
30
- console.log(err);
31
- // await flow.callHook('app:error', err);
32
- // ssrContext.error = ssrContext.error || err;
33
- }
34
-
35
- return flow;
36
- };