demoway-sdk
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -0,1 +1,4 @@ | ||
export interface IDemoDialogOptions { | ||
zIndex?: number; | ||
} | ||
export interface IDemoDialog { | ||
@@ -5,2 +8,2 @@ demoId: string; | ||
} | ||
export declare function openDemoDialog(demoId: string): IDemoDialog; | ||
export declare function openDemoDialog(demoId: string, options?: IDemoDialogOptions): IDemoDialog; |
297
dist/sdk.js
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".demo-dialog-overlay.svelte-170r52r{position:fixed;width:100vw;height:100vh;display:flex;align-items:center;justify-content:center;top:0;left:0;background-color:#ffffffb3}.demo-dialog-container.svelte-170r52r{width:80%;height:80%;overflow:visible;position:relative}.demo-dialog-content.svelte-170r52r{border:none}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})(); | ||
var P = Object.defineProperty; | ||
var B = (e, t, n) => t in e ? P(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n; | ||
var C = (e, t, n) => (B(e, typeof t != "symbol" ? t + "" : t, n), n); | ||
let I = null; | ||
function F(e) { | ||
I = e; | ||
var B = Object.defineProperty; | ||
var F = (e, t, n) => t in e ? B(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n; | ||
var C = (e, t, n) => (F(e, typeof t != "symbol" ? t + "" : t, n), n); | ||
let z = null; | ||
function M(e) { | ||
z = e; | ||
} | ||
function M() { | ||
if (!I) | ||
function U() { | ||
if (!z) | ||
throw new Error("sdk is not initialized"); | ||
return I; | ||
return z; | ||
} | ||
@@ -22,3 +22,3 @@ function g() { | ||
} | ||
function b(e) { | ||
function $(e) { | ||
e.forEach(q); | ||
@@ -29,19 +29,19 @@ } | ||
} | ||
function U(e, t) { | ||
function G(e, t) { | ||
return e != e ? t == t : e !== t || e && typeof e == "object" || typeof e == "function"; | ||
} | ||
let v; | ||
let x; | ||
function A(e, t) { | ||
return v || (v = document.createElement("a")), v.href = t, e === v.href; | ||
return x || (x = document.createElement("a")), x.href = t, e === x.href; | ||
} | ||
function G(e) { | ||
function H(e) { | ||
return Object.keys(e).length === 0; | ||
} | ||
function H(e) { | ||
function J(e) { | ||
return e && S(e.destroy) ? e.destroy : g; | ||
} | ||
function j(e, t) { | ||
function P(e, t) { | ||
e.appendChild(t); | ||
} | ||
function J(e, t, n) { | ||
function K(e, t, n) { | ||
e.insertBefore(t, n || null); | ||
@@ -55,33 +55,36 @@ } | ||
} | ||
function K(e, t, n, o) { | ||
function Q(e, t, n, o) { | ||
return e.addEventListener(t, n, o), () => e.removeEventListener(t, n, o); | ||
} | ||
function f(e, t, n) { | ||
function a(e, t, n) { | ||
n == null ? e.removeAttribute(t) : e.getAttribute(t) !== n && e.setAttribute(t, n); | ||
} | ||
function Q(e) { | ||
function V(e) { | ||
return Array.from(e.childNodes); | ||
} | ||
function V(e, t, { bubbles: n = !1, cancelable: o = !1 } = {}) { | ||
function j(e, t, n, o) { | ||
n === null ? e.style.removeProperty(t) : e.style.setProperty(t, n, o ? "important" : ""); | ||
} | ||
function W(e, t, { bubbles: n = !1, cancelable: o = !1 } = {}) { | ||
const r = document.createEvent("CustomEvent"); | ||
return r.initCustomEvent(e, n, o, t), r; | ||
} | ||
let $; | ||
function y(e) { | ||
$ = e; | ||
let k; | ||
function p(e) { | ||
k = e; | ||
} | ||
function W() { | ||
if (!$) | ||
function X() { | ||
if (!k) | ||
throw new Error("Function called outside component initialization"); | ||
return $; | ||
return k; | ||
} | ||
function X() { | ||
const e = W(); | ||
function Y() { | ||
const e = X(); | ||
return (t, n, { cancelable: o = !1 } = {}) => { | ||
const r = e.$$.callbacks[t]; | ||
if (r) { | ||
const i = V(t, n, { cancelable: o }); | ||
return r.slice().forEach((c) => { | ||
c.call(e, i); | ||
}), !i.defaultPrevented; | ||
const l = W(t, n, { cancelable: o }); | ||
return r.slice().forEach((u) => { | ||
u.call(e, l); | ||
}), !l.defaultPrevented; | ||
} | ||
@@ -93,6 +96,6 @@ return !0; | ||
let _ = []; | ||
const R = [], Y = /* @__PURE__ */ Promise.resolve(); | ||
const R = [], Z = /* @__PURE__ */ Promise.resolve(); | ||
let T = !1; | ||
function Z() { | ||
T || (T = !0, Y.then(w)); | ||
function ee() { | ||
T || (T = !0, Z.then(b)); | ||
} | ||
@@ -102,8 +105,8 @@ function D(e) { | ||
} | ||
const x = /* @__PURE__ */ new Set(); | ||
const I = /* @__PURE__ */ new Set(); | ||
let h = 0; | ||
function w() { | ||
function b() { | ||
if (h !== 0) | ||
return; | ||
const e = $; | ||
const e = k; | ||
do { | ||
@@ -113,3 +116,3 @@ try { | ||
const t = m[h]; | ||
h++, y(t), ee(t.$$); | ||
h++, p(t), te(t.$$); | ||
} | ||
@@ -119,7 +122,7 @@ } catch (t) { | ||
} | ||
for (y(null), m.length = 0, h = 0; N.length; ) | ||
for (p(null), m.length = 0, h = 0; N.length; ) | ||
N.pop()(); | ||
for (let t = 0; t < _.length; t += 1) { | ||
const n = _[t]; | ||
x.has(n) || (x.add(n), n()); | ||
I.has(n) || (I.add(n), n()); | ||
} | ||
@@ -130,7 +133,7 @@ _.length = 0; | ||
R.pop()(); | ||
T = !1, x.clear(), y(e); | ||
T = !1, I.clear(), p(e); | ||
} | ||
function ee(e) { | ||
function te(e) { | ||
if (e.fragment !== null) { | ||
e.update(), b(e.before_update); | ||
e.update(), $(e.before_update); | ||
const t = e.dirty; | ||
@@ -140,27 +143,27 @@ e.dirty = [-1], e.fragment && e.fragment.p(e.ctx, t), e.after_update.forEach(D); | ||
} | ||
function te(e) { | ||
function ne(e) { | ||
const t = [], n = []; | ||
_.forEach((o) => e.indexOf(o) === -1 ? t.push(o) : n.push(o)), n.forEach((o) => o()), _ = t; | ||
} | ||
const ne = /* @__PURE__ */ new Set(); | ||
function oe(e, t) { | ||
e && e.i && (ne.delete(e), e.i(t)); | ||
const oe = /* @__PURE__ */ new Set(); | ||
function re(e, t) { | ||
e && e.i && (oe.delete(e), e.i(t)); | ||
} | ||
function re(e, t, n, o) { | ||
const { fragment: r, after_update: i } = e.$$; | ||
function se(e, t, n, o) { | ||
const { fragment: r, after_update: l } = e.$$; | ||
r && r.m(t, n), o || D(() => { | ||
const c = e.$$.on_mount.map(q).filter(S); | ||
e.$$.on_destroy ? e.$$.on_destroy.push(...c) : b(c), e.$$.on_mount = []; | ||
}), i.forEach(D); | ||
const u = e.$$.on_mount.map(q).filter(S); | ||
e.$$.on_destroy ? e.$$.on_destroy.push(...u) : $(u), e.$$.on_mount = []; | ||
}), l.forEach(D); | ||
} | ||
function se(e, t) { | ||
function ce(e, t) { | ||
const n = e.$$; | ||
n.fragment !== null && (te(n.after_update), b(n.on_destroy), n.fragment && n.fragment.d(t), n.on_destroy = n.fragment = null, n.ctx = []); | ||
n.fragment !== null && (ne(n.after_update), $(n.on_destroy), n.fragment && n.fragment.d(t), n.on_destroy = n.fragment = null, n.ctx = []); | ||
} | ||
function ce(e, t) { | ||
e.$$.dirty[0] === -1 && (m.push(e), Z(), e.$$.dirty.fill(0)), e.$$.dirty[t / 31 | 0] |= 1 << t % 31; | ||
function ie(e, t) { | ||
e.$$.dirty[0] === -1 && (m.push(e), ee(), e.$$.dirty.fill(0)), e.$$.dirty[t / 31 | 0] |= 1 << t % 31; | ||
} | ||
function ie(e, t, n, o, r, i, c, l = [-1]) { | ||
const u = $; | ||
y(e); | ||
function le(e, t, n, o, r, l, u, c = [-1]) { | ||
const i = k; | ||
p(e); | ||
const s = e.$$ = { | ||
@@ -170,3 +173,3 @@ fragment: null, | ||
// state | ||
props: i, | ||
props: l, | ||
update: g, | ||
@@ -181,27 +184,27 @@ not_equal: r, | ||
after_update: [], | ||
context: new Map(t.context || (u ? u.$$.context : [])), | ||
context: new Map(t.context || (i ? i.$$.context : [])), | ||
// everything else | ||
callbacks: O(), | ||
dirty: l, | ||
dirty: c, | ||
skip_bound: !1, | ||
root: t.target || u.$$.root | ||
root: t.target || i.$$.root | ||
}; | ||
c && c(s.root); | ||
let p = !1; | ||
if (s.ctx = n ? n(e, t.props || {}, (a, k, ...d) => { | ||
const z = d.length ? d[0] : k; | ||
return s.ctx && r(s.ctx[a], s.ctx[a] = z) && (!s.skip_bound && s.bound[a] && s.bound[a](z), p && ce(e, a)), k; | ||
}) : [], s.update(), p = !0, b(s.before_update), s.fragment = o ? o(s.ctx) : !1, t.target) { | ||
u && u(s.root); | ||
let y = !1; | ||
if (s.ctx = n ? n(e, t.props || {}, (d, w, ...v) => { | ||
const f = v.length ? v[0] : w; | ||
return s.ctx && r(s.ctx[d], s.ctx[d] = f) && (!s.skip_bound && s.bound[d] && s.bound[d](f), y && ie(e, d)), w; | ||
}) : [], s.update(), y = !0, $(s.before_update), s.fragment = o ? o(s.ctx) : !1, t.target) { | ||
if (t.hydrate) { | ||
const a = Q(t.target); | ||
s.fragment && s.fragment.l(a), a.forEach(L); | ||
const d = V(t.target); | ||
s.fragment && s.fragment.l(d), d.forEach(L); | ||
} else | ||
s.fragment && s.fragment.c(); | ||
t.intro && oe(e.$$.fragment), re(e, t.target, t.anchor, t.customElement), w(); | ||
t.intro && re(e.$$.fragment), se(e, t.target, t.anchor, t.customElement), b(); | ||
} | ||
y(u); | ||
p(i); | ||
} | ||
class le { | ||
class ue { | ||
$destroy() { | ||
se(this, 1), this.$destroy = g; | ||
ce(this, 1), this.$destroy = g; | ||
} | ||
@@ -218,6 +221,6 @@ $on(t, n) { | ||
$set(t) { | ||
this.$$set && !G(t) && (this.$$.skip_bound = !0, this.$$set(t), this.$$.skip_bound = !1); | ||
this.$$set && !H(t) && (this.$$.skip_bound = !0, this.$$set(t), this.$$.skip_bound = !1); | ||
} | ||
} | ||
const ue = (e, t) => { | ||
const fe = (e, t) => { | ||
const n = new ResizeObserver(() => { | ||
@@ -232,105 +235,133 @@ const o = e.getBoundingClientRect(); | ||
}; | ||
}, fe = "https://demoway.co"; | ||
function ae(e) { | ||
let t, n, o, r, i, c; | ||
}, ae = "https://demoway.co"; | ||
function de(e) { | ||
let t, n, o, r, l, u; | ||
return { | ||
c() { | ||
t = E("div"), n = E("div"), o = E("iframe"), f(o, "class", "demo-dialog-content svelte-170r52r"), f( | ||
t = E("div"), n = E("div"), o = E("iframe"), a(o, "class", "demo-dialog-content svelte-170r52r"), a( | ||
o, | ||
"width", | ||
/*width*/ | ||
e[1] | ||
), f( | ||
e[2] | ||
), a( | ||
o, | ||
"height", | ||
/*height*/ | ||
e[2] | ||
), f(o, "title", "demo"), A(o.src, r = /*src*/ | ||
e[0]) || f(o, "src", r), o.allowFullscreen = !0, f(o, "allowtransparency", "true"), f(n, "class", "demo-dialog-container svelte-170r52r"), f(t, "class", "demo-dialog-overlay svelte-170r52r"), f(t, "role", "button"); | ||
e[3] | ||
), a(o, "title", "demo"), A(o.src, r = /*src*/ | ||
e[1]) || a(o, "src", r), o.allowFullscreen = !0, a(o, "allowtransparency", "true"), a(n, "class", "demo-dialog-container svelte-170r52r"), a(t, "class", "demo-dialog-overlay svelte-170r52r"), a(t, "role", "button"), j( | ||
t, | ||
"z-index", | ||
/*zIndex*/ | ||
e[0] | ||
); | ||
}, | ||
m(l, u) { | ||
J(l, t, u), j(t, n), j(n, o), i || (c = [ | ||
H(ue.call( | ||
m(c, i) { | ||
K(c, t, i), P(t, n), P(n, o), l || (u = [ | ||
J(fe.call( | ||
null, | ||
n, | ||
/*onResize*/ | ||
e[3] | ||
e[4] | ||
)), | ||
K( | ||
Q( | ||
t, | ||
"click", | ||
/*onClose*/ | ||
e[4] | ||
e[5] | ||
) | ||
], i = !0); | ||
], l = !0); | ||
}, | ||
p(l, [u]) { | ||
u & /*width*/ | ||
2 && f( | ||
p(c, [i]) { | ||
i & /*width*/ | ||
4 && a( | ||
o, | ||
"width", | ||
/*width*/ | ||
l[1] | ||
), u & /*height*/ | ||
4 && f( | ||
c[2] | ||
), i & /*height*/ | ||
8 && a( | ||
o, | ||
"height", | ||
/*height*/ | ||
l[2] | ||
), u & /*src*/ | ||
1 && !A(o.src, r = /*src*/ | ||
l[0]) && f(o, "src", r); | ||
c[3] | ||
), i & /*src*/ | ||
2 && !A(o.src, r = /*src*/ | ||
c[1]) && a(o, "src", r), i & /*zIndex*/ | ||
1 && j( | ||
t, | ||
"z-index", | ||
/*zIndex*/ | ||
c[0] | ||
); | ||
}, | ||
i: g, | ||
o: g, | ||
d(l) { | ||
l && L(t), i = !1, b(c); | ||
d(c) { | ||
c && L(t), l = !1, $(u); | ||
} | ||
}; | ||
} | ||
function de(e, t, n) { | ||
const o = X(); | ||
let { demoId: r = "" } = t, { accessToken: i = "" } = t; | ||
function he(e, t, n) { | ||
const o = Y(); | ||
let { demoId: r = "" } = t, { accessToken: l = "" } = t, { zIndex: u } = t; | ||
const c = new URLSearchParams(); | ||
c.set("browser", String(!0)), c.set("scale", String(100)); | ||
let l = "", u = "", s = 0, p = 0; | ||
function a(d) { | ||
n(1, s = d.width), n(2, p = d.height); | ||
let i = "", s = "", y = 0, d = 0; | ||
function w(f) { | ||
n(2, y = f.width), n(3, d = f.height); | ||
} | ||
function k() { | ||
function v() { | ||
o("close", void 0); | ||
} | ||
return e.$$set = (d) => { | ||
"demoId" in d && n(5, r = d.demoId), "accessToken" in d && n(6, i = d.accessToken); | ||
return e.$$set = (f) => { | ||
"demoId" in f && n(6, r = f.demoId), "accessToken" in f && n(7, l = f.accessToken), "zIndex" in f && n(0, u = f.zIndex); | ||
}, e.$$.update = () => { | ||
e.$$.dirty & /*accessToken*/ | ||
64 && (c.set("access_token", i), n(7, l = c.toString())), e.$$.dirty & /*demoId, queryString*/ | ||
160 && n(0, u = `${fe}/demo/${r}?${l}`); | ||
}, [u, s, p, a, k, r, i, l]; | ||
128 && (c.set("access_token", l), n(8, i = c.toString())), e.$$.dirty & /*demoId, queryString*/ | ||
320 && n(1, s = `${ae}/demo/${r}?${i}`); | ||
}, [ | ||
u, | ||
s, | ||
y, | ||
d, | ||
w, | ||
v, | ||
r, | ||
l, | ||
i | ||
]; | ||
} | ||
class he extends le { | ||
class me extends ue { | ||
constructor(t) { | ||
super(), ie(this, t, de, ae, U, { demoId: 5, accessToken: 6 }); | ||
super(), le(this, t, he, de, G, { demoId: 6, accessToken: 7, zIndex: 0 }); | ||
} | ||
get demoId() { | ||
return this.$$.ctx[5]; | ||
return this.$$.ctx[6]; | ||
} | ||
set demoId(t) { | ||
this.$$set({ demoId: t }), w(); | ||
this.$$set({ demoId: t }), b(); | ||
} | ||
get accessToken() { | ||
return this.$$.ctx[6]; | ||
return this.$$.ctx[7]; | ||
} | ||
set accessToken(t) { | ||
this.$$set({ accessToken: t }), w(); | ||
this.$$set({ accessToken: t }), b(); | ||
} | ||
get zIndex() { | ||
return this.$$.ctx[0]; | ||
} | ||
set zIndex(t) { | ||
this.$$set({ zIndex: t }), b(); | ||
} | ||
} | ||
class me { | ||
constructor(t) { | ||
class _e { | ||
constructor(t, { zIndex: n = 10100 }) { | ||
C(this, "component"); | ||
this.component = new he({ | ||
this.component = new me({ | ||
target: document.body, | ||
props: { | ||
demoId: t, | ||
accessToken: M() | ||
accessToken: U(), | ||
zIndex: n | ||
} | ||
@@ -354,11 +385,11 @@ }), this.component.$on("close", () => { | ||
} | ||
function ge(e) { | ||
return new me(e); | ||
function ye(e, t = {}) { | ||
return new _e(e, t); | ||
} | ||
function pe({ accessToken: e }) { | ||
F(e); | ||
M(e); | ||
} | ||
export { | ||
pe as initialize, | ||
ge as openDemoDialog | ||
ye as openDemoDialog | ||
}; |
{ | ||
"name": "demoway-sdk", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"type": "module", | ||
@@ -26,3 +26,4 @@ "files": [ | ||
"storybook": "storybook dev -p 6006", | ||
"build-storybook": "storybook build" | ||
"build-storybook": "storybook build", | ||
"prepublishOnly": "npm run build" | ||
}, | ||
@@ -29,0 +30,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
23696
452