@blocklet/pages-kit-inner-components 0.5.34 → 0.5.36
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 +2 -2
- package/lib/cjs/chunks/{array-DxhrK2d5.js → array-Ck0L_JhL.js} +1 -1
- package/lib/cjs/chunks/{config-string-DqWgB7yO.js → config-string-CaLe_baf.js} +1 -1
- package/lib/cjs/chunks/{draft-data-DzN2u_NT.js → draft-data-CY1N7Ozn.js} +1 -1
- package/lib/cjs/chunks/{home-0fezWT4S.js → home-CjWVwLEf.js} +3 -3
- package/lib/cjs/chunks/{publish-button-D2jaaXXn.js → publish-button-BDrUGRX4.js} +1 -1
- package/lib/cjs/chunks/site-state-CIPfhJn5.js +57 -0
- package/lib/cjs/chunks/state-D4QeRw7n.js +1 -0
- package/lib/cjs/components.js +1 -1
- package/lib/cjs/home.js +1 -1
- package/lib/cjs/project-html.js +1 -1
- package/lib/cjs/resources.js +1 -1
- package/lib/cjs/setting.js +2 -2
- package/lib/cjs/site-state.js +1 -1
- package/lib/es/add-component.js +4 -4
- package/lib/es/chunks/{array-D6qyZucY.js → array-HCA75FfO.js} +1 -1
- package/lib/es/chunks/{config-string-Btybe5Rd.js → config-string-17RNX8vu.js} +1 -1
- package/lib/es/chunks/{draft-data-DQ7_JyJX.js → draft-data-CyeVe0kA.js} +1 -1
- package/lib/es/chunks/{home-Dox9JwvF.js → home-COrN_x32.js} +4 -4
- package/lib/es/chunks/{publish-button-T2YJBoty.js → publish-button-WmGjhj6q.js} +3 -3
- package/lib/es/chunks/site-state-CfrteYXm.js +2137 -0
- package/lib/es/chunks/{state-NhsHvaKm.js → state-Br2xp7Mf.js} +179 -175
- package/lib/es/components.js +1 -1
- package/lib/es/home.js +3 -3
- package/lib/es/project-html.js +1 -1
- package/lib/es/resources.js +1 -1
- package/lib/es/setting.js +541 -534
- package/lib/es/site-state.js +1 -1
- package/package.json +3 -3
- package/lib/cjs/chunks/site-state-D00xEf4T.js +0 -57
- package/lib/cjs/chunks/state-DoGBMTzI.js +0 -1
- package/lib/es/chunks/site-state-nXcBqjeR.js +0 -2076
|
@@ -19,61 +19,61 @@ import { IndexeddbPersistence as me } from "y-indexeddb";
|
|
|
19
19
|
import { WebsocketProvider as fe } from "y-websocket";
|
|
20
20
|
import { UndoManager as Se } from "yjs";
|
|
21
21
|
import "@blocklet/pages-kit/types";
|
|
22
|
-
const qe = (
|
|
23
|
-
const
|
|
24
|
-
return
|
|
22
|
+
const qe = (s) => {
|
|
23
|
+
const n = blocklet == null ? void 0 : blocklet.componentMountPoints.find((f) => f.name === s);
|
|
24
|
+
return n ? n.mountPoint : "/";
|
|
25
25
|
};
|
|
26
26
|
function pe() {
|
|
27
|
-
const { pathname:
|
|
27
|
+
const { pathname: s } = window.location, n = s.match(/\/admin\/(maker|previewer)\/([^/]+)/), f = n == null ? void 0 : n[2], h = window.__PROJECT_ID__;
|
|
28
28
|
if (!f && !h)
|
|
29
29
|
throw new Error("Unable to get projectId from pathname");
|
|
30
30
|
return f || h;
|
|
31
31
|
}
|
|
32
|
-
function Qe(
|
|
33
|
-
return `${
|
|
32
|
+
function Qe(s) {
|
|
33
|
+
return `${s}:pages:version`;
|
|
34
34
|
}
|
|
35
|
-
function Xe(
|
|
36
|
-
return
|
|
35
|
+
function Xe(s, n) {
|
|
36
|
+
return n === "yaml" ? X(s) ? "" : H.stringify(s, { indent: 2 }) : n === "json" ? JSON.parse(JSON.stringify(s || {})) : n === "array" ? JSON.parse(JSON.stringify(s || [])) : s;
|
|
37
37
|
}
|
|
38
|
-
function He({ error:
|
|
39
|
-
return /* @__PURE__ */ T(V, { children: /* @__PURE__ */ T(z, { severity: "error", children:
|
|
38
|
+
function He({ error: s }) {
|
|
39
|
+
return /* @__PURE__ */ T(V, { children: /* @__PURE__ */ T(z, { severity: "error", children: s.message }) });
|
|
40
40
|
}
|
|
41
41
|
var G;
|
|
42
42
|
const J = ((G = window.blocklet) == null ? void 0 : G.prefix) || "/", F = Q({
|
|
43
43
|
timeout: 200 * 1e3
|
|
44
|
-
}), ge = window.location.protocol === "https:" ? "wss" : "ws", Ye = (
|
|
44
|
+
}), ge = window.location.protocol === "https:" ? "wss" : "ws", Ye = (s) => _(`${ge}://${window.location.hostname}`, J, `api/${s}/ws/pages`), Pe = "z8ia1mAXo8ZE7ytGF36L5uBf9kD2kenhqFGp9";
|
|
45
45
|
var B;
|
|
46
|
-
(B = blocklet == null ? void 0 : blocklet.componentMountPoints.find((
|
|
47
|
-
function Ze(
|
|
48
|
-
return
|
|
46
|
+
(B = blocklet == null ? void 0 : blocklet.componentMountPoints.find((s) => s.did === Pe)) != null && B.mountPoint || _(J, "/image-bin");
|
|
47
|
+
function Ze(s) {
|
|
48
|
+
return s && !/^(https?:\/\/|\/)/.test(s) ? window.location.origin + _(J, "uploads", s) : s;
|
|
49
49
|
}
|
|
50
50
|
const we = window.innerWidth <= 750;
|
|
51
|
-
function et(
|
|
52
|
-
if (!
|
|
53
|
-
const h = (we ?
|
|
54
|
-
return Ie(
|
|
51
|
+
function et(s, n, f) {
|
|
52
|
+
if (!s || /\.gif/.test(s)) return s;
|
|
53
|
+
const h = (we ? n / 1.5 : n) * (f === "quality" ? 1.5 : 1);
|
|
54
|
+
return Ie(s, { imageFilter: "resize", w: h, f: "webp" });
|
|
55
55
|
}
|
|
56
|
-
function Ie(
|
|
57
|
-
return !
|
|
56
|
+
function Ie(s, n) {
|
|
57
|
+
return !s || !n ? s : q(s, n);
|
|
58
58
|
}
|
|
59
|
-
async function ye(
|
|
60
|
-
return F.get(`/api/projects/${
|
|
59
|
+
async function ye(s) {
|
|
60
|
+
return F.get(`/api/projects/${s}`).then((n) => n.data);
|
|
61
61
|
}
|
|
62
|
-
async function he(
|
|
63
|
-
return F.post(`/api/projects/${
|
|
62
|
+
async function he(s) {
|
|
63
|
+
return F.post(`/api/projects/${s.id}/update`, s).then((n) => n.data);
|
|
64
64
|
}
|
|
65
65
|
const ve = 500, A = ce("abcdefghijklmnopqrstuvwxyz0123456789", 16), W = ie(null);
|
|
66
66
|
function tt({
|
|
67
|
-
url:
|
|
68
|
-
name:
|
|
67
|
+
url: s,
|
|
68
|
+
name: n,
|
|
69
69
|
children: f,
|
|
70
70
|
waitingSynced: h
|
|
71
71
|
}) {
|
|
72
|
-
const [L, O] = R(!1), { locale: S } = Y(), v = N(), k = `${v}:MakerLocalState`, e = `${v}:${
|
|
72
|
+
const [L, O] = R(!1), { locale: S } = Y(), v = N(), k = `${v}:MakerLocalState`, e = `${v}:${n}`, [t, c] = re(k, {
|
|
73
73
|
defaultValue: {},
|
|
74
74
|
listenStorageChange: !0
|
|
75
|
-
}),
|
|
76
|
-
|
|
75
|
+
}), r = ae(t);
|
|
76
|
+
r.current = t;
|
|
77
77
|
const i = E(
|
|
78
78
|
() => te({
|
|
79
79
|
dataSourceIds: [],
|
|
@@ -88,31 +88,31 @@ function tt({
|
|
|
88
88
|
resources: {}
|
|
89
89
|
}),
|
|
90
90
|
[]
|
|
91
|
-
),
|
|
92
|
-
E(() => new me(e,
|
|
91
|
+
), o = E(() => oe(i), [i]);
|
|
92
|
+
E(() => new me(e, o), [e, o]);
|
|
93
93
|
const a = E(
|
|
94
|
-
() => new fe(
|
|
94
|
+
() => new fe(s, e, o, {
|
|
95
95
|
params: {},
|
|
96
96
|
resyncInterval: 5 * 60 * 1e3
|
|
97
97
|
}),
|
|
98
|
-
[
|
|
98
|
+
[s, e, o]
|
|
99
99
|
), d = $(() => {
|
|
100
100
|
a && (a.disconnect(), a.connect());
|
|
101
101
|
}, [a]), l = E(
|
|
102
102
|
() => new Se(
|
|
103
103
|
[
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
104
|
+
o.getArray("pageIds"),
|
|
105
|
+
o.getMap("pages"),
|
|
106
|
+
o.getArray("supportedLocales"),
|
|
107
|
+
o.getMap("config"),
|
|
108
|
+
o.getMap("dataSources"),
|
|
109
|
+
o.getArray("dataSourceIds"),
|
|
110
|
+
o.getArray("routeIds"),
|
|
111
|
+
o.getMap("routes")
|
|
112
112
|
],
|
|
113
|
-
{ doc:
|
|
113
|
+
{ doc: o }
|
|
114
114
|
),
|
|
115
|
-
[
|
|
115
|
+
[o]
|
|
116
116
|
), [u, m] = R(null), [x, P] = R(!1), [w, C] = R(void 0), p = $(async () => {
|
|
117
117
|
if (v) {
|
|
118
118
|
P(!0);
|
|
@@ -150,7 +150,7 @@ function tt({
|
|
|
150
150
|
}, [v, p]);
|
|
151
151
|
const K = E(
|
|
152
152
|
() => ({
|
|
153
|
-
doc:
|
|
153
|
+
doc: o,
|
|
154
154
|
state: i,
|
|
155
155
|
localState: {
|
|
156
156
|
...t,
|
|
@@ -169,7 +169,7 @@ function tt({
|
|
|
169
169
|
}),
|
|
170
170
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
171
171
|
[
|
|
172
|
-
|
|
172
|
+
o,
|
|
173
173
|
i,
|
|
174
174
|
JSON.stringify(t),
|
|
175
175
|
// resolve the problem of react warning
|
|
@@ -185,7 +185,7 @@ function tt({
|
|
|
185
185
|
);
|
|
186
186
|
return D(() => {
|
|
187
187
|
l.on("stack-item-added", ({ stackItem: g }) => {
|
|
188
|
-
const { currentPageId: I, currentLocale: j, pages: y } =
|
|
188
|
+
const { currentPageId: I, currentLocale: j, pages: y } = r.current;
|
|
189
189
|
g.meta.set("localState", { currentPageId: I, currentLocale: j, pages: y });
|
|
190
190
|
}), l.on("stack-item-popped", ({ stackItem: g }) => {
|
|
191
191
|
const I = g.meta.get("localState");
|
|
@@ -214,86 +214,86 @@ function tt({
|
|
|
214
214
|
}, [a, c]), h && !L ? null : /* @__PURE__ */ T(W.Provider, { value: K, children: f });
|
|
215
215
|
}
|
|
216
216
|
const Ce = () => {
|
|
217
|
-
const
|
|
218
|
-
if (!
|
|
217
|
+
const s = de(W);
|
|
218
|
+
if (!s)
|
|
219
219
|
throw new Error("Context is null");
|
|
220
|
-
const
|
|
220
|
+
const n = ne(s.state), { setLocalState: f, localState: h } = s, L = ue(), O = N(), S = E(
|
|
221
221
|
() => ({
|
|
222
222
|
get currentPage() {
|
|
223
223
|
const {
|
|
224
224
|
localState: { currentPageId: e }
|
|
225
|
-
} =
|
|
226
|
-
return e ?
|
|
225
|
+
} = s;
|
|
226
|
+
return e ? n.pages[e] : void 0;
|
|
227
227
|
},
|
|
228
228
|
get currentSection() {
|
|
229
|
-
var
|
|
229
|
+
var r, i, o, a, d;
|
|
230
230
|
const {
|
|
231
231
|
localState: { currentPageId: e, ...t }
|
|
232
|
-
} =
|
|
232
|
+
} = s;
|
|
233
233
|
if (!e)
|
|
234
234
|
return;
|
|
235
|
-
const c = (i = (
|
|
235
|
+
const c = (i = (r = t.pages) == null ? void 0 : r[e]) == null ? void 0 : i.currentSectionId;
|
|
236
236
|
if (c)
|
|
237
|
-
return ((
|
|
237
|
+
return ((o = n.pages[e]) == null ? void 0 : o.sections[c]) ?? ((d = (a = this.currentPageModel) == null ? void 0 : a.getComponentById(c)) == null ? void 0 : d.model);
|
|
238
238
|
},
|
|
239
239
|
get currentSectionProperties() {
|
|
240
|
-
var
|
|
240
|
+
var o, a, d, l;
|
|
241
241
|
const {
|
|
242
242
|
localState: { currentPageId: e, ...t }
|
|
243
|
-
} =
|
|
243
|
+
} = s;
|
|
244
244
|
if (!e)
|
|
245
245
|
return;
|
|
246
|
-
const c = (a = (
|
|
246
|
+
const c = (a = (o = t.pages) == null ? void 0 : o[e]) == null ? void 0 : a.currentSectionId;
|
|
247
247
|
if (!c)
|
|
248
248
|
return;
|
|
249
|
-
const
|
|
250
|
-
if (!
|
|
249
|
+
const r = (l = (d = n.pages[e]) == null ? void 0 : d.dataSource) == null ? void 0 : l[c];
|
|
250
|
+
if (!r)
|
|
251
251
|
return;
|
|
252
252
|
const { currentLocale: i } = this.currentLocaleMap;
|
|
253
|
-
return i ?
|
|
253
|
+
return i ? r[i] : void 0;
|
|
254
254
|
},
|
|
255
255
|
get currentSectionPropertiesWithFallback() {
|
|
256
256
|
var d, l, u, m;
|
|
257
257
|
const {
|
|
258
258
|
localState: { currentPageId: e, ...t }
|
|
259
|
-
} =
|
|
259
|
+
} = s;
|
|
260
260
|
if (!e)
|
|
261
261
|
return;
|
|
262
262
|
const c = (l = (d = t.pages) == null ? void 0 : d[e]) == null ? void 0 : l.currentSectionId;
|
|
263
263
|
if (!c)
|
|
264
264
|
return;
|
|
265
|
-
const
|
|
266
|
-
if (!
|
|
265
|
+
const r = (m = (u = n.pages[e]) == null ? void 0 : u.dataSource) == null ? void 0 : m[c];
|
|
266
|
+
if (!r)
|
|
267
267
|
return;
|
|
268
|
-
const { currentLocale: i, defaultLocale:
|
|
269
|
-
if (i &&
|
|
270
|
-
return
|
|
271
|
-
if (
|
|
272
|
-
return
|
|
273
|
-
if (a &&
|
|
274
|
-
return
|
|
268
|
+
const { currentLocale: i, defaultLocale: o, fallbackLocale: a } = this.currentLocaleMap;
|
|
269
|
+
if (i && r[i])
|
|
270
|
+
return r[i];
|
|
271
|
+
if (o && r[o])
|
|
272
|
+
return r[o];
|
|
273
|
+
if (a && r[a])
|
|
274
|
+
return r[a];
|
|
275
275
|
},
|
|
276
276
|
get currentLocaleMap() {
|
|
277
|
-
var
|
|
277
|
+
var r;
|
|
278
278
|
const {
|
|
279
279
|
localState: { currentLocale: e },
|
|
280
280
|
state: {
|
|
281
281
|
supportedLocales: t,
|
|
282
282
|
config: { defaultLocale: c }
|
|
283
283
|
}
|
|
284
|
-
} =
|
|
284
|
+
} = s;
|
|
285
285
|
return {
|
|
286
286
|
currentLocale: e,
|
|
287
287
|
defaultLocale: c,
|
|
288
|
-
fallbackLocale: ((
|
|
288
|
+
fallbackLocale: ((r = t == null ? void 0 : t[0]) == null ? void 0 : r.locale) ?? "en"
|
|
289
289
|
};
|
|
290
290
|
},
|
|
291
291
|
get currentRoute() {
|
|
292
292
|
var t;
|
|
293
293
|
const {
|
|
294
294
|
localState: { currentRouteId: e }
|
|
295
|
-
} =
|
|
296
|
-
return e ? (t =
|
|
295
|
+
} = s;
|
|
296
|
+
return e ? (t = n.routes) == null ? void 0 : t[e] : void 0;
|
|
297
297
|
},
|
|
298
298
|
get currentPageModel() {
|
|
299
299
|
const e = this.currentPage ?? null;
|
|
@@ -306,45 +306,49 @@ const Ce = () => {
|
|
|
306
306
|
}
|
|
307
307
|
}
|
|
308
308
|
}),
|
|
309
|
-
[JSON.stringify(h),
|
|
309
|
+
[JSON.stringify(h), n]
|
|
310
310
|
), v = E(
|
|
311
311
|
() => ({
|
|
312
312
|
setCurrentSectionId: (e, t) => {
|
|
313
|
-
var c,
|
|
314
|
-
e === h.currentPageId && t === ((
|
|
315
|
-
(i) => M(i, (
|
|
313
|
+
var c, r;
|
|
314
|
+
e === h.currentPageId && t === ((r = (c = h.pages) == null ? void 0 : c[e]) == null ? void 0 : r.currentSectionId) || (L(_("/admin/maker", O ?? "", "pages", e)), f(
|
|
315
|
+
(i) => M(i, (o) => {
|
|
316
316
|
var a;
|
|
317
|
-
|
|
317
|
+
o.currentPageId = e, o.currentComponentId = void 0, t !== void 0 && (o.pages ?? (o.pages = {}), (a = o.pages)[e] ?? (a[e] = {}), o.pages[e].currentSectionId = t ?? void 0), t ? window.sessionStorage.setItem("iframe_show_id", `"${t}"`) : window.sessionStorage.removeItem("iframe_show_id");
|
|
318
318
|
})
|
|
319
319
|
));
|
|
320
320
|
},
|
|
321
321
|
setCurrentComponentId: (e) => {
|
|
322
322
|
e !== h.currentComponentId && (L(_("/admin/maker", O ?? "", "components", e)), f(
|
|
323
323
|
(t) => M(t, (c) => {
|
|
324
|
-
c.currentComponentId = e
|
|
324
|
+
c.currentComponentId = e;
|
|
325
325
|
})
|
|
326
326
|
));
|
|
327
327
|
},
|
|
328
328
|
setCurrentRouteId: ({ routeId: e, dynamicParams: t }) => {
|
|
329
329
|
f(
|
|
330
|
-
(c) => M(c, (
|
|
331
|
-
|
|
330
|
+
(c) => M(c, (r) => {
|
|
331
|
+
r.currentRouteId = e, r.currentDynamicParams = t;
|
|
332
332
|
})
|
|
333
333
|
);
|
|
334
334
|
},
|
|
335
|
+
// 本地缓存组件调试参数,避免用户切换组件后,需要重新输入
|
|
335
336
|
setCustomComponentPreviewerProperties: (() => {
|
|
336
|
-
const e = {}
|
|
337
|
+
const e = {};
|
|
338
|
+
let t = "";
|
|
339
|
+
const c = U(() => {
|
|
337
340
|
f(
|
|
338
|
-
(
|
|
339
|
-
|
|
340
|
-
...
|
|
341
|
-
...e
|
|
342
|
-
},
|
|
341
|
+
(r) => M(r, (i) => {
|
|
342
|
+
i.customComponentPreviewerProperties ?? (i.customComponentPreviewerProperties = {}), i.customComponentPreviewerProperties[t] = {
|
|
343
|
+
...i.customComponentPreviewerProperties[t],
|
|
344
|
+
...e[t]
|
|
345
|
+
}, delete e[t];
|
|
343
346
|
})
|
|
344
347
|
);
|
|
345
348
|
}, 5);
|
|
346
|
-
return (
|
|
347
|
-
|
|
349
|
+
return (r, i) => {
|
|
350
|
+
const o = e[r] ?? {};
|
|
351
|
+
Object.assign(o, i), e[r] = o, t = r, c();
|
|
348
352
|
};
|
|
349
353
|
})(),
|
|
350
354
|
setRouteGenerateProcess: (e) => {
|
|
@@ -371,8 +375,8 @@ const Ce = () => {
|
|
|
371
375
|
), k = E(
|
|
372
376
|
() => ({
|
|
373
377
|
addPage: (e, t) => {
|
|
374
|
-
var i,
|
|
375
|
-
const c = (e == null ? void 0 : e.id) ?? A(),
|
|
378
|
+
var i, o, a, d, l, u;
|
|
379
|
+
const c = (e == null ? void 0 : e.id) ?? A(), r = {
|
|
376
380
|
...e,
|
|
377
381
|
id: c,
|
|
378
382
|
createdAt: (e == null ? void 0 : e.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -384,19 +388,19 @@ const Ce = () => {
|
|
|
384
388
|
isPublic: (e == null ? void 0 : e.isPublic) ?? !0,
|
|
385
389
|
templateConfig: (e == null ? void 0 : e.templateConfig) ?? {
|
|
386
390
|
isTemplate: ((i = e == null ? void 0 : e.templateConfig) == null ? void 0 : i.isTemplate) ?? !0,
|
|
387
|
-
displayTemplateId: ((
|
|
391
|
+
displayTemplateId: ((o = e == null ? void 0 : e.templateConfig) == null ? void 0 : o.displayTemplateId) ?? void 0,
|
|
388
392
|
dataSourceIds: ((a = e == null ? void 0 : e.templateConfig) == null ? void 0 : a.dataSourceIds) ?? void 0,
|
|
389
393
|
dataSourceParameters: ((d = e == null ? void 0 : e.templateConfig) == null ? void 0 : d.dataSourceParameters) ?? {},
|
|
390
394
|
enabledGenerate: ((l = e == null ? void 0 : e.templateConfig) == null ? void 0 : l.enabledGenerate) ?? !1,
|
|
391
395
|
agentId: ((u = e == null ? void 0 : e.templateConfig) == null ? void 0 : u.agentId) ?? void 0
|
|
392
396
|
}
|
|
393
397
|
};
|
|
394
|
-
return
|
|
395
|
-
|
|
396
|
-
}),
|
|
398
|
+
return s.doc.transact(() => {
|
|
399
|
+
n.pages[r.id] = r, n.pageIds.splice(t ?? n.pageIds.length, 0, r.id);
|
|
400
|
+
}), r;
|
|
397
401
|
},
|
|
398
402
|
addRoute: (e, t) => {
|
|
399
|
-
const c = (e == null ? void 0 : e.id) ?? A(),
|
|
403
|
+
const c = (e == null ? void 0 : e.id) ?? A(), r = {
|
|
400
404
|
...e,
|
|
401
405
|
id: c,
|
|
402
406
|
createdAt: (e == null ? void 0 : e.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -410,68 +414,68 @@ const Ce = () => {
|
|
|
410
414
|
displayTemplateId: (e == null ? void 0 : e.displayTemplateId) ?? void 0,
|
|
411
415
|
dataSource: (e == null ? void 0 : e.dataSource) ?? {}
|
|
412
416
|
};
|
|
413
|
-
return
|
|
414
|
-
|
|
415
|
-
}),
|
|
417
|
+
return s.doc.transact(() => {
|
|
418
|
+
n.routes ?? (n.routes = {}), n.routeIds ?? (n.routeIds = []), n.routes[r.id] = r, n.routeIds.splice(t ?? n.routeIds.length, 0, r.id);
|
|
419
|
+
}), r;
|
|
416
420
|
},
|
|
417
421
|
deleteRoute: (e) => {
|
|
418
422
|
var c;
|
|
419
423
|
if (!e)
|
|
420
424
|
return;
|
|
421
|
-
const t = (c =
|
|
422
|
-
t !== void 0 && t !== -1 &&
|
|
423
|
-
var
|
|
424
|
-
(
|
|
425
|
+
const t = (c = n.routeIds) == null ? void 0 : c.indexOf(e);
|
|
426
|
+
t !== void 0 && t !== -1 && s.doc.transact(() => {
|
|
427
|
+
var r, i;
|
|
428
|
+
(r = n.routeIds) == null || r.splice(t, 1), (i = n.routes) == null || delete i[e];
|
|
425
429
|
});
|
|
426
430
|
},
|
|
427
431
|
deletePage: (e) => {
|
|
428
|
-
const t =
|
|
429
|
-
t !== -1 &&
|
|
430
|
-
|
|
432
|
+
const t = n.pageIds.indexOf(e);
|
|
433
|
+
t !== -1 && s.doc.transact(() => {
|
|
434
|
+
n.pageIds.splice(t, 1), delete n.pages[e];
|
|
431
435
|
});
|
|
432
436
|
},
|
|
433
437
|
movePage: (e, t) => {
|
|
434
|
-
const { pageIds: c } =
|
|
435
|
-
|
|
438
|
+
const { pageIds: c } = n, r = c.indexOf(e);
|
|
439
|
+
r >= 0 && c.splice(t, 0, ...c.splice(r, 1));
|
|
436
440
|
},
|
|
437
|
-
addSection: (e, t, c,
|
|
438
|
-
const i =
|
|
441
|
+
addSection: (e, t, c, r) => {
|
|
442
|
+
const i = n.pages[e];
|
|
439
443
|
if (!i)
|
|
440
444
|
throw new Error(`Page ${e} is not exists`);
|
|
441
|
-
const
|
|
445
|
+
const o = {
|
|
442
446
|
...t,
|
|
443
447
|
id: t.id ?? A(),
|
|
444
448
|
isTemplateSection: t.isTemplateSection ?? !0,
|
|
445
449
|
llmConfig: t.llmConfig ?? {}
|
|
446
|
-
}, a = se(
|
|
447
|
-
return delete
|
|
450
|
+
}, a = se(o.locales);
|
|
451
|
+
return delete o.locales, s.doc.transact(() => {
|
|
448
452
|
var d, l, u;
|
|
449
|
-
if (
|
|
450
|
-
const m = (d = S.currentPageModel) == null ? void 0 : d.getComponentById(
|
|
451
|
-
m && ((l = m.model).sections ?? (l.sections = {}), m.model.sections[
|
|
453
|
+
if (r && r.component === "layout-block") {
|
|
454
|
+
const m = (d = S.currentPageModel) == null ? void 0 : d.getComponentById(r.id);
|
|
455
|
+
m && ((l = m.model).sections ?? (l.sections = {}), m.model.sections[o.id] = o, (u = m.model).sectionIds ?? (u.sectionIds = []), m.model.sectionIds.push(o.id));
|
|
452
456
|
} else
|
|
453
|
-
i.sections[
|
|
454
|
-
a && (i.dataSource ?? (i.dataSource = {}), i.dataSource[
|
|
455
|
-
}),
|
|
457
|
+
i.sections[o.id] = o, i.sectionIds.splice(c ?? i.sectionIds.length, 0, o.id);
|
|
458
|
+
a && (i.dataSource ?? (i.dataSource = {}), i.dataSource[o.id] = a);
|
|
459
|
+
}), o;
|
|
456
460
|
},
|
|
457
461
|
deleteSection: (e, t) => {
|
|
458
|
-
const c =
|
|
462
|
+
const c = n.pages[e];
|
|
459
463
|
if (!c)
|
|
460
464
|
throw new Error(`Page ${e} is not exists`);
|
|
461
|
-
|
|
465
|
+
s.doc.transact(() => {
|
|
462
466
|
var a, d, l, u, m, x;
|
|
463
|
-
const
|
|
464
|
-
if (i && (
|
|
465
|
-
const P = (d =
|
|
466
|
-
P !== void 0 && P !== -1 && ((l =
|
|
467
|
+
const r = [], i = (a = S.currentPageModel) == null ? void 0 : a.getComponentById(t), o = i == null ? void 0 : i.parent;
|
|
468
|
+
if (i && (r.push(i.model.id, ...i.all().map((P) => P.model.id)), (o == null ? void 0 : o.model.component) === "layout-block")) {
|
|
469
|
+
const P = (d = o.model.sectionIds) == null ? void 0 : d.indexOf(t);
|
|
470
|
+
P !== void 0 && P !== -1 && ((l = o.model.sectionIds) == null || l.splice(P, 1), (u = o.model.sections) == null || delete u[t]), (m = o.model.config) != null && m.gridSettings && Object.keys(o.model.config.gridSettings).forEach((w) => {
|
|
467
471
|
var C;
|
|
468
472
|
try {
|
|
469
|
-
(C =
|
|
473
|
+
(C = o.model.config.gridSettings[w]) == null || delete C[t];
|
|
470
474
|
} catch {
|
|
471
475
|
}
|
|
472
|
-
}), ((x =
|
|
476
|
+
}), ((x = o.model.config) == null ? void 0 : x.backgroundSectionId) === t && (o.model.config.backgroundSectionId = void 0);
|
|
473
477
|
}
|
|
474
|
-
|
|
478
|
+
r.forEach((P) => {
|
|
475
479
|
var C, p;
|
|
476
480
|
const w = c.sectionIds.indexOf(P);
|
|
477
481
|
w !== -1 && c.sectionIds.splice(w, 1), c.sections[P] && delete c.sections[P], (C = c.dataSource) != null && C[P] && ((p = c.dataSource) == null || delete p[P]);
|
|
@@ -479,43 +483,43 @@ const Ce = () => {
|
|
|
479
483
|
});
|
|
480
484
|
},
|
|
481
485
|
lockSection: (e, t) => {
|
|
482
|
-
var i,
|
|
483
|
-
if (!
|
|
486
|
+
var i, o;
|
|
487
|
+
if (!n.pages[e])
|
|
484
488
|
throw new Error(`Page ${e} is not exists`);
|
|
485
|
-
const
|
|
486
|
-
|
|
489
|
+
const r = (o = (i = S.currentPageModel) == null ? void 0 : i.getComponentById(t)) == null ? void 0 : o.model;
|
|
490
|
+
r && (r.locked = !r.locked);
|
|
487
491
|
},
|
|
488
492
|
toggleSectionVisibility: (e, t, c) => {
|
|
489
|
-
var
|
|
490
|
-
if (!
|
|
493
|
+
var o, a;
|
|
494
|
+
if (!n.pages[e])
|
|
491
495
|
throw new Error(`Page ${e} is not exists`);
|
|
492
|
-
const i = (a = (
|
|
496
|
+
const i = (a = (o = S.currentPageModel) == null ? void 0 : o.getComponentById(t)) == null ? void 0 : a.model;
|
|
493
497
|
i && (i.visibility = c);
|
|
494
498
|
},
|
|
495
|
-
moveSection: (e, t, c,
|
|
496
|
-
var
|
|
497
|
-
if (!
|
|
499
|
+
moveSection: (e, t, c, r) => {
|
|
500
|
+
var o, a, d, l, u, m, x, P;
|
|
501
|
+
if (!n.pages[e])
|
|
498
502
|
throw new Error(`Page ${e} is not exists`);
|
|
499
|
-
if (
|
|
500
|
-
const w = (
|
|
501
|
-
b && p && ((d = b == null ? void 0 : b.model) == null ? void 0 : d.id) === ((l = p == null ? void 0 : p.model) == null ? void 0 : l.id) ?
|
|
503
|
+
if (r && r !== t) {
|
|
504
|
+
const w = (o = S.currentPageModel) == null ? void 0 : o.getComponentById(t), C = (a = S.currentPageModel) == null ? void 0 : a.getComponentById(r), p = w == null ? void 0 : w.parent, b = C == null ? void 0 : C.parent;
|
|
505
|
+
b && p && ((d = b == null ? void 0 : b.model) == null ? void 0 : d.id) === ((l = p == null ? void 0 : p.model) == null ? void 0 : l.id) ? s.doc.transact(() => {
|
|
502
506
|
p.model.sectionIds.splice(w.getIndex(), 1), p.model.sectionIds.splice(C.getIndex(), 0, t);
|
|
503
|
-
}) : b && p && ((u = b == null ? void 0 : b.model) == null ? void 0 : u.id) !== ((m = p == null ? void 0 : p.model) == null ? void 0 : m.id) && t !==
|
|
507
|
+
}) : b && p && ((u = b == null ? void 0 : b.model) == null ? void 0 : u.id) !== ((m = p == null ? void 0 : p.model) == null ? void 0 : m.id) && t !== r && !((P = (x = w == null ? void 0 : w.model) == null ? void 0 : x.sectionIds) != null && P.includes(r)) && s.doc.transact(() => {
|
|
504
508
|
b.model.sections[t] = JSON.parse(JSON.stringify(w.model)), b.model.sectionIds.splice(C.getIndex(), 0, t), p.model.sectionIds.splice(w.getIndex(), 1), delete p.model.sections[t];
|
|
505
509
|
});
|
|
506
510
|
}
|
|
507
511
|
},
|
|
508
512
|
copySection: (e, t) => {
|
|
509
513
|
var l, u, m;
|
|
510
|
-
if (!
|
|
514
|
+
if (!n.pages[e])
|
|
511
515
|
throw new Error(`Page ${e} is not exists`);
|
|
512
|
-
const
|
|
513
|
-
if (!(
|
|
516
|
+
const r = (l = S.currentPageModel) == null ? void 0 : l.getComponentById(t);
|
|
517
|
+
if (!(r != null && r.model))
|
|
514
518
|
throw new Error(`Section ${t} is not exists`);
|
|
515
|
-
const i = JSON.parse(JSON.stringify(
|
|
516
|
-
return d && (d.model.sections[a] =
|
|
519
|
+
const i = JSON.parse(JSON.stringify(r.model)), o = Ee(i), a = o.id, d = r == null ? void 0 : r.parent;
|
|
520
|
+
return d && (d.model.sections[a] = o, 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
521
|
JSON.stringify(S.currentPage.dataSource[t])
|
|
518
|
-
))),
|
|
522
|
+
))), o;
|
|
519
523
|
},
|
|
520
524
|
addDataSource: (e) => {
|
|
521
525
|
const t = e.id ?? A(), c = {
|
|
@@ -523,40 +527,40 @@ const Ce = () => {
|
|
|
523
527
|
id: t,
|
|
524
528
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
525
529
|
};
|
|
526
|
-
return
|
|
527
|
-
|
|
528
|
-
}),
|
|
530
|
+
return s.doc.transact(() => {
|
|
531
|
+
n.dataSourceIds ?? (n.dataSourceIds = []), n.dataSources ?? (n.dataSources = {}), n.dataSourceIds.push(t), n.dataSources[t] = c;
|
|
532
|
+
}), n.dataSources[t];
|
|
529
533
|
},
|
|
530
534
|
deleteDataSource: (e) => {
|
|
531
|
-
const t =
|
|
532
|
-
t !== -1 &&
|
|
533
|
-
|
|
535
|
+
const t = n.dataSourceIds.indexOf(e);
|
|
536
|
+
t !== -1 && s.doc.transact(() => {
|
|
537
|
+
n.dataSourceIds.splice(t, 1), delete n.dataSources[e];
|
|
534
538
|
});
|
|
535
539
|
}
|
|
536
540
|
}),
|
|
537
|
-
[
|
|
541
|
+
[n, s.doc, S]
|
|
538
542
|
);
|
|
539
543
|
return {
|
|
540
|
-
...
|
|
541
|
-
state:
|
|
544
|
+
...s,
|
|
545
|
+
state: n,
|
|
542
546
|
actions: k,
|
|
543
547
|
localActions: v,
|
|
544
548
|
...S
|
|
545
549
|
};
|
|
546
550
|
}, N = () => {
|
|
547
|
-
const { projectId:
|
|
548
|
-
return
|
|
551
|
+
const { projectId: s } = le();
|
|
552
|
+
return s ?? pe() ?? "";
|
|
549
553
|
}, ot = () => window.__PROJECT_SLUG__ ?? "";
|
|
550
|
-
function be(
|
|
554
|
+
function be(s) {
|
|
551
555
|
var h, L;
|
|
552
|
-
const { resources:
|
|
553
|
-
if (!
|
|
556
|
+
const { resources: n } = s;
|
|
557
|
+
if (!n.components)
|
|
554
558
|
return {};
|
|
555
559
|
const f = {};
|
|
556
560
|
return (L = (h = window == null ? void 0 : window.blocklet) == null ? void 0 : h.componentMountPoints) == null || L.forEach((O) => {
|
|
557
561
|
f[O.did] = O;
|
|
558
562
|
}), Object.fromEntries(
|
|
559
|
-
Object.entries(
|
|
563
|
+
Object.entries(n.components).map(([O, { blockletId: S, component: v }]) => {
|
|
560
564
|
var k;
|
|
561
565
|
return [
|
|
562
566
|
O,
|
|
@@ -565,21 +569,21 @@ function be(r) {
|
|
|
565
569
|
})
|
|
566
570
|
);
|
|
567
571
|
}
|
|
568
|
-
function Oe(
|
|
569
|
-
const { components:
|
|
570
|
-
return
|
|
572
|
+
function Oe(s) {
|
|
573
|
+
const { components: n } = s;
|
|
574
|
+
return n || {};
|
|
571
575
|
}
|
|
572
|
-
function je(
|
|
576
|
+
function je(s) {
|
|
573
577
|
return {
|
|
574
|
-
...be(
|
|
575
|
-
...Oe(
|
|
578
|
+
...be(s),
|
|
579
|
+
...Oe(s)
|
|
576
580
|
};
|
|
577
581
|
}
|
|
578
582
|
const nt = () => je(Ce().state);
|
|
579
|
-
function Ee(
|
|
580
|
-
const
|
|
583
|
+
function Ee(s) {
|
|
584
|
+
const n = JSON.parse(JSON.stringify(s)), f = A();
|
|
581
585
|
return {
|
|
582
|
-
...
|
|
586
|
+
...n,
|
|
583
587
|
id: f
|
|
584
588
|
};
|
|
585
589
|
}
|
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-CfrteYXm.js";
|
|
11
11
|
export {
|
|
12
12
|
_ as CUSTOM_COMPONENT_CACHE_DURATION_IN_SECONDS,
|
|
13
13
|
E as GET_SERVER_SIDE_PROPS_TIMEOUT_IN_SECONDS,
|