@monkeyplus/flow 5.0.0-rc.108 → 5.0.0-rc.109
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.
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "node-fetch-native/polyfill";
|
|
2
2
|
import { eventHandler } from "h3";
|
|
3
3
|
import { defineCachedFunction, useRuntimeConfig } from "#internal/nitro";
|
|
4
|
-
const getServerApp =
|
|
5
|
-
export const getFlowRenderer =
|
|
4
|
+
const getServerApp = () => import("#server").then((r) => r?.default?.default || r?.default || r);
|
|
5
|
+
export const getFlowRenderer = lazyCachedFunction(async () => {
|
|
6
6
|
const createFlowApp = await getServerApp();
|
|
7
7
|
if (!createFlowApp)
|
|
8
8
|
throw new Error("Server bundle is not available");
|
|
@@ -14,13 +14,7 @@ export default eventHandler(async (event) => {
|
|
|
14
14
|
event.context.render = flow.render;
|
|
15
15
|
event.context.defineCachedFunction = defineCachedFunction;
|
|
16
16
|
});
|
|
17
|
-
function
|
|
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) {
|
|
17
|
+
function lazyCachedFunction(fn) {
|
|
24
18
|
let res = null;
|
|
25
19
|
return () => {
|
|
26
20
|
if (res === null)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { eventHandler, getQuery } from "h3";
|
|
2
2
|
import { joinURL } from "ufo";
|
|
3
|
+
import { getFlowRenderer } from "./flow.mjs";
|
|
3
4
|
const normalizeCall = async (seo, ctx) => {
|
|
4
5
|
if (typeof seo === "function")
|
|
5
6
|
return await seo(ctx);
|
|
@@ -19,7 +20,7 @@ function replacePath(_path, url) {
|
|
|
19
20
|
}
|
|
20
21
|
export default eventHandler(async (event) => {
|
|
21
22
|
const url = event.req.url?.split("?")[0];
|
|
22
|
-
const flow =
|
|
23
|
+
const flow = await getFlowRenderer();
|
|
23
24
|
if (url.includes("_urls")) {
|
|
24
25
|
const urls = await flow.app.utils.getUrls();
|
|
25
26
|
return urls;
|
package/dist/index.mjs
CHANGED
|
@@ -2,10 +2,9 @@ import { createHooks } from 'hookable';
|
|
|
2
2
|
import { dirname, resolve, normalize, join, isAbsolute, relative, extname } from 'pathe';
|
|
3
3
|
import { defineFlowModule, addPlugin, defineNuxtModule, logger, addTemplate, addPluginTemplate, addVitePlugin, addWebpackPlugin, updateTemplates, useNuxt, resolveAlias, resolveFilesFlow, nuxtCtx, installModule, loadFlowConfig, normalizeTemplate, compileTemplate, normalizePlugin, findPath, templateUtils, isIgnoredFlow } from '@monkeyplus/flow-kit';
|
|
4
4
|
import escapeRE from 'escape-string-regexp';
|
|
5
|
-
import { fileURLToPath } from 'url';
|
|
5
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
6
6
|
import { defineUnimportPreset, createUnimport, toImports, scanDirExports } from 'unimport';
|
|
7
7
|
import defu from 'defu';
|
|
8
|
-
import { pathToFileURL } from 'node:url';
|
|
9
8
|
import { createUnplugin } from 'unplugin';
|
|
10
9
|
import { parseURL, parseQuery, joinURL } from 'ufo';
|
|
11
10
|
import fs from 'fs';
|
|
@@ -25,10 +24,10 @@ import replace from '@rollup/plugin-replace';
|
|
|
25
24
|
import { resolveTSConfig } from 'pkg-types';
|
|
26
25
|
import fse from 'fs-extra';
|
|
27
26
|
|
|
28
|
-
const version = "5.0.0-rc.
|
|
27
|
+
const version = "5.0.0-rc.109";
|
|
29
28
|
|
|
30
29
|
let _distDir = dirname(fileURLToPath(import.meta.url));
|
|
31
|
-
if (_distDir.
|
|
30
|
+
if (_distDir.match(/(chunks|shared)$/))
|
|
32
31
|
_distDir = dirname(_distDir);
|
|
33
32
|
const distDir = _distDir;
|
|
34
33
|
const pkgDir = resolve(distDir, "..");
|
|
@@ -402,13 +401,14 @@ const ImportProtectionPlugin = createUnplugin((options) => {
|
|
|
402
401
|
async function initNitro(flow) {
|
|
403
402
|
const _nitroConfig = flow.options.nitro || {};
|
|
404
403
|
globalThis.generate = {};
|
|
404
|
+
const scanDirs = flow.options._layers.map((layer) => (layer.config.serverDir || layer.config.srcDir) && resolve(layer.cwd, layer.config.serverDir || resolve(layer.config.srcDir, "server"))).filter(Boolean);
|
|
405
405
|
const nitroConfig = defu(_nitroConfig, {
|
|
406
406
|
rootDir: flow.options.rootDir,
|
|
407
407
|
workspaceDir: flow.options.workspaceDir,
|
|
408
408
|
srcDir: flow.options.serverDir,
|
|
409
409
|
dev: flow.options.dev,
|
|
410
410
|
buildDir: flow.options.buildDir,
|
|
411
|
-
scanDirs
|
|
411
|
+
scanDirs,
|
|
412
412
|
renderer: resolve(distDir, "core/runtime/nitro/renderer"),
|
|
413
413
|
nodeModulesDirs: flow.options.modulesDir,
|
|
414
414
|
handlers: [
|
|
@@ -456,9 +456,13 @@ async function initNitro(flow) {
|
|
|
456
456
|
inline: [
|
|
457
457
|
...flow.options.dev ? [] : ["eta", "@monkeyplus/", "@vue/", "@nuxt/", flow.options.buildDir],
|
|
458
458
|
"@monkeyplus/flow/dist",
|
|
459
|
-
"C:/Users/gnu/Documents/GitHub/flow/packages/flow/dist/app"
|
|
459
|
+
"C:/Users/gnu/Documents/GitHub/flow/packages/flow/dist/app",
|
|
460
|
+
distDir
|
|
460
461
|
]
|
|
461
462
|
},
|
|
463
|
+
replace: {
|
|
464
|
+
"process.dev": flow.options.dev
|
|
465
|
+
},
|
|
462
466
|
alias: {
|
|
463
467
|
"estree-walker": "unenv/runtime/mock/proxy",
|
|
464
468
|
"@babel/parser": "unenv/runtime/mock/proxy",
|
|
@@ -467,8 +471,10 @@ async function initNitro(flow) {
|
|
|
467
471
|
...flow.options.alias
|
|
468
472
|
},
|
|
469
473
|
rollupConfig: {
|
|
470
|
-
plugins: []
|
|
471
|
-
|
|
474
|
+
plugins: []
|
|
475
|
+
},
|
|
476
|
+
devServer: {
|
|
477
|
+
watch: [resolve(flow.options.buildDir, "dist/server/server.mjs")]
|
|
472
478
|
}
|
|
473
479
|
});
|
|
474
480
|
nitroConfig.rollupConfig.plugins.push(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monkeyplus/flow",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.109",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.mjs",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@monkeyplus/flow-cli": "5.0.0-rc.
|
|
29
|
-
"@monkeyplus/flow-kit": "5.0.0-rc.
|
|
30
|
-
"@monkeyplus/flow-schema": "5.0.0-rc.
|
|
28
|
+
"@monkeyplus/flow-cli": "5.0.0-rc.109",
|
|
29
|
+
"@monkeyplus/flow-kit": "5.0.0-rc.109",
|
|
30
|
+
"@monkeyplus/flow-schema": "5.0.0-rc.109",
|
|
31
31
|
"@rollup/plugin-replace": "^4.0.0",
|
|
32
32
|
"@vueuse/head": "^1.0.16",
|
|
33
33
|
"c12": "^1.0.1",
|