@webstudio-is/sdk-components-react 0.144.1-89bca38.0 → 0.151.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/components.js +117 -11
- package/lib/metas.js +850 -372
- package/lib/props.js +945 -1099
- package/lib/types/__generated__/xml-node.props.d.ts +2 -0
- package/lib/types/code-text.d.ts +3 -1
- package/lib/types/components.d.ts +1 -0
- package/lib/types/html-embed-patchers.d.ts +2 -0
- package/lib/types/metas.d.ts +1 -0
- package/lib/types/props.d.ts +1 -0
- package/lib/types/vimeo-preview-image.d.ts +62 -64
- package/lib/types/xml-node.d.ts +8 -0
- package/lib/types/xml-node.ws.d.ts +3 -0
- package/package.json +15 -15
package/lib/components.js
CHANGED
|
@@ -32,6 +32,57 @@ import {
|
|
|
32
32
|
} from "react";
|
|
33
33
|
import { mergeRefs } from "@react-aria/utils";
|
|
34
34
|
import { ReactSdkContext } from "@webstudio-is/react-sdk";
|
|
35
|
+
|
|
36
|
+
// src/html-embed-patchers.ts
|
|
37
|
+
var isDOMContentLoaded = () => {
|
|
38
|
+
return document.readyState === "complete" || document.readyState === "interactive";
|
|
39
|
+
};
|
|
40
|
+
var eventListenerTasks = [];
|
|
41
|
+
var domContentLoadedPatched = false;
|
|
42
|
+
var patchDomEvents = () => {
|
|
43
|
+
if (isDOMContentLoaded() === false) {
|
|
44
|
+
console.error("DOMContentLoaded event has not been fired yet");
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (domContentLoadedPatched) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
domContentLoadedPatched = true;
|
|
51
|
+
console.info("Patching DOMContentLoaded event listener");
|
|
52
|
+
const originalAddEventListener = document.addEventListener;
|
|
53
|
+
const originalWindowAddEventListener = window.addEventListener;
|
|
54
|
+
const domContentLoadedEvent = new Event("DOMContentLoaded");
|
|
55
|
+
const windowLoadEvent = new Event("load");
|
|
56
|
+
window.addEventListener = (type, listener, options) => {
|
|
57
|
+
if (type === "DOMContentLoaded") {
|
|
58
|
+
eventListenerTasks.push(
|
|
59
|
+
() => listener.call(window, domContentLoadedEvent)
|
|
60
|
+
);
|
|
61
|
+
} else if (type === "load") {
|
|
62
|
+
eventListenerTasks.push(() => listener.call(window, windowLoadEvent));
|
|
63
|
+
originalWindowAddEventListener.call(window, type, listener, options);
|
|
64
|
+
} else {
|
|
65
|
+
originalWindowAddEventListener.call(window, type, listener, options);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
document.addEventListener = (type, listener, options) => {
|
|
69
|
+
if (type === "DOMContentLoaded") {
|
|
70
|
+
eventListenerTasks.push(
|
|
71
|
+
() => listener.call(document, domContentLoadedEvent)
|
|
72
|
+
);
|
|
73
|
+
} else {
|
|
74
|
+
originalAddEventListener.call(document, type, listener, options);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
var executeDomEvents = () => {
|
|
79
|
+
for (const task of eventListenerTasks) {
|
|
80
|
+
task();
|
|
81
|
+
}
|
|
82
|
+
eventListenerTasks.length = 0;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// src/html-embed.tsx
|
|
35
86
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
36
87
|
var __testing__ = {
|
|
37
88
|
scriptTestIdPrefix: "client-"
|
|
@@ -48,7 +99,7 @@ var insertScript = (sourceScript) => {
|
|
|
48
99
|
}
|
|
49
100
|
if (hasSrc) {
|
|
50
101
|
script.addEventListener("load", () => {
|
|
51
|
-
resolve(
|
|
102
|
+
resolve();
|
|
52
103
|
});
|
|
53
104
|
script.addEventListener("error", reject);
|
|
54
105
|
} else {
|
|
@@ -56,11 +107,30 @@ var insertScript = (sourceScript) => {
|
|
|
56
107
|
}
|
|
57
108
|
sourceScript.replaceWith(script);
|
|
58
109
|
if (hasSrc === false) {
|
|
59
|
-
resolve(
|
|
110
|
+
resolve();
|
|
60
111
|
}
|
|
61
112
|
});
|
|
62
113
|
};
|
|
63
|
-
var
|
|
114
|
+
var syncTasksQueue = [];
|
|
115
|
+
var processing = false;
|
|
116
|
+
var processSyncTasks = async (syncTasks) => {
|
|
117
|
+
syncTasksQueue.push(...syncTasks);
|
|
118
|
+
await Promise.resolve();
|
|
119
|
+
if (processing) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
patchDomEvents();
|
|
123
|
+
console.info("Start processing sync tasks");
|
|
124
|
+
processing = true;
|
|
125
|
+
while (syncTasksQueue.length > 0) {
|
|
126
|
+
const task = syncTasksQueue.shift();
|
|
127
|
+
await task();
|
|
128
|
+
}
|
|
129
|
+
executeDomEvents();
|
|
130
|
+
processing = false;
|
|
131
|
+
console.info("Stop processing sync tasks");
|
|
132
|
+
};
|
|
133
|
+
var execute = (container) => {
|
|
64
134
|
const scripts = container.querySelectorAll("script");
|
|
65
135
|
const syncTasks = [];
|
|
66
136
|
const asyncTasks = [];
|
|
@@ -73,13 +143,11 @@ var execute = async (container) => {
|
|
|
73
143
|
for (const task of asyncTasks) {
|
|
74
144
|
task();
|
|
75
145
|
}
|
|
76
|
-
|
|
77
|
-
await task();
|
|
78
|
-
}
|
|
146
|
+
processSyncTasks(syncTasks);
|
|
79
147
|
};
|
|
80
148
|
var Placeholder = (props) => {
|
|
81
149
|
const { code, innerRef, ...rest } = props;
|
|
82
|
-
return /* @__PURE__ */ jsx3("div", { ref: innerRef, ...rest, style: { padding:
|
|
150
|
+
return /* @__PURE__ */ jsx3("div", { ref: innerRef, ...rest, style: { padding: 20 }, children: 'Open the "Settings" panel to insert HTML code.' });
|
|
83
151
|
};
|
|
84
152
|
var useIsServer = () => {
|
|
85
153
|
const isServer = useSyncExternalStore(
|
|
@@ -396,10 +464,21 @@ var Separator = forwardRef23(
|
|
|
396
464
|
Separator.displayName = "Separator";
|
|
397
465
|
|
|
398
466
|
// src/code-text.tsx
|
|
399
|
-
import {
|
|
467
|
+
import {
|
|
468
|
+
forwardRef as forwardRef24
|
|
469
|
+
} from "react";
|
|
400
470
|
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
401
|
-
var
|
|
402
|
-
|
|
471
|
+
var Placeholder2 = ({
|
|
472
|
+
innerRef,
|
|
473
|
+
...rest
|
|
474
|
+
}) => {
|
|
475
|
+
return /* @__PURE__ */ jsx21("code", { ...rest, style: { padding: 20 }, ref: innerRef, children: `Open the "Settings" panel to edit the code.` });
|
|
476
|
+
};
|
|
477
|
+
var CodeText = forwardRef24(({ code, children, ...props }, ref) => {
|
|
478
|
+
if (children === void 0 && code === void 0 || String(code).trim().length === 0) {
|
|
479
|
+
return /* @__PURE__ */ jsx21(Placeholder2, { innerRef: ref, ...props });
|
|
480
|
+
}
|
|
481
|
+
return /* @__PURE__ */ jsx21("code", { ...props, ref, children: code ?? children });
|
|
403
482
|
});
|
|
404
483
|
CodeText.displayName = "CodeText";
|
|
405
484
|
|
|
@@ -771,6 +850,32 @@ var VimeoSpinner = forwardRef32(
|
|
|
771
850
|
}
|
|
772
851
|
);
|
|
773
852
|
VimeoSpinner.displayName = "VimeoSpinner";
|
|
853
|
+
|
|
854
|
+
// src/xml-node.tsx
|
|
855
|
+
import { Children, forwardRef as forwardRef33 } from "react";
|
|
856
|
+
import { jsx as jsx30, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
857
|
+
var XmlNode = forwardRef33(
|
|
858
|
+
({ tag = "", children, ...props }, ref) => {
|
|
859
|
+
const isTextChild = Children.toArray(children).every(
|
|
860
|
+
(child) => typeof child === "string"
|
|
861
|
+
);
|
|
862
|
+
const elementName = tag.replace(/^[^\p{L}_]+/u, "").replaceAll(/[^\p{L}\p{N}\-._]+/gu, "");
|
|
863
|
+
return /* @__PURE__ */ jsxs2("div", { style: { display: isTextChild ? "flex" : "contents" }, ...props, children: [
|
|
864
|
+
/* @__PURE__ */ jsxs2("div", { style: { color: "rgb(16, 23, 233)" }, children: [
|
|
865
|
+
"<",
|
|
866
|
+
elementName,
|
|
867
|
+
">"
|
|
868
|
+
] }),
|
|
869
|
+
/* @__PURE__ */ jsx30("div", { ref, style: { marginLeft: isTextChild ? 0 : "1rem" }, children }),
|
|
870
|
+
/* @__PURE__ */ jsxs2("div", { style: { color: "rgb(16, 23, 233)" }, children: [
|
|
871
|
+
"</",
|
|
872
|
+
elementName,
|
|
873
|
+
">"
|
|
874
|
+
] })
|
|
875
|
+
] });
|
|
876
|
+
}
|
|
877
|
+
);
|
|
878
|
+
XmlNode.displayName = "XmlNode";
|
|
774
879
|
export {
|
|
775
880
|
Blockquote,
|
|
776
881
|
Body,
|
|
@@ -803,5 +908,6 @@ export {
|
|
|
803
908
|
Vimeo,
|
|
804
909
|
VimeoPlayButton,
|
|
805
910
|
VimeoPreviewImage,
|
|
806
|
-
VimeoSpinner
|
|
911
|
+
VimeoSpinner,
|
|
912
|
+
XmlNode
|
|
807
913
|
};
|