samandesk 1.0.23 → 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 +15 -15
- package/dist/saman-desk.umd.cjs +1 -1
- package/dist/src/data.d.ts +1 -1
- package/package.json +1 -1
package/dist/saman-desk.js
CHANGED
|
@@ -20,7 +20,7 @@ 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
26
|
function w() {
|
|
@@ -39,13 +39,13 @@ function i() {
|
|
|
39
39
|
return g;
|
|
40
40
|
}
|
|
41
41
|
const C = new Event("ready"), D = new Event("open"), O = new Event("close");
|
|
42
|
-
function
|
|
42
|
+
function I() {
|
|
43
43
|
return C;
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function M() {
|
|
46
46
|
return D;
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function T() {
|
|
49
49
|
return O;
|
|
50
50
|
}
|
|
51
51
|
function R(n) {
|
|
@@ -59,14 +59,14 @@ function R(n) {
|
|
|
59
59
|
} catch {
|
|
60
60
|
console.error("error while run event action");
|
|
61
61
|
}
|
|
62
|
-
const o = e.data, a = o.id,
|
|
63
|
-
a in
|
|
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");
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
function $(n, e, t) {
|
|
67
|
-
var
|
|
67
|
+
var r;
|
|
68
68
|
const o = { from: "SamanDesk", action: t, data: e, id: n };
|
|
69
|
-
(
|
|
69
|
+
(r = s().contentWindow) == null || r.postMessage(o, "*");
|
|
70
70
|
}
|
|
71
71
|
class L {
|
|
72
72
|
async init() {
|
|
@@ -74,18 +74,18 @@ class L {
|
|
|
74
74
|
}
|
|
75
75
|
/** توکن را از میزبان دریافت کرده و آن را ذخیره میکند. سپس به میزبان اعلام میکند که آمادهی ادامهی کار است */
|
|
76
76
|
setToken(e) {
|
|
77
|
-
y(e.data.token), d(), window.dispatchEvent(
|
|
77
|
+
y(e.data.token), d(), window.dispatchEvent(I());
|
|
78
78
|
}
|
|
79
79
|
/** بستن کتابخانه */
|
|
80
80
|
close() {
|
|
81
81
|
d();
|
|
82
82
|
const e = i();
|
|
83
|
-
document.body.removeChild(e), e.onclick = null, document.body.removeChild(
|
|
83
|
+
document.body.removeChild(e), e.onclick = null, document.body.removeChild(s()), window.dispatchEvent(T());
|
|
84
84
|
}
|
|
85
85
|
/** اطلاعات کتابخانه را به بیرون اطلاع میدهد */
|
|
86
86
|
getConfig(e) {
|
|
87
87
|
const t = w(), o = x();
|
|
88
|
-
$(e.id, { theme: t.theme, language: o.language }, e.action);
|
|
88
|
+
$(e.id, { color: t.color, theme: t.theme, language: o.language }, e.action);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
const u = {}.VITE_DEV_MODE === "1" ? "http://localhost:2525" : "https://samandesk.com";
|
|
@@ -95,7 +95,7 @@ class F {
|
|
|
95
95
|
*/
|
|
96
96
|
async init(e) {
|
|
97
97
|
this.interoperation = new L(), this.interoperation.init();
|
|
98
|
-
const t =
|
|
98
|
+
const t = s(), o = i();
|
|
99
99
|
l(`${u}/setup-interoperation/${e}`), t.width = "0", t.style.width = "0", document.body.appendChild(o), document.body.appendChild(t);
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
@@ -105,7 +105,7 @@ class F {
|
|
|
105
105
|
*
|
|
106
106
|
*/
|
|
107
107
|
setStyle(e) {
|
|
108
|
-
const t =
|
|
108
|
+
const t = s(), o = i();
|
|
109
109
|
t.style.position = "fixed", t.style.zIndex = "1000";
|
|
110
110
|
const a = {
|
|
111
111
|
position: "fixed",
|
|
@@ -138,7 +138,7 @@ class F {
|
|
|
138
138
|
* این تابع آیفریم را باز میکند.
|
|
139
139
|
*/
|
|
140
140
|
open(e) {
|
|
141
|
-
const t =
|
|
141
|
+
const t = s(), o = i();
|
|
142
142
|
v({
|
|
143
143
|
darkMode: e.theme.darkMode ?? "light",
|
|
144
144
|
color: e.theme.color ?? "default"
|
|
@@ -146,7 +146,7 @@ class F {
|
|
|
146
146
|
const a = e.link || `${u}/department-selection?token=${E()}`;
|
|
147
147
|
l(a), this.setStyle(e.fullScreen), document.body.appendChild(o), document.body.appendChild(t), o.onclick = () => {
|
|
148
148
|
this.close();
|
|
149
|
-
}, window.dispatchEvent(
|
|
149
|
+
}, window.dispatchEvent(M());
|
|
150
150
|
}
|
|
151
151
|
/**
|
|
152
152
|
* بستن کتابخانه
|
package/dist/saman-desk.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(a,
|
|
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
|
@@ -37,7 +37,7 @@ export declare function getLanguage(): {
|
|
|
37
37
|
language: string;
|
|
38
38
|
};
|
|
39
39
|
/** تم و رنگ جدید کتابخانه را تنظیم میکند */
|
|
40
|
-
export declare function setTheme(
|
|
40
|
+
export declare function setTheme(newTheme: ProjectTheme): void;
|
|
41
41
|
/** زبان جدید کتابخانه را تنظیم میکند */
|
|
42
42
|
export declare function setLanguage(newLanguage: string): void;
|
|
43
43
|
/** عنصر بکدراپ را برمیگرداند */
|