@monkeyplus/flow 5.0.0-rc.88 → 5.0.0-rc.90
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.
|
@@ -5,7 +5,7 @@ import { resolve, normalize, isAbsolute } from 'pathe';
|
|
|
5
5
|
import { genObjectFromRawEntries, genDynamicImport } from 'knitwork';
|
|
6
6
|
import fse from 'fs-extra';
|
|
7
7
|
import { debounce } from 'perfect-debounce';
|
|
8
|
-
import {
|
|
8
|
+
import { isIgnoredFlow, logger } from '@monkeyplus/flow-kit';
|
|
9
9
|
import { h as hashId, c as createIsExternal, u as uniq, i as isCSS } from './external.mjs';
|
|
10
10
|
import { withTrailingSlash, withoutLeadingSlash } from 'ufo';
|
|
11
11
|
import escapeRE from 'escape-string-regexp';
|
|
@@ -235,7 +235,7 @@ async function initViteDevBundler(ctx, onBuild) {
|
|
|
235
235
|
await _doBuild();
|
|
236
236
|
viteServer.watcher.on("all", (_event, file) => {
|
|
237
237
|
file = normalize(file);
|
|
238
|
-
if (file.indexOf(ctx.nuxt.options.buildDir) === 0 ||
|
|
238
|
+
if (file.indexOf(ctx.nuxt.options.buildDir) === 0 || isIgnoredFlow(file))
|
|
239
239
|
return;
|
|
240
240
|
doBuild();
|
|
241
241
|
});
|
package/dist/chunks/external.mjs
CHANGED
package/dist/chunks/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHooks } from 'hookable';
|
|
2
2
|
import { dirname, resolve, normalize, join, isAbsolute, relative, extname } from 'pathe';
|
|
3
|
-
import { defineFlowModule, addPlugin, defineNuxtModule, logger, addTemplate, addPluginTemplate, addVitePlugin, useNuxt, resolveAlias, resolveFilesFlow, nuxtCtx, installModule, loadFlowConfig, templateUtils, normalizeTemplate, compileTemplate, normalizePlugin,
|
|
3
|
+
import { defineFlowModule, addPlugin, defineNuxtModule, logger, addTemplate, addPluginTemplate, addVitePlugin, useNuxt, resolveAlias, resolveFilesFlow, nuxtCtx, installModule, loadFlowConfig, templateUtils, normalizeTemplate, compileTemplate, normalizePlugin, isIgnoredFlow } from '@monkeyplus/flow-kit';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
5
|
import { defineUnimportPreset, createUnimport, toImports, scanDirExports } from 'unimport';
|
|
6
6
|
import { pathToFileURL } from 'node:url';
|
|
@@ -26,7 +26,7 @@ import replace from '@rollup/plugin-replace';
|
|
|
26
26
|
import { sanitizeFilePath } from 'mlly';
|
|
27
27
|
import { resolveTSConfig } from 'pkg-types';
|
|
28
28
|
|
|
29
|
-
const version = "5.0.0-rc.
|
|
29
|
+
const version = "5.0.0-rc.90";
|
|
30
30
|
|
|
31
31
|
let _distDir = dirname(fileURLToPath(import.meta.url));
|
|
32
32
|
if (_distDir.endsWith("chunks"))
|
|
@@ -231,23 +231,25 @@ ${ctx.generateTypeDeclarations({ resolvePath: r })}`
|
|
|
231
231
|
async function resolveFiles(dir) {
|
|
232
232
|
const nuxt = useNuxt();
|
|
233
233
|
const dirs = [resolve(nuxt.options.srcDir, dir)];
|
|
234
|
-
const allRoutes = (await Promise.all(
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
234
|
+
const allRoutes = (await Promise.all(
|
|
235
|
+
dirs.map(async (dir2) => {
|
|
236
|
+
const files = await resolveFilesFlow(dir2, `**/*{${nuxt.options.extensions.join(",")}}`);
|
|
237
|
+
files.sort();
|
|
238
|
+
return files.filter((file) => {
|
|
239
|
+
if (file.includes(" copy"))
|
|
240
|
+
return false;
|
|
241
|
+
if (!fs.readFileSync(file, "utf8").includes("export"))
|
|
242
|
+
return false;
|
|
243
|
+
return true;
|
|
244
|
+
}).map((file) => {
|
|
245
|
+
const segments = relative(dir2, file).replace(new RegExp(`${escapeRE(extname(file))}$`), "").split("/").join("_");
|
|
246
|
+
return {
|
|
247
|
+
file,
|
|
248
|
+
name: camelCase(segments)
|
|
249
|
+
};
|
|
250
|
+
});
|
|
251
|
+
})
|
|
252
|
+
)).flat();
|
|
251
253
|
return allRoutes;
|
|
252
254
|
}
|
|
253
255
|
function normalizeExports(files) {
|
|
@@ -370,6 +372,7 @@ const createClient = async (flow) => {
|
|
|
370
372
|
});
|
|
371
373
|
return vite;
|
|
372
374
|
};
|
|
375
|
+
|
|
373
376
|
const builClient = async (flow) => {
|
|
374
377
|
return await build$1({
|
|
375
378
|
base: flow.options.dev ? "/" : flow.options.app.baseURL,
|
|
@@ -381,7 +384,6 @@ const builClient = async (flow) => {
|
|
|
381
384
|
}
|
|
382
385
|
});
|
|
383
386
|
};
|
|
384
|
-
|
|
385
387
|
const viteModule = defineFlowModule({
|
|
386
388
|
meta: {
|
|
387
389
|
name: "vite-client",
|
|
@@ -736,22 +738,30 @@ const schemaTemplate = {
|
|
|
736
738
|
"import { FlowModule } from '@monkeyplus/flow-schema'",
|
|
737
739
|
"declare module '@monkeyplus/flow-schema' {",
|
|
738
740
|
" interface FlowConfig {",
|
|
739
|
-
...moduleInfo.filter(Boolean).map(
|
|
741
|
+
...moduleInfo.filter(Boolean).map(
|
|
742
|
+
(meta) => ` [${genString(meta.configKey)}]?: typeof ${genDynamicImport(meta.importName, { wrapper: false })}.default extends FlowModule<infer O> ? Partial<O> : Record<string, any>`
|
|
743
|
+
),
|
|
740
744
|
" }",
|
|
741
|
-
generateTypes(
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
745
|
+
generateTypes(
|
|
746
|
+
resolveSchema(Object.fromEntries(Object.entries(nuxt.options.runtimeConfig).filter(([key]) => key !== "public"))),
|
|
747
|
+
{
|
|
748
|
+
interfaceName: "RuntimeConfig",
|
|
749
|
+
addExport: false,
|
|
750
|
+
addDefaults: false,
|
|
751
|
+
allowExtraKeys: false,
|
|
752
|
+
indentation: 2
|
|
753
|
+
}
|
|
754
|
+
),
|
|
755
|
+
generateTypes(
|
|
756
|
+
resolveSchema(nuxt.options.runtimeConfig.public),
|
|
757
|
+
{
|
|
758
|
+
interfaceName: "PublicRuntimeConfig",
|
|
759
|
+
addExport: false,
|
|
760
|
+
addDefaults: false,
|
|
761
|
+
allowExtraKeys: false,
|
|
762
|
+
indentation: 2
|
|
763
|
+
}
|
|
764
|
+
),
|
|
755
765
|
"}"
|
|
756
766
|
].join("\n");
|
|
757
767
|
}
|
|
@@ -792,35 +802,41 @@ function createApp(flow, options = {}) {
|
|
|
792
802
|
}
|
|
793
803
|
async function generateApp(flow, app) {
|
|
794
804
|
await resolveApp(flow, app);
|
|
795
|
-
app.templates = Object.values(defaultTemplates).concat(
|
|
805
|
+
app.templates = Object.values(defaultTemplates).concat(
|
|
806
|
+
flow.options.build.templates
|
|
807
|
+
);
|
|
796
808
|
await flow.callHook("app:templates", app);
|
|
797
809
|
app.templates = app.templates.map((tmpl) => normalizeTemplate(tmpl));
|
|
798
810
|
const templateContext = { utils: templateUtils, nuxt: flow, app };
|
|
799
|
-
await Promise.all(
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
811
|
+
await Promise.all(
|
|
812
|
+
app.templates.map(async (template) => {
|
|
813
|
+
const contents = await compileTemplate(template, templateContext);
|
|
814
|
+
const fullPath = template.dst || resolve(flow.options.buildDir, template.filename);
|
|
815
|
+
flow.vfs[fullPath] = contents;
|
|
816
|
+
const aliasPath = `#build/${template.filename.replace(/\.\w+$/, "")}`;
|
|
817
|
+
flow.vfs[aliasPath] = contents;
|
|
818
|
+
if (process.platform === "win32")
|
|
819
|
+
flow.vfs[fullPath.replace(/\//g, "\\")] = contents;
|
|
820
|
+
if (template.write) {
|
|
821
|
+
await promises.mkdir(dirname(fullPath), { recursive: true });
|
|
822
|
+
await promises.writeFile(fullPath, contents, "utf8");
|
|
823
|
+
}
|
|
824
|
+
})
|
|
825
|
+
);
|
|
812
826
|
await flow.callHook("app:templatesGenerated", app);
|
|
813
827
|
}
|
|
814
828
|
async function resolveApp(flow, app) {
|
|
815
829
|
app.plugins = [...flow.options.plugins.map(normalizePlugin)];
|
|
816
830
|
for (const config of flow.options._layers.map((layer) => layer.config)) {
|
|
817
|
-
app.plugins.push(
|
|
818
|
-
...
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
831
|
+
app.plugins.push(
|
|
832
|
+
...[
|
|
833
|
+
...config.plugins || [],
|
|
834
|
+
...await resolveFilesFlow(config.srcDir, [
|
|
835
|
+
"plugins/*.{ts,js,mjs,cjs,mts,cts}",
|
|
836
|
+
"plugins/*/index.*{ts,js,mjs,cjs,mts,cts}"
|
|
837
|
+
])
|
|
838
|
+
].map((plugin) => normalizePlugin(plugin))
|
|
839
|
+
);
|
|
824
840
|
}
|
|
825
841
|
app.plugins = uniqueBy(app.plugins, "src");
|
|
826
842
|
await flow.callHook("app:resolve", app);
|
|
@@ -1010,51 +1026,54 @@ async function bundle$1(nuxt) {
|
|
|
1010
1026
|
const ctx = {
|
|
1011
1027
|
nuxt,
|
|
1012
1028
|
entry,
|
|
1013
|
-
config: vite.mergeConfig(
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
optimizeDeps: {
|
|
1026
|
-
entries: [entry],
|
|
1027
|
-
include: []
|
|
1028
|
-
},
|
|
1029
|
-
build: {
|
|
1030
|
-
rollupOptions: {
|
|
1031
|
-
output: { sanitizeFileName: sanitizeFilePath },
|
|
1032
|
-
input: resolve(nuxt.options.appDir, "entry")
|
|
1029
|
+
config: vite.mergeConfig(
|
|
1030
|
+
{
|
|
1031
|
+
configFile: false,
|
|
1032
|
+
resolve: {
|
|
1033
|
+
alias: {
|
|
1034
|
+
...nuxt.options.alias,
|
|
1035
|
+
"#app": nuxt.options.appDir,
|
|
1036
|
+
"#build/plugins": "",
|
|
1037
|
+
"#build": nuxt.options.buildDir,
|
|
1038
|
+
"web-streams-polyfill/ponyfill/es2018": "unenv/runtime/mock/empty",
|
|
1039
|
+
"abort-controller": "unenv/runtime/mock/empty"
|
|
1040
|
+
}
|
|
1033
1041
|
},
|
|
1034
|
-
|
|
1035
|
-
|
|
1042
|
+
optimizeDeps: {
|
|
1043
|
+
entries: [entry],
|
|
1044
|
+
include: []
|
|
1045
|
+
},
|
|
1046
|
+
build: {
|
|
1047
|
+
rollupOptions: {
|
|
1048
|
+
output: { sanitizeFileName: sanitizeFilePath },
|
|
1049
|
+
input: resolve(nuxt.options.appDir, "entry")
|
|
1050
|
+
},
|
|
1051
|
+
watch: {
|
|
1052
|
+
exclude: nuxt.options.ignore
|
|
1053
|
+
}
|
|
1054
|
+
},
|
|
1055
|
+
plugins: [
|
|
1056
|
+
replace({
|
|
1057
|
+
...Object.fromEntries([";", "(", "{", "}", " ", " ", "\n"].map((d) => [`${d}global.`, `${d}globalThis.`])),
|
|
1058
|
+
preventAssignment: true
|
|
1059
|
+
}),
|
|
1060
|
+
virtual(nuxt.vfs)
|
|
1061
|
+
],
|
|
1062
|
+
vue: {
|
|
1063
|
+
reactivityTransform: nuxt.options.experimental.reactivityTransform
|
|
1064
|
+
},
|
|
1065
|
+
server: {
|
|
1066
|
+
watch: { ignored: isIgnoredFlow },
|
|
1067
|
+
fs: {
|
|
1068
|
+
allow: [
|
|
1069
|
+
nuxt.options.appDir
|
|
1070
|
+
]
|
|
1071
|
+
},
|
|
1072
|
+
hmr: false
|
|
1036
1073
|
}
|
|
1037
1074
|
},
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
...Object.fromEntries([";", "(", "{", "}", " ", " ", "\n"].map((d) => [`${d}global.`, `${d}globalThis.`])),
|
|
1041
|
-
preventAssignment: true
|
|
1042
|
-
}),
|
|
1043
|
-
virtual(nuxt.vfs)
|
|
1044
|
-
],
|
|
1045
|
-
vue: {
|
|
1046
|
-
reactivityTransform: nuxt.options.experimental.reactivityTransform
|
|
1047
|
-
},
|
|
1048
|
-
server: {
|
|
1049
|
-
watch: { ignored: isIgnored },
|
|
1050
|
-
fs: {
|
|
1051
|
-
allow: [
|
|
1052
|
-
nuxt.options.appDir
|
|
1053
|
-
]
|
|
1054
|
-
},
|
|
1055
|
-
hmr: false
|
|
1056
|
-
}
|
|
1057
|
-
}, nuxt.options.vite)
|
|
1075
|
+
nuxt.options.vite
|
|
1076
|
+
)
|
|
1058
1077
|
};
|
|
1059
1078
|
if (!nuxt.options.dev) {
|
|
1060
1079
|
ctx.config.server.watch = void 0;
|
|
@@ -142,8 +142,14 @@ async function initViteNodeServer(ctx) {
|
|
|
142
142
|
process.env.NUXT_VITE_NODE_OPTIONS = JSON.stringify(viteNodeServerOptions);
|
|
143
143
|
const serverResolvedPath = resolve$1(distDir, "core/runtime/vite-node.mjs");
|
|
144
144
|
const manifestResolvedPath = resolve$1(distDir, "core/runtime/client.manifest.mjs");
|
|
145
|
-
await fse.writeFile(
|
|
146
|
-
|
|
145
|
+
await fse.writeFile(
|
|
146
|
+
resolve$1(ctx.nuxt.options.buildDir, "dist/server/server.mjs"),
|
|
147
|
+
`export { default } from ${JSON.stringify(pathToFileURL(serverResolvedPath).href)}`
|
|
148
|
+
);
|
|
149
|
+
await fse.writeFile(
|
|
150
|
+
resolve$1(ctx.nuxt.options.buildDir, "dist/server/client.manifest.mjs"),
|
|
151
|
+
`export { default } from ${JSON.stringify(pathToFileURL(manifestResolvedPath).href)}`
|
|
152
|
+
);
|
|
147
153
|
}
|
|
148
154
|
|
|
149
155
|
export { initViteNodeServer, registerViteNodeMiddleware, viteNodePlugin };
|
|
@@ -16,7 +16,11 @@ export default defineFlowPlugin(async (flow) => {
|
|
|
16
16
|
name,
|
|
17
17
|
...page
|
|
18
18
|
});
|
|
19
|
-
const _pages2 = getPages(
|
|
19
|
+
const _pages2 = getPages(
|
|
20
|
+
app.locale.location,
|
|
21
|
+
app.locale.language,
|
|
22
|
+
app.locale.locales
|
|
23
|
+
);
|
|
20
24
|
_pages2.forEach((page2) => {
|
|
21
25
|
flow.router.byUrl.insert(page2.url, page2.context);
|
|
22
26
|
flow.router.byName.insert(page2.name, page2.context);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { joinURL } from "ufo";
|
|
2
2
|
export const generateBundle = (config, bundle, _id) => {
|
|
3
|
-
const analyzedChunk = new Map();
|
|
4
|
-
const getImportedChunks = (chunk2, seen = new Set()) => {
|
|
3
|
+
const analyzedChunk = /* @__PURE__ */ new Map();
|
|
4
|
+
const getImportedChunks = (chunk2, seen = /* @__PURE__ */ new Set()) => {
|
|
5
5
|
const chunks = [];
|
|
6
6
|
chunk2.imports?.forEach((file) => {
|
|
7
7
|
const importee = bundle[file];
|
|
@@ -31,7 +31,7 @@ export const generateBundle = (config, bundle, _id) => {
|
|
|
31
31
|
href: toPublicPath(chunk2.file, publicBase2)
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
|
-
const getCssTagsForChunk = (chunk2, publicBase2, seen = new Set()) => {
|
|
34
|
+
const getCssTagsForChunk = (chunk2, publicBase2, seen = /* @__PURE__ */ new Set()) => {
|
|
35
35
|
const tags = [];
|
|
36
36
|
if (!analyzedChunk.has(chunk2)) {
|
|
37
37
|
analyzedChunk.set(chunk2, 1);
|
|
@@ -57,7 +57,9 @@ export const generateBundle = (config, bundle, _id) => {
|
|
|
57
57
|
};
|
|
58
58
|
const publicBase = config.baseURL || "/";
|
|
59
59
|
const isAsync = false;
|
|
60
|
-
const chunk = Object.values(bundle).find(
|
|
60
|
+
const chunk = Object.values(bundle).find(
|
|
61
|
+
(chunk2) => chunk2.isEntry && chunk2.src === _id
|
|
62
|
+
);
|
|
61
63
|
if (chunk) {
|
|
62
64
|
const imports = getImportedChunks(chunk);
|
|
63
65
|
const assetTags = [
|
|
@@ -74,12 +76,15 @@ export const isExternalUrl = (url) => externalRE.test(url);
|
|
|
74
76
|
function toPublicPath(filename, publicBase) {
|
|
75
77
|
return isExternalUrl(filename) ? filename : joinURL(publicBase, filename);
|
|
76
78
|
}
|
|
77
|
-
const unaryTags = new Set(["link", "meta", "base"]);
|
|
79
|
+
const unaryTags = /* @__PURE__ */ new Set(["link", "meta", "base"]);
|
|
78
80
|
function serializeTag({ tag, attrs, children }, indent = "") {
|
|
79
81
|
if (unaryTags.has(tag)) {
|
|
80
82
|
return `<${tag}${serializeAttrs(attrs)}>`;
|
|
81
83
|
} else {
|
|
82
|
-
return `<${tag}${serializeAttrs(attrs)}>${serializeTags(
|
|
84
|
+
return `<${tag}${serializeAttrs(attrs)}>${serializeTags(
|
|
85
|
+
children,
|
|
86
|
+
incrementIndent(indent)
|
|
87
|
+
)}</${tag}>`;
|
|
83
88
|
}
|
|
84
89
|
}
|
|
85
90
|
function serializeTags(tags, indent = "") {
|
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.90",
|
|
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.90",
|
|
29
|
+
"@monkeyplus/flow-kit": "5.0.0-rc.90",
|
|
30
|
+
"@monkeyplus/flow-schema": "5.0.0-rc.90",
|
|
31
31
|
"@rollup/plugin-replace": "^4.0.0",
|
|
32
32
|
"@vueuse/head": "^0.7.6",
|
|
33
33
|
"c12": "^0.2.8",
|
|
@@ -62,12 +62,12 @@
|
|
|
62
62
|
"rollup-plugin-visualizer": "^5.7.1",
|
|
63
63
|
"scule": "^0.2.1",
|
|
64
64
|
"ufo": "^0.8.5",
|
|
65
|
-
"unctx": "^
|
|
65
|
+
"unctx": "^2.0.1",
|
|
66
66
|
"unimport": "^0.4.5",
|
|
67
|
-
"unplugin": "^0.
|
|
67
|
+
"unplugin": "^0.9.4",
|
|
68
68
|
"untyped": "^0.4.5",
|
|
69
69
|
"pkg-types": "^0.3.3",
|
|
70
|
-
"vite": "
|
|
70
|
+
"vite": "2.9.15",
|
|
71
71
|
"vite-node": "^0.22.1",
|
|
72
72
|
"vite-plugin-checker": "^0.4.9",
|
|
73
73
|
"vue-bundle-renderer": "^0.4.2",
|