move sdk packages to its own folder and rename api & dashboard
This commit is contained in:
31
packages/sdks/web/cdn.ts
Normal file
31
packages/sdks/web/cdn.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { MixanWeb as Openpanel } from './index';
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
op: {
|
||||
q?: [string, ...any[]];
|
||||
(method: string, ...args: any[]): void;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
((window) => {
|
||||
if (window.op && 'q' in window.op) {
|
||||
const queue = window.op.q || [];
|
||||
const op = new Openpanel(queue.shift()[1]);
|
||||
queue.forEach((item) => {
|
||||
if (item[0] in op) {
|
||||
// @ts-expect-error
|
||||
op[item[0]](...item.slice(1));
|
||||
}
|
||||
});
|
||||
|
||||
window.op = (t, ...args) => {
|
||||
// @ts-expect-error
|
||||
const fn = op[t].bind(op);
|
||||
if (typeof fn === 'function') {
|
||||
fn(...args);
|
||||
}
|
||||
};
|
||||
}
|
||||
})(window);
|
||||
Reference in New Issue
Block a user