@monkeyplus/flow 6.0.17 → 6.0.19
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/README.md +2 -0
- package/cms/dist/assets/Button-BqeUw3Nb.js +1 -0
- package/cms/dist/assets/Cms--iKNGffI.js +1 -0
- package/cms/dist/assets/Cms-DPkKSuvX.js +1 -0
- package/cms/dist/assets/Cms.vue_vue_type_script_setup_true_lang-BLjYlaya.js +1 -0
- package/cms/dist/assets/Collection-CC4xVuVM.js +1 -0
- package/cms/dist/assets/Collection-oMH_nwxS.js +1 -0
- package/cms/dist/assets/Collection-sfaJ9fwa.js +1 -0
- package/cms/dist/assets/Collection.vue_vue_type_script_setup_true_lang-DBh9sOKn.js +4 -0
- package/cms/dist/assets/DropdownMenu-pXjjYDJf.js +1 -0
- package/cms/dist/assets/EditorDragHandle-DjhDrza4.js +210 -0
- package/cms/dist/assets/Entry-D1FEE6Xe.js +1 -0
- package/cms/dist/assets/Entry-DIjoQMCn.js +1 -0
- package/cms/dist/assets/Entry-Dx-Gentu.js +1 -0
- package/cms/dist/assets/Entry-futdQUpk.js +1 -0
- package/cms/dist/assets/Entry.vue_vue_type_script_setup_true_lang-CGsCqUcC.js +1 -0
- package/cms/dist/assets/Entry.vue_vue_type_script_setup_true_lang-yZb441-Z.js +1 -0
- package/cms/dist/assets/Fields-1zzijKwy.css +1 -0
- package/cms/dist/assets/Fields-DG6uyVyw.js +1 -0
- package/cms/dist/assets/Main-Xea2Go7n.js +1 -0
- package/cms/dist/assets/Media-D9qcmiia.js +64 -0
- package/cms/dist/assets/Modal-DzMlh1K9.js +1 -0
- package/cms/dist/assets/Page-Bg6ZJkCi.js +1 -0
- package/cms/dist/assets/PageSideForm-CJvudHte.js +1 -0
- package/cms/dist/assets/PageSideForm-v14TdYOR.js +1 -0
- package/cms/dist/assets/Pages-CgtLUrd1.js +1 -0
- package/cms/dist/assets/Pages-Colx-y_M.js +1 -0
- package/cms/dist/assets/Presence-DXmvDu-B.js +3 -0
- package/cms/dist/assets/Preview-DyW6gcwI.js +1 -0
- package/cms/dist/assets/RovingFocusGroup-Zc2iLojI.js +1 -0
- package/cms/dist/assets/RovingFocusItem-XP2WbDfI.js +1 -0
- package/cms/dist/assets/Settings-6BY8hMNJ.js +1 -0
- package/cms/dist/assets/Sidebar-7tc1rH-m.js +1 -0
- package/cms/dist/assets/TooltipProvider-T49u14GZ.js +1 -0
- package/cms/dist/assets/_plugin-vue_export-helper-BDNMzG2s.js +1 -0
- package/cms/dist/assets/app-DBVODLiC.js +1 -0
- package/cms/dist/assets/app-DBac-q-m.css +2 -0
- package/cms/dist/assets/app-DzK4b1Um.js +1 -0
- package/cms/dist/assets/app.vue_vue_type_script_setup_true_lang-BXAw_NlS.js +13 -0
- package/cms/dist/assets/cms-D2eW8dB-.js +1 -0
- package/cms/dist/assets/dist-DASomEJF.js +1 -0
- package/cms/dist/assets/dist-TO46HCAG.js +1 -0
- package/cms/dist/assets/en.svg +11 -0
- package/cms/dist/assets/es-ec.svg +13 -0
- package/cms/dist/assets/es.svg +42 -0
- package/cms/dist/assets/index-1Es5a0_Z.js +18 -0
- package/cms/dist/assets/index-yfLwsAFs.css +1 -0
- package/cms/dist/assets/index.vue_vue_type_style_index_0_scoped_2e5c9142_lang-CfB8rLPy.js +1 -0
- package/cms/dist/assets/logger-DSeL-og4.js +10 -0
- package/cms/dist/assets/not-found-B8Yomlc0.js +1 -0
- package/cms/dist/assets/not-found-z4zyiO6n.js +1 -0
- package/cms/dist/assets/pages-B6dE90Nv.js +1 -0
- package/cms/dist/assets/pages-kaHLKSrN.js +1 -0
- package/cms/dist/assets/preview-D1CIVM6p.js +1 -0
- package/cms/dist/assets/useCmsBreadcrumb-BGzdrscS.js +1 -0
- package/cms/dist/assets/useOverlay-BON7Ngo_.js +1 -0
- package/cms/dist/assets/usePortal-C04XvxfO.js +1 -0
- package/cms/dist/assets/useToast-T1ue7roH.js +1 -0
- package/cms/dist/assets/utils-Cx7OEZFn.js +1 -0
- package/cms/dist/index.html +12 -0
- package/cms/server/database/schema.d.ts +648 -0
- package/cms/server/database/schema.mjs +43 -0
- package/cms/server/routes/api/auth/[...auth].d.ts +2 -0
- package/cms/server/routes/api/auth/[...auth].mjs +5 -0
- package/cms/server/routes/api/draft.d.ts +3 -0
- package/cms/server/routes/api/draft.mjs +26 -0
- package/cms/server/routes/api/repos/remote/[repo]/blobs/[file]/index.d.ts +2 -0
- package/cms/server/routes/api/repos/remote/[repo]/blobs/[file]/index.mjs +20 -0
- package/cms/server/routes/api/repos/remote/[repo]/blobs/index.post.d.ts +2 -0
- package/cms/server/routes/api/repos/remote/[repo]/blobs/index.post.mjs +8 -0
- package/cms/server/routes/api/repos/remote/[repo]/branches/[branch]/index.d.ts +2 -0
- package/cms/server/routes/api/repos/remote/[repo]/branches/[branch]/index.mjs +8 -0
- package/cms/server/routes/api/repos/remote/[repo]/commits/index.post.d.ts +2 -0
- package/cms/server/routes/api/repos/remote/[repo]/commits/index.post.mjs +8 -0
- package/cms/server/routes/api/repos/remote/[repo]/files/[branch]/index.d.ts +2 -0
- package/cms/server/routes/api/repos/remote/[repo]/files/[branch]/index.mjs +38 -0
- package/cms/server/routes/api/repos/remote/[repo]/files/index.post.d.ts +2 -0
- package/cms/server/routes/api/repos/remote/[repo]/files/index.post.mjs +8 -0
- package/cms/server/routes/api/repos/remote/[repo]/refs/heads/[branch]/index.patch.d.ts +2 -0
- package/cms/server/routes/api/repos/remote/[repo]/refs/heads/[branch]/index.patch.mjs +9 -0
- package/cms/server/utils/auth.d.ts +3 -0
- package/cms/server/utils/auth.mjs +16 -0
- package/cms/server/utils/db.d.ts +3 -0
- package/cms/server/utils/db.mjs +5 -0
- package/cms/server/utils/github.d.ts +15 -0
- package/cms/server/utils/github.mjs +160 -0
- package/cms/server/utils/github_token.d.ts +71 -0
- package/cms/server/utils/github_token.mjs +377 -0
- package/modules/cms/module.d.ts +11 -0
- package/modules/cms/module.mjs +163 -0
- package/modules/cms/server/api/admin.d.ts +2 -0
- package/modules/cms/server/api/admin.mjs +18 -0
- package/modules/cms/server/api/config.d.ts +2 -0
- package/modules/cms/server/api/config.mjs +88 -0
- package/modules/cms/server/api/localFs.d.ts +2 -0
- package/modules/cms/server/api/localFs.mjs +88 -0
- package/modules/cms/server/api/meta.d.ts +2 -0
- package/modules/cms/server/api/meta.mjs +12 -0
- package/modules/cms/server/lib/composables.d.ts +116 -0
- package/modules/cms/server/lib/composables.mjs +82 -0
- package/modules/cms/server/lib/fs.d.ts +1 -0
- package/modules/cms/server/lib/fs.mjs +18 -0
- package/modules/cms/server/lib/helpers.d.ts +14 -0
- package/modules/cms/server/lib/helpers.mjs +78 -0
- package/modules/cms/server/lib/types.d.ts +120 -0
- package/modules/cms/server/lib/types.mjs +0 -0
- package/modules/cms/server/lib/widgets.d.ts +82 -0
- package/modules/cms/server/lib/widgets.mjs +200 -0
- package/modules/cms/server/trial.d.ts +2 -0
- package/modules/cms/server/trial.mjs +8 -0
- package/modules/content/query.mjs +31 -3
- package/modules/images/ipx.mjs +4 -2
- package/modules/images/module.d.ts +0 -1
- package/modules/images/module.mjs +5 -3
- package/modules/images/runtime/build.mjs +12 -0
- package/modules/images/runtime/image.mjs +4 -3
- package/modules/images/runtime/renames.mjs +59 -8
- package/modules/images/runtime/types.d.ts +27 -4
- package/modules/images/watermark.d.ts +1 -0
- package/modules/images/watermark.mjs +113 -0
- package/modules/netlify-cms/handler.mjs +2 -1
- package/modules/netlify-cms/module.mjs +1 -1
- package/modules/netlify-cms/server/api/config.mjs +25 -1
- package/modules/netlify-cms/server/api/local-fs.d.ts +51 -0
- package/modules/netlify-cms/server/api/local-fs.mjs +81 -77
- package/modules/netlify-cms/server/lib/cms/handler.d.ts +1 -1
- package/modules/netlify-cms/server/lib/cms/handlerV1.d.ts +1 -1
- package/modules/netlify-cms/server/lib/composables.d.ts +8 -0
- package/modules/netlify-cms/server/lib/composables.mjs +2 -1
- package/monkeyplus-flow-6.0.18.tgz +0 -0
- package/package.json +10 -2
- package/server/lib/context.d.ts +3 -0
- package/server/lib/context.mjs +5 -0
- package/server/lib/handler.mjs +58 -23
- package/server/lib/pages.d.ts +2 -2
- package/server/lib/pages.mjs +8 -6
- package/server/lib/render.mjs +20 -4
- package/server/plugins/00.lifecycle.mjs +2 -1
- package/src/public/index.d.ts +1 -0
- package/src/public/index.mjs +1 -0
- package/src/public/nitro.mjs +2 -0
- package/src/public/query-content.mjs +9 -2
- package/src/public/shared.d.ts +1 -0
- package/src/public/shared.mjs +3 -0
- package/src/public/vite.mjs +63 -8
- package/src/runtime/components/FlowIsland.mjs +31 -4
- package/src/runtime/components/MkImage.d.ts +100 -22
- package/src/runtime/components/MkImage.mjs +20 -12
- package/src/runtime/components/MkLink.d.ts +8 -5
- package/src/runtime/components/MkLink.mjs +9 -3
- package/src/runtime/components/MkPicture.d.ts +92 -7
- package/src/runtime/components/MkPicture.mjs +8 -2
- package/src/runtime/components/image-shared.d.ts +0 -1
- package/src/runtime/components/image-shared.mjs +9 -18
- package/src/runtime/config.d.ts +6 -15
- package/src/runtime/head.d.ts +2 -1
- package/src/runtime/head.mjs +5 -2
- package/src/runtime/islands.mjs +20 -2
- package/src/runtime/page-discovery.mjs +9 -1
- package/src/runtime/pages.d.ts +14 -13
- package/src/runtime/virtual-pages.mjs +2 -2
|
@@ -17,7 +17,7 @@ export default defineFlowModule({
|
|
|
17
17
|
const configHandlerPath = context.projectRoot === resolvePackagePath() ? resolve(context.projectRoot, "modules/netlify-cms/server/api/config.ts") : resolvePackageFile("modules/netlify-cms/server/api/config.ts", "modules/netlify-cms/server/api/config.mjs", "modules/netlify-cms/server/api/config.js");
|
|
18
18
|
const adminHandlerPath = context.projectRoot === resolvePackagePath() ? resolve(context.projectRoot, "modules/netlify-cms/server/api/admin.ts") : resolvePackageFile("modules/netlify-cms/server/api/admin.ts", "modules/netlify-cms/server/api/admin.mjs", "modules/netlify-cms/server/api/admin.js");
|
|
19
19
|
const metaHandlerPath = context.projectRoot === resolvePackagePath() ? resolve(context.projectRoot, "modules/netlify-cms/server/api/meta.ts") : resolvePackageFile("modules/netlify-cms/server/api/meta.ts", "modules/netlify-cms/server/api/meta.mjs", "modules/netlify-cms/server/api/meta.js");
|
|
20
|
-
const locales = context.flowConfig.locale?.locales || ["es"];
|
|
20
|
+
const locales = context.flowConfig.locale?.locales || ["es-ec"];
|
|
21
21
|
context.nitro.virtual = context.nitro.virtual || {};
|
|
22
22
|
context.nitro.virtual["#cms-meta"] = `export const localeConfig = ${JSON.stringify(context.flowConfig.locale || {})};`;
|
|
23
23
|
context.nitro.handlers.push({
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
import process from "node:process";
|
|
4
|
+
import { consola } from "consola";
|
|
4
5
|
import defu from "defu";
|
|
5
6
|
import { createJiti } from "jiti";
|
|
6
7
|
import yml from "js-yaml";
|
|
7
8
|
import { defineEventHandler, setResponseHeader } from "nitro/h3";
|
|
9
|
+
import { getUrl } from "../../../../server/lib/pages.mjs";
|
|
8
10
|
import { collections, defineCms } from "../lib/cms/helpers.mjs";
|
|
9
11
|
import { widgets } from "../lib/cms/widgets.mjs";
|
|
10
12
|
import { defineCmsCollection } from "../lib/composables.mjs";
|
|
@@ -62,10 +64,32 @@ export default defineEventHandler(async (event) => {
|
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
66
|
} catch (e) {
|
|
65
|
-
|
|
67
|
+
consola.error("[CMS CONFIG] Error loading collections dynamically:", e);
|
|
66
68
|
}
|
|
67
69
|
const resolvedCollections = loadedCollections.map((c) => c({ widgets, collections }));
|
|
68
70
|
const manifest = defineCms(config, resolvedCollections)(`${base}content/${locale}/`, { rootDir: base });
|
|
71
|
+
if (manifest.collections) {
|
|
72
|
+
for (const col of manifest.collections) {
|
|
73
|
+
if (col.injectContext?.page) {
|
|
74
|
+
const pageName = col.injectContext.page;
|
|
75
|
+
const [lang = "es", loc = "ec"] = locale.split("-");
|
|
76
|
+
try {
|
|
77
|
+
const url = await getUrl(pageName, locale);
|
|
78
|
+
col.flow = {
|
|
79
|
+
path: url || "/",
|
|
80
|
+
locale: {
|
|
81
|
+
lang,
|
|
82
|
+
loc,
|
|
83
|
+
code: locale
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
} catch (e) {
|
|
87
|
+
consola.error("[CMS CONFIG] Error resolving url for injectContext:", e);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
delete col.injectContext;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
69
93
|
const ymlConfig = yml.dump(manifest, { skipInvalid: true });
|
|
70
94
|
setResponseHeader(event, "Content-Type", "text/yml;charset=utf-8");
|
|
71
95
|
return ymlConfig;
|
|
@@ -1,2 +1,53 @@
|
|
|
1
|
+
export declare function localFileSystemAPI(body: any): Promise<{
|
|
2
|
+
data: string;
|
|
3
|
+
file: {
|
|
4
|
+
path: string;
|
|
5
|
+
label: string | undefined;
|
|
6
|
+
id: any;
|
|
7
|
+
};
|
|
8
|
+
} | {
|
|
9
|
+
data: null;
|
|
10
|
+
file: {
|
|
11
|
+
path: string;
|
|
12
|
+
label: string | undefined;
|
|
13
|
+
id: null;
|
|
14
|
+
};
|
|
15
|
+
} | ({
|
|
16
|
+
data: string;
|
|
17
|
+
file: {
|
|
18
|
+
path: string;
|
|
19
|
+
label: string | undefined;
|
|
20
|
+
id: any;
|
|
21
|
+
};
|
|
22
|
+
} | {
|
|
23
|
+
data: null;
|
|
24
|
+
file: {
|
|
25
|
+
path: string;
|
|
26
|
+
label: string | undefined;
|
|
27
|
+
id: null;
|
|
28
|
+
};
|
|
29
|
+
})[] | {
|
|
30
|
+
id: any;
|
|
31
|
+
content: string;
|
|
32
|
+
encoding: string;
|
|
33
|
+
path: string;
|
|
34
|
+
name: any;
|
|
35
|
+
} | {
|
|
36
|
+
id: any;
|
|
37
|
+
content: string;
|
|
38
|
+
encoding: string;
|
|
39
|
+
path: string;
|
|
40
|
+
name: any;
|
|
41
|
+
}[] | {
|
|
42
|
+
repo: string;
|
|
43
|
+
publish_modes: string[];
|
|
44
|
+
type: string;
|
|
45
|
+
message?: undefined;
|
|
46
|
+
} | {
|
|
47
|
+
message: string;
|
|
48
|
+
repo?: undefined;
|
|
49
|
+
publish_modes?: undefined;
|
|
50
|
+
type?: undefined;
|
|
51
|
+
} | null | undefined>;
|
|
1
52
|
declare const _default: any;
|
|
2
53
|
export default _default;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Buffer } from "node:buffer";
|
|
2
2
|
import { basename, join, resolve } from "node:path";
|
|
3
3
|
import process from "node:process";
|
|
4
|
+
import { consola } from "consola";
|
|
4
5
|
import { defineEventHandler, readBody, setResponseStatus } from "nitro/h3";
|
|
5
6
|
import * as v from "valibot";
|
|
6
7
|
import { entriesFromFiles, readMediaFile } from "../lib/entries.mjs";
|
|
@@ -92,6 +93,84 @@ const paramsSchema = v.variant("action", [
|
|
|
92
93
|
params: v.any()
|
|
93
94
|
})
|
|
94
95
|
]);
|
|
96
|
+
export async function localFileSystemAPI(body) {
|
|
97
|
+
switch (body.action) {
|
|
98
|
+
case "info":
|
|
99
|
+
return {
|
|
100
|
+
repo: basename(repoPath),
|
|
101
|
+
publish_modes: ["simple"],
|
|
102
|
+
type: "local_fs"
|
|
103
|
+
};
|
|
104
|
+
case "entriesByFolder": {
|
|
105
|
+
const { folder, extension, depth } = body.params;
|
|
106
|
+
const files = await listRepoFiles(repoPath, folder, extension, depth);
|
|
107
|
+
const entries = await entriesFromFiles(
|
|
108
|
+
repoPath,
|
|
109
|
+
files.reverse().map((file) => ({ path: file }))
|
|
110
|
+
);
|
|
111
|
+
return entries;
|
|
112
|
+
}
|
|
113
|
+
case "entriesByFiles": {
|
|
114
|
+
const entries = await entriesFromFiles(repoPath, body.params.files);
|
|
115
|
+
return entries;
|
|
116
|
+
}
|
|
117
|
+
case "getEntry": {
|
|
118
|
+
const [entry] = await entriesFromFiles(repoPath, [{ path: body.params.path }]);
|
|
119
|
+
return entry;
|
|
120
|
+
}
|
|
121
|
+
case "persistEntry": {
|
|
122
|
+
const dataFiles = body.params.dataFiles || (body.params.entry ? [body.params.entry] : []);
|
|
123
|
+
await Promise.all(
|
|
124
|
+
dataFiles.map((dataFile) => writeFile(join(repoPath, dataFile.path), dataFile.raw))
|
|
125
|
+
);
|
|
126
|
+
await Promise.all(
|
|
127
|
+
body.params.assets.map((a) => writeFile(
|
|
128
|
+
join(repoPath, a.path),
|
|
129
|
+
Buffer.from(a.content, a.encoding)
|
|
130
|
+
))
|
|
131
|
+
);
|
|
132
|
+
if (dataFiles.every((dataFile) => dataFile.newPath)) {
|
|
133
|
+
await Promise.all(dataFiles.map(
|
|
134
|
+
(dataFile) => move(join(repoPath, dataFile.path), join(repoPath, dataFile.newPath))
|
|
135
|
+
));
|
|
136
|
+
}
|
|
137
|
+
return { message: "entry persisted" };
|
|
138
|
+
}
|
|
139
|
+
case "getMedia": {
|
|
140
|
+
const files = await listRepoFiles(repoPath, body.params.mediaFolder, "", 1);
|
|
141
|
+
const mediaFiles = await Promise.all(
|
|
142
|
+
files.map((file) => readMediaFile(repoPath, file))
|
|
143
|
+
);
|
|
144
|
+
return mediaFiles;
|
|
145
|
+
}
|
|
146
|
+
case "getMediaFile": {
|
|
147
|
+
const mediaFile = await readMediaFile(repoPath, body.params.path);
|
|
148
|
+
return mediaFile;
|
|
149
|
+
}
|
|
150
|
+
case "persistMedia": {
|
|
151
|
+
const asset = body.params.asset;
|
|
152
|
+
await writeFile(
|
|
153
|
+
join(repoPath, asset.path),
|
|
154
|
+
Buffer.from(asset.content, asset.encoding)
|
|
155
|
+
);
|
|
156
|
+
const file = await readMediaFile(repoPath, asset.path);
|
|
157
|
+
return file;
|
|
158
|
+
}
|
|
159
|
+
case "deleteFile": {
|
|
160
|
+
await deleteFile(repoPath, body.params.path);
|
|
161
|
+
return { message: `deleted file ${body.params.path}` };
|
|
162
|
+
}
|
|
163
|
+
case "deleteFiles": {
|
|
164
|
+
await Promise.all(
|
|
165
|
+
body.params.paths.map((filePath) => deleteFile(repoPath, filePath))
|
|
166
|
+
);
|
|
167
|
+
return { message: `deleted files ${body.params.paths.join(", ")}` };
|
|
168
|
+
}
|
|
169
|
+
case "getDeployPreview": {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
95
174
|
export default defineEventHandler(async (event) => {
|
|
96
175
|
const rawBody = await readBody(event);
|
|
97
176
|
if (!rawBody || !rawBody.action) {
|
|
@@ -105,84 +184,9 @@ export default defineEventHandler(async (event) => {
|
|
|
105
184
|
}
|
|
106
185
|
const body = result.output;
|
|
107
186
|
try {
|
|
108
|
-
|
|
109
|
-
case "info":
|
|
110
|
-
return {
|
|
111
|
-
repo: basename(repoPath),
|
|
112
|
-
publish_modes: ["simple"],
|
|
113
|
-
type: "local_fs"
|
|
114
|
-
};
|
|
115
|
-
case "entriesByFolder": {
|
|
116
|
-
const { folder, extension, depth } = body.params;
|
|
117
|
-
const files = await listRepoFiles(repoPath, folder, extension, depth);
|
|
118
|
-
const entries = await entriesFromFiles(
|
|
119
|
-
repoPath,
|
|
120
|
-
files.reverse().map((file) => ({ path: file }))
|
|
121
|
-
);
|
|
122
|
-
return entries;
|
|
123
|
-
}
|
|
124
|
-
case "entriesByFiles": {
|
|
125
|
-
const entries = await entriesFromFiles(repoPath, body.params.files);
|
|
126
|
-
return entries;
|
|
127
|
-
}
|
|
128
|
-
case "getEntry": {
|
|
129
|
-
const [entry] = await entriesFromFiles(repoPath, [{ path: body.params.path }]);
|
|
130
|
-
return entry;
|
|
131
|
-
}
|
|
132
|
-
case "persistEntry": {
|
|
133
|
-
const dataFiles = body.params.dataFiles || (body.params.entry ? [body.params.entry] : []);
|
|
134
|
-
await Promise.all(
|
|
135
|
-
dataFiles.map((dataFile) => writeFile(join(repoPath, dataFile.path), dataFile.raw))
|
|
136
|
-
);
|
|
137
|
-
await Promise.all(
|
|
138
|
-
body.params.assets.map((a) => writeFile(
|
|
139
|
-
join(repoPath, a.path),
|
|
140
|
-
Buffer.from(a.content, a.encoding)
|
|
141
|
-
))
|
|
142
|
-
);
|
|
143
|
-
if (dataFiles.every((dataFile) => dataFile.newPath)) {
|
|
144
|
-
await Promise.all(dataFiles.map(
|
|
145
|
-
(dataFile) => move(join(repoPath, dataFile.path), join(repoPath, dataFile.newPath))
|
|
146
|
-
));
|
|
147
|
-
}
|
|
148
|
-
return { message: "entry persisted" };
|
|
149
|
-
}
|
|
150
|
-
case "getMedia": {
|
|
151
|
-
const files = await listRepoFiles(repoPath, body.params.mediaFolder, "", 1);
|
|
152
|
-
const mediaFiles = await Promise.all(
|
|
153
|
-
files.map((file) => readMediaFile(repoPath, file))
|
|
154
|
-
);
|
|
155
|
-
return mediaFiles;
|
|
156
|
-
}
|
|
157
|
-
case "getMediaFile": {
|
|
158
|
-
const mediaFile = await readMediaFile(repoPath, body.params.path);
|
|
159
|
-
return mediaFile;
|
|
160
|
-
}
|
|
161
|
-
case "persistMedia": {
|
|
162
|
-
const asset = body.params.asset;
|
|
163
|
-
await writeFile(
|
|
164
|
-
join(repoPath, asset.path),
|
|
165
|
-
Buffer.from(asset.content, asset.encoding)
|
|
166
|
-
);
|
|
167
|
-
const file = await readMediaFile(repoPath, asset.path);
|
|
168
|
-
return file;
|
|
169
|
-
}
|
|
170
|
-
case "deleteFile": {
|
|
171
|
-
await deleteFile(repoPath, body.params.path);
|
|
172
|
-
return { message: `deleted file ${body.params.path}` };
|
|
173
|
-
}
|
|
174
|
-
case "deleteFiles": {
|
|
175
|
-
await Promise.all(
|
|
176
|
-
body.params.paths.map((filePath) => deleteFile(repoPath, filePath))
|
|
177
|
-
);
|
|
178
|
-
return { message: `deleted files ${body.params.paths.join(", ")}` };
|
|
179
|
-
}
|
|
180
|
-
case "getDeployPreview": {
|
|
181
|
-
return null;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
187
|
+
return localFileSystemAPI(body);
|
|
184
188
|
} catch (e) {
|
|
185
|
-
|
|
189
|
+
consola.error(`Error handling ${JSON.stringify(rawBody)}: ${e.message}`);
|
|
186
190
|
setResponseStatus(event, 500);
|
|
187
191
|
return { error: "Unknown error" };
|
|
188
192
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: any
|
|
1
|
+
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
|
|
2
2
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: any
|
|
1
|
+
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
|
|
2
2
|
export default _default;
|
|
@@ -19,10 +19,18 @@ export interface OptionsCollection {
|
|
|
19
19
|
}
|
|
20
20
|
export declare function defineCmsCollection(options: OptionsCollection): (ctx: Ctx) => (baseDir: string, ctx2: any) => {
|
|
21
21
|
group: Group;
|
|
22
|
+
injectContext: {
|
|
23
|
+
page: string;
|
|
24
|
+
assign: string;
|
|
25
|
+
} | undefined;
|
|
22
26
|
folder: string;
|
|
23
27
|
fields: import("./types").Cms.Fields[];
|
|
24
28
|
} | {
|
|
25
29
|
group: Group;
|
|
30
|
+
injectContext: {
|
|
31
|
+
page: string;
|
|
32
|
+
assign: string;
|
|
33
|
+
} | undefined;
|
|
26
34
|
files: Collections.File[];
|
|
27
35
|
};
|
|
28
36
|
export {};
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monkeyplus/flow",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.19",
|
|
4
4
|
"description": "@monkeyplus/flow package-first runtime with Vite, Nitro, Vue and a workspace playground.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -56,6 +56,14 @@
|
|
|
56
56
|
"types": "./src/public/modules/content.d.ts",
|
|
57
57
|
"import": "./src/public/modules/content.mjs"
|
|
58
58
|
},
|
|
59
|
+
"./modules/netlify-cms": {
|
|
60
|
+
"types": "./modules/netlify-cms/module.d.ts",
|
|
61
|
+
"import": "./modules/netlify-cms/module.mjs"
|
|
62
|
+
},
|
|
63
|
+
"./modules/cms": {
|
|
64
|
+
"types": "./modules/cms/module.d.ts",
|
|
65
|
+
"import": "./modules/cms/module.mjs"
|
|
66
|
+
},
|
|
59
67
|
"./main": {
|
|
60
68
|
"types": "./src/main.d.ts",
|
|
61
69
|
"import": "./src/main.mjs"
|
|
@@ -71,7 +79,7 @@
|
|
|
71
79
|
"types": "./src/public/index.d.ts",
|
|
72
80
|
"dependencies": {
|
|
73
81
|
"@iconify/json": "^2.2.471",
|
|
74
|
-
"@nuxt/ui": "^4.
|
|
82
|
+
"@nuxt/ui": "^4.8.2",
|
|
75
83
|
"@unhead/ssr": "^3.1.0",
|
|
76
84
|
"@unhead/vue": "^3.1.0",
|
|
77
85
|
"@vitejs/plugin-vue": "^6.0.5",
|
package/server/lib/handler.mjs
CHANGED
|
@@ -12,32 +12,67 @@ function mergeClientAssets(baseAssets, pageAssets) {
|
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
export async function renderPageRequest(request) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
let pathname = new URL(request.url).pathname;
|
|
16
|
+
let overrideContext;
|
|
17
|
+
if (pathname.startsWith("/cms-preview")) {
|
|
18
|
+
pathname = pathname.replace("/cms-preview", "") || "/";
|
|
19
|
+
if (request.method === "POST") {
|
|
20
|
+
try {
|
|
21
|
+
overrideContext = await request.clone().json();
|
|
22
|
+
} catch {
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const runWithContext = async () => {
|
|
27
|
+
let oldPreviewData;
|
|
28
|
+
if (overrideContext) {
|
|
29
|
+
oldPreviewData = globalThis.__cmsPreviewData;
|
|
30
|
+
globalThis.__cmsPreviewData = overrideContext;
|
|
31
|
+
console.log("[handler] SET globalThis.__cmsPreviewData", overrideContext);
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
const page = await resolvePage(pathname, request);
|
|
35
|
+
if (!page) {
|
|
36
|
+
const notFoundPage = await resolvePageByName("error404", pathname, request);
|
|
37
|
+
if (!notFoundPage) {
|
|
38
|
+
return new Response("Not Found", {
|
|
39
|
+
status: 404,
|
|
40
|
+
headers: {
|
|
41
|
+
"content-type": "text/plain; charset=utf-8"
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (overrideContext) {
|
|
46
|
+
notFoundPage.context = { ...notFoundPage.context, ...overrideContext };
|
|
47
|
+
}
|
|
48
|
+
const bundleName2 = notFoundPage.definition.view.bundle || "_default";
|
|
49
|
+
const resolvedAssets2 = mergeClientAssets(clientAssets, bundleAssets[bundleName2] || bundleAssets._default);
|
|
50
|
+
return new Response(await renderDocument(notFoundPage, resolvedAssets2), {
|
|
51
|
+
status: 404,
|
|
52
|
+
headers: {
|
|
53
|
+
"content-type": "text/html; charset=utf-8"
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (overrideContext) {
|
|
58
|
+
page.context = { ...page.context, ...overrideContext };
|
|
59
|
+
}
|
|
60
|
+
const bundleName = page.definition.view.bundle || "_default";
|
|
61
|
+
const resolvedAssets = mergeClientAssets(clientAssets, bundleAssets[bundleName] || bundleAssets._default);
|
|
62
|
+
return new Response(await renderDocument(page, resolvedAssets), {
|
|
22
63
|
headers: {
|
|
23
|
-
"content-type": "text/
|
|
64
|
+
"content-type": "text/html; charset=utf-8"
|
|
24
65
|
}
|
|
25
66
|
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
67
|
+
} finally {
|
|
68
|
+
if (overrideContext) {
|
|
69
|
+
if (oldPreviewData === void 0) {
|
|
70
|
+
delete globalThis.__cmsPreviewData;
|
|
71
|
+
} else {
|
|
72
|
+
globalThis.__cmsPreviewData = oldPreviewData;
|
|
73
|
+
}
|
|
33
74
|
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
const bundleName = page.definition.view.bundle || "_default";
|
|
37
|
-
const resolvedAssets = mergeClientAssets(clientAssets, bundleAssets[bundleName] || bundleAssets._default);
|
|
38
|
-
return new Response(await renderDocument(page, resolvedAssets), {
|
|
39
|
-
headers: {
|
|
40
|
-
"content-type": "text/html; charset=utf-8"
|
|
41
75
|
}
|
|
42
|
-
}
|
|
76
|
+
};
|
|
77
|
+
return runWithContext();
|
|
43
78
|
}
|
package/server/lib/pages.d.ts
CHANGED
|
@@ -16,5 +16,5 @@ export interface ResolvedPage {
|
|
|
16
16
|
}
|
|
17
17
|
export declare function getUrl(namePage: string, localeCode?: string, options?: GetUrlOptions): Promise<string | undefined>;
|
|
18
18
|
export declare function getUrls(withLocale?: boolean, omitNoPublish?: boolean): Promise<(string | PageUrlInfo)[]>;
|
|
19
|
-
export declare function resolvePage(pathname: string): Promise<ResolvedPage | undefined>;
|
|
20
|
-
export declare function resolvePageByName(name: string, pathname: string): Promise<ResolvedPage | undefined>;
|
|
19
|
+
export declare function resolvePage(pathname: string, request?: Request): Promise<ResolvedPage | undefined>;
|
|
20
|
+
export declare function resolvePageByName(name: string, pathname: string, request?: Request): Promise<ResolvedPage | undefined>;
|
package/server/lib/pages.mjs
CHANGED
|
@@ -66,8 +66,9 @@ function createLocale(code) {
|
|
|
66
66
|
loc
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
|
-
function createContext(definition, locale, localePage, pathname, params, dynamic) {
|
|
69
|
+
function createContext(definition, locale, localePage, pathname, params, dynamic, request) {
|
|
70
70
|
const imageUtils = getFlowImageRuntimeUtils();
|
|
71
|
+
const preview = request?.headers.get("cookie")?.includes("flow_preview=true") || false;
|
|
71
72
|
return {
|
|
72
73
|
dynamic,
|
|
73
74
|
locale,
|
|
@@ -75,6 +76,7 @@ function createContext(definition, locale, localePage, pathname, params, dynamic
|
|
|
75
76
|
name: definition.name,
|
|
76
77
|
page: localePage,
|
|
77
78
|
params,
|
|
79
|
+
preview,
|
|
78
80
|
view: definition.view,
|
|
79
81
|
utils: {
|
|
80
82
|
getLocale() {
|
|
@@ -244,7 +246,7 @@ export async function getUrls(withLocale = false, omitNoPublish = false) {
|
|
|
244
246
|
}
|
|
245
247
|
return urls;
|
|
246
248
|
}
|
|
247
|
-
export async function resolvePage(pathname) {
|
|
249
|
+
export async function resolvePage(pathname, request) {
|
|
248
250
|
const runtimeConfig = getFlowRuntimeConfig();
|
|
249
251
|
const enabledLocales = runtimeConfig.flow?.locale?.locales || [];
|
|
250
252
|
const candidates = [];
|
|
@@ -269,12 +271,12 @@ export async function resolvePage(pathname) {
|
|
|
269
271
|
const sortedCandidates = candidates.sort((left, right) => right.score - left.score);
|
|
270
272
|
for (const match of sortedCandidates) {
|
|
271
273
|
const locale = createLocale(match.localeCode);
|
|
272
|
-
const baseCtx = createContext(match.definition, locale, match.localePage, pathname, match.params);
|
|
274
|
+
const baseCtx = createContext(match.definition, locale, match.localePage, pathname, match.params, void 0, request);
|
|
273
275
|
const dynamic = await resolveDynamicEntry(match.definition, match.localeCode, match.localePage, baseCtx, pathname);
|
|
274
276
|
if (match.localePage.dynamic && !dynamic) {
|
|
275
277
|
continue;
|
|
276
278
|
}
|
|
277
|
-
const ctx = createContext(match.definition, locale, match.localePage, pathname, match.params, dynamic);
|
|
279
|
+
const ctx = createContext(match.definition, locale, match.localePage, pathname, match.params, dynamic, request);
|
|
278
280
|
const head = match.localePage.head ? await match.localePage.head(ctx) : match.localePage.seo ? await match.localePage.seo(ctx) : {};
|
|
279
281
|
const layoutContext = await resolveLayoutContext(match.definition, ctx);
|
|
280
282
|
const context = match.localePage.context ? await match.localePage.context(ctx) : {};
|
|
@@ -295,7 +297,7 @@ export async function resolvePage(pathname) {
|
|
|
295
297
|
}
|
|
296
298
|
return void 0;
|
|
297
299
|
}
|
|
298
|
-
export async function resolvePageByName(name, pathname) {
|
|
300
|
+
export async function resolvePageByName(name, pathname, request) {
|
|
299
301
|
const runtimeConfig = getFlowRuntimeConfig();
|
|
300
302
|
const enabledLocales = runtimeConfig.flow?.locale?.locales || [];
|
|
301
303
|
const definition = pageDefinitions.find((candidate) => candidate.name === name);
|
|
@@ -308,7 +310,7 @@ export async function resolvePageByName(name, pathname) {
|
|
|
308
310
|
}
|
|
309
311
|
const locale = createLocale(localeCode);
|
|
310
312
|
const params = {};
|
|
311
|
-
const ctx = createContext(definition, locale, localePage, pathname, params);
|
|
313
|
+
const ctx = createContext(definition, locale, localePage, pathname, params, void 0, request);
|
|
312
314
|
const head = localePage.head ? await localePage.head(ctx) : localePage.seo ? await localePage.seo(ctx) : {};
|
|
313
315
|
const layoutContext = await resolveLayoutContext(definition, ctx);
|
|
314
316
|
const context = localePage.context ? await localePage.context(ctx) : {};
|
package/server/lib/render.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import UApp from "@nuxt/ui/components/App.vue";
|
|
2
|
+
import { UnheadSchemaOrg } from "@unhead/schema-org";
|
|
2
3
|
import { createHead, transformHtmlTemplate } from "@unhead/vue/server";
|
|
3
4
|
import { renderToString } from "@vue/server-renderer";
|
|
5
|
+
import { consola } from "consola";
|
|
4
6
|
import bases from "virtual:flow/bases";
|
|
5
7
|
import layouts from "virtual:flow/layouts";
|
|
6
8
|
import templates from "virtual:flow/templates";
|
|
@@ -80,7 +82,7 @@ function normalizeSeoToHead(head, fallbackTitle, fallbackDescription) {
|
|
|
80
82
|
};
|
|
81
83
|
}
|
|
82
84
|
async function renderBody(page) {
|
|
83
|
-
const templateKey = page.definition.view.template.toLowerCase();
|
|
85
|
+
const templateKey = (page.definition.view.template || page.definition.name).toLowerCase();
|
|
84
86
|
const layoutKey = (page.definition.view.layout || "default").toLowerCase();
|
|
85
87
|
const TemplateComponent = templates[templateKey];
|
|
86
88
|
const LayoutComponent = layouts[layoutKey];
|
|
@@ -93,7 +95,7 @@ async function renderBody(page) {
|
|
|
93
95
|
meta: [{ name: "description", content: fallbackDescription }]
|
|
94
96
|
});
|
|
95
97
|
return {
|
|
96
|
-
body: `<section class="shell"><div class="shell__panel">Missing template: ${escapeHtml(page.definition.view.template)}</div></section>`,
|
|
98
|
+
body: `<section class="shell"><div class="shell__panel">Missing template: ${escapeHtml(page.definition.view.template || page.definition.name)}</div></section>`,
|
|
97
99
|
head: head2
|
|
98
100
|
};
|
|
99
101
|
}
|
|
@@ -134,6 +136,7 @@ async function renderBody(page) {
|
|
|
134
136
|
app.provide("context", context);
|
|
135
137
|
app.provide("utils", utils);
|
|
136
138
|
const head = createHead();
|
|
139
|
+
head.use(UnheadSchemaOrg());
|
|
137
140
|
head.push(normalizeSeoToHead(page.head, fallbackTitle, fallbackDescription));
|
|
138
141
|
app.use(head);
|
|
139
142
|
installFlowVuePlugins(app);
|
|
@@ -149,7 +152,7 @@ export async function renderDocument(page, clientAssets) {
|
|
|
149
152
|
const boot = {
|
|
150
153
|
path: page.pathname,
|
|
151
154
|
bundle: page.definition.view.bundle || "_default",
|
|
152
|
-
template: page.definition.view.template,
|
|
155
|
+
template: page.definition.view.template || page.definition.name,
|
|
153
156
|
title: fallbackTitle,
|
|
154
157
|
locale: page.locale,
|
|
155
158
|
mode,
|
|
@@ -159,7 +162,20 @@ export async function renderDocument(page, clientAssets) {
|
|
|
159
162
|
const body = stripVueFragmentMarkers(rendered.body);
|
|
160
163
|
const baseKey = (page.definition.view.base || "default").toLowerCase();
|
|
161
164
|
const baseTemplate = bases[baseKey] || bases.default || '<!doctype html><html lang="{{lang}}"><head><meta charset="UTF-8" /><title>{{title}}</title>{{head}}</head><body>{{body}}</body></html>';
|
|
162
|
-
|
|
165
|
+
if (!(bases[baseKey] || bases.default)) {
|
|
166
|
+
consola.warn(`No existe el template base: ${baseKey}`);
|
|
167
|
+
}
|
|
168
|
+
const pageMarkup = mode === "app" ? `<div id="app" data-page="${escapeHtml(page.definition.name)}" data-template="${escapeHtml(page.definition.view.template || page.definition.name)}" data-flow-mode="app">${body}</div>` : body;
|
|
169
|
+
if (boot.images?.options?.lazy) {
|
|
170
|
+
rendered.head.push({
|
|
171
|
+
script: [{
|
|
172
|
+
src: "https://cdnjs.cloudflare.com/ajax/libs/lazysizes/5.3.2/lazysizes.min.js",
|
|
173
|
+
integrity: "sha512-q583ppKrCRc7N5O0n2nzUiJ+suUv7Et1JGels4bXOaMFQcamPk9HjdUknZuuFjBNs7tsMuadge5k9RzdmO+1GQ==",
|
|
174
|
+
crossorigin: "anonymous",
|
|
175
|
+
referrerpolicy: "no-referrer"
|
|
176
|
+
}]
|
|
177
|
+
});
|
|
178
|
+
}
|
|
163
179
|
const html = applyBaseTemplate(baseTemplate, {
|
|
164
180
|
lang: page.locale.lang,
|
|
165
181
|
title: fallbackTitle,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { definePlugin } from "nitro";
|
|
2
|
+
import { consola } from "consola";
|
|
2
3
|
export default definePlugin((nitroApp) => {
|
|
3
4
|
nitroApp.hooks.hook("request", (event) => {
|
|
4
5
|
const pathname = new URL(event.req.url, "http://localhost").pathname;
|
|
5
6
|
if (!pathname.startsWith("/api/")) {
|
|
6
|
-
|
|
7
|
+
consola.info(`[nitro] request ${pathname}`);
|
|
7
8
|
}
|
|
8
9
|
});
|
|
9
10
|
});
|
package/src/public/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export type { ContentDirectoryNode, ContentEntry, ContentFileNode, ContentTreeNo
|
|
|
2
2
|
export type { FlowBootPayload } from '../runtime/boot.ts';
|
|
3
3
|
export { defineFlowConfig, defineFlowModule, resolveFlowConfig } from '../runtime/config.ts';
|
|
4
4
|
export type { FlowConfig, UserFlowConfig, } from '../runtime/config.ts';
|
|
5
|
+
export { useSchemaOrg } from '../runtime/head.ts';
|
|
5
6
|
export { defineLayoutContext } from '../runtime/layout-context.ts';
|
|
6
7
|
export type { LayoutContextDefinition, LayoutContextValue } from '../runtime/layout-context.ts';
|
|
7
8
|
export { definePage } from '../runtime/pages.ts';
|
package/src/public/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { defineFlowConfig, defineFlowModule, resolveFlowConfig } from "../runtime/config.mjs";
|
|
2
|
+
export { useSchemaOrg } from "../runtime/head.mjs";
|
|
2
3
|
export { defineLayoutContext } from "../runtime/layout-context.mjs";
|
|
3
4
|
export { definePage } from "../runtime/pages.mjs";
|
|
4
5
|
export { queryContent } from "./query-content.mjs";
|
package/src/public/nitro.mjs
CHANGED
|
@@ -65,11 +65,13 @@ export function createFlowNitroConfig(options = {}) {
|
|
|
65
65
|
noExternals: [...configuredNoExternals, flowPackagePattern],
|
|
66
66
|
handlers: flowModules.nitro.handlers,
|
|
67
67
|
storage: flowModules.nitro.storage,
|
|
68
|
+
publicAssets: flowModules.nitro.publicAssets,
|
|
68
69
|
routeRules: {
|
|
69
70
|
"/api/**": { cors: true },
|
|
70
71
|
...flowNitroConfig.routeRules,
|
|
71
72
|
...flowModules.nitro.routeRules
|
|
72
73
|
},
|
|
74
|
+
routes: flowModules.nitro.routes,
|
|
73
75
|
imports: flowModules.nitro.imports,
|
|
74
76
|
runtimeConfig: {
|
|
75
77
|
app: {
|