samandesk 1.0.7 → 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/events.d.ts +8 -0
- package/dist/index.d.ts +22 -5
- package/dist/interoperation.d.ts +2 -0
- package/dist/saman-desk.js +63 -36
- package/dist/saman-desk.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/events.d.ts
CHANGED
|
@@ -3,6 +3,14 @@ import { InterOperation } from './interoperation';
|
|
|
3
3
|
* ایونت آمادهشدن توکن را بر میگرداند
|
|
4
4
|
*/
|
|
5
5
|
export declare function getReadyEvent(): Event;
|
|
6
|
+
/**
|
|
7
|
+
* ایونت بازشدن کتابخانه را بر میگرداند
|
|
8
|
+
*/
|
|
9
|
+
export declare function getOpenEvent(): Event;
|
|
10
|
+
/**
|
|
11
|
+
* ایونت بستهشدن کتابخانه را بر میگرداند
|
|
12
|
+
*/
|
|
13
|
+
export declare function getCloseEvent(): Event;
|
|
6
14
|
/**
|
|
7
15
|
* eventهایی که از بیرون به داخل میایند را اعتبار سنجی و سپس کار خواسته شده را انجام میدهد
|
|
8
16
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,32 @@
|
|
|
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 را دریافت و سپس آن را ذخیره میکند
|
|
4
19
|
*/
|
|
5
20
|
init(verifiedToken: string): Promise<void>;
|
|
6
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* استایل مربوط به آیفریم را تنظیم میکند
|
|
23
|
+
*
|
|
24
|
+
* @param fullScreen - تمام صفحه باز شود یا خیر
|
|
25
|
+
*
|
|
26
|
+
*/
|
|
7
27
|
private setStyle;
|
|
8
28
|
/**
|
|
9
29
|
* این تابع آیفریم را باز میکند.
|
|
10
|
-
* اگر لینک مستقیما از بیرون آمده باشد همان را باز میکند
|
|
11
|
-
* این اتفاق در شرایطی رخ میدهد که میزبان میخواهد از لینکی که در اختیارش قرار گرفته است مستقیما استفاده کند
|
|
12
|
-
* اگر لینک را در ورودی ارسال نکند، خودکار به صفحهی انتخاب دپارتمان میرویم و ادامهی کار توسط سامان دسک صورت میگیرد
|
|
13
30
|
*/
|
|
14
|
-
open(
|
|
31
|
+
open(config: OpenConfig): void;
|
|
15
32
|
}
|
package/dist/interoperation.d.ts
CHANGED
package/dist/saman-desk.js
CHANGED
|
@@ -1,79 +1,106 @@
|
|
|
1
|
-
let
|
|
2
|
-
const
|
|
1
|
+
let l;
|
|
2
|
+
const a = document.createElement("iframe"), m = {
|
|
3
3
|
count: 0,
|
|
4
4
|
promises: {}
|
|
5
5
|
};
|
|
6
|
-
function
|
|
7
|
-
return
|
|
6
|
+
function p() {
|
|
7
|
+
return m;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
9
|
+
function u(n) {
|
|
10
|
+
l = n;
|
|
11
11
|
}
|
|
12
12
|
function f() {
|
|
13
|
-
return
|
|
13
|
+
return l;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
|
|
15
|
+
function c() {
|
|
16
|
+
a.src = "";
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
|
|
18
|
+
function d(n) {
|
|
19
|
+
a.src = n;
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
return
|
|
21
|
+
function s() {
|
|
22
|
+
return a;
|
|
23
23
|
}
|
|
24
|
-
const h = new Event("ready");
|
|
24
|
+
const h = new Event("ready"), g = new Event("open"), w = new Event("close");
|
|
25
25
|
function y() {
|
|
26
26
|
return h;
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function E() {
|
|
29
|
+
return g;
|
|
30
|
+
}
|
|
31
|
+
function x() {
|
|
32
|
+
return w;
|
|
33
|
+
}
|
|
34
|
+
function k(n) {
|
|
29
35
|
window.addEventListener("message", (e) => {
|
|
30
36
|
if (!e.data.from || e.data.from !== "SamanDesk")
|
|
31
37
|
return;
|
|
32
|
-
let
|
|
38
|
+
let t = !1;
|
|
33
39
|
console.log(`message from (${e.origin})`, e);
|
|
34
40
|
try {
|
|
35
|
-
|
|
41
|
+
n[e.data.action](e.data.data), t = !0;
|
|
36
42
|
} catch {
|
|
37
43
|
console.error("error while run event action");
|
|
38
44
|
}
|
|
39
|
-
const
|
|
40
|
-
|
|
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");
|
|
41
47
|
});
|
|
42
48
|
}
|
|
43
|
-
class
|
|
49
|
+
class v {
|
|
44
50
|
async init() {
|
|
45
|
-
|
|
51
|
+
k(this);
|
|
46
52
|
}
|
|
47
53
|
/** توکن را از میزبان دریافت کرده و آن را ذخیره میکند. سپس به میزبان اعلام میکند که آمادهی ادامهی کار است */
|
|
48
54
|
setToken(e) {
|
|
49
|
-
|
|
55
|
+
u(e.token), c(), window.dispatchEvent(y());
|
|
56
|
+
}
|
|
57
|
+
/** بستن کتابخانه */
|
|
58
|
+
close() {
|
|
59
|
+
c(), document.body.removeChild(s()), window.dispatchEvent(x());
|
|
50
60
|
}
|
|
51
61
|
}
|
|
52
|
-
class
|
|
62
|
+
class S {
|
|
53
63
|
/**
|
|
54
64
|
* این تابع در ابتدا مقدار verifiedToken را دریافت کرده و سپس مقدار token را دریافت و سپس آن را ذخیره میکند
|
|
55
65
|
*/
|
|
56
66
|
async init(e) {
|
|
57
|
-
new
|
|
58
|
-
const
|
|
59
|
-
|
|
67
|
+
new v().init();
|
|
68
|
+
const o = s();
|
|
69
|
+
d(`https://samandesk.com/setup-interoperation/${e}`), o.width = "0", document.body.appendChild(o);
|
|
60
70
|
}
|
|
61
|
-
/**
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
71
|
+
/**
|
|
72
|
+
* استایل مربوط به آیفریم را تنظیم میکند
|
|
73
|
+
*
|
|
74
|
+
* @param fullScreen - تمام صفحه باز شود یا خیر
|
|
75
|
+
*
|
|
76
|
+
*/
|
|
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
|
+
});
|
|
65
95
|
}
|
|
66
96
|
/**
|
|
67
97
|
* این تابع آیفریم را باز میکند.
|
|
68
|
-
* اگر لینک مستقیما از بیرون آمده باشد همان را باز میکند
|
|
69
|
-
* این اتفاق در شرایطی رخ میدهد که میزبان میخواهد از لینکی که در اختیارش قرار گرفته است مستقیما استفاده کند
|
|
70
|
-
* اگر لینک را در ورودی ارسال نکند، خودکار به صفحهی انتخاب دپارتمان میرویم و ادامهی کار توسط سامان دسک صورت میگیرد
|
|
71
98
|
*/
|
|
72
99
|
open(e) {
|
|
73
|
-
const
|
|
74
|
-
|
|
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());
|
|
75
102
|
}
|
|
76
103
|
}
|
|
77
104
|
export {
|
|
78
|
-
|
|
105
|
+
S as SamanDesk
|
|
79
106
|
};
|
package/dist/saman-desk.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
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"})});
|