ublo-lib 1.31.38 → 1.31.40
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.
|
@@ -7,30 +7,19 @@ function Tunnel({
|
|
|
7
7
|
presets,
|
|
8
8
|
children
|
|
9
9
|
}) {
|
|
10
|
-
const [widgetOptions, setWidgetOptions] = React.useState(options);
|
|
11
|
-
const [widgetPresets, setWidgetPresets] = React.useState(presets);
|
|
12
|
-
const [started, setStarted] = React.useState(false);
|
|
13
10
|
React.useEffect(() => {
|
|
14
|
-
|
|
15
|
-
setWidgetPresets(presets);
|
|
16
|
-
setStarted(false);
|
|
17
|
-
}, [options, presets]);
|
|
18
|
-
React.useEffect(() => {
|
|
19
|
-
const lang = widgetOptions?.lang === "fr" ? "fr" : "en";
|
|
11
|
+
const lang = options?.lang === "fr" ? "fr" : "en";
|
|
20
12
|
const categoryCode = window.sessionStorage.getItem("categoryCode") || undefined;
|
|
21
13
|
const patchedOptions = {
|
|
22
|
-
...
|
|
14
|
+
...options,
|
|
23
15
|
lang,
|
|
24
16
|
categoryCode,
|
|
25
17
|
analytics: (...args) => {
|
|
26
|
-
|
|
18
|
+
options?.analytics?.apply(null, args);
|
|
27
19
|
Plausible.callback.apply(null, args);
|
|
28
20
|
}
|
|
29
21
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
setStarted(true);
|
|
33
|
-
}
|
|
34
|
-
}, [widgetOptions, widgetPresets, started]);
|
|
22
|
+
Utils.loadWidget("tunnel", patchedOptions, presets);
|
|
23
|
+
}, [options, presets]);
|
|
35
24
|
return children;
|
|
36
25
|
}
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
export function loadWidget(widget, options = {}, presets = {}) {
|
|
2
|
+
const isGroundedTo = ("groundedTo" in options);
|
|
2
3
|
if (window.MseMLoaded) {
|
|
3
|
-
window.
|
|
4
|
+
window.MseM?.onLoad(() => {
|
|
5
|
+
if (isGroundedTo) {
|
|
6
|
+
const container = document.querySelector(options.groundedTo);
|
|
7
|
+
try {
|
|
8
|
+
container.unmount();
|
|
9
|
+
} catch {}
|
|
10
|
+
}
|
|
11
|
+
window.MseM[widget](options, presets);
|
|
12
|
+
});
|
|
4
13
|
} else {
|
|
5
14
|
setTimeout(() => {
|
|
6
|
-
const isGroundedTo = ("groundedTo" in options);
|
|
7
15
|
if (isGroundedTo) {
|
|
8
16
|
const selector = options.groundedTo;
|
|
9
17
|
const widgetStillHasTarget = document.querySelector(selector);
|