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.
Files changed (52) hide show
  1. package/LICENCE +1 -1
  2. package/README.md +136 -113
  3. package/cjs/enums.d.ts +5 -1
  4. package/cjs/enums.js +4 -0
  5. package/cjs/exp.d.ts +4 -0
  6. package/cjs/exp.js +21 -0
  7. package/cjs/index.d.ts +3 -4
  8. package/cjs/index.js +5 -7
  9. package/cjs/scripts/Bridge.js +6 -0
  10. package/cjs/scripts/Main.js +26 -0
  11. package/cjs/scripts/newDecorators.d.ts +63 -1
  12. package/cjs/scripts/newDecorators.js +50 -5
  13. package/cjs/scripts/oldDecorators.d.ts +167 -1
  14. package/cjs/scripts/oldDecorators.js +62 -1
  15. package/cjs/scripts/preloadProvider.js +37 -1
  16. package/cjs/scripts/provider.js +58 -1
  17. package/cjs/scripts/publish.d.ts +15 -1
  18. package/cjs/scripts/publish.js +96 -1
  19. package/cjs/types.d.ts +21 -0
  20. package/{lib → esm}/enums.d.ts +5 -1
  21. package/{lib → esm}/enums.js +4 -0
  22. package/esm/exp.d.ts +4 -0
  23. package/esm/exp.js +3 -0
  24. package/esm/index.d.ts +4 -0
  25. package/esm/index.js +3 -0
  26. package/{lib → esm}/scripts/Bridge.js +6 -0
  27. package/esm/scripts/Main.js +61 -0
  28. package/{lib → esm}/scripts/newDecorators.d.ts +63 -1
  29. package/{lib → esm}/scripts/newDecorators.js +48 -5
  30. package/esm/scripts/oldDecorators.d.ts +289 -0
  31. package/{lib → esm}/scripts/oldDecorators.js +58 -1
  32. package/esm/scripts/preloadProvider.js +87 -0
  33. package/{lib → esm}/scripts/provider.js +58 -1
  34. package/{lib → esm}/scripts/publish.d.ts +15 -1
  35. package/esm/scripts/publish.js +194 -0
  36. package/{lib → esm}/types.d.ts +21 -0
  37. package/package.json +29 -13
  38. package/lib/index.d.ts +0 -5
  39. package/lib/index.js +0 -4
  40. package/lib/scripts/Main.js +0 -35
  41. package/lib/scripts/oldDecorators.d.ts +0 -123
  42. package/lib/scripts/preloadProvider.js +0 -51
  43. package/lib/scripts/publish.js +0 -101
  44. /package/{lib → esm}/preload.d.ts +0 -0
  45. /package/{lib → esm}/preload.js +0 -0
  46. /package/{lib → esm}/renderer.d.ts +0 -0
  47. /package/{lib → esm}/renderer.js +0 -0
  48. /package/{lib → esm}/scripts/Bridge.d.ts +0 -0
  49. /package/{lib → esm}/scripts/Main.d.ts +0 -0
  50. /package/{lib → esm}/scripts/preloadProvider.d.ts +0 -0
  51. /package/{lib → esm}/scripts/provider.d.ts +0 -0
  52. /package/{lib → esm}/types.js +0 -0
@@ -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
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes