@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.
Files changed (127) hide show
  1. package/README.md +34 -0
  2. package/entry-server.d.ts +1 -0
  3. package/entry-server.mjs +5 -0
  4. package/modules/content/module.d.ts +6 -0
  5. package/modules/content/module.mjs +32 -0
  6. package/modules/content/query.mjs +104 -0
  7. package/modules/sitemap/handler.mjs +17 -0
  8. package/modules/sitemap/module.d.ts +6 -0
  9. package/modules/sitemap/module.mjs +28 -0
  10. package/modules/strapi/README.md +235 -0
  11. package/modules/strapi/module.d.ts +11 -0
  12. package/modules/strapi/module.mjs +69 -0
  13. package/modules/strapi/proxy.mjs +54 -0
  14. package/modules/strapi/runtime/client.d.ts +30 -0
  15. package/modules/strapi/runtime/client.mjs +248 -0
  16. package/package.json +73 -77
  17. package/server/lib/handler.d.ts +1 -0
  18. package/server/lib/handler.mjs +43 -0
  19. package/server/lib/pages.d.ts +20 -0
  20. package/server/lib/pages.mjs +276 -0
  21. package/server/lib/render.d.ts +7 -0
  22. package/server/lib/render.mjs +156 -0
  23. package/server/plugins/00.lifecycle.d.ts +2 -0
  24. package/server/plugins/00.lifecycle.mjs +9 -0
  25. package/server/renderer.d.ts +3 -0
  26. package/server/renderer.mjs +14 -0
  27. package/server/routes/api/health.get.d.ts +2 -0
  28. package/server/routes/api/health.get.mjs +5 -0
  29. package/server.d.ts +1 -0
  30. package/server.mjs +32 -0
  31. package/src/main.d.ts +1 -0
  32. package/src/main.mjs +29 -0
  33. package/src/public/boot.d.ts +1 -0
  34. package/src/public/components.d.ts +1 -0
  35. package/src/public/components.mjs +1 -0
  36. package/src/public/head.d.ts +1 -0
  37. package/src/public/head.mjs +1 -0
  38. package/src/public/index.d.ts +5 -0
  39. package/src/public/index.mjs +2 -0
  40. package/src/public/modules/content.d.ts +2 -0
  41. package/src/public/modules/content.mjs +1 -0
  42. package/src/public/modules/sitemap.d.ts +2 -0
  43. package/src/public/modules/sitemap.mjs +1 -0
  44. package/src/public/modules/strapi.d.ts +2 -0
  45. package/src/public/modules/strapi.mjs +1 -0
  46. package/src/public/nitro.d.ts +6 -0
  47. package/src/public/nitro.mjs +78 -0
  48. package/src/public/shared.d.ts +2 -0
  49. package/src/public/shared.mjs +18 -0
  50. package/src/public/vite.d.ts +6 -0
  51. package/src/public/vite.mjs +273 -0
  52. package/src/public/vue.d.ts +1 -0
  53. package/src/public/vue.mjs +1 -0
  54. package/src/runtime/boot.d.ts +9 -0
  55. package/src/runtime/components/FlowIsland.d.ts +42 -0
  56. package/src/runtime/components/FlowIsland.mjs +35 -0
  57. package/src/runtime/config.d.ts +73 -0
  58. package/src/runtime/config.mjs +26 -0
  59. package/src/runtime/head.d.ts +3 -0
  60. package/src/runtime/head.mjs +7 -0
  61. package/src/runtime/islands.d.ts +2 -0
  62. package/src/runtime/islands.mjs +52 -0
  63. package/src/runtime/modules.d.ts +12 -0
  64. package/src/runtime/modules.mjs +115 -0
  65. package/src/runtime/page-discovery.d.ts +6 -0
  66. package/src/runtime/page-discovery.mjs +175 -0
  67. package/src/runtime/pages.d.ts +107 -0
  68. package/src/runtime/pages.mjs +3 -0
  69. package/src/runtime/ssg.d.ts +9 -0
  70. package/src/runtime/ssg.mjs +37 -0
  71. package/src/runtime/virtual-pages.d.ts +8 -0
  72. package/src/runtime/virtual-pages.mjs +151 -0
  73. package/src/runtime/virtual.d.ts +103 -0
  74. package/src/runtime/vite-assets.d.ts +9 -0
  75. package/src/runtime/vue.d.ts +6 -0
  76. package/src/runtime/vue.mjs +6 -0
  77. package/src/styles.css +1 -0
  78. package/app.d.ts +0 -1
  79. package/bin/flow.mjs +0 -2
  80. package/dist/app/composables/index.d.ts +0 -5
  81. package/dist/app/composables/index.mjs +0 -12
  82. package/dist/app/entry.async.d.ts +0 -3
  83. package/dist/app/entry.async.mjs +0 -1
  84. package/dist/app/entry.d.ts +0 -3
  85. package/dist/app/entry.mjs +0 -23
  86. package/dist/app/flow.d.ts +0 -80
  87. package/dist/app/flow.mjs +0 -88
  88. package/dist/app/index.d.ts +0 -3
  89. package/dist/app/index.mjs +0 -3
  90. package/dist/chunks/dev-bundler.mjs +0 -247
  91. package/dist/chunks/external.mjs +0 -37
  92. package/dist/chunks/index.mjs +0 -1140
  93. package/dist/chunks/vite-node.mjs +0 -155
  94. package/dist/core/runtime/client.manifest.d.mts +0 -2
  95. package/dist/core/runtime/client.manifest.mjs +0 -6
  96. package/dist/core/runtime/nitro/flow.d.ts +0 -3
  97. package/dist/core/runtime/nitro/flow.mjs +0 -33
  98. package/dist/core/runtime/nitro/paths.d.ts +0 -4
  99. package/dist/core/runtime/nitro/paths.mjs +0 -15
  100. package/dist/core/runtime/nitro/renderer.d.ts +0 -2
  101. package/dist/core/runtime/nitro/renderer.mjs +0 -101
  102. package/dist/core/runtime/vite-node-shared.d.mts +0 -1
  103. package/dist/core/runtime/vite-node-shared.d.ts +0 -8
  104. package/dist/core/runtime/vite-node-shared.mjs +0 -3
  105. package/dist/core/runtime/vite-node.d.mts +0 -2
  106. package/dist/core/runtime/vite-node.mjs +0 -42
  107. package/dist/head/runtime/composables.d.ts +0 -9
  108. package/dist/head/runtime/composables.mjs +0 -2
  109. package/dist/head/runtime/index.d.ts +0 -1
  110. package/dist/head/runtime/index.mjs +0 -1
  111. package/dist/head/runtime/plugin.mjs +0 -5
  112. package/dist/index.d.ts +0 -11
  113. package/dist/index.mjs +0 -27
  114. package/dist/pages/runtime/helpers/index.d.ts +0 -5
  115. package/dist/pages/runtime/helpers/index.mjs +0 -31
  116. package/dist/pages/runtime/index.d.ts +0 -10
  117. package/dist/pages/runtime/index.mjs +0 -13
  118. package/dist/pages/runtime/pages.mjs +0 -100
  119. package/dist/vite-client/runtime/injectManifest.d.ts +0 -26
  120. package/dist/vite-client/runtime/injectManifest.mjs +0 -110
  121. package/dist/vite-client/runtime/plugin.mjs +0 -28
  122. package/types.d.ts +0 -2
  123. /package/{dist/head/runtime/plugin.d.ts → modules/content/query.d.ts} +0 -0
  124. /package/{dist/pages/runtime/pages.d.ts → modules/sitemap/handler.d.ts} +0 -0
  125. /package/{dist/vite-client/runtime/plugin.d.ts → modules/strapi/proxy.d.ts} +0 -0
  126. /package/{dist/pages/runtime/helpers/chunks.d.ts → src/public/boot.mjs} +0 -0
  127. /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": "5.0.0-rc.99",
3
+ "version": "6.0.1",
4
+ "description": "@monkeyplus/flow package-first runtime with Vite, Nitro, Vue and a workspace playground.",
4
5
  "license": "MIT",
5
- "type": "module",
6
- "main": "./dist/index.mjs",
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
- ".": "./dist/index.mjs",
13
- "./app": "./dist/app/index.mjs",
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
- "imports": {
17
- "#app": "./dist/app/index.mjs",
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
- "@monkeyplus/flow-cli": "5.0.0-rc.99",
29
- "@monkeyplus/flow-kit": "5.0.0-rc.99",
30
- "@monkeyplus/flow-schema": "5.0.0-rc.99",
31
- "@rollup/plugin-replace": "^4.0.0",
32
- "@vueuse/head": "^0.7.6",
33
- "c12": "^0.2.8",
34
- "chokidar": "^3.5.3",
35
- "consola": "^2.15.3",
36
- "defu": "^6.0.0",
37
- "esbuild": "^0.14.49",
38
- "escape-string-regexp": "^5.0.0",
39
- "esno": "^0.16.3",
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.mjs?assets=client";
2
+ import bundleAssets from "virtual:flow/client-page-assets";
3
+ import { renderDocument } from "./render.mjs";
4
+ import { resolvePage, resolvePageByName } from "./pages.mjs";
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>;