@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.
Files changed (2) hide show
  1. package/lib/html-embed.js +51 -44
  2. package/package.json +7 -7
package/lib/html-embed.js CHANGED
@@ -1,15 +1,15 @@
1
- import { jsx as i } from "react/jsx-runtime";
2
- import { forwardRef as R, useContext as S, useState as b, useSyncExternalStore as x, useRef as f, useMemo as E, useEffect as k } from "react";
3
- import { mergeRefs as T } from "@react-aria/utils";
4
- import { ReactSdkContext as g } from "@webstudio-is/react-sdk/runtime";
5
- import { patchDomEvents as L, executeDomEvents as _ } from "./html-embed-patchers.js";
6
- const C = {
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
- }, w = (e) => new Promise((t, n) => {
9
- const r = document.createElement("script"), s = e.hasAttribute("src"), a = e.type === "module";
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 = `${C.scriptTestIdPrefix}${r.dataset.testid}`), s)
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), s === !1 && t();
32
- }), l = [];
33
- let d = !1;
34
- const O = async (e) => {
35
- if (l.push(...e), await Promise.resolve(), !d) {
36
- for (L(), d = !0; l.length > 0; )
37
- await l.shift()();
38
- _(), d = !1;
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
- }, H = (e) => {
40
+ }, I = (e) => {
41
41
  const t = e.querySelectorAll("script"), n = [], r = [];
42
- t.forEach((s) => {
43
- (s.hasAttribute("async") ? r : n).push(() => w(s));
42
+ t.forEach((i) => {
43
+ (i.hasAttribute("async") ? r : n).push(() => O(i));
44
44
  });
45
- for (const s of r)
46
- s();
47
- O(n);
48
- }, I = (e) => {
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__ */ i("div", { ref: n, ...r, style: { display: "block", padding: 20 }, children: 'Open the "Settings" panel to insert HTML code.' });
51
- }, h = () => x(
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
- ), u = (e) => {
57
- if (!h())
56
+ ), l = (e) => {
57
+ if (!p())
58
58
  return e.children;
59
59
  }, m = (e) => {
60
- const { code: t, innerRef: n, ...r } = e, s = f(null), a = f(!0), c = 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 k(() => {
67
- const o = s.current;
68
- o && a.current && (a.current = !1, H(o));
69
- }, []), /* @__PURE__ */ i(
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: T(n, s),
73
+ ref: L(n, i),
74
74
  dangerouslySetInnerHTML: c
75
75
  }
76
76
  );
77
- }, p = (e) => {
77
+ }, v = (e) => {
78
78
  const { code: t, innerRef: n, ...r } = e;
79
- return /* @__PURE__ */ i(
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
- }, M = p, P = R(
87
+ }, h = v, A = b(
88
88
  (e, t) => {
89
- const { code: n, executeScriptOnCanvas: r, clientOnly: s, children: a, ...c } = e, { renderer: o } = S(g), v = h(), [y] = b(v);
90
- return n === void 0 || String(n).trim().length === 0 ? /* @__PURE__ */ i(I, { innerRef: t, ...c }) : y ? s !== !0 ? /* @__PURE__ */ i(p, { innerRef: t, code: n, ...c }) : /* @__PURE__ */ i(u, { children: /* @__PURE__ */ i(m, { innerRef: t, code: n, ...c }) }) : o === "canvas" && r !== !0 ? /* @__PURE__ */ i(u, { children: /* @__PURE__ */ i(
91
- M,
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__ */ i(u, { children: /* @__PURE__ */ i(
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
- P.displayName = "HtmlEmbed";
115
+ A.displayName = "HtmlEmbed";
109
116
  export {
110
- P as HtmlEmbed,
111
- C as __testing__
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.253.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.253.0",
48
- "@webstudio-is/react-sdk": "0.253.0",
49
- "@webstudio-is/image": "0.253.0",
50
- "@webstudio-is/sdk": "0.253.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/tsconfig": "1.0.7",
64
- "@webstudio-is/template": "0.253.0"
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",