samandesk 1.0.8 → 1.0.9

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
@@ -1,3 +1,18 @@
1
+ export interface OpenConfig {
2
+ /**
3
+ * اگر لینک مستقیما از بیرون آمده باشد همان را باز می‌کند
4
+ * این اتفاق در شرایطی رخ می‌دهد که میزبان می‌خواهد از لینکی که در اختیارش قرار گرفته است مستقیما استفاده کند
5
+ * اگر لینک را در ورودی ارسال نکند، خودکار به صفحه‌ی انتخاب دپارتمان می‌رویم و ادامه‌ی کار توسط سامان دسک صورت می‌گیرد
6
+ */
7
+ link?: string;
8
+ /**
9
+ * کتابخانه به صورت تمام صفحه باز شود یا خیر
10
+ *
11
+ * اگر تمام صفحه شود، از اطراف هیچ فضای خالی‌ای وجود نخواهد داشت و در غیر اینصورت، در وسط صفحه قرار خواهدگرفت
12
+ * ⁧در این حالت یک overlay پشت کتابخانه قرار خواهد گرفت
13
+ */
14
+ fullScreen: boolean;
15
+ }
1
16
  export declare class SamanDesk {
2
17
  /**
3
18
  * ⁧این تابع در ابتدا مقدار verifiedToken را دریافت کرده و سپس مقدار token‌ را دریافت و سپس آن را ذخیره می‌کند
@@ -6,21 +21,12 @@ export declare class SamanDesk {
6
21
  /**
7
22
  * استایل مربوط به آیفریم را تنظیم می‌کند
8
23
  *
9
- * @param size - در چه سایزی باز می‌شود
10
- *
11
- * ⁧'desktop' : اگر در سایز وب باز شود، در وسط صفحه نمایش داده خواهد شد
24
+ * @param fullScreen - تمام صفحه باز شود یا خیر
12
25
  *
13
- * ⁧'mobile': اگر در سایز موبایل باز شود، به صورت تمام صفحه خواهد بود
14
26
  */
15
27
  private setStyle;
16
28
  /**
17
29
  * این تابع آیفریم را باز می‌کند.
18
- * اگر لینک مستقیما از بیرون آمده باشد همان را باز می‌کند
19
- * این اتفاق در شرایطی رخ می‌دهد که میزبان می‌خواهد از لینکی که در اختیارش قرار گرفته است مستقیما استفاده کند
20
- * اگر لینک را در ورودی ارسال نکند، خودکار به صفحه‌ی انتخاب دپارتمان می‌رویم و ادامه‌ی کار توسط سامان دسک صورت می‌گیرد
21
30
  */
22
- open(config: {
23
- link?: string;
24
- size: 'desktop' | 'mobile';
25
- }): void;
31
+ open(config: OpenConfig): void;
26
32
  }
@@ -12,5 +12,5 @@ export declare class InterOperation {
12
12
  /** توکن را از میزبان دریافت کرده و آن را ذخیره می‌کند. سپس به میزبان اعلام می‌کند که آماده‌ی ادامه‌ی کار است */
13
13
  setToken(data: any): void;
14
14
  /** بستن کتابخانه */
15
- close(data: any): void;
15
+ close(): void;
16
16
  }
@@ -6,91 +6,99 @@ const a = document.createElement("iframe"), m = {
6
6
  function p() {
7
7
  return m;
8
8
  }
9
- function f(n) {
9
+ function u(n) {
10
10
  l = n;
11
11
  }
12
- function u() {
12
+ function f() {
13
13
  return l;
14
14
  }
15
- function d() {
15
+ function c() {
16
16
  a.src = "";
17
17
  }
18
- function c(n) {
18
+ function d(n) {
19
19
  a.src = n;
20
20
  }
21
21
  function s() {
22
22
  return a;
23
23
  }
24
- const y = new Event("ready"), h = new Event("open"), w = new Event("close");
25
- function g() {
26
- return y;
24
+ const h = new Event("ready"), g = new Event("open"), w = new Event("close");
25
+ function y() {
26
+ return h;
27
27
  }
28
28
  function E() {
29
- return h;
29
+ return g;
30
30
  }
31
31
  function x() {
32
32
  return w;
33
33
  }
34
- function v(n) {
35
- window.addEventListener("message", (t) => {
36
- if (!t.data.from || t.data.from !== "SamanDesk")
34
+ function k(n) {
35
+ window.addEventListener("message", (e) => {
36
+ if (!e.data.from || e.data.from !== "SamanDesk")
37
37
  return;
38
- let e = !1;
39
- console.log(`message from (${t.origin})`, t);
38
+ let t = !1;
39
+ console.log(`message from (${e.origin})`, e);
40
40
  try {
41
- n[t.data.action](t.data.data), e = !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 o = t.data, r = o.id, i = p();
46
- r in i.promises ? (i.promises[r](o), delete i.promises[r]) : e || console.error("Message from outside of frame is invalid");
45
+ const o = e.data, r = o.id, i = p();
46
+ r in i.promises ? (i.promises[r](o), delete i.promises[r]) : t || console.error("Message from outside of frame is invalid");
47
47
  });
48
48
  }
49
- class k {
49
+ class v {
50
50
  async init() {
51
- v(this);
51
+ k(this);
52
52
  }
53
53
  /** توکن را از میزبان دریافت کرده و آن را ذخیره می‌کند. سپس به میزبان اعلام می‌کند که آماده‌ی ادامه‌ی کار است */
54
- setToken(t) {
55
- f(t.token), d(), window.dispatchEvent(g());
54
+ setToken(e) {
55
+ u(e.token), c(), window.dispatchEvent(y());
56
56
  }
57
57
  /** بستن کتابخانه */
58
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
59
- close(t) {
60
- d(), document.body.removeChild(s()), window.dispatchEvent(x());
58
+ close() {
59
+ c(), document.body.removeChild(s()), window.dispatchEvent(x());
61
60
  }
62
61
  }
63
62
  class S {
64
63
  /**
65
64
  * ⁧این تابع در ابتدا مقدار verifiedToken را دریافت کرده و سپس مقدار token‌ را دریافت و سپس آن را ذخیره می‌کند
66
65
  */
67
- async init(t) {
68
- new k().init();
66
+ async init(e) {
67
+ new v().init();
69
68
  const o = s();
70
- c(`https://samandesk.com/setup-interoperation/${t}`), o.width = "0", document.body.appendChild(o);
69
+ d(`https://samandesk.com/setup-interoperation/${e}`), o.width = "0", document.body.appendChild(o);
71
70
  }
72
71
  /**
73
72
  * استایل مربوط به آیفریم را تنظیم می‌کند
74
73
  *
75
- * @param size - در چه سایزی باز می‌شود
76
- *
77
- * ⁧'desktop' : اگر در سایز وب باز شود، در وسط صفحه نمایش داده خواهد شد
74
+ * @param fullScreen - تمام صفحه باز شود یا خیر
78
75
  *
79
- * ⁧'mobile': اگر در سایز موبایل باز شود، به صورت تمام صفحه خواهد بود
80
76
  */
81
- setStyle(t) {
82
- const e = s();
83
- e.style.position = "fixed", e.style.zIndex = "1000", t === "mobile" ? (e.style.bottom = "0", e.style.left = "0", e.style.top = "0", e.style.right = "0", e.width = "100%", e.height = "100%") : (e.style.top = "50%", e.style.left = "50%", e.style.transform = "translate(-50%, -50%)", e.style.width = "100%", e.style.maxWidth = "450px", e.style.boxShadow = "0px 0px 100px 0px rgba(0,0,0,0.48)", e.style.borderRadius = "24px", e.style.height = "100%", e.style.maxHeight = "660px", e.style.overflow = "hidden");
77
+ setStyle(e) {
78
+ const t = s();
79
+ t.style.position = "fixed", t.style.zIndex = "1000", e ? (Object.assign(t.style, {
80
+ bottom: "0",
81
+ left: "0",
82
+ top: "0",
83
+ right: "0"
84
+ }), t.width = "100%", t.height = "100%") : Object.assign(t.style, {
85
+ top: "50%",
86
+ left: "50%",
87
+ transform: "translate(-50%, -50%)",
88
+ width: "100%",
89
+ maxWidth: "450px",
90
+ boxShadow: "0px 0px 100px 0px rgba(0,0,0,0.48)",
91
+ borderRadius: "24px",
92
+ height: "100%",
93
+ maxHeight: "660px"
94
+ });
84
95
  }
85
96
  /**
86
97
  * این تابع آیفریم را باز می‌کند.
87
- * اگر لینک مستقیما از بیرون آمده باشد همان را باز می‌کند
88
- * این اتفاق در شرایطی رخ می‌دهد که میزبان می‌خواهد از لینکی که در اختیارش قرار گرفته است مستقیما استفاده کند
89
- * اگر لینک را در ورودی ارسال نکند، خودکار به صفحه‌ی انتخاب دپارتمان می‌رویم و ادامه‌ی کار توسط سامان دسک صورت می‌گیرد
90
98
  */
91
- open(t) {
92
- const e = s(), o = t.link || `https://samandesk.com/department-selection?token=${u()}`;
93
- c(o), this.setStyle(t.size), document.body.appendChild(e), window.dispatchEvent(E());
99
+ open(e) {
100
+ const t = s(), o = e.link || `https://samandesk.com/department-selection?token=${f()}`;
101
+ d(o), this.setStyle(e.fullScreen), document.body.appendChild(t), window.dispatchEvent(E());
94
102
  }
95
103
  }
96
104
  export {
@@ -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(n){i=n}function y(){return i}function l(){a.src=""}function f(n){a.src=n}function r(){return a}const h=new Event("ready"),w=new Event("open"),g=new Event("close");function E(){return h}function x(){return w}function k(){return g}function v(n){window.addEventListener("message",t=>{if(!t.data.from||t.data.from!=="SamanDesk")return;let e=!1;console.log(`message from (${t.origin})`,t);try{n[t.data.action](t.data.data),e=!0}catch{console.error("error while run event action")}const o=t.data,d=o.id,c=p();d in c.promises?(c.promises[d](o),delete c.promises[d]):e||console.error("Message from outside of frame is invalid")})}class b{async init(){v(this)}setToken(t){u(t.token),l(),window.dispatchEvent(E())}close(t){l(),document.body.removeChild(r()),window.dispatchEvent(k())}}class S{async init(t){new b().init();const o=r();f(`https://samandesk.com/setup-interoperation/${t}`),o.width="0",document.body.appendChild(o)}setStyle(t){const e=r();e.style.position="fixed",e.style.zIndex="1000",t==="mobile"?(e.style.bottom="0",e.style.left="0",e.style.top="0",e.style.right="0",e.width="100%",e.height="100%"):(e.style.top="50%",e.style.left="50%",e.style.transform="translate(-50%, -50%)",e.style.width="100%",e.style.maxWidth="450px",e.style.boxShadow="0px 0px 100px 0px rgba(0,0,0,0.48)",e.style.borderRadius="24px",e.style.height="100%",e.style.maxHeight="660px",e.style.overflow="hidden")}open(t){const e=r(),o=t.link||`https://samandesk.com/department-selection?token=${y()}`;f(o),this.setStyle(t.size),document.body.appendChild(e),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"),m={count:0,promises:{}};function p(){return m}function u(n){i=n}function h(){return i}function l(){a.src=""}function f(n){a.src=n}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(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,d=o.id,c=p();d in c.promises?(c.promises[d](o),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 o=r();f(`https://samandesk.com/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||`https://samandesk.com/department-selection?token=${h()}`;f(o),this.setStyle(e.fullScreen),document.body.appendChild(t),window.dispatchEvent(x())}}s.SamanDesk=S,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.8",
3
+ "version": "1.0.9",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "files": [