emr-bridge 1.2.2 → 1.4.0
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/LICENCE +1 -1
- package/README.md +136 -113
- package/cjs/enums.d.ts +5 -1
- package/cjs/enums.js +4 -0
- package/cjs/exp.d.ts +4 -0
- package/cjs/exp.js +21 -0
- package/cjs/index.d.ts +3 -4
- package/cjs/index.js +5 -7
- package/cjs/scripts/Bridge.js +6 -0
- package/cjs/scripts/Main.js +26 -0
- package/cjs/scripts/newDecorators.d.ts +63 -1
- package/cjs/scripts/newDecorators.js +50 -5
- package/cjs/scripts/oldDecorators.d.ts +167 -1
- package/cjs/scripts/oldDecorators.js +62 -1
- package/cjs/scripts/preloadProvider.js +37 -1
- package/cjs/scripts/provider.js +58 -1
- package/cjs/scripts/publish.d.ts +15 -1
- package/cjs/scripts/publish.js +96 -1
- package/cjs/types.d.ts +21 -0
- package/{lib → esm}/enums.d.ts +5 -1
- package/{lib → esm}/enums.js +4 -0
- package/esm/exp.d.ts +4 -0
- package/esm/exp.js +3 -0
- package/esm/index.d.ts +4 -0
- package/esm/index.js +3 -0
- package/{lib → esm}/scripts/Bridge.js +6 -0
- package/esm/scripts/Main.js +61 -0
- package/{lib → esm}/scripts/newDecorators.d.ts +63 -1
- package/{lib → esm}/scripts/newDecorators.js +48 -5
- package/esm/scripts/oldDecorators.d.ts +289 -0
- package/{lib → esm}/scripts/oldDecorators.js +58 -1
- package/esm/scripts/preloadProvider.js +87 -0
- package/{lib → esm}/scripts/provider.js +58 -1
- package/{lib → esm}/scripts/publish.d.ts +15 -1
- package/esm/scripts/publish.js +194 -0
- package/{lib → esm}/types.d.ts +21 -0
- package/package.json +29 -13
- package/lib/index.d.ts +0 -5
- package/lib/index.js +0 -4
- package/lib/scripts/Main.js +0 -35
- package/lib/scripts/oldDecorators.d.ts +0 -123
- package/lib/scripts/preloadProvider.js +0 -51
- package/lib/scripts/publish.js +0 -101
- /package/{lib → esm}/preload.d.ts +0 -0
- /package/{lib → esm}/preload.js +0 -0
- /package/{lib → esm}/renderer.d.ts +0 -0
- /package/{lib → esm}/renderer.js +0 -0
- /package/{lib → esm}/scripts/Bridge.d.ts +0 -0
- /package/{lib → esm}/scripts/Main.d.ts +0 -0
- /package/{lib → esm}/scripts/preloadProvider.d.ts +0 -0
- /package/{lib → esm}/scripts/provider.d.ts +0 -0
- /package/{lib → esm}/types.js +0 -0
package/lib/scripts/publish.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { ipcMain } from 'electron';
|
|
2
|
-
import { Access, IPCChannel, Scope } from '../enums';
|
|
3
|
-
const publicInfo = {
|
|
4
|
-
properties: new Set(),
|
|
5
|
-
functions: new Set(),
|
|
6
|
-
accesses: {},
|
|
7
|
-
scopes: {}
|
|
8
|
-
};
|
|
9
|
-
ipcMain.on(IPCChannel.getPublicInfo, e => e.returnValue = publicInfo);
|
|
10
|
-
/**
|
|
11
|
-
* Makes the function available for **renderer** and **preload** processes.
|
|
12
|
-
*
|
|
13
|
-
* _only for function_
|
|
14
|
-
* @param name - name by which the function will be accessed
|
|
15
|
-
* @param func - linked function
|
|
16
|
-
* @param scopes - function scopes
|
|
17
|
-
*/
|
|
18
|
-
export function publicFunction(name, func, scopes = [Scope.preload, Scope.renderer]) {
|
|
19
|
-
const { functions } = publicInfo;
|
|
20
|
-
const channel = IPCChannel.functionCall + name;
|
|
21
|
-
functions.add(name);
|
|
22
|
-
if (!publicInfo.scopes[name])
|
|
23
|
-
publicInfo.scopes[name] = new Set(scopes);
|
|
24
|
-
ipcMain.removeAllListeners(channel);
|
|
25
|
-
ipcMain.on(channel, (e, ...args) => {
|
|
26
|
-
try {
|
|
27
|
-
const result = func(...args);
|
|
28
|
-
if (result instanceof Promise) {
|
|
29
|
-
const promiseChannel = channel + IPCChannel.promisePostfix;
|
|
30
|
-
result
|
|
31
|
-
.then(value => e.sender.send(promiseChannel, { value }))
|
|
32
|
-
.catch(reason => e.sender.send(promiseChannel, { error: String(reason) }));
|
|
33
|
-
e.returnValue = { promiseChannel };
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
e.returnValue = { value: result };
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
e.returnValue = { error: String(error) };
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Makes the function available for **renderer** and **preload** processes.
|
|
46
|
-
*
|
|
47
|
-
* _only for variables_
|
|
48
|
-
* @param name - name by which the variable will be accessed
|
|
49
|
-
* @param value - variable getter/setter
|
|
50
|
-
* @param scopes - variable scopes
|
|
51
|
-
*/
|
|
52
|
-
export function publicVariable(name, value, scopes = [Scope.renderer, Scope.preload]) {
|
|
53
|
-
const { properties } = publicInfo;
|
|
54
|
-
const getChannel = IPCChannel.propertyGet + name;
|
|
55
|
-
const setChannel = IPCChannel.propertySet + name;
|
|
56
|
-
const { get: getter, set: setter } = value;
|
|
57
|
-
properties.add(name);
|
|
58
|
-
if (!publicInfo.scopes[name])
|
|
59
|
-
publicInfo.scopes[name] = new Set(scopes);
|
|
60
|
-
if (!publicInfo.accesses[name]) {
|
|
61
|
-
const accesses = [];
|
|
62
|
-
getter && accesses.push(Access.get);
|
|
63
|
-
setter && accesses.push(Access.set);
|
|
64
|
-
publicInfo.accesses[name] = new Set(accesses);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
const accesses = publicInfo.accesses[name];
|
|
68
|
-
getter && accesses.add(Access.get);
|
|
69
|
-
setter && accesses.add(Access.set);
|
|
70
|
-
}
|
|
71
|
-
if (getter) {
|
|
72
|
-
ipcMain.removeAllListeners(getChannel);
|
|
73
|
-
ipcMain.on(getChannel, event => {
|
|
74
|
-
try {
|
|
75
|
-
const result = getter();
|
|
76
|
-
event.returnValue = { value: result };
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
event.returnValue = { error };
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
if (setter) {
|
|
84
|
-
ipcMain.removeAllListeners(setChannel);
|
|
85
|
-
ipcMain.on(setChannel, (event, ...args) => {
|
|
86
|
-
try {
|
|
87
|
-
setter(args[0]);
|
|
88
|
-
event.returnValue = { value: null };
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
event.returnValue = { error };
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
export function addScope(key, scope) {
|
|
97
|
-
publicInfo.scopes[key] = new Set([scope]);
|
|
98
|
-
}
|
|
99
|
-
export function addAccess(key, access) {
|
|
100
|
-
publicInfo.accesses[key] = new Set([access]);
|
|
101
|
-
}
|
|
File without changes
|
/package/{lib → esm}/preload.js
RENAMED
|
File without changes
|
|
File without changes
|
/package/{lib → esm}/renderer.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{lib → esm}/types.js
RENAMED
|
File without changes
|