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