obi-sdk 0.4.4 → 0.5.1
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/README.md +0 -1
- package/dist/core/constants.d.ts +1 -1
- package/dist/core/init.d.ts +1 -1
- package/dist/loader.d.ts +0 -1
- package/dist/modular/chunks/index-ade17481.js +6 -0
- package/dist/modular/chunks/index-ade17481.js.map +1 -0
- package/dist/modular/chunks/{obi-widget-f540f7e0.js → obi-widget-2b8e7b28.js} +520 -136
- package/dist/modular/chunks/obi-widget-2b8e7b28.js.map +1 -0
- package/dist/modular/chunks/{types-e0297e7b.js → types-fad85d8c.js} +2 -2
- package/dist/modular/chunks/types-fad85d8c.js.map +1 -0
- package/dist/modular/core.js +1 -1
- package/dist/modular/index.js +37 -52
- package/dist/modular/index.js.map +1 -1
- package/dist/modular/ui.js +11 -11
- package/dist/modular/ui.js.map +1 -1
- package/dist/obi-sdk.es.js +556 -185
- package/dist/obi-sdk.es.js.map +1 -1
- package/dist/obi-sdk.standalone.iife.js +360 -127
- package/dist/obi-sdk.standalone.iife.js.map +1 -1
- package/dist/obi-sdk.umd.js +347 -114
- package/dist/obi-sdk.umd.js.map +1 -1
- package/dist/ui/components/courses/course-modal.d.ts +3 -0
- package/dist/ui/components/courses/courses.d.ts +4 -2
- package/dist/ui/components/obi-widget/index.d.ts +1 -0
- package/dist/ui/components/{obi-widget.d.ts → obi-widget/obi-widget.d.ts} +11 -6
- package/dist/utils/color.d.ts +12 -0
- package/dist/utils/index.d.ts +1 -0
- package/package.json +11 -3
- package/dist/modular/chunks/obi-widget-f540f7e0.js.map +0 -1
- package/dist/modular/chunks/types-e0297e7b.js.map +0 -1
- package/dist/ui/components/session-start-modal/session-start-modal.stories.d.ts +0 -37
package/dist/modular/core.js
CHANGED
package/dist/modular/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { O as ObiWidget } from "./chunks/obi-widget-
|
|
2
|
-
import "./chunks/types-
|
|
1
|
+
import { O as ObiWidget } from "./chunks/obi-widget-2b8e7b28.js";
|
|
2
|
+
import "./chunks/types-fad85d8c.js";
|
|
3
3
|
const DEBUG_BUILD$2 = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
|
|
4
4
|
const SDK_VERSION = "9.23.0";
|
|
5
5
|
const GLOBAL_OBJ = globalThis;
|
|
@@ -5749,7 +5749,7 @@ async function retryOperation(operation, operationName, maxAttempts = RETRY_CONF
|
|
|
5749
5749
|
return await operation();
|
|
5750
5750
|
} catch (error) {
|
|
5751
5751
|
lastError = error;
|
|
5752
|
-
console.warn(
|
|
5752
|
+
console.warn(`[obi-sdk] ${operationName} failed (attempt ${attempt + 1}/${maxAttempts}):`, error);
|
|
5753
5753
|
if (attempt < maxAttempts - 1) {
|
|
5754
5754
|
const delayMs = getRetryDelay(attempt);
|
|
5755
5755
|
await delay(delayMs);
|
|
@@ -5760,8 +5760,9 @@ async function retryOperation(operation, operationName, maxAttempts = RETRY_CONF
|
|
|
5760
5760
|
}
|
|
5761
5761
|
function mountSDK() {
|
|
5762
5762
|
const w = window;
|
|
5763
|
+
let q = [];
|
|
5763
5764
|
if (typeof w.ObiSDK === "function" || typeof w.ObiSDK === "object") {
|
|
5764
|
-
|
|
5765
|
+
q = w.ObiSDK.q || [];
|
|
5765
5766
|
}
|
|
5766
5767
|
w.ObiSDK = function(command, config) {
|
|
5767
5768
|
if (command === "update" && config) {
|
|
@@ -5769,9 +5770,19 @@ function mountSDK() {
|
|
|
5769
5770
|
...w.obiWidgetConfig,
|
|
5770
5771
|
...config
|
|
5771
5772
|
};
|
|
5773
|
+
const widgets = document.querySelectorAll("obi-widget");
|
|
5774
|
+
widgets.forEach((widget) => {
|
|
5775
|
+
widget.dispatchEvent(
|
|
5776
|
+
new CustomEvent("obi-config-updated", {
|
|
5777
|
+
detail: config,
|
|
5778
|
+
bubbles: true,
|
|
5779
|
+
composed: true
|
|
5780
|
+
})
|
|
5781
|
+
);
|
|
5782
|
+
});
|
|
5772
5783
|
}
|
|
5773
5784
|
};
|
|
5774
|
-
w.ObiSDK.q =
|
|
5785
|
+
w.ObiSDK.q = q;
|
|
5775
5786
|
}
|
|
5776
5787
|
async function mountWidget() {
|
|
5777
5788
|
return retryOperation(async () => {
|
|
@@ -5783,20 +5794,14 @@ async function mountWidget() {
|
|
|
5783
5794
|
}
|
|
5784
5795
|
const widget = document.createElement("obi-widget");
|
|
5785
5796
|
document.body.appendChild(widget);
|
|
5786
|
-
console.log("
|
|
5787
|
-
}, "
|
|
5797
|
+
console.log("[obi-sdk] widget mounted");
|
|
5798
|
+
}, "widget mounting");
|
|
5788
5799
|
}
|
|
5789
5800
|
function processQueue() {
|
|
5790
5801
|
const w = window;
|
|
5791
5802
|
if (w.ObiSDK && Array.isArray(w.ObiSDK.q)) {
|
|
5792
|
-
w.ObiSDK.q.forEach((args) => {
|
|
5793
|
-
|
|
5794
|
-
if (command === "update" && config) {
|
|
5795
|
-
w.obiWidgetConfig = {
|
|
5796
|
-
...w.obiWidgetConfig,
|
|
5797
|
-
...config
|
|
5798
|
-
};
|
|
5799
|
-
}
|
|
5803
|
+
(w.ObiSDK.q || []).forEach((args) => {
|
|
5804
|
+
w.ObiSDK(...args);
|
|
5800
5805
|
});
|
|
5801
5806
|
w.ObiSDK.q = [];
|
|
5802
5807
|
}
|
|
@@ -5811,57 +5816,37 @@ async function loadFont(fontUrl) {
|
|
|
5811
5816
|
throw new Error("document.head not available");
|
|
5812
5817
|
}
|
|
5813
5818
|
const link = document.createElement("link");
|
|
5814
|
-
document.head.querySelectorAll("link[data-obi-font]").forEach((node) => node.remove());
|
|
5815
|
-
link.setAttribute("data-obi-font", "true");
|
|
5816
5819
|
link.href = fontUrl;
|
|
5817
5820
|
link.rel = "stylesheet";
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
reject(new Error("Font loading timeout"));
|
|
5821
|
-
}, 5e3);
|
|
5822
|
-
link.onload = () => {
|
|
5823
|
-
clearTimeout(timeout);
|
|
5824
|
-
resolve();
|
|
5825
|
-
};
|
|
5826
|
-
link.onerror = () => {
|
|
5827
|
-
clearTimeout(timeout);
|
|
5828
|
-
reject(new Error("Font loading failed"));
|
|
5829
|
-
};
|
|
5830
|
-
document.head.appendChild(link);
|
|
5831
|
-
});
|
|
5832
|
-
}, "Font loading");
|
|
5821
|
+
document.head.appendChild(link);
|
|
5822
|
+
}, "font loading");
|
|
5833
5823
|
}
|
|
5834
5824
|
async function safeInitialize() {
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
console.log("Obi Widget initialized successfully");
|
|
5841
|
-
} catch (error) {
|
|
5842
|
-
console.error("Obi Widget initialization failed:", error);
|
|
5843
|
-
try {
|
|
5844
|
-
mountSDK();
|
|
5845
|
-
processQueue();
|
|
5846
|
-
console.log("Obi Widget fallback initialization completed");
|
|
5847
|
-
} catch (fallbackError) {
|
|
5848
|
-
console.error("Obi Widget fallback initialization failed:", fallbackError);
|
|
5849
|
-
}
|
|
5850
|
-
}
|
|
5825
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
5826
|
+
mountSDK();
|
|
5827
|
+
await loadFonts();
|
|
5828
|
+
await mountWidget();
|
|
5829
|
+
processQueue();
|
|
5851
5830
|
}
|
|
5852
|
-
function initializeObiWidget() {
|
|
5831
|
+
async function initializeObiWidget() {
|
|
5853
5832
|
if (document.readyState === "loading") {
|
|
5854
|
-
document.addEventListener("DOMContentLoaded", () => {
|
|
5855
|
-
|
|
5833
|
+
document.addEventListener("DOMContentLoaded", async () => {
|
|
5834
|
+
try {
|
|
5835
|
+
await safeInitialize();
|
|
5836
|
+
} catch (error) {
|
|
5837
|
+
captureException(error);
|
|
5838
|
+
console.error("[obi-sdk] initialization failed:", error);
|
|
5839
|
+
}
|
|
5856
5840
|
});
|
|
5857
5841
|
} else {
|
|
5858
|
-
safeInitialize();
|
|
5842
|
+
await safeInitialize();
|
|
5859
5843
|
}
|
|
5860
5844
|
}
|
|
5861
5845
|
try {
|
|
5862
5846
|
initializeObiWidget();
|
|
5863
5847
|
} catch (error) {
|
|
5864
5848
|
captureException(error);
|
|
5849
|
+
console.error("[obi-sdk] initialization failed:", error);
|
|
5865
5850
|
}
|
|
5866
5851
|
export {
|
|
5867
5852
|
ObiWidget
|