samandesk 1.0.5 → 1.0.7
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/dist/data.d.ts +2 -0
- package/dist/saman-desk.js +30 -27
- package/dist/saman-desk.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/data.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export declare function setToken(newToken: string): void;
|
|
|
16
16
|
export declare function getToken(): string | undefined;
|
|
17
17
|
/** تگ iframe را حذف میکند */
|
|
18
18
|
export declare function clearFrame(): void;
|
|
19
|
+
/** مقدار src تگ iframe را براساس ورودی تنظیم میکند */
|
|
20
|
+
export declare function setFrameSrc(src: string): void;
|
|
19
21
|
/** تگ iframe را بر میگرداند */
|
|
20
22
|
export declare function getFrame(): HTMLIFrameElement;
|
|
21
23
|
export {};
|
package/dist/saman-desk.js
CHANGED
|
@@ -1,63 +1,66 @@
|
|
|
1
|
-
let
|
|
2
|
-
const i = document.createElement("iframe"),
|
|
1
|
+
let d;
|
|
2
|
+
const i = document.createElement("iframe"), l = {
|
|
3
3
|
count: 0,
|
|
4
4
|
promises: {}
|
|
5
5
|
};
|
|
6
6
|
function m() {
|
|
7
|
-
return
|
|
7
|
+
return l;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
9
|
+
function p(t) {
|
|
10
|
+
d = t;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
return
|
|
12
|
+
function f() {
|
|
13
|
+
return d;
|
|
14
14
|
}
|
|
15
15
|
function u() {
|
|
16
16
|
i.src = "";
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function c(t) {
|
|
19
|
+
i.src = t;
|
|
20
|
+
}
|
|
21
|
+
function a() {
|
|
19
22
|
return i;
|
|
20
23
|
}
|
|
21
|
-
const
|
|
22
|
-
function
|
|
23
|
-
return
|
|
24
|
+
const h = new Event("ready");
|
|
25
|
+
function y() {
|
|
26
|
+
return h;
|
|
24
27
|
}
|
|
25
|
-
function
|
|
28
|
+
function x(t) {
|
|
26
29
|
window.addEventListener("message", (e) => {
|
|
27
30
|
if (!e.data.from || e.data.from !== "SamanDesk")
|
|
28
31
|
return;
|
|
32
|
+
let o = !1;
|
|
29
33
|
console.log(`message from (${e.origin})`, e);
|
|
30
34
|
try {
|
|
31
|
-
|
|
35
|
+
t[e.data.action](e.data.data), o = !0;
|
|
32
36
|
} catch {
|
|
33
37
|
console.error("error while run event action");
|
|
34
38
|
}
|
|
35
|
-
const n = e.data,
|
|
36
|
-
|
|
39
|
+
const n = e.data, s = n.id, r = m();
|
|
40
|
+
s in r.promises ? (r.promises[s](n), delete r.promises[s]) : o || console.error("Message from outside of frame is invalid");
|
|
37
41
|
});
|
|
38
42
|
}
|
|
39
|
-
class
|
|
43
|
+
class g {
|
|
40
44
|
async init() {
|
|
41
|
-
|
|
45
|
+
x(this);
|
|
42
46
|
}
|
|
43
47
|
/** توکن را از میزبان دریافت کرده و آن را ذخیره میکند. سپس به میزبان اعلام میکند که آمادهی ادامهی کار است */
|
|
44
48
|
setToken(e) {
|
|
45
|
-
|
|
49
|
+
p(e.token), u(), window.dispatchEvent(y());
|
|
46
50
|
}
|
|
47
51
|
}
|
|
48
|
-
class
|
|
52
|
+
class k {
|
|
49
53
|
/**
|
|
50
54
|
* این تابع در ابتدا مقدار verifiedToken را دریافت کرده و سپس مقدار token را دریافت و سپس آن را ذخیره میکند
|
|
51
55
|
*/
|
|
52
56
|
async init(e) {
|
|
53
|
-
|
|
54
|
-
n
|
|
55
|
-
|
|
56
|
-
t.src = `https://samandesk.com/setup-interoperation/${e}`, t.width = "0", document.body.appendChild(t);
|
|
57
|
+
new g().init();
|
|
58
|
+
const n = a();
|
|
59
|
+
c(`https://samandesk.com/setup-interoperation/${e}`), n.width = "0", document.body.appendChild(n);
|
|
57
60
|
}
|
|
58
61
|
/** استایل مربوط به آیفریم را تنظیم میکند */
|
|
59
62
|
setStyle() {
|
|
60
|
-
const e =
|
|
63
|
+
const e = a();
|
|
61
64
|
e.style.position = "fixed", e.style.bottom = "12px", e.style.left = "12px", e.style.boxShadow = "0px 0px 100px 0px rgba(0,0,0,0.48)", e.style.maxWidth = "500px", e.style.width = "100%", e.style.maxHeight = "640px", e.style.height = "100%", e.style.zIndex = "1000", e.style.borderRadius = "24px", e.width = "500px", e.height = "640px";
|
|
62
65
|
}
|
|
63
66
|
/**
|
|
@@ -67,10 +70,10 @@ class g {
|
|
|
67
70
|
* اگر لینک را در ورودی ارسال نکند، خودکار به صفحهی انتخاب دپارتمان میرویم و ادامهی کار توسط سامان دسک صورت میگیرد
|
|
68
71
|
*/
|
|
69
72
|
open(e) {
|
|
70
|
-
const
|
|
71
|
-
n
|
|
73
|
+
const o = a(), n = e || `https://samandesk.com/department-selection?token=${f()}`;
|
|
74
|
+
c(n), this.setStyle(), document.body.appendChild(o);
|
|
72
75
|
}
|
|
73
76
|
}
|
|
74
77
|
export {
|
|
75
|
-
|
|
78
|
+
k as SamanDesk
|
|
76
79
|
};
|
package/dist/saman-desk.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(o,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(o=typeof globalThis<"u"?globalThis:o||self,s(o.SamanDesk={}))})(this,function(o){"use strict";let s;const
|
|
1
|
+
(function(o,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(o=typeof globalThis<"u"?globalThis:o||self,s(o.SamanDesk={}))})(this,function(o){"use strict";let s;const r=document.createElement("iframe"),m={count:0,promises:{}};function p(){return m}function f(t){s=t}function u(){return s}function y(){r.src=""}function l(t){r.src=t}function a(){return r}const h=new Event("ready");function x(){return h}function g(t){window.addEventListener("message",e=>{if(!e.data.from||e.data.from!=="SamanDesk")return;let i=!1;console.log(`message from (${e.origin})`,e);try{t[e.data.action](e.data.data),i=!0}catch{console.error("error while run event action")}const n=e.data,d=n.id,c=p();d in c.promises?(c.promises[d](n),delete c.promises[d]):i||console.error("Message from outside of frame is invalid")})}class k{async init(){g(this)}setToken(e){f(e.token),y(),window.dispatchEvent(x())}}class w{async init(e){new k().init();const n=a();l(`https://samandesk.com/setup-interoperation/${e}`),n.width="0",document.body.appendChild(n)}setStyle(){const e=a();e.style.position="fixed",e.style.bottom="12px",e.style.left="12px",e.style.boxShadow="0px 0px 100px 0px rgba(0,0,0,0.48)",e.style.maxWidth="500px",e.style.width="100%",e.style.maxHeight="640px",e.style.height="100%",e.style.zIndex="1000",e.style.borderRadius="24px",e.width="500px",e.height="640px"}open(e){const i=a(),n=e||`https://samandesk.com/department-selection?token=${u()}`;l(n),this.setStyle(),document.body.appendChild(i)}}o.SamanDesk=w,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
|