@lvce-editor/renderer-process 30.63.0 → 30.63.2
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/rendererProcessMain.js +46 -6
- package/package.json +1 -1
|
@@ -4703,16 +4703,18 @@ const pendingBatches = new Map();
|
|
|
4703
4703
|
const state$9 = {
|
|
4704
4704
|
nextTransactionId: 1
|
|
4705
4705
|
};
|
|
4706
|
-
const queue = (uid, commands) => {
|
|
4706
|
+
const queue = (uid, commands, focusVersion = 0) => {
|
|
4707
4707
|
const transactionId = state$9.nextTransactionId++;
|
|
4708
4708
|
pendingBatches.set(transactionId, {
|
|
4709
4709
|
commands,
|
|
4710
4710
|
committed: false,
|
|
4711
|
+
focusVersion,
|
|
4711
4712
|
uid
|
|
4712
4713
|
});
|
|
4713
4714
|
return transactionId;
|
|
4714
4715
|
};
|
|
4715
|
-
const
|
|
4716
|
+
const focusCommands = new Set(['Viewlet.focus', 'Viewlet.focusElementByName', 'Viewlet.focusSelector', 'Viewlet.focusSelectorAfterRender']);
|
|
4717
|
+
const take = (uid, transactionId, focusVersion = 0) => {
|
|
4716
4718
|
const batch = pendingBatches.get(transactionId);
|
|
4717
4719
|
if (!batch) {
|
|
4718
4720
|
throw new Error(`pending viewlet command transaction not found: ${transactionId}`);
|
|
@@ -4729,7 +4731,11 @@ const take = (uid, transactionId) => {
|
|
|
4729
4731
|
if (!pendingBatch.committed) {
|
|
4730
4732
|
break;
|
|
4731
4733
|
}
|
|
4732
|
-
|
|
4734
|
+
for (const command of pendingBatch.commands) {
|
|
4735
|
+
if (pendingBatch.focusVersion === focusVersion || !focusCommands.has(command[0])) {
|
|
4736
|
+
commands.push(command);
|
|
4737
|
+
}
|
|
4738
|
+
}
|
|
4733
4739
|
pendingBatches.delete(pendingTransactionId);
|
|
4734
4740
|
}
|
|
4735
4741
|
return commands;
|
|
@@ -9287,10 +9293,30 @@ const focusSelector = (viewletId, selector) => {
|
|
|
9287
9293
|
}
|
|
9288
9294
|
}
|
|
9289
9295
|
};
|
|
9296
|
+
const pendingFocusAfterRender = {};
|
|
9290
9297
|
const focusSelectorAfterRender = (viewletId, selector) => {
|
|
9298
|
+
pendingFocusAfterRender.cancel?.();
|
|
9299
|
+
const instance = get$b(viewletId);
|
|
9300
|
+
let cancelled = false;
|
|
9301
|
+
const cancel = () => {
|
|
9302
|
+
cancelled = true;
|
|
9303
|
+
document.removeEventListener('focusin', cancel, true);
|
|
9304
|
+
if (pendingFocusAfterRender.cancel === cancel) {
|
|
9305
|
+
pendingFocusAfterRender.cancel = undefined;
|
|
9306
|
+
}
|
|
9307
|
+
};
|
|
9308
|
+
pendingFocusAfterRender.cancel = cancel;
|
|
9309
|
+
// A newer focus choice owns focus, even while this viewlet is still rendering.
|
|
9310
|
+
document.addEventListener('focusin', cancel, {
|
|
9311
|
+
capture: true
|
|
9312
|
+
});
|
|
9291
9313
|
requestAnimationFrame(() => {
|
|
9292
9314
|
requestAnimationFrame(() => {
|
|
9293
|
-
|
|
9315
|
+
const shouldFocus = !cancelled && get$b(viewletId) === instance;
|
|
9316
|
+
cancel();
|
|
9317
|
+
if (shouldFocus) {
|
|
9318
|
+
focusSelector(viewletId, selector);
|
|
9319
|
+
}
|
|
9294
9320
|
});
|
|
9295
9321
|
});
|
|
9296
9322
|
};
|
|
@@ -9572,11 +9598,25 @@ const attachWindowEvents = () => {
|
|
|
9572
9598
|
const sendMultiple = commands => {
|
|
9573
9599
|
executeCommands(commands);
|
|
9574
9600
|
};
|
|
9601
|
+
const queuedFocus = {
|
|
9602
|
+
listening: false,
|
|
9603
|
+
version: 0
|
|
9604
|
+
};
|
|
9605
|
+
const getFocusVersion = () => {
|
|
9606
|
+
if (!queuedFocus.listening) {
|
|
9607
|
+
// One observer for this document's lifetime, without retaining focused elements.
|
|
9608
|
+
document.addEventListener('focusin', () => queuedFocus.version++, {
|
|
9609
|
+
capture: true
|
|
9610
|
+
});
|
|
9611
|
+
queuedFocus.listening = true;
|
|
9612
|
+
}
|
|
9613
|
+
return queuedFocus.version;
|
|
9614
|
+
};
|
|
9575
9615
|
const queueCommands = (uid, commands) => {
|
|
9576
|
-
return queue(uid, commands);
|
|
9616
|
+
return queue(uid, commands, getFocusVersion());
|
|
9577
9617
|
};
|
|
9578
9618
|
const commitPending = (uid, transactionId) => {
|
|
9579
|
-
executeCommands(take(uid, transactionId));
|
|
9619
|
+
executeCommands(take(uid, transactionId, getFocusVersion()));
|
|
9580
9620
|
};
|
|
9581
9621
|
const dispose$4 = id => {
|
|
9582
9622
|
try {
|