@monkeyplus/flow 5.0.0-rc.98 → 6.0.0
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
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { defineNitroConfig } from "nitro/config";
|
|
3
|
+
import { resolveFlowConfig } from "../runtime/config.ts";
|
|
4
|
+
import { loadFlowModules } from "../runtime/modules.ts";
|
|
5
|
+
import { createFlowBuildHooks } from "../runtime/ssg.ts";
|
|
6
|
+
import {
|
|
7
|
+
createVirtualBaseTemplatesModule,
|
|
8
|
+
createVirtualIslandsModule,
|
|
9
|
+
createVirtualLayoutsModule,
|
|
10
|
+
createVirtualPagesModule,
|
|
11
|
+
createVirtualTemplatesModule
|
|
12
|
+
} from "../runtime/virtual-pages.ts";
|
|
13
|
+
import { resolvePackageFile } from "./shared.ts";
|
|
14
|
+
export function createFlowNitroConfig(options = {}) {
|
|
15
|
+
const projectRoot = resolve(options.projectRoot || process.cwd());
|
|
16
|
+
const flowConfig = resolveFlowConfig(options.userFlowConfig || {});
|
|
17
|
+
const flowModules = loadFlowModules(projectRoot, flowConfig);
|
|
18
|
+
const flowNitroConfig = { ...flowConfig.nitro || {} };
|
|
19
|
+
const flowNitroHooks = flowNitroConfig.hooks || {};
|
|
20
|
+
const flowRuntimeConfig = typeof flowModules.nitro.runtimeConfig.flow === "object" && flowModules.nitro.runtimeConfig.flow ? flowModules.nitro.runtimeConfig.flow : {};
|
|
21
|
+
const moduleRuntimeConfig = { ...flowModules.nitro.runtimeConfig };
|
|
22
|
+
delete moduleRuntimeConfig.flow;
|
|
23
|
+
return defineNitroConfig({
|
|
24
|
+
compatibilityDate: "2026-04-02",
|
|
25
|
+
builder: "vite",
|
|
26
|
+
renderer: {
|
|
27
|
+
handler: resolvePackageFile("server/renderer.ts", "server/renderer.mjs", "server/renderer.js")
|
|
28
|
+
},
|
|
29
|
+
framework: {
|
|
30
|
+
name: "@monkeyplus/flow",
|
|
31
|
+
version: "6.0.0"
|
|
32
|
+
},
|
|
33
|
+
serverDir: "./server",
|
|
34
|
+
devServer: {
|
|
35
|
+
watch: [
|
|
36
|
+
resolve(projectRoot, "flow.config.ts"),
|
|
37
|
+
resolve(projectRoot, "pages"),
|
|
38
|
+
resolve(projectRoot, "client"),
|
|
39
|
+
resolve(projectRoot, "views")
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
serverEntry: resolvePackageFile("server.ts", "server.mjs", "server.js"),
|
|
43
|
+
virtual: {
|
|
44
|
+
"virtual:flow/pages": createVirtualPagesModule(projectRoot, flowConfig),
|
|
45
|
+
"virtual:flow/islands": createVirtualIslandsModule(projectRoot),
|
|
46
|
+
"virtual:flow/templates": createVirtualTemplatesModule(projectRoot),
|
|
47
|
+
"virtual:flow/layouts": createVirtualLayoutsModule(projectRoot),
|
|
48
|
+
"virtual:flow/bases": createVirtualBaseTemplatesModule(projectRoot),
|
|
49
|
+
...flowModules.nitro.virtual
|
|
50
|
+
},
|
|
51
|
+
hooks: createFlowBuildHooks({
|
|
52
|
+
projectRoot,
|
|
53
|
+
flowConfig,
|
|
54
|
+
modulePrerenderRoutes: flowModules.prerenderRoutes,
|
|
55
|
+
existingHooks: flowNitroHooks
|
|
56
|
+
}),
|
|
57
|
+
plugins: flowModules.nitro.plugins,
|
|
58
|
+
handlers: flowModules.nitro.handlers,
|
|
59
|
+
routeRules: {
|
|
60
|
+
"/api/**": { cors: true },
|
|
61
|
+
...flowModules.nitro.routeRules
|
|
62
|
+
},
|
|
63
|
+
runtimeConfig: {
|
|
64
|
+
app: {
|
|
65
|
+
name: "@monkeyplus/flow",
|
|
66
|
+
version: "6.0.0"
|
|
67
|
+
},
|
|
68
|
+
flow: {
|
|
69
|
+
build: flowConfig.build,
|
|
70
|
+
dir: flowConfig.dir,
|
|
71
|
+
locale: flowConfig.locale,
|
|
72
|
+
siteUrl: flowConfig.siteUrl,
|
|
73
|
+
...flowRuntimeConfig
|
|
74
|
+
},
|
|
75
|
+
...moduleRuntimeConfig
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { accessSync, constants } from "node:fs";
|
|
2
|
+
import { dirname, resolve } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
const publicDir = dirname(fileURLToPath(import.meta.url));
|
|
5
|
+
export function resolvePackagePath(...segments) {
|
|
6
|
+
return resolve(publicDir, "..", "..", ...segments);
|
|
7
|
+
}
|
|
8
|
+
export function resolvePackageFile(...candidates) {
|
|
9
|
+
for (const candidate of candidates) {
|
|
10
|
+
const absolutePath = resolvePackagePath(candidate);
|
|
11
|
+
try {
|
|
12
|
+
accessSync(absolutePath, constants.F_OK);
|
|
13
|
+
return absolutePath;
|
|
14
|
+
} catch {
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return resolvePackagePath(candidates[0] || "");
|
|
18
|
+
}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { relative, resolve } from "node:path";
|
|
3
|
+
import Vue from "@vitejs/plugin-vue";
|
|
4
|
+
import { nitro } from "nitro/vite";
|
|
5
|
+
import { defineConfig, normalizePath } from "vite";
|
|
6
|
+
import IconsResolver from "unplugin-icons/resolver";
|
|
7
|
+
import Icons from "unplugin-icons/vite";
|
|
8
|
+
import ui from "@nuxt/ui/vite";
|
|
9
|
+
import { resolveFlowConfig } from "../runtime/config.ts";
|
|
10
|
+
import { loadFlowModules } from "../runtime/modules.ts";
|
|
11
|
+
import { getPrerenderRoutes } from "../runtime/page-discovery.ts";
|
|
12
|
+
import {
|
|
13
|
+
createVirtualBaseTemplatesModule,
|
|
14
|
+
createVirtualClientPageAssetsModule,
|
|
15
|
+
createVirtualClientPagesModule,
|
|
16
|
+
createVirtualIslandsModule,
|
|
17
|
+
createVirtualLayoutsModule,
|
|
18
|
+
createVirtualPagesModule,
|
|
19
|
+
createVirtualTemplatesModule
|
|
20
|
+
} from "../runtime/virtual-pages.ts";
|
|
21
|
+
const flowRestartPatterns = [
|
|
22
|
+
/^flow\.config\.ts$/,
|
|
23
|
+
/^nitro\.config\.ts$/,
|
|
24
|
+
/^vite\.config\.ts$/,
|
|
25
|
+
/^pages\/.+\.ts$/,
|
|
26
|
+
/^views\/templates\/.+\.vue$/,
|
|
27
|
+
/^views\/layouts\/.+\.vue$/,
|
|
28
|
+
/^views\/base\/.+\.html$/,
|
|
29
|
+
/^server\/.+\.(ts|js|mjs|mts)$/,
|
|
30
|
+
/^server\.ts$/,
|
|
31
|
+
/^entry-server\.ts$/
|
|
32
|
+
];
|
|
33
|
+
const flowFullReloadPatterns = [
|
|
34
|
+
/^client\/pages\/.+\.ts$/,
|
|
35
|
+
/^client\/islands\/.+\.ts$/
|
|
36
|
+
];
|
|
37
|
+
const flowStructureReloadPatterns = [
|
|
38
|
+
/^pages\/.+\.ts$/,
|
|
39
|
+
/^views\/templates\/.+\.vue$/,
|
|
40
|
+
/^views\/layouts\/.+\.vue$/,
|
|
41
|
+
/^views\/base\/.+\.html$/,
|
|
42
|
+
/^client\/pages\/.+\.ts$/,
|
|
43
|
+
/^client\/islands\/.+\.(ts|vue)$/
|
|
44
|
+
];
|
|
45
|
+
function matchesAny(patterns, value) {
|
|
46
|
+
return patterns.some((pattern) => pattern.test(value));
|
|
47
|
+
}
|
|
48
|
+
function getVirtualModuleIdsForPath(projectPath) {
|
|
49
|
+
const ids = /* @__PURE__ */ new Set();
|
|
50
|
+
if (projectPath === "flow.config.ts" || projectPath.startsWith("pages/")) {
|
|
51
|
+
ids.add("virtual:flow/pages");
|
|
52
|
+
}
|
|
53
|
+
if (projectPath.startsWith("views/templates/")) {
|
|
54
|
+
ids.add("virtual:flow/templates");
|
|
55
|
+
}
|
|
56
|
+
if (projectPath.startsWith("views/layouts/")) {
|
|
57
|
+
ids.add("virtual:flow/layouts");
|
|
58
|
+
}
|
|
59
|
+
if (projectPath.startsWith("views/base/")) {
|
|
60
|
+
ids.add("virtual:flow/bases");
|
|
61
|
+
}
|
|
62
|
+
if (projectPath.startsWith("client/pages/")) {
|
|
63
|
+
ids.add("virtual:flow/client-pages");
|
|
64
|
+
ids.add("virtual:flow/client-page-assets");
|
|
65
|
+
}
|
|
66
|
+
if (projectPath.startsWith("client/islands/")) {
|
|
67
|
+
ids.add("virtual:flow/islands");
|
|
68
|
+
}
|
|
69
|
+
return [...ids];
|
|
70
|
+
}
|
|
71
|
+
function invalidateVirtualModules(server, projectPath) {
|
|
72
|
+
const ids = getVirtualModuleIdsForPath(projectPath);
|
|
73
|
+
for (const id of ids) {
|
|
74
|
+
for (const candidate of [id, `\0${id}`]) {
|
|
75
|
+
const mod = server.moduleGraph.getModuleById(candidate);
|
|
76
|
+
if (mod) {
|
|
77
|
+
server.moduleGraph.invalidateModule(mod);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function invalidateFileModules(server, filePath, event) {
|
|
83
|
+
const normalizedFile = normalizePath(filePath);
|
|
84
|
+
if (event === "unlink") {
|
|
85
|
+
server.moduleGraph.onFileDelete(normalizedFile);
|
|
86
|
+
for (const environment of Object.values(server.environments)) {
|
|
87
|
+
environment.moduleGraph.onFileDelete(normalizedFile);
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
server.moduleGraph.onFileChange(normalizedFile);
|
|
92
|
+
for (const environment of Object.values(server.environments)) {
|
|
93
|
+
environment.moduleGraph.onFileChange(normalizedFile);
|
|
94
|
+
}
|
|
95
|
+
const mixedModules = server.moduleGraph.getModulesByFile(normalizedFile) || [];
|
|
96
|
+
for (const mod of mixedModules) {
|
|
97
|
+
server.moduleGraph.invalidateModule(mod);
|
|
98
|
+
}
|
|
99
|
+
for (const environment of Object.values(server.environments)) {
|
|
100
|
+
const modules = environment.moduleGraph.getModulesByFile(normalizedFile) || [];
|
|
101
|
+
for (const mod of modules) {
|
|
102
|
+
environment.moduleGraph.invalidateModule(mod);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function createFlowHotReload(projectRoot) {
|
|
107
|
+
let restartPending = false;
|
|
108
|
+
function toProjectPath(filePath) {
|
|
109
|
+
return normalizePath(relative(projectRoot, filePath));
|
|
110
|
+
}
|
|
111
|
+
function scheduleRestart(server) {
|
|
112
|
+
if (restartPending) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
restartPending = true;
|
|
116
|
+
server.ws.send({ type: "full-reload", path: "*" });
|
|
117
|
+
setTimeout(() => {
|
|
118
|
+
void server.restart().finally(() => {
|
|
119
|
+
restartPending = false;
|
|
120
|
+
});
|
|
121
|
+
}, 0);
|
|
122
|
+
}
|
|
123
|
+
async function handleServerChange(server, filePath, event) {
|
|
124
|
+
const projectPath = toProjectPath(filePath);
|
|
125
|
+
invalidateFileModules(server, filePath, event);
|
|
126
|
+
invalidateVirtualModules(server, projectPath);
|
|
127
|
+
if (matchesAny(flowRestartPatterns, projectPath)) {
|
|
128
|
+
scheduleRestart(server);
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
const shouldReload = event === "change" ? matchesAny(flowFullReloadPatterns, projectPath) : matchesAny(flowStructureReloadPatterns, projectPath);
|
|
132
|
+
if (!shouldReload) {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
server.ws.send({ type: "full-reload", path: "*" });
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
name: "flow:hot-reload",
|
|
140
|
+
configureServer(server) {
|
|
141
|
+
server.watcher.on("add", (filePath) => {
|
|
142
|
+
void handleServerChange(server, filePath, "add");
|
|
143
|
+
});
|
|
144
|
+
server.watcher.on("unlink", (filePath) => {
|
|
145
|
+
void handleServerChange(server, filePath, "unlink");
|
|
146
|
+
});
|
|
147
|
+
},
|
|
148
|
+
async handleHotUpdate(ctx) {
|
|
149
|
+
if (await handleServerChange(ctx.server, ctx.file, "change")) {
|
|
150
|
+
return [];
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function createFlowVirtualServerModules(projectRoot, flowConfig) {
|
|
156
|
+
const modules = /* @__PURE__ */ new Map([
|
|
157
|
+
["virtual:flow/pages", () => createVirtualPagesModule(projectRoot, flowConfig)],
|
|
158
|
+
["virtual:flow/client-page-assets", () => createVirtualClientPageAssetsModule(projectRoot)],
|
|
159
|
+
["virtual:flow/islands", () => createVirtualIslandsModule(projectRoot)],
|
|
160
|
+
["virtual:flow/templates", () => createVirtualTemplatesModule(projectRoot)],
|
|
161
|
+
["virtual:flow/layouts", () => createVirtualLayoutsModule(projectRoot)],
|
|
162
|
+
["virtual:flow/bases", () => createVirtualBaseTemplatesModule(projectRoot)]
|
|
163
|
+
]);
|
|
164
|
+
return {
|
|
165
|
+
name: "flow:server-virtuals",
|
|
166
|
+
enforce: "pre",
|
|
167
|
+
resolveId(id) {
|
|
168
|
+
if (modules.has(id)) {
|
|
169
|
+
return `\0${id}`;
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
load(id) {
|
|
173
|
+
const normalizedId = id.startsWith("\0") ? id.slice(1) : id;
|
|
174
|
+
const factory = modules.get(normalizedId);
|
|
175
|
+
if (!factory) {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
return factory();
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
function createFlowVirtualClientPages(projectRoot) {
|
|
183
|
+
const virtualId = "virtual:flow/client-pages";
|
|
184
|
+
const resolvedVirtualId = `\0${virtualId}`;
|
|
185
|
+
return {
|
|
186
|
+
name: "flow:client-pages",
|
|
187
|
+
enforce: "pre",
|
|
188
|
+
resolveId(id) {
|
|
189
|
+
if (id === virtualId) {
|
|
190
|
+
return resolvedVirtualId;
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
load(id) {
|
|
194
|
+
if (id !== resolvedVirtualId) {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
const clientPagesDir = resolve(projectRoot, "client/pages");
|
|
198
|
+
if (!existsSync(clientPagesDir)) {
|
|
199
|
+
return "const bundles = {};\n\nexport default bundles;\n";
|
|
200
|
+
}
|
|
201
|
+
return createVirtualClientPagesModule(projectRoot);
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
export function createFlowViteConfig(options = {}) {
|
|
206
|
+
const projectRoot = resolve(options.projectRoot || process.cwd());
|
|
207
|
+
const flowConfig = resolveFlowConfig(options.userFlowConfig || {});
|
|
208
|
+
const flowModules = loadFlowModules(projectRoot, flowConfig);
|
|
209
|
+
const flowNitroConfig = { ...flowConfig.nitro || {} };
|
|
210
|
+
const flowNitroHooks = flowNitroConfig.hooks || {};
|
|
211
|
+
const userPrerenderRoutesHook = typeof flowNitroHooks["prerender:routes"] === "function" ? flowNitroHooks["prerender:routes"] : void 0;
|
|
212
|
+
return defineConfig({
|
|
213
|
+
plugins: [
|
|
214
|
+
createFlowVirtualServerModules(projectRoot, flowConfig),
|
|
215
|
+
createFlowVirtualClientPages(projectRoot),
|
|
216
|
+
createFlowHotReload(projectRoot),
|
|
217
|
+
...flowModules.vite.plugins,
|
|
218
|
+
Icons({
|
|
219
|
+
autoInstall: true,
|
|
220
|
+
compiler: "vue3"
|
|
221
|
+
}),
|
|
222
|
+
Vue(),
|
|
223
|
+
ui({
|
|
224
|
+
router: false,
|
|
225
|
+
components: {
|
|
226
|
+
resolvers: [
|
|
227
|
+
IconsResolver()
|
|
228
|
+
]
|
|
229
|
+
}
|
|
230
|
+
}),
|
|
231
|
+
nitro({
|
|
232
|
+
...flowNitroConfig,
|
|
233
|
+
hooks: {
|
|
234
|
+
...flowNitroHooks,
|
|
235
|
+
async "prerender:routes"(routes) {
|
|
236
|
+
const discoveredRoutes = await getPrerenderRoutes(projectRoot, flowConfig);
|
|
237
|
+
for (const route of discoveredRoutes) {
|
|
238
|
+
routes.add(route);
|
|
239
|
+
}
|
|
240
|
+
for (const route of flowModules.prerenderRoutes) {
|
|
241
|
+
routes.add(route);
|
|
242
|
+
}
|
|
243
|
+
if (userPrerenderRoutesHook) {
|
|
244
|
+
await userPrerenderRoutesHook(routes);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
})
|
|
249
|
+
],
|
|
250
|
+
environments: {
|
|
251
|
+
client: {
|
|
252
|
+
build: {
|
|
253
|
+
rollupOptions: {
|
|
254
|
+
input: resolve(projectRoot, "src/main.ts")
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
ssr: {
|
|
259
|
+
build: {
|
|
260
|
+
rollupOptions: {
|
|
261
|
+
input: resolve(projectRoot, "entry-server.ts")
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
resolve: {
|
|
267
|
+
alias: {
|
|
268
|
+
"@": resolve(projectRoot, "src"),
|
|
269
|
+
...flowModules.vite.resolve.alias
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { installFlowVuePlugins } from '../runtime/vue.ts';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { installFlowVuePlugins } from "../runtime/vue.ts";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type Component, type PropType } from 'vue';
|
|
2
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
3
|
+
name: {
|
|
4
|
+
type: StringConstructor;
|
|
5
|
+
required: true;
|
|
6
|
+
};
|
|
7
|
+
component: {
|
|
8
|
+
type: PropType<Component>;
|
|
9
|
+
required: true;
|
|
10
|
+
};
|
|
11
|
+
props: {
|
|
12
|
+
type: PropType<Record<string, unknown>>;
|
|
13
|
+
default: () => {};
|
|
14
|
+
};
|
|
15
|
+
tag: {
|
|
16
|
+
type: StringConstructor;
|
|
17
|
+
default: string;
|
|
18
|
+
};
|
|
19
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
22
|
+
name: {
|
|
23
|
+
type: StringConstructor;
|
|
24
|
+
required: true;
|
|
25
|
+
};
|
|
26
|
+
component: {
|
|
27
|
+
type: PropType<Component>;
|
|
28
|
+
required: true;
|
|
29
|
+
};
|
|
30
|
+
props: {
|
|
31
|
+
type: PropType<Record<string, unknown>>;
|
|
32
|
+
default: () => {};
|
|
33
|
+
};
|
|
34
|
+
tag: {
|
|
35
|
+
type: StringConstructor;
|
|
36
|
+
default: string;
|
|
37
|
+
};
|
|
38
|
+
}>> & Readonly<{}>, {
|
|
39
|
+
props: Record<string, unknown>;
|
|
40
|
+
tag: string;
|
|
41
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
42
|
+
export default _default;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { defineComponent, h, mergeProps, useAttrs } from "vue";
|
|
2
|
+
function serializeIslandProps(props) {
|
|
3
|
+
return JSON.stringify(props).replaceAll("<", "\\u003c");
|
|
4
|
+
}
|
|
5
|
+
export default defineComponent({
|
|
6
|
+
name: "FlowIsland",
|
|
7
|
+
inheritAttrs: false,
|
|
8
|
+
props: {
|
|
9
|
+
name: {
|
|
10
|
+
type: String,
|
|
11
|
+
required: true
|
|
12
|
+
},
|
|
13
|
+
component: {
|
|
14
|
+
type: [Object, Function],
|
|
15
|
+
required: true
|
|
16
|
+
},
|
|
17
|
+
props: {
|
|
18
|
+
type: Object,
|
|
19
|
+
default: () => ({})
|
|
20
|
+
},
|
|
21
|
+
tag: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: "div"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
setup(props) {
|
|
27
|
+
const attrs = useAttrs();
|
|
28
|
+
return () => h(props.tag, mergeProps(attrs, {
|
|
29
|
+
"data-flow-island": props.name.toLowerCase(),
|
|
30
|
+
"data-flow-props": serializeIslandProps(props.props)
|
|
31
|
+
}), [
|
|
32
|
+
h(props.component, props.props)
|
|
33
|
+
]);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export interface FlowDirEntry {
|
|
2
|
+
dir: string;
|
|
3
|
+
}
|
|
4
|
+
export type FlowBuildPreset = 'server' | 'ssg';
|
|
5
|
+
export interface FlowBuildConfig {
|
|
6
|
+
preset: FlowBuildPreset;
|
|
7
|
+
}
|
|
8
|
+
export interface FlowModuleMeta {
|
|
9
|
+
name: string;
|
|
10
|
+
configKey?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface FlowModuleDefinition<TOptions = Record<string, unknown>> {
|
|
13
|
+
meta?: FlowModuleMeta;
|
|
14
|
+
defaults?: Partial<TOptions>;
|
|
15
|
+
setup?: (options: TOptions, context: FlowModuleSetupContext) => void;
|
|
16
|
+
}
|
|
17
|
+
export interface FlowModuleInstall<TOptions = Record<string, unknown>> {
|
|
18
|
+
module: string | FlowModuleDefinition<TOptions>;
|
|
19
|
+
options?: Partial<TOptions>;
|
|
20
|
+
}
|
|
21
|
+
export type FlowModuleInput = string | FlowModuleDefinition<any> | FlowModuleInstall<any> | [string | FlowModuleDefinition<any>, Record<string, unknown>?];
|
|
22
|
+
export interface FlowLocaleConfig {
|
|
23
|
+
locales: string[];
|
|
24
|
+
location: string;
|
|
25
|
+
language: string;
|
|
26
|
+
}
|
|
27
|
+
export interface FlowConfig {
|
|
28
|
+
modules: FlowModuleInput[];
|
|
29
|
+
dir: {
|
|
30
|
+
pages: FlowDirEntry[];
|
|
31
|
+
};
|
|
32
|
+
build: FlowBuildConfig;
|
|
33
|
+
locale: FlowLocaleConfig;
|
|
34
|
+
siteUrl?: string;
|
|
35
|
+
nitro?: Record<string, unknown>;
|
|
36
|
+
[key: string]: unknown;
|
|
37
|
+
}
|
|
38
|
+
export type UserFlowConfig = Partial<FlowConfig> & Record<string, unknown> & {
|
|
39
|
+
build?: Partial<FlowBuildConfig>;
|
|
40
|
+
dir?: {
|
|
41
|
+
pages?: FlowDirEntry[];
|
|
42
|
+
};
|
|
43
|
+
locale?: Partial<FlowLocaleConfig>;
|
|
44
|
+
siteUrl?: string;
|
|
45
|
+
};
|
|
46
|
+
export interface FlowModuleNitroConfig extends Record<string, unknown> {
|
|
47
|
+
plugins: string[];
|
|
48
|
+
handlers: Array<Record<string, unknown>>;
|
|
49
|
+
routeRules: Record<string, Record<string, unknown>>;
|
|
50
|
+
runtimeConfig: Record<string, unknown>;
|
|
51
|
+
virtual: Record<string, string | (() => string | Promise<string>)>;
|
|
52
|
+
}
|
|
53
|
+
export interface FlowModuleViteConfig extends Record<string, unknown> {
|
|
54
|
+
plugins: unknown[];
|
|
55
|
+
resolve: {
|
|
56
|
+
alias: Record<string, string>;
|
|
57
|
+
};
|
|
58
|
+
server: {
|
|
59
|
+
watch: {
|
|
60
|
+
additionalPaths: string[];
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export interface FlowModuleSetupContext {
|
|
65
|
+
projectRoot: string;
|
|
66
|
+
flowConfig: FlowConfig;
|
|
67
|
+
nitro: FlowModuleNitroConfig;
|
|
68
|
+
vite: FlowModuleViteConfig;
|
|
69
|
+
prerenderRoutes: Set<string>;
|
|
70
|
+
}
|
|
71
|
+
export declare function defineFlowConfig(config: UserFlowConfig): UserFlowConfig;
|
|
72
|
+
export declare function defineFlowModule<TOptions = Record<string, unknown>>(module: FlowModuleDefinition<TOptions>): FlowModuleDefinition<TOptions>;
|
|
73
|
+
export declare function resolveFlowConfig(userFlowConfig?: UserFlowConfig): FlowConfig;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export function defineFlowConfig(config) {
|
|
2
|
+
return config;
|
|
3
|
+
}
|
|
4
|
+
export function defineFlowModule(module) {
|
|
5
|
+
return module;
|
|
6
|
+
}
|
|
7
|
+
export function resolveFlowConfig(userFlowConfig = {}) {
|
|
8
|
+
const preset = process.env.FLOW_BUILD_PRESET === "ssg" ? "ssg" : process.env.FLOW_BUILD_PRESET === "server" ? "server" : userFlowConfig.build?.preset || "server";
|
|
9
|
+
return {
|
|
10
|
+
...userFlowConfig,
|
|
11
|
+
modules: userFlowConfig.modules || [],
|
|
12
|
+
build: {
|
|
13
|
+
preset
|
|
14
|
+
},
|
|
15
|
+
siteUrl: userFlowConfig.siteUrl,
|
|
16
|
+
nitro: userFlowConfig.nitro,
|
|
17
|
+
dir: {
|
|
18
|
+
pages: userFlowConfig.dir?.pages?.length ? userFlowConfig.dir.pages : [{ dir: "pages" }]
|
|
19
|
+
},
|
|
20
|
+
locale: {
|
|
21
|
+
locales: userFlowConfig.locale?.locales?.length ? userFlowConfig.locale.locales : ["es-ec"],
|
|
22
|
+
location: userFlowConfig.locale?.location || "ec",
|
|
23
|
+
language: userFlowConfig.locale?.language || "es"
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { createSSRApp } from "vue";
|
|
2
|
+
import { getClientHead } from "./head.mjs";
|
|
3
|
+
import { installFlowVuePlugins } from "./vue.mjs";
|
|
4
|
+
import islands from "virtual:flow/islands";
|
|
5
|
+
function parseIslandProps(value) {
|
|
6
|
+
if (!value) {
|
|
7
|
+
return {};
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
return JSON.parse(value);
|
|
11
|
+
} catch {
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
async function hydrateIsland(element, boot) {
|
|
16
|
+
if (element.dataset.flowIslandHydrated === "true") {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const islandName = element.dataset.flowIsland?.toLowerCase();
|
|
20
|
+
if (!islandName) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const importer = islands[islandName];
|
|
24
|
+
if (!importer) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const props = parseIslandProps(element.dataset.flowProps);
|
|
28
|
+
const mod = await importer();
|
|
29
|
+
if (mod.hydrate) {
|
|
30
|
+
await mod.hydrate({
|
|
31
|
+
element,
|
|
32
|
+
props,
|
|
33
|
+
boot
|
|
34
|
+
});
|
|
35
|
+
element.dataset.flowIslandHydrated = "true";
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (!mod.default) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const app = createSSRApp(mod.default, props);
|
|
42
|
+
app.use(getClientHead());
|
|
43
|
+
installFlowVuePlugins(app);
|
|
44
|
+
app.mount(element);
|
|
45
|
+
element.dataset.flowIslandHydrated = "true";
|
|
46
|
+
}
|
|
47
|
+
export async function hydrateIslands(boot) {
|
|
48
|
+
const elements = Array.from(document.querySelectorAll("[data-flow-island]"));
|
|
49
|
+
for (const element of elements) {
|
|
50
|
+
await hydrateIsland(element, boot);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FlowConfig, FlowModuleNitroConfig, FlowModuleViteConfig } from './config.ts';
|
|
2
|
+
export interface LoadedFlowModule {
|
|
3
|
+
name: string;
|
|
4
|
+
options: Record<string, unknown>;
|
|
5
|
+
}
|
|
6
|
+
export interface FlowModuleResolution {
|
|
7
|
+
modules: LoadedFlowModule[];
|
|
8
|
+
nitro: FlowModuleNitroConfig;
|
|
9
|
+
vite: FlowModuleViteConfig;
|
|
10
|
+
prerenderRoutes: string[];
|
|
11
|
+
}
|
|
12
|
+
export declare function loadFlowModules(projectRoot: string, flowConfig: FlowConfig): FlowModuleResolution;
|