@lvce-editor/about-view 7.9.0 → 7.11.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 +138 -30
- package/package.json +1 -1
package/dist/aboutWorkerMain.js
CHANGED
|
@@ -3,9 +3,18 @@ const toCommandId = key => {
|
|
|
3
3
|
return key.slice(dotIndex + 1);
|
|
4
4
|
};
|
|
5
5
|
const create$a = () => {
|
|
6
|
+
const commandQueues = new Map();
|
|
7
|
+
const generations = Object.create(null);
|
|
6
8
|
const states = Object.create(null);
|
|
7
9
|
const commandMapRef = {};
|
|
8
|
-
const
|
|
10
|
+
const getGeneration = uid => generations[uid] || 0;
|
|
11
|
+
const isCurrentGeneration = (uid, generation) => {
|
|
12
|
+
return states[uid] !== undefined && getGeneration(uid) === generation;
|
|
13
|
+
};
|
|
14
|
+
const updateState = (uid, generation, fallbackState, updater) => {
|
|
15
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
16
|
+
return Promise.resolve(fallbackState);
|
|
17
|
+
}
|
|
9
18
|
const current = states[uid];
|
|
10
19
|
const updatedState = updater(current.newState);
|
|
11
20
|
if (updatedState !== current.newState) {
|
|
@@ -17,8 +26,44 @@ const create$a = () => {
|
|
|
17
26
|
}
|
|
18
27
|
return Promise.resolve(updatedState);
|
|
19
28
|
};
|
|
29
|
+
const createAsyncCommandContext = (uid, generation) => {
|
|
30
|
+
let latestState = states[uid].newState;
|
|
31
|
+
return {
|
|
32
|
+
getState: () => {
|
|
33
|
+
if (isCurrentGeneration(uid, generation)) {
|
|
34
|
+
latestState = states[uid].newState;
|
|
35
|
+
}
|
|
36
|
+
return latestState;
|
|
37
|
+
},
|
|
38
|
+
updateState: async updater => {
|
|
39
|
+
latestState = await updateState(uid, generation, latestState, updater);
|
|
40
|
+
return latestState;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
const enqueueCommand = async (uid, command) => {
|
|
45
|
+
const previous = commandQueues.get(uid) || Promise.resolve();
|
|
46
|
+
const run = async () => {
|
|
47
|
+
try {
|
|
48
|
+
await previous;
|
|
49
|
+
} catch {
|
|
50
|
+
// The previous caller receives its error; later commands must still run.
|
|
51
|
+
}
|
|
52
|
+
await command();
|
|
53
|
+
};
|
|
54
|
+
const current = run();
|
|
55
|
+
commandQueues.set(uid, current);
|
|
56
|
+
try {
|
|
57
|
+
await current;
|
|
58
|
+
} finally {
|
|
59
|
+
if (commandQueues.get(uid) === current) {
|
|
60
|
+
commandQueues.delete(uid);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
20
64
|
return {
|
|
21
65
|
clear() {
|
|
66
|
+
commandQueues.clear();
|
|
22
67
|
for (const key of Object.keys(states)) {
|
|
23
68
|
delete states[key];
|
|
24
69
|
}
|
|
@@ -38,6 +83,7 @@ const create$a = () => {
|
|
|
38
83
|
return diffResult;
|
|
39
84
|
},
|
|
40
85
|
dispose(uid) {
|
|
86
|
+
commandQueues.delete(uid);
|
|
41
87
|
delete states[uid];
|
|
42
88
|
},
|
|
43
89
|
get(uid) {
|
|
@@ -55,6 +101,10 @@ const create$a = () => {
|
|
|
55
101
|
Object.assign(commandMapRef, commandMap);
|
|
56
102
|
},
|
|
57
103
|
set(uid, oldState, newState, scheduledState) {
|
|
104
|
+
const current = states[uid];
|
|
105
|
+
if (!current || oldState === newState && newState !== current.newState) {
|
|
106
|
+
generations[uid] = getGeneration(uid) + 1;
|
|
107
|
+
}
|
|
58
108
|
states[uid] = {
|
|
59
109
|
newState,
|
|
60
110
|
oldState,
|
|
@@ -63,16 +113,15 @@ const create$a = () => {
|
|
|
63
113
|
},
|
|
64
114
|
wrapAsyncCommand(fn) {
|
|
65
115
|
const wrapped = async (uid, ...args) => {
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
updateState: updater => updateState(uid, updater)
|
|
69
|
-
};
|
|
116
|
+
const generation = getGeneration(uid);
|
|
117
|
+
const context = createAsyncCommandContext(uid, generation);
|
|
70
118
|
await fn(context, ...args);
|
|
71
119
|
};
|
|
72
120
|
return wrapped;
|
|
73
121
|
},
|
|
74
122
|
wrapCommand(fn) {
|
|
75
123
|
const wrapped = async (uid, ...args) => {
|
|
124
|
+
const generation = getGeneration(uid);
|
|
76
125
|
const {
|
|
77
126
|
newState,
|
|
78
127
|
oldState
|
|
@@ -81,6 +130,9 @@ const create$a = () => {
|
|
|
81
130
|
if (oldState === newerState || newState === newerState) {
|
|
82
131
|
return;
|
|
83
132
|
}
|
|
133
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
84
136
|
const latestOld = states[uid];
|
|
85
137
|
const latestNew = {
|
|
86
138
|
...latestOld.newState,
|
|
@@ -105,6 +157,7 @@ const create$a = () => {
|
|
|
105
157
|
},
|
|
106
158
|
wrapLoadContent(fn) {
|
|
107
159
|
const wrapped = async (uid, ...args) => {
|
|
160
|
+
const generation = getGeneration(uid);
|
|
108
161
|
const {
|
|
109
162
|
newState,
|
|
110
163
|
oldState
|
|
@@ -119,6 +172,11 @@ const create$a = () => {
|
|
|
119
172
|
error
|
|
120
173
|
};
|
|
121
174
|
}
|
|
175
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
176
|
+
return {
|
|
177
|
+
error
|
|
178
|
+
};
|
|
179
|
+
}
|
|
122
180
|
const latestOld = states[uid];
|
|
123
181
|
const latestNew = {
|
|
124
182
|
...latestOld.newState,
|
|
@@ -134,6 +192,51 @@ const create$a = () => {
|
|
|
134
192
|
};
|
|
135
193
|
};
|
|
136
194
|
return wrapped;
|
|
195
|
+
},
|
|
196
|
+
wrapSerialAsyncCommand(fn) {
|
|
197
|
+
const wrapped = async (uid, ...args) => {
|
|
198
|
+
await enqueueCommand(uid, async () => {
|
|
199
|
+
if (!states[uid]) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const generation = getGeneration(uid);
|
|
203
|
+
const context = createAsyncCommandContext(uid, generation);
|
|
204
|
+
await fn(context, ...args);
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
return wrapped;
|
|
208
|
+
},
|
|
209
|
+
wrapSerialCommand(fn) {
|
|
210
|
+
const wrapped = async (uid, ...args) => {
|
|
211
|
+
await enqueueCommand(uid, async () => {
|
|
212
|
+
if (!states[uid]) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const generation = getGeneration(uid);
|
|
216
|
+
const {
|
|
217
|
+
newState,
|
|
218
|
+
oldState
|
|
219
|
+
} = states[uid];
|
|
220
|
+
const newerState = await fn(newState, ...args);
|
|
221
|
+
if (oldState === newerState || newState === newerState) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
const latestOld = states[uid];
|
|
228
|
+
const latestNew = {
|
|
229
|
+
...latestOld.newState,
|
|
230
|
+
...newerState
|
|
231
|
+
};
|
|
232
|
+
states[uid] = {
|
|
233
|
+
newState: latestNew,
|
|
234
|
+
oldState: latestOld.oldState,
|
|
235
|
+
scheduledState: latestNew
|
|
236
|
+
};
|
|
237
|
+
});
|
|
238
|
+
};
|
|
239
|
+
return wrapped;
|
|
137
240
|
}
|
|
138
241
|
};
|
|
139
242
|
};
|
|
@@ -2171,6 +2274,32 @@ const joinBySpace = (...items) => {
|
|
|
2171
2274
|
|
|
2172
2275
|
const Focusable = -1;
|
|
2173
2276
|
|
|
2277
|
+
const dialogToolBarRow = {
|
|
2278
|
+
childCount: 1,
|
|
2279
|
+
className: DialogToolBarRow,
|
|
2280
|
+
type: Div
|
|
2281
|
+
};
|
|
2282
|
+
const dialogMessageRow = {
|
|
2283
|
+
childCount: 2,
|
|
2284
|
+
className: DialogMessageRow,
|
|
2285
|
+
type: Div
|
|
2286
|
+
};
|
|
2287
|
+
const dialogContentRight = {
|
|
2288
|
+
childCount: 2,
|
|
2289
|
+
className: DialogContentRight,
|
|
2290
|
+
type: Div
|
|
2291
|
+
};
|
|
2292
|
+
const dialogHeading = {
|
|
2293
|
+
childCount: 1,
|
|
2294
|
+
className: DialogHeading$1,
|
|
2295
|
+
id: DialogHeading,
|
|
2296
|
+
type: Div
|
|
2297
|
+
};
|
|
2298
|
+
const dialogButtonsRow = {
|
|
2299
|
+
childCount: 2,
|
|
2300
|
+
className: DialogButtonsRow,
|
|
2301
|
+
type: Div
|
|
2302
|
+
};
|
|
2174
2303
|
const getDialogVirtualDom = (content, closeMessage, infoMessage, okMessage, copyMessage, productName) => {
|
|
2175
2304
|
const dom = [{
|
|
2176
2305
|
ariaLabelledBy: joinBySpace(DialogIcon, DialogHeading),
|
|
@@ -2181,11 +2310,7 @@ const getDialogVirtualDom = (content, closeMessage, infoMessage, okMessage, copy
|
|
|
2181
2310
|
role: Dialog,
|
|
2182
2311
|
tabIndex: Focusable,
|
|
2183
2312
|
type: Div
|
|
2184
|
-
}, {
|
|
2185
|
-
childCount: 1,
|
|
2186
|
-
className: DialogToolBarRow,
|
|
2187
|
-
type: Div
|
|
2188
|
-
}, {
|
|
2313
|
+
}, dialogToolBarRow, {
|
|
2189
2314
|
ariaLabel: closeMessage,
|
|
2190
2315
|
childCount: 1,
|
|
2191
2316
|
className: DialogClose,
|
|
@@ -2195,30 +2320,13 @@ const getDialogVirtualDom = (content, closeMessage, infoMessage, okMessage, copy
|
|
|
2195
2320
|
childCount: 0,
|
|
2196
2321
|
className: mergeClassNames(MaskIcon, MaskIconClose),
|
|
2197
2322
|
type: Div
|
|
2198
|
-
}, {
|
|
2199
|
-
childCount: 2,
|
|
2200
|
-
className: DialogMessageRow,
|
|
2201
|
-
type: Div
|
|
2202
|
-
}, {
|
|
2323
|
+
}, dialogMessageRow, {
|
|
2203
2324
|
ariaLabel: infoMessage,
|
|
2204
2325
|
childCount: 0,
|
|
2205
2326
|
className: mergeClassNames(DialogIcon$1, DialogInfoIcon, MaskIcon, MaskIconInfo),
|
|
2206
2327
|
id: DialogIcon,
|
|
2207
2328
|
type: Div
|
|
2208
|
-
},
|
|
2209
|
-
childCount: 2,
|
|
2210
|
-
className: DialogContentRight,
|
|
2211
|
-
type: Div
|
|
2212
|
-
}, {
|
|
2213
|
-
childCount: 1,
|
|
2214
|
-
className: DialogHeading$1,
|
|
2215
|
-
id: DialogHeading,
|
|
2216
|
-
type: Div
|
|
2217
|
-
}, text(productName), ...content, {
|
|
2218
|
-
childCount: 2,
|
|
2219
|
-
className: DialogButtonsRow,
|
|
2220
|
-
type: Div
|
|
2221
|
-
}, ...getSecondaryButtonVirtualDom(okMessage, Ok$1), ...getPrimaryButtonVirtualDom(copyMessage, Copy$1)];
|
|
2329
|
+
}, dialogContentRight, dialogHeading, text(productName), ...content, dialogButtonsRow, ...getSecondaryButtonVirtualDom(okMessage, Ok$1), ...getPrimaryButtonVirtualDom(copyMessage, Copy$1)];
|
|
2222
2330
|
return dom;
|
|
2223
2331
|
};
|
|
2224
2332
|
|
|
@@ -2262,7 +2370,7 @@ const renderFocus = (oldState, newState) => {
|
|
|
2262
2370
|
};
|
|
2263
2371
|
|
|
2264
2372
|
const renderFocusContext = (oldState, newState) => {
|
|
2265
|
-
return ['Viewlet.setFocusContext', FocusAbout];
|
|
2373
|
+
return ['Viewlet.setFocusContext', newState.uid, FocusAbout];
|
|
2266
2374
|
};
|
|
2267
2375
|
|
|
2268
2376
|
const getRenderer = diffType => {
|