@monkeyplus/flow 5.0.0-rc.99 → 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,248 @@
|
|
|
1
|
+
const defaultStrapiConfig = {
|
|
2
|
+
apiBase: "/api/_strapi",
|
|
3
|
+
url: process.env.STRAPI_URL || "http://localhost:1337",
|
|
4
|
+
prefix: "/api",
|
|
5
|
+
admin: "/admin",
|
|
6
|
+
version: "v5"
|
|
7
|
+
};
|
|
8
|
+
const defaultServerToken = process.env.STRAPI_TOKEN || void 0;
|
|
9
|
+
export const strapiConfig = { ...defaultStrapiConfig };
|
|
10
|
+
let cachedStrapiConfig = strapiConfig;
|
|
11
|
+
function withLeadingSlash(value) {
|
|
12
|
+
return value.startsWith("/") ? value : `/${value}`;
|
|
13
|
+
}
|
|
14
|
+
function withoutTrailingSlash(value) {
|
|
15
|
+
return value.endsWith("/") ? value.slice(0, -1) : value;
|
|
16
|
+
}
|
|
17
|
+
function joinUrl(base, path = "") {
|
|
18
|
+
const normalizedBase = withoutTrailingSlash(base);
|
|
19
|
+
const normalizedPath = path ? withLeadingSlash(path) : "";
|
|
20
|
+
return `${normalizedBase}${normalizedPath}`;
|
|
21
|
+
}
|
|
22
|
+
function isAbsoluteUrl(value) {
|
|
23
|
+
return /^https?:\/\//i.test(value);
|
|
24
|
+
}
|
|
25
|
+
function appendQueryValue(searchParams, key, value) {
|
|
26
|
+
if (value == null) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (Array.isArray(value)) {
|
|
30
|
+
value.forEach((entry, index) => {
|
|
31
|
+
appendQueryValue(searchParams, `${key}[${index}]`, entry);
|
|
32
|
+
});
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (typeof value === "object") {
|
|
36
|
+
Object.entries(value).forEach(([childKey, childValue]) => {
|
|
37
|
+
appendQueryValue(searchParams, `${key}[${childKey}]`, childValue);
|
|
38
|
+
});
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
searchParams.append(key, String(value));
|
|
42
|
+
}
|
|
43
|
+
function withQuery(url, params) {
|
|
44
|
+
if (!params || Object.keys(params).length === 0) {
|
|
45
|
+
return url;
|
|
46
|
+
}
|
|
47
|
+
const target = new URL(url);
|
|
48
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
49
|
+
appendQueryValue(target.searchParams, key, value);
|
|
50
|
+
});
|
|
51
|
+
return target.toString();
|
|
52
|
+
}
|
|
53
|
+
async function getServerRuntimeConfig() {
|
|
54
|
+
if (typeof window !== "undefined") {
|
|
55
|
+
return void 0;
|
|
56
|
+
}
|
|
57
|
+
const runtime = await import("nitro/runtime-config");
|
|
58
|
+
return runtime.useRuntimeConfig();
|
|
59
|
+
}
|
|
60
|
+
async function getPublicStrapiConfig() {
|
|
61
|
+
try {
|
|
62
|
+
const loaded = await import("virtual:flow/strapi-config");
|
|
63
|
+
if (loaded?.default) {
|
|
64
|
+
Object.assign(strapiConfig, {
|
|
65
|
+
...defaultStrapiConfig,
|
|
66
|
+
...loaded.default
|
|
67
|
+
});
|
|
68
|
+
cachedStrapiConfig = strapiConfig;
|
|
69
|
+
}
|
|
70
|
+
} catch {
|
|
71
|
+
Object.assign(strapiConfig, defaultStrapiConfig);
|
|
72
|
+
cachedStrapiConfig = strapiConfig;
|
|
73
|
+
}
|
|
74
|
+
return cachedStrapiConfig;
|
|
75
|
+
}
|
|
76
|
+
async function resolveRestBaseUrl() {
|
|
77
|
+
const publicConfig = await getPublicStrapiConfig();
|
|
78
|
+
const runtimeConfig = await getServerRuntimeConfig();
|
|
79
|
+
const privateConfig = runtimeConfig?.flow?.strapi;
|
|
80
|
+
if (privateConfig?.url) {
|
|
81
|
+
return {
|
|
82
|
+
url: joinUrl(privateConfig.url, privateConfig.prefix),
|
|
83
|
+
token: privateConfig.token
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (typeof window !== "undefined") {
|
|
87
|
+
return {
|
|
88
|
+
url: publicConfig.apiBase,
|
|
89
|
+
token: void 0
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
if (publicConfig.url) {
|
|
93
|
+
return {
|
|
94
|
+
url: joinUrl(publicConfig.url, publicConfig.prefix),
|
|
95
|
+
token: defaultServerToken
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
if (runtimeConfig?.flow?.siteUrl) {
|
|
99
|
+
return {
|
|
100
|
+
url: joinUrl(runtimeConfig.flow.siteUrl, publicConfig.apiBase),
|
|
101
|
+
token: void 0
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
url: joinUrl("http://localhost:3000", publicConfig.apiBase),
|
|
106
|
+
token: defaultServerToken
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
async function resolveGraphqlUrl() {
|
|
110
|
+
const publicConfig = await getPublicStrapiConfig();
|
|
111
|
+
const runtimeConfig = await getServerRuntimeConfig();
|
|
112
|
+
const privateConfig = runtimeConfig?.flow?.strapi;
|
|
113
|
+
if (privateConfig?.url) {
|
|
114
|
+
return {
|
|
115
|
+
url: joinUrl(privateConfig.url, "/graphql"),
|
|
116
|
+
token: privateConfig.token
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
if (typeof window !== "undefined") {
|
|
120
|
+
return {
|
|
121
|
+
url: joinUrl(publicConfig.apiBase, "/graphql"),
|
|
122
|
+
token: void 0
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
if (publicConfig.url) {
|
|
126
|
+
return {
|
|
127
|
+
url: joinUrl(publicConfig.url, "/graphql"),
|
|
128
|
+
token: defaultServerToken
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
if (runtimeConfig?.flow?.siteUrl) {
|
|
132
|
+
return {
|
|
133
|
+
url: joinUrl(runtimeConfig.flow.siteUrl, joinUrl(publicConfig.apiBase, "/graphql")),
|
|
134
|
+
token: void 0
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
url: joinUrl("http://localhost:3000", joinUrl(publicConfig.apiBase, "/graphql")),
|
|
139
|
+
token: defaultServerToken
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function createHeaders(input, token) {
|
|
143
|
+
const headers = new Headers(input);
|
|
144
|
+
if (token && !headers.has("authorization")) {
|
|
145
|
+
headers.set("authorization", `Bearer ${token}`);
|
|
146
|
+
}
|
|
147
|
+
if (!headers.has("accept")) {
|
|
148
|
+
headers.set("accept", "application/json");
|
|
149
|
+
}
|
|
150
|
+
return headers;
|
|
151
|
+
}
|
|
152
|
+
async function request(base, path, options = {}) {
|
|
153
|
+
const resolved = await base();
|
|
154
|
+
const target = isAbsoluteUrl(path) ? withQuery(path, options.params) : withQuery(joinUrl(resolved.url, path), options.params);
|
|
155
|
+
const headers = createHeaders(options.headers, resolved.token);
|
|
156
|
+
const method = options.method || "GET";
|
|
157
|
+
if ((method === "POST" || method === "PUT" || method === "PATCH") && !headers.has("content-type")) {
|
|
158
|
+
headers.set("content-type", "application/json");
|
|
159
|
+
}
|
|
160
|
+
const response = await fetch(target, {
|
|
161
|
+
...options,
|
|
162
|
+
method,
|
|
163
|
+
headers
|
|
164
|
+
});
|
|
165
|
+
if (!response.ok) {
|
|
166
|
+
const details = await response.text();
|
|
167
|
+
throw new Error(`Strapi request failed (${response.status} ${response.statusText}): ${details}`);
|
|
168
|
+
}
|
|
169
|
+
if (response.status === 204) {
|
|
170
|
+
return void 0;
|
|
171
|
+
}
|
|
172
|
+
const contentType = response.headers.get("content-type") || "";
|
|
173
|
+
return contentType.includes("application/json") ? await response.json() : await response.text();
|
|
174
|
+
}
|
|
175
|
+
export function useStrapiVersion() {
|
|
176
|
+
return cachedStrapiConfig.version;
|
|
177
|
+
}
|
|
178
|
+
export function useStrapiUrl(path = "") {
|
|
179
|
+
return cachedStrapiConfig.url ? joinUrl(joinUrl(cachedStrapiConfig.url, cachedStrapiConfig.prefix), path) : joinUrl(cachedStrapiConfig.apiBase, path);
|
|
180
|
+
}
|
|
181
|
+
export function useStrapiAdminUrl(path = "") {
|
|
182
|
+
return cachedStrapiConfig.url ? joinUrl(joinUrl(cachedStrapiConfig.url, cachedStrapiConfig.admin), path) : joinUrl(cachedStrapiConfig.admin, path);
|
|
183
|
+
}
|
|
184
|
+
export function useStrapiMedia(url) {
|
|
185
|
+
if (!url) {
|
|
186
|
+
return url;
|
|
187
|
+
}
|
|
188
|
+
if (isAbsoluteUrl(url) || !cachedStrapiConfig.url) {
|
|
189
|
+
return url;
|
|
190
|
+
}
|
|
191
|
+
return new URL(url, cachedStrapiConfig.url).toString();
|
|
192
|
+
}
|
|
193
|
+
export function useStrapiClient() {
|
|
194
|
+
return async function strapiClient(url, options) {
|
|
195
|
+
return await request(resolveRestBaseUrl, url, options);
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
export function useStrapi() {
|
|
199
|
+
const client = useStrapiClient();
|
|
200
|
+
return {
|
|
201
|
+
async find(contentType, params, options) {
|
|
202
|
+
return await client(contentType, {
|
|
203
|
+
...options,
|
|
204
|
+
params
|
|
205
|
+
});
|
|
206
|
+
},
|
|
207
|
+
async findOne(contentType, documentId, params, options) {
|
|
208
|
+
return await client(`${contentType}/${documentId}`, {
|
|
209
|
+
...options,
|
|
210
|
+
params
|
|
211
|
+
});
|
|
212
|
+
},
|
|
213
|
+
async create(contentType, data, params, options) {
|
|
214
|
+
return await client(contentType, {
|
|
215
|
+
...options,
|
|
216
|
+
method: "POST",
|
|
217
|
+
body: JSON.stringify({ data }),
|
|
218
|
+
params
|
|
219
|
+
});
|
|
220
|
+
},
|
|
221
|
+
async update(contentType, documentId, data, params, options) {
|
|
222
|
+
return await client(`${contentType}/${documentId}`, {
|
|
223
|
+
...options,
|
|
224
|
+
method: "PUT",
|
|
225
|
+
body: JSON.stringify({ data: data || {} }),
|
|
226
|
+
params
|
|
227
|
+
});
|
|
228
|
+
},
|
|
229
|
+
async delete(contentType, documentId, params, options) {
|
|
230
|
+
const target = documentId ? `${contentType}/${documentId}` : contentType;
|
|
231
|
+
return await client(target, {
|
|
232
|
+
...options,
|
|
233
|
+
method: "DELETE",
|
|
234
|
+
params
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
export function useStrapiGraphQL() {
|
|
240
|
+
return async function strapiGraphQL(query, variables, options) {
|
|
241
|
+
const source = typeof query === "string" ? query : query.loc?.source?.body || "";
|
|
242
|
+
return await request(resolveGraphqlUrl, "", {
|
|
243
|
+
...options,
|
|
244
|
+
method: "POST",
|
|
245
|
+
body: JSON.stringify({ query: source, variables })
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
}
|
package/package.json
CHANGED
|
@@ -1,86 +1,82 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monkeyplus/flow",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
|
+
"description": "@monkeyplus/flow package-first runtime with Vite, Nitro, Vue and a workspace playground.",
|
|
4
5
|
"license": "MIT",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
"types": "./types.d.ts",
|
|
8
|
-
"bin": {
|
|
9
|
-
"flow": "./bin/flow.mjs"
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
10
8
|
},
|
|
9
|
+
"type": "module",
|
|
11
10
|
"exports": {
|
|
12
|
-
".":
|
|
13
|
-
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./src/public/index.d.ts",
|
|
13
|
+
"import": "./src/public/index.mjs"
|
|
14
|
+
},
|
|
15
|
+
"./vite": {
|
|
16
|
+
"types": "./src/public/vite.d.ts",
|
|
17
|
+
"import": "./src/public/vite.mjs"
|
|
18
|
+
},
|
|
19
|
+
"./nitro": {
|
|
20
|
+
"types": "./src/public/nitro.d.ts",
|
|
21
|
+
"import": "./src/public/nitro.mjs"
|
|
22
|
+
},
|
|
23
|
+
"./head": {
|
|
24
|
+
"types": "./src/public/head.d.ts",
|
|
25
|
+
"import": "./src/public/head.mjs"
|
|
26
|
+
},
|
|
27
|
+
"./vue": {
|
|
28
|
+
"types": "./src/public/vue.d.ts",
|
|
29
|
+
"import": "./src/public/vue.mjs"
|
|
30
|
+
},
|
|
31
|
+
"./boot": {
|
|
32
|
+
"types": "./src/public/boot.d.ts",
|
|
33
|
+
"import": "./src/public/boot.mjs"
|
|
34
|
+
},
|
|
35
|
+
"./components": {
|
|
36
|
+
"types": "./src/public/components.d.ts",
|
|
37
|
+
"import": "./src/public/components.mjs"
|
|
38
|
+
},
|
|
39
|
+
"./strapi": {
|
|
40
|
+
"types": "./modules/strapi/runtime/client.d.ts",
|
|
41
|
+
"import": "./modules/strapi/runtime/client.mjs"
|
|
42
|
+
},
|
|
43
|
+
"./modules/sitemap": {
|
|
44
|
+
"types": "./src/public/modules/sitemap.d.ts",
|
|
45
|
+
"import": "./src/public/modules/sitemap.mjs"
|
|
46
|
+
},
|
|
47
|
+
"./modules/strapi": {
|
|
48
|
+
"types": "./src/public/modules/strapi.d.ts",
|
|
49
|
+
"import": "./src/public/modules/strapi.mjs"
|
|
50
|
+
},
|
|
51
|
+
"./modules/content": {
|
|
52
|
+
"types": "./src/public/modules/content.d.ts",
|
|
53
|
+
"import": "./src/public/modules/content.mjs"
|
|
54
|
+
},
|
|
55
|
+
"./main": {
|
|
56
|
+
"types": "./src/main.d.ts",
|
|
57
|
+
"import": "./src/main.mjs"
|
|
58
|
+
},
|
|
59
|
+
"./entry-server": {
|
|
60
|
+
"types": "./entry-server.d.ts",
|
|
61
|
+
"import": "./entry-server.mjs"
|
|
62
|
+
},
|
|
63
|
+
"./styles.css": "./src/styles.css",
|
|
14
64
|
"./package.json": "./package.json"
|
|
15
65
|
},
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
"#head": "./dist/head/runtime/index.mjs",
|
|
19
|
-
"#pages": "./dist/pages/runtime/index.mjs"
|
|
20
|
-
},
|
|
21
|
-
"files": [
|
|
22
|
-
"app.d.ts",
|
|
23
|
-
"bin",
|
|
24
|
-
"types.d.ts",
|
|
25
|
-
"dist"
|
|
26
|
-
],
|
|
66
|
+
"main": "./src/public/index.mjs",
|
|
67
|
+
"types": "./src/public/index.d.ts",
|
|
27
68
|
"dependencies": {
|
|
28
|
-
"@
|
|
29
|
-
"@
|
|
30
|
-
"@
|
|
31
|
-
"@
|
|
32
|
-
"@
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"eta": "^1.12.3",
|
|
41
|
-
"externality": "^0.2.2",
|
|
42
|
-
"fs-extra": "^10.1.0",
|
|
43
|
-
"get-port-please": "^2.5.0",
|
|
44
|
-
"globby": "^13.1.2",
|
|
45
|
-
"h3": "^0.7.16",
|
|
46
|
-
"hookable": "^5.1.1",
|
|
47
|
-
"jiti": "^1.14.0",
|
|
48
|
-
"ohash": "^0.1.5",
|
|
49
|
-
"knitwork": "^0.1.2",
|
|
50
|
-
"listhen": "^0.2.13",
|
|
51
|
-
"magic-string": "^0.26.2",
|
|
52
|
-
"mlly": "^0.5.4",
|
|
53
|
-
"mri": "^1.2.0",
|
|
54
|
-
"nitropack": "^0.4.12",
|
|
55
|
-
"pathe": "^0.3.2",
|
|
56
|
-
"perfect-debounce": "^0.1.3",
|
|
57
|
-
"radix3": "^0.1.2",
|
|
58
|
-
"unenv": "^0.5.2",
|
|
59
|
-
"ohmyfetch": "^0.4.18",
|
|
60
|
-
"node-fetch-native": "^0.1.4",
|
|
61
|
-
"rollup": "^2.77.0",
|
|
62
|
-
"rollup-plugin-visualizer": "^5.7.1",
|
|
63
|
-
"scule": "^0.2.1",
|
|
64
|
-
"ufo": "^0.8.5",
|
|
65
|
-
"unctx": "^2.0.1",
|
|
66
|
-
"unimport": "^0.4.5",
|
|
67
|
-
"unplugin": "^0.9.4",
|
|
68
|
-
"untyped": "^0.4.5",
|
|
69
|
-
"pkg-types": "^0.3.3",
|
|
70
|
-
"vite": "~3.0.9",
|
|
71
|
-
"vite-node": "^0.22.1",
|
|
72
|
-
"vite-plugin-checker": "^0.4.9",
|
|
73
|
-
"vue-bundle-renderer": "^0.4.2",
|
|
74
|
-
"vue": "^3.2.37"
|
|
75
|
-
},
|
|
76
|
-
"devDependencies": {
|
|
77
|
-
"@types/fs-extra": "^9.0.13",
|
|
78
|
-
"vue-router": "^4.1.2"
|
|
79
|
-
},
|
|
80
|
-
"engines": {
|
|
81
|
-
"node": "^16.11.0 || ^17.0.0 || ^18.0.0"
|
|
82
|
-
},
|
|
83
|
-
"scripts": {
|
|
84
|
-
"stub": "unbuild --stub"
|
|
69
|
+
"@iconify/json": "^2.2.471",
|
|
70
|
+
"@nuxt/ui": "^4.7.1",
|
|
71
|
+
"@unhead/ssr": "^3.1.0",
|
|
72
|
+
"@unhead/vue": "^3.1.0",
|
|
73
|
+
"@vitejs/plugin-vue": "^6.0.5",
|
|
74
|
+
"@vue/server-renderer": "^3.5.13",
|
|
75
|
+
"nitro": "3.0.260429-beta",
|
|
76
|
+
"std-env": "^4.0.0",
|
|
77
|
+
"unhead": "^3.1.0",
|
|
78
|
+
"unplugin-icons": "^23.0.1",
|
|
79
|
+
"vite": "^8.0.5",
|
|
80
|
+
"vue": "^3.5.13"
|
|
85
81
|
}
|
|
86
|
-
}
|
|
82
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function renderPageRequest(request: Request): Promise<Response>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import clientAssets from "../../src/main.ts?assets=client";
|
|
2
|
+
import bundleAssets from "virtual:flow/client-page-assets";
|
|
3
|
+
import { renderDocument } from "./render.ts";
|
|
4
|
+
import { resolvePage, resolvePageByName } from "./pages.ts";
|
|
5
|
+
function mergeClientAssets(baseAssets, pageAssets) {
|
|
6
|
+
const css = [...baseAssets.css || [], ...pageAssets?.css || []];
|
|
7
|
+
const js = [...baseAssets.js || [], ...pageAssets?.js || []];
|
|
8
|
+
return {
|
|
9
|
+
entry: baseAssets.entry,
|
|
10
|
+
css: css.filter((asset, index, list) => list.findIndex((candidate) => candidate.href === asset.href) === index),
|
|
11
|
+
js: js.filter((asset, index, list) => list.findIndex((candidate) => candidate.href === asset.href) === index)
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export async function renderPageRequest(request) {
|
|
15
|
+
const pathname = new URL(request.url).pathname;
|
|
16
|
+
const page = await resolvePage(pathname);
|
|
17
|
+
if (!page) {
|
|
18
|
+
const notFoundPage = await resolvePageByName("error404", pathname);
|
|
19
|
+
if (!notFoundPage) {
|
|
20
|
+
return new Response("Not Found", {
|
|
21
|
+
status: 404,
|
|
22
|
+
headers: {
|
|
23
|
+
"content-type": "text/plain; charset=utf-8"
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const bundleName2 = notFoundPage.definition.view.bundle || "_default";
|
|
28
|
+
const resolvedAssets2 = mergeClientAssets(clientAssets, bundleAssets[bundleName2] || bundleAssets._default);
|
|
29
|
+
return new Response(await renderDocument(notFoundPage, resolvedAssets2), {
|
|
30
|
+
status: 404,
|
|
31
|
+
headers: {
|
|
32
|
+
"content-type": "text/html; charset=utf-8"
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
const bundleName = page.definition.view.bundle || "_default";
|
|
37
|
+
const resolvedAssets = mergeClientAssets(clientAssets, bundleAssets[bundleName] || bundleAssets._default);
|
|
38
|
+
return new Response(await renderDocument(page, resolvedAssets), {
|
|
39
|
+
headers: {
|
|
40
|
+
"content-type": "text/html; charset=utf-8"
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { DynamicRouteEntry, FlowLocale, GetUrlOptions, HeadDefinition, PageDefinition, PageLocaleDefinition, PageUrlInfo } from '../../src/runtime/pages';
|
|
2
|
+
export interface ResolvedPage {
|
|
3
|
+
definition: PageDefinition;
|
|
4
|
+
locale: FlowLocale;
|
|
5
|
+
localeCode: string;
|
|
6
|
+
localePage: PageLocaleDefinition;
|
|
7
|
+
pathname: string;
|
|
8
|
+
params: Record<string, string>;
|
|
9
|
+
dynamic?: DynamicRouteEntry;
|
|
10
|
+
head: HeadDefinition;
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Use head.
|
|
13
|
+
*/
|
|
14
|
+
seo: HeadDefinition;
|
|
15
|
+
context: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
export declare function getUrl(namePage: string, localeCode?: string, options?: GetUrlOptions): Promise<string | undefined>;
|
|
18
|
+
export declare function getUrls(withLocale?: boolean, omitNoPublish?: boolean): Promise<(string | PageUrlInfo)[]>;
|
|
19
|
+
export declare function resolvePage(pathname: string): Promise<ResolvedPage | undefined>;
|
|
20
|
+
export declare function resolvePageByName(name: string, pathname: string): Promise<ResolvedPage | undefined>;
|