@monkeyplus/flow 6.0.15 → 6.0.17
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.
- package/modules/netlify-cms/runtime/cms.d.ts +2 -2
- package/modules/netlify-cms/runtime/cms.mjs +2 -2
- package/modules/netlify-cms/server/api/config.mjs +4 -4
- package/package.json +1 -1
- package/src/public/nitro.mjs +1 -0
- package/src/public/vite.mjs +54 -4
- package/src/runtime/components/FlowIsland.mjs +2 -2
- package/src/runtime/vue.mjs +10 -0
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { defineCmsCollection } from '../server/lib/composables';
|
|
2
|
-
export { widgets } from '../server/lib/cms/widgets';
|
|
3
1
|
export { collections } from '../server/lib/cms/helpers';
|
|
2
|
+
export { widgets } from '../server/lib/cms/widgets';
|
|
3
|
+
export { defineCmsCollection } from '../server/lib/composables';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { defineCmsCollection } from "../server/lib/composables.mjs";
|
|
2
|
-
export { widgets } from "../server/lib/cms/widgets.mjs";
|
|
3
1
|
export { collections } from "../server/lib/cms/helpers.mjs";
|
|
2
|
+
export { widgets } from "../server/lib/cms/widgets.mjs";
|
|
3
|
+
export { defineCmsCollection } from "../server/lib/composables.mjs";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import process from "node:process";
|
|
1
4
|
import defu from "defu";
|
|
5
|
+
import { createJiti } from "jiti";
|
|
2
6
|
import yml from "js-yaml";
|
|
3
7
|
import { defineEventHandler, setResponseHeader } from "nitro/h3";
|
|
4
8
|
import { collections, defineCms } from "../lib/cms/helpers.mjs";
|
|
5
9
|
import { widgets } from "../lib/cms/widgets.mjs";
|
|
6
|
-
import fs from "node:fs";
|
|
7
|
-
import { resolve } from "node:path";
|
|
8
|
-
import { createJiti } from "jiti";
|
|
9
|
-
import process from "node:process";
|
|
10
10
|
import { defineCmsCollection } from "../lib/composables.mjs";
|
|
11
11
|
export default defineEventHandler(async (event) => {
|
|
12
12
|
if (!globalThis.defineCmsCollection) {
|
package/package.json
CHANGED
package/src/public/nitro.mjs
CHANGED
package/src/public/vite.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync } from "node:fs";
|
|
1
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { relative, resolve } from "node:path";
|
|
3
3
|
import ui from "@nuxt/ui/vite";
|
|
4
4
|
import Vue from "@vitejs/plugin-vue";
|
|
@@ -240,11 +240,27 @@ function createFlowVirtualClientPages(projectRoot) {
|
|
|
240
240
|
}
|
|
241
241
|
};
|
|
242
242
|
}
|
|
243
|
+
function FlowComponentsResolver() {
|
|
244
|
+
return {
|
|
245
|
+
type: "component",
|
|
246
|
+
resolve: (name) => {
|
|
247
|
+
if (["FlowIsland", "MkImage", "MkLink", "MkPicture"].includes(name)) {
|
|
248
|
+
return {
|
|
249
|
+
name,
|
|
250
|
+
from: "@monkeyplus/flow/components"
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
}
|
|
243
256
|
export function createFlowViteConfig(options = {}) {
|
|
244
257
|
const projectRoot = resolve(options.projectRoot || process.cwd());
|
|
245
258
|
const flowConfig = resolveFlowConfig(options.userFlowConfig || {});
|
|
246
259
|
const flowModules = loadFlowModules(projectRoot, flowConfig);
|
|
247
|
-
const flowNitroConfig = {
|
|
260
|
+
const flowNitroConfig = {
|
|
261
|
+
typescript: { generateTsConfig: true },
|
|
262
|
+
...flowConfig.nitro || {}
|
|
263
|
+
};
|
|
248
264
|
const flowNitroHooks = flowNitroConfig.hooks || {};
|
|
249
265
|
const flowPackagePattern = /^@monkeyplus\/flow(?:\/.*)?$/;
|
|
250
266
|
const userPrerenderRoutesHook = typeof flowNitroHooks["prerender:routes"] === "function" ? flowNitroHooks["prerender:routes"] : void 0;
|
|
@@ -260,6 +276,29 @@ export function createFlowViteConfig(options = {}) {
|
|
|
260
276
|
moduleWatch.additionalPaths,
|
|
261
277
|
componentDirs
|
|
262
278
|
);
|
|
279
|
+
const flowTypesDir = resolve(projectRoot, ".flow/types");
|
|
280
|
+
if (!existsSync(flowTypesDir)) {
|
|
281
|
+
mkdirSync(flowTypesDir, { recursive: true });
|
|
282
|
+
}
|
|
283
|
+
writeFileSync(resolve(flowTypesDir, "flow.d.ts"), [
|
|
284
|
+
'/// <reference path="./auto-imports.d.ts" />',
|
|
285
|
+
'/// <reference path="./components.d.ts" />',
|
|
286
|
+
'/// <reference path="../../.nitro/types/nitro-imports.d.ts" />'
|
|
287
|
+
].join("\n"));
|
|
288
|
+
const mappedNitroImports = {};
|
|
289
|
+
if (flowModules.nitro.imports?.imports && Array.isArray(flowModules.nitro.imports.imports)) {
|
|
290
|
+
for (const item of flowModules.nitro.imports.imports) {
|
|
291
|
+
if (!item.from || !item.name) continue;
|
|
292
|
+
if (!mappedNitroImports[item.from]) {
|
|
293
|
+
mappedNitroImports[item.from] = [];
|
|
294
|
+
}
|
|
295
|
+
if (item.as) {
|
|
296
|
+
mappedNitroImports[item.from].push([item.name, item.as]);
|
|
297
|
+
} else {
|
|
298
|
+
mappedNitroImports[item.from].push(item.name);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
263
302
|
return defineConfig({
|
|
264
303
|
plugins: [
|
|
265
304
|
createFlowVirtualServerModules(projectRoot, flowConfig),
|
|
@@ -274,14 +313,25 @@ export function createFlowViteConfig(options = {}) {
|
|
|
274
313
|
ui({
|
|
275
314
|
router: false,
|
|
276
315
|
components: {
|
|
316
|
+
dts: resolve(projectRoot, ".flow/types/components.d.ts"),
|
|
277
317
|
...options.userFlowConfig?.components,
|
|
278
318
|
resolvers: [
|
|
319
|
+
FlowComponentsResolver(),
|
|
279
320
|
IconsResolver(),
|
|
280
321
|
...options.userFlowConfig?.components?.resolvers || []
|
|
281
322
|
]
|
|
282
|
-
// dirs: [],
|
|
283
323
|
},
|
|
284
|
-
autoImport:
|
|
324
|
+
autoImport: {
|
|
325
|
+
dts: resolve(projectRoot, ".flow/types/auto-imports.d.ts"),
|
|
326
|
+
imports: [
|
|
327
|
+
{
|
|
328
|
+
"@monkeyplus/flow": ["definePage", "defineLayoutContext", "queryContent"],
|
|
329
|
+
...mappedNitroImports
|
|
330
|
+
},
|
|
331
|
+
...options.userFlowConfig?.autoImport?.imports || []
|
|
332
|
+
],
|
|
333
|
+
...options.userFlowConfig?.autoImport
|
|
334
|
+
}
|
|
285
335
|
}),
|
|
286
336
|
nitro({
|
|
287
337
|
...flowNitroConfig,
|
|
@@ -23,13 +23,13 @@ export default defineComponent({
|
|
|
23
23
|
default: "div"
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
|
-
setup(props) {
|
|
26
|
+
setup(props, { slots }) {
|
|
27
27
|
const attrs = useAttrs();
|
|
28
28
|
return () => h(props.tag, mergeProps(attrs, {
|
|
29
29
|
"data-flow-island": props.name.toLowerCase(),
|
|
30
30
|
"data-flow-props": serializeIslandProps(props.props)
|
|
31
31
|
}), [
|
|
32
|
-
h(props.component, props.props)
|
|
32
|
+
h(props.component, props.props, slots)
|
|
33
33
|
]);
|
|
34
34
|
}
|
|
35
35
|
});
|
package/src/runtime/vue.mjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import ui from "@nuxt/ui/vue-plugin";
|
|
2
|
+
import { createPinia } from "pinia";
|
|
2
3
|
import MkImage from "./components/MkImage.mjs";
|
|
3
4
|
import MkLink from "./components/MkLink.mjs";
|
|
4
5
|
import MkPicture from "./components/MkPicture.mjs";
|
|
6
|
+
let sharedPinia = null;
|
|
5
7
|
export function installFlowVuePlugins(app, { ui: enableUi } = { ui: true }) {
|
|
6
8
|
if (enableUi) {
|
|
7
9
|
app.use(ui);
|
|
@@ -9,5 +11,13 @@ export function installFlowVuePlugins(app, { ui: enableUi } = { ui: true }) {
|
|
|
9
11
|
app.component("MkImage", MkImage);
|
|
10
12
|
app.component("MkLink", MkLink);
|
|
11
13
|
app.component("MkPicture", MkPicture);
|
|
14
|
+
if (typeof window !== "undefined") {
|
|
15
|
+
if (!sharedPinia) {
|
|
16
|
+
sharedPinia = createPinia();
|
|
17
|
+
}
|
|
18
|
+
app.use(sharedPinia);
|
|
19
|
+
} else {
|
|
20
|
+
app.use(createPinia());
|
|
21
|
+
}
|
|
12
22
|
return app;
|
|
13
23
|
}
|