emr-bridge 1.0.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/README.md ADDED
@@ -0,0 +1,283 @@
1
+ # Electron main-renderer bridge (emr-bridge)
2
+
3
+ _Only for Electron_
4
+ JS library for easily providing access to the **main** from the **renderer** process
5
+
6
+ ## Table of contents
7
+
8
+ - [Installation](#installation)
9
+ - [Usage](#usage)
10
+ - [static](#static-methods-and-properties)
11
+ - [non-static](#methods-and-properties)
12
+ - [functions and variables](#functions-and-variables)
13
+ - [scopes](#scopes)
14
+ - [access](#restricting-access-to-variables)
15
+ - [usage in renderer](#access-from-renderer-and-preload)
16
+
17
+ ## Installation
18
+
19
+ ```
20
+ npm i emr-bridge
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ There are three ways to use
26
+
27
+ **IMPORTANT**: In any of the cases, you need to insert this code into preload
28
+
29
+ ```ts
30
+ // Preload process
31
+ import { provideFromMain } from 'emr-bridge/preload'
32
+
33
+ const contextIsolation = true
34
+
35
+ provideFromMain(contextIsolation)
36
+ ```
37
+
38
+ ### Static methods and properties
39
+
40
+ Use **publicStaticMethod**/**publicStaticProperty** decorators
41
+
42
+ ```ts
43
+ // Main process
44
+ import { publicStaticMethod, publicStaticProperty, access, Access } from 'emr-bridge'
45
+
46
+ class User {
47
+ private static name = 'Name'
48
+ private static age = 20
49
+ private static money = 1000
50
+
51
+ @publicStaticProperty()
52
+ static get balance(): string {
53
+ return `${this.money}$`
54
+ }
55
+
56
+ static set balance(newBalance: string) {
57
+ this.money = Number(newBalance.split('$')[0])
58
+ }
59
+
60
+ @publicStaticProperty('userInfo')
61
+ static get info(): string {
62
+ return `Name: '${this.name}'; Age: '${this.age}'; Money: '${this.money}';`
63
+ }
64
+
65
+ @access(Access.get)
66
+ @publicStaticMethod()
67
+ static setName(newName: string): void {
68
+ this.name = newName
69
+ }
70
+
71
+ @publicStaticMethod('getUserAge')
72
+ static getAge(): number {
73
+ return this.age
74
+ }
75
+ }
76
+ ```
77
+
78
+ ### Methods and properties
79
+
80
+ Use **providePublic** and **publicMethod**/**publicProperty** decorators.
81
+
82
+ ```ts
83
+ // Main process
84
+ import { providePublic, publicMethod, publicProperty, access, Access } from 'emr-bridge'
85
+
86
+ class User {
87
+ private name = 'Name'
88
+ private age = 20
89
+ private money = 1000
90
+
91
+ @publicProperty()
92
+ get balance(): string {
93
+ return `${this.money}$`
94
+ }
95
+
96
+ set balance(newBalance: string) {
97
+ this.money = Number(newBalance.split('$')[0])
98
+ }
99
+
100
+ @access(Access.get)
101
+ @publicProperty('userInfo')
102
+ get info(): string {
103
+ return `Name: '${this.name}'; Age: '${this.age}'; Money: '${this.money}';`
104
+ }
105
+
106
+ @publicMethod()
107
+ setName(newName: string): void {
108
+ this.name = newName
109
+ }
110
+
111
+ @publicMethod('getUserAge')
112
+ getAge(): number {
113
+ return this.age
114
+ }
115
+ }
116
+
117
+ const user = providePublic(new User())
118
+ ```
119
+
120
+ ### Functions and variables
121
+
122
+ Use **publicFunction** and **publicVariable**.
123
+
124
+ ```ts
125
+ // Main process
126
+ import { publicFunction, publicVariable } from 'emr-bridge'
127
+
128
+ publicFunction(sayHello, 'sayHello')
129
+ publicFunction(getName, 'getUserName')
130
+ publicVariable('count', {
131
+ get: () => count,
132
+ set: (value: number) => count = value
133
+ })
134
+
135
+ let count = 0
136
+
137
+ const user = {
138
+ name: 'Name',
139
+ age: 20
140
+ }
141
+
142
+ function sayHello(name: string): string {
143
+ return `Hello, ${name}!`
144
+ }
145
+
146
+ function getName(): string {
147
+ return user.name
148
+ }
149
+ ```
150
+
151
+ ### Scopes
152
+
153
+ In order to set a specific scope, use the **scope** decorator
154
+
155
+ ```ts
156
+ // Main process
157
+
158
+ // static and non-static
159
+ import { scope, Scope, providePublic, publicStaticMethod, publicMethod, publicProperty } from 'emr-bridge'
160
+
161
+ class User {
162
+ private static age = 20
163
+ private name = 'Name'
164
+
165
+ @scope(Scope.preload)
166
+ @publicProperty()
167
+ get count(): number {
168
+ return 30
169
+ }
170
+
171
+ @scope(Scope.preload)
172
+ @publicStaticMethod()
173
+ static getAge(): number {
174
+ return this.age
175
+ }
176
+
177
+ @scope(Scope.renderer)
178
+ @publicMethod('getUserName')
179
+ getName(): string {
180
+ return this.name
181
+ }
182
+ }
183
+
184
+ providePublic(new User())
185
+
186
+ // functions and variables
187
+ import { publicFunction, publicVariable, Scope } from 'emr-bridge'
188
+
189
+ publicFunction(getName, 'getName', [Scope.preload])
190
+ publicVariable('count', {
191
+ get: () => count,
192
+ set: (value: number) => count = value
193
+ }, [Scope.renderer])
194
+
195
+ let count = 0
196
+
197
+ function getName(): string {
198
+ return 'Name'
199
+ }
200
+ ```
201
+
202
+ By default, the entity is available in any scope.
203
+ Using an entity outside the specified scope _will cause an error_.
204
+
205
+ ### Restricting access to variables
206
+
207
+ ```ts
208
+ // Main process
209
+
210
+ // static and non-static
211
+ import { publicStaticProperty, publicProperty, providePublic, access, Access } from 'emr-bridge'
212
+
213
+ class User {
214
+ private static name = 'Name'
215
+ private static surname = 'Surname'
216
+
217
+ @access(Access.get)
218
+ @publicStaticProperty()
219
+ static get fullName(): string {
220
+ return `${this.name} ${this.surname}`
221
+ }
222
+
223
+ @access(Access.get)
224
+ @publicProperty('userAge')
225
+ get age(): number {
226
+ return 20
227
+ }
228
+ }
229
+
230
+ providePublic(new User())
231
+
232
+ // for variables
233
+ import { publicVariable } from 'emr-bridge'
234
+
235
+ publicVariable('count', {
236
+ get: () => count, // get access
237
+ set: (value: number) => count = value // set access
238
+ })
239
+
240
+ let count = 0
241
+ ```
242
+
243
+ ### Access from renderer and preload
244
+
245
+ For _preload_, use **Main** from 'emr-bridge/preload'
246
+
247
+ ```ts
248
+ // Preload process
249
+ import { Main, provideFromMain } from 'emr-bridge/preload'
250
+
251
+ provideFromMain()
252
+
253
+ type ProvidedPublic = {
254
+ getUserName(): string
255
+ setUserAge(newAge: number): void
256
+ count: number
257
+ }
258
+
259
+ const main = Main.as<ProvidedPublic>()
260
+
261
+ main.getUserName()
262
+ main.count++
263
+ main.setUserAge(20)
264
+ ```
265
+
266
+ For _renderer_, use **Bridge** from 'emr-bridge/renderer'
267
+
268
+ ```ts
269
+ // Renderer process
270
+ import { Bridge } from 'emr-bridge/renderer'
271
+
272
+ type ProvidedPublic = {
273
+ getUserName(): string
274
+ setUserAge(newAge: number): void
275
+ count: number
276
+ }
277
+
278
+ const bridge = Bridge.as<ProvidedPubic>()
279
+
280
+ bridge.getUserName()
281
+ bridge.count--
282
+ bridge.setUserAge(30)
283
+ ```
@@ -0,0 +1,10 @@
1
+ declare const target: {
2
+ as: <T>() => T;
3
+ };
4
+ /**
5
+ * Bridge between `renderer` and `main` processes.
6
+ *
7
+ * _only for renderer process_
8
+ */
9
+ export declare const Bridge: typeof target;
10
+ export {};
package/lib/bridge.js ADDED
@@ -0,0 +1,98 @@
1
+ import { Access, Scope } from './enums';
2
+ if (!window.__provider__) {
3
+ throw new Error('Required methods not provided. Did you forget to call "provide" in preload?');
4
+ }
5
+ const provider = window.__provider__;
6
+ const info = provider.getInfo();
7
+ const scopes = provider.getScopes();
8
+ const accesses = provider.getAccesses();
9
+ function errorHandler(error, channel) {
10
+ console.error(`Error on ${channel}.\n${error}`.replace('Error: ', ''));
11
+ }
12
+ const target = {
13
+ as: () => Bridge
14
+ };
15
+ /**
16
+ * Bridge between `renderer` and `main` processes.
17
+ *
18
+ * _only for renderer process_
19
+ */
20
+ export const Bridge = new Proxy(target, {
21
+ get(target, key) {
22
+ if (key in target)
23
+ return target[key];
24
+ const isFunction = info.functions.has(key);
25
+ const isProperty = info.properties.has(key);
26
+ if (!isFunction && !isProperty) {
27
+ throw new Error(`'${key}' is not provided from main`);
28
+ }
29
+ if (!scopes[key].has(Scope.renderer)) {
30
+ throw new Error(`'${key}' is not provided into renderer scope`);
31
+ }
32
+ if (isFunction) {
33
+ return (...args) => {
34
+ const result = provider.provided.functions[key](...args);
35
+ if (result.error) {
36
+ errorHandler(result.error, key);
37
+ return;
38
+ }
39
+ if (result.promiseChannel) {
40
+ return new Promise((resolve, reject) => {
41
+ provider.waitPromise(key, resolve, reject);
42
+ });
43
+ }
44
+ return result.value;
45
+ };
46
+ }
47
+ if (isProperty) {
48
+ if (!accesses[key].has(Access.get)) {
49
+ throw new Error(`No access to getting the '${key}' property`);
50
+ }
51
+ const result = provider.provided.properties[key];
52
+ if (result.error) {
53
+ errorHandler(result.error, key);
54
+ return;
55
+ }
56
+ return result.value;
57
+ }
58
+ },
59
+ set(target, key, newValue) {
60
+ const isFunction = info.functions.has(key);
61
+ const isProperty = info.properties.has(key);
62
+ if (isFunction) {
63
+ throw new Error(`Function '${key}' is readonly`);
64
+ }
65
+ if (!isProperty) {
66
+ throw new Error(`Property '${key}' is not provided from main`);
67
+ }
68
+ if (!scopes[key].has(Scope.renderer)) {
69
+ throw new Error(`'${key}' is not provided into renderer scope`);
70
+ }
71
+ if (!accesses[key].has(Access.set)) {
72
+ throw new Error(`No access to setting the '${key}' property`);
73
+ }
74
+ provider.provided.properties[key] = newValue;
75
+ return true;
76
+ },
77
+ ownKeys(target) {
78
+ const keys = [];
79
+ for (const key of [...info.functions, ...info.properties]) {
80
+ if (scopes[key].has(Scope.renderer)) {
81
+ keys.push(key);
82
+ }
83
+ }
84
+ for (const key in target) {
85
+ keys.push(key);
86
+ }
87
+ return keys;
88
+ },
89
+ has(target, key) {
90
+ const keys = [];
91
+ for (const key of [...info.functions, ...info.properties]) {
92
+ if (scopes[key].has(Scope.renderer)) {
93
+ keys.push(key);
94
+ }
95
+ }
96
+ return (key in target) || keys.includes(key);
97
+ }
98
+ });
package/lib/enums.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ export declare enum Access {
2
+ get = "get",
3
+ set = "set"
4
+ }
5
+ export declare enum Scope {
6
+ renderer = "renderer",
7
+ preload = "preload"
8
+ }
9
+ export declare enum IPCChannel {
10
+ getPublicScopes = "GET_PUBLIC_SCOPES",
11
+ getPublicInfo = "GET_PUBLIC_INFO",
12
+ getPublicAccesses = "GET_PUBLIC_ACCESSES",
13
+ functionCall = "FUNCTION_CALL_",
14
+ propertyGet = "PROPERTY_GET_",
15
+ propertySet = "PROPERTY_SET_",
16
+ promisePostfix = "_PROMISE"
17
+ }
package/lib/enums.js ADDED
@@ -0,0 +1,20 @@
1
+ export var Access;
2
+ (function (Access) {
3
+ Access["get"] = "get";
4
+ Access["set"] = "set";
5
+ })(Access || (Access = {}));
6
+ export var Scope;
7
+ (function (Scope) {
8
+ Scope["renderer"] = "renderer";
9
+ Scope["preload"] = "preload";
10
+ })(Scope || (Scope = {}));
11
+ export var IPCChannel;
12
+ (function (IPCChannel) {
13
+ IPCChannel["getPublicScopes"] = "GET_PUBLIC_SCOPES";
14
+ IPCChannel["getPublicInfo"] = "GET_PUBLIC_INFO";
15
+ IPCChannel["getPublicAccesses"] = "GET_PUBLIC_ACCESSES";
16
+ IPCChannel["functionCall"] = "FUNCTION_CALL_";
17
+ IPCChannel["propertyGet"] = "PROPERTY_GET_";
18
+ IPCChannel["propertySet"] = "PROPERTY_SET_";
19
+ IPCChannel["promisePostfix"] = "_PROMISE";
20
+ })(IPCChannel || (IPCChannel = {}));
package/lib/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { scope, access, publicMethod, publicProperty, publicFunction, publicVariable, publicStaticMethod, publicStaticProperty, providePublic } from './publish';
2
+ export { Access, Scope } from './enums';
3
+ export type { PublicFunction, PublicProperty } from './types';
package/lib/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { scope, access, publicMethod, publicProperty, publicFunction, publicVariable, publicStaticMethod, publicStaticProperty, providePublic } from './publish';
2
+ export { Access, Scope } from './enums';
package/lib/main.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ declare const target: {
2
+ as: <T>() => T;
3
+ };
4
+ /**
5
+ * Bridge between `preload` and `main` processes.
6
+ *
7
+ * _only for preload process_
8
+ */
9
+ export declare const Main: typeof target;
10
+ export {};
package/lib/main.js ADDED
@@ -0,0 +1,110 @@
1
+ import { ipcRenderer } from 'electron';
2
+ import { Access, IPCChannel, Scope } from './enums';
3
+ const info = ipcRenderer.sendSync(IPCChannel.getPublicInfo);
4
+ const scopes = ipcRenderer.sendSync(IPCChannel.getPublicScopes);
5
+ const accesses = ipcRenderer.sendSync(IPCChannel.getPublicAccesses);
6
+ if (!info) {
7
+ throw new Error('Public methods from main is not provided');
8
+ }
9
+ function errorHandler(error, channel) {
10
+ console.error(`Error on ${channel}.\n${error}`.replace('Error: ', ''));
11
+ }
12
+ const target = {
13
+ as: () => Main
14
+ };
15
+ /**
16
+ * Bridge between `preload` and `main` processes.
17
+ *
18
+ * _only for preload process_
19
+ */
20
+ export const Main = new Proxy(target, {
21
+ get(target, key) {
22
+ if (key in target)
23
+ return target[key];
24
+ const isFunction = info.functions.has(key);
25
+ const isProperty = info.properties.has(key);
26
+ if (!isFunction && !isProperty) {
27
+ throw new Error(`'${key}' is not provided from main`);
28
+ }
29
+ if (!scopes[key].has(Scope.preload)) {
30
+ throw new Error(`'${key}' is not provided into preload scope`);
31
+ }
32
+ if (isFunction) {
33
+ return (...args) => {
34
+ const channel = IPCChannel.functionCall + key;
35
+ const result = ipcRenderer.sendSync(channel, ...args);
36
+ if (result.error) {
37
+ errorHandler(result.error, key);
38
+ return;
39
+ }
40
+ if (result.promiseChannel) {
41
+ return new Promise((resolve, reject) => {
42
+ ipcRenderer.once(result.promiseChannel, (_, result) => {
43
+ if (result.error)
44
+ reject(result.error);
45
+ else
46
+ resolve(result.value);
47
+ });
48
+ });
49
+ }
50
+ return result.value;
51
+ };
52
+ }
53
+ if (isProperty) {
54
+ if (!accesses[key].has(Access.get)) {
55
+ throw new Error(`No access to getting the '${key}' property`);
56
+ }
57
+ const channel = IPCChannel.propertyGet + key;
58
+ const getterResult = ipcRenderer.sendSync(channel);
59
+ if (getterResult.error) {
60
+ errorHandler(getterResult.error, key);
61
+ return;
62
+ }
63
+ return getterResult.value;
64
+ }
65
+ },
66
+ set(target, key, newValue) {
67
+ const isFunction = info.functions.has(key);
68
+ const isProperty = info.properties.has(key);
69
+ if (isFunction) {
70
+ throw new Error(`Function '${key}' is readonly`);
71
+ }
72
+ if (!isProperty) {
73
+ throw new Error(`Property '${key}' is not provided from main`);
74
+ }
75
+ if (!scopes[key].has(Scope.preload)) {
76
+ throw new Error(`'${key}' is not provided into preload scope`);
77
+ }
78
+ if (!accesses[key].has(Access.set)) {
79
+ throw new Error(`No access to setting the '${key}' property`);
80
+ }
81
+ const channel = IPCChannel.propertySet + key;
82
+ const setterResult = ipcRenderer.sendSync(channel, newValue);
83
+ if (setterResult.error) {
84
+ errorHandler(setterResult.error, key);
85
+ return false;
86
+ }
87
+ return true;
88
+ },
89
+ ownKeys(target) {
90
+ const keys = [];
91
+ for (const key of [...info.functions, ...info.properties]) {
92
+ if (scopes[key].has(Scope.preload)) {
93
+ keys.push(key);
94
+ }
95
+ }
96
+ for (const key in target) {
97
+ keys.push(key);
98
+ }
99
+ return keys;
100
+ },
101
+ has(target, key) {
102
+ const keys = [];
103
+ for (const key of [...info.functions, ...info.properties]) {
104
+ if (scopes[key].has(Scope.preload)) {
105
+ keys.push(key);
106
+ }
107
+ }
108
+ return (key in target) || keys.includes(key);
109
+ }
110
+ });
@@ -0,0 +1,2 @@
1
+ export { Main } from './main';
2
+ export { provideFromMain } from './provider';
package/lib/preload.js ADDED
@@ -0,0 +1,2 @@
1
+ export { Main } from './main';
2
+ export { provideFromMain } from './provider';
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Sets access to main from renderer
3
+ */
4
+ export declare function provideFromMain(contextIsolation?: boolean): void;
@@ -0,0 +1,63 @@
1
+ import { contextBridge, ipcRenderer } from 'electron';
2
+ import { Main } from './main';
3
+ import { IPCChannel } from './enums';
4
+ const info = ipcRenderer.sendSync(IPCChannel.getPublicInfo);
5
+ const scopes = ipcRenderer.sendSync(IPCChannel.getPublicScopes);
6
+ const accesses = ipcRenderer.sendSync(IPCChannel.getPublicAccesses);
7
+ const main = Main.as();
8
+ /**
9
+ * Sets access to main from renderer
10
+ */
11
+ export function provideFromMain(contextIsolation = true) {
12
+ const promises = {};
13
+ const provider = {
14
+ getInfo: () => info,
15
+ getScopes: () => scopes,
16
+ getAccesses: () => accesses,
17
+ waitPromise(name, resolve, reject) {
18
+ promises[name] = { resolve, reject };
19
+ },
20
+ provided: {
21
+ properties: {},
22
+ functions: {}
23
+ }
24
+ };
25
+ info.functions.forEach(funcName => {
26
+ Object.defineProperty(provider.provided.functions, funcName, {
27
+ value: (...args) => {
28
+ const result = main[funcName](...args);
29
+ if (result instanceof Promise) {
30
+ result
31
+ .then(value => {
32
+ if (!promises[funcName])
33
+ return;
34
+ promises[funcName].resolve(value);
35
+ })
36
+ .catch(reason => {
37
+ if (!promises[funcName])
38
+ return;
39
+ promises[funcName].reject?.(reason);
40
+ });
41
+ return { promiseChannel: funcName };
42
+ }
43
+ else {
44
+ return { value: result };
45
+ }
46
+ },
47
+ enumerable: true
48
+ });
49
+ });
50
+ info.properties.forEach(propName => {
51
+ Object.defineProperty(provider.provided.properties, propName, {
52
+ get: () => ({ value: main[propName] }),
53
+ set: value => main[propName] = value,
54
+ enumerable: true
55
+ });
56
+ });
57
+ if (contextIsolation) {
58
+ contextBridge.exposeInMainWorld('__provider__', provider);
59
+ }
60
+ else {
61
+ window.__provider__ = provider;
62
+ }
63
+ }
@@ -0,0 +1,66 @@
1
+ import { Access, Scope } from './enums';
2
+ import type { PublicFunction, PublicProperty } from './types';
3
+ /**
4
+ * Restricts the access scope
5
+ */
6
+ export declare function scope(scope: Scope): (target: any, key: string) => void;
7
+ /**
8
+ * Restricts access
9
+ */
10
+ export declare function access(access: Access): (target: any, key: string) => void;
11
+ /**
12
+ * Makes the method available for **renderer** and **preload** processes.
13
+ *
14
+ * _only for static_
15
+ * @param name - name by which the method will be accessed
16
+ */
17
+ export declare function publicStaticMethod(name?: string): MethodDecorator;
18
+ /**
19
+ * Makes the method available for **renderer** and **preload** processes.
20
+ *
21
+ * _only for non-static_
22
+ *
23
+ * _required `providePublic(classInstance)`_
24
+ * @param name - name by which the method will be accessed
25
+ */
26
+ export declare function publicMethod(name?: string): MethodDecorator;
27
+ /**
28
+ * Makes the property available for **renderer** and **preload** processes.
29
+ *
30
+ * _only for static_
31
+ * @param name - name by which the property will be accessed
32
+ */
33
+ export declare function publicStaticProperty(name?: string): PropertyDecorator;
34
+ /**
35
+ * Makes the property available for **renderer** and **preload** processes.
36
+ *
37
+ * _only for non-static_
38
+ *
39
+ * _required `providePublic(classInstance)`_
40
+ * @param name - name by which the property will be accessed
41
+ */
42
+ export declare function publicProperty(name?: string): PropertyDecorator;
43
+ /**
44
+ * Binds all public entities of a class to a specific instance.
45
+ *
46
+ * _only for class instance_
47
+ */
48
+ export declare function providePublic<InstanceType>(instance: InstanceType): InstanceType;
49
+ /**
50
+ * Makes the function available for **renderer** and **preload** processes.
51
+ *
52
+ * _only for function_
53
+ * @param func - linked function
54
+ * @param name - name by which the function will be accessed
55
+ * @param scopes - function scopes
56
+ */
57
+ export declare function publicFunction(func: PublicFunction, name: string, scopes?: Scope[]): void;
58
+ /**
59
+ * Makes the function available for **renderer** and **preload** processes.
60
+ *
61
+ * _only for variables_
62
+ * @param name - name by which the variable will be accessed
63
+ * @param value - variable getter/setter
64
+ * @param scopes - variable scopes
65
+ */
66
+ export declare function publicVariable(name: string, value: PublicProperty, scopes?: Scope[]): void;
package/lib/publish.js ADDED
@@ -0,0 +1,186 @@
1
+ import { ipcMain } from 'electron';
2
+ import { Access, IPCChannel, Scope } from './enums';
3
+ const publicScopes = {};
4
+ const publicAccesses = {};
5
+ const publicInfo = {
6
+ properties: new Set(),
7
+ functions: new Set()
8
+ };
9
+ ipcMain.on(IPCChannel.getPublicInfo, e => e.returnValue = publicInfo);
10
+ ipcMain.on(IPCChannel.getPublicScopes, e => e.returnValue = publicScopes);
11
+ ipcMain.on(IPCChannel.getPublicAccesses, e => e.returnValue = publicAccesses);
12
+ /**
13
+ * Restricts the access scope
14
+ */
15
+ export function scope(scope) {
16
+ return (target, key) => {
17
+ publicScopes[key] = new Set([scope]);
18
+ };
19
+ }
20
+ /**
21
+ * Restricts access
22
+ */
23
+ export function access(access) {
24
+ return (target, key) => {
25
+ publicAccesses[key] = new Set([access]);
26
+ };
27
+ }
28
+ /**
29
+ * Makes the method available for **renderer** and **preload** processes.
30
+ *
31
+ * _only for static_
32
+ * @param name - name by which the method will be accessed
33
+ */
34
+ export function publicStaticMethod(name) {
35
+ return (target, key) => {
36
+ publicFunction((...args) => target[key](...args), String(name ?? key));
37
+ };
38
+ }
39
+ /**
40
+ * Makes the method available for **renderer** and **preload** processes.
41
+ *
42
+ * _only for non-static_
43
+ *
44
+ * _required `providePublic(classInstance)`_
45
+ * @param name - name by which the method will be accessed
46
+ */
47
+ export function publicMethod(name) {
48
+ return (tgt, key, _) => {
49
+ const target = tgt;
50
+ const prevRegister = target.__register__ ?? (() => { });
51
+ target.__register__ = instance => {
52
+ prevRegister(instance);
53
+ publicStaticMethod(name)(instance, key, _);
54
+ };
55
+ };
56
+ }
57
+ /**
58
+ * Makes the property available for **renderer** and **preload** processes.
59
+ *
60
+ * _only for static_
61
+ * @param name - name by which the property will be accessed
62
+ */
63
+ export function publicStaticProperty(name) {
64
+ return (target, k) => {
65
+ const key = String(name ?? k);
66
+ publicVariable(key, {
67
+ get: () => target[k],
68
+ set: value => target[k] = value
69
+ });
70
+ };
71
+ }
72
+ /**
73
+ * Makes the property available for **renderer** and **preload** processes.
74
+ *
75
+ * _only for non-static_
76
+ *
77
+ * _required `providePublic(classInstance)`_
78
+ * @param name - name by which the property will be accessed
79
+ */
80
+ export function publicProperty(name) {
81
+ return (tgt, key) => {
82
+ const target = tgt;
83
+ const prevRegister = target.__register__ ?? (() => { });
84
+ target.__register__ = instance => {
85
+ prevRegister(instance);
86
+ publicStaticProperty(name)(instance, key);
87
+ };
88
+ };
89
+ }
90
+ /**
91
+ * Binds all public entities of a class to a specific instance.
92
+ *
93
+ * _only for class instance_
94
+ */
95
+ export function providePublic(instance) {
96
+ const target = instance;
97
+ if (!target.__register__) {
98
+ throw new Error('Public methods not defined');
99
+ }
100
+ target.__register__(instance);
101
+ target.__register__ = undefined;
102
+ return instance;
103
+ }
104
+ /**
105
+ * Makes the function available for **renderer** and **preload** processes.
106
+ *
107
+ * _only for function_
108
+ * @param func - linked function
109
+ * @param name - name by which the function will be accessed
110
+ * @param scopes - function scopes
111
+ */
112
+ export function publicFunction(func, name, scopes = [Scope.preload, Scope.renderer]) {
113
+ const { functions } = publicInfo;
114
+ const channel = IPCChannel.functionCall + name;
115
+ functions.add(name);
116
+ if (!publicScopes[name]) {
117
+ publicScopes[name] = new Set(scopes);
118
+ }
119
+ ipcMain.removeAllListeners(channel);
120
+ ipcMain.on(channel, (e, ...args) => {
121
+ try {
122
+ const result = func(...args);
123
+ if (result instanceof Promise) {
124
+ const promiseChannel = `${channel}${IPCChannel.promisePostfix}`;
125
+ result
126
+ .then(value => e.sender.send(promiseChannel, { value }))
127
+ .catch(reason => e.sender.send(promiseChannel, { error: String(reason) }));
128
+ e.returnValue = { promiseChannel };
129
+ }
130
+ else {
131
+ e.returnValue = { value: result };
132
+ }
133
+ }
134
+ catch (error) {
135
+ e.returnValue = { error: String(error) };
136
+ }
137
+ });
138
+ }
139
+ /**
140
+ * Makes the function available for **renderer** and **preload** processes.
141
+ *
142
+ * _only for variables_
143
+ * @param name - name by which the variable will be accessed
144
+ * @param value - variable getter/setter
145
+ * @param scopes - variable scopes
146
+ */
147
+ export function publicVariable(name, value, scopes = [Scope.renderer, Scope.preload]) {
148
+ const { properties } = publicInfo;
149
+ const getChannel = IPCChannel.propertyGet + name;
150
+ const setChannel = IPCChannel.propertySet + name;
151
+ const { get: getter, set: setter } = value;
152
+ properties.add(name);
153
+ if (!publicScopes[name]) {
154
+ publicScopes[name] = new Set(scopes);
155
+ }
156
+ if (!publicAccesses[name]) {
157
+ const accesses = [];
158
+ getter && accesses.push(Access.get);
159
+ setter && accesses.push(Access.set);
160
+ publicAccesses[name] = new Set(accesses);
161
+ }
162
+ if (getter) {
163
+ ipcMain.removeAllListeners(getChannel);
164
+ ipcMain.on(getChannel, event => {
165
+ try {
166
+ const result = getter();
167
+ event.returnValue = { value: result };
168
+ }
169
+ catch (error) {
170
+ event.returnValue = { error };
171
+ }
172
+ });
173
+ }
174
+ if (setter) {
175
+ ipcMain.removeAllListeners(setChannel);
176
+ ipcMain.on(setChannel, (event, ...args) => {
177
+ try {
178
+ setter(args[0]);
179
+ event.returnValue = { value: null };
180
+ }
181
+ catch (error) {
182
+ event.returnValue = { error };
183
+ }
184
+ });
185
+ }
186
+ }
@@ -0,0 +1 @@
1
+ export { Bridge } from './bridge';
@@ -0,0 +1 @@
1
+ export { Bridge } from './bridge';
@@ -0,0 +1 @@
1
+ {"program":{"fileNames":["../node_modules/typescript/lib/lib.es5.d.ts","../node_modules/typescript/lib/lib.es2015.d.ts","../node_modules/typescript/lib/lib.es2016.d.ts","../node_modules/typescript/lib/lib.es2017.d.ts","../node_modules/typescript/lib/lib.es2018.d.ts","../node_modules/typescript/lib/lib.es2019.d.ts","../node_modules/typescript/lib/lib.es2020.d.ts","../node_modules/typescript/lib/lib.es2021.d.ts","../node_modules/typescript/lib/lib.es2022.d.ts","../node_modules/typescript/lib/lib.esnext.d.ts","../node_modules/typescript/lib/lib.dom.d.ts","../node_modules/typescript/lib/lib.dom.iterable.d.ts","../node_modules/typescript/lib/lib.es2015.core.d.ts","../node_modules/typescript/lib/lib.es2015.collection.d.ts","../node_modules/typescript/lib/lib.es2015.generator.d.ts","../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../node_modules/typescript/lib/lib.es2015.promise.d.ts","../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../node_modules/typescript/lib/lib.es2017.object.d.ts","../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../node_modules/typescript/lib/lib.es2017.string.d.ts","../node_modules/typescript/lib/lib.es2017.intl.d.ts","../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../node_modules/typescript/lib/lib.es2018.intl.d.ts","../node_modules/typescript/lib/lib.es2018.promise.d.ts","../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../node_modules/typescript/lib/lib.es2019.array.d.ts","../node_modules/typescript/lib/lib.es2019.object.d.ts","../node_modules/typescript/lib/lib.es2019.string.d.ts","../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../node_modules/typescript/lib/lib.es2020.date.d.ts","../node_modules/typescript/lib/lib.es2020.promise.d.ts","../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../node_modules/typescript/lib/lib.es2020.string.d.ts","../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../node_modules/typescript/lib/lib.es2020.intl.d.ts","../node_modules/typescript/lib/lib.es2020.number.d.ts","../node_modules/typescript/lib/lib.es2021.promise.d.ts","../node_modules/typescript/lib/lib.es2021.string.d.ts","../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../node_modules/typescript/lib/lib.es2021.intl.d.ts","../node_modules/typescript/lib/lib.es2022.array.d.ts","../node_modules/typescript/lib/lib.es2022.error.d.ts","../node_modules/typescript/lib/lib.es2022.intl.d.ts","../node_modules/typescript/lib/lib.es2022.object.d.ts","../node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../node_modules/typescript/lib/lib.es2022.string.d.ts","../node_modules/typescript/lib/lib.esnext.intl.d.ts","../src/enums.ts","../src/bridge.ts","../src/types.ts","../src/global.d.ts","../node_modules/@types/node/ts4.8/assert.d.ts","../node_modules/@types/node/ts4.8/assert/strict.d.ts","../node_modules/@types/node/ts4.8/globals.d.ts","../node_modules/@types/node/ts4.8/async_hooks.d.ts","../node_modules/@types/node/ts4.8/buffer.d.ts","../node_modules/@types/node/ts4.8/child_process.d.ts","../node_modules/@types/node/ts4.8/cluster.d.ts","../node_modules/@types/node/ts4.8/console.d.ts","../node_modules/@types/node/ts4.8/constants.d.ts","../node_modules/@types/node/ts4.8/crypto.d.ts","../node_modules/@types/node/ts4.8/dgram.d.ts","../node_modules/@types/node/ts4.8/diagnostics_channel.d.ts","../node_modules/@types/node/ts4.8/dns.d.ts","../node_modules/@types/node/ts4.8/dns/promises.d.ts","../node_modules/@types/node/ts4.8/domain.d.ts","../node_modules/@types/node/ts4.8/events.d.ts","../node_modules/@types/node/ts4.8/fs.d.ts","../node_modules/@types/node/ts4.8/fs/promises.d.ts","../node_modules/@types/node/ts4.8/http.d.ts","../node_modules/@types/node/ts4.8/http2.d.ts","../node_modules/@types/node/ts4.8/https.d.ts","../node_modules/@types/node/ts4.8/inspector.d.ts","../node_modules/@types/node/ts4.8/module.d.ts","../node_modules/@types/node/ts4.8/net.d.ts","../node_modules/@types/node/ts4.8/os.d.ts","../node_modules/@types/node/ts4.8/path.d.ts","../node_modules/@types/node/ts4.8/perf_hooks.d.ts","../node_modules/@types/node/ts4.8/process.d.ts","../node_modules/@types/node/ts4.8/punycode.d.ts","../node_modules/@types/node/ts4.8/querystring.d.ts","../node_modules/@types/node/ts4.8/readline.d.ts","../node_modules/@types/node/ts4.8/repl.d.ts","../node_modules/@types/node/ts4.8/stream.d.ts","../node_modules/@types/node/ts4.8/stream/promises.d.ts","../node_modules/@types/node/ts4.8/stream/consumers.d.ts","../node_modules/@types/node/ts4.8/stream/web.d.ts","../node_modules/@types/node/ts4.8/string_decoder.d.ts","../node_modules/@types/node/ts4.8/test.d.ts","../node_modules/@types/node/ts4.8/timers.d.ts","../node_modules/@types/node/ts4.8/timers/promises.d.ts","../node_modules/@types/node/ts4.8/tls.d.ts","../node_modules/@types/node/ts4.8/trace_events.d.ts","../node_modules/@types/node/ts4.8/tty.d.ts","../node_modules/@types/node/ts4.8/url.d.ts","../node_modules/@types/node/ts4.8/util.d.ts","../node_modules/@types/node/ts4.8/v8.d.ts","../node_modules/@types/node/ts4.8/vm.d.ts","../node_modules/@types/node/ts4.8/wasi.d.ts","../node_modules/@types/node/ts4.8/worker_threads.d.ts","../node_modules/@types/node/ts4.8/zlib.d.ts","../node_modules/@types/node/ts4.8/globals.global.d.ts","../node_modules/@types/node/ts4.8/index.d.ts","../node_modules/electron/electron.d.ts","../src/publish.ts","../src/index.ts","../src/main.ts","../src/provider.ts","../src/preload.ts","../src/renderer.ts","../node_modules/@types/yauzl/index.d.ts"],"fileInfos":[{"version":"f20c05dbfe50a208301d2a1da37b9931bce0466eb5a1f4fe240971b4ecc82b67","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","1fc5ab7a764205c68fa10d381b08417795fc73111d6dd16b5b1ed36badb743d9","746d62152361558ea6d6115cf0da4dd10ede041d14882ede3568bce5dc4b4f1f","d11a03592451da2d1065e09e61f4e2a9bf68f780f4f6623c18b57816a9679d17","aea179452def8a6152f98f63b191b84e7cbd69b0e248c91e61fb2e52328abe8c",{"version":"9b087de7268e4efc5f215347a62656663933d63c0b1d7b624913240367b999ea","affectsGlobalScope":true},{"version":"3260e3386d9535b804205bdddb5618a9a27735bd22927f48ad54363abcd23d45","affectsGlobalScope":true},{"version":"adb996790133eb33b33aadb9c09f15c2c575e71fb57a62de8bf74dbf59ec7dfb","affectsGlobalScope":true},{"version":"8cc8c5a3bac513368b0157f3d8b31cfdcfe78b56d3724f30f80ed9715e404af8","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"c5c05907c02476e4bde6b7e76a79ffcd948aedd14b6a8f56e4674221b0417398","affectsGlobalScope":true},{"version":"0d5f52b3174bee6edb81260ebcd792692c32c81fd55499d69531496f3f2b25e7","affectsGlobalScope":true},{"version":"55f400eec64d17e888e278f4def2f254b41b89515d3b88ad75d5e05f019daddd","affectsGlobalScope":true},{"version":"181f1784c6c10b751631b24ce60c7f78b20665db4550b335be179217bacc0d5f","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"81cac4cbc92c0c839c70f8ffb94eb61e2d32dc1c3cf6d95844ca099463cf37ea","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"d154ea5bb7f7f9001ed9153e876b2d5b8f5c2bb9ec02b3ae0d239ec769f1f2ae","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"6e7997ef61de3132e4d4b2250e75343f487903ddf5370e7ce33cf1b9db9a63ed","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"09aa50414b80c023553090e2f53827f007a301bc34b0495bfb2c3c08ab9ad1eb","affectsGlobalScope":true},{"version":"d7f680a43f8cd12a6b6122c07c54ba40952b0c8aa140dcfcf32eb9e6cb028596","affectsGlobalScope":true},{"version":"3787b83e297de7c315d55d4a7c546ae28e5f6c0a361b7a1dcec1f1f50a54ef11","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"775d9c9fd150d5de79e0450f35bc8b8f94ae64e3eb5da12725ff2a649dccc777","affectsGlobalScope":true},{"version":"b248e32ca52e8f5571390a4142558ae4f203ae2f94d5bac38a3084d529ef4e58","affectsGlobalScope":true},{"version":"6c55633c733c8378db65ac3da7a767c3cf2cf3057f0565a9124a16a3a2019e87","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"34c839eaaa6d78c8674ae2c37af2236dee6831b13db7b4ef4df3ec889a04d4f2","affectsGlobalScope":true},{"version":"34478567f8a80171f88f2f30808beb7da15eac0538ae91282dd33dce928d98ed","affectsGlobalScope":true},{"version":"ab7d58e6161a550ff92e5aff755dc37fe896245348332cd5f1e1203479fe0ed1","affectsGlobalScope":true},{"version":"6bda95ea27a59a276e46043b7065b55bd4b316c25e70e29b572958fa77565d43","affectsGlobalScope":true},{"version":"aedb8de1abb2ff1095c153854a6df7deae4a5709c37297f9d6e9948b6806fa66","affectsGlobalScope":true},{"version":"a4da0551fd39b90ca7ce5f68fb55d4dc0c1396d589b612e1902f68ee090aaada","affectsGlobalScope":true},{"version":"11ffe3c281f375fff9ffdde8bbec7669b4dd671905509079f866f2354a788064","affectsGlobalScope":true},{"version":"52d1bb7ab7a3306fd0375c8bff560feed26ed676a5b0457fa8027b563aecb9a4","affectsGlobalScope":true},{"version":"54baee84b1946297e4d0d068f972d46754147533b3f5e1696632e891480d9c36","signature":"51459ae9ed3237ad8d5d264f8ac139ee5fa546b8d026162c70abbad29f140183"},{"version":"b86e7ae692ef56ebb918ca145dc22982895b560a936b06e0ac850d0b3f1314f3","signature":"aaa5ef99c8e26450e9b93ab0e574bf9da82770d0160e24a0104488d1a13109d4"},{"version":"c82ebfb46b6d439c6d372a426f6499d1d2939d2a684306c434fc085e2aedb8ec","signature":"98fbb6b27818e169e7c95488db82f7a881349485a401611b81b224ff76e2ac22"},{"version":"afe5dbe85989e01633ae250eb3c322eecdd22c3dfda158a029a839c0545b0dc1","affectsGlobalScope":true},"0d5a2ee1fdfa82740e0103389b9efd6bfe145a20018a2da3c02b89666181f4d9","a69c09dbea52352f479d3e7ac949fde3d17b195abe90b045d619f747b38d6d1a",{"version":"2f6c9750131d5d2fdaba85c164a930dc07d2d7e7e8970b89d32864aa6c72620c","affectsGlobalScope":true},"56d13f223ab40f71840795f5bef2552a397a70666ee60878222407f3893fb8d0",{"version":"aeeee3998c5a730f8689f04038d41cf4245c9edbf6ef29a698e45b36e399b8ed","affectsGlobalScope":true},"95843d5cfafced8f3f8a5ce57d2335f0bcd361b9483587d12a25e4bd403b8216","afc6e96061af46bcff47246158caee7e056f5288783f2d83d6858cd25be1c565",{"version":"34f5bcac12b36d70304b73de5f5aab3bb91bd9919f984be80579ebcad03a624e","affectsGlobalScope":true},"82408ed3e959ddc60d3e9904481b5a8dc16469928257af22a3f7d1a3bc7fd8c4","3a0c45fe95e8f0e2c5247d48acf3a522d2ef29f1ab0effb3c59a9c4fdd5edbcd","f50c975ab7b50e25a69e3d8a3773894125b44e9698924105f23b812bf7488baf","c993aac3b6d4a4620ef9651497069eb84806a131420e4f158ea9396fb8eb9b8c","76650408392bf49a8fbf3e2b6b302712a92d76af77b06e2da1cc8077359c4409","0af3121e68297b2247dd331c0d24dba599e50736a7517a5622d5591aae4a3122","06ccebc2c2db57d6bdbca63b71c4ae5e6ddc42d972fd8f122d4c1a28aa111b25",{"version":"81e8508d1e82278f5d3fee936f267e00c308af36219bfcee2631f9513c9c4017","affectsGlobalScope":true},"413a4be7f94f631235bbc83dad36c4d15e5a2ff02bca1efdbd03636d6454631b","20c468256fd68d3ef1fa53526e76d51d6aa91711e84d72c0343589b99238287e","a5f6d22760eef0178bebc5b5b5664a403109615a9c49da879ccd84438bd55223","8d4c16a26d59e3ce49741a7d4a6e8206b884e226cf308667c7778a0b2c0fee7f","ee3bad055a79f188626b1a7046f04ab151fdd3581e55c51d32face175bd9d06f","d61c7c41eb1960b1285e242fd102c162b65c0522985b839fadda59874308a170",{"version":"e8b18c6385ff784228a6f369694fcf1a6b475355ba89090a88de13587a9391d5","affectsGlobalScope":true},"11c8be5993cd30dbb5310d95ba6c54dbb8724221eed0c4b2e4a7d6a4f9a032dd","d10f4929cd610c26926d6784fc3f9f4120b789c03081b5d65fb2d2670a00fa04","fb0989383c6109f20281b3d31265293daefdd76d0d30551782c1654e93704f48","a4210a84a82b3e7a8cec5b2f3616e46d523f4f10cc1576d8f2fb89d0987b341e",{"version":"8207e7e6db9aa5fc7e61c8f17ba74cf9c115d26f51f91ee93f790815a7ea9dfb","affectsGlobalScope":true},"9f1069b9e2c051737b1f9b4f1baf50e4a63385a6a89c32235549ae87fc3d5492","ee18f2da7a037c6ceeb112a084e485aead9ea166980bf433474559eac1b46553","29c2706fa0cc49a2bd90c83234da33d08bb9554ecec675e91c1f85087f5a5324","0acbf26bf958f9e80c1ffa587b74749d2697b75b484062d36e103c137c562bc3","02b3239cf1b1ff8737e383ed5557f0247499d15f5bd21ab849b1a24687b6100c","1b952304137851e45bc009785de89ada562d9376177c97e37702e39e60c2f1ff",{"version":"806ef4cac3b3d9fa4a48d849c8e084d7c72fcd7b16d76e06049a9ed742ff79c0","affectsGlobalScope":true},"33eee034727baf564056b4ea719075c23d3b4767d0b5f9c6933b81f3d77774d2","c33a6ea7147af60d8e98f1ac127047f4b0d4e2ce28b8f08ff3de07ca7cc00637","a4471d2bdba495b2a6a30b8765d5e0282fa7009d88345a9528f73c37869d3b93",{"version":"aee7013623e7632fba449d4df1da92925b27d9b816cb05546044dbfe54c88ef4","affectsGlobalScope":true},"664d8f2d59164f2e08c543981453893bc7e003e4dfd29651ce09db13e9457980","c9d70d3d7191a66a81cb554557f8ed1cf736ea8397c44a864fe52689de18865a","998a3de5237518c0b3ac00a11b3b4417affb008aa20aedee52f3fdae3cb86151","ad41008ffe077206e1811fc873f4d9005b5fd7f6ab52bb6118fef600815a5cb4",{"version":"1aad825534c73852a1f3275e527d729a2c0640f539198fdfdfeb83b839851910","affectsGlobalScope":true},"badae0df9a8016ac36994b0a0e7b82ba6aaa3528e175a8c3cb161e4683eec03e","c3db860bcaaaeb3bbc23f353bbda1f8ab82756c8d5e973bebb3953cb09ea68f2","235a53595bd20b0b0eeb1a29cb2887c67c48375e92f03749b2488fbd46d0b1a0","bc09393cd4cd13f69cf1366d4236fbae5359bb550f0de4e15767e9a91d63dfb1","9c266243b01545e11d2733a55ad02b4c00ecdbda99c561cd1674f96e89cdc958","c71155c05fc76ff948a4759abc1cb9feec036509f500174bc18dad4c7827a60c",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"e3685a8957b4e2af64c3f04a58289ee0858a649dbcd963a2b897fe85858ae18a",{"version":"af13fcee09b628c8d6c8707c692430b44ae06b1169b2a167b1e4604a4a55e282","affectsGlobalScope":true},{"version":"1e7d1414c17b8cb069937fe6d9d52c647bdb300aa4faae0ebfb59c934e09285c","signature":"118db4eb201f24f2b4415628ca0b1f10250ea5028b5b5e0fefbda85e5e57ee0f"},{"version":"3d523b35b5827aa75a091ef7a2a4c7ba2a1e700e388e6272048b608a938191b3","signature":"4895c0e00d589047f08d558722cf7823925021c160e8d6da2aa121921938c511"},{"version":"a6ad4fd9ea11b4c1e8bfb8cc4ac00b20e7287e0ab0851cb5c5c71e093ec6b379","signature":"209b0c8b5e5ab0259d8c777d39fa2295d72090b3da60c514fe1a0beaf4a15634"},{"version":"39196528b1c22a489e5d0f51b9dc3a7b28246a35251e20eca520d9b0321ed410","signature":"cd4b74f7bb53330d45995128b44fc017e93ed9a086da4262a8adbcf121273ef2"},{"version":"58df1cc7e75f36df616b79f48f0c94ce3dbeeb285170bbd24465ae2b5369e7c7","signature":"06358a5f8f3ad3f1482ae5a20f821d77aa9d6278e2bedc89b796f4364445a8b5"},{"version":"881b32917fbb22384a0acb8ec845532a6f35a27bb7bca7d9c47a3a78bc8c54eb","signature":"bb4d6349051e838a4b12dbf722ce610ff381e5e268159f513ff4c4f1290afa70"},"65dfa4bc49ccd1355789abb6ae215b302a5b050fdee9651124fe7e826f33113c"],"options":{"allowSyntheticDefaultImports":true,"allowUnreachableCode":false,"declaration":true,"emitDeclarationOnly":false,"esModuleInterop":true,"experimentalDecorators":true,"module":99,"newLine":1,"noImplicitAny":false,"outDir":"./","skipLibCheck":true,"sourceMap":false,"strict":true,"target":99},"fileIdsList":[[60,104],[63,104],[64,69,104],[65,75,76,83,92,103,104],[65,66,75,83,104],[67,104],[68,69,76,84,104],[69,92,100,104],[70,72,75,83,104],[71,104],[72,73,104],[74,75,104],[75,104],[75,76,77,92,103,104],[75,76,77,92,104],[104],[78,83,92,103,104],[75,76,78,79,83,92,100,103,104],[78,80,92,100,103,104],[60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110],[75,81,104],[82,103,104],[72,75,83,92,104],[84,104],[85,104],[63,86,104],[87,102,104,108],[88,104],[89,104],[75,90,104],[90,91,104,106],[75,92,93,94,104],[92,94,104],[92,93,104],[95,104],[96,104],[75,98,99,104],[98,99,104],[69,83,100,104],[101,104],[83,102,104],[64,78,89,103,104],[69,104],[92,104,105],[104,106],[104,107],[64,69,75,77,86,92,103,104,106,108],[92,104,109],[75,92,104,111],[75,76,104,111],[56,104],[58,104],[56,58,104,113],[56,58,104,112],[104,115,116],[56,58,104,112,115],[57,104],[56,58,113],[115,116],[56,58],[57],[56]],"referencedMap":[[60,1],[61,1],[63,2],[64,3],[65,4],[66,5],[67,6],[68,7],[69,8],[70,9],[71,10],[72,11],[73,11],[74,12],[75,13],[76,14],[77,15],[62,16],[110,16],[78,17],[79,18],[80,19],[111,20],[81,21],[82,22],[83,23],[84,24],[85,25],[86,26],[87,27],[88,28],[89,29],[90,30],[91,31],[92,32],[94,33],[93,34],[95,35],[96,36],[97,16],[98,37],[99,38],[100,39],[101,40],[102,41],[103,42],[104,43],[105,44],[106,45],[107,46],[108,47],[109,48],[119,49],[112,50],[11,16],[12,16],[14,16],[13,16],[2,16],[15,16],[16,16],[17,16],[18,16],[19,16],[20,16],[21,16],[22,16],[3,16],[4,16],[26,16],[23,16],[24,16],[25,16],[27,16],[28,16],[29,16],[5,16],[30,16],[31,16],[32,16],[33,16],[6,16],[34,16],[35,16],[36,16],[37,16],[7,16],[38,16],[43,16],[44,16],[39,16],[40,16],[41,16],[42,16],[8,16],[48,16],[45,16],[46,16],[47,16],[49,16],[9,16],[50,16],[51,16],[52,16],[53,16],[54,16],[1,16],[10,16],[55,16],[57,51],[56,16],[59,52],[114,53],[115,54],[117,55],[116,56],[113,54],[118,57],[58,51]],"exportedModulesMap":[[60,1],[61,1],[63,2],[64,3],[65,4],[66,5],[67,6],[68,7],[69,8],[70,9],[71,10],[72,11],[73,11],[74,12],[75,13],[76,14],[77,15],[62,16],[110,16],[78,17],[79,18],[80,19],[111,20],[81,21],[82,22],[83,23],[84,24],[85,25],[86,26],[87,27],[88,28],[89,29],[90,30],[91,31],[92,32],[94,33],[93,34],[95,35],[96,36],[97,16],[98,37],[99,38],[100,39],[101,40],[102,41],[103,42],[104,43],[105,44],[106,45],[107,46],[108,47],[109,48],[119,49],[112,50],[11,16],[12,16],[14,16],[13,16],[2,16],[15,16],[16,16],[17,16],[18,16],[19,16],[20,16],[21,16],[22,16],[3,16],[4,16],[26,16],[23,16],[24,16],[25,16],[27,16],[28,16],[29,16],[5,16],[30,16],[31,16],[32,16],[33,16],[6,16],[34,16],[35,16],[36,16],[37,16],[7,16],[38,16],[43,16],[44,16],[39,16],[40,16],[41,16],[42,16],[8,16],[48,16],[45,16],[46,16],[47,16],[49,16],[9,16],[50,16],[51,16],[52,16],[53,16],[54,16],[1,16],[10,16],[55,16],[59,52],[114,58],[117,59],[113,60],[118,61],[58,62]],"semanticDiagnosticsPerFile":[60,61,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,62,110,78,79,80,111,81,82,83,84,85,86,87,88,89,90,91,92,94,93,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,119,112,11,12,14,13,2,15,16,17,18,19,20,21,22,3,4,26,23,24,25,27,28,29,5,30,31,32,33,6,34,35,36,37,7,38,43,44,39,40,41,42,8,48,45,46,47,49,9,50,51,52,53,54,1,10,55,57,56,59,114,115,117,116,113,118,58]},"version":"4.8.4"}
package/lib/types.d.ts ADDED
@@ -0,0 +1,39 @@
1
+ import type { Scope } from './enums';
2
+ import { Access } from './enums';
3
+ export interface IIPCResult {
4
+ value?: any;
5
+ error?: string;
6
+ promiseChannel?: string;
7
+ }
8
+ export interface IScopes {
9
+ [name: string]: Set<Scope>;
10
+ }
11
+ export interface IAccesses {
12
+ [name: string]: Set<Access>;
13
+ }
14
+ export interface IRendererPublic {
15
+ __register__?(instance: any): void;
16
+ }
17
+ export interface IProvider {
18
+ getInfo(): IInfo;
19
+ getScopes(): IScopes;
20
+ getAccesses(): IAccesses;
21
+ waitPromise(name: string, resolve: (value: any) => void, reject?: (reason?: any) => void): void;
22
+ provided: {
23
+ functions: {
24
+ [key: string]: (...args: any[]) => IIPCResult;
25
+ };
26
+ properties: {
27
+ [key: string]: IIPCResult;
28
+ };
29
+ };
30
+ }
31
+ export declare type PublicFunction = (...args: any[]) => any;
32
+ export declare type PublicProperty = {
33
+ get?(): any;
34
+ set?(value: any): void;
35
+ };
36
+ export interface IInfo {
37
+ properties: Set<string>;
38
+ functions: Set<string>;
39
+ }
package/lib/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "emr-bridge",
3
+ "version": "1.0.0",
4
+ "description": "Allows you to easily give access to main methods from the renderer process",
5
+ "main": "lib/index.js",
6
+ "scripts": {
7
+ "compile": "tsc --project ./tsconfig.json"
8
+ },
9
+ "types": "lib/index.d.ts",
10
+ "files": [
11
+ "lib"
12
+ ],
13
+ "typesVersions": {
14
+ "*": {
15
+ ".": [
16
+ "./lib/index.d.ts"
17
+ ],
18
+ "renderer": [
19
+ "./lib/renderer.d.ts"
20
+ ],
21
+ "preload": [
22
+ "./lib/preload.d.ts"
23
+ ],
24
+ "main": [
25
+ "./lib/index.d.ts"
26
+ ]
27
+ }
28
+ },
29
+ "exports": {
30
+ ".": "./lib/index.js",
31
+ "./renderer": "./lib/renderer.js",
32
+ "./preload": "./lib/preload.js",
33
+ "./main": "./lib/index.js",
34
+ "./package.json": "./package.json"
35
+ },
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "https://github.com/VerZsuT/emr-bridge.git"
39
+ },
40
+ "keywords": [
41
+ "electron",
42
+ "ipc"
43
+ ],
44
+ "author": "VerZsuT",
45
+ "license": "MIT",
46
+ "devDependencies": {
47
+ "electron": "^21.0.1",
48
+ "typescript": "^4.8.4"
49
+ }
50
+ }