@blocklet/pages-kit-inner-components 0.4.125 → 0.4.127
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/lib/cjs/add-component.js +1 -1
- package/lib/cjs/chunks/{array-DOclwySd.js → array-3OBY1z8c.js} +1 -1
- package/lib/cjs/chunks/{config-string-DUTyex-9.js → config-string-BOqUdy2S.js} +1 -1
- package/lib/cjs/chunks/{draft-data-CRdesc3Z.js → draft-data-C4FzOyR5.js} +1 -1
- package/lib/cjs/chunks/{home-DMWxIeUw.js → home-on-Gjgnl.js} +4 -4
- package/lib/cjs/chunks/{publish-button-B_2z7mDz.js → publish-button-gJaGa548.js} +1 -1
- package/lib/cjs/chunks/{site-state-DMexEilp.js → site-state-C5t-5c6U.js} +3 -3
- package/lib/cjs/chunks/state-5jwYHuoB.js +1 -0
- package/lib/cjs/components.js +1 -1
- package/lib/cjs/home.js +1 -1
- package/lib/cjs/locales.js +1 -1
- package/lib/cjs/project-html.js +7 -7
- package/lib/cjs/resources.js +1 -1
- package/lib/cjs/setting.js +1 -1
- package/lib/cjs/site-state.js +1 -1
- package/lib/es/add-component.js +3 -3
- package/lib/es/chunks/{array-CUVFSUuJ.js → array-CWudJ_mc.js} +1 -1
- package/lib/es/chunks/{config-string-DZMNWDnb.js → config-string-CcDa1MHl.js} +1 -1
- package/lib/es/chunks/{draft-data-CWtmeHdw.js → draft-data-DoNjnkxB.js} +1 -1
- package/lib/es/chunks/{home-DIJ8xaUb.js → home-D5UawjLT.js} +50 -50
- package/lib/es/chunks/{publish-button-LDqfGwdd.js → publish-button-C-ra2NsA.js} +3 -3
- package/lib/es/chunks/{site-state-BHfXVFkY.js → site-state-BLNi12iP.js} +3 -6
- package/lib/es/chunks/state-DNndJ33Y.js +456 -0
- package/lib/es/components.js +1 -1
- package/lib/es/home.js +3 -3
- package/lib/es/locales.js +41 -5
- package/lib/es/project-html.js +160 -99
- package/lib/es/resources.js +1 -1
- package/lib/es/setting.js +2 -2
- package/lib/es/site-state.js +1 -1
- package/package.json +3 -3
- package/lib/cjs/chunks/state-oc52fQ0j.js +0 -1
- package/lib/es/chunks/state-DCRhzAYq.js +0 -437
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
import { jsx as L } from "react/jsx-runtime";
|
|
2
|
+
import { Box as z, Alert as K } from "@mui/material";
|
|
3
|
+
import { joinURL as b, withQuery as q } from "ufo";
|
|
4
|
+
import { createAxios as Q } from "@blocklet/js-sdk";
|
|
5
|
+
import X from "lodash/isEmpty";
|
|
6
|
+
import * as Y from "yaml";
|
|
7
|
+
import { useLocaleContext as Z } from "@arcblock/ux/lib/Locale/context";
|
|
8
|
+
import H, { getYjsDoc as ee } from "@syncedstore/core";
|
|
9
|
+
import { useSyncedStore as te } from "@syncedstore/react";
|
|
10
|
+
import { useLocalStorageState as ne } from "ahooks";
|
|
11
|
+
import { produce as C } from "immer";
|
|
12
|
+
import oe from "js-cookie";
|
|
13
|
+
import N from "lodash/debounce";
|
|
14
|
+
import { customAlphabet as re } from "nanoid";
|
|
15
|
+
import { createContext as se, useState as E, useRef as ie, useMemo as v, useCallback as k, useEffect as O, useContext as ce } from "react";
|
|
16
|
+
import { useParams as ae, useNavigate as de } from "react-router-dom";
|
|
17
|
+
import { IndexeddbPersistence as le } from "y-indexeddb";
|
|
18
|
+
import { WebsocketProvider as me } from "y-websocket";
|
|
19
|
+
import { UndoManager as fe } from "yjs";
|
|
20
|
+
import "@blocklet/pages-kit/types";
|
|
21
|
+
const Ve = (t) => {
|
|
22
|
+
const n = blocklet == null ? void 0 : blocklet.componentMountPoints.find((a) => a.name === t);
|
|
23
|
+
return n ? n.mountPoint : "/";
|
|
24
|
+
};
|
|
25
|
+
function ue() {
|
|
26
|
+
const { pathname: t } = window.location, n = t.match(/\/admin\/(maker|previewer)\/([^/]+)/), a = n == null ? void 0 : n[2], u = window.__PROJECT_ID__;
|
|
27
|
+
if (!a && !u)
|
|
28
|
+
throw new Error("Unable to get projectId from pathname");
|
|
29
|
+
return a || u;
|
|
30
|
+
}
|
|
31
|
+
function We(t) {
|
|
32
|
+
return `${t}:pages:version`;
|
|
33
|
+
}
|
|
34
|
+
function ze(t, n) {
|
|
35
|
+
return n === "yaml" ? X(t) ? "" : Y.stringify(t, { indent: 2 }) : n === "json" ? JSON.parse(JSON.stringify(t || {})) : n === "array" ? JSON.parse(JSON.stringify(t || [])) : t;
|
|
36
|
+
}
|
|
37
|
+
function Ke({ error: t }) {
|
|
38
|
+
return /* @__PURE__ */ L(z, { children: /* @__PURE__ */ L(K, { severity: "error", children: t.message }) });
|
|
39
|
+
}
|
|
40
|
+
var U;
|
|
41
|
+
const R = ((U = window.blocklet) == null ? void 0 : U.prefix) || "/", J = Q({
|
|
42
|
+
timeout: 200 * 1e3
|
|
43
|
+
}), pe = window.location.protocol === "https:" ? "wss" : "ws", qe = (t) => b(`${pe}://${window.location.hostname}`, R, `api/${t}/ws/pages`), we = "z8ia1mAXo8ZE7ytGF36L5uBf9kD2kenhqFGp9";
|
|
44
|
+
var F;
|
|
45
|
+
(F = blocklet == null ? void 0 : blocklet.componentMountPoints.find((t) => t.did === we)) != null && F.mountPoint || b(R, "/image-bin");
|
|
46
|
+
function Qe(t) {
|
|
47
|
+
return t && !/^(https?:\/\/|\/)/.test(t) ? window.location.origin + b(R, "uploads", t) : t;
|
|
48
|
+
}
|
|
49
|
+
const Se = window.innerWidth <= 750;
|
|
50
|
+
function Xe(t, n, a) {
|
|
51
|
+
if (!t || /\.gif/.test(t)) return t;
|
|
52
|
+
const u = (Se ? n / 1.5 : n) * (a === "quality" ? 1.5 : 1);
|
|
53
|
+
return Pe(t, { imageFilter: "resize", w: u, f: "webp" });
|
|
54
|
+
}
|
|
55
|
+
function Pe(t, n) {
|
|
56
|
+
return !t || !n ? t : q(t, n);
|
|
57
|
+
}
|
|
58
|
+
async function Ie(t) {
|
|
59
|
+
return J.get(`/api/projects/${t}`).then((n) => n.data);
|
|
60
|
+
}
|
|
61
|
+
async function he(t) {
|
|
62
|
+
return J.post(`/api/projects/${t.id}/update`, t).then((n) => n.data);
|
|
63
|
+
}
|
|
64
|
+
const ye = 500, A = re("abcdefghijklmnopqrstuvwxyz0123456789", 16), B = se(null);
|
|
65
|
+
function Ye({
|
|
66
|
+
url: t,
|
|
67
|
+
name: n,
|
|
68
|
+
children: a,
|
|
69
|
+
waitingSynced: u
|
|
70
|
+
}) {
|
|
71
|
+
const [I, S] = E(!1), { locale: h } = Z(), p = V(), e = `${p}:MakerLocalState`, o = `${p}:${n}`, [r, s] = ne(e, {
|
|
72
|
+
defaultValue: {},
|
|
73
|
+
listenStorageChange: !0
|
|
74
|
+
}), i = ie(r);
|
|
75
|
+
i.current = r;
|
|
76
|
+
const c = v(
|
|
77
|
+
() => H({
|
|
78
|
+
pages: {},
|
|
79
|
+
pageIds: [],
|
|
80
|
+
routes: {},
|
|
81
|
+
routeIds: [],
|
|
82
|
+
components: {},
|
|
83
|
+
supportedLocales: [],
|
|
84
|
+
config: {},
|
|
85
|
+
resources: {}
|
|
86
|
+
}),
|
|
87
|
+
[]
|
|
88
|
+
), d = v(() => ee(c), [c]);
|
|
89
|
+
v(() => new le(o, d), [o, d]);
|
|
90
|
+
const w = v(
|
|
91
|
+
() => new me(t, o, d, {
|
|
92
|
+
params: { token: oe.get("login_token") },
|
|
93
|
+
resyncInterval: 5 * 60 * 1e3
|
|
94
|
+
}),
|
|
95
|
+
[t, o, d]
|
|
96
|
+
), g = k(() => {
|
|
97
|
+
w && (w.disconnect(), w.connect());
|
|
98
|
+
}, [w]), y = v(
|
|
99
|
+
() => new fe(
|
|
100
|
+
[d.getArray("pageIds"), d.getMap("pages"), d.getArray("supportedLocales"), d.getMap("config")],
|
|
101
|
+
{ doc: d }
|
|
102
|
+
),
|
|
103
|
+
[d]
|
|
104
|
+
), [j, x] = E(null), [$, T] = E(!1), [_, G] = E(void 0), D = k(async () => {
|
|
105
|
+
if (p) {
|
|
106
|
+
T(!0);
|
|
107
|
+
try {
|
|
108
|
+
const l = await Ie(p);
|
|
109
|
+
x(l);
|
|
110
|
+
} catch (l) {
|
|
111
|
+
console.error("Failed to fetch project:", l);
|
|
112
|
+
} finally {
|
|
113
|
+
T(!1);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}, [p]), M = k(
|
|
117
|
+
async (l, m) => {
|
|
118
|
+
var P;
|
|
119
|
+
if (G(void 0), !!p) {
|
|
120
|
+
m != null && m.optimisticUpdate && j && x((f) => ({
|
|
121
|
+
...f,
|
|
122
|
+
...l
|
|
123
|
+
}));
|
|
124
|
+
try {
|
|
125
|
+
const f = await he({
|
|
126
|
+
...l
|
|
127
|
+
});
|
|
128
|
+
x(f);
|
|
129
|
+
} catch (f) {
|
|
130
|
+
console.error("Failed to update project:", f), m != null && m.optimisticUpdate && x(j), G((P = f == null ? void 0 : f.response) == null ? void 0 : P.data);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
[p, j]
|
|
135
|
+
);
|
|
136
|
+
O(() => {
|
|
137
|
+
p && D();
|
|
138
|
+
}, [p, D]);
|
|
139
|
+
const W = v(
|
|
140
|
+
() => ({
|
|
141
|
+
doc: d,
|
|
142
|
+
state: c,
|
|
143
|
+
localState: {
|
|
144
|
+
...r,
|
|
145
|
+
// always use the locale from the context
|
|
146
|
+
currentLocale: h
|
|
147
|
+
},
|
|
148
|
+
setLocalState: (l) => s(typeof l == "function" ? (m) => l(m ?? {}) : l),
|
|
149
|
+
undoManager: y,
|
|
150
|
+
projectState: {
|
|
151
|
+
project: j,
|
|
152
|
+
isLoadingProject: $,
|
|
153
|
+
error: _
|
|
154
|
+
},
|
|
155
|
+
updateProject: M,
|
|
156
|
+
forceSync: g
|
|
157
|
+
}),
|
|
158
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
159
|
+
[
|
|
160
|
+
d,
|
|
161
|
+
c,
|
|
162
|
+
JSON.stringify(r),
|
|
163
|
+
// resolve the problem of react warning
|
|
164
|
+
s,
|
|
165
|
+
y,
|
|
166
|
+
j,
|
|
167
|
+
$,
|
|
168
|
+
M,
|
|
169
|
+
_,
|
|
170
|
+
h,
|
|
171
|
+
g
|
|
172
|
+
]
|
|
173
|
+
);
|
|
174
|
+
return O(() => {
|
|
175
|
+
y.on("stack-item-added", ({ stackItem: l }) => {
|
|
176
|
+
const { currentPageId: m, currentLocale: P, pages: f } = i.current;
|
|
177
|
+
l.meta.set("localState", { currentPageId: m, currentLocale: P, pages: f });
|
|
178
|
+
}), y.on("stack-item-popped", ({ stackItem: l }) => {
|
|
179
|
+
const m = l.meta.get("localState");
|
|
180
|
+
m && s((P) => ({ ...P, ...m }));
|
|
181
|
+
});
|
|
182
|
+
}, [y, s]), O(() => {
|
|
183
|
+
w.awareness.setLocalState(r);
|
|
184
|
+
}, [w, r]), O(() => {
|
|
185
|
+
w.once("synced", () => S(!0));
|
|
186
|
+
const l = () => {
|
|
187
|
+
s((f) => ({
|
|
188
|
+
...f,
|
|
189
|
+
networkStatus: void 0
|
|
190
|
+
}));
|
|
191
|
+
}, m = () => {
|
|
192
|
+
s((f) => ({
|
|
193
|
+
...f,
|
|
194
|
+
networkStatus: "offline"
|
|
195
|
+
}));
|
|
196
|
+
}, P = N(({ status: f }) => {
|
|
197
|
+
f === "connected" ? l() : f === "disconnected" && m();
|
|
198
|
+
}, ye);
|
|
199
|
+
return w.on("status", P), window.addEventListener("online", l), window.addEventListener("offline", m), () => {
|
|
200
|
+
w.off("status", P), window.removeEventListener("online", l), window.removeEventListener("offline", m);
|
|
201
|
+
};
|
|
202
|
+
}, [w, s]), u && !I ? null : /* @__PURE__ */ L(B.Provider, { value: W, children: a });
|
|
203
|
+
}
|
|
204
|
+
const ve = () => {
|
|
205
|
+
const t = ce(B);
|
|
206
|
+
if (!t)
|
|
207
|
+
throw new Error("Context is null");
|
|
208
|
+
const n = te(t.state), { setLocalState: a, localState: u } = t, I = de(), S = V(), h = v(
|
|
209
|
+
() => ({
|
|
210
|
+
setCurrentSectionId: (e, o) => {
|
|
211
|
+
var r, s;
|
|
212
|
+
e === u.currentPageId && o === ((s = (r = u.pages) == null ? void 0 : r[e]) == null ? void 0 : s.currentSectionId) || (I(b("/admin/maker", S ?? "", "pages", e)), a(
|
|
213
|
+
(i) => C(i, (c) => {
|
|
214
|
+
var d;
|
|
215
|
+
c.currentPageId = e, c.currentComponentId = void 0, c.customComponentPreviewerProperties = {}, o !== void 0 && (c.pages ?? (c.pages = {}), (d = c.pages)[e] ?? (d[e] = {}), c.pages[e].currentSectionId = o ?? void 0), o ? window.sessionStorage.setItem("iframe_show_id", `"${o}"`) : window.sessionStorage.removeItem("iframe_show_id");
|
|
216
|
+
})
|
|
217
|
+
));
|
|
218
|
+
},
|
|
219
|
+
setCurrentComponentId: (e) => {
|
|
220
|
+
e !== u.currentComponentId && (I(b("/admin/maker", S ?? "", "components", e)), a(
|
|
221
|
+
(o) => C(o, (r) => {
|
|
222
|
+
r.currentComponentId = e, r.customComponentPreviewerProperties = {};
|
|
223
|
+
})
|
|
224
|
+
));
|
|
225
|
+
},
|
|
226
|
+
setCurrentRouteId: (e) => {
|
|
227
|
+
a(
|
|
228
|
+
(o) => C(o, (r) => {
|
|
229
|
+
r.currentRouteId = e;
|
|
230
|
+
})
|
|
231
|
+
);
|
|
232
|
+
},
|
|
233
|
+
setCustomComponentPreviewerProperties: (() => {
|
|
234
|
+
const e = {}, o = N(() => {
|
|
235
|
+
a(
|
|
236
|
+
(r) => C(r, (s) => {
|
|
237
|
+
s.customComponentPreviewerProperties = {
|
|
238
|
+
...s == null ? void 0 : s.customComponentPreviewerProperties,
|
|
239
|
+
...e
|
|
240
|
+
}, Object.keys(e).forEach((i) => delete e[i]);
|
|
241
|
+
})
|
|
242
|
+
);
|
|
243
|
+
}, 5);
|
|
244
|
+
return (r) => {
|
|
245
|
+
Object.assign(e, r), o();
|
|
246
|
+
};
|
|
247
|
+
})(),
|
|
248
|
+
setRouteGenerateProcess: (e) => {
|
|
249
|
+
a(
|
|
250
|
+
(o) => C(o, (r) => {
|
|
251
|
+
e ? r.routeGenerateProcess = {
|
|
252
|
+
...r.routeGenerateProcess,
|
|
253
|
+
...e
|
|
254
|
+
} : r.routeGenerateProcess = {};
|
|
255
|
+
})
|
|
256
|
+
);
|
|
257
|
+
},
|
|
258
|
+
resetRouteGenerateProcess: () => {
|
|
259
|
+
a(
|
|
260
|
+
(e) => C(e, (o) => {
|
|
261
|
+
o.routeGenerateProcess = {
|
|
262
|
+
progress: "complete"
|
|
263
|
+
};
|
|
264
|
+
})
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
}),
|
|
268
|
+
[a, I, S]
|
|
269
|
+
), p = v(
|
|
270
|
+
() => ({
|
|
271
|
+
addPage: (e, o) => {
|
|
272
|
+
var i, c, d, w, g, y;
|
|
273
|
+
const r = (e == null ? void 0 : e.id) ?? A(), s = {
|
|
274
|
+
...e,
|
|
275
|
+
id: r,
|
|
276
|
+
createdAt: (e == null ? void 0 : e.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
277
|
+
updatedAt: (e == null ? void 0 : e.updatedAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
278
|
+
publishedAt: (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
279
|
+
slug: (e == null ? void 0 : e.slug) ?? `/${r}`,
|
|
280
|
+
sections: (e == null ? void 0 : e.sections) ?? {},
|
|
281
|
+
sectionIds: (e == null ? void 0 : e.sectionIds) ?? [],
|
|
282
|
+
isPublic: (e == null ? void 0 : e.isPublic) ?? !0,
|
|
283
|
+
templateConfig: (e == null ? void 0 : e.templateConfig) ?? {
|
|
284
|
+
isTemplate: ((i = e == null ? void 0 : e.templateConfig) == null ? void 0 : i.isTemplate) ?? !0,
|
|
285
|
+
displayTemplateId: ((c = e == null ? void 0 : e.templateConfig) == null ? void 0 : c.displayTemplateId) ?? void 0,
|
|
286
|
+
dataSourceIds: ((d = e == null ? void 0 : e.templateConfig) == null ? void 0 : d.dataSourceIds) ?? void 0,
|
|
287
|
+
dataSourceParameters: ((w = e == null ? void 0 : e.templateConfig) == null ? void 0 : w.dataSourceParameters) ?? {},
|
|
288
|
+
enabledGenerate: ((g = e == null ? void 0 : e.templateConfig) == null ? void 0 : g.enabledGenerate) ?? !1,
|
|
289
|
+
agentId: ((y = e == null ? void 0 : e.templateConfig) == null ? void 0 : y.agentId) ?? void 0
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
return t.doc.transact(() => {
|
|
293
|
+
n.pages[s.id] = s, n.pageIds.splice(o ?? n.pageIds.length, 0, s.id);
|
|
294
|
+
}), s;
|
|
295
|
+
},
|
|
296
|
+
addRoute: (e, o) => {
|
|
297
|
+
const r = (e == null ? void 0 : e.id) ?? A(), s = {
|
|
298
|
+
...e,
|
|
299
|
+
id: r,
|
|
300
|
+
createdAt: (e == null ? void 0 : e.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
301
|
+
updatedAt: (e == null ? void 0 : e.updatedAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
302
|
+
publishedAt: (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
303
|
+
path: (e == null ? void 0 : e.path) ?? `/${r}`,
|
|
304
|
+
handler: (e == null ? void 0 : e.handler) ?? "Pages Kit",
|
|
305
|
+
isPublic: (e == null ? void 0 : e.isPublic) ?? !0,
|
|
306
|
+
params: (e == null ? void 0 : e.params) ?? [],
|
|
307
|
+
enabledGenerate: (e == null ? void 0 : e.enabledGenerate) ?? !1,
|
|
308
|
+
displayTemplateId: (e == null ? void 0 : e.displayTemplateId) ?? void 0,
|
|
309
|
+
dataSource: (e == null ? void 0 : e.dataSource) ?? {}
|
|
310
|
+
};
|
|
311
|
+
return t.doc.transact(() => {
|
|
312
|
+
n.routes ?? (n.routes = {}), n.routeIds ?? (n.routeIds = []), n.routes[s.id] = s, n.routeIds.splice(o ?? n.routeIds.length, 0, s.id);
|
|
313
|
+
}), s;
|
|
314
|
+
},
|
|
315
|
+
deleteRoute: (e) => {
|
|
316
|
+
var r;
|
|
317
|
+
if (!e)
|
|
318
|
+
return;
|
|
319
|
+
const o = (r = n.routeIds) == null ? void 0 : r.indexOf(e);
|
|
320
|
+
o !== void 0 && o !== -1 && t.doc.transact(() => {
|
|
321
|
+
var s, i;
|
|
322
|
+
(s = n.routeIds) == null || s.splice(o, 1), (i = n.routes) == null || delete i[e];
|
|
323
|
+
});
|
|
324
|
+
},
|
|
325
|
+
deletePage: (e) => {
|
|
326
|
+
const o = n.pageIds.indexOf(e);
|
|
327
|
+
o !== -1 && t.doc.transact(() => {
|
|
328
|
+
n.pageIds.splice(o, 1), delete n.pages[e];
|
|
329
|
+
});
|
|
330
|
+
},
|
|
331
|
+
movePage: (e, o) => {
|
|
332
|
+
const { pageIds: r } = n, s = r.indexOf(e);
|
|
333
|
+
s >= 0 && r.splice(o, 0, ...r.splice(s, 1));
|
|
334
|
+
},
|
|
335
|
+
addSection: (e, o, r) => {
|
|
336
|
+
const s = n.pages[e];
|
|
337
|
+
if (!s)
|
|
338
|
+
throw new Error(`Page ${e} is not exists`);
|
|
339
|
+
const i = {
|
|
340
|
+
...o,
|
|
341
|
+
id: o.id ?? A(),
|
|
342
|
+
isTemplateSection: o.isTemplateSection ?? !0,
|
|
343
|
+
llmConfig: o.llmConfig ?? {}
|
|
344
|
+
};
|
|
345
|
+
return t.doc.transact(() => {
|
|
346
|
+
s.sections[i.id] = i, s.sectionIds.splice(r ?? s.sectionIds.length, 0, i.id);
|
|
347
|
+
}), i;
|
|
348
|
+
},
|
|
349
|
+
deleteSection: (e, o) => {
|
|
350
|
+
const r = n.pages[e];
|
|
351
|
+
if (!r)
|
|
352
|
+
throw new Error(`Page ${e} is not exists`);
|
|
353
|
+
const s = r.sectionIds.indexOf(o);
|
|
354
|
+
s !== -1 && t.doc.transact(() => {
|
|
355
|
+
r.sectionIds.splice(s, 1), delete r.sections[o];
|
|
356
|
+
});
|
|
357
|
+
},
|
|
358
|
+
toggleSectionVisibility: (e, o, r) => {
|
|
359
|
+
const s = n.pages[e];
|
|
360
|
+
if (!s)
|
|
361
|
+
throw new Error(`Page ${e} is not exists`);
|
|
362
|
+
const i = s.sections[o];
|
|
363
|
+
i && (i.visibility = r);
|
|
364
|
+
},
|
|
365
|
+
moveSection: (e, o, r) => {
|
|
366
|
+
const s = n.pages[e];
|
|
367
|
+
if (!s)
|
|
368
|
+
throw new Error(`Page ${e} is not exists`);
|
|
369
|
+
const { sectionIds: i } = s, c = i.indexOf(o);
|
|
370
|
+
c >= 0 && i.splice(r, 0, ...i.splice(c, 1));
|
|
371
|
+
}
|
|
372
|
+
}),
|
|
373
|
+
[n, t.doc]
|
|
374
|
+
);
|
|
375
|
+
return {
|
|
376
|
+
...t,
|
|
377
|
+
state: n,
|
|
378
|
+
actions: p,
|
|
379
|
+
localActions: h,
|
|
380
|
+
get currentPage() {
|
|
381
|
+
const {
|
|
382
|
+
localState: { currentPageId: e }
|
|
383
|
+
} = t;
|
|
384
|
+
return e ? n.pages[e] : void 0;
|
|
385
|
+
},
|
|
386
|
+
get currentSection() {
|
|
387
|
+
var s, i, c;
|
|
388
|
+
const {
|
|
389
|
+
localState: { currentPageId: e, ...o }
|
|
390
|
+
} = t;
|
|
391
|
+
if (!e)
|
|
392
|
+
return;
|
|
393
|
+
const r = (i = (s = o.pages) == null ? void 0 : s[e]) == null ? void 0 : i.currentSectionId;
|
|
394
|
+
if (r)
|
|
395
|
+
return (c = n.pages[e]) == null ? void 0 : c.sections[r];
|
|
396
|
+
},
|
|
397
|
+
get currentRoute() {
|
|
398
|
+
var o;
|
|
399
|
+
const {
|
|
400
|
+
localState: { currentRouteId: e }
|
|
401
|
+
} = t;
|
|
402
|
+
return e ? (o = n.routes) == null ? void 0 : o[e] : void 0;
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
}, V = () => {
|
|
406
|
+
const { projectId: t } = ae();
|
|
407
|
+
return t ?? ue() ?? "";
|
|
408
|
+
};
|
|
409
|
+
function Ce(t) {
|
|
410
|
+
var u, I;
|
|
411
|
+
const { resources: n } = t;
|
|
412
|
+
if (!n.components)
|
|
413
|
+
return {};
|
|
414
|
+
const a = {};
|
|
415
|
+
return (I = (u = window == null ? void 0 : window.blocklet) == null ? void 0 : u.componentMountPoints) == null || I.forEach((S) => {
|
|
416
|
+
a[S.did] = S;
|
|
417
|
+
}), Object.fromEntries(
|
|
418
|
+
Object.entries(n.components).map(([S, { blockletId: h, component: p }]) => {
|
|
419
|
+
var e;
|
|
420
|
+
return [
|
|
421
|
+
S,
|
|
422
|
+
{ data: p, blockletId: h, blockletTitle: ((e = a[h]) == null ? void 0 : e.title) || h }
|
|
423
|
+
];
|
|
424
|
+
})
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
function ge(t) {
|
|
428
|
+
const { components: n } = t;
|
|
429
|
+
return n || {};
|
|
430
|
+
}
|
|
431
|
+
function je(t) {
|
|
432
|
+
return {
|
|
433
|
+
...Ce(t),
|
|
434
|
+
...ge(t)
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
const Ze = () => je(ve().state);
|
|
438
|
+
export {
|
|
439
|
+
Ke as E,
|
|
440
|
+
Ye as S,
|
|
441
|
+
qe as a,
|
|
442
|
+
ve as b,
|
|
443
|
+
We as c,
|
|
444
|
+
je as d,
|
|
445
|
+
Xe as e,
|
|
446
|
+
Ze as f,
|
|
447
|
+
Qe as g,
|
|
448
|
+
J as h,
|
|
449
|
+
Ve as i,
|
|
450
|
+
ge as j,
|
|
451
|
+
Ce as k,
|
|
452
|
+
ue as l,
|
|
453
|
+
A as n,
|
|
454
|
+
ze as t,
|
|
455
|
+
V as u
|
|
456
|
+
};
|
package/lib/es/components.js
CHANGED
|
@@ -7,7 +7,7 @@ import "lru-cache";
|
|
|
7
7
|
import "node-fetch";
|
|
8
8
|
import "ufo";
|
|
9
9
|
import "crypto";
|
|
10
|
-
import { c as _, G as E, d as i, e as d, j as l, k as N, m as O, h as P, g as c, f as g } from "./chunks/site-state-
|
|
10
|
+
import { c as _, G as E, d as i, e as d, j as l, k as N, m as O, h as P, g as c, f as g } from "./chunks/site-state-BLNi12iP.js";
|
|
11
11
|
export {
|
|
12
12
|
_ as CUSTOM_COMPONENT_CACHE_DURATION_IN_SECONDS,
|
|
13
13
|
E as GET_SERVER_SIDE_PROPS_TIMEOUT_IN_SECONDS,
|
package/lib/es/home.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
|
-
import "./chunks/state-
|
|
2
|
+
import "./chunks/state-DNndJ33Y.js";
|
|
3
3
|
import "@arcblock/ux/lib/Locale/context";
|
|
4
4
|
import "@arcblock/ux/lib/Result";
|
|
5
5
|
import "@blocklet/pages-kit/builtin/page/header";
|
|
@@ -20,8 +20,8 @@ import "react-helmet";
|
|
|
20
20
|
import "react-router-dom";
|
|
21
21
|
import "react-use";
|
|
22
22
|
import "ufo";
|
|
23
|
-
import "./chunks/array-
|
|
24
|
-
import { a as B, P as D, d as R, c as S, b as W, T as j, H as k } from "./chunks/home-
|
|
23
|
+
import "./chunks/array-CWudJ_mc.js";
|
|
24
|
+
import { a as B, P as D, d as R, c as S, b as W, T as j, H as k } from "./chunks/home-D5UawjLT.js";
|
|
25
25
|
export {
|
|
26
26
|
B as HomeView,
|
|
27
27
|
D as PageRoutes,
|
package/lib/es/locales.js
CHANGED
|
@@ -118,6 +118,21 @@ const t = e({
|
|
|
118
118
|
},
|
|
119
119
|
export: "Export",
|
|
120
120
|
noPreviewAvailable: "No preview available",
|
|
121
|
+
routePreview: {
|
|
122
|
+
loading: "Loading...",
|
|
123
|
+
generatingPageStructure: "Generating page content structure...",
|
|
124
|
+
generatingSectionContent: "Generating section content...",
|
|
125
|
+
routePreview: "Route Preview",
|
|
126
|
+
noDisplayTemplate: "This route has no display template",
|
|
127
|
+
templateNotFound: "Display template not found",
|
|
128
|
+
noSectionsAvailable: "No sections available",
|
|
129
|
+
optimizeContent: "Optimize Content",
|
|
130
|
+
optimizeContentButton: "Use AI to optimize content",
|
|
131
|
+
sectionRule: "Section Rule",
|
|
132
|
+
sectionRulePlaceholder: "Enter your section rule or instructions for AI generation",
|
|
133
|
+
confirmOptimize: "Confirm",
|
|
134
|
+
cancelOptimize: "Cancel"
|
|
135
|
+
},
|
|
121
136
|
pages: {
|
|
122
137
|
addPage: "Create Page",
|
|
123
138
|
createResource: "Create Resource",
|
|
@@ -283,6 +298,9 @@ const t = e({
|
|
|
283
298
|
deleteRouteTitle: "Delete Route",
|
|
284
299
|
deleteRouteConfirm: "Are you sure you want to delete this route? This action cannot be undone.",
|
|
285
300
|
routeDeleted: "Route deleted successfully"
|
|
301
|
+
},
|
|
302
|
+
datasource: {
|
|
303
|
+
autoSaveSuccess: "Auto save success"
|
|
286
304
|
}
|
|
287
305
|
},
|
|
288
306
|
error: {
|
|
@@ -564,6 +582,21 @@ const t = e({
|
|
|
564
582
|
},
|
|
565
583
|
export: "导出",
|
|
566
584
|
noPreviewAvailable: "无可用预览",
|
|
585
|
+
routePreview: {
|
|
586
|
+
loading: "加载中...",
|
|
587
|
+
generatingPageStructure: "正在生成页面内容结构...",
|
|
588
|
+
generatingSectionContent: "正在生成卡片内容...",
|
|
589
|
+
routePreview: "路由预览",
|
|
590
|
+
noDisplayTemplate: "该路由没有显示模板",
|
|
591
|
+
templateNotFound: "未找到显示模板",
|
|
592
|
+
noSectionsAvailable: "没有可用内容",
|
|
593
|
+
optimizeContent: "内容优化",
|
|
594
|
+
optimizeContentButton: "使用 AI 优化内容",
|
|
595
|
+
sectionRule: "卡片规则",
|
|
596
|
+
sectionRulePlaceholder: "输入卡片规则",
|
|
597
|
+
confirmOptimize: "确认",
|
|
598
|
+
cancelOptimize: "取消"
|
|
599
|
+
},
|
|
567
600
|
pages: {
|
|
568
601
|
addPage: "创建页面",
|
|
569
602
|
createResource: "创建资源",
|
|
@@ -693,9 +726,9 @@ const t = e({
|
|
|
693
726
|
isTemplate: "作为模版页面使用",
|
|
694
727
|
isTemplateSection: "模板动态卡片",
|
|
695
728
|
templateDescription: "卡片描述,使用 AIGNE 生成页面内容时,会根据卡片描述生成卡片内容",
|
|
696
|
-
templateSectionNameRequired: "
|
|
697
|
-
templateSectionNameHelper: "
|
|
698
|
-
templateSectionNameDuplicated: "
|
|
729
|
+
templateSectionNameRequired: "模板卡片需要设置名称,以便在使用动态模板时为卡片设置对应的值",
|
|
730
|
+
templateSectionNameHelper: "卡片名称用于标识模板中的卡片,请使用有意义且唯一的名称,以便后续为卡片设置内容",
|
|
731
|
+
templateSectionNameDuplicated: "模板卡片名称在页面中必须唯一,当前名称已被其他模板卡片使用",
|
|
699
732
|
propertyNotFound: "修改参数失败,原因:组件不存在 `{key}` 属性",
|
|
700
733
|
configDetailedDescription: "配置详细描述",
|
|
701
734
|
llmConfigTitle: "LLM 配置详情",
|
|
@@ -738,6 +771,9 @@ const t = e({
|
|
|
738
771
|
landing: "落地页模板",
|
|
739
772
|
form: "表单模板"
|
|
740
773
|
}
|
|
774
|
+
},
|
|
775
|
+
datasource: {
|
|
776
|
+
autoSaveSuccess: "自动保存成功"
|
|
741
777
|
}
|
|
742
778
|
},
|
|
743
779
|
error: {
|
|
@@ -900,7 +936,7 @@ const t = e({
|
|
|
900
936
|
style: {
|
|
901
937
|
title: "公共样式"
|
|
902
938
|
}
|
|
903
|
-
}),
|
|
939
|
+
}), n = { en: t, zh: a };
|
|
904
940
|
export {
|
|
905
|
-
|
|
941
|
+
n as translations
|
|
906
942
|
};
|