emr-bridge 1.7.1 → 2.0.1
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 +173 -366
- package/cjs/entries/index.d.ts +1 -0
- package/cjs/entries/index.js +6 -0
- package/cjs/entries/main.d.ts +2 -0
- package/cjs/entries/main.js +27 -0
- package/cjs/entries/preload.d.ts +3 -0
- package/cjs/entries/preload.js +29 -0
- package/cjs/entries/renderer.d.ts +2 -0
- package/cjs/entries/renderer.js +27 -0
- package/cjs/errors.d.ts +42 -10
- package/cjs/errors.js +77 -23
- package/cjs/scripts/base-bridge.d.ts +95 -0
- package/cjs/scripts/base-bridge.js +128 -0
- package/cjs/scripts/helpers/env.d.ts +19 -0
- package/cjs/scripts/helpers/env.js +28 -0
- package/cjs/scripts/helpers/errors.d.ts +12 -0
- package/cjs/scripts/helpers/errors.js +17 -0
- package/cjs/scripts/helpers/id.d.ts +9 -0
- package/cjs/scripts/helpers/id.js +14 -0
- package/cjs/scripts/helpers/index.d.ts +8 -0
- package/cjs/scripts/helpers/index.js +22 -0
- package/cjs/scripts/helpers/ipc-channel.d.ts +75 -0
- package/cjs/scripts/helpers/ipc-channel.js +78 -0
- package/cjs/scripts/helpers/ipc-event-in-main.d.ts +24 -0
- package/cjs/scripts/helpers/ipc-event-in-main.js +30 -0
- package/cjs/scripts/helpers/ipc-result.d.ts +26 -0
- package/cjs/scripts/helpers/ipc-result.js +48 -0
- package/cjs/scripts/helpers/transfer.d.ts +33 -0
- package/cjs/scripts/helpers/transfer.js +57 -0
- package/cjs/scripts/helpers/web-contents-events-container.d.ts +51 -0
- package/cjs/scripts/helpers/web-contents-events-container.js +75 -0
- package/cjs/scripts/main/publish.d.ts +36 -0
- package/cjs/scripts/main/publish.js +184 -0
- package/cjs/scripts/preload/bridge.d.ts +27 -0
- package/cjs/scripts/preload/bridge.js +85 -0
- package/cjs/scripts/preload/provider.d.ts +7 -0
- package/cjs/scripts/preload/provider.js +89 -0
- package/cjs/scripts/renderer/bridge.d.ts +6 -0
- package/cjs/scripts/renderer/bridge.js +74 -0
- package/cjs/scripts/renderer/tunnels.d.ts +171 -0
- package/cjs/scripts/renderer/tunnels.js +205 -0
- package/cjs/types.d.ts +189 -64
- package/esm/entries/index.d.ts +1 -0
- package/esm/entries/index.js +5 -0
- package/esm/entries/main.d.ts +2 -0
- package/esm/entries/main.js +5 -0
- package/esm/entries/preload.d.ts +3 -0
- package/esm/entries/preload.js +7 -0
- package/esm/entries/renderer.d.ts +2 -0
- package/esm/entries/renderer.js +6 -0
- package/esm/errors.d.ts +42 -10
- package/esm/errors.js +69 -16
- package/esm/scripts/base-bridge.d.ts +95 -0
- package/esm/scripts/base-bridge.js +125 -0
- package/esm/scripts/helpers/env.d.ts +19 -0
- package/esm/scripts/helpers/env.js +25 -0
- package/esm/scripts/helpers/errors.d.ts +12 -0
- package/esm/scripts/helpers/errors.js +14 -0
- package/esm/scripts/helpers/id.d.ts +9 -0
- package/esm/scripts/helpers/id.js +11 -0
- package/esm/scripts/helpers/index.d.ts +8 -0
- package/esm/scripts/helpers/index.js +8 -0
- package/esm/scripts/helpers/ipc-channel.d.ts +75 -0
- package/esm/scripts/helpers/ipc-channel.js +76 -0
- package/esm/scripts/helpers/ipc-event-in-main.d.ts +24 -0
- package/esm/scripts/helpers/ipc-event-in-main.js +27 -0
- package/esm/scripts/helpers/ipc-result.d.ts +26 -0
- package/esm/scripts/helpers/ipc-result.js +42 -0
- package/esm/scripts/helpers/transfer.d.ts +33 -0
- package/esm/scripts/helpers/transfer.js +54 -0
- package/esm/scripts/helpers/web-contents-events-container.d.ts +51 -0
- package/esm/scripts/helpers/web-contents-events-container.js +72 -0
- package/esm/scripts/main/publish.d.ts +36 -0
- package/esm/scripts/main/publish.js +177 -0
- package/esm/scripts/preload/bridge.d.ts +27 -0
- package/esm/scripts/preload/bridge.js +77 -0
- package/esm/scripts/preload/provider.d.ts +7 -0
- package/esm/scripts/preload/provider.js +84 -0
- package/esm/scripts/renderer/bridge.d.ts +6 -0
- package/esm/scripts/renderer/bridge.js +69 -0
- package/esm/scripts/renderer/tunnels.d.ts +171 -0
- package/esm/scripts/renderer/tunnels.js +203 -0
- package/esm/types.d.ts +189 -64
- package/package.json +23 -41
- package/cjs/enums.d.ts +0 -19
- package/cjs/enums.js +0 -25
- package/cjs/exp.d.ts +0 -4
- package/cjs/exp.js +0 -19
- package/cjs/index.d.ts +0 -4
- package/cjs/index.js +0 -18
- package/cjs/main.d.ts +0 -4
- package/cjs/main.js +0 -18
- package/cjs/preload.d.ts +0 -3
- package/cjs/preload.js +0 -10
- package/cjs/renderer.d.ts +0 -2
- package/cjs/renderer.js +0 -8
- package/cjs/scripts/bridge.d.ts +0 -8
- package/cjs/scripts/bridge.js +0 -57
- package/cjs/scripts/main.d.ts +0 -8
- package/cjs/scripts/main.js +0 -72
- package/cjs/scripts/new-decorators.d.ts +0 -150
- package/cjs/scripts/new-decorators.js +0 -141
- package/cjs/scripts/old-decorators.d.ts +0 -185
- package/cjs/scripts/old-decorators.js +0 -132
- package/cjs/scripts/preload-provider.d.ts +0 -7
- package/cjs/scripts/preload-provider.js +0 -96
- package/cjs/scripts/provider.d.ts +0 -25
- package/cjs/scripts/provider.js +0 -116
- package/cjs/scripts/publish.d.ts +0 -40
- package/cjs/scripts/publish.js +0 -232
- package/cjs/scripts/renderer-tunnels.d.ts +0 -47
- package/cjs/scripts/renderer-tunnels.js +0 -115
- package/esm/enums.d.ts +0 -19
- package/esm/enums.js +0 -22
- package/esm/exp.d.ts +0 -4
- package/esm/exp.js +0 -3
- package/esm/index.d.ts +0 -4
- package/esm/index.js +0 -3
- package/esm/main.d.ts +0 -4
- package/esm/main.js +0 -3
- package/esm/preload.d.ts +0 -3
- package/esm/preload.js +0 -2
- package/esm/renderer.d.ts +0 -2
- package/esm/renderer.js +0 -1
- package/esm/scripts/bridge.d.ts +0 -8
- package/esm/scripts/bridge.js +0 -52
- package/esm/scripts/main.d.ts +0 -8
- package/esm/scripts/main.js +0 -67
- package/esm/scripts/new-decorators.d.ts +0 -150
- package/esm/scripts/new-decorators.js +0 -132
- package/esm/scripts/old-decorators.d.ts +0 -185
- package/esm/scripts/old-decorators.js +0 -122
- package/esm/scripts/preload-provider.d.ts +0 -7
- package/esm/scripts/preload-provider.js +0 -91
- package/esm/scripts/provider.d.ts +0 -25
- package/esm/scripts/provider.js +0 -113
- package/esm/scripts/publish.d.ts +0 -40
- package/esm/scripts/publish.js +0 -220
- package/esm/scripts/renderer-tunnels.d.ts +0 -47
- package/esm/scripts/renderer-tunnels.js +0 -109
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import type { ClassGetterDecorator, ClassMethodDecorator, ClassPropertyDecorator, ClassSetterDecorator, EventReceiver, PublishGetterArgs, PublishMainEventArgs, PublishMethodArgs, PublishPropertyArgs, PublishRendererEventArgs, PublishSetterArgs } from '../types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Makes the method available for **renderer** and **preload** processes.
|
|
4
|
-
*
|
|
5
|
-
* _only new decorators_
|
|
6
|
-
*/
|
|
7
|
-
export declare function publicMethod(): ClassMethodDecorator;
|
|
8
|
-
/**
|
|
9
|
-
* Makes the method available for **renderer** and **preload** processes.
|
|
10
|
-
*
|
|
11
|
-
* _only new decorators_
|
|
12
|
-
*
|
|
13
|
-
* @param name - name by which the method will be accessed
|
|
14
|
-
*/
|
|
15
|
-
export declare function publicMethod(name: string): ClassMethodDecorator;
|
|
16
|
-
/**
|
|
17
|
-
* Makes the method available for **renderer** and **preload** processes.
|
|
18
|
-
*
|
|
19
|
-
* _only new decorators_
|
|
20
|
-
*
|
|
21
|
-
* @param args - publish args
|
|
22
|
-
*/
|
|
23
|
-
export declare function publicMethod(args: PublishMethodArgs): ClassMethodDecorator;
|
|
24
|
-
/**
|
|
25
|
-
* Makes the event available for **renderer** and **preload** processes.
|
|
26
|
-
*
|
|
27
|
-
* _only new decorators_
|
|
28
|
-
*/
|
|
29
|
-
export declare function publicClassMainEvent(): ClassMethodDecorator;
|
|
30
|
-
/**
|
|
31
|
-
* Makes the event available for **renderer** and **preload** processes.
|
|
32
|
-
*
|
|
33
|
-
* _only new decorators_
|
|
34
|
-
*
|
|
35
|
-
* @param name - name by which the event will be accessed
|
|
36
|
-
*/
|
|
37
|
-
export declare function publicClassMainEvent(name: string): ClassMethodDecorator;
|
|
38
|
-
/**
|
|
39
|
-
* Makes the event available for **renderer** and **preload** processes.
|
|
40
|
-
*
|
|
41
|
-
* _only new decorators_
|
|
42
|
-
*
|
|
43
|
-
* @param args - publish args
|
|
44
|
-
*/
|
|
45
|
-
export declare function publicClassMainEvent(args: PublishMainEventArgs): ClassMethodDecorator;
|
|
46
|
-
/**
|
|
47
|
-
* Makes the event from **renderer** and **preload** available for **main** process.
|
|
48
|
-
*
|
|
49
|
-
* _only new decorators_
|
|
50
|
-
*/
|
|
51
|
-
export declare function publicClassRendererEvent(): ClassPropertyDecorator;
|
|
52
|
-
/**
|
|
53
|
-
* Makes the event from **renderer** and **preload** available for **main** process.
|
|
54
|
-
*
|
|
55
|
-
* _only new decorators_
|
|
56
|
-
*
|
|
57
|
-
* @param name - name by which the event will be accessed
|
|
58
|
-
*/
|
|
59
|
-
export declare function publicClassRendererEvent(name: string): ClassPropertyDecorator;
|
|
60
|
-
/**
|
|
61
|
-
* Makes the event from **renderer** and **preload** available for **main** process.
|
|
62
|
-
*
|
|
63
|
-
* _only new decorators_
|
|
64
|
-
*
|
|
65
|
-
* @param receiver - linked receiver
|
|
66
|
-
*/
|
|
67
|
-
export declare function publicClassRendererEvent(receiver: EventReceiver): ClassPropertyDecorator;
|
|
68
|
-
/**
|
|
69
|
-
* Makes the event from **renderer** and **preload** available for **main** process.
|
|
70
|
-
*
|
|
71
|
-
* * _only new decorators_
|
|
72
|
-
*
|
|
73
|
-
* @param name - name by which the event will be accessed
|
|
74
|
-
* @param receiver - linked receiver
|
|
75
|
-
*/
|
|
76
|
-
export declare function publicClassRendererEvent(name: string, receiver: EventReceiver): ClassPropertyDecorator;
|
|
77
|
-
/**
|
|
78
|
-
* Makes the event from **renderer** and **preload** available for **main** process.
|
|
79
|
-
*
|
|
80
|
-
* _only new decorators_
|
|
81
|
-
*
|
|
82
|
-
* @param args - publish args
|
|
83
|
-
*/
|
|
84
|
-
export declare function publicClassRendererEvent(args: PublishRendererEventArgs): ClassPropertyDecorator;
|
|
85
|
-
/**
|
|
86
|
-
* Makes the property available for **renderer** and **preload** processes.
|
|
87
|
-
*
|
|
88
|
-
* _only new decorators_
|
|
89
|
-
*/
|
|
90
|
-
export declare function publicProperty(): ClassPropertyDecorator;
|
|
91
|
-
/**
|
|
92
|
-
* Makes the property available for **renderer** and **preload** processes.
|
|
93
|
-
*
|
|
94
|
-
* _only new decorators_
|
|
95
|
-
*
|
|
96
|
-
* @param name - name by which the property will be accessed
|
|
97
|
-
*/
|
|
98
|
-
export declare function publicProperty(name: string): ClassPropertyDecorator;
|
|
99
|
-
/**
|
|
100
|
-
* Makes the property available for **renderer** and **preload** processes.
|
|
101
|
-
*
|
|
102
|
-
* _only new decorators_
|
|
103
|
-
*
|
|
104
|
-
* @param args - publish args
|
|
105
|
-
*/
|
|
106
|
-
export declare function publicProperty(args: PublishPropertyArgs): ClassPropertyDecorator;
|
|
107
|
-
/**
|
|
108
|
-
* Makes the property getter available for **renderer** and **preload** processes.
|
|
109
|
-
*
|
|
110
|
-
* _only new decorators_
|
|
111
|
-
*/
|
|
112
|
-
export declare function publicGetter(): ClassGetterDecorator;
|
|
113
|
-
/**
|
|
114
|
-
* Makes the property getter available for **renderer** and **preload** processes.
|
|
115
|
-
*
|
|
116
|
-
* _only new decorators_
|
|
117
|
-
*
|
|
118
|
-
* @param name - name by which the property will be accessed
|
|
119
|
-
*/
|
|
120
|
-
export declare function publicGetter(name: string): ClassGetterDecorator;
|
|
121
|
-
/**
|
|
122
|
-
* Makes the property getter available for **renderer** and **preload** processes.
|
|
123
|
-
*
|
|
124
|
-
* _only new decorators_
|
|
125
|
-
*
|
|
126
|
-
* @param args - publish args
|
|
127
|
-
*/
|
|
128
|
-
export declare function publicGetter(args: PublishGetterArgs): ClassGetterDecorator;
|
|
129
|
-
/**
|
|
130
|
-
* Makes the property setter available for **renderer** and **preload** processes.
|
|
131
|
-
*
|
|
132
|
-
* _only new decorators_
|
|
133
|
-
*/
|
|
134
|
-
export declare function publicSetter(): ClassSetterDecorator;
|
|
135
|
-
/**
|
|
136
|
-
* Makes the property setter available for **renderer** and **preload** processes.
|
|
137
|
-
*
|
|
138
|
-
* _only new decorators_
|
|
139
|
-
*
|
|
140
|
-
* @param name - name by which the property will be accessed
|
|
141
|
-
*/
|
|
142
|
-
export declare function publicSetter(name: string): ClassSetterDecorator;
|
|
143
|
-
/**
|
|
144
|
-
* Makes the property setter available for **renderer** and **preload** processes.
|
|
145
|
-
*
|
|
146
|
-
* _only new decorators_
|
|
147
|
-
*
|
|
148
|
-
* @param args - publish args
|
|
149
|
-
*/
|
|
150
|
-
export declare function publicSetter(args: PublishSetterArgs): ClassSetterDecorator;
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { addAccess, addScope, publicFunction, publicMainEvent, publicRendererEvent, publicVariable } from './publish.js';
|
|
2
|
-
export function publicMethod(arg) {
|
|
3
|
-
return (method, context) => {
|
|
4
|
-
let name = String(context.name);
|
|
5
|
-
if (arg) {
|
|
6
|
-
if (typeof arg === 'string') {
|
|
7
|
-
name = arg;
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
10
|
-
name = arg.name ?? name;
|
|
11
|
-
if (arg.scope)
|
|
12
|
-
addScope(name, arg.scope);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
context.addInitializer(function () {
|
|
16
|
-
publicFunction(name, method.bind(this));
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
export function publicClassMainEvent(arg) {
|
|
21
|
-
return (method, context) => {
|
|
22
|
-
let name = String(context.name);
|
|
23
|
-
if (arg) {
|
|
24
|
-
if (typeof arg === 'string') {
|
|
25
|
-
name = arg;
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
name = arg.name ?? name;
|
|
29
|
-
if (arg.scope)
|
|
30
|
-
addScope(name, arg.scope);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
context.addInitializer(function () {
|
|
34
|
-
// @ts-ignore
|
|
35
|
-
this[context.name] = publicMainEvent(name, method.bind(this));
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
export function publicClassRendererEvent(arg) {
|
|
40
|
-
return (_, context) => {
|
|
41
|
-
let name = String(context.name);
|
|
42
|
-
let receiver = (v) => v;
|
|
43
|
-
if (arg) {
|
|
44
|
-
if (typeof arg === 'string') {
|
|
45
|
-
name = arg;
|
|
46
|
-
}
|
|
47
|
-
else if (typeof arg === 'object') {
|
|
48
|
-
name = arg.name ?? String(context.name);
|
|
49
|
-
receiver = arg.procFn ?? receiver;
|
|
50
|
-
if (arg.scope)
|
|
51
|
-
addScope(name, arg.scope);
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
receiver = arg;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
context.addInitializer(function () {
|
|
58
|
-
// @ts-ignore
|
|
59
|
-
this[context.name] = publicRendererEvent(name, receiver);
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
export function publicProperty(arg) {
|
|
64
|
-
return (_, context) => {
|
|
65
|
-
const key = String(context.name);
|
|
66
|
-
let name = key;
|
|
67
|
-
if (arg) {
|
|
68
|
-
if (typeof arg === 'string') {
|
|
69
|
-
name = arg;
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
name = arg.name ?? name;
|
|
73
|
-
if (arg.scope)
|
|
74
|
-
addScope(name, arg.scope);
|
|
75
|
-
if (arg.access)
|
|
76
|
-
addAccess(name, arg.access);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
context.addInitializer(function () {
|
|
80
|
-
publicVariable(name, {
|
|
81
|
-
get: () => {
|
|
82
|
-
// @ts-expect-error
|
|
83
|
-
return this[key];
|
|
84
|
-
},
|
|
85
|
-
set: (value) => {
|
|
86
|
-
// @ts-expect-error
|
|
87
|
-
this[key] = value;
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
export function publicGetter(arg) {
|
|
94
|
-
return (getter, context) => {
|
|
95
|
-
let name = String(context.name);
|
|
96
|
-
if (arg) {
|
|
97
|
-
if (typeof arg === 'string') {
|
|
98
|
-
name = arg;
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
name = arg.name ?? name;
|
|
102
|
-
if (arg.scope)
|
|
103
|
-
addScope(name, arg.scope);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
context.addInitializer(function () {
|
|
107
|
-
publicVariable(name, {
|
|
108
|
-
get: getter.bind(this)
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
export function publicSetter(arg) {
|
|
114
|
-
return (setter, context) => {
|
|
115
|
-
let name = String(context.name);
|
|
116
|
-
if (arg) {
|
|
117
|
-
if (typeof arg === 'string') {
|
|
118
|
-
name = arg;
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
name = arg.name ?? name;
|
|
122
|
-
if (arg.scope)
|
|
123
|
-
addScope(name, arg.scope);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
context.addInitializer(function () {
|
|
127
|
-
publicVariable(name, {
|
|
128
|
-
set: setter.bind(this)
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
}
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import type { EventReceiver, PublishMainEventArgs, PublishMethodArgs, PublishPropertyArgs, PublishRendererEventArgs } from '../types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Makes the method available for **renderer** and **preload** processes.
|
|
4
|
-
*
|
|
5
|
-
* _only for static_
|
|
6
|
-
* _experimental decorators_
|
|
7
|
-
*/
|
|
8
|
-
export declare function publicStaticMethod(): MethodDecorator;
|
|
9
|
-
/**
|
|
10
|
-
* Makes the method available for **renderer** and **preload** processes.
|
|
11
|
-
*
|
|
12
|
-
* _only for static_
|
|
13
|
-
* _experimental decorators_
|
|
14
|
-
*
|
|
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 static_
|
|
22
|
-
* _experimental decorators_
|
|
23
|
-
*
|
|
24
|
-
* @param args - publish args
|
|
25
|
-
*/
|
|
26
|
-
export declare function publicStaticMethod(args: PublishMethodArgs): MethodDecorator;
|
|
27
|
-
/**
|
|
28
|
-
* Makes the method available for **renderer** and **preload** processes.
|
|
29
|
-
*
|
|
30
|
-
* _only for non-static_
|
|
31
|
-
* _experimental decorators_
|
|
32
|
-
* _required `providePublic(classInstance)`_
|
|
33
|
-
*/
|
|
34
|
-
export declare function publicMethod(): MethodDecorator;
|
|
35
|
-
/**
|
|
36
|
-
* Makes the method available for **renderer** and **preload** processes.
|
|
37
|
-
*
|
|
38
|
-
* _only for non-static_
|
|
39
|
-
* _experimental decorators_
|
|
40
|
-
* _required `providePublic(classInstance)`_
|
|
41
|
-
*
|
|
42
|
-
* @param name - name by which the method will be accessed
|
|
43
|
-
*/
|
|
44
|
-
export declare function publicMethod(name: string): MethodDecorator;
|
|
45
|
-
/**
|
|
46
|
-
* Makes the method available for **renderer** and **preload** processes.
|
|
47
|
-
*
|
|
48
|
-
* _only for non-static_
|
|
49
|
-
* _experimental decorators_
|
|
50
|
-
* _required `providePublic(classInstance)`_
|
|
51
|
-
*
|
|
52
|
-
* @param args - publish args
|
|
53
|
-
*/
|
|
54
|
-
export declare function publicMethod(args: PublishMethodArgs): MethodDecorator;
|
|
55
|
-
/**
|
|
56
|
-
* Makes the event available for **renderer** and **preload** processes.
|
|
57
|
-
*
|
|
58
|
-
* _only for non-static_
|
|
59
|
-
* _experimental decorators_
|
|
60
|
-
* _required `providePublic(classInstance)`_
|
|
61
|
-
*/
|
|
62
|
-
export declare function publicClassMainEvent(): MethodDecorator;
|
|
63
|
-
/**
|
|
64
|
-
* Makes the event available for **renderer** and **preload** processes.
|
|
65
|
-
*
|
|
66
|
-
* _only for non-static_
|
|
67
|
-
* _experimental decorators_
|
|
68
|
-
* _required `providePublic(classInstance)`_
|
|
69
|
-
*
|
|
70
|
-
* @param name - name by which the event will be accessed
|
|
71
|
-
*/
|
|
72
|
-
export declare function publicClassMainEvent(name: string): MethodDecorator;
|
|
73
|
-
/**
|
|
74
|
-
* Makes the event available for **renderer** and **preload** processes.
|
|
75
|
-
*
|
|
76
|
-
* _only for non-static_
|
|
77
|
-
* _experimental decorators_
|
|
78
|
-
* _required `providePublic(classInstance)`_
|
|
79
|
-
*
|
|
80
|
-
* @param args - publish args
|
|
81
|
-
*/
|
|
82
|
-
export declare function publicClassMainEvent(args: PublishMainEventArgs): MethodDecorator;
|
|
83
|
-
/**
|
|
84
|
-
* Makes the event from **renderer** and **preload** available for **main** process.
|
|
85
|
-
*
|
|
86
|
-
* _only for non-static_
|
|
87
|
-
* _experimental decorators_
|
|
88
|
-
*/
|
|
89
|
-
export declare function publicClassRendererEvent(): PropertyDecorator;
|
|
90
|
-
/**
|
|
91
|
-
* Makes the event from **renderer** and **preload** available for **main** process.
|
|
92
|
-
*
|
|
93
|
-
* _only for non-static_
|
|
94
|
-
* _experimental decorators_
|
|
95
|
-
*
|
|
96
|
-
* @param name - name by which the event will be accessed
|
|
97
|
-
*/
|
|
98
|
-
export declare function publicClassRendererEvent(name: string): PropertyDecorator;
|
|
99
|
-
/**
|
|
100
|
-
* Makes the event from **renderer** and **preload** available for **main** process.
|
|
101
|
-
*
|
|
102
|
-
* _only for non-static_
|
|
103
|
-
* _experimental decorators_
|
|
104
|
-
*
|
|
105
|
-
* @param receiver - linked receiver
|
|
106
|
-
*/
|
|
107
|
-
export declare function publicClassRendererEvent(receiver: EventReceiver): PropertyDecorator;
|
|
108
|
-
/**
|
|
109
|
-
* Makes the event from **renderer** and **preload** available for **main** process.
|
|
110
|
-
*
|
|
111
|
-
* _only for non-static_
|
|
112
|
-
* _experimental decorators_
|
|
113
|
-
*
|
|
114
|
-
* @param name - name by which the event will be accessed
|
|
115
|
-
* @param receiver - linked receiver
|
|
116
|
-
*/
|
|
117
|
-
export declare function publicClassRendererEvent(name: string, receiver: EventReceiver): PropertyDecorator;
|
|
118
|
-
/**
|
|
119
|
-
* Makes the event from **renderer** and **preload** available for **main** process.
|
|
120
|
-
*
|
|
121
|
-
* _only for non-static_
|
|
122
|
-
* _experimental decorators_
|
|
123
|
-
*
|
|
124
|
-
* @param args - publish args
|
|
125
|
-
*/
|
|
126
|
-
export declare function publicClassRendererEvent(args: PublishRendererEventArgs): PropertyDecorator;
|
|
127
|
-
/**
|
|
128
|
-
* Makes the property available for **renderer** and **preload** processes.
|
|
129
|
-
*
|
|
130
|
-
* _only for static_
|
|
131
|
-
* _experimental decorators_
|
|
132
|
-
*/
|
|
133
|
-
export declare function publicStaticProperty(): PropertyDecorator;
|
|
134
|
-
/**
|
|
135
|
-
* Makes the property available for **renderer** and **preload** processes.
|
|
136
|
-
*
|
|
137
|
-
* _only for static_
|
|
138
|
-
* _experimental decorators_
|
|
139
|
-
*
|
|
140
|
-
* @param name - name by which the property will be accessed
|
|
141
|
-
*/
|
|
142
|
-
export declare function publicStaticProperty(name: string): PropertyDecorator;
|
|
143
|
-
/**
|
|
144
|
-
* Makes the property available for **renderer** and **preload** processes.
|
|
145
|
-
*
|
|
146
|
-
* _only for static_
|
|
147
|
-
* _experimental decorators_
|
|
148
|
-
*
|
|
149
|
-
* @param args - publish args
|
|
150
|
-
*/
|
|
151
|
-
export declare function publicStaticProperty(args: PublishPropertyArgs): PropertyDecorator;
|
|
152
|
-
/**
|
|
153
|
-
* Makes the property available for **renderer** and **preload** processes.
|
|
154
|
-
*
|
|
155
|
-
* _only for non-static_
|
|
156
|
-
* _experimental decorators_
|
|
157
|
-
* _required `providePublic(classInstance)`_
|
|
158
|
-
*/
|
|
159
|
-
export declare function publicProperty(): PropertyDecorator;
|
|
160
|
-
/**
|
|
161
|
-
* Makes the property available for **renderer** and **preload** processes.
|
|
162
|
-
*
|
|
163
|
-
* _only for non-static_
|
|
164
|
-
* _experimental decorators_
|
|
165
|
-
* _required `providePublic(classInstance)`_
|
|
166
|
-
*
|
|
167
|
-
* @param name - name by which the property will be accessed
|
|
168
|
-
*/
|
|
169
|
-
export declare function publicProperty(name: string): PropertyDecorator;
|
|
170
|
-
/**
|
|
171
|
-
* Makes the property available for **renderer** and **preload** processes.
|
|
172
|
-
*
|
|
173
|
-
* _only for non-static_
|
|
174
|
-
* _experimental decorators_
|
|
175
|
-
* _required `providePublic(classInstance)`_
|
|
176
|
-
*
|
|
177
|
-
* @param args - publish args
|
|
178
|
-
*/
|
|
179
|
-
export declare function publicProperty(args: PublishPropertyArgs): PropertyDecorator;
|
|
180
|
-
/**
|
|
181
|
-
* Binds all public entities of a class to a specific instance.
|
|
182
|
-
*
|
|
183
|
-
* _only for class instance_
|
|
184
|
-
*/
|
|
185
|
-
export declare function providePublic<InstanceType>(instance: InstanceType): InstanceType;
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { addAccess, addScope, publicFunction, publicMainEvent, publicRendererEvent, publicVariable } from './publish.js';
|
|
2
|
-
export function publicStaticMethod(arg) {
|
|
3
|
-
return (target, key) => {
|
|
4
|
-
let name = String(key);
|
|
5
|
-
if (arg) {
|
|
6
|
-
if (typeof arg === 'string') {
|
|
7
|
-
name = arg;
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
10
|
-
name = arg.name ?? String(key);
|
|
11
|
-
if (arg.scope)
|
|
12
|
-
addScope(name, arg.scope);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
publicFunction(name, (...args) => target[key](...args));
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
export function publicMethod(arg) {
|
|
19
|
-
return (tgt, key, _) => {
|
|
20
|
-
const target = tgt;
|
|
21
|
-
const prevRegister = target.__register__ ?? (() => { });
|
|
22
|
-
target.__register__ = instance => {
|
|
23
|
-
prevRegister(instance);
|
|
24
|
-
publicStaticMethod(arg)(instance, key, _);
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
export function publicClassMainEvent(arg) {
|
|
29
|
-
return (tgt, key, _) => {
|
|
30
|
-
const target = tgt;
|
|
31
|
-
const prevRegister = target.__register__ ?? (() => { });
|
|
32
|
-
target.__register__ = instance => {
|
|
33
|
-
prevRegister(instance);
|
|
34
|
-
let name = String(key);
|
|
35
|
-
if (arg) {
|
|
36
|
-
if (typeof arg === 'string') {
|
|
37
|
-
name = arg;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
name = arg.name ?? String(key);
|
|
41
|
-
if (arg.scope)
|
|
42
|
-
addScope(name, arg.scope);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
instance[key] = publicMainEvent(name, instance[key].bind(instance));
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
export function publicClassRendererEvent(arg) {
|
|
50
|
-
return (tgt, key) => {
|
|
51
|
-
const target = tgt;
|
|
52
|
-
const prevRegister = target.__register__ ?? (() => { });
|
|
53
|
-
target.__register__ = instance => {
|
|
54
|
-
prevRegister(instance);
|
|
55
|
-
let name = String(key);
|
|
56
|
-
let receiver = (v) => v;
|
|
57
|
-
if (arg) {
|
|
58
|
-
if (typeof arg === 'string') {
|
|
59
|
-
name = arg;
|
|
60
|
-
}
|
|
61
|
-
else if (typeof arg === 'object') {
|
|
62
|
-
name = arg.name ?? String(key);
|
|
63
|
-
receiver = arg.procFn ?? receiver;
|
|
64
|
-
if (arg.scope)
|
|
65
|
-
addScope(name, arg.scope);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
receiver = arg;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
instance[key] = publicRendererEvent(name, receiver);
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
export function publicStaticProperty(arg) {
|
|
76
|
-
return (target, key) => {
|
|
77
|
-
let name = String(key);
|
|
78
|
-
if (arg) {
|
|
79
|
-
if (typeof arg === 'string') {
|
|
80
|
-
name = arg;
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
name = arg.name ?? String(key);
|
|
84
|
-
if (arg.scope)
|
|
85
|
-
addScope(name, arg.scope);
|
|
86
|
-
if (arg.access)
|
|
87
|
-
addAccess(name, arg.access);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
publicVariable(name, {
|
|
91
|
-
get() {
|
|
92
|
-
return target[key];
|
|
93
|
-
},
|
|
94
|
-
set(value) {
|
|
95
|
-
target[key] = value;
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
export function publicProperty(arg) {
|
|
101
|
-
return (tgt, key) => {
|
|
102
|
-
const target = tgt;
|
|
103
|
-
const prevRegister = target.__register__ ?? (() => { });
|
|
104
|
-
target.__register__ = instance => {
|
|
105
|
-
prevRegister(instance);
|
|
106
|
-
publicStaticProperty(arg)(instance, key);
|
|
107
|
-
};
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Binds all public entities of a class to a specific instance.
|
|
112
|
-
*
|
|
113
|
-
* _only for class instance_
|
|
114
|
-
*/
|
|
115
|
-
export function providePublic(instance) {
|
|
116
|
-
const target = instance;
|
|
117
|
-
if (!target.__register__)
|
|
118
|
-
throw new Error('Public methods not defined');
|
|
119
|
-
target.__register__(instance);
|
|
120
|
-
target.__register__ = undefined;
|
|
121
|
-
return instance;
|
|
122
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import electron from 'electron';
|
|
2
|
-
import { IPCChannel } from '../enums.js';
|
|
3
|
-
import IPCTunnel from './renderer-tunnels.js';
|
|
4
|
-
/** Выбрасывает ошибку если используется не в том процессе */
|
|
5
|
-
let mayThrowError = () => { };
|
|
6
|
-
if (typeof window === 'undefined') {
|
|
7
|
-
mayThrowError = () => { throw new Error('"provideFromMain" is unavailable in main process.'); };
|
|
8
|
-
}
|
|
9
|
-
else if (!('contextBridge' in electron)) {
|
|
10
|
-
mayThrowError = () => { throw new Error('"provideFromMain" is unavailable in renderer process.'); };
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Sets access to main from renderer
|
|
14
|
-
*
|
|
15
|
-
* @param contextIsolation - _default_: `true`
|
|
16
|
-
*/
|
|
17
|
-
function provideFromMain(contextIsolation = true) {
|
|
18
|
-
mayThrowError();
|
|
19
|
-
const { contextBridge, ipcRenderer } = electron;
|
|
20
|
-
const info = ipcRenderer.sendSync(IPCChannel.getPublicInfo);
|
|
21
|
-
const provider = {
|
|
22
|
-
getInfo: () => info,
|
|
23
|
-
waitPromise(channel, resolve, reject, secret) {
|
|
24
|
-
new IPCTunnel.Promise(channel).wait(secret)
|
|
25
|
-
.then(resolve)
|
|
26
|
-
.catch(reject);
|
|
27
|
-
},
|
|
28
|
-
provided: {
|
|
29
|
-
functions: getFunctions(),
|
|
30
|
-
properties: getProperties(),
|
|
31
|
-
mainEvents: getMainEvents(),
|
|
32
|
-
rendererEvents: getRendererEvents(),
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
if (contextIsolation) {
|
|
36
|
-
contextBridge.exposeInMainWorld('__provider__', provider);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
window.__provider__ = provider;
|
|
40
|
-
}
|
|
41
|
-
function getFunctions() {
|
|
42
|
-
const result = {};
|
|
43
|
-
for (const name of info.functions) {
|
|
44
|
-
result[name] = (secret, args) => {
|
|
45
|
-
return new IPCTunnel.Function(name).call({ args, secret });
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
return result;
|
|
49
|
-
}
|
|
50
|
-
function getProperties() {
|
|
51
|
-
const result = {};
|
|
52
|
-
for (const name of info.properties) {
|
|
53
|
-
const tunnel = new IPCTunnel.Property(name);
|
|
54
|
-
result[name] = {
|
|
55
|
-
get: () => tunnel.get(),
|
|
56
|
-
set: (value) => tunnel.set(value)
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
return result;
|
|
60
|
-
}
|
|
61
|
-
function getMainEvents() {
|
|
62
|
-
const result = {};
|
|
63
|
-
for (const name of info.mainEvents) {
|
|
64
|
-
result[name] = (type, handler) => {
|
|
65
|
-
const tunnel = new IPCTunnel.MainEvent(name);
|
|
66
|
-
if (type === 'on')
|
|
67
|
-
return tunnel.on(handler);
|
|
68
|
-
else
|
|
69
|
-
return tunnel.once(handler);
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
return result;
|
|
73
|
-
}
|
|
74
|
-
function getRendererEvents() {
|
|
75
|
-
const result = {};
|
|
76
|
-
for (const name of info.rendererEvents) {
|
|
77
|
-
result[name] = (arg) => {
|
|
78
|
-
const tunnel = new IPCTunnel.RendererEvent(name);
|
|
79
|
-
if (arg instanceof Promise) {
|
|
80
|
-
arg.then(value => tunnel.emit(value))
|
|
81
|
-
.catch(reason => tunnel.error(String(reason)));
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
tunnel.emit(arg);
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
return result;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
export default provideFromMain;
|