@monkeyplus/flow 5.0.0-rc.107 → 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(
|
|
@@ -540,7 +546,6 @@ const addModuleTranspiles = (opts = {}) => {
|
|
|
540
546
|
const flow = useNuxt();
|
|
541
547
|
const modules = [
|
|
542
548
|
...opts.additionalModules || [],
|
|
543
|
-
...flow.options.buildModules,
|
|
544
549
|
...flow.options.modules,
|
|
545
550
|
...flow.options._modules
|
|
546
551
|
].map((m) => typeof m === "string" ? m : Array.isArray(m) ? m[0] : m.src).filter((m) => typeof m === "string").map((m) => m.split("node_modules/").pop());
|
|
@@ -557,7 +562,7 @@ const addModuleTranspiles = (opts = {}) => {
|
|
|
557
562
|
function createFlow(options) {
|
|
558
563
|
const hooks = createHooks();
|
|
559
564
|
const flow = {
|
|
560
|
-
_version: "3.0.0
|
|
565
|
+
_version: "3.0.0",
|
|
561
566
|
version,
|
|
562
567
|
options,
|
|
563
568
|
hooks,
|
|
@@ -576,24 +581,9 @@ async function initFlow(flow) {
|
|
|
576
581
|
flow.hook("close", () => nuxtCtx.unset());
|
|
577
582
|
await flow.callHook("modules:before");
|
|
578
583
|
const modulesToInstall = [
|
|
579
|
-
...flow.options.buildModules,
|
|
580
584
|
...flow.options.modules,
|
|
581
585
|
...flow.options._modules
|
|
582
586
|
];
|
|
583
|
-
flow.hooks.deprecateHooks({
|
|
584
|
-
"autoImports:sources": {
|
|
585
|
-
to: "imports:sources",
|
|
586
|
-
message: "`autoImports:sources` hook is deprecated. Use `addImportsSources()` from `@nuxt/kit` or `imports:dirs` with `nuxt>=3.0.0-rc.10`."
|
|
587
|
-
},
|
|
588
|
-
"autoImports:dirs": {
|
|
589
|
-
to: "imports:dirs",
|
|
590
|
-
message: "`autoImports:dirs` hook is deprecated. Use `addImportsDir()` from `@nuxt/kit` or `imports:dirs` with `nuxt>=3.0.0-rc.9`."
|
|
591
|
-
},
|
|
592
|
-
"autoImports:extend": {
|
|
593
|
-
to: "imports:extend",
|
|
594
|
-
message: "`autoImports:extend` hook is deprecated. Use `addImports()` from `@nuxt/kit` or `imports:extend` with `nuxt>=3.0.0-rc.9`."
|
|
595
|
-
}
|
|
596
|
-
});
|
|
597
587
|
for (const m of modulesToInstall) {
|
|
598
588
|
if (Array.isArray(m))
|
|
599
589
|
await installModule(m[0], m[1]);
|
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,12 +25,12 @@
|
|
|
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
|
-
"@vueuse/head": "^0.
|
|
33
|
-
"c12": "^0.
|
|
32
|
+
"@vueuse/head": "^1.0.16",
|
|
33
|
+
"c12": "^1.0.1",
|
|
34
34
|
"chokidar": "^3.5.3",
|
|
35
35
|
"consola": "^2.15.3",
|
|
36
36
|
"defu": "^6.1.0",
|
|
@@ -38,38 +38,38 @@
|
|
|
38
38
|
"escape-string-regexp": "^5.0.0",
|
|
39
39
|
"esno": "^0.16.3",
|
|
40
40
|
"eta": "^1.12.3",
|
|
41
|
-
"externality": "^0.
|
|
41
|
+
"externality": "^1.0.0",
|
|
42
42
|
"fs-extra": "^10.1.0",
|
|
43
43
|
"globby": "^13.1.2",
|
|
44
|
-
"h3": "^0.
|
|
45
|
-
"hookable": "^5.4.
|
|
44
|
+
"h3": "^1.0.1",
|
|
45
|
+
"hookable": "^5.4.2",
|
|
46
46
|
"jiti": "^1.16.0",
|
|
47
|
-
"ohash": "^0.
|
|
48
|
-
"knitwork": "^0.
|
|
49
|
-
"listhen": "^0.
|
|
47
|
+
"ohash": "^1.0.0",
|
|
48
|
+
"knitwork": "^1.0.0",
|
|
49
|
+
"listhen": "^1.0.0",
|
|
50
50
|
"magic-string": "^0.26.7",
|
|
51
|
-
"mlly": "^0.
|
|
51
|
+
"mlly": "^1.0.0",
|
|
52
52
|
"mri": "^1.2.0",
|
|
53
|
-
"nitropack": "^0.
|
|
54
|
-
"pathe": "^0.
|
|
53
|
+
"nitropack": "^1.0.0",
|
|
54
|
+
"pathe": "^1.0.0",
|
|
55
55
|
"perfect-debounce": "^0.1.3",
|
|
56
|
-
"radix3": "^0.
|
|
57
|
-
"unenv": "^0.
|
|
56
|
+
"radix3": "^1.0.0",
|
|
57
|
+
"unenv": "^1.0.0",
|
|
58
58
|
"ohmyfetch": "^0.4.21",
|
|
59
|
-
"node-fetch-native": "^0.1
|
|
59
|
+
"node-fetch-native": "^1.0.1",
|
|
60
60
|
"rollup": "^2.79.1",
|
|
61
61
|
"rollup-plugin-visualizer": "^5.8.3",
|
|
62
|
-
"scule": "^0.
|
|
63
|
-
"ufo": "^0.
|
|
64
|
-
"unctx": "^2.0
|
|
65
|
-
"unimport": "^0.
|
|
66
|
-
"unplugin": "^0.
|
|
67
|
-
"untyped": "^0.
|
|
68
|
-
"pkg-types": "^0.
|
|
62
|
+
"scule": "^1.0.0",
|
|
63
|
+
"ufo": "^1.0.0",
|
|
64
|
+
"unctx": "^2.1.0",
|
|
65
|
+
"unimport": "^1.0.1",
|
|
66
|
+
"unplugin": "^1.0.0",
|
|
67
|
+
"untyped": "^1.0.0",
|
|
68
|
+
"pkg-types": "^1.0.1",
|
|
69
69
|
"vite": "~3.2.2",
|
|
70
70
|
"vite-node": "^0.24.5",
|
|
71
71
|
"vite-plugin-checker": "^0.5.1",
|
|
72
|
-
"vue-bundle-renderer": "^0.
|
|
72
|
+
"vue-bundle-renderer": "^1.0.0",
|
|
73
73
|
"vue": "^3.2.41"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|