samandesk 1.0.18 → 1.0.20

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 CHANGED
@@ -41,4 +41,8 @@ export declare class SamanDesk {
41
41
  * این تابع آیفریم را باز می‌کند.
42
42
  */
43
43
  open(config: OpenConfig): void;
44
+ /**
45
+ * بستن کتابخانه
46
+ */
47
+ close(): void;
44
48
  }
@@ -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, 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");
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 s;
61
+ var r;
62
62
  const o = { from: "SamanDesk", action: t, data: e, id: n };
63
- (s = i().contentWindow) == null || s.postMessage(o, "*");
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 r = {
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, r), e ? (Object.assign(t.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 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();
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
@@ -1 +1 @@
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"})});
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"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "samandesk",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "files": [