@monkeyplus/flow 6.0.3 → 6.0.4

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 (2) hide show
  1. package/package.json +1 -1
  2. package/server/renderer.mjs +24 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monkeyplus/flow",
3
- "version": "6.0.3",
3
+ "version": "6.0.4",
4
4
  "description": "@monkeyplus/flow package-first runtime with Vite, Nitro, Vue and a workspace playground.",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -1,4 +1,14 @@
1
+ import { resolve } from "node:path";
2
+ import { pathToFileURL } from "node:url";
1
3
  let prerenderFetchHandlerPromise;
4
+ function resolvePrerenderServiceUrls() {
5
+ const cwd = process.cwd();
6
+ return [
7
+ pathToFileURL(resolve(cwd, "node_modules/.nitro/vite/services/ssr/index.js")).href,
8
+ pathToFileURL(resolve(cwd, ".nitro/vite/services/ssr/index.js")).href,
9
+ new URL("../../vite/services/ssr/index.js", import.meta.url).href
10
+ ];
11
+ }
2
12
  function resolveRequest(input) {
3
13
  if (input instanceof Request) {
4
14
  return input;
@@ -7,18 +17,21 @@ function resolveRequest(input) {
7
17
  }
8
18
  async function resolvePrerenderFetchHandler() {
9
19
  prerenderFetchHandlerPromise ||= (async () => {
10
- try {
11
- const ssrServiceUrl = new URL("../../vite/services/ssr/index.js", import.meta.url);
12
- const ssrService = await import(
13
- /* @vite-ignore */
14
- ssrServiceUrl.href
15
- );
16
- const defaultService = ssrService.default;
17
- const fetchHandler = defaultService?.fetch;
18
- return typeof fetchHandler === "function" ? fetchHandler.bind(defaultService) : void 0;
19
- } catch {
20
- return void 0;
20
+ for (const ssrServiceUrl of resolvePrerenderServiceUrls()) {
21
+ try {
22
+ const ssrService = await import(
23
+ /* @vite-ignore */
24
+ ssrServiceUrl
25
+ );
26
+ const defaultService = ssrService.default;
27
+ const fetchHandler = defaultService?.fetch;
28
+ if (typeof fetchHandler === "function") {
29
+ return fetchHandler.bind(defaultService);
30
+ }
31
+ } catch {
32
+ }
21
33
  }
34
+ return void 0;
22
35
  })();
23
36
  return await prerenderFetchHandlerPromise;
24
37
  }