@lvce-editor/about-view 7.2.0 → 7.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/dist/aboutWorkerMain.js +678 -430
- package/package.json +1 -1
package/dist/aboutWorkerMain.js
CHANGED
|
@@ -1,3 +1,278 @@
|
|
|
1
|
+
const toCommandId = key => {
|
|
2
|
+
const dotIndex = key.indexOf('.');
|
|
3
|
+
return key.slice(dotIndex + 1);
|
|
4
|
+
};
|
|
5
|
+
const create$a = () => {
|
|
6
|
+
const states = Object.create(null);
|
|
7
|
+
const commandMapRef = {};
|
|
8
|
+
return {
|
|
9
|
+
clear() {
|
|
10
|
+
for (const key of Object.keys(states)) {
|
|
11
|
+
delete states[key];
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
diff(uid, modules, numbers) {
|
|
15
|
+
const {
|
|
16
|
+
oldState,
|
|
17
|
+
scheduledState
|
|
18
|
+
} = states[uid];
|
|
19
|
+
const diffResult = [];
|
|
20
|
+
for (let i = 0; i < modules.length; i++) {
|
|
21
|
+
const fn = modules[i];
|
|
22
|
+
if (!fn(oldState, scheduledState)) {
|
|
23
|
+
diffResult.push(numbers[i]);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return diffResult;
|
|
27
|
+
},
|
|
28
|
+
dispose(uid) {
|
|
29
|
+
delete states[uid];
|
|
30
|
+
},
|
|
31
|
+
get(uid) {
|
|
32
|
+
return states[uid];
|
|
33
|
+
},
|
|
34
|
+
getCommandIds() {
|
|
35
|
+
const keys = Object.keys(commandMapRef);
|
|
36
|
+
const ids = keys.map(toCommandId);
|
|
37
|
+
return ids;
|
|
38
|
+
},
|
|
39
|
+
getKeys() {
|
|
40
|
+
return Object.keys(states).map(Number);
|
|
41
|
+
},
|
|
42
|
+
registerCommands(commandMap) {
|
|
43
|
+
Object.assign(commandMapRef, commandMap);
|
|
44
|
+
},
|
|
45
|
+
set(uid, oldState, newState, scheduledState) {
|
|
46
|
+
states[uid] = {
|
|
47
|
+
newState,
|
|
48
|
+
oldState,
|
|
49
|
+
scheduledState: scheduledState ?? newState
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
wrapCommand(fn) {
|
|
53
|
+
const wrapped = async (uid, ...args) => {
|
|
54
|
+
const {
|
|
55
|
+
newState,
|
|
56
|
+
oldState
|
|
57
|
+
} = states[uid];
|
|
58
|
+
const newerState = await fn(newState, ...args);
|
|
59
|
+
if (oldState === newerState || newState === newerState) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const latestOld = states[uid];
|
|
63
|
+
const latestNew = {
|
|
64
|
+
...latestOld.newState,
|
|
65
|
+
...newerState
|
|
66
|
+
};
|
|
67
|
+
states[uid] = {
|
|
68
|
+
newState: latestNew,
|
|
69
|
+
oldState: latestOld.oldState,
|
|
70
|
+
scheduledState: latestNew
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
return wrapped;
|
|
74
|
+
},
|
|
75
|
+
wrapGetter(fn) {
|
|
76
|
+
const wrapped = (uid, ...args) => {
|
|
77
|
+
const {
|
|
78
|
+
newState
|
|
79
|
+
} = states[uid];
|
|
80
|
+
return fn(newState, ...args);
|
|
81
|
+
};
|
|
82
|
+
return wrapped;
|
|
83
|
+
},
|
|
84
|
+
wrapLoadContent(fn) {
|
|
85
|
+
const wrapped = async (uid, ...args) => {
|
|
86
|
+
const {
|
|
87
|
+
newState,
|
|
88
|
+
oldState
|
|
89
|
+
} = states[uid];
|
|
90
|
+
const result = await fn(newState, ...args);
|
|
91
|
+
const {
|
|
92
|
+
error,
|
|
93
|
+
state
|
|
94
|
+
} = result;
|
|
95
|
+
if (oldState === state || newState === state) {
|
|
96
|
+
return {
|
|
97
|
+
error
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
const latestOld = states[uid];
|
|
101
|
+
const latestNew = {
|
|
102
|
+
...latestOld.newState,
|
|
103
|
+
...state
|
|
104
|
+
};
|
|
105
|
+
states[uid] = {
|
|
106
|
+
newState: latestNew,
|
|
107
|
+
oldState: latestOld.oldState,
|
|
108
|
+
scheduledState: latestNew
|
|
109
|
+
};
|
|
110
|
+
return {
|
|
111
|
+
error
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
return wrapped;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const {
|
|
120
|
+
dispose: dispose$1,
|
|
121
|
+
get: get$2,
|
|
122
|
+
getCommandIds,
|
|
123
|
+
registerCommands,
|
|
124
|
+
set: set$3,
|
|
125
|
+
wrapCommand
|
|
126
|
+
} = create$a();
|
|
127
|
+
|
|
128
|
+
const create$9 = (uid, useNewLoadConfig = false) => {
|
|
129
|
+
const state = {
|
|
130
|
+
focusId: 0,
|
|
131
|
+
lines: [],
|
|
132
|
+
productName: '',
|
|
133
|
+
uid,
|
|
134
|
+
useNewLoadConfig
|
|
135
|
+
};
|
|
136
|
+
set$3(uid, state, state);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const RenderFocus = 2;
|
|
140
|
+
const RenderFocusContext = 4;
|
|
141
|
+
const RenderAbout = 3;
|
|
142
|
+
|
|
143
|
+
const diffType$2 = RenderAbout;
|
|
144
|
+
const isEqual$2 = (oldState, newState) => {
|
|
145
|
+
return oldState.productName === newState.productName && JSON.stringify(oldState.lines) === JSON.stringify(newState.lines);
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const diffType$1 = RenderFocus;
|
|
149
|
+
const isEqual$1 = (oldState, newState) => {
|
|
150
|
+
return oldState.focusId === newState.focusId;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
const diffType = RenderFocusContext;
|
|
154
|
+
const isEqual = (oldState, newState) => {
|
|
155
|
+
return oldState.focusId === newState.focusId;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const modules = [isEqual$2, isEqual$1, isEqual];
|
|
159
|
+
const numbers = [diffType$2, diffType$1, diffType];
|
|
160
|
+
|
|
161
|
+
const diff = (oldState, newState) => {
|
|
162
|
+
const diffResult = [];
|
|
163
|
+
for (let i = 0; i < modules.length; i++) {
|
|
164
|
+
const fn = modules[i];
|
|
165
|
+
if (!fn(oldState, newState)) {
|
|
166
|
+
diffResult.push(numbers[i]);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return diffResult;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const diff2 = uid => {
|
|
173
|
+
const {
|
|
174
|
+
oldState,
|
|
175
|
+
scheduledState
|
|
176
|
+
} = get$2(uid);
|
|
177
|
+
const diffResult = diff(oldState, scheduledState);
|
|
178
|
+
return diffResult;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const dispose = uid => {
|
|
182
|
+
dispose$1(uid);
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
const None = 0;
|
|
186
|
+
const Ok$2 = 1;
|
|
187
|
+
const Copy$2 = 2;
|
|
188
|
+
|
|
189
|
+
const getNextFocus = focusId => {
|
|
190
|
+
switch (focusId) {
|
|
191
|
+
case Copy$2:
|
|
192
|
+
return Ok$2;
|
|
193
|
+
case Ok$2:
|
|
194
|
+
return Copy$2;
|
|
195
|
+
default:
|
|
196
|
+
return None;
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const focusNext = state => {
|
|
201
|
+
const {
|
|
202
|
+
focusId
|
|
203
|
+
} = state;
|
|
204
|
+
return {
|
|
205
|
+
...state,
|
|
206
|
+
focusId: getNextFocus(focusId)
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
const getPreviousFocus = focusId => {
|
|
211
|
+
switch (focusId) {
|
|
212
|
+
case Copy$2:
|
|
213
|
+
return Ok$2;
|
|
214
|
+
case Ok$2:
|
|
215
|
+
return Copy$2;
|
|
216
|
+
default:
|
|
217
|
+
return None;
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
const focusPrevious = state => {
|
|
222
|
+
const {
|
|
223
|
+
focusId
|
|
224
|
+
} = state;
|
|
225
|
+
return {
|
|
226
|
+
...state,
|
|
227
|
+
focusId: getPreviousFocus(focusId)
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
const Button$2 = 1;
|
|
232
|
+
const Div = 4;
|
|
233
|
+
const Text = 12;
|
|
234
|
+
const Br = 55;
|
|
235
|
+
|
|
236
|
+
const TargetName = 'event.target.name';
|
|
237
|
+
|
|
238
|
+
const Tab = 2;
|
|
239
|
+
const Escape = 8;
|
|
240
|
+
|
|
241
|
+
const Shift = 1 << 10 >>> 0;
|
|
242
|
+
|
|
243
|
+
const FileSystemWorker = 209;
|
|
244
|
+
const RendererWorker = 1;
|
|
245
|
+
|
|
246
|
+
const mergeClassNames = (...classNames) => {
|
|
247
|
+
return classNames.filter(Boolean).join(' ');
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
const text = data => {
|
|
251
|
+
return {
|
|
252
|
+
childCount: 0,
|
|
253
|
+
text: data,
|
|
254
|
+
type: Text
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
const FocusAbout = 4;
|
|
259
|
+
|
|
260
|
+
const getKeyBindings = () => {
|
|
261
|
+
return [{
|
|
262
|
+
command: 'About.handleClickClose',
|
|
263
|
+
key: Escape,
|
|
264
|
+
when: FocusAbout
|
|
265
|
+
}, {
|
|
266
|
+
command: 'About.focusNext',
|
|
267
|
+
key: Tab,
|
|
268
|
+
when: FocusAbout
|
|
269
|
+
}, {
|
|
270
|
+
command: 'About.focusPrevious',
|
|
271
|
+
key: Tab | Shift,
|
|
272
|
+
when: FocusAbout
|
|
273
|
+
}];
|
|
274
|
+
};
|
|
275
|
+
|
|
1
276
|
const normalizeLine = line => {
|
|
2
277
|
if (line.startsWith('Error: ')) {
|
|
3
278
|
return line.slice('Error: '.length);
|
|
@@ -368,11 +643,105 @@ const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
|
368
643
|
listen: listen$6,
|
|
369
644
|
wrap: wrap$e
|
|
370
645
|
};
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
646
|
+
const addListener = (emitter, type, callback) => {
|
|
647
|
+
if ('addEventListener' in emitter) {
|
|
648
|
+
emitter.addEventListener(type, callback);
|
|
649
|
+
} else {
|
|
650
|
+
emitter.on(type, callback);
|
|
651
|
+
}
|
|
652
|
+
};
|
|
653
|
+
const removeListener = (emitter, type, callback) => {
|
|
654
|
+
if ('removeEventListener' in emitter) {
|
|
655
|
+
emitter.removeEventListener(type, callback);
|
|
656
|
+
} else {
|
|
657
|
+
emitter.off(type, callback);
|
|
658
|
+
}
|
|
659
|
+
};
|
|
660
|
+
const getFirstEvent = (eventEmitter, eventMap) => {
|
|
661
|
+
const {
|
|
662
|
+
promise,
|
|
663
|
+
resolve
|
|
664
|
+
} = Promise.withResolvers();
|
|
665
|
+
const listenerMap = Object.create(null);
|
|
666
|
+
const cleanup = value => {
|
|
667
|
+
for (const event of Object.keys(eventMap)) {
|
|
668
|
+
removeListener(eventEmitter, event, listenerMap[event]);
|
|
669
|
+
}
|
|
670
|
+
resolve(value);
|
|
671
|
+
};
|
|
672
|
+
for (const [event, type] of Object.entries(eventMap)) {
|
|
673
|
+
const listener = event => {
|
|
674
|
+
cleanup({
|
|
675
|
+
event,
|
|
676
|
+
type
|
|
677
|
+
});
|
|
678
|
+
};
|
|
679
|
+
addListener(eventEmitter, event, listener);
|
|
680
|
+
listenerMap[event] = listener;
|
|
681
|
+
}
|
|
682
|
+
return promise;
|
|
683
|
+
};
|
|
684
|
+
const Message$1 = 3;
|
|
685
|
+
const create$5$1 = async ({
|
|
686
|
+
isMessagePortOpen,
|
|
687
|
+
messagePort
|
|
688
|
+
}) => {
|
|
689
|
+
if (!isMessagePort(messagePort)) {
|
|
690
|
+
throw new IpcError('port must be of type MessagePort');
|
|
691
|
+
}
|
|
692
|
+
if (isMessagePortOpen) {
|
|
693
|
+
return messagePort;
|
|
694
|
+
}
|
|
695
|
+
const eventPromise = getFirstEvent(messagePort, {
|
|
696
|
+
message: Message$1
|
|
697
|
+
});
|
|
698
|
+
messagePort.start();
|
|
699
|
+
const {
|
|
700
|
+
event,
|
|
701
|
+
type
|
|
702
|
+
} = await eventPromise;
|
|
703
|
+
if (type !== Message$1) {
|
|
704
|
+
throw new IpcError('Failed to wait for ipc message');
|
|
705
|
+
}
|
|
706
|
+
if (event.data !== readyMessage) {
|
|
707
|
+
throw new IpcError('unexpected first message');
|
|
708
|
+
}
|
|
709
|
+
return messagePort;
|
|
710
|
+
};
|
|
711
|
+
const signal$1 = messagePort => {
|
|
712
|
+
messagePort.start();
|
|
713
|
+
};
|
|
714
|
+
class IpcParentWithMessagePort extends Ipc {
|
|
715
|
+
getData = getData$2;
|
|
716
|
+
send(message) {
|
|
717
|
+
this._rawIpc.postMessage(message);
|
|
718
|
+
}
|
|
719
|
+
sendAndTransfer(message) {
|
|
720
|
+
const transfer = getTransferrables(message);
|
|
721
|
+
this._rawIpc.postMessage(message, transfer);
|
|
722
|
+
}
|
|
723
|
+
dispose() {
|
|
724
|
+
this._rawIpc.close();
|
|
725
|
+
}
|
|
726
|
+
onMessage(callback) {
|
|
727
|
+
this._rawIpc.addEventListener('message', callback);
|
|
728
|
+
}
|
|
729
|
+
onClose(callback) {}
|
|
730
|
+
}
|
|
731
|
+
const wrap$5 = messagePort => {
|
|
732
|
+
return new IpcParentWithMessagePort(messagePort);
|
|
733
|
+
};
|
|
734
|
+
const IpcParentWithMessagePort$1 = {
|
|
735
|
+
__proto__: null,
|
|
736
|
+
create: create$5$1,
|
|
737
|
+
signal: signal$1,
|
|
738
|
+
wrap: wrap$5
|
|
739
|
+
};
|
|
740
|
+
|
|
741
|
+
class CommandNotFoundError extends Error {
|
|
742
|
+
constructor(command) {
|
|
743
|
+
super(`Command not found ${command}`);
|
|
744
|
+
this.name = 'CommandNotFoundError';
|
|
376
745
|
}
|
|
377
746
|
}
|
|
378
747
|
const commands = Object.create(null);
|
|
@@ -392,7 +761,7 @@ const execute = (command, ...args) => {
|
|
|
392
761
|
|
|
393
762
|
const Two$1 = '2.0';
|
|
394
763
|
const callbacks = Object.create(null);
|
|
395
|
-
const get$
|
|
764
|
+
const get$1 = id => {
|
|
396
765
|
return callbacks[id];
|
|
397
766
|
};
|
|
398
767
|
const remove$1 = id => {
|
|
@@ -541,7 +910,7 @@ const warn = (...args) => {
|
|
|
541
910
|
console.warn(...args);
|
|
542
911
|
};
|
|
543
912
|
const resolve = (id, response) => {
|
|
544
|
-
const fn = get$
|
|
913
|
+
const fn = get$1(id);
|
|
545
914
|
if (!fn) {
|
|
546
915
|
console.log(response);
|
|
547
916
|
warn(`callback ${id} may already be disposed`);
|
|
@@ -604,7 +973,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
604
973
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
605
974
|
return create$1$1(id, errorProperty);
|
|
606
975
|
};
|
|
607
|
-
const create$
|
|
976
|
+
const create$8 = (message, result) => {
|
|
608
977
|
return {
|
|
609
978
|
id: message.id,
|
|
610
979
|
jsonrpc: Two$1,
|
|
@@ -613,7 +982,7 @@ const create$7 = (message, result) => {
|
|
|
613
982
|
};
|
|
614
983
|
const getSuccessResponse = (message, result) => {
|
|
615
984
|
const resultProperty = result ?? null;
|
|
616
|
-
return create$
|
|
985
|
+
return create$8(message, resultProperty);
|
|
617
986
|
};
|
|
618
987
|
const getErrorResponseSimple = (id, error) => {
|
|
619
988
|
return {
|
|
@@ -707,7 +1076,7 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
707
1076
|
|
|
708
1077
|
const Two = '2.0';
|
|
709
1078
|
|
|
710
|
-
const create$
|
|
1079
|
+
const create$7 = (method, params) => {
|
|
711
1080
|
return {
|
|
712
1081
|
jsonrpc: Two,
|
|
713
1082
|
method,
|
|
@@ -715,7 +1084,7 @@ const create$6 = (method, params) => {
|
|
|
715
1084
|
};
|
|
716
1085
|
};
|
|
717
1086
|
|
|
718
|
-
const create$
|
|
1087
|
+
const create$6 = (id, method, params) => {
|
|
719
1088
|
const message = {
|
|
720
1089
|
id,
|
|
721
1090
|
jsonrpc: Two,
|
|
@@ -726,12 +1095,12 @@ const create$5 = (id, method, params) => {
|
|
|
726
1095
|
};
|
|
727
1096
|
|
|
728
1097
|
let id = 0;
|
|
729
|
-
const create$
|
|
1098
|
+
const create$5 = () => {
|
|
730
1099
|
return ++id;
|
|
731
1100
|
};
|
|
732
1101
|
|
|
733
1102
|
const registerPromise = map => {
|
|
734
|
-
const id = create$
|
|
1103
|
+
const id = create$5();
|
|
735
1104
|
const {
|
|
736
1105
|
promise,
|
|
737
1106
|
resolve
|
|
@@ -748,7 +1117,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
|
|
|
748
1117
|
id,
|
|
749
1118
|
promise
|
|
750
1119
|
} = registerPromise(callbacks);
|
|
751
|
-
const message = create$
|
|
1120
|
+
const message = create$6(id, method, params);
|
|
752
1121
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
753
1122
|
ipc.sendAndTransfer(message);
|
|
754
1123
|
} else {
|
|
@@ -784,7 +1153,7 @@ const createRpc = ipc => {
|
|
|
784
1153
|
* @deprecated
|
|
785
1154
|
*/
|
|
786
1155
|
send(method, ...params) {
|
|
787
|
-
const message = create$
|
|
1156
|
+
const message = create$7(method, params);
|
|
788
1157
|
ipc.send(message);
|
|
789
1158
|
}
|
|
790
1159
|
};
|
|
@@ -806,408 +1175,226 @@ const handleMessage = event => {
|
|
|
806
1175
|
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
807
1176
|
};
|
|
808
1177
|
|
|
809
|
-
const handleIpc = ipc => {
|
|
810
|
-
if ('addEventListener' in ipc) {
|
|
811
|
-
ipc.addEventListener('message', handleMessage);
|
|
812
|
-
} else if ('on' in ipc) {
|
|
813
|
-
// deprecated
|
|
814
|
-
ipc.on('message', handleMessage);
|
|
815
|
-
}
|
|
816
|
-
};
|
|
817
|
-
|
|
818
|
-
const listen$1 = async (module, options) => {
|
|
819
|
-
const rawIpc = await module.listen(options);
|
|
820
|
-
if (module.signal) {
|
|
821
|
-
module.signal(rawIpc);
|
|
822
|
-
}
|
|
823
|
-
const ipc = module.wrap(rawIpc);
|
|
824
|
-
return ipc;
|
|
825
|
-
};
|
|
826
|
-
|
|
827
|
-
const create$3 = async ({
|
|
828
|
-
commandMap
|
|
829
|
-
}) => {
|
|
830
|
-
// TODO create a commandMap per rpc instance
|
|
831
|
-
register(commandMap);
|
|
832
|
-
const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
|
|
833
|
-
handleIpc(ipc);
|
|
834
|
-
const rpc = createRpc(ipc);
|
|
835
|
-
return rpc;
|
|
836
|
-
};
|
|
837
|
-
|
|
838
|
-
const createMockRpc = ({
|
|
839
|
-
commandMap
|
|
840
|
-
}) => {
|
|
841
|
-
const invocations = [];
|
|
842
|
-
const invoke = (method, ...params) => {
|
|
843
|
-
invocations.push([method, ...params]);
|
|
844
|
-
const command = commandMap[method];
|
|
845
|
-
if (!command) {
|
|
846
|
-
throw new Error(`command ${method} not found`);
|
|
847
|
-
}
|
|
848
|
-
return command(...params);
|
|
849
|
-
};
|
|
850
|
-
const mockRpc = {
|
|
851
|
-
invocations,
|
|
852
|
-
invoke,
|
|
853
|
-
invokeAndTransfer: invoke
|
|
854
|
-
};
|
|
855
|
-
return mockRpc;
|
|
856
|
-
};
|
|
857
|
-
|
|
858
|
-
const rpcs = Object.create(null);
|
|
859
|
-
const set$2 = (id, rpc) => {
|
|
860
|
-
rpcs[id] = rpc;
|
|
861
|
-
};
|
|
862
|
-
const get$1 = id => {
|
|
863
|
-
return rpcs[id];
|
|
864
|
-
};
|
|
865
|
-
const remove = id => {
|
|
866
|
-
delete rpcs[id];
|
|
867
|
-
};
|
|
868
|
-
|
|
869
|
-
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
870
|
-
const create$2 = rpcId => {
|
|
871
|
-
return {
|
|
872
|
-
async dispose() {
|
|
873
|
-
const rpc = get$1(rpcId);
|
|
874
|
-
await rpc.dispose();
|
|
875
|
-
},
|
|
876
|
-
// @ts-ignore
|
|
877
|
-
invoke(method, ...params) {
|
|
878
|
-
const rpc = get$1(rpcId);
|
|
879
|
-
// @ts-ignore
|
|
880
|
-
return rpc.invoke(method, ...params);
|
|
881
|
-
},
|
|
882
|
-
// @ts-ignore
|
|
883
|
-
invokeAndTransfer(method, ...params) {
|
|
884
|
-
const rpc = get$1(rpcId);
|
|
885
|
-
// @ts-ignore
|
|
886
|
-
return rpc.invokeAndTransfer(method, ...params);
|
|
887
|
-
},
|
|
888
|
-
registerMockRpc(commandMap) {
|
|
889
|
-
const mockRpc = createMockRpc({
|
|
890
|
-
commandMap
|
|
891
|
-
});
|
|
892
|
-
set$2(rpcId, mockRpc);
|
|
893
|
-
// @ts-ignore
|
|
894
|
-
mockRpc[Symbol.dispose] = () => {
|
|
895
|
-
remove(rpcId);
|
|
896
|
-
};
|
|
897
|
-
// @ts-ignore
|
|
898
|
-
return mockRpc;
|
|
899
|
-
},
|
|
900
|
-
set(rpc) {
|
|
901
|
-
set$2(rpcId, rpc);
|
|
902
|
-
}
|
|
903
|
-
};
|
|
904
|
-
};
|
|
905
|
-
|
|
906
|
-
const Button$2 = 1;
|
|
907
|
-
const Div = 4;
|
|
908
|
-
const Text = 12;
|
|
909
|
-
const Br = 55;
|
|
910
|
-
|
|
911
|
-
const TargetName = 'event.target.name';
|
|
912
|
-
|
|
913
|
-
const Tab = 2;
|
|
914
|
-
const Escape = 8;
|
|
915
|
-
|
|
916
|
-
const Shift = 1 << 10 >>> 0;
|
|
917
|
-
|
|
918
|
-
const RendererWorker = 1;
|
|
919
|
-
|
|
920
|
-
const {
|
|
921
|
-
invoke,
|
|
922
|
-
set: set$1
|
|
923
|
-
} = create$2(RendererWorker);
|
|
924
|
-
const getElectronVersion$1 = async () => {
|
|
925
|
-
return invoke('Process.getElectronVersion');
|
|
926
|
-
};
|
|
927
|
-
const getNodeVersion$1 = async () => {
|
|
928
|
-
return invoke('Process.getNodeVersion');
|
|
929
|
-
};
|
|
930
|
-
const getChromeVersion$1 = async () => {
|
|
931
|
-
return invoke('Process.getChromeVersion');
|
|
932
|
-
};
|
|
933
|
-
const getV8Version$1 = async () => {
|
|
934
|
-
return invoke('Process.getV8Version');
|
|
935
|
-
};
|
|
936
|
-
const setFocus = key => {
|
|
937
|
-
return invoke('Focus.setFocus', key);
|
|
938
|
-
};
|
|
939
|
-
const closeWidget$1 = async widgetId => {
|
|
940
|
-
return invoke('Viewlet.closeWidget', widgetId);
|
|
941
|
-
};
|
|
942
|
-
const writeClipBoardText = async text => {
|
|
943
|
-
await invoke('ClipBoard.writeText', /* text */text);
|
|
944
|
-
};
|
|
945
|
-
const showMessageBox$1 = async options => {
|
|
946
|
-
return invoke('ElectronDialog.showMessageBox', options);
|
|
947
|
-
};
|
|
948
|
-
const openWidget = async name => {
|
|
949
|
-
await invoke('Viewlet.openWidget', name);
|
|
950
|
-
};
|
|
951
|
-
const getWindowId$1 = async () => {
|
|
952
|
-
return invoke('GetWindowId.getWindowId');
|
|
953
|
-
};
|
|
954
|
-
|
|
955
|
-
const toCommandId = key => {
|
|
956
|
-
const dotIndex = key.indexOf('.');
|
|
957
|
-
return key.slice(dotIndex + 1);
|
|
958
|
-
};
|
|
959
|
-
const create$1 = () => {
|
|
960
|
-
const states = Object.create(null);
|
|
961
|
-
const commandMapRef = {};
|
|
962
|
-
return {
|
|
963
|
-
clear() {
|
|
964
|
-
for (const key of Object.keys(states)) {
|
|
965
|
-
delete states[key];
|
|
966
|
-
}
|
|
967
|
-
},
|
|
968
|
-
diff(uid, modules, numbers) {
|
|
969
|
-
const {
|
|
970
|
-
newState,
|
|
971
|
-
oldState
|
|
972
|
-
} = states[uid];
|
|
973
|
-
const diffResult = [];
|
|
974
|
-
for (let i = 0; i < modules.length; i++) {
|
|
975
|
-
const fn = modules[i];
|
|
976
|
-
if (!fn(oldState, newState)) {
|
|
977
|
-
diffResult.push(numbers[i]);
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
return diffResult;
|
|
981
|
-
},
|
|
982
|
-
dispose(uid) {
|
|
983
|
-
delete states[uid];
|
|
984
|
-
},
|
|
985
|
-
get(uid) {
|
|
986
|
-
return states[uid];
|
|
987
|
-
},
|
|
988
|
-
getCommandIds() {
|
|
989
|
-
const keys = Object.keys(commandMapRef);
|
|
990
|
-
const ids = keys.map(toCommandId);
|
|
991
|
-
return ids;
|
|
992
|
-
},
|
|
993
|
-
getKeys() {
|
|
994
|
-
return Object.keys(states).map(key => {
|
|
995
|
-
return Number.parseFloat(key);
|
|
996
|
-
});
|
|
997
|
-
},
|
|
998
|
-
registerCommands(commandMap) {
|
|
999
|
-
Object.assign(commandMapRef, commandMap);
|
|
1000
|
-
},
|
|
1001
|
-
set(uid, oldState, newState) {
|
|
1002
|
-
states[uid] = {
|
|
1003
|
-
newState,
|
|
1004
|
-
oldState
|
|
1005
|
-
};
|
|
1006
|
-
},
|
|
1007
|
-
wrapCommand(fn) {
|
|
1008
|
-
const wrapped = async (uid, ...args) => {
|
|
1009
|
-
const {
|
|
1010
|
-
newState,
|
|
1011
|
-
oldState
|
|
1012
|
-
} = states[uid];
|
|
1013
|
-
const newerState = await fn(newState, ...args);
|
|
1014
|
-
if (oldState === newerState || newState === newerState) {
|
|
1015
|
-
return;
|
|
1016
|
-
}
|
|
1017
|
-
const latestOld = states[uid];
|
|
1018
|
-
const latestNew = {
|
|
1019
|
-
...latestOld.newState,
|
|
1020
|
-
...newerState
|
|
1021
|
-
};
|
|
1022
|
-
states[uid] = {
|
|
1023
|
-
newState: latestNew,
|
|
1024
|
-
oldState: latestOld.oldState
|
|
1025
|
-
};
|
|
1026
|
-
};
|
|
1027
|
-
return wrapped;
|
|
1028
|
-
},
|
|
1029
|
-
wrapGetter(fn) {
|
|
1030
|
-
const wrapped = (uid, ...args) => {
|
|
1031
|
-
const {
|
|
1032
|
-
newState
|
|
1033
|
-
} = states[uid];
|
|
1034
|
-
return fn(newState, ...args);
|
|
1035
|
-
};
|
|
1036
|
-
return wrapped;
|
|
1037
|
-
},
|
|
1038
|
-
wrapLoadContent(fn) {
|
|
1039
|
-
const wrapped = async (uid, ...args) => {
|
|
1040
|
-
const {
|
|
1041
|
-
newState,
|
|
1042
|
-
oldState
|
|
1043
|
-
} = states[uid];
|
|
1044
|
-
const result = await fn(newState, ...args);
|
|
1045
|
-
const {
|
|
1046
|
-
error,
|
|
1047
|
-
state
|
|
1048
|
-
} = result;
|
|
1049
|
-
if (oldState === state || newState === state) {
|
|
1050
|
-
return {
|
|
1051
|
-
error
|
|
1052
|
-
};
|
|
1053
|
-
}
|
|
1054
|
-
const latestOld = states[uid];
|
|
1055
|
-
const latestNew = {
|
|
1056
|
-
...latestOld.newState,
|
|
1057
|
-
...state
|
|
1058
|
-
};
|
|
1059
|
-
states[uid] = {
|
|
1060
|
-
newState: latestNew,
|
|
1061
|
-
oldState: latestOld.oldState
|
|
1062
|
-
};
|
|
1063
|
-
return {
|
|
1064
|
-
error
|
|
1065
|
-
};
|
|
1066
|
-
};
|
|
1067
|
-
return wrapped;
|
|
1068
|
-
}
|
|
1069
|
-
};
|
|
1070
|
-
};
|
|
1071
|
-
|
|
1072
|
-
const {
|
|
1073
|
-
dispose: dispose$1,
|
|
1074
|
-
get,
|
|
1075
|
-
getCommandIds,
|
|
1076
|
-
registerCommands,
|
|
1077
|
-
set,
|
|
1078
|
-
wrapCommand
|
|
1079
|
-
} = create$1();
|
|
1080
|
-
|
|
1081
|
-
const create = uid => {
|
|
1082
|
-
const state = {
|
|
1083
|
-
focusId: 0,
|
|
1084
|
-
lines: [],
|
|
1085
|
-
productName: '',
|
|
1086
|
-
uid
|
|
1087
|
-
};
|
|
1088
|
-
set(uid, state, state);
|
|
1089
|
-
};
|
|
1090
|
-
|
|
1091
|
-
const RenderFocus = 2;
|
|
1092
|
-
const RenderFocusContext = 4;
|
|
1093
|
-
const RenderAbout = 3;
|
|
1094
|
-
|
|
1095
|
-
const diffType$2 = RenderAbout;
|
|
1096
|
-
const isEqual$2 = (oldState, newState) => {
|
|
1097
|
-
return oldState.productName === newState.productName && JSON.stringify(oldState.lines) === JSON.stringify(newState.lines);
|
|
1098
|
-
};
|
|
1099
|
-
|
|
1100
|
-
const diffType$1 = RenderFocus;
|
|
1101
|
-
const isEqual$1 = (oldState, newState) => {
|
|
1102
|
-
return oldState.focusId === newState.focusId;
|
|
1103
|
-
};
|
|
1104
|
-
|
|
1105
|
-
const diffType = RenderFocusContext;
|
|
1106
|
-
const isEqual = (oldState, newState) => {
|
|
1107
|
-
return oldState.focusId === newState.focusId;
|
|
1108
|
-
};
|
|
1109
|
-
|
|
1110
|
-
const modules = [isEqual$2, isEqual$1, isEqual];
|
|
1111
|
-
const numbers = [diffType$2, diffType$1, diffType];
|
|
1112
|
-
|
|
1113
|
-
const diff = (oldState, newState) => {
|
|
1114
|
-
const diffResult = [];
|
|
1115
|
-
for (let i = 0; i < modules.length; i++) {
|
|
1116
|
-
const fn = modules[i];
|
|
1117
|
-
if (!fn(oldState, newState)) {
|
|
1118
|
-
diffResult.push(numbers[i]);
|
|
1119
|
-
}
|
|
1178
|
+
const handleIpc = ipc => {
|
|
1179
|
+
if ('addEventListener' in ipc) {
|
|
1180
|
+
ipc.addEventListener('message', handleMessage);
|
|
1181
|
+
} else if ('on' in ipc) {
|
|
1182
|
+
// deprecated
|
|
1183
|
+
ipc.on('message', handleMessage);
|
|
1120
1184
|
}
|
|
1121
|
-
return diffResult;
|
|
1122
1185
|
};
|
|
1123
1186
|
|
|
1124
|
-
const
|
|
1125
|
-
const
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
}
|
|
1129
|
-
const
|
|
1130
|
-
return
|
|
1187
|
+
const listen$1 = async (module, options) => {
|
|
1188
|
+
const rawIpc = await module.listen(options);
|
|
1189
|
+
if (module.signal) {
|
|
1190
|
+
module.signal(rawIpc);
|
|
1191
|
+
}
|
|
1192
|
+
const ipc = module.wrap(rawIpc);
|
|
1193
|
+
return ipc;
|
|
1131
1194
|
};
|
|
1132
1195
|
|
|
1133
|
-
const
|
|
1134
|
-
|
|
1196
|
+
const create$4 = async ({
|
|
1197
|
+
commandMap,
|
|
1198
|
+
isMessagePortOpen = true,
|
|
1199
|
+
messagePort
|
|
1200
|
+
}) => {
|
|
1201
|
+
// TODO create a commandMap per rpc instance
|
|
1202
|
+
register(commandMap);
|
|
1203
|
+
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
1204
|
+
isMessagePortOpen,
|
|
1205
|
+
messagePort
|
|
1206
|
+
});
|
|
1207
|
+
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
1208
|
+
handleIpc(ipc);
|
|
1209
|
+
const rpc = createRpc(ipc);
|
|
1210
|
+
messagePort.start();
|
|
1211
|
+
return rpc;
|
|
1135
1212
|
};
|
|
1136
1213
|
|
|
1137
|
-
const
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1214
|
+
const create$3 = async ({
|
|
1215
|
+
commandMap,
|
|
1216
|
+
isMessagePortOpen,
|
|
1217
|
+
send
|
|
1218
|
+
}) => {
|
|
1219
|
+
const {
|
|
1220
|
+
port1,
|
|
1221
|
+
port2
|
|
1222
|
+
} = new MessageChannel();
|
|
1223
|
+
await send(port1);
|
|
1224
|
+
return create$4({
|
|
1225
|
+
commandMap,
|
|
1226
|
+
isMessagePortOpen,
|
|
1227
|
+
messagePort: port2
|
|
1228
|
+
});
|
|
1150
1229
|
};
|
|
1151
1230
|
|
|
1152
|
-
const
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1231
|
+
const createSharedLazyRpc = factory => {
|
|
1232
|
+
let rpcPromise;
|
|
1233
|
+
const getOrCreate = () => {
|
|
1234
|
+
if (!rpcPromise) {
|
|
1235
|
+
rpcPromise = factory();
|
|
1236
|
+
}
|
|
1237
|
+
return rpcPromise;
|
|
1238
|
+
};
|
|
1156
1239
|
return {
|
|
1157
|
-
|
|
1158
|
-
|
|
1240
|
+
async dispose() {
|
|
1241
|
+
const rpc = await getOrCreate();
|
|
1242
|
+
await rpc.dispose();
|
|
1243
|
+
},
|
|
1244
|
+
async invoke(method, ...params) {
|
|
1245
|
+
const rpc = await getOrCreate();
|
|
1246
|
+
return rpc.invoke(method, ...params);
|
|
1247
|
+
},
|
|
1248
|
+
async invokeAndTransfer(method, ...params) {
|
|
1249
|
+
const rpc = await getOrCreate();
|
|
1250
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1251
|
+
},
|
|
1252
|
+
async send(method, ...params) {
|
|
1253
|
+
const rpc = await getOrCreate();
|
|
1254
|
+
rpc.send(method, ...params);
|
|
1255
|
+
}
|
|
1159
1256
|
};
|
|
1160
1257
|
};
|
|
1161
1258
|
|
|
1162
|
-
const
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1259
|
+
const create$2 = async ({
|
|
1260
|
+
commandMap,
|
|
1261
|
+
isMessagePortOpen,
|
|
1262
|
+
send
|
|
1263
|
+
}) => {
|
|
1264
|
+
return createSharedLazyRpc(() => {
|
|
1265
|
+
return create$3({
|
|
1266
|
+
commandMap,
|
|
1267
|
+
isMessagePortOpen,
|
|
1268
|
+
send
|
|
1269
|
+
});
|
|
1270
|
+
});
|
|
1171
1271
|
};
|
|
1172
1272
|
|
|
1173
|
-
const
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1273
|
+
const create$1 = async ({
|
|
1274
|
+
commandMap
|
|
1275
|
+
}) => {
|
|
1276
|
+
// TODO create a commandMap per rpc instance
|
|
1277
|
+
register(commandMap);
|
|
1278
|
+
const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
|
|
1279
|
+
handleIpc(ipc);
|
|
1280
|
+
const rpc = createRpc(ipc);
|
|
1281
|
+
return rpc;
|
|
1282
|
+
};
|
|
1283
|
+
|
|
1284
|
+
const createMockRpc = ({
|
|
1285
|
+
commandMap
|
|
1286
|
+
}) => {
|
|
1287
|
+
const invocations = [];
|
|
1288
|
+
const invoke = (method, ...params) => {
|
|
1289
|
+
invocations.push([method, ...params]);
|
|
1290
|
+
const command = commandMap[method];
|
|
1291
|
+
if (!command) {
|
|
1292
|
+
throw new Error(`command ${method} not found`);
|
|
1293
|
+
}
|
|
1294
|
+
return command(...params);
|
|
1295
|
+
};
|
|
1296
|
+
const mockRpc = {
|
|
1297
|
+
invocations,
|
|
1298
|
+
invoke,
|
|
1299
|
+
invokeAndTransfer: invoke
|
|
1180
1300
|
};
|
|
1301
|
+
return mockRpc;
|
|
1181
1302
|
};
|
|
1182
1303
|
|
|
1183
|
-
const
|
|
1184
|
-
|
|
1304
|
+
const rpcs = Object.create(null);
|
|
1305
|
+
const set$2 = (id, rpc) => {
|
|
1306
|
+
rpcs[id] = rpc;
|
|
1307
|
+
};
|
|
1308
|
+
const get = id => {
|
|
1309
|
+
return rpcs[id];
|
|
1310
|
+
};
|
|
1311
|
+
const remove = id => {
|
|
1312
|
+
delete rpcs[id];
|
|
1185
1313
|
};
|
|
1186
1314
|
|
|
1187
|
-
|
|
1315
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1316
|
+
const create = rpcId => {
|
|
1188
1317
|
return {
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1318
|
+
async dispose() {
|
|
1319
|
+
const rpc = get(rpcId);
|
|
1320
|
+
await rpc.dispose();
|
|
1321
|
+
},
|
|
1322
|
+
// @ts-ignore
|
|
1323
|
+
invoke(method, ...params) {
|
|
1324
|
+
const rpc = get(rpcId);
|
|
1325
|
+
// @ts-ignore
|
|
1326
|
+
return rpc.invoke(method, ...params);
|
|
1327
|
+
},
|
|
1328
|
+
// @ts-ignore
|
|
1329
|
+
invokeAndTransfer(method, ...params) {
|
|
1330
|
+
const rpc = get(rpcId);
|
|
1331
|
+
// @ts-ignore
|
|
1332
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1333
|
+
},
|
|
1334
|
+
registerMockRpc(commandMap) {
|
|
1335
|
+
const mockRpc = createMockRpc({
|
|
1336
|
+
commandMap
|
|
1337
|
+
});
|
|
1338
|
+
set$2(rpcId, mockRpc);
|
|
1339
|
+
// @ts-ignore
|
|
1340
|
+
mockRpc[Symbol.dispose] = () => {
|
|
1341
|
+
remove(rpcId);
|
|
1342
|
+
};
|
|
1343
|
+
// @ts-ignore
|
|
1344
|
+
return mockRpc;
|
|
1345
|
+
},
|
|
1346
|
+
set(rpc) {
|
|
1347
|
+
set$2(rpcId, rpc);
|
|
1348
|
+
}
|
|
1192
1349
|
};
|
|
1193
1350
|
};
|
|
1194
1351
|
|
|
1195
|
-
const
|
|
1352
|
+
const {
|
|
1353
|
+
invoke: invoke$1,
|
|
1354
|
+
set: set$1
|
|
1355
|
+
} = create(FileSystemWorker);
|
|
1356
|
+
const readFile = async uri => {
|
|
1357
|
+
return invoke$1('FileSystem.readFile', uri);
|
|
1358
|
+
};
|
|
1196
1359
|
|
|
1197
|
-
const
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1360
|
+
const {
|
|
1361
|
+
invoke,
|
|
1362
|
+
invokeAndTransfer,
|
|
1363
|
+
set
|
|
1364
|
+
} = create(RendererWorker);
|
|
1365
|
+
const getElectronVersion$1 = async () => {
|
|
1366
|
+
return invoke('Process.getElectronVersion');
|
|
1367
|
+
};
|
|
1368
|
+
const getNodeVersion$1 = async () => {
|
|
1369
|
+
return invoke('Process.getNodeVersion');
|
|
1370
|
+
};
|
|
1371
|
+
const getChromeVersion$1 = async () => {
|
|
1372
|
+
return invoke('Process.getChromeVersion');
|
|
1373
|
+
};
|
|
1374
|
+
const getV8Version$1 = async () => {
|
|
1375
|
+
return invoke('Process.getV8Version');
|
|
1376
|
+
};
|
|
1377
|
+
const sendMessagePortToFileSystemWorker = async (port, rpcId) => {
|
|
1378
|
+
const command = 'FileSystem.handleMessagePort';
|
|
1379
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
|
|
1380
|
+
};
|
|
1381
|
+
const setFocus = key => {
|
|
1382
|
+
return invoke('Focus.setFocus', key);
|
|
1383
|
+
};
|
|
1384
|
+
const closeWidget$1 = async widgetId => {
|
|
1385
|
+
return invoke('Viewlet.closeWidget', widgetId);
|
|
1386
|
+
};
|
|
1387
|
+
const writeClipBoardText = async text => {
|
|
1388
|
+
await invoke('ClipBoard.writeText', /* text */text);
|
|
1389
|
+
};
|
|
1390
|
+
const showMessageBox$1 = async options => {
|
|
1391
|
+
return invoke('ElectronDialog.showMessageBox', options);
|
|
1392
|
+
};
|
|
1393
|
+
const openWidget = async name => {
|
|
1394
|
+
await invoke('Viewlet.openWidget', name);
|
|
1395
|
+
};
|
|
1396
|
+
const getWindowId$1 = async () => {
|
|
1397
|
+
return invoke('GetWindowId.getWindowId');
|
|
1211
1398
|
};
|
|
1212
1399
|
|
|
1213
1400
|
const closeWidget = closeWidget$1;
|
|
@@ -1496,7 +1683,7 @@ const ranges$1 = [{
|
|
|
1496
1683
|
some: inSomeMonths
|
|
1497
1684
|
}, {
|
|
1498
1685
|
divisor: year,
|
|
1499
|
-
limit:
|
|
1686
|
+
limit: Infinity,
|
|
1500
1687
|
one: inOneYear,
|
|
1501
1688
|
some: inSomeYears
|
|
1502
1689
|
}];
|
|
@@ -1537,7 +1724,7 @@ const ranges = [{
|
|
|
1537
1724
|
some: someMonthsAgo
|
|
1538
1725
|
}, {
|
|
1539
1726
|
divisor: year,
|
|
1540
|
-
limit:
|
|
1727
|
+
limit: Infinity,
|
|
1541
1728
|
one: oneYearAgo,
|
|
1542
1729
|
some: someYearsAgo
|
|
1543
1730
|
}];
|
|
@@ -1569,7 +1756,7 @@ const formatAboutDate = (isoDate, now) => {
|
|
|
1569
1756
|
|
|
1570
1757
|
const getBrowser = () => {
|
|
1571
1758
|
// @ts-ignore
|
|
1572
|
-
return
|
|
1759
|
+
return navigator.userAgent;
|
|
1573
1760
|
};
|
|
1574
1761
|
|
|
1575
1762
|
const version = '0.0.0-dev';
|
|
@@ -1582,28 +1769,61 @@ const getDetailStringWeb = () => {
|
|
|
1582
1769
|
return lines;
|
|
1583
1770
|
};
|
|
1584
1771
|
|
|
1585
|
-
const
|
|
1586
|
-
|
|
1587
|
-
const getChromeVersion = getChromeVersion$1;
|
|
1588
|
-
const getVersion = () => {
|
|
1589
|
-
return version;
|
|
1772
|
+
const getConfigJsonPath = async () => {
|
|
1773
|
+
return invoke('ProcessPaths.getConfigJsonPath');
|
|
1590
1774
|
};
|
|
1591
|
-
|
|
1592
|
-
|
|
1775
|
+
|
|
1776
|
+
const getString = (config, key) => {
|
|
1777
|
+
const value = config[key];
|
|
1778
|
+
if (typeof value !== 'string') {
|
|
1779
|
+
return '';
|
|
1780
|
+
}
|
|
1781
|
+
return value;
|
|
1593
1782
|
};
|
|
1594
|
-
const
|
|
1595
|
-
const
|
|
1596
|
-
|
|
1783
|
+
const loadConfig = async _state => {
|
|
1784
|
+
const configJsonPath = await getConfigJsonPath();
|
|
1785
|
+
// FileSystemWorker.readFile is a custom RPC that already returns a string.
|
|
1786
|
+
// eslint-disable-next-line unicorn/consistent-json-file-read
|
|
1787
|
+
const content = await readFile(configJsonPath);
|
|
1788
|
+
const config = JSON.parse(content);
|
|
1789
|
+
return {
|
|
1790
|
+
commit: getString(config, 'commit'),
|
|
1791
|
+
date: getString(config, 'date'),
|
|
1792
|
+
productName: getString(config, 'productName'),
|
|
1793
|
+
version: getString(config, 'version')
|
|
1794
|
+
};
|
|
1597
1795
|
};
|
|
1598
|
-
const productNameLong$1 = 'Lvce Editor - OSS';
|
|
1599
1796
|
|
|
1600
|
-
const
|
|
1601
|
-
const
|
|
1797
|
+
const getContentFromConfig = async state => {
|
|
1798
|
+
const now = Date.now();
|
|
1799
|
+
try {
|
|
1800
|
+
const config = await loadConfig(state);
|
|
1801
|
+
const resolvedVersion = config.version || version;
|
|
1802
|
+
const resolvedCommit = config.commit || commit;
|
|
1803
|
+
const resolvedDate = config.date || commitDate;
|
|
1804
|
+
const formattedDate = formatAboutDate(resolvedDate, now);
|
|
1805
|
+
const browser = getBrowser();
|
|
1806
|
+
return {
|
|
1807
|
+
lines: [`Version: ${resolvedVersion}`, `Commit: ${resolvedCommit}`, `Date: ${formattedDate}`, `Browser: ${browser}`],
|
|
1808
|
+
productName: config.productName || state.productName
|
|
1809
|
+
};
|
|
1810
|
+
} catch {
|
|
1811
|
+
return {
|
|
1812
|
+
lines: getDetailStringWeb(),
|
|
1813
|
+
productName: state.productName
|
|
1814
|
+
};
|
|
1815
|
+
}
|
|
1816
|
+
};
|
|
1817
|
+
const loadContent2 = async state => {
|
|
1818
|
+
const content = state.useNewLoadConfig ? await getContentFromConfig(state) : {
|
|
1819
|
+
lines: getDetailStringWeb(),
|
|
1820
|
+
productName: state.productName
|
|
1821
|
+
};
|
|
1602
1822
|
return {
|
|
1603
1823
|
...state,
|
|
1604
1824
|
focusId: Ok$2,
|
|
1605
|
-
lines,
|
|
1606
|
-
productName:
|
|
1825
|
+
lines: content.lines,
|
|
1826
|
+
productName: content.productName
|
|
1607
1827
|
};
|
|
1608
1828
|
};
|
|
1609
1829
|
|
|
@@ -1803,7 +2023,7 @@ const getFocusSelector = focusId => {
|
|
|
1803
2023
|
|
|
1804
2024
|
const renderFocus = (oldState, newState) => {
|
|
1805
2025
|
const name = getFocusSelector(newState.focusId);
|
|
1806
|
-
return ['Viewlet.
|
|
2026
|
+
return ['Viewlet.focusSelector', `[name="${name}"]`];
|
|
1807
2027
|
};
|
|
1808
2028
|
|
|
1809
2029
|
const renderFocusContext = (oldState, newState) => {
|
|
@@ -1834,11 +2054,11 @@ const applyRender = (oldState, newState, diffResult) => {
|
|
|
1834
2054
|
|
|
1835
2055
|
const doRender = (uid, diffResult) => {
|
|
1836
2056
|
const {
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
} = get(uid);
|
|
1840
|
-
set(uid,
|
|
1841
|
-
const commands = applyRender(oldState,
|
|
2057
|
+
oldState,
|
|
2058
|
+
scheduledState
|
|
2059
|
+
} = get$2(uid);
|
|
2060
|
+
set$3(uid, scheduledState, scheduledState);
|
|
2061
|
+
const commands = applyRender(oldState, scheduledState, diffResult);
|
|
1842
2062
|
return commands;
|
|
1843
2063
|
};
|
|
1844
2064
|
|
|
@@ -1867,17 +2087,10 @@ const showAboutDefault = async () => {
|
|
|
1867
2087
|
|
|
1868
2088
|
const getWindowId = getWindowId$1;
|
|
1869
2089
|
|
|
1870
|
-
const productNameLong = 'Lvce Editor - OSS';
|
|
1871
|
-
const getProductNameLong = () => {
|
|
1872
|
-
return productNameLong;
|
|
1873
|
-
};
|
|
1874
|
-
|
|
1875
2090
|
const showMessageBox = async options => {
|
|
1876
|
-
const productName = getProductNameLong();
|
|
1877
2091
|
const windowId = await getWindowId();
|
|
1878
2092
|
const finalOptions = {
|
|
1879
2093
|
...options,
|
|
1880
|
-
productName,
|
|
1881
2094
|
windowId
|
|
1882
2095
|
};
|
|
1883
2096
|
return showMessageBox$1(finalOptions);
|
|
@@ -1885,6 +2098,20 @@ const showMessageBox = async options => {
|
|
|
1885
2098
|
|
|
1886
2099
|
const Info = 'info';
|
|
1887
2100
|
|
|
2101
|
+
const getElectronVersion = getElectronVersion$1;
|
|
2102
|
+
const getNodeVersion = getNodeVersion$1;
|
|
2103
|
+
const getChromeVersion = getChromeVersion$1;
|
|
2104
|
+
const getVersion = async () => {
|
|
2105
|
+
return version;
|
|
2106
|
+
};
|
|
2107
|
+
const getCommit = async () => {
|
|
2108
|
+
return commit;
|
|
2109
|
+
};
|
|
2110
|
+
const getV8Version = getV8Version$1;
|
|
2111
|
+
const getDate = () => {
|
|
2112
|
+
return commitDate;
|
|
2113
|
+
};
|
|
2114
|
+
|
|
1888
2115
|
/* eslint-disable @typescript-eslint/await-thenable */
|
|
1889
2116
|
const getDetailString = async () => {
|
|
1890
2117
|
const [electronVersion, nodeVersion, chromeVersion, version, commit, v8Version, date] = await Promise.all([getElectronVersion(), getNodeVersion(), getChromeVersion(), getVersion(), getCommit(), getV8Version(), getDate()]);
|
|
@@ -1894,14 +2121,19 @@ const getDetailString = async () => {
|
|
|
1894
2121
|
return joinLines(lines);
|
|
1895
2122
|
};
|
|
1896
2123
|
|
|
2124
|
+
const getProductName = async () => {
|
|
2125
|
+
const config = await loadConfig();
|
|
2126
|
+
return config.productName;
|
|
2127
|
+
};
|
|
1897
2128
|
const showAboutElectron = async () => {
|
|
1898
2129
|
const windowId = await getWindowId();
|
|
1899
2130
|
const detail = await getDetailString();
|
|
1900
|
-
const
|
|
2131
|
+
const productName = await getProductName();
|
|
1901
2132
|
const options = {
|
|
1902
2133
|
buttons: [copy(), ok()],
|
|
1903
2134
|
detail,
|
|
1904
|
-
message:
|
|
2135
|
+
message: productName,
|
|
2136
|
+
productName,
|
|
1905
2137
|
type: Info,
|
|
1906
2138
|
windowId
|
|
1907
2139
|
};
|
|
@@ -1928,7 +2160,7 @@ const showAbout = async platform => {
|
|
|
1928
2160
|
};
|
|
1929
2161
|
|
|
1930
2162
|
const commandMap = {
|
|
1931
|
-
'About.create': create,
|
|
2163
|
+
'About.create': create$9,
|
|
1932
2164
|
'About.diff2': diff2,
|
|
1933
2165
|
'About.dispose': dispose,
|
|
1934
2166
|
'About.focusNext': wrapCommand(focusNext),
|
|
@@ -1947,14 +2179,30 @@ const commandMap = {
|
|
|
1947
2179
|
'About.showAboutElectron': showAboutElectron
|
|
1948
2180
|
};
|
|
1949
2181
|
|
|
1950
|
-
const
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
2182
|
+
const send = async port => {
|
|
2183
|
+
await sendMessagePortToFileSystemWorker(port, 0);
|
|
2184
|
+
};
|
|
2185
|
+
const initializeFileSystemWorker = async () => {
|
|
2186
|
+
const rpc = await create$2({
|
|
2187
|
+
commandMap: {},
|
|
2188
|
+
send
|
|
1954
2189
|
});
|
|
1955
2190
|
set$1(rpc);
|
|
1956
2191
|
};
|
|
1957
2192
|
|
|
2193
|
+
const initializeRendererWorker = async () => {
|
|
2194
|
+
const rpc = await create$1({
|
|
2195
|
+
commandMap: commandMap
|
|
2196
|
+
});
|
|
2197
|
+
set(rpc);
|
|
2198
|
+
};
|
|
2199
|
+
|
|
2200
|
+
const listen = async () => {
|
|
2201
|
+
registerCommands(commandMap);
|
|
2202
|
+
await initializeRendererWorker();
|
|
2203
|
+
await initializeFileSystemWorker();
|
|
2204
|
+
};
|
|
2205
|
+
|
|
1958
2206
|
const main = async () => {
|
|
1959
2207
|
await listen();
|
|
1960
2208
|
};
|