samandesk 1.0.17 → 1.0.19
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/index.d.ts +4 -0
- package/dist/saman-desk.js +16 -10
- package/dist/saman-desk.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/saman-desk.js
CHANGED
|
@@ -53,14 +53,14 @@ function O(n) {
|
|
|
53
53
|
} catch {
|
|
54
54
|
console.error("error while run event action");
|
|
55
55
|
}
|
|
56
|
-
const o = e.data,
|
|
57
|
-
|
|
56
|
+
const o = e.data, s = o.id, r = g();
|
|
57
|
+
s in r.promises ? (r.promises[s](o), delete r.promises[s]) : t || console.error("Message from outside of frame is invalid");
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
function D(n, e, t) {
|
|
61
|
-
var
|
|
61
|
+
var r;
|
|
62
62
|
const o = { from: "SamanDesk", action: t, data: e, id: n };
|
|
63
|
-
(
|
|
63
|
+
(r = i().contentWindow) == null || r.postMessage(o, "*");
|
|
64
64
|
}
|
|
65
65
|
class I {
|
|
66
66
|
async init() {
|
|
@@ -100,7 +100,7 @@ class $ {
|
|
|
100
100
|
setStyle(e) {
|
|
101
101
|
const t = i(), o = a();
|
|
102
102
|
t.style.position = "fixed", t.style.zIndex = "1000";
|
|
103
|
-
const
|
|
103
|
+
const s = {
|
|
104
104
|
position: "fixed",
|
|
105
105
|
top: "0",
|
|
106
106
|
bottom: "0",
|
|
@@ -109,7 +109,7 @@ class $ {
|
|
|
109
109
|
backgroundColor: "rgba(0,0,0,0.5)",
|
|
110
110
|
zIndex: "1000"
|
|
111
111
|
};
|
|
112
|
-
Object.assign(o.style,
|
|
112
|
+
Object.assign(o.style, s), e ? (Object.assign(t.style, {
|
|
113
113
|
bottom: "0",
|
|
114
114
|
left: "0",
|
|
115
115
|
top: "0",
|
|
@@ -133,12 +133,18 @@ class $ {
|
|
|
133
133
|
open(e) {
|
|
134
134
|
const t = i(), o = a();
|
|
135
135
|
w(e.theme ?? "light");
|
|
136
|
-
const
|
|
137
|
-
l(
|
|
138
|
-
|
|
139
|
-
(s = this.interoperation) == null || s.close();
|
|
136
|
+
const s = e.link || `${m}/department-selection?token=${y()}`;
|
|
137
|
+
l(s), this.setStyle(e.fullScreen), document.body.appendChild(o), document.body.appendChild(t), o.onclick = () => {
|
|
138
|
+
this.close();
|
|
140
139
|
}, window.dispatchEvent(C());
|
|
141
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* بستن کتابخانه
|
|
143
|
+
*/
|
|
144
|
+
close() {
|
|
145
|
+
var e;
|
|
146
|
+
(e = this.interoperation) == null || e.close();
|
|
147
|
+
}
|
|
142
148
|
}
|
|
143
149
|
export {
|
|
144
150
|
$ as SamanDesk
|
package/dist/saman-desk.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(r
|
|
1
|
+
(function(i,r){typeof exports=="object"&&typeof module<"u"?r(exports):typeof define=="function"&&define.amd?define(["exports"],r):(i=typeof globalThis<"u"?globalThis:i||self,r(i.SamanDesk={}))})(this,function(i){"use strict";let r;const l=document.createElement("iframe");let p;const h=document.createElement("div"),g={count:0,promises:{}};function y(){return g}function b(n){r=n}function k(){return r}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,s=o.id,a=y();s in a.promises?(a.promises[s](o),delete a.promises[s]):t||console.error("Message from outside of frame is invalid")})}function I(n,e,t){var a;const o={from:"SamanDesk",action:t,data:e,id:n};(a=c().contentWindow)==null||a.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 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();E(e.theme??"light");const s=e.link||`${f}/department-selection?token=${k()}`;u(s),this.setStyle(e.fullScreen),document.body.appendChild(o),document.body.appendChild(t),o.onclick=()=>{this.close()},window.dispatchEvent(C())}close(){var e;(e=this.interoperation)==null||e.close()}}i.SamanDesk=R,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
|