samandesk 1.0.12 → 1.0.13

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.
@@ -1,72 +1,73 @@
1
- let l;
1
+ let p;
2
2
  const a = document.createElement("iframe"), m = {
3
3
  count: 0,
4
4
  promises: {}
5
5
  };
6
- function p() {
6
+ function u() {
7
7
  return m;
8
8
  }
9
- function u(o) {
10
- l = o;
9
+ function f(n) {
10
+ p = n;
11
11
  }
12
- function f() {
13
- return l;
12
+ function h() {
13
+ return p;
14
14
  }
15
15
  function c() {
16
16
  a.src = "";
17
17
  }
18
- function d(o) {
19
- a.src = o;
18
+ function d(n) {
19
+ a.src = n;
20
20
  }
21
- function s() {
21
+ function r() {
22
22
  return a;
23
23
  }
24
- const h = new Event("ready"), w = new Event("open"), g = new Event("close");
25
- function y() {
26
- return h;
27
- }
24
+ const g = new Event("ready"), w = new Event("open"), y = new Event("close");
28
25
  function E() {
29
- return w;
26
+ return g;
30
27
  }
31
28
  function x() {
32
- return g;
29
+ return w;
30
+ }
31
+ function v() {
32
+ return y;
33
33
  }
34
- function k(o) {
34
+ function b(n) {
35
35
  window.addEventListener("message", (e) => {
36
36
  if (!e.data.from || e.data.from !== "SamanDesk")
37
37
  return;
38
38
  let t = !1;
39
39
  console.log(`message from (${e.origin})`, e);
40
40
  try {
41
- o[e.data.action](e.data.data), t = !0;
41
+ n[e.data.action](e.data.data), t = !0;
42
42
  } catch {
43
43
  console.error("error while run event action");
44
44
  }
45
- const n = e.data, r = n.id, i = p();
46
- r in i.promises ? (i.promises[r](n), delete i.promises[r]) : t || console.error("Message from outside of frame is invalid");
45
+ const o = e.data, s = o.id, i = u();
46
+ s in i.promises ? (i.promises[s](o), delete i.promises[s]) : t || console.error("Message from outside of frame is invalid");
47
47
  });
48
48
  }
49
- class v {
49
+ class k {
50
50
  async init() {
51
- k(this);
51
+ b(this);
52
52
  }
53
53
  /** توکن را از میزبان دریافت کرده و آن را ذخیره می‌کند. سپس به میزبان اعلام می‌کند که آماده‌ی ادامه‌ی کار است */
54
54
  setToken(e) {
55
- u(e.token), c(), window.dispatchEvent(y());
55
+ f(e.token), c(), window.dispatchEvent(E());
56
56
  }
57
57
  /** بستن کتابخانه */
58
58
  close() {
59
- c(), document.body.removeChild(s()), window.dispatchEvent(x());
59
+ c(), document.body.removeChild(r()), window.dispatchEvent(v());
60
60
  }
61
61
  }
62
- class S {
62
+ const l = "http://localhost:2525";
63
+ class O {
63
64
  /**
64
65
  * ⁧این تابع در ابتدا مقدار verifiedToken را دریافت کرده و سپس مقدار token‌ را دریافت و سپس آن را ذخیره می‌کند
65
66
  */
66
67
  async init(e) {
67
- new v().init();
68
- const n = s();
69
- d(`https://samandesk.com/setup-interoperation/${e}`), n.width = "0", n.style.width = "0", document.body.appendChild(n);
68
+ new k().init();
69
+ const o = r();
70
+ d(`${l}/setup-interoperation/${e}`), o.width = "0", document.body.appendChild(o);
70
71
  }
71
72
  /**
72
73
  * استایل مربوط به آیفریم را تنظیم می‌کند
@@ -75,7 +76,7 @@ class S {
75
76
  *
76
77
  */
77
78
  setStyle(e) {
78
- const t = s();
79
+ const t = r();
79
80
  t.style.position = "fixed", t.style.zIndex = "1000", e ? (Object.assign(t.style, {
80
81
  bottom: "0",
81
82
  left: "0",
@@ -97,10 +98,10 @@ class S {
97
98
  * این تابع آیفریم را باز می‌کند.
98
99
  */
99
100
  open(e) {
100
- const t = s(), n = e.link || `https://samandesk.com/department-selection?token=${f()}`;
101
- d(n), this.setStyle(e.fullScreen), document.body.appendChild(t), window.dispatchEvent(E());
101
+ const t = r(), o = e.link || `${l}/department-selection?token=${h()}`;
102
+ d(o), this.setStyle(e.fullScreen), document.body.appendChild(t), window.dispatchEvent(x());
102
103
  }
103
104
  }
104
105
  export {
105
- S as SamanDesk
106
+ O as SamanDesk
106
107
  };
@@ -1 +1 @@
1
- (function(s,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(s=typeof globalThis<"u"?globalThis:s||self,i(s.SamanDesk={}))})(this,function(s){"use strict";let i;const a=document.createElement("iframe"),m={count:0,promises:{}};function p(){return m}function u(o){i=o}function h(){return i}function l(){a.src=""}function f(o){a.src=o}function r(){return a}const y=new Event("ready"),g=new Event("open"),w=new Event("close");function E(){return y}function x(){return g}function k(){return w}function b(o){window.addEventListener("message",e=>{if(!e.data.from||e.data.from!=="SamanDesk")return;let t=!1;console.log(`message from (${e.origin})`,e);try{o[e.data.action](e.data.data),t=!0}catch{console.error("error while run event action")}const n=e.data,d=n.id,c=p();d in c.promises?(c.promises[d](n),delete c.promises[d]):t||console.error("Message from outside of frame is invalid")})}class v{async init(){b(this)}setToken(e){u(e.token),l(),window.dispatchEvent(E())}close(){l(),document.body.removeChild(r()),window.dispatchEvent(k())}}class S{async init(e){new v().init();const n=r();f(`https://samandesk.com/setup-interoperation/${e}`),n.width="0",n.style.width="0",document.body.appendChild(n)}setStyle(e){const t=r();t.style.position="fixed",t.style.zIndex="1000",e?(Object.assign(t.style,{bottom:"0",left:"0",top:"0",right:"0"}),t.width="100%",t.height="100%"):Object.assign(t.style,{top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"100%",maxWidth:"450px",boxShadow:"0px 0px 100px 0px rgba(0,0,0,0.48)",borderRadius:"24px",height:"100%",maxHeight:"660px"})}open(e){const t=r(),n=e.link||`https://samandesk.com/department-selection?token=${h()}`;f(n),this.setStyle(e.fullScreen),document.body.appendChild(t),window.dispatchEvent(x())}}s.SamanDesk=S,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
1
+ (function(s,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(s=typeof globalThis<"u"?globalThis:s||self,i(s.SamanDesk={}))})(this,function(s){"use strict";let i;const a=document.createElement("iframe"),u={count:0,promises:{}};function m(){return u}function h(n){i=n}function y(){return i}function l(){a.src=""}function f(n){a.src=n}function r(){return a}const g=new Event("ready"),w=new Event("open"),E=new Event("close");function x(){return g}function b(){return w}function v(){return E}function S(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.data),t=!0}catch{console.error("error while run event action")}const o=e.data,c=o.id,d=m();c in d.promises?(d.promises[c](o),delete d.promises[c]):t||console.error("Message from outside of frame is invalid")})}class k{async init(){S(this)}setToken(e){h(e.token),l(),window.dispatchEvent(x())}close(){l(),document.body.removeChild(r()),window.dispatchEvent(v())}}const p="http://localhost:2525";class T{async init(e){new k().init();const o=r();f(`${p}/setup-interoperation/${e}`),o.width="0",document.body.appendChild(o)}setStyle(e){const t=r();t.style.position="fixed",t.style.zIndex="1000",e?(Object.assign(t.style,{bottom:"0",left:"0",top:"0",right:"0"}),t.width="100%",t.height="100%"):Object.assign(t.style,{top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"100%",maxWidth:"450px",boxShadow:"0px 0px 100px 0px rgba(0,0,0,0.48)",borderRadius:"24px",height:"100%",maxHeight:"660px"})}open(e){const t=r(),o=e.link||`${p}/department-selection?token=${y()}`;f(o),this.setStyle(e.fullScreen),document.body.appendChild(t),window.dispatchEvent(b())}}s.SamanDesk=T,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "samandesk",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "files": [
@@ -16,7 +16,11 @@
16
16
  "types": "./dist/index.d.ts"
17
17
  }
18
18
  },
19
+ "scripts": {
20
+ "start": "yarn link && cross-env VITE_DEV_MODE=1 yarn vite build --watch"
21
+ },
19
22
  "devDependencies": {
23
+ "cross-env": "^7.0.3",
20
24
  "typescript": "^5.2.2",
21
25
  "utility-types": "^3.10.0",
22
26
  "vite": "^4.4.9",