samandesk 1.0.20 → 1.0.21
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/saman-desk.js +28 -24
- package/dist/saman-desk.umd.cjs +1 -1
- package/dist/{data.d.ts → src/data.d.ts} +14 -4
- package/dist/{index.d.ts → src/index.d.ts} +5 -7
- package/dist/{interoperation.d.ts → src/interoperation.d.ts} +1 -1
- package/package.json +1 -1
- /package/dist/{events.d.ts → src/events.d.ts} +0 -0
package/dist/saman-desk.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
let p;
|
|
2
2
|
const c = document.createElement("iframe");
|
|
3
|
-
let u;
|
|
4
|
-
const
|
|
3
|
+
let u, h;
|
|
4
|
+
const f = document.createElement("div"), g = {
|
|
5
5
|
count: 0,
|
|
6
6
|
promises: {}
|
|
7
7
|
};
|
|
8
|
-
function
|
|
9
|
-
return
|
|
8
|
+
function k() {
|
|
9
|
+
return g;
|
|
10
10
|
}
|
|
11
11
|
function b(n) {
|
|
12
12
|
p = n;
|
|
@@ -23,26 +23,26 @@ function l(n) {
|
|
|
23
23
|
function i() {
|
|
24
24
|
return c;
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
return u;
|
|
26
|
+
function E() {
|
|
27
|
+
return { theme: u, color: h };
|
|
28
28
|
}
|
|
29
29
|
function w(n) {
|
|
30
|
-
u = n;
|
|
30
|
+
u = n.darkMode, h = n.color;
|
|
31
31
|
}
|
|
32
32
|
function a() {
|
|
33
|
-
return
|
|
34
|
-
}
|
|
35
|
-
const E = new Event("ready"), x = new Event("open"), v = new Event("close");
|
|
36
|
-
function S() {
|
|
37
|
-
return E;
|
|
33
|
+
return f;
|
|
38
34
|
}
|
|
35
|
+
const x = new Event("ready"), v = new Event("open"), S = new Event("close");
|
|
39
36
|
function C() {
|
|
40
37
|
return x;
|
|
41
38
|
}
|
|
42
|
-
function
|
|
39
|
+
function D() {
|
|
43
40
|
return v;
|
|
44
41
|
}
|
|
45
|
-
function O(
|
|
42
|
+
function O() {
|
|
43
|
+
return S;
|
|
44
|
+
}
|
|
45
|
+
function T(n) {
|
|
46
46
|
window.addEventListener("message", (e) => {
|
|
47
47
|
if (!e.data.from || e.data.from !== "SamanDesk")
|
|
48
48
|
return;
|
|
@@ -53,32 +53,33 @@ function O(n) {
|
|
|
53
53
|
} catch {
|
|
54
54
|
console.error("error while run event action");
|
|
55
55
|
}
|
|
56
|
-
const o = e.data, s = o.id, r =
|
|
56
|
+
const o = e.data, s = o.id, r = k();
|
|
57
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
|
-
function
|
|
60
|
+
function I(n, e, t) {
|
|
61
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
|
-
class
|
|
65
|
+
class M {
|
|
66
66
|
async init() {
|
|
67
|
-
|
|
67
|
+
T(this);
|
|
68
68
|
}
|
|
69
69
|
/** توکن را از میزبان دریافت کرده و آن را ذخیره میکند. سپس به میزبان اعلام میکند که آمادهی ادامهی کار است */
|
|
70
70
|
setToken(e) {
|
|
71
|
-
b(e.data.token), d(), window.dispatchEvent(
|
|
71
|
+
b(e.data.token), d(), window.dispatchEvent(C());
|
|
72
72
|
}
|
|
73
73
|
/** بستن کتابخانه */
|
|
74
74
|
close() {
|
|
75
75
|
d();
|
|
76
76
|
const e = a();
|
|
77
|
-
document.body.removeChild(e), e.onclick = null, document.body.removeChild(i()), window.dispatchEvent(
|
|
77
|
+
document.body.removeChild(e), e.onclick = null, document.body.removeChild(i()), window.dispatchEvent(O());
|
|
78
78
|
}
|
|
79
79
|
/** تم کتابخانه را به بیرون اطلاع میدهد */
|
|
80
80
|
getTheme(e) {
|
|
81
|
-
|
|
81
|
+
const t = E();
|
|
82
|
+
I(e.id, t, e.action);
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
85
|
const m = {}.VITE_DEV_MODE === "1" ? "http://localhost:2525" : "https://samandesk.com";
|
|
@@ -87,7 +88,7 @@ class $ {
|
|
|
87
88
|
* این تابع در ابتدا مقدار verifiedToken را دریافت کرده و سپس مقدار token را دریافت و سپس آن را ذخیره میکند
|
|
88
89
|
*/
|
|
89
90
|
async init(e) {
|
|
90
|
-
this.interoperation = new
|
|
91
|
+
this.interoperation = new M(), this.interoperation.init();
|
|
91
92
|
const t = i(), o = a();
|
|
92
93
|
l(`${m}/setup-interoperation/${e}`), t.width = "0", t.style.width = "0", document.body.appendChild(o), document.body.appendChild(t);
|
|
93
94
|
}
|
|
@@ -132,11 +133,14 @@ class $ {
|
|
|
132
133
|
*/
|
|
133
134
|
open(e) {
|
|
134
135
|
const t = i(), o = a();
|
|
135
|
-
w(
|
|
136
|
+
w({
|
|
137
|
+
darkMode: e.theme.darkMode ?? "light",
|
|
138
|
+
color: e.theme.color ?? "default"
|
|
139
|
+
});
|
|
136
140
|
const s = e.link || `${m}/department-selection?token=${y()}`;
|
|
137
141
|
l(s), this.setStyle(e.fullScreen), document.body.appendChild(o), document.body.appendChild(t), o.onclick = () => {
|
|
138
142
|
this.close();
|
|
139
|
-
}, window.dispatchEvent(
|
|
143
|
+
}, window.dispatchEvent(D());
|
|
140
144
|
}
|
|
141
145
|
/**
|
|
142
146
|
* بستن کتابخانه
|
package/dist/saman-desk.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
|
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,m;const g=document.createElement("div"),k={count:0,promises:{}};function y(){return k}function b(n){r=n}function E(){return r}function u(){l.src=""}function f(n){l.src=n}function c(){return l}function w(){return{theme:p,color:m}}function x(n){p=n.darkMode,m=n.color}function d(){return g}const v=new Event("ready"),S=new Event("open"),T=new Event("close");function D(){return v}function C(){return S}function O(){return T}function M(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(){M(this)}setToken(e){b(e.data.token),u(),window.dispatchEvent(D())}close(){u();const e=d();document.body.removeChild(e),e.onclick=null,document.body.removeChild(c()),window.dispatchEvent(O())}getTheme(e){const t=w();I(e.id,t,e.action)}}const h={}.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();f(`${h}/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();x({darkMode:e.theme.darkMode??"light",color:e.theme.color??"default"});const s=e.link||`${h}/department-selection?token=${E()}`;f(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"})});
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import { Color } from '../library-colors';
|
|
2
|
+
export type ProjectTheme = {
|
|
3
|
+
/** روشن یا تیرهبودن تم برنامه */
|
|
4
|
+
darkMode: 'light' | 'dark';
|
|
5
|
+
/** رنگ برنامه */
|
|
6
|
+
color: Color;
|
|
7
|
+
};
|
|
1
8
|
type PromiseMap = {
|
|
2
9
|
[key: number]: (data: any) => void;
|
|
3
10
|
};
|
|
@@ -20,10 +27,13 @@ export declare function clearFrame(): void;
|
|
|
20
27
|
export declare function setFrameSrc(src: string): void;
|
|
21
28
|
/** تگ iframe را بر میگرداند */
|
|
22
29
|
export declare function getFrame(): HTMLIFrameElement;
|
|
23
|
-
/** تم کتابخانه را بر میگرداند */
|
|
24
|
-
export declare function getTheme():
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
/** تم و رنگ کتابخانه را بر میگرداند */
|
|
31
|
+
export declare function getTheme(): {
|
|
32
|
+
theme: "light" | "dark" | undefined;
|
|
33
|
+
color: Color;
|
|
34
|
+
};
|
|
35
|
+
/** تم و رنگ جدید کتابخانه را تنظیم میکند */
|
|
36
|
+
export declare function setTheme(newTheme: ProjectTheme): void;
|
|
27
37
|
/** عنصر بکدراپ را برمیگرداند */
|
|
28
38
|
export declare function getBackdrop(): HTMLDivElement;
|
|
29
39
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ProjectTheme } from './data';
|
|
1
2
|
export interface OpenConfig {
|
|
2
3
|
/**
|
|
3
4
|
* اگر لینک مستقیما از بیرون آمده باشد همان را باز میکند
|
|
@@ -12,14 +13,11 @@ export interface OpenConfig {
|
|
|
12
13
|
* در این حالت یک overlay پشت کتابخانه قرار خواهد گرفت
|
|
13
14
|
*/
|
|
14
15
|
fullScreen: boolean;
|
|
15
|
-
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* 'light': تم کتابخانه روشن است
|
|
19
|
-
*
|
|
20
|
-
* 'dark': تم برنامه تاریک است
|
|
16
|
+
/** تم کتابخانه شامل :
|
|
17
|
+
* روشن یا تیره بودن کتابخانه
|
|
18
|
+
* رنگ تم کتابخانه
|
|
21
19
|
*/
|
|
22
|
-
theme
|
|
20
|
+
theme: Partial<ProjectTheme>;
|
|
23
21
|
}
|
|
24
22
|
export declare class SamanDesk {
|
|
25
23
|
/**
|
package/package.json
CHANGED
|
File without changes
|