webim-adapter 0.13.0 → 0.15.0
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/build/webim-adapter.js +261 -176
- package/build/webim-embed.js +4 -4
- package/build/webim-ssr.js +131 -46
- package/package.json +1 -1
package/build/webim-ssr.js
CHANGED
|
@@ -2196,27 +2196,27 @@ function yt({ items: e = [], separator: t = "/", style: n, nodeRef: r }) {
|
|
|
2196
2196
|
})
|
|
2197
2197
|
}) : null;
|
|
2198
2198
|
}
|
|
2199
|
-
function bt({ pages: e = 5, current: t = 1, prevNext: n = !0, href: r = "#", source: o, pageSize: s = 6, align: c,
|
|
2200
|
-
let { tenant:
|
|
2199
|
+
function bt({ pages: e = 5, current: t = 1, prevNext: n = !0, href: r = "#", source: o, pageSize: s = 6, align: c, hideEmpty: u, inert: p, style: m, nodeRef: h }) {
|
|
2200
|
+
let { tenant: g, apiUrl: _ } = i(H), v = i(U), [y, b] = l(null), x = o ? Number(v?.[`${o}:total`]) : NaN;
|
|
2201
2201
|
a(() => {
|
|
2202
|
-
if (!o || Number.isFinite(
|
|
2203
|
-
let e = !0, t = o.startsWith("api:") ? `${
|
|
2204
|
-
return fetch(t, { headers:
|
|
2202
|
+
if (!o || Number.isFinite(x)) return;
|
|
2203
|
+
let e = !0, t = o.startsWith("api:") ? `${_}/data/${encodeURIComponent(o.slice(4))}` : `${_}/dynamic/${encodeURIComponent(o)}?limit=1`;
|
|
2204
|
+
return fetch(t, { headers: g ? { "x-tenant": g } : {} }).then((e) => e.json()).then((t) => {
|
|
2205
2205
|
if (!e) return;
|
|
2206
2206
|
let n = t?.payload, r = Array.isArray(n) ? n.length : Number(n?.total?.filtered ?? n?.total?.all ?? (Array.isArray(n?.data) ? n.data.length : 0));
|
|
2207
|
-
|
|
2208
|
-
}).catch(() => e &&
|
|
2207
|
+
b(Number.isFinite(r) ? r : 0);
|
|
2208
|
+
}).catch(() => e && b(0)), () => {
|
|
2209
2209
|
e = !1;
|
|
2210
2210
|
};
|
|
2211
2211
|
}, [
|
|
2212
2212
|
o,
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2213
|
+
g,
|
|
2214
|
+
_,
|
|
2215
|
+
x
|
|
2216
2216
|
]);
|
|
2217
|
-
let
|
|
2218
|
-
if (o &&
|
|
2219
|
-
let
|
|
2217
|
+
let S = Math.max(1, Number(s) || 6), w = Number.isFinite(x) ? x : y;
|
|
2218
|
+
if (o && w === null || o && u && !(w > 0)) return null;
|
|
2219
|
+
let T = Math.min(Math.max(o ? Math.ceil(w / S) : Number(e) || 1, 1), 50), E = Math.min(Math.max(o ? W(v) : Number(t) || 1, 1), T), D = (e) => {
|
|
2220
2220
|
if (o) {
|
|
2221
2221
|
if (typeof window < "u") {
|
|
2222
2222
|
let t = new URLSearchParams(window.location.search);
|
|
@@ -2225,7 +2225,7 @@ function bt({ pages: e = 5, current: t = 1, prevNext: n = !0, href: r = "#", sou
|
|
|
2225
2225
|
return `?page=${e}`;
|
|
2226
2226
|
}
|
|
2227
2227
|
return r && r !== "#" ? r.replace("{page}", String(e)) : "#";
|
|
2228
|
-
},
|
|
2228
|
+
}, O = c === "center" ? "center" : c === "right" ? "flex-end" : "flex-start", k = p ? (e) => e.preventDefault() : void 0, A = (e) => ({
|
|
2229
2229
|
display: "inline-flex",
|
|
2230
2230
|
alignItems: "center",
|
|
2231
2231
|
justifyContent: "center",
|
|
@@ -2240,38 +2240,41 @@ function bt({ pages: e = 5, current: t = 1, prevNext: n = !0, href: r = "#", sou
|
|
|
2240
2240
|
border: e ? "1px solid transparent" : "1px solid rgba(148, 163, 184, 0.4)"
|
|
2241
2241
|
});
|
|
2242
2242
|
return /* @__PURE__ */ f("nav", {
|
|
2243
|
-
ref:
|
|
2243
|
+
ref: h,
|
|
2244
2244
|
"aria-label": "Pagination",
|
|
2245
2245
|
style: {
|
|
2246
2246
|
display: "flex",
|
|
2247
2247
|
flexWrap: "wrap",
|
|
2248
2248
|
gap: 8,
|
|
2249
2249
|
alignItems: "center",
|
|
2250
|
-
justifyContent:
|
|
2251
|
-
...C(
|
|
2250
|
+
justifyContent: O,
|
|
2251
|
+
...C(m)
|
|
2252
2252
|
},
|
|
2253
2253
|
children: [
|
|
2254
2254
|
n && /* @__PURE__ */ d("a", {
|
|
2255
|
-
href:
|
|
2255
|
+
href: E > 1 ? D(E - 1) : "#",
|
|
2256
|
+
onClick: k,
|
|
2256
2257
|
"aria-label": "Previous",
|
|
2257
2258
|
style: {
|
|
2258
|
-
...
|
|
2259
|
-
opacity:
|
|
2259
|
+
...A(!1),
|
|
2260
|
+
opacity: E > 1 ? 1 : .4
|
|
2260
2261
|
},
|
|
2261
2262
|
children: "‹"
|
|
2262
2263
|
}),
|
|
2263
|
-
Array.from({ length:
|
|
2264
|
-
href:
|
|
2265
|
-
|
|
2266
|
-
|
|
2264
|
+
Array.from({ length: T }, (e, t) => t + 1).map((e) => /* @__PURE__ */ d("a", {
|
|
2265
|
+
href: D(e),
|
|
2266
|
+
onClick: k,
|
|
2267
|
+
"aria-current": e === E ? "page" : void 0,
|
|
2268
|
+
style: A(e === E),
|
|
2267
2269
|
children: e
|
|
2268
2270
|
}, e)),
|
|
2269
2271
|
n && /* @__PURE__ */ d("a", {
|
|
2270
|
-
href:
|
|
2272
|
+
href: E < T ? D(E + 1) : "#",
|
|
2273
|
+
onClick: k,
|
|
2271
2274
|
"aria-label": "Next",
|
|
2272
2275
|
style: {
|
|
2273
|
-
...
|
|
2274
|
-
opacity:
|
|
2276
|
+
...A(!1),
|
|
2277
|
+
opacity: E < T ? 1 : .4
|
|
2275
2278
|
},
|
|
2276
2279
|
children: "›"
|
|
2277
2280
|
})
|
|
@@ -3143,10 +3146,92 @@ var Vt = [Pt], Ht = {
|
|
|
3143
3146
|
};
|
|
3144
3147
|
new Set(Vt.filter((e) => e.ssr === "shell").flatMap((e) => e.keys));
|
|
3145
3148
|
//#endregion
|
|
3149
|
+
//#region ../ui/src/components/builder/plugins/runtime.js
|
|
3150
|
+
var Ut = /* @__PURE__ */ new Map();
|
|
3151
|
+
function Wt(e) {
|
|
3152
|
+
if (Ut.has(e)) return Ut.get(e);
|
|
3153
|
+
let t = URL.createObjectURL(new Blob([e], { type: "text/javascript" })), n = import(
|
|
3154
|
+
/* @vite-ignore */
|
|
3155
|
+
t
|
|
3156
|
+
).finally(() => URL.revokeObjectURL(t));
|
|
3157
|
+
return Ut.set(e, n), n;
|
|
3158
|
+
}
|
|
3159
|
+
function Gt(e) {
|
|
3160
|
+
let t = e && typeof e == "object" ? e.builder_plugins : null, n = t && typeof t == "object" ? t.plugins : null;
|
|
3161
|
+
return n && typeof n == "object" ? n : {};
|
|
3162
|
+
}
|
|
3163
|
+
//#endregion
|
|
3164
|
+
//#region ../ui/src/components/builder/plugins/view.jsx
|
|
3165
|
+
async function Kt(e, t) {
|
|
3166
|
+
let n = await Wt(e);
|
|
3167
|
+
return (Array.isArray(n?.default?.blocks) ? n.default.blocks : []).find((e) => e?.id === t && typeof e.mount == "function") ?? null;
|
|
3168
|
+
}
|
|
3169
|
+
var qt = {
|
|
3170
|
+
padding: "10px 12px",
|
|
3171
|
+
border: "1px dashed rgba(148, 163, 184, 0.5)",
|
|
3172
|
+
borderRadius: 8,
|
|
3173
|
+
fontSize: 12,
|
|
3174
|
+
opacity: .6
|
|
3175
|
+
};
|
|
3176
|
+
function Jt({ pluginId: e, blockId: t, props: n, style: r, nodeRef: o }) {
|
|
3177
|
+
let s = i(H), l = Gt(s?.settings)[e], u = c(null), p = c(null), m = {
|
|
3178
|
+
tenant: s?.tenant ?? "",
|
|
3179
|
+
apiUrl: s?.apiUrl ?? "/api",
|
|
3180
|
+
locale: s?.locale ?? "",
|
|
3181
|
+
settings: s?.settings ?? null
|
|
3182
|
+
}, h = c(m);
|
|
3183
|
+
h.current = m;
|
|
3184
|
+
let g = JSON.stringify(n ?? {});
|
|
3185
|
+
return a(() => {
|
|
3186
|
+
let e = u.current;
|
|
3187
|
+
if (!l?.code || !e) return;
|
|
3188
|
+
let n = !0;
|
|
3189
|
+
return Kt(l.code, t).then((e) => {
|
|
3190
|
+
if (!(!n || !e || !u.current)) {
|
|
3191
|
+
p.current = e;
|
|
3192
|
+
try {
|
|
3193
|
+
e.mount(u.current, JSON.parse(g), h.current);
|
|
3194
|
+
} catch {
|
|
3195
|
+
p.current = null;
|
|
3196
|
+
}
|
|
3197
|
+
}
|
|
3198
|
+
}).catch(() => {}), () => {
|
|
3199
|
+
n = !1;
|
|
3200
|
+
let t = p.current;
|
|
3201
|
+
p.current = null;
|
|
3202
|
+
try {
|
|
3203
|
+
t?.unmount?.(e);
|
|
3204
|
+
} catch {}
|
|
3205
|
+
e && (e.innerHTML = "");
|
|
3206
|
+
};
|
|
3207
|
+
}, [l?.code, t]), a(() => {
|
|
3208
|
+
let e = p.current, t = u.current;
|
|
3209
|
+
if (!(!e || !t)) try {
|
|
3210
|
+
e.update ? e.update(t, JSON.parse(g), h.current) : (e.unmount?.(t), t.innerHTML = "", e.mount(t, JSON.parse(g), h.current));
|
|
3211
|
+
} catch {}
|
|
3212
|
+
}, [g]), l ? /* @__PURE__ */ d("div", {
|
|
3213
|
+
ref: o,
|
|
3214
|
+
style: C(r),
|
|
3215
|
+
children: /* @__PURE__ */ d("div", { ref: u })
|
|
3216
|
+
}) : /* @__PURE__ */ f("div", {
|
|
3217
|
+
ref: o,
|
|
3218
|
+
style: {
|
|
3219
|
+
...qt,
|
|
3220
|
+
...C(r)
|
|
3221
|
+
},
|
|
3222
|
+
children: [
|
|
3223
|
+
"Plugin “",
|
|
3224
|
+
e,
|
|
3225
|
+
"” is not installed"
|
|
3226
|
+
]
|
|
3227
|
+
});
|
|
3228
|
+
}
|
|
3229
|
+
//#endregion
|
|
3146
3230
|
//#region ../ui/src/components/builder/render.jsx
|
|
3147
|
-
var
|
|
3231
|
+
var Yt = {
|
|
3148
3232
|
...Nt,
|
|
3149
|
-
...Ht
|
|
3233
|
+
...Ht,
|
|
3234
|
+
PluginBlock: Jt
|
|
3150
3235
|
};
|
|
3151
3236
|
function Q(e, n, r, i = /* @__PURE__ */ new Set(), a = void 0) {
|
|
3152
3237
|
let o = n[e];
|
|
@@ -3158,7 +3243,7 @@ function Q(e, n, r, i = /* @__PURE__ */ new Set(), a = void 0) {
|
|
|
3158
3243
|
let c = new Set(i).add(n);
|
|
3159
3244
|
return /* @__PURE__ */ d(t, { children: Q(s.template.rootId, s.template.nodes, r, c, a) }, e);
|
|
3160
3245
|
}
|
|
3161
|
-
let l =
|
|
3246
|
+
let l = Yt[s];
|
|
3162
3247
|
if (!l) return null;
|
|
3163
3248
|
let u = (o.nodes ?? []).map((e) => Q(e, n, r, i, a)).filter(Boolean), f = Object.entries(o.linkedNodes ?? {}), p = f.length ? Object.fromEntries(f.map(([e, t]) => [e, Q(t, n, r, i)])) : void 0, m = /* @__PURE__ */ d(l, {
|
|
3164
3249
|
...c,
|
|
@@ -3176,8 +3261,8 @@ function Q(e, n, r, i = /* @__PURE__ */ new Set(), a = void 0) {
|
|
|
3176
3261
|
}
|
|
3177
3262
|
//#endregion
|
|
3178
3263
|
//#region ../ui/src/components/builder/PageRenderer.jsx
|
|
3179
|
-
var
|
|
3180
|
-
function
|
|
3264
|
+
var Xt = (e) => Object.entries(e).map(([e, t]) => `${e}: ${t};`).join(" ");
|
|
3265
|
+
function Zt({ blocks: e, theme: t, components: n, mode: r = "auto", style: i, custom: o, tenant: c, apiUrl: l, datasets: u, locale: p, direction: m, settings: g, siteUser: v }) {
|
|
3181
3266
|
let b = o?.js?.trim();
|
|
3182
3267
|
if (a(() => {
|
|
3183
3268
|
if (!b) return;
|
|
@@ -3253,8 +3338,8 @@ function Gt({ blocks: e, theme: t, components: n, mode: r = "auto", style: i, cu
|
|
|
3253
3338
|
...i
|
|
3254
3339
|
},
|
|
3255
3340
|
children: [
|
|
3256
|
-
/* @__PURE__ */ d("style", { children: `.webim-page { ${
|
|
3257
|
-
@media (prefers-color-scheme: dark) { .webim-page { ${
|
|
3341
|
+
/* @__PURE__ */ d("style", { children: `.webim-page { ${Xt(V(A.light))} }
|
|
3342
|
+
@media (prefers-color-scheme: dark) { .webim-page { ${Xt(V(A.dark))} } }` }),
|
|
3258
3343
|
k,
|
|
3259
3344
|
/* @__PURE__ */ d("style", { children: S }),
|
|
3260
3345
|
E && /* @__PURE__ */ d("style", { children: E }),
|
|
@@ -3270,8 +3355,8 @@ function Gt({ blocks: e, theme: t, components: n, mode: r = "auto", style: i, cu
|
|
|
3270
3355
|
}
|
|
3271
3356
|
//#endregion
|
|
3272
3357
|
//#region src/WebimContent.jsx
|
|
3273
|
-
function
|
|
3274
|
-
return e?.blocks?.ROOT ? /* @__PURE__ */ d(
|
|
3358
|
+
function Qt({ bundle: e, mode: t = "auto", style: n }) {
|
|
3359
|
+
return e?.blocks?.ROOT ? /* @__PURE__ */ d(Zt, {
|
|
3275
3360
|
blocks: e.blocks,
|
|
3276
3361
|
theme: e.theme,
|
|
3277
3362
|
components: e.components,
|
|
@@ -3288,7 +3373,7 @@ function Kt({ bundle: e, mode: t = "auto", style: n }) {
|
|
|
3288
3373
|
}
|
|
3289
3374
|
//#endregion
|
|
3290
3375
|
//#region src/bundle.js
|
|
3291
|
-
function
|
|
3376
|
+
function $t({ page: e, settings: t, tenant: n, apiUrl: r, locale: i }) {
|
|
3292
3377
|
let a = {
|
|
3293
3378
|
...t?.global ?? {},
|
|
3294
3379
|
...t?.tenant ?? {}
|
|
@@ -3312,18 +3397,18 @@ function qt({ page: e, settings: t, tenant: n, apiUrl: r, locale: i }) {
|
|
|
3312
3397
|
}
|
|
3313
3398
|
//#endregion
|
|
3314
3399
|
//#region src/fetchPage.js
|
|
3315
|
-
var
|
|
3400
|
+
var en = async (e) => {
|
|
3316
3401
|
let t = await e.json().catch(() => null);
|
|
3317
3402
|
if (!e.ok || t?.success === !1) throw Error(t?.error?.message || `Request failed (${e.status})`);
|
|
3318
3403
|
return t?.payload ?? t;
|
|
3319
3404
|
};
|
|
3320
|
-
async function
|
|
3405
|
+
async function tn({ apiUrl: e, tenant: t, slug: n, locale: r, preview: i, token: a, page: o, fetch: s }) {
|
|
3321
3406
|
if (!e) throw Error("fetchPage: apiUrl is required");
|
|
3322
3407
|
if (!n) throw Error("fetchPage: slug is required");
|
|
3323
3408
|
let c = s ?? fetch, l = e.replace(/\/$/, ""), u = {
|
|
3324
3409
|
...t ? { "x-tenant": t } : {},
|
|
3325
3410
|
...a ? { authorization: `Bearer ${a}` } : {}
|
|
3326
|
-
}, [d, f] = await Promise.all([c(`${l}/render/${encodeURIComponent(n)}${i ? `?preview=${encodeURIComponent(i)}` : ""}`, { headers: u }).then(
|
|
3411
|
+
}, [d, f] = await Promise.all([c(`${l}/render/${encodeURIComponent(n)}${i ? `?preview=${encodeURIComponent(i)}` : ""}`, { headers: u }).then(en), c(`${l}/settings/public`, { headers: u }).then(en)]), p = $t({
|
|
3327
3412
|
page: d,
|
|
3328
3413
|
settings: f,
|
|
3329
3414
|
tenant: t,
|
|
@@ -3331,7 +3416,7 @@ async function Yt({ apiUrl: e, tenant: t, slug: n, locale: r, preview: i, token:
|
|
|
3331
3416
|
locale: r
|
|
3332
3417
|
}), m = [...new Set(Object.values(p.blocks ?? {}).map((e) => e?.type?.resolvedName === "CollectionList" ? e.props?.collection : e?.type?.resolvedName === "TableBlock" || e?.type?.resolvedName === "OrgChartBlock" ? e.props?.source : null).filter(Boolean))];
|
|
3333
3418
|
if (m.length) {
|
|
3334
|
-
let e = (e) => e.startsWith("api:") ? `${l}/data/${encodeURIComponent(e.slice(4))}` : `${l}/dynamic/${encodeURIComponent(e)}?all=1${r ? `&locale=${encodeURIComponent(r)}` : ""}`, t = await Promise.all(m.map((t) => c(e(t), { headers: u }).then(
|
|
3419
|
+
let e = (e) => e.startsWith("api:") ? `${l}/data/${encodeURIComponent(e.slice(4))}` : `${l}/dynamic/${encodeURIComponent(e)}?all=1${r ? `&locale=${encodeURIComponent(r)}` : ""}`, t = await Promise.all(m.map((t) => c(e(t), { headers: u }).then(en).then((e) => {
|
|
3335
3420
|
let n = Array.isArray(e) ? e : Array.isArray(e?.data) ? e.data : [], r = Number(e?.total?.filtered ?? e?.total?.all ?? n.length);
|
|
3336
3421
|
return [[t, n], [`${t}:total`, Number.isFinite(r) ? r : n.length]];
|
|
3337
3422
|
}).catch(() => [[t, []]])));
|
|
@@ -3351,14 +3436,14 @@ var $ = (e) => String(e ?? "").replace(/[&<>"]/g, (e) => ({
|
|
|
3351
3436
|
">": ">",
|
|
3352
3437
|
"\"": """
|
|
3353
3438
|
})[e]);
|
|
3354
|
-
function
|
|
3355
|
-
return e(/* @__PURE__ */ d(
|
|
3439
|
+
function nn(t, { mode: n = "auto", style: r } = {}) {
|
|
3440
|
+
return e(/* @__PURE__ */ d(Qt, {
|
|
3356
3441
|
bundle: t,
|
|
3357
3442
|
mode: n,
|
|
3358
3443
|
style: r
|
|
3359
3444
|
}));
|
|
3360
3445
|
}
|
|
3361
|
-
function
|
|
3446
|
+
function rn(e, { mode: t = "auto", lang: n } = {}) {
|
|
3362
3447
|
let r = e.seo ?? {}, i = n || e.locale || "en", a = h(e.direction, i), o = r.title || e.title || e.slug || "Page", s = e.custom?.js?.trim(), c = [
|
|
3363
3448
|
"<meta charset=\"utf-8\"/>",
|
|
3364
3449
|
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/>",
|
|
@@ -3375,10 +3460,10 @@ function Zt(e, { mode: t = "auto", lang: n } = {}) {
|
|
|
3375
3460
|
${c}
|
|
3376
3461
|
</head>
|
|
3377
3462
|
<body>
|
|
3378
|
-
${
|
|
3463
|
+
${nn(e, { mode: t })}
|
|
3379
3464
|
${s ? `<script>${s.replaceAll("<\/script", "<\\/script")}<\/script>` : ""}
|
|
3380
3465
|
</body>
|
|
3381
3466
|
</html>`;
|
|
3382
3467
|
}
|
|
3383
3468
|
//#endregion
|
|
3384
|
-
export {
|
|
3469
|
+
export { $t as assembleBundle, tn as fetchPage, nn as renderBundleHtml, rn as renderPageDocument };
|