@webstudio-is/sdk-components-react 0.253.0 → 0.254.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/lib/html-embed.js +51 -44
- package/package.json +7 -7
package/lib/html-embed.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { mergeRefs as
|
|
4
|
-
import { ReactSdkContext as
|
|
5
|
-
import { patchDomEvents as
|
|
6
|
-
const
|
|
1
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as b, useContext as x, useState as E, useSyncExternalStore as k, useRef as f, useMemo as T, useEffect as g } from "react";
|
|
3
|
+
import { mergeRefs as L } from "@react-aria/utils";
|
|
4
|
+
import { ReactSdkContext as _ } from "@webstudio-is/react-sdk/runtime";
|
|
5
|
+
import { patchDomEvents as C, executeDomEvents as w } from "./html-embed-patchers.js";
|
|
6
|
+
const M = {
|
|
7
7
|
scriptTestIdPrefix: "client-"
|
|
8
|
-
},
|
|
9
|
-
const r = document.createElement("script"),
|
|
8
|
+
}, O = (e) => new Promise((t, n) => {
|
|
9
|
+
const r = document.createElement("script"), i = e.hasAttribute("src"), a = e.type === "module";
|
|
10
10
|
for (const { name: c, value: o } of e.attributes)
|
|
11
11
|
r.setAttribute(c, o);
|
|
12
|
-
if (r.dataset.testid !== void 0 && (r.dataset.testid = `${
|
|
12
|
+
if (r.dataset.testid !== void 0 && (r.dataset.testid = `${M.scriptTestIdPrefix}${r.dataset.testid}`), i)
|
|
13
13
|
r.addEventListener("load", () => {
|
|
14
14
|
t();
|
|
15
15
|
}), r.addEventListener("error", n);
|
|
@@ -28,55 +28,55 @@ const C = {
|
|
|
28
28
|
}
|
|
29
29
|
r.textContent = e.innerText;
|
|
30
30
|
}
|
|
31
|
-
e.replaceWith(r),
|
|
32
|
-
}),
|
|
33
|
-
let
|
|
34
|
-
const
|
|
35
|
-
if (
|
|
36
|
-
for (
|
|
37
|
-
await
|
|
38
|
-
|
|
31
|
+
e.replaceWith(r), i === !1 && t();
|
|
32
|
+
}), d = [];
|
|
33
|
+
let u = !1;
|
|
34
|
+
const H = async (e) => {
|
|
35
|
+
if (d.push(...e), await Promise.resolve(), !u) {
|
|
36
|
+
for (C(), u = !0; d.length > 0; )
|
|
37
|
+
await d.shift()();
|
|
38
|
+
w(), u = !1;
|
|
39
39
|
}
|
|
40
|
-
},
|
|
40
|
+
}, I = (e) => {
|
|
41
41
|
const t = e.querySelectorAll("script"), n = [], r = [];
|
|
42
|
-
t.forEach((
|
|
43
|
-
(
|
|
42
|
+
t.forEach((i) => {
|
|
43
|
+
(i.hasAttribute("async") ? r : n).push(() => O(i));
|
|
44
44
|
});
|
|
45
|
-
for (const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
},
|
|
45
|
+
for (const i of r)
|
|
46
|
+
i();
|
|
47
|
+
H(n);
|
|
48
|
+
}, P = (e) => {
|
|
49
49
|
const { code: t, innerRef: n, ...r } = e;
|
|
50
|
-
return /* @__PURE__ */
|
|
51
|
-
},
|
|
50
|
+
return /* @__PURE__ */ s("div", { ref: n, ...r, style: { display: "block", padding: 20 }, children: 'Open the "Settings" panel to insert HTML code.' });
|
|
51
|
+
}, p = () => k(
|
|
52
52
|
() => () => {
|
|
53
53
|
},
|
|
54
54
|
() => !1,
|
|
55
55
|
() => !0
|
|
56
|
-
),
|
|
57
|
-
if (!
|
|
56
|
+
), l = (e) => {
|
|
57
|
+
if (!p())
|
|
58
58
|
return e.children;
|
|
59
59
|
}, m = (e) => {
|
|
60
|
-
const { code: t, innerRef: n, ...r } = e,
|
|
60
|
+
const { code: t, innerRef: n, ...r } = e, i = f(null), a = f(!0), c = T(
|
|
61
61
|
() => ({
|
|
62
62
|
__html: t ?? ""
|
|
63
63
|
}),
|
|
64
64
|
[t]
|
|
65
65
|
);
|
|
66
|
-
return
|
|
67
|
-
const o =
|
|
68
|
-
o && a.current && (a.current = !1,
|
|
69
|
-
}, []), /* @__PURE__ */
|
|
66
|
+
return g(() => {
|
|
67
|
+
const o = i.current;
|
|
68
|
+
o && a.current && (a.current = !1, I(o));
|
|
69
|
+
}, []), /* @__PURE__ */ s(
|
|
70
70
|
"div",
|
|
71
71
|
{
|
|
72
72
|
...r,
|
|
73
|
-
ref:
|
|
73
|
+
ref: L(n, i),
|
|
74
74
|
dangerouslySetInnerHTML: c
|
|
75
75
|
}
|
|
76
76
|
);
|
|
77
|
-
},
|
|
77
|
+
}, v = (e) => {
|
|
78
78
|
const { code: t, innerRef: n, ...r } = e;
|
|
79
|
-
return /* @__PURE__ */
|
|
79
|
+
return /* @__PURE__ */ s(
|
|
80
80
|
"div",
|
|
81
81
|
{
|
|
82
82
|
...r,
|
|
@@ -84,17 +84,24 @@ const O = async (e) => {
|
|
|
84
84
|
dangerouslySetInnerHTML: { __html: t ?? "" }
|
|
85
85
|
}
|
|
86
86
|
);
|
|
87
|
-
},
|
|
87
|
+
}, h = v, A = b(
|
|
88
88
|
(e, t) => {
|
|
89
|
-
const { code: n, executeScriptOnCanvas: r, clientOnly:
|
|
90
|
-
return n === void 0 || String(n).trim().length === 0 ? /* @__PURE__ */
|
|
91
|
-
|
|
89
|
+
const { code: n, executeScriptOnCanvas: r, clientOnly: i, children: a, ...c } = e, { renderer: o, isSafeMode: y } = x(_), R = p(), [S] = E(R);
|
|
90
|
+
return n === void 0 || String(n).trim().length === 0 ? /* @__PURE__ */ s(P, { innerRef: t, ...c }) : S ? i !== !0 ? /* @__PURE__ */ s(v, { innerRef: t, code: n, ...c }) : /* @__PURE__ */ s(l, { children: /* @__PURE__ */ s(m, { innerRef: t, code: n, ...c }) }) : y ? /* @__PURE__ */ s(l, { children: /* @__PURE__ */ s(
|
|
91
|
+
h,
|
|
92
|
+
{
|
|
93
|
+
innerRef: t,
|
|
94
|
+
code: n,
|
|
95
|
+
...c
|
|
96
|
+
}
|
|
97
|
+
) }) : o === "canvas" && r !== !0 ? /* @__PURE__ */ s(l, { children: /* @__PURE__ */ s(
|
|
98
|
+
h,
|
|
92
99
|
{
|
|
93
100
|
innerRef: t,
|
|
94
101
|
code: n,
|
|
95
102
|
...c
|
|
96
103
|
}
|
|
97
|
-
) }) : /* @__PURE__ */
|
|
104
|
+
) }) : /* @__PURE__ */ s(l, { children: /* @__PURE__ */ s(
|
|
98
105
|
m,
|
|
99
106
|
{
|
|
100
107
|
innerRef: t,
|
|
@@ -105,8 +112,8 @@ const O = async (e) => {
|
|
|
105
112
|
) });
|
|
106
113
|
}
|
|
107
114
|
);
|
|
108
|
-
|
|
115
|
+
A.displayName = "HtmlEmbed";
|
|
109
116
|
export {
|
|
110
|
-
|
|
111
|
-
|
|
117
|
+
A as HtmlEmbed,
|
|
118
|
+
M as __testing__
|
|
112
119
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/sdk-components-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.254.0",
|
|
4
4
|
"description": "Webstudio default library for react",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"colord": "^2.9.3",
|
|
45
45
|
"micromark": "^4.0.2",
|
|
46
46
|
"micromark-extension-gfm-table": "^2.1.1",
|
|
47
|
-
"@webstudio-is/icons": "0.
|
|
48
|
-
"@webstudio-is/
|
|
49
|
-
"@webstudio-is/
|
|
50
|
-
"@webstudio-is/sdk": "0.
|
|
47
|
+
"@webstudio-is/icons": "0.254.0",
|
|
48
|
+
"@webstudio-is/image": "0.254.0",
|
|
49
|
+
"@webstudio-is/react-sdk": "0.254.0",
|
|
50
|
+
"@webstudio-is/sdk": "0.254.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@testing-library/dom": "^10.4.0",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"vitest": "^3.1.2",
|
|
61
61
|
"@webstudio-is/generate-arg-types": "0.0.0",
|
|
62
62
|
"@webstudio-is/sdk-cli": "0.94.0",
|
|
63
|
-
"@webstudio-is/
|
|
64
|
-
"@webstudio-is/
|
|
63
|
+
"@webstudio-is/template": "0.254.0",
|
|
64
|
+
"@webstudio-is/tsconfig": "1.0.7"
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|
|
67
67
|
"build": "vite build --config ../../vite.sdk-components.config.ts",
|