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