samandesk 1.0.15 → 1.0.16
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 +0 -2
- package/dist/index.d.ts +0 -4
- package/dist/saman-desk.js +47 -65
- package/dist/saman-desk.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/data.d.ts
CHANGED
|
@@ -24,6 +24,4 @@ export declare function getFrame(): HTMLIFrameElement;
|
|
|
24
24
|
export declare function getTheme(): "light" | "dark" | undefined;
|
|
25
25
|
/** تم جدید کتابخانه را تنظیم میکند */
|
|
26
26
|
export declare function setTheme(newTheme: 'light' | 'dark'): void;
|
|
27
|
-
/** عنصر بکدراپ را برمیگرداند */
|
|
28
|
-
export declare function getBackdrop(): HTMLDivElement;
|
|
29
27
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -22,10 +22,6 @@ export interface OpenConfig {
|
|
|
22
22
|
theme?: 'light' | 'dark';
|
|
23
23
|
}
|
|
24
24
|
export declare class SamanDesk {
|
|
25
|
-
/**
|
|
26
|
-
* شیء کلاس InterOperation
|
|
27
|
-
*/
|
|
28
|
-
private interoperation?;
|
|
29
25
|
/**
|
|
30
26
|
* این تابع در ابتدا مقدار verifiedToken را دریافت کرده و سپس مقدار token را دریافت و سپس آن را ذخیره میکند
|
|
31
27
|
*/
|
package/dist/saman-desk.js
CHANGED
|
@@ -1,48 +1,45 @@
|
|
|
1
|
+
let m;
|
|
2
|
+
const a = document.createElement("iframe");
|
|
1
3
|
let p;
|
|
2
|
-
const
|
|
3
|
-
let u;
|
|
4
|
-
const h = document.createElement("div"), f = {
|
|
4
|
+
const u = {
|
|
5
5
|
count: 0,
|
|
6
6
|
promises: {}
|
|
7
7
|
};
|
|
8
|
-
function
|
|
9
|
-
return
|
|
10
|
-
}
|
|
11
|
-
function b(n) {
|
|
12
|
-
p = n;
|
|
8
|
+
function f() {
|
|
9
|
+
return u;
|
|
13
10
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
11
|
+
function h(n) {
|
|
12
|
+
m = n;
|
|
16
13
|
}
|
|
17
|
-
function
|
|
18
|
-
|
|
14
|
+
function g() {
|
|
15
|
+
return m;
|
|
19
16
|
}
|
|
20
|
-
function
|
|
21
|
-
|
|
17
|
+
function c() {
|
|
18
|
+
a.src = "";
|
|
22
19
|
}
|
|
23
|
-
function
|
|
24
|
-
|
|
20
|
+
function d(n) {
|
|
21
|
+
a.src = n;
|
|
25
22
|
}
|
|
26
|
-
function
|
|
27
|
-
return
|
|
23
|
+
function r() {
|
|
24
|
+
return a;
|
|
28
25
|
}
|
|
29
|
-
function
|
|
30
|
-
|
|
26
|
+
function w() {
|
|
27
|
+
return p;
|
|
31
28
|
}
|
|
32
|
-
function
|
|
33
|
-
|
|
29
|
+
function y(n) {
|
|
30
|
+
p = n;
|
|
34
31
|
}
|
|
35
|
-
const
|
|
36
|
-
function
|
|
37
|
-
return
|
|
32
|
+
const E = new Event("ready"), x = new Event("open"), v = new Event("close");
|
|
33
|
+
function k() {
|
|
34
|
+
return E;
|
|
38
35
|
}
|
|
39
|
-
function
|
|
36
|
+
function b() {
|
|
40
37
|
return x;
|
|
41
38
|
}
|
|
42
|
-
function
|
|
39
|
+
function S() {
|
|
43
40
|
return v;
|
|
44
41
|
}
|
|
45
|
-
function
|
|
42
|
+
function T(n) {
|
|
46
43
|
window.addEventListener("message", (e) => {
|
|
47
44
|
if (!e.data.from || e.data.from !== "SamanDesk")
|
|
48
45
|
return;
|
|
@@ -53,43 +50,41 @@ function O(n) {
|
|
|
53
50
|
} catch {
|
|
54
51
|
console.error("error while run event action");
|
|
55
52
|
}
|
|
56
|
-
const o = e.data,
|
|
57
|
-
|
|
53
|
+
const o = e.data, i = o.id, s = f();
|
|
54
|
+
i in s.promises ? (s.promises[i](o), delete s.promises[i]) : t || console.error("Message from outside of frame is invalid");
|
|
58
55
|
});
|
|
59
56
|
}
|
|
60
|
-
function
|
|
57
|
+
function O(n, e, t) {
|
|
61
58
|
var s;
|
|
62
59
|
const o = { from: "SamanDesk", action: t, data: e, id: n };
|
|
63
|
-
(s =
|
|
60
|
+
(s = r().contentWindow) == null || s.postMessage(o, "*");
|
|
64
61
|
}
|
|
65
|
-
class
|
|
62
|
+
class R {
|
|
66
63
|
async init() {
|
|
67
|
-
|
|
64
|
+
T(this);
|
|
68
65
|
}
|
|
69
66
|
/** توکن را از میزبان دریافت کرده و آن را ذخیره میکند. سپس به میزبان اعلام میکند که آمادهی ادامهی کار است */
|
|
70
67
|
setToken(e) {
|
|
71
|
-
|
|
68
|
+
h(e.data.token), c(), window.dispatchEvent(k());
|
|
72
69
|
}
|
|
73
70
|
/** بستن کتابخانه */
|
|
74
71
|
close() {
|
|
75
|
-
|
|
76
|
-
const e = a();
|
|
77
|
-
document.body.removeChild(e), e.onclick = null, document.body.removeChild(i()), window.dispatchEvent(T());
|
|
72
|
+
c(), document.body.removeChild(r()), window.dispatchEvent(S());
|
|
78
73
|
}
|
|
79
74
|
/** تم کتابخانه را به بیرون اطلاع میدهد */
|
|
80
75
|
getTheme(e) {
|
|
81
|
-
|
|
76
|
+
O(e.id, { theme: w() }, e.action);
|
|
82
77
|
}
|
|
83
78
|
}
|
|
84
|
-
const
|
|
85
|
-
class
|
|
79
|
+
const l = "http://localhost:2525";
|
|
80
|
+
class C {
|
|
86
81
|
/**
|
|
87
82
|
* این تابع در ابتدا مقدار verifiedToken را دریافت کرده و سپس مقدار token را دریافت و سپس آن را ذخیره میکند
|
|
88
83
|
*/
|
|
89
84
|
async init(e) {
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
|
|
85
|
+
new R().init();
|
|
86
|
+
const o = r();
|
|
87
|
+
d(`${l}/setup-interoperation/${e}`), o.width = "0", o.style.width = "0", document.body.appendChild(o);
|
|
93
88
|
}
|
|
94
89
|
/**
|
|
95
90
|
* استایل مربوط به آیفریم را تنظیم میکند
|
|
@@ -98,18 +93,8 @@ class $ {
|
|
|
98
93
|
*
|
|
99
94
|
*/
|
|
100
95
|
setStyle(e) {
|
|
101
|
-
const t =
|
|
102
|
-
t.style.position = "fixed", t.style.zIndex = "1000"
|
|
103
|
-
const r = {
|
|
104
|
-
position: "fixed",
|
|
105
|
-
top: "0",
|
|
106
|
-
bottom: "0",
|
|
107
|
-
left: "0",
|
|
108
|
-
right: "0",
|
|
109
|
-
backgroundColor: "rgba(0,0,0,0.5)",
|
|
110
|
-
zIndex: "1000"
|
|
111
|
-
};
|
|
112
|
-
Object.assign(o.style, r), e ? (Object.assign(t.style, {
|
|
96
|
+
const t = r();
|
|
97
|
+
t.style.position = "fixed", t.style.zIndex = "1000", e ? (Object.assign(t.style, {
|
|
113
98
|
bottom: "0",
|
|
114
99
|
left: "0",
|
|
115
100
|
top: "0",
|
|
@@ -119,7 +104,7 @@ class $ {
|
|
|
119
104
|
left: "50%",
|
|
120
105
|
transform: "translate(-50%, -50%)",
|
|
121
106
|
width: "100%",
|
|
122
|
-
maxWidth: "
|
|
107
|
+
maxWidth: "450px",
|
|
123
108
|
boxShadow: "0px 0px 100px 0px rgba(0,0,0,0.48)",
|
|
124
109
|
borderRadius: "24px",
|
|
125
110
|
height: "100%",
|
|
@@ -130,15 +115,12 @@ class $ {
|
|
|
130
115
|
* این تابع آیفریم را باز میکند.
|
|
131
116
|
*/
|
|
132
117
|
open(e) {
|
|
133
|
-
const t =
|
|
134
|
-
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
var s;
|
|
138
|
-
(s = this.interoperation) == null || s.close();
|
|
139
|
-
}, window.dispatchEvent(C());
|
|
118
|
+
const t = r();
|
|
119
|
+
y(e.theme ?? "light");
|
|
120
|
+
const o = e.link || `${l}/department-selection?token=${g()}`;
|
|
121
|
+
d(o), this.setStyle(e.fullScreen), document.body.appendChild(t), window.dispatchEvent(b());
|
|
140
122
|
}
|
|
141
123
|
}
|
|
142
124
|
export {
|
|
143
|
-
|
|
125
|
+
C as SamanDesk
|
|
144
126
|
};
|
package/dist/saman-desk.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(s,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(s=typeof globalThis<"u"?globalThis:s||self,i(s.SamanDesk={}))})(this,function(s){"use strict";let i;const d=document.createElement("iframe");let l;const p={count:0,promises:{}};function h(){return p}function g(n){i=n}function y(){return i}function f(){d.src=""}function m(n){d.src=n}function a(){return d}function w(){return l}function E(n){l=n}const x=new Event("ready"),v=new Event("open"),S=new Event("close");function b(){return x}function k(){return v}function T(){return S}function D(n){window.addEventListener("message",e=>{if(!e.data.from||e.data.from!=="SamanDesk")return;let t=!1;console.log(`message from (${e.origin})`,e);try{n[e.data.action](e.data),t=!0}catch{console.error("error while run event action")}const o=e.data,c=o.id,r=h();c in r.promises?(r.promises[c](o),delete r.promises[c]):t||console.error("Message from outside of frame is invalid")})}function O(n,e,t){var r;const o={from:"SamanDesk",action:t,data:e,id:n};(r=a().contentWindow)==null||r.postMessage(o,"*")}class R{async init(){D(this)}setToken(e){g(e.data.token),f(),window.dispatchEvent(b())}close(){f(),document.body.removeChild(a()),window.dispatchEvent(T())}getTheme(e){O(e.id,{theme:w()},e.action)}}const u="http://localhost:2525";class ${async init(e){new R().init();const o=a();m(`${u}/setup-interoperation/${e}`),o.width="0",o.style.width="0",document.body.appendChild(o)}setStyle(e){const t=a();t.style.position="fixed",t.style.zIndex="1000",e?(Object.assign(t.style,{bottom:"0",left:"0",top:"0",right:"0"}),t.width="100%",t.height="100%"):Object.assign(t.style,{top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"100%",maxWidth:"450px",boxShadow:"0px 0px 100px 0px rgba(0,0,0,0.48)",borderRadius:"24px",height:"100%",maxHeight:"660px"})}open(e){const t=a();E(e.theme??"light");const o=e.link||`${u}/department-selection?token=${y()}`;m(o),this.setStyle(e.fullScreen),document.body.appendChild(t),window.dispatchEvent(k())}}s.SamanDesk=$,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
|