@blocklet/pages-kit-inner-components 0.5.29 → 0.5.31
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 +47 -23
- package/lib/cjs/chunks/array-BH41o7C6.js +475 -0
- package/lib/cjs/chunks/{config-string-C4Q0hgG0.js → config-string-B3JoYJVu.js} +1 -1
- package/lib/cjs/chunks/{draft-data-Cu9gua-P.js → draft-data-hZaTeHgL.js} +1 -1
- package/lib/cjs/chunks/home-B6E0yAU3.js +38 -0
- package/lib/cjs/chunks/{publish-button-DvwoFH1F.js → publish-button-CO_WU_f5.js} +1 -1
- package/lib/cjs/chunks/site-state-D5jk8eJT.js +57 -0
- package/lib/cjs/chunks/state-DxOb57hO.js +1 -0
- package/lib/cjs/components.js +1 -1
- package/lib/cjs/home.js +1 -1
- package/lib/cjs/locales.js +3 -1
- package/lib/cjs/project-html.js +2 -2
- 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 +795 -749
- package/lib/es/chunks/array-NLDZzhVt.js +2224 -0
- package/lib/es/chunks/{config-string-CNLg1EYu.js → config-string-DutyRoOh.js} +1 -1
- package/lib/es/chunks/{draft-data-hSHLdxKp.js → draft-data-DjX0kpDC.js} +1 -1
- package/lib/es/chunks/{home-CNk6U8FU.js → home-CxRa0eKd.js} +112 -96
- package/lib/es/chunks/{publish-button-BftBlabj.js → publish-button-1bl_Nuva.js} +3 -3
- package/lib/es/chunks/site-state-DEduMTrY.js +2073 -0
- package/lib/es/chunks/state-C02ZI8vz.js +605 -0
- package/lib/es/components.js +1 -1
- package/lib/es/home.js +3 -3
- package/lib/es/locales.js +44 -6
- package/lib/es/project-html.js +43 -42
- package/lib/es/resources.js +51 -51
- package/lib/es/setting.js +2 -2
- package/lib/es/site-state.js +1 -1
- package/package.json +10 -10
- package/lib/cjs/chunks/array-CJC7ex3i.js +0 -467
- package/lib/cjs/chunks/home-CimGvyT9.js +0 -38
- package/lib/cjs/chunks/site-state-JgP3yURe.js +0 -57
- package/lib/cjs/chunks/state-jCG5gSUJ.js +0 -1
- package/lib/es/chunks/array-9j8tOSbO.js +0 -1993
- package/lib/es/chunks/site-state-BB9-Tm4i.js +0 -1930
- package/lib/es/chunks/state-D5BnGunt.js +0 -483
|
@@ -0,0 +1,605 @@
|
|
|
1
|
+
import { jsx as $ } from "react/jsx-runtime";
|
|
2
|
+
import { Box as V, Alert as z } from "@mui/material";
|
|
3
|
+
import { joinURL as A, withQuery as q } from "ufo";
|
|
4
|
+
import { createAxios as Q } from "@blocklet/js-sdk";
|
|
5
|
+
import X from "lodash/isEmpty";
|
|
6
|
+
import * as H from "yaml";
|
|
7
|
+
import { useLocaleContext as Y } from "@arcblock/ux/lib/Locale/context";
|
|
8
|
+
import { TemplateModel as Z, PAGES_KIT_CHILDREN_PROPERTIES as ee } from "@blocklet/pages-kit-core";
|
|
9
|
+
import te, { getYjsDoc as oe } from "@syncedstore/core";
|
|
10
|
+
import { useSyncedStore as ne } from "@syncedstore/react";
|
|
11
|
+
import { useLocalStorageState as re } from "ahooks";
|
|
12
|
+
import { produce as k } from "immer";
|
|
13
|
+
import ce from "lodash/cloneDeep";
|
|
14
|
+
import U from "lodash/debounce";
|
|
15
|
+
import { customAlphabet as se } from "nanoid";
|
|
16
|
+
import { createContext as ie, useState as _, useRef as ae, useMemo as j, useCallback as D, useEffect as R, useContext as de } from "react";
|
|
17
|
+
import { useParams as le, useNavigate as ue } from "react-router-dom";
|
|
18
|
+
import { IndexeddbPersistence as me } from "y-indexeddb";
|
|
19
|
+
import { WebsocketProvider as fe } from "y-websocket";
|
|
20
|
+
import { UndoManager as Se } from "yjs";
|
|
21
|
+
import "@blocklet/pages-kit/types";
|
|
22
|
+
const qe = (r) => {
|
|
23
|
+
const o = blocklet == null ? void 0 : blocklet.componentMountPoints.find((f) => f.name === r);
|
|
24
|
+
return o ? o.mountPoint : "/";
|
|
25
|
+
};
|
|
26
|
+
function pe() {
|
|
27
|
+
const { pathname: r } = window.location, o = r.match(/\/admin\/(maker|previewer)\/([^/]+)/), f = o == null ? void 0 : o[2], h = window.__PROJECT_ID__;
|
|
28
|
+
if (!f && !h)
|
|
29
|
+
throw new Error("Unable to get projectId from pathname");
|
|
30
|
+
return f || h;
|
|
31
|
+
}
|
|
32
|
+
function Qe(r) {
|
|
33
|
+
return `${r}:pages:version`;
|
|
34
|
+
}
|
|
35
|
+
function Xe(r, o) {
|
|
36
|
+
return o === "yaml" ? X(r) ? "" : H.stringify(r, { indent: 2 }) : o === "json" ? JSON.parse(JSON.stringify(r || {})) : o === "array" ? JSON.parse(JSON.stringify(r || [])) : r;
|
|
37
|
+
}
|
|
38
|
+
function He({ error: r }) {
|
|
39
|
+
return /* @__PURE__ */ $(V, { children: /* @__PURE__ */ $(z, { severity: "error", children: r.message }) });
|
|
40
|
+
}
|
|
41
|
+
var G;
|
|
42
|
+
const T = ((G = window.blocklet) == null ? void 0 : G.prefix) || "/", F = Q({
|
|
43
|
+
timeout: 200 * 1e3
|
|
44
|
+
}), ge = window.location.protocol === "https:" ? "wss" : "ws", Ye = (r) => A(`${ge}://${window.location.hostname}`, T, `api/${r}/ws/pages`), Pe = "z8ia1mAXo8ZE7ytGF36L5uBf9kD2kenhqFGp9";
|
|
45
|
+
var B;
|
|
46
|
+
(B = blocklet == null ? void 0 : blocklet.componentMountPoints.find((r) => r.did === Pe)) != null && B.mountPoint || A(T, "/image-bin");
|
|
47
|
+
function Ze(r) {
|
|
48
|
+
return r && !/^(https?:\/\/|\/)/.test(r) ? window.location.origin + A(T, "uploads", r) : r;
|
|
49
|
+
}
|
|
50
|
+
const we = window.innerWidth <= 750;
|
|
51
|
+
function et(r, o, f) {
|
|
52
|
+
if (!r || /\.gif/.test(r)) return r;
|
|
53
|
+
const h = (we ? o / 1.5 : o) * (f === "quality" ? 1.5 : 1);
|
|
54
|
+
return Ie(r, { imageFilter: "resize", w: h, f: "webp" });
|
|
55
|
+
}
|
|
56
|
+
function Ie(r, o) {
|
|
57
|
+
return !r || !o ? r : q(r, o);
|
|
58
|
+
}
|
|
59
|
+
async function ye(r) {
|
|
60
|
+
return F.get(`/api/projects/${r}`).then((o) => o.data);
|
|
61
|
+
}
|
|
62
|
+
async function he(r) {
|
|
63
|
+
return F.post(`/api/projects/${r.id}/update`, r).then((o) => o.data);
|
|
64
|
+
}
|
|
65
|
+
const ve = 500, M = se("abcdefghijklmnopqrstuvwxyz0123456789", 16), N = ie(null);
|
|
66
|
+
function tt({
|
|
67
|
+
url: r,
|
|
68
|
+
name: o,
|
|
69
|
+
children: f,
|
|
70
|
+
waitingSynced: h
|
|
71
|
+
}) {
|
|
72
|
+
const [E, b] = _(!1), { locale: S } = Y(), v = W(), L = `${v}:MakerLocalState`, e = `${v}:${o}`, [t, s] = re(L, {
|
|
73
|
+
defaultValue: {},
|
|
74
|
+
listenStorageChange: !0
|
|
75
|
+
}), c = ae(t);
|
|
76
|
+
c.current = t;
|
|
77
|
+
const i = j(
|
|
78
|
+
() => te({
|
|
79
|
+
dataSourceIds: [],
|
|
80
|
+
dataSources: {},
|
|
81
|
+
pages: {},
|
|
82
|
+
pageIds: [],
|
|
83
|
+
routes: {},
|
|
84
|
+
routeIds: [],
|
|
85
|
+
components: {},
|
|
86
|
+
supportedLocales: [],
|
|
87
|
+
config: {},
|
|
88
|
+
resources: {}
|
|
89
|
+
}),
|
|
90
|
+
[]
|
|
91
|
+
), n = j(() => oe(i), [i]);
|
|
92
|
+
j(() => new me(e, n), [e, n]);
|
|
93
|
+
const a = j(
|
|
94
|
+
() => new fe(r, e, n, {
|
|
95
|
+
params: {},
|
|
96
|
+
resyncInterval: 5 * 60 * 1e3
|
|
97
|
+
}),
|
|
98
|
+
[r, e, n]
|
|
99
|
+
), d = D(() => {
|
|
100
|
+
a && (a.disconnect(), a.connect());
|
|
101
|
+
}, [a]), l = j(
|
|
102
|
+
() => new Se(
|
|
103
|
+
[
|
|
104
|
+
n.getArray("pageIds"),
|
|
105
|
+
n.getMap("pages"),
|
|
106
|
+
n.getArray("supportedLocales"),
|
|
107
|
+
n.getMap("config"),
|
|
108
|
+
n.getMap("dataSources"),
|
|
109
|
+
n.getArray("dataSourceIds"),
|
|
110
|
+
n.getArray("routeIds"),
|
|
111
|
+
n.getMap("routes")
|
|
112
|
+
],
|
|
113
|
+
{ doc: n }
|
|
114
|
+
),
|
|
115
|
+
[n]
|
|
116
|
+
), [u, m] = _(null), [C, p] = _(!1), [g, P] = _(void 0), x = D(async () => {
|
|
117
|
+
if (v) {
|
|
118
|
+
p(!0);
|
|
119
|
+
try {
|
|
120
|
+
const w = await ye(v);
|
|
121
|
+
m(w);
|
|
122
|
+
} catch (w) {
|
|
123
|
+
console.error("Failed to fetch project:", w);
|
|
124
|
+
} finally {
|
|
125
|
+
p(!1);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}, [v]), J = D(
|
|
129
|
+
async (w, I) => {
|
|
130
|
+
var O;
|
|
131
|
+
if (P(void 0), !!v) {
|
|
132
|
+
I != null && I.optimisticUpdate && u && m((y) => ({
|
|
133
|
+
...y,
|
|
134
|
+
...w
|
|
135
|
+
}));
|
|
136
|
+
try {
|
|
137
|
+
const y = await he({
|
|
138
|
+
...w
|
|
139
|
+
});
|
|
140
|
+
m(y);
|
|
141
|
+
} catch (y) {
|
|
142
|
+
console.error("Failed to update project:", y), I != null && I.optimisticUpdate && m(u), P((O = y == null ? void 0 : y.response) == null ? void 0 : O.data);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
[v, u]
|
|
147
|
+
);
|
|
148
|
+
R(() => {
|
|
149
|
+
v && x();
|
|
150
|
+
}, [v, x]);
|
|
151
|
+
const K = j(
|
|
152
|
+
() => ({
|
|
153
|
+
doc: n,
|
|
154
|
+
state: i,
|
|
155
|
+
localState: {
|
|
156
|
+
...t,
|
|
157
|
+
// always use the locale from the context
|
|
158
|
+
currentLocale: S
|
|
159
|
+
},
|
|
160
|
+
setLocalState: (w) => s(typeof w == "function" ? (I) => w(I ?? {}) : w),
|
|
161
|
+
undoManager: l,
|
|
162
|
+
projectState: {
|
|
163
|
+
project: u,
|
|
164
|
+
isLoadingProject: C,
|
|
165
|
+
error: g
|
|
166
|
+
},
|
|
167
|
+
updateProject: J,
|
|
168
|
+
forceSync: d
|
|
169
|
+
}),
|
|
170
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
171
|
+
[
|
|
172
|
+
n,
|
|
173
|
+
i,
|
|
174
|
+
JSON.stringify(t),
|
|
175
|
+
// resolve the problem of react warning
|
|
176
|
+
s,
|
|
177
|
+
l,
|
|
178
|
+
u,
|
|
179
|
+
C,
|
|
180
|
+
J,
|
|
181
|
+
g,
|
|
182
|
+
S,
|
|
183
|
+
d
|
|
184
|
+
]
|
|
185
|
+
);
|
|
186
|
+
return R(() => {
|
|
187
|
+
l.on("stack-item-added", ({ stackItem: w }) => {
|
|
188
|
+
const { currentPageId: I, currentLocale: O, pages: y } = c.current;
|
|
189
|
+
w.meta.set("localState", { currentPageId: I, currentLocale: O, pages: y });
|
|
190
|
+
}), l.on("stack-item-popped", ({ stackItem: w }) => {
|
|
191
|
+
const I = w.meta.get("localState");
|
|
192
|
+
I && s((O) => ({ ...O, ...I }));
|
|
193
|
+
});
|
|
194
|
+
}, [l, s]), R(() => {
|
|
195
|
+
a.awareness.setLocalState(t);
|
|
196
|
+
}, [a, t]), R(() => {
|
|
197
|
+
a.once("synced", () => b(!0));
|
|
198
|
+
const w = () => {
|
|
199
|
+
s((y) => ({
|
|
200
|
+
...y,
|
|
201
|
+
networkStatus: void 0
|
|
202
|
+
}));
|
|
203
|
+
}, I = () => {
|
|
204
|
+
s((y) => ({
|
|
205
|
+
...y,
|
|
206
|
+
networkStatus: "offline"
|
|
207
|
+
}));
|
|
208
|
+
}, O = U(({ status: y }) => {
|
|
209
|
+
y === "connected" ? w() : y === "disconnected" && I();
|
|
210
|
+
}, ve);
|
|
211
|
+
return a.on("status", O), window.addEventListener("online", w), window.addEventListener("offline", I), () => {
|
|
212
|
+
a.off("status", O), window.removeEventListener("online", w), window.removeEventListener("offline", I);
|
|
213
|
+
};
|
|
214
|
+
}, [a, s]), h && !E ? null : /* @__PURE__ */ $(N.Provider, { value: K, children: f });
|
|
215
|
+
}
|
|
216
|
+
const Ce = () => {
|
|
217
|
+
const r = de(N);
|
|
218
|
+
if (!r)
|
|
219
|
+
throw new Error("Context is null");
|
|
220
|
+
const o = ne(r.state), { setLocalState: f, localState: h } = r, E = ue(), b = W(), S = j(
|
|
221
|
+
() => ({
|
|
222
|
+
get currentPage() {
|
|
223
|
+
const {
|
|
224
|
+
localState: { currentPageId: e }
|
|
225
|
+
} = r;
|
|
226
|
+
return e ? o.pages[e] : void 0;
|
|
227
|
+
},
|
|
228
|
+
get currentSection() {
|
|
229
|
+
var c, i, n, a, d;
|
|
230
|
+
const {
|
|
231
|
+
localState: { currentPageId: e, ...t }
|
|
232
|
+
} = r;
|
|
233
|
+
if (!e)
|
|
234
|
+
return;
|
|
235
|
+
const s = (i = (c = t.pages) == null ? void 0 : c[e]) == null ? void 0 : i.currentSectionId;
|
|
236
|
+
if (s)
|
|
237
|
+
return ((n = o.pages[e]) == null ? void 0 : n.sections[s]) ?? ((d = (a = this.currentPageModel) == null ? void 0 : a.getComponentById(s)) == null ? void 0 : d.model);
|
|
238
|
+
},
|
|
239
|
+
get currentSectionProperties() {
|
|
240
|
+
var n, a, d, l;
|
|
241
|
+
const {
|
|
242
|
+
localState: { currentPageId: e, ...t }
|
|
243
|
+
} = r;
|
|
244
|
+
if (!e)
|
|
245
|
+
return;
|
|
246
|
+
const s = (a = (n = t.pages) == null ? void 0 : n[e]) == null ? void 0 : a.currentSectionId;
|
|
247
|
+
if (!s)
|
|
248
|
+
return;
|
|
249
|
+
const c = (l = (d = o.pages[e]) == null ? void 0 : d.dataSource) == null ? void 0 : l[s];
|
|
250
|
+
if (!c)
|
|
251
|
+
return;
|
|
252
|
+
const { currentLocale: i } = this.currentLocaleMap;
|
|
253
|
+
return i ? c[i] : void 0;
|
|
254
|
+
},
|
|
255
|
+
get currentSectionPropertiesWithFallback() {
|
|
256
|
+
var d, l, u, m;
|
|
257
|
+
const {
|
|
258
|
+
localState: { currentPageId: e, ...t }
|
|
259
|
+
} = r;
|
|
260
|
+
if (!e)
|
|
261
|
+
return;
|
|
262
|
+
const s = (l = (d = t.pages) == null ? void 0 : d[e]) == null ? void 0 : l.currentSectionId;
|
|
263
|
+
if (!s)
|
|
264
|
+
return;
|
|
265
|
+
const c = (m = (u = o.pages[e]) == null ? void 0 : u.dataSource) == null ? void 0 : m[s];
|
|
266
|
+
if (!c)
|
|
267
|
+
return;
|
|
268
|
+
const { currentLocale: i, defaultLocale: n, fallbackLocale: a } = this.currentLocaleMap;
|
|
269
|
+
if (i && c[i])
|
|
270
|
+
return c[i];
|
|
271
|
+
if (n && c[n])
|
|
272
|
+
return c[n];
|
|
273
|
+
if (a && c[a])
|
|
274
|
+
return c[a];
|
|
275
|
+
},
|
|
276
|
+
get currentLocaleMap() {
|
|
277
|
+
var c;
|
|
278
|
+
const {
|
|
279
|
+
localState: { currentLocale: e },
|
|
280
|
+
state: {
|
|
281
|
+
supportedLocales: t,
|
|
282
|
+
config: { defaultLocale: s }
|
|
283
|
+
}
|
|
284
|
+
} = r;
|
|
285
|
+
return {
|
|
286
|
+
currentLocale: e,
|
|
287
|
+
defaultLocale: s,
|
|
288
|
+
fallbackLocale: ((c = t == null ? void 0 : t[0]) == null ? void 0 : c.locale) ?? "en"
|
|
289
|
+
};
|
|
290
|
+
},
|
|
291
|
+
get currentRoute() {
|
|
292
|
+
var t;
|
|
293
|
+
const {
|
|
294
|
+
localState: { currentRouteId: e }
|
|
295
|
+
} = r;
|
|
296
|
+
return e ? (t = o.routes) == null ? void 0 : t[e] : void 0;
|
|
297
|
+
},
|
|
298
|
+
get currentPageModel() {
|
|
299
|
+
const e = this.currentPage ?? null;
|
|
300
|
+
if (e) {
|
|
301
|
+
const t = new Z({
|
|
302
|
+
childrenProperties: ee,
|
|
303
|
+
locale: h.currentLocale
|
|
304
|
+
});
|
|
305
|
+
return t.parse(e), t;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}),
|
|
309
|
+
[JSON.stringify(h), o]
|
|
310
|
+
), v = j(
|
|
311
|
+
() => ({
|
|
312
|
+
setCurrentSectionId: (e, t) => {
|
|
313
|
+
var s, c;
|
|
314
|
+
e === h.currentPageId && t === ((c = (s = h.pages) == null ? void 0 : s[e]) == null ? void 0 : c.currentSectionId) || (E(A("/admin/maker", b ?? "", "pages", e)), f(
|
|
315
|
+
(i) => k(i, (n) => {
|
|
316
|
+
var a;
|
|
317
|
+
n.currentPageId = e, n.currentComponentId = void 0, n.customComponentPreviewerProperties = {}, t !== void 0 && (n.pages ?? (n.pages = {}), (a = n.pages)[e] ?? (a[e] = {}), n.pages[e].currentSectionId = t ?? void 0), t ? window.sessionStorage.setItem("iframe_show_id", `"${t}"`) : window.sessionStorage.removeItem("iframe_show_id");
|
|
318
|
+
})
|
|
319
|
+
));
|
|
320
|
+
},
|
|
321
|
+
setCurrentComponentId: (e) => {
|
|
322
|
+
e !== h.currentComponentId && (E(A("/admin/maker", b ?? "", "components", e)), f(
|
|
323
|
+
(t) => k(t, (s) => {
|
|
324
|
+
s.currentComponentId = e, s.customComponentPreviewerProperties = {};
|
|
325
|
+
})
|
|
326
|
+
));
|
|
327
|
+
},
|
|
328
|
+
setCurrentRouteId: ({ routeId: e, dynamicParams: t }) => {
|
|
329
|
+
f(
|
|
330
|
+
(s) => k(s, (c) => {
|
|
331
|
+
c.currentRouteId = e, c.currentDynamicParams = t;
|
|
332
|
+
})
|
|
333
|
+
);
|
|
334
|
+
},
|
|
335
|
+
setCustomComponentPreviewerProperties: (() => {
|
|
336
|
+
const e = {}, t = U(() => {
|
|
337
|
+
f(
|
|
338
|
+
(s) => k(s, (c) => {
|
|
339
|
+
c.customComponentPreviewerProperties = {
|
|
340
|
+
...c == null ? void 0 : c.customComponentPreviewerProperties,
|
|
341
|
+
...e
|
|
342
|
+
}, Object.keys(e).forEach((i) => delete e[i]);
|
|
343
|
+
})
|
|
344
|
+
);
|
|
345
|
+
}, 5);
|
|
346
|
+
return (s) => {
|
|
347
|
+
Object.assign(e, s), t();
|
|
348
|
+
};
|
|
349
|
+
})(),
|
|
350
|
+
setRouteGenerateProcess: (e) => {
|
|
351
|
+
f(
|
|
352
|
+
(t) => k(t, (s) => {
|
|
353
|
+
e ? s.routeGenerateProcess = {
|
|
354
|
+
...s.routeGenerateProcess,
|
|
355
|
+
...e
|
|
356
|
+
} : s.routeGenerateProcess = {};
|
|
357
|
+
})
|
|
358
|
+
);
|
|
359
|
+
},
|
|
360
|
+
resetRouteGenerateProcess: () => {
|
|
361
|
+
f(
|
|
362
|
+
(e) => k(e, (t) => {
|
|
363
|
+
t.routeGenerateProcess = {
|
|
364
|
+
progress: "complete"
|
|
365
|
+
};
|
|
366
|
+
})
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
}),
|
|
370
|
+
[f, E, b, S]
|
|
371
|
+
), L = j(
|
|
372
|
+
() => ({
|
|
373
|
+
addPage: (e, t) => {
|
|
374
|
+
var i, n, a, d, l, u;
|
|
375
|
+
const s = (e == null ? void 0 : e.id) ?? M(), c = {
|
|
376
|
+
...e,
|
|
377
|
+
id: s,
|
|
378
|
+
createdAt: (e == null ? void 0 : e.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
379
|
+
updatedAt: (e == null ? void 0 : e.updatedAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
380
|
+
publishedAt: (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
381
|
+
slug: (e == null ? void 0 : e.slug) ?? `/${s}`,
|
|
382
|
+
sections: (e == null ? void 0 : e.sections) ?? {},
|
|
383
|
+
sectionIds: (e == null ? void 0 : e.sectionIds) ?? [],
|
|
384
|
+
isPublic: (e == null ? void 0 : e.isPublic) ?? !0,
|
|
385
|
+
templateConfig: (e == null ? void 0 : e.templateConfig) ?? {
|
|
386
|
+
isTemplate: ((i = e == null ? void 0 : e.templateConfig) == null ? void 0 : i.isTemplate) ?? !0,
|
|
387
|
+
displayTemplateId: ((n = e == null ? void 0 : e.templateConfig) == null ? void 0 : n.displayTemplateId) ?? void 0,
|
|
388
|
+
dataSourceIds: ((a = e == null ? void 0 : e.templateConfig) == null ? void 0 : a.dataSourceIds) ?? void 0,
|
|
389
|
+
dataSourceParameters: ((d = e == null ? void 0 : e.templateConfig) == null ? void 0 : d.dataSourceParameters) ?? {},
|
|
390
|
+
enabledGenerate: ((l = e == null ? void 0 : e.templateConfig) == null ? void 0 : l.enabledGenerate) ?? !1,
|
|
391
|
+
agentId: ((u = e == null ? void 0 : e.templateConfig) == null ? void 0 : u.agentId) ?? void 0
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
return r.doc.transact(() => {
|
|
395
|
+
o.pages[c.id] = c, o.pageIds.splice(t ?? o.pageIds.length, 0, c.id);
|
|
396
|
+
}), c;
|
|
397
|
+
},
|
|
398
|
+
addRoute: (e, t) => {
|
|
399
|
+
const s = (e == null ? void 0 : e.id) ?? M(), c = {
|
|
400
|
+
...e,
|
|
401
|
+
id: s,
|
|
402
|
+
createdAt: (e == null ? void 0 : e.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
403
|
+
updatedAt: (e == null ? void 0 : e.updatedAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
404
|
+
publishedAt: (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
405
|
+
path: (e == null ? void 0 : e.path) ?? `/${s}`,
|
|
406
|
+
handler: (e == null ? void 0 : e.handler) ?? "Pages Kit",
|
|
407
|
+
isPublic: (e == null ? void 0 : e.isPublic) ?? !0,
|
|
408
|
+
params: (e == null ? void 0 : e.params) ?? [],
|
|
409
|
+
enabledGenerate: (e == null ? void 0 : e.enabledGenerate) ?? !1,
|
|
410
|
+
displayTemplateId: (e == null ? void 0 : e.displayTemplateId) ?? void 0,
|
|
411
|
+
dataSource: (e == null ? void 0 : e.dataSource) ?? {}
|
|
412
|
+
};
|
|
413
|
+
return r.doc.transact(() => {
|
|
414
|
+
o.routes ?? (o.routes = {}), o.routeIds ?? (o.routeIds = []), o.routes[c.id] = c, o.routeIds.splice(t ?? o.routeIds.length, 0, c.id);
|
|
415
|
+
}), c;
|
|
416
|
+
},
|
|
417
|
+
deleteRoute: (e) => {
|
|
418
|
+
var s;
|
|
419
|
+
if (!e)
|
|
420
|
+
return;
|
|
421
|
+
const t = (s = o.routeIds) == null ? void 0 : s.indexOf(e);
|
|
422
|
+
t !== void 0 && t !== -1 && r.doc.transact(() => {
|
|
423
|
+
var c, i;
|
|
424
|
+
(c = o.routeIds) == null || c.splice(t, 1), (i = o.routes) == null || delete i[e];
|
|
425
|
+
});
|
|
426
|
+
},
|
|
427
|
+
deletePage: (e) => {
|
|
428
|
+
const t = o.pageIds.indexOf(e);
|
|
429
|
+
t !== -1 && r.doc.transact(() => {
|
|
430
|
+
o.pageIds.splice(t, 1), delete o.pages[e];
|
|
431
|
+
});
|
|
432
|
+
},
|
|
433
|
+
movePage: (e, t) => {
|
|
434
|
+
const { pageIds: s } = o, c = s.indexOf(e);
|
|
435
|
+
c >= 0 && s.splice(t, 0, ...s.splice(c, 1));
|
|
436
|
+
},
|
|
437
|
+
addSection: (e, t, s, c) => {
|
|
438
|
+
const i = o.pages[e];
|
|
439
|
+
if (!i)
|
|
440
|
+
throw new Error(`Page ${e} is not exists`);
|
|
441
|
+
const n = {
|
|
442
|
+
...t,
|
|
443
|
+
id: t.id ?? M(),
|
|
444
|
+
isTemplateSection: t.isTemplateSection ?? !0,
|
|
445
|
+
llmConfig: t.llmConfig ?? {}
|
|
446
|
+
}, a = ce(n.locales);
|
|
447
|
+
return delete n.locales, r.doc.transact(() => {
|
|
448
|
+
var d, l, u;
|
|
449
|
+
if (c && c.component === "layout-block") {
|
|
450
|
+
const m = (d = S.currentPageModel) == null ? void 0 : d.getComponentById(c.id);
|
|
451
|
+
m && ((l = m.model).sections ?? (l.sections = {}), m.model.sections[n.id] = n, (u = m.model).sectionIds ?? (u.sectionIds = []), m.model.sectionIds.push(n.id));
|
|
452
|
+
} else
|
|
453
|
+
i.sections[n.id] = n, i.sectionIds.splice(s ?? i.sectionIds.length, 0, n.id);
|
|
454
|
+
a && (i.dataSource ?? (i.dataSource = {}), i.dataSource[n.id] = a);
|
|
455
|
+
}), n;
|
|
456
|
+
},
|
|
457
|
+
deleteSection: (e, t) => {
|
|
458
|
+
const s = o.pages[e];
|
|
459
|
+
if (!s)
|
|
460
|
+
throw new Error(`Page ${e} is not exists`);
|
|
461
|
+
r.doc.transact(() => {
|
|
462
|
+
var a, d, l, u, m, C;
|
|
463
|
+
const c = [], i = (a = S.currentPageModel) == null ? void 0 : a.getComponentById(t), n = i == null ? void 0 : i.parent;
|
|
464
|
+
if (i && (c.push(i.model.id, ...i.all().map((p) => p.model.id)), (n == null ? void 0 : n.model.component) === "layout-block")) {
|
|
465
|
+
const p = (d = n.model.sectionIds) == null ? void 0 : d.indexOf(t);
|
|
466
|
+
p !== void 0 && p !== -1 && ((l = n.model.sectionIds) == null || l.splice(p, 1), (u = n.model.sections) == null || delete u[t]), (m = n.model.config) != null && m.gridSettings && Object.keys(n.model.config.gridSettings).forEach((g) => {
|
|
467
|
+
var P;
|
|
468
|
+
try {
|
|
469
|
+
(P = n.model.config.gridSettings[g]) == null || delete P[t];
|
|
470
|
+
} catch {
|
|
471
|
+
}
|
|
472
|
+
}), ((C = n.model.config) == null ? void 0 : C.backgroundSectionId) === t && (n.model.config.backgroundSectionId = void 0);
|
|
473
|
+
}
|
|
474
|
+
c.forEach((p) => {
|
|
475
|
+
var P, x;
|
|
476
|
+
const g = s.sectionIds.indexOf(p);
|
|
477
|
+
g !== -1 && s.sectionIds.splice(g, 1), s.sections[p] && delete s.sections[p], (P = s.dataSource) != null && P[p] && ((x = s.dataSource) == null || delete x[p]);
|
|
478
|
+
});
|
|
479
|
+
});
|
|
480
|
+
},
|
|
481
|
+
lockSection: (e, t) => {
|
|
482
|
+
var i, n;
|
|
483
|
+
if (!o.pages[e])
|
|
484
|
+
throw new Error(`Page ${e} is not exists`);
|
|
485
|
+
const c = (n = (i = S.currentPageModel) == null ? void 0 : i.getComponentById(t)) == null ? void 0 : n.model;
|
|
486
|
+
c && (c.locked = !c.locked);
|
|
487
|
+
},
|
|
488
|
+
toggleSectionVisibility: (e, t, s) => {
|
|
489
|
+
var n, a;
|
|
490
|
+
if (!o.pages[e])
|
|
491
|
+
throw new Error(`Page ${e} is not exists`);
|
|
492
|
+
const i = (a = (n = S.currentPageModel) == null ? void 0 : n.getComponentById(t)) == null ? void 0 : a.model;
|
|
493
|
+
i && (i.visibility = s);
|
|
494
|
+
},
|
|
495
|
+
moveSection: (e, t, s, c) => {
|
|
496
|
+
var n, a, d, l, u, m;
|
|
497
|
+
if (!o.pages[e])
|
|
498
|
+
throw new Error(`Page ${e} is not exists`);
|
|
499
|
+
if (c && c !== t) {
|
|
500
|
+
const C = (n = S.currentPageModel) == null ? void 0 : n.getComponentById(t), p = (a = S.currentPageModel) == null ? void 0 : a.getComponentById(c), g = C == null ? void 0 : C.parent, P = p == null ? void 0 : p.parent;
|
|
501
|
+
P && g && ((d = P == null ? void 0 : P.model) == null ? void 0 : d.id) === ((l = g == null ? void 0 : g.model) == null ? void 0 : l.id) ? r.doc.transact(() => {
|
|
502
|
+
g.model.sectionIds.splice(C.getIndex(), 1), g.model.sectionIds.splice(p.getIndex(), 0, t);
|
|
503
|
+
}) : P && g && ((u = P == null ? void 0 : P.model) == null ? void 0 : u.id) !== ((m = g == null ? void 0 : g.model) == null ? void 0 : m.id) && r.doc.transact(() => {
|
|
504
|
+
P.model.sections[t] = JSON.parse(JSON.stringify(C.model)), P.model.sectionIds.splice(p.getIndex(), 0, t), g.model.sectionIds.splice(C.getIndex(), 1), delete g.model.sections[t];
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
},
|
|
508
|
+
copySection: (e, t) => {
|
|
509
|
+
var l, u, m;
|
|
510
|
+
if (!o.pages[e])
|
|
511
|
+
throw new Error(`Page ${e} is not exists`);
|
|
512
|
+
const c = (l = S.currentPageModel) == null ? void 0 : l.getComponentById(t);
|
|
513
|
+
if (!(c != null && c.model))
|
|
514
|
+
throw new Error(`Section ${t} is not exists`);
|
|
515
|
+
const i = JSON.parse(JSON.stringify(c.model)), n = Ee(i), a = n.id, d = c == null ? void 0 : c.parent;
|
|
516
|
+
return d && (d.model.sections[a] = n, d.model.sectionIds.push(a), v.setCurrentSectionId(e, a), (m = (u = S.currentPage) == null ? void 0 : u.dataSource) != null && m[t] && (S.currentPage.dataSource[a] = JSON.parse(
|
|
517
|
+
JSON.stringify(S.currentPage.dataSource[t])
|
|
518
|
+
))), n;
|
|
519
|
+
},
|
|
520
|
+
addDataSource: (e) => {
|
|
521
|
+
const t = e.id ?? M(), s = {
|
|
522
|
+
...e ?? {},
|
|
523
|
+
id: t,
|
|
524
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
525
|
+
};
|
|
526
|
+
return r.doc.transact(() => {
|
|
527
|
+
o.dataSourceIds ?? (o.dataSourceIds = []), o.dataSources ?? (o.dataSources = {}), o.dataSourceIds.push(t), o.dataSources[t] = s;
|
|
528
|
+
}), o.dataSources[t];
|
|
529
|
+
},
|
|
530
|
+
deleteDataSource: (e) => {
|
|
531
|
+
const t = o.dataSourceIds.indexOf(e);
|
|
532
|
+
t !== -1 && r.doc.transact(() => {
|
|
533
|
+
o.dataSourceIds.splice(t, 1), delete o.dataSources[e];
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
}),
|
|
537
|
+
[o, r.doc, S]
|
|
538
|
+
);
|
|
539
|
+
return {
|
|
540
|
+
...r,
|
|
541
|
+
state: o,
|
|
542
|
+
actions: L,
|
|
543
|
+
localActions: v,
|
|
544
|
+
...S
|
|
545
|
+
};
|
|
546
|
+
}, W = () => {
|
|
547
|
+
const { projectId: r } = le();
|
|
548
|
+
return r ?? pe() ?? "";
|
|
549
|
+
}, ot = () => window.__PROJECT_SLUG__ ?? "";
|
|
550
|
+
function be(r) {
|
|
551
|
+
var h, E;
|
|
552
|
+
const { resources: o } = r;
|
|
553
|
+
if (!o.components)
|
|
554
|
+
return {};
|
|
555
|
+
const f = {};
|
|
556
|
+
return (E = (h = window == null ? void 0 : window.blocklet) == null ? void 0 : h.componentMountPoints) == null || E.forEach((b) => {
|
|
557
|
+
f[b.did] = b;
|
|
558
|
+
}), Object.fromEntries(
|
|
559
|
+
Object.entries(o.components).map(([b, { blockletId: S, component: v }]) => {
|
|
560
|
+
var L;
|
|
561
|
+
return [
|
|
562
|
+
b,
|
|
563
|
+
{ data: v, blockletId: S, blockletTitle: ((L = f[S]) == null ? void 0 : L.title) || S }
|
|
564
|
+
];
|
|
565
|
+
})
|
|
566
|
+
);
|
|
567
|
+
}
|
|
568
|
+
function Oe(r) {
|
|
569
|
+
const { components: o } = r;
|
|
570
|
+
return o || {};
|
|
571
|
+
}
|
|
572
|
+
function je(r) {
|
|
573
|
+
return {
|
|
574
|
+
...be(r),
|
|
575
|
+
...Oe(r)
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
const nt = () => je(Ce().state);
|
|
579
|
+
function Ee(r) {
|
|
580
|
+
const o = JSON.parse(JSON.stringify(r)), f = M();
|
|
581
|
+
return {
|
|
582
|
+
...o,
|
|
583
|
+
id: f
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
export {
|
|
587
|
+
He as E,
|
|
588
|
+
tt as S,
|
|
589
|
+
Ye as a,
|
|
590
|
+
Ce as b,
|
|
591
|
+
Qe as c,
|
|
592
|
+
je as d,
|
|
593
|
+
ot as e,
|
|
594
|
+
et as f,
|
|
595
|
+
Ze as g,
|
|
596
|
+
nt as h,
|
|
597
|
+
F as i,
|
|
598
|
+
qe as j,
|
|
599
|
+
Oe as k,
|
|
600
|
+
be as l,
|
|
601
|
+
pe as m,
|
|
602
|
+
M as n,
|
|
603
|
+
Xe as t,
|
|
604
|
+
W as u
|
|
605
|
+
};
|
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-DEduMTrY.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-C02ZI8vz.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";
|
|
@@ -21,8 +21,8 @@ import "react-helmet";
|
|
|
21
21
|
import "react-router-dom";
|
|
22
22
|
import "react-use";
|
|
23
23
|
import "ufo";
|
|
24
|
-
import "./chunks/array-
|
|
25
|
-
import { a as R, P as S, d as W, c as j, b as k, T as q, H as v } from "./chunks/home-
|
|
24
|
+
import "./chunks/array-NLDZzhVt.js";
|
|
25
|
+
import { a as R, P as S, d as W, c as j, b as k, T as q, H as v } from "./chunks/home-CxRa0eKd.js";
|
|
26
26
|
import "./chunks/session-CVblGhSp.js";
|
|
27
27
|
export {
|
|
28
28
|
R as HomeView,
|