webim-adapter 0.14.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 +231 -149
- package/build/webim-embed.js +4 -4
- package/build/webim-ssr.js +101 -19
- package/package.json +1 -1
package/build/webim-ssr.js
CHANGED
|
@@ -3146,10 +3146,92 @@ var Vt = [Pt], Ht = {
|
|
|
3146
3146
|
};
|
|
3147
3147
|
new Set(Vt.filter((e) => e.ssr === "shell").flatMap((e) => e.keys));
|
|
3148
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
|
|
3149
3230
|
//#region ../ui/src/components/builder/render.jsx
|
|
3150
|
-
var
|
|
3231
|
+
var Yt = {
|
|
3151
3232
|
...Nt,
|
|
3152
|
-
...Ht
|
|
3233
|
+
...Ht,
|
|
3234
|
+
PluginBlock: Jt
|
|
3153
3235
|
};
|
|
3154
3236
|
function Q(e, n, r, i = /* @__PURE__ */ new Set(), a = void 0) {
|
|
3155
3237
|
let o = n[e];
|
|
@@ -3161,7 +3243,7 @@ function Q(e, n, r, i = /* @__PURE__ */ new Set(), a = void 0) {
|
|
|
3161
3243
|
let c = new Set(i).add(n);
|
|
3162
3244
|
return /* @__PURE__ */ d(t, { children: Q(s.template.rootId, s.template.nodes, r, c, a) }, e);
|
|
3163
3245
|
}
|
|
3164
|
-
let l =
|
|
3246
|
+
let l = Yt[s];
|
|
3165
3247
|
if (!l) return null;
|
|
3166
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, {
|
|
3167
3249
|
...c,
|
|
@@ -3179,8 +3261,8 @@ function Q(e, n, r, i = /* @__PURE__ */ new Set(), a = void 0) {
|
|
|
3179
3261
|
}
|
|
3180
3262
|
//#endregion
|
|
3181
3263
|
//#region ../ui/src/components/builder/PageRenderer.jsx
|
|
3182
|
-
var
|
|
3183
|
-
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 }) {
|
|
3184
3266
|
let b = o?.js?.trim();
|
|
3185
3267
|
if (a(() => {
|
|
3186
3268
|
if (!b) return;
|
|
@@ -3256,8 +3338,8 @@ function Gt({ blocks: e, theme: t, components: n, mode: r = "auto", style: i, cu
|
|
|
3256
3338
|
...i
|
|
3257
3339
|
},
|
|
3258
3340
|
children: [
|
|
3259
|
-
/* @__PURE__ */ d("style", { children: `.webim-page { ${
|
|
3260
|
-
@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))} } }` }),
|
|
3261
3343
|
k,
|
|
3262
3344
|
/* @__PURE__ */ d("style", { children: S }),
|
|
3263
3345
|
E && /* @__PURE__ */ d("style", { children: E }),
|
|
@@ -3273,8 +3355,8 @@ function Gt({ blocks: e, theme: t, components: n, mode: r = "auto", style: i, cu
|
|
|
3273
3355
|
}
|
|
3274
3356
|
//#endregion
|
|
3275
3357
|
//#region src/WebimContent.jsx
|
|
3276
|
-
function
|
|
3277
|
-
return e?.blocks?.ROOT ? /* @__PURE__ */ d(
|
|
3358
|
+
function Qt({ bundle: e, mode: t = "auto", style: n }) {
|
|
3359
|
+
return e?.blocks?.ROOT ? /* @__PURE__ */ d(Zt, {
|
|
3278
3360
|
blocks: e.blocks,
|
|
3279
3361
|
theme: e.theme,
|
|
3280
3362
|
components: e.components,
|
|
@@ -3291,7 +3373,7 @@ function Kt({ bundle: e, mode: t = "auto", style: n }) {
|
|
|
3291
3373
|
}
|
|
3292
3374
|
//#endregion
|
|
3293
3375
|
//#region src/bundle.js
|
|
3294
|
-
function
|
|
3376
|
+
function $t({ page: e, settings: t, tenant: n, apiUrl: r, locale: i }) {
|
|
3295
3377
|
let a = {
|
|
3296
3378
|
...t?.global ?? {},
|
|
3297
3379
|
...t?.tenant ?? {}
|
|
@@ -3315,18 +3397,18 @@ function qt({ page: e, settings: t, tenant: n, apiUrl: r, locale: i }) {
|
|
|
3315
3397
|
}
|
|
3316
3398
|
//#endregion
|
|
3317
3399
|
//#region src/fetchPage.js
|
|
3318
|
-
var
|
|
3400
|
+
var en = async (e) => {
|
|
3319
3401
|
let t = await e.json().catch(() => null);
|
|
3320
3402
|
if (!e.ok || t?.success === !1) throw Error(t?.error?.message || `Request failed (${e.status})`);
|
|
3321
3403
|
return t?.payload ?? t;
|
|
3322
3404
|
};
|
|
3323
|
-
async function
|
|
3405
|
+
async function tn({ apiUrl: e, tenant: t, slug: n, locale: r, preview: i, token: a, page: o, fetch: s }) {
|
|
3324
3406
|
if (!e) throw Error("fetchPage: apiUrl is required");
|
|
3325
3407
|
if (!n) throw Error("fetchPage: slug is required");
|
|
3326
3408
|
let c = s ?? fetch, l = e.replace(/\/$/, ""), u = {
|
|
3327
3409
|
...t ? { "x-tenant": t } : {},
|
|
3328
3410
|
...a ? { authorization: `Bearer ${a}` } : {}
|
|
3329
|
-
}, [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({
|
|
3330
3412
|
page: d,
|
|
3331
3413
|
settings: f,
|
|
3332
3414
|
tenant: t,
|
|
@@ -3334,7 +3416,7 @@ async function Yt({ apiUrl: e, tenant: t, slug: n, locale: r, preview: i, token:
|
|
|
3334
3416
|
locale: r
|
|
3335
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))];
|
|
3336
3418
|
if (m.length) {
|
|
3337
|
-
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) => {
|
|
3338
3420
|
let n = Array.isArray(e) ? e : Array.isArray(e?.data) ? e.data : [], r = Number(e?.total?.filtered ?? e?.total?.all ?? n.length);
|
|
3339
3421
|
return [[t, n], [`${t}:total`, Number.isFinite(r) ? r : n.length]];
|
|
3340
3422
|
}).catch(() => [[t, []]])));
|
|
@@ -3354,14 +3436,14 @@ var $ = (e) => String(e ?? "").replace(/[&<>"]/g, (e) => ({
|
|
|
3354
3436
|
">": ">",
|
|
3355
3437
|
"\"": """
|
|
3356
3438
|
})[e]);
|
|
3357
|
-
function
|
|
3358
|
-
return e(/* @__PURE__ */ d(
|
|
3439
|
+
function nn(t, { mode: n = "auto", style: r } = {}) {
|
|
3440
|
+
return e(/* @__PURE__ */ d(Qt, {
|
|
3359
3441
|
bundle: t,
|
|
3360
3442
|
mode: n,
|
|
3361
3443
|
style: r
|
|
3362
3444
|
}));
|
|
3363
3445
|
}
|
|
3364
|
-
function
|
|
3446
|
+
function rn(e, { mode: t = "auto", lang: n } = {}) {
|
|
3365
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 = [
|
|
3366
3448
|
"<meta charset=\"utf-8\"/>",
|
|
3367
3449
|
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/>",
|
|
@@ -3378,10 +3460,10 @@ function Zt(e, { mode: t = "auto", lang: n } = {}) {
|
|
|
3378
3460
|
${c}
|
|
3379
3461
|
</head>
|
|
3380
3462
|
<body>
|
|
3381
|
-
${
|
|
3463
|
+
${nn(e, { mode: t })}
|
|
3382
3464
|
${s ? `<script>${s.replaceAll("<\/script", "<\\/script")}<\/script>` : ""}
|
|
3383
3465
|
</body>
|
|
3384
3466
|
</html>`;
|
|
3385
3467
|
}
|
|
3386
3468
|
//#endregion
|
|
3387
|
-
export {
|
|
3469
|
+
export { $t as assembleBundle, tn as fetchPage, nn as renderBundleHtml, rn as renderPageDocument };
|