@monkeyplus/flow 5.0.0-rc.99 → 6.0.1
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/README.md +34 -0
- package/entry-server.d.ts +1 -0
- package/entry-server.mjs +5 -0
- package/modules/content/module.d.ts +6 -0
- package/modules/content/module.mjs +32 -0
- package/modules/content/query.mjs +104 -0
- package/modules/sitemap/handler.mjs +17 -0
- package/modules/sitemap/module.d.ts +6 -0
- package/modules/sitemap/module.mjs +28 -0
- package/modules/strapi/README.md +235 -0
- package/modules/strapi/module.d.ts +11 -0
- package/modules/strapi/module.mjs +69 -0
- package/modules/strapi/proxy.mjs +54 -0
- package/modules/strapi/runtime/client.d.ts +30 -0
- package/modules/strapi/runtime/client.mjs +248 -0
- package/package.json +73 -77
- package/server/lib/handler.d.ts +1 -0
- package/server/lib/handler.mjs +43 -0
- package/server/lib/pages.d.ts +20 -0
- package/server/lib/pages.mjs +276 -0
- package/server/lib/render.d.ts +7 -0
- package/server/lib/render.mjs +156 -0
- package/server/plugins/00.lifecycle.d.ts +2 -0
- package/server/plugins/00.lifecycle.mjs +9 -0
- package/server/renderer.d.ts +3 -0
- package/server/renderer.mjs +14 -0
- package/server/routes/api/health.get.d.ts +2 -0
- package/server/routes/api/health.get.mjs +5 -0
- package/server.d.ts +1 -0
- package/server.mjs +32 -0
- package/src/main.d.ts +1 -0
- package/src/main.mjs +29 -0
- package/src/public/boot.d.ts +1 -0
- package/src/public/components.d.ts +1 -0
- package/src/public/components.mjs +1 -0
- package/src/public/head.d.ts +1 -0
- package/src/public/head.mjs +1 -0
- package/src/public/index.d.ts +5 -0
- package/src/public/index.mjs +2 -0
- package/src/public/modules/content.d.ts +2 -0
- package/src/public/modules/content.mjs +1 -0
- package/src/public/modules/sitemap.d.ts +2 -0
- package/src/public/modules/sitemap.mjs +1 -0
- package/src/public/modules/strapi.d.ts +2 -0
- package/src/public/modules/strapi.mjs +1 -0
- package/src/public/nitro.d.ts +6 -0
- package/src/public/nitro.mjs +78 -0
- package/src/public/shared.d.ts +2 -0
- package/src/public/shared.mjs +18 -0
- package/src/public/vite.d.ts +6 -0
- package/src/public/vite.mjs +273 -0
- package/src/public/vue.d.ts +1 -0
- package/src/public/vue.mjs +1 -0
- package/src/runtime/boot.d.ts +9 -0
- package/src/runtime/components/FlowIsland.d.ts +42 -0
- package/src/runtime/components/FlowIsland.mjs +35 -0
- package/src/runtime/config.d.ts +73 -0
- package/src/runtime/config.mjs +26 -0
- package/src/runtime/head.d.ts +3 -0
- package/src/runtime/head.mjs +7 -0
- package/src/runtime/islands.d.ts +2 -0
- package/src/runtime/islands.mjs +52 -0
- package/src/runtime/modules.d.ts +12 -0
- package/src/runtime/modules.mjs +115 -0
- package/src/runtime/page-discovery.d.ts +6 -0
- package/src/runtime/page-discovery.mjs +175 -0
- package/src/runtime/pages.d.ts +107 -0
- package/src/runtime/pages.mjs +3 -0
- package/src/runtime/ssg.d.ts +9 -0
- package/src/runtime/ssg.mjs +37 -0
- package/src/runtime/virtual-pages.d.ts +8 -0
- package/src/runtime/virtual-pages.mjs +151 -0
- package/src/runtime/virtual.d.ts +103 -0
- package/src/runtime/vite-assets.d.ts +9 -0
- package/src/runtime/vue.d.ts +6 -0
- package/src/runtime/vue.mjs +6 -0
- package/src/styles.css +1 -0
- package/app.d.ts +0 -1
- package/bin/flow.mjs +0 -2
- package/dist/app/composables/index.d.ts +0 -5
- package/dist/app/composables/index.mjs +0 -12
- package/dist/app/entry.async.d.ts +0 -3
- package/dist/app/entry.async.mjs +0 -1
- package/dist/app/entry.d.ts +0 -3
- package/dist/app/entry.mjs +0 -23
- package/dist/app/flow.d.ts +0 -80
- package/dist/app/flow.mjs +0 -88
- package/dist/app/index.d.ts +0 -3
- package/dist/app/index.mjs +0 -3
- package/dist/chunks/dev-bundler.mjs +0 -247
- package/dist/chunks/external.mjs +0 -37
- package/dist/chunks/index.mjs +0 -1140
- package/dist/chunks/vite-node.mjs +0 -155
- package/dist/core/runtime/client.manifest.d.mts +0 -2
- package/dist/core/runtime/client.manifest.mjs +0 -6
- package/dist/core/runtime/nitro/flow.d.ts +0 -3
- package/dist/core/runtime/nitro/flow.mjs +0 -33
- package/dist/core/runtime/nitro/paths.d.ts +0 -4
- package/dist/core/runtime/nitro/paths.mjs +0 -15
- package/dist/core/runtime/nitro/renderer.d.ts +0 -2
- package/dist/core/runtime/nitro/renderer.mjs +0 -101
- package/dist/core/runtime/vite-node-shared.d.mts +0 -1
- package/dist/core/runtime/vite-node-shared.d.ts +0 -8
- package/dist/core/runtime/vite-node-shared.mjs +0 -3
- package/dist/core/runtime/vite-node.d.mts +0 -2
- package/dist/core/runtime/vite-node.mjs +0 -42
- package/dist/head/runtime/composables.d.ts +0 -9
- package/dist/head/runtime/composables.mjs +0 -2
- package/dist/head/runtime/index.d.ts +0 -1
- package/dist/head/runtime/index.mjs +0 -1
- package/dist/head/runtime/plugin.mjs +0 -5
- package/dist/index.d.ts +0 -11
- package/dist/index.mjs +0 -27
- package/dist/pages/runtime/helpers/index.d.ts +0 -5
- package/dist/pages/runtime/helpers/index.mjs +0 -31
- package/dist/pages/runtime/index.d.ts +0 -10
- package/dist/pages/runtime/index.mjs +0 -13
- package/dist/pages/runtime/pages.mjs +0 -100
- package/dist/vite-client/runtime/injectManifest.d.ts +0 -26
- package/dist/vite-client/runtime/injectManifest.mjs +0 -110
- package/dist/vite-client/runtime/plugin.mjs +0 -28
- package/types.d.ts +0 -2
- /package/{dist/head/runtime/plugin.d.ts → modules/content/query.d.ts} +0 -0
- /package/{dist/pages/runtime/pages.d.ts → modules/sitemap/handler.d.ts} +0 -0
- /package/{dist/vite-client/runtime/plugin.d.ts → modules/strapi/proxy.d.ts} +0 -0
- /package/{dist/pages/runtime/helpers/chunks.d.ts → src/public/boot.mjs} +0 -0
- /package/{dist/pages/runtime/helpers/chunks.mjs → src/runtime/boot.mjs} +0 -0
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { pathToFileURL } from 'node:url';
|
|
2
|
-
import { createApp, defineEventHandler, defineLazyEventHandler, createError } from 'h3';
|
|
3
|
-
import { ViteNodeServer } from 'vite-node/server';
|
|
4
|
-
import fse from 'fs-extra';
|
|
5
|
-
import { resolve as resolve$1 } from 'pathe';
|
|
6
|
-
import { addServerMiddleware } from '@monkeyplus/flow-kit';
|
|
7
|
-
import { normalizeViteManifest } from 'vue-bundle-renderer';
|
|
8
|
-
import { resolve } from 'mlly';
|
|
9
|
-
import { d as distDir } from './index.mjs';
|
|
10
|
-
import { c as createIsExternal, i as isCSS } from './external.mjs';
|
|
11
|
-
import 'hookable';
|
|
12
|
-
import 'url';
|
|
13
|
-
import 'unimport';
|
|
14
|
-
import 'unplugin';
|
|
15
|
-
import 'ufo';
|
|
16
|
-
import 'fs';
|
|
17
|
-
import 'escape-string-regexp';
|
|
18
|
-
import 'scule';
|
|
19
|
-
import 'knitwork';
|
|
20
|
-
import 'consola';
|
|
21
|
-
import 'vite';
|
|
22
|
-
import 'perfect-debounce';
|
|
23
|
-
import 'node:fs';
|
|
24
|
-
import 'nitropack';
|
|
25
|
-
import 'defu';
|
|
26
|
-
import 'node:module';
|
|
27
|
-
import 'chokidar';
|
|
28
|
-
import 'untyped';
|
|
29
|
-
import '@rollup/plugin-replace';
|
|
30
|
-
import 'pkg-types';
|
|
31
|
-
import 'ohash';
|
|
32
|
-
import 'externality';
|
|
33
|
-
|
|
34
|
-
function viteNodePlugin(ctx) {
|
|
35
|
-
const invalidates = /* @__PURE__ */ new Set();
|
|
36
|
-
return {
|
|
37
|
-
name: "nuxt:vite-node-server",
|
|
38
|
-
enforce: "post",
|
|
39
|
-
configureServer(server) {
|
|
40
|
-
server.middlewares.use("/__nuxt_vite_node__", createViteNodeMiddleware(ctx, invalidates));
|
|
41
|
-
},
|
|
42
|
-
handleHotUpdate({ file, server }) {
|
|
43
|
-
function markInvalidate(mod) {
|
|
44
|
-
if (invalidates.has(mod.id))
|
|
45
|
-
return;
|
|
46
|
-
invalidates.add(mod.id);
|
|
47
|
-
for (const importer of mod.importers)
|
|
48
|
-
markInvalidate(importer);
|
|
49
|
-
}
|
|
50
|
-
const mods = server.moduleGraph.getModulesByFile(file) || [];
|
|
51
|
-
for (const mod of mods)
|
|
52
|
-
markInvalidate(mod);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
function registerViteNodeMiddleware(ctx) {
|
|
57
|
-
addServerMiddleware({
|
|
58
|
-
route: "/__nuxt_vite_node__/",
|
|
59
|
-
handler: createViteNodeMiddleware(ctx)
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
function getManifest(ctx) {
|
|
63
|
-
const css = Array.from(ctx.ssrServer.moduleGraph.urlToModuleMap.keys()).filter((i) => isCSS(i));
|
|
64
|
-
const manifest = normalizeViteManifest({
|
|
65
|
-
"@vite/client": {
|
|
66
|
-
file: "@vite/client",
|
|
67
|
-
css,
|
|
68
|
-
module: true,
|
|
69
|
-
isEntry: true
|
|
70
|
-
},
|
|
71
|
-
[ctx.entry]: {
|
|
72
|
-
file: ctx.entry,
|
|
73
|
-
isEntry: true,
|
|
74
|
-
module: true,
|
|
75
|
-
resourceType: "script"
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
return manifest;
|
|
79
|
-
}
|
|
80
|
-
function createViteNodeMiddleware(ctx, invalidates = /* @__PURE__ */ new Set()) {
|
|
81
|
-
const app = createApp();
|
|
82
|
-
app.use("/manifest", defineEventHandler(() => {
|
|
83
|
-
const manifest = getManifest(ctx);
|
|
84
|
-
return manifest;
|
|
85
|
-
}));
|
|
86
|
-
app.use("/invalidates", defineEventHandler(() => {
|
|
87
|
-
if (invalidates.size) {
|
|
88
|
-
for (const key of ctx.ssrServer.moduleGraph.fileToModulesMap.keys()) {
|
|
89
|
-
if (key.startsWith(`${ctx.nuxt.options.appDir}/entry`))
|
|
90
|
-
invalidates.add(key);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
const ids = Array.from(invalidates);
|
|
94
|
-
invalidates.clear();
|
|
95
|
-
return ids;
|
|
96
|
-
}));
|
|
97
|
-
app.use("/module", defineLazyEventHandler(() => {
|
|
98
|
-
const viteServer = ctx.ssrServer;
|
|
99
|
-
const node = new ViteNodeServer(viteServer, {
|
|
100
|
-
deps: {
|
|
101
|
-
inline: [
|
|
102
|
-
/\/(nuxt|nuxt3)\//,
|
|
103
|
-
/^#/,
|
|
104
|
-
...ctx.nuxt.options.build.transpile
|
|
105
|
-
]
|
|
106
|
-
},
|
|
107
|
-
transformMode: {
|
|
108
|
-
ssr: [/.*/],
|
|
109
|
-
web: []
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
const isExternal = createIsExternal(viteServer, ctx.nuxt.options.rootDir);
|
|
113
|
-
node.shouldExternalize = async (id) => {
|
|
114
|
-
const result = await isExternal(id);
|
|
115
|
-
if (result?.external)
|
|
116
|
-
return resolve(result.id, { url: ctx.nuxt.options.rootDir });
|
|
117
|
-
return false;
|
|
118
|
-
};
|
|
119
|
-
return async (event) => {
|
|
120
|
-
const moduleId = decodeURI(event.req.url).substring(1);
|
|
121
|
-
if (moduleId === "/")
|
|
122
|
-
throw createError({ statusCode: 400 });
|
|
123
|
-
const module = await node.fetchModule(moduleId);
|
|
124
|
-
return module;
|
|
125
|
-
};
|
|
126
|
-
}));
|
|
127
|
-
return app.nodeHandler;
|
|
128
|
-
}
|
|
129
|
-
async function initViteNodeServer(ctx) {
|
|
130
|
-
let entryPath = resolve$1(ctx.nuxt.options.appDir, "entry.async.mjs");
|
|
131
|
-
if (!fse.existsSync(entryPath))
|
|
132
|
-
entryPath = resolve$1(ctx.nuxt.options.appDir, "entry.async.ts");
|
|
133
|
-
const host = ctx.nuxt.options.server.host || "localhost";
|
|
134
|
-
const port = ctx.nuxt.options.server.port || "3000";
|
|
135
|
-
const protocol = ctx.nuxt.options.server.https ? "https" : "http";
|
|
136
|
-
const viteNodeServerOptions = {
|
|
137
|
-
baseURL: `${protocol}://${host}:${port}/__nuxt_vite_node__`,
|
|
138
|
-
root: ctx.nuxt.options.srcDir,
|
|
139
|
-
entryPath,
|
|
140
|
-
base: ctx.ssrServer.config.base || "/_nuxt/"
|
|
141
|
-
};
|
|
142
|
-
process.env.NUXT_VITE_NODE_OPTIONS = JSON.stringify(viteNodeServerOptions);
|
|
143
|
-
const serverResolvedPath = resolve$1(distDir, "core/runtime/vite-node.mjs");
|
|
144
|
-
const manifestResolvedPath = resolve$1(distDir, "core/runtime/client.manifest.mjs");
|
|
145
|
-
await fse.writeFile(
|
|
146
|
-
resolve$1(ctx.nuxt.options.buildDir, "dist/server/server.mjs"),
|
|
147
|
-
`export { default } from ${JSON.stringify(pathToFileURL(serverResolvedPath).href)}`
|
|
148
|
-
);
|
|
149
|
-
await fse.writeFile(
|
|
150
|
-
resolve$1(ctx.nuxt.options.buildDir, "dist/server/client.manifest.mjs"),
|
|
151
|
-
`export { default } from ${JSON.stringify(pathToFileURL(manifestResolvedPath).href)}`
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export { initViteNodeServer, registerViteNodeMiddleware, viteNodePlugin };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import "node-fetch-native/polyfill";
|
|
2
|
-
import { defineEventHandler } from "h3";
|
|
3
|
-
import { defineCachedFunction, useRuntimeConfig } from "#internal/nitro";
|
|
4
|
-
const getServerApp = cachedImport(() => import("#server"));
|
|
5
|
-
const getFlowRenderer = cachedResult(async () => {
|
|
6
|
-
const createFlowApp = await getServerApp();
|
|
7
|
-
if (!createFlowApp)
|
|
8
|
-
throw new Error("Server bundle is not available");
|
|
9
|
-
return createFlowApp(useRuntimeConfig());
|
|
10
|
-
});
|
|
11
|
-
export default defineEventHandler(async ({ context }) => {
|
|
12
|
-
const flow = await getFlowRenderer();
|
|
13
|
-
context.flow = flow;
|
|
14
|
-
context.render = flow.render;
|
|
15
|
-
context.defineCachedFunction = defineCachedFunction;
|
|
16
|
-
});
|
|
17
|
-
function _interopDefault(e) {
|
|
18
|
-
return e && typeof e === "object" && "default" in e ? e.default : e;
|
|
19
|
-
}
|
|
20
|
-
function cachedImport(importer) {
|
|
21
|
-
return cachedResult(() => importer().then(_interopDefault).then(_interopDefault));
|
|
22
|
-
}
|
|
23
|
-
function cachedResult(fn) {
|
|
24
|
-
let res = null;
|
|
25
|
-
return () => {
|
|
26
|
-
if (res === null)
|
|
27
|
-
res = fn().catch((err) => {
|
|
28
|
-
res = null;
|
|
29
|
-
throw err;
|
|
30
|
-
});
|
|
31
|
-
return res;
|
|
32
|
-
};
|
|
33
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { joinURL } from "ufo";
|
|
2
|
-
import { useRuntimeConfig } from "#internal/nitro";
|
|
3
|
-
export function baseURL() {
|
|
4
|
-
return useRuntimeConfig().app.baseURL;
|
|
5
|
-
}
|
|
6
|
-
export function buildAssetsDir() {
|
|
7
|
-
return useRuntimeConfig().app.buildAssetsDir;
|
|
8
|
-
}
|
|
9
|
-
export function buildAssetsURL(...path) {
|
|
10
|
-
return joinURL(publicAssetsURL(), useRuntimeConfig().app.buildAssetsDir, ...path);
|
|
11
|
-
}
|
|
12
|
-
export function publicAssetsURL(...path) {
|
|
13
|
-
const publicBase = useRuntimeConfig().app.cdnURL || useRuntimeConfig().app.baseURL;
|
|
14
|
-
return path.length ? joinURL(publicBase, ...path) : publicBase;
|
|
15
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { eventHandler, useQuery } from "h3";
|
|
2
|
-
import { joinURL } from "ufo";
|
|
3
|
-
const normalizeCall = async (seo, ctx) => {
|
|
4
|
-
if (typeof seo === "function")
|
|
5
|
-
return await seo(ctx);
|
|
6
|
-
return seo || {};
|
|
7
|
-
};
|
|
8
|
-
export default eventHandler(async (event) => {
|
|
9
|
-
const url = event.req.url?.split("?")[0];
|
|
10
|
-
const flow = event.context.flow;
|
|
11
|
-
if (url.includes("_urls")) {
|
|
12
|
-
const urls = await flow.app.utils.getUrls();
|
|
13
|
-
return urls;
|
|
14
|
-
}
|
|
15
|
-
const scripts = { head: [], bodyStart: [], bodyEnd: [] };
|
|
16
|
-
const chunks = { head: [], body: [] };
|
|
17
|
-
const generate = {};
|
|
18
|
-
const { page, locale, params, view, name: pageName } = flow.router.byUrl.lookup(url) || {};
|
|
19
|
-
if (!page)
|
|
20
|
-
return;
|
|
21
|
-
if (view.bundle)
|
|
22
|
-
await flow.callHook("page:chunks", view.bundle, chunks);
|
|
23
|
-
const templateContext = {};
|
|
24
|
-
const dynamic = params?._;
|
|
25
|
-
const contextPage = {
|
|
26
|
-
chunks,
|
|
27
|
-
locale
|
|
28
|
-
};
|
|
29
|
-
const contextInject = {};
|
|
30
|
-
const utils = Object.assign({ getLocale: () => locale, injectContext: (key, value) => contextInject[key] = value, defineCachedFunction: event.context.defineCachedFunction }, flow.app.utils);
|
|
31
|
-
const contextHooks = {};
|
|
32
|
-
await flow.callHook("page:context", { localeCode: locale.code, page: pageName }, utils, contextHooks);
|
|
33
|
-
templateContext.url = url;
|
|
34
|
-
templateContext.baseURL = flow.$config.app.baseURL;
|
|
35
|
-
const pageObject = {
|
|
36
|
-
name: pageName,
|
|
37
|
-
pathname: url,
|
|
38
|
-
url: joinURL(flow.site.origin, templateContext.baseURL, `${url}`),
|
|
39
|
-
origin: flow.site.origin,
|
|
40
|
-
joinOrigin: (_url, includeBase) => joinURL(flow.site.origin, includeBase ? templateContext.baseURL : "/", _url)
|
|
41
|
-
};
|
|
42
|
-
templateContext.page = pageObject;
|
|
43
|
-
contextPage.page = pageObject;
|
|
44
|
-
templateContext.locale = locale;
|
|
45
|
-
templateContext.view = view;
|
|
46
|
-
if (dynamic && page.dynamic) {
|
|
47
|
-
const pages = await page.dynamic.method({ locale, utils });
|
|
48
|
-
const dynamicPage = pages.find((_page) => _page.url === dynamic);
|
|
49
|
-
if (!dynamicPage)
|
|
50
|
-
return;
|
|
51
|
-
if (page.dynamic.assign)
|
|
52
|
-
templateContext[page.dynamic.assign] = dynamicPage.context;
|
|
53
|
-
contextPage.dynamic = dynamicPage;
|
|
54
|
-
}
|
|
55
|
-
templateContext.seo = {};
|
|
56
|
-
const sharedContext = await utils.getSharedContext({
|
|
57
|
-
...contextHooks,
|
|
58
|
-
...contextPage,
|
|
59
|
-
utils
|
|
60
|
-
});
|
|
61
|
-
templateContext.sharedContext = sharedContext || {};
|
|
62
|
-
templateContext.utils = utils;
|
|
63
|
-
templateContext.seo = await normalizeCall(page?.seo, { ...contextHooks, ...contextPage, utils, sharedContext });
|
|
64
|
-
const contexData = await page.context?.({ ...contextHooks, ...contextPage, utils, sharedContext }) || {};
|
|
65
|
-
templateContext.context = {
|
|
66
|
-
...contextHooks,
|
|
67
|
-
...contexData
|
|
68
|
-
};
|
|
69
|
-
await flow.callHook("page:scripts", scripts, templateContext);
|
|
70
|
-
templateContext.getHeadScripts = () => {
|
|
71
|
-
return scripts.head.join("\n");
|
|
72
|
-
};
|
|
73
|
-
templateContext.getBodyEndScripts = () => {
|
|
74
|
-
return scripts.bodyEnd.join("\n");
|
|
75
|
-
};
|
|
76
|
-
templateContext.getHeadChunks = () => {
|
|
77
|
-
return chunks.head.join("\n");
|
|
78
|
-
};
|
|
79
|
-
templateContext.getBodyChunks = () => {
|
|
80
|
-
return chunks.body.join("\n");
|
|
81
|
-
};
|
|
82
|
-
templateContext.getInjectContext = () => {
|
|
83
|
-
return `<script id="__FLOW_DATA__" type="application/json">${JSON.stringify(contextInject)}<\/script>`;
|
|
84
|
-
};
|
|
85
|
-
const query = useQuery(event);
|
|
86
|
-
if (query?.context)
|
|
87
|
-
return { ...templateContext, utils: Object.keys(utils) };
|
|
88
|
-
let html;
|
|
89
|
-
if (view.render)
|
|
90
|
-
html = await view.render(templateContext, event);
|
|
91
|
-
else
|
|
92
|
-
html = await flow.render(view, templateContext);
|
|
93
|
-
event.res.setHeader("Content-Type", view.contentType || "text/html;charset=UTF-8");
|
|
94
|
-
if (view.postRender)
|
|
95
|
-
html = await view.postRender(html, event);
|
|
96
|
-
if (flow.generate) {
|
|
97
|
-
await flow.callHook("page:generate", generate);
|
|
98
|
-
globalThis.generate = generate;
|
|
99
|
-
}
|
|
100
|
-
return html;
|
|
101
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function getViteNodeOptions(): any;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { performance } from 'node:perf_hooks';
|
|
2
|
-
import { ViteNodeRunner } from 'vite-node/client';
|
|
3
|
-
import { $fetch } from 'ohmyfetch';
|
|
4
|
-
import consola from 'consola';
|
|
5
|
-
import { getViteNodeOptions } from './vite-node-shared.mjs';
|
|
6
|
-
|
|
7
|
-
const viteNodeOptions = getViteNodeOptions();
|
|
8
|
-
console.log(viteNodeOptions);
|
|
9
|
-
const runner = new ViteNodeRunner({
|
|
10
|
-
root: viteNodeOptions.root, // Equals to Nuxt `srcDir`
|
|
11
|
-
base: viteNodeOptions.base,
|
|
12
|
-
async fetchModule(id) {
|
|
13
|
-
return await $fetch(`/module/${encodeURI(id)}`, {
|
|
14
|
-
baseURL: viteNodeOptions.baseURL,
|
|
15
|
-
});
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
let render;
|
|
20
|
-
|
|
21
|
-
export default async(ssrContext) => {
|
|
22
|
-
// Workaround for stub mode
|
|
23
|
-
// https://github.com/nuxt/framework/pull/3983
|
|
24
|
-
process.server = true;
|
|
25
|
-
|
|
26
|
-
// Invalidate cache for files changed since last rendering
|
|
27
|
-
const invalidates = await $fetch('/invalidates', {
|
|
28
|
-
baseURL: viteNodeOptions.baseURL,
|
|
29
|
-
});
|
|
30
|
-
const updates = runner.moduleCache.invalidateDepTree(invalidates);
|
|
31
|
-
|
|
32
|
-
// Execute SSR bundle on demand
|
|
33
|
-
const start = performance.now();
|
|
34
|
-
render = render || (await runner.executeFile(viteNodeOptions.entryPath)).default;
|
|
35
|
-
if (updates.size) {
|
|
36
|
-
const time = Math.round((performance.now() - start) * 1000) / 1000;
|
|
37
|
-
consola.success(`Vite server hmr ${updates.size} files`, time ? `in ${time}ms` : '');
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const result = await render(ssrContext);
|
|
41
|
-
return result;
|
|
42
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { MetaObject } from '@monkeyplus/flow-schema';
|
|
2
|
-
/**
|
|
3
|
-
* You can pass in a meta object, which has keys corresponding to meta tags:
|
|
4
|
-
* `title`, `base`, `script`, `style`, `meta` and `link`, as well as `htmlAttrs` and `bodyAttrs`.
|
|
5
|
-
*
|
|
6
|
-
* Alternatively, for reactive meta state, you can pass in a function
|
|
7
|
-
* that returns a meta object.
|
|
8
|
-
*/
|
|
9
|
-
export declare function useHead(meta: MetaObject): void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './composables';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./composables.mjs";
|
package/dist/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { FlowOptions, Flow, FlowConfig } from '@monkeyplus/flow-schema';
|
|
2
|
-
export { FlowConfig } from '@monkeyplus/flow-schema';
|
|
3
|
-
import { LoadFlowOptions } from '@monkeyplus/flow-kit';
|
|
4
|
-
|
|
5
|
-
declare function createFlow(options: FlowOptions): Flow;
|
|
6
|
-
declare function loadFlow(opts: LoadFlowOptions): Promise<Flow>;
|
|
7
|
-
declare function defineFlowConfig(config: FlowConfig): FlowConfig;
|
|
8
|
-
|
|
9
|
-
declare function build(flow: Flow): Promise<void>;
|
|
10
|
-
|
|
11
|
-
export { build, createFlow, defineFlowConfig, loadFlow };
|
package/dist/index.mjs
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export { b as build, c as createFlow, a as defineFlowConfig, l as loadFlow } from './chunks/index.mjs';
|
|
2
|
-
import 'hookable';
|
|
3
|
-
import 'pathe';
|
|
4
|
-
import '@monkeyplus/flow-kit';
|
|
5
|
-
import 'url';
|
|
6
|
-
import 'unimport';
|
|
7
|
-
import 'node:url';
|
|
8
|
-
import 'unplugin';
|
|
9
|
-
import 'ufo';
|
|
10
|
-
import 'fs';
|
|
11
|
-
import 'escape-string-regexp';
|
|
12
|
-
import 'scule';
|
|
13
|
-
import 'knitwork';
|
|
14
|
-
import 'fs-extra';
|
|
15
|
-
import 'consola';
|
|
16
|
-
import 'vite';
|
|
17
|
-
import 'perfect-debounce';
|
|
18
|
-
import 'node:fs';
|
|
19
|
-
import 'nitropack';
|
|
20
|
-
import 'defu';
|
|
21
|
-
import 'h3';
|
|
22
|
-
import 'node:module';
|
|
23
|
-
import 'chokidar';
|
|
24
|
-
import 'untyped';
|
|
25
|
-
import '@rollup/plugin-replace';
|
|
26
|
-
import 'mlly';
|
|
27
|
-
import 'pkg-types';
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { joinURL, withTrailingSlash } from "ufo";
|
|
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]);
|
|
7
|
-
return locales.map(([locale, localePage]) => {
|
|
8
|
-
const [_language, _location] = locale.split("-");
|
|
9
|
-
const name = joinURL("/", _location, _language, page.name);
|
|
10
|
-
const defLocation = _location === location ? "" : _location;
|
|
11
|
-
const defLanguage = _language === language ? "" : _language;
|
|
12
|
-
const url = joinURL("/", defLocation, defLanguage, localePage.url);
|
|
13
|
-
const _locale = {
|
|
14
|
-
lang: _language,
|
|
15
|
-
loc: _location,
|
|
16
|
-
code: locale
|
|
17
|
-
};
|
|
18
|
-
const path = localePage.url.endsWith("/") ? withTrailingSlash(url) : url;
|
|
19
|
-
return {
|
|
20
|
-
name,
|
|
21
|
-
url: path,
|
|
22
|
-
context: { page: localePage, locale: _locale, path, view: page.view, name: page.name }
|
|
23
|
-
};
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
export function definePage(page) {
|
|
27
|
-
return {
|
|
28
|
-
pages: [],
|
|
29
|
-
getPages: buildPages(page)
|
|
30
|
-
};
|
|
31
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
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,13 +0,0 @@
|
|
|
1
|
-
export function definePage(...pages) {
|
|
2
|
-
return pages;
|
|
3
|
-
}
|
|
4
|
-
export function defineDynamicPage(...pages) {
|
|
5
|
-
return pages.map((page) => {
|
|
6
|
-
if (!page.name.endsWith("/**"))
|
|
7
|
-
page.name = `${page.name}/**`;
|
|
8
|
-
return page;
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
export function defineSharedContext(shared) {
|
|
12
|
-
return shared;
|
|
13
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
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
|
-
flow.router.byName.insert(page2.name, page2.context);
|
|
27
|
-
allPages.push(page2.context);
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
const cache = {};
|
|
32
|
-
async function getUrl(namePage, localeCode) {
|
|
33
|
-
const code = localeCode || this?.getLocale()?.code;
|
|
34
|
-
const [lang, loc] = code.split("-");
|
|
35
|
-
const name = joinURL("/", loc, lang, namePage);
|
|
36
|
-
const { path, params, page } = flow.router.byName.lookup(name) || {};
|
|
37
|
-
if (params?._ && page.dynamic) {
|
|
38
|
-
if (!cache[path]) {
|
|
39
|
-
cache[path] = this.defineCachedFunction(async (_ctx) => {
|
|
40
|
-
return await page.dynamic.method(_ctx);
|
|
41
|
-
}, { maxAge: 8, getKey: () => path, swr: false });
|
|
42
|
-
}
|
|
43
|
-
const fn = cache[path];
|
|
44
|
-
const list = await fn({ utils: this, locale: this.getLocale() });
|
|
45
|
-
const dPage = list.find((el) => el.name === params._);
|
|
46
|
-
return dPage ? path.replace("**", dPage.url) : "/404";
|
|
47
|
-
}
|
|
48
|
-
return path || "/404";
|
|
49
|
-
}
|
|
50
|
-
async function getUrls(withLocale = false) {
|
|
51
|
-
const urls = [];
|
|
52
|
-
for (const page of allPages) {
|
|
53
|
-
if (page.path.includes("/**") && page.page.dynamic) {
|
|
54
|
-
const dPages = await page.page.dynamic.method({
|
|
55
|
-
locale: page.locale,
|
|
56
|
-
utils: Object.assign({ getLocale: () => page.locale }, flow.app.utils),
|
|
57
|
-
chunks: {},
|
|
58
|
-
page: {}
|
|
59
|
-
});
|
|
60
|
-
dPages.forEach((dPage) => {
|
|
61
|
-
const _path = joinURL(page.path.replace("/**", ""), dPage.url);
|
|
62
|
-
urls.push(withLocale ? { url: _path, locale: page.locale.code, name: joinURL(page.name, dPage.name) } : _path);
|
|
63
|
-
});
|
|
64
|
-
} else {
|
|
65
|
-
const url = page.path.replaceAll("*", "");
|
|
66
|
-
urls.push(withLocale ? { url, locale: page.locale.code, name: page.name } : url);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return urls.sort();
|
|
70
|
-
}
|
|
71
|
-
async function getSharedContext(ctx) {
|
|
72
|
-
const entries = Object.entries(contexts);
|
|
73
|
-
if (!entries.length)
|
|
74
|
-
return {};
|
|
75
|
-
const _contexts = await Promise.all(entries.map(async ([key, method]) => {
|
|
76
|
-
const data = await method.setup(ctx);
|
|
77
|
-
const setupLocal = method?.locales?.[ctx.locale.code];
|
|
78
|
-
let dataLocal = {};
|
|
79
|
-
if (setupLocal)
|
|
80
|
-
dataLocal = await setupLocal(ctx);
|
|
81
|
-
const obj = method.merge ? { ...data, ...dataLocal } : { [key]: { ...data, ...dataLocal } };
|
|
82
|
-
return obj;
|
|
83
|
-
}));
|
|
84
|
-
return _contexts.reduce((acc, curr) => {
|
|
85
|
-
return {
|
|
86
|
-
...acc,
|
|
87
|
-
...curr
|
|
88
|
-
};
|
|
89
|
-
}, {});
|
|
90
|
-
}
|
|
91
|
-
flow.setUtil("getUrl", getUrl);
|
|
92
|
-
flow.setUtil("getUrls", getUrls);
|
|
93
|
-
flow.setUtil("getPages", () => allPages);
|
|
94
|
-
flow.setUtil("getSharedContext", getSharedContext);
|
|
95
|
-
return {
|
|
96
|
-
provide: {
|
|
97
|
-
pages: { allPages }
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
});
|
|
@@ -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;
|