@lvce-editor/renderer-process 30.73.2 → 30.74.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/rendererProcessMain.js +93 -10
- package/package.json +1 -1
|
@@ -629,7 +629,7 @@ class CommandNotFoundError extends Error {
|
|
|
629
629
|
}
|
|
630
630
|
}
|
|
631
631
|
const commands = Object.create(null);
|
|
632
|
-
const register$
|
|
632
|
+
const register$2 = commandMap => {
|
|
633
633
|
Object.assign(commands, commandMap);
|
|
634
634
|
};
|
|
635
635
|
const getCommand = key => {
|
|
@@ -648,7 +648,7 @@ const callbacks = Object.create(null);
|
|
|
648
648
|
const get$c = id => {
|
|
649
649
|
return callbacks[id];
|
|
650
650
|
};
|
|
651
|
-
const remove$
|
|
651
|
+
const remove$7 = id => {
|
|
652
652
|
delete callbacks[id];
|
|
653
653
|
};
|
|
654
654
|
class JsonRpcError extends Error {
|
|
@@ -876,7 +876,7 @@ const resolve = (id, response) => {
|
|
|
876
876
|
return;
|
|
877
877
|
}
|
|
878
878
|
fn(response);
|
|
879
|
-
remove$
|
|
879
|
+
remove$7(id);
|
|
880
880
|
};
|
|
881
881
|
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
882
882
|
const getErrorType = prettyError => {
|
|
@@ -1164,7 +1164,7 @@ const create$E = async ({
|
|
|
1164
1164
|
window
|
|
1165
1165
|
}) => {
|
|
1166
1166
|
// TODO create a commandMap per rpc instance
|
|
1167
|
-
register$
|
|
1167
|
+
register$2(commandMap);
|
|
1168
1168
|
const ipc = IpcChildWithElectronWindow$1.wrap(window);
|
|
1169
1169
|
handleIpc(ipc);
|
|
1170
1170
|
const rpc = createRpc(ipc);
|
|
@@ -1177,7 +1177,7 @@ const create$D = async ({
|
|
|
1177
1177
|
messagePort
|
|
1178
1178
|
}) => {
|
|
1179
1179
|
// TODO create a commandMap per rpc instance
|
|
1180
|
-
register$
|
|
1180
|
+
register$2(commandMap);
|
|
1181
1181
|
const rawIpc = await IpcParentWithMessagePort$1$1.create({
|
|
1182
1182
|
isMessagePortOpen,
|
|
1183
1183
|
messagePort
|
|
@@ -1199,7 +1199,7 @@ const create$C = async ({
|
|
|
1199
1199
|
url
|
|
1200
1200
|
}) => {
|
|
1201
1201
|
// TODO create a commandMap per rpc instance
|
|
1202
|
-
register$
|
|
1202
|
+
register$2(commandMap);
|
|
1203
1203
|
const worker = await IpcParentWithModuleWorker$1$1.create({
|
|
1204
1204
|
name,
|
|
1205
1205
|
url
|
|
@@ -1220,7 +1220,7 @@ const create$B = async ({
|
|
|
1220
1220
|
url
|
|
1221
1221
|
}) => {
|
|
1222
1222
|
// TODO create a commandMap per rpc instance
|
|
1223
|
-
register$
|
|
1223
|
+
register$2(commandMap);
|
|
1224
1224
|
const worker = await IpcParentWithModuleWorker$1$1.create({
|
|
1225
1225
|
name,
|
|
1226
1226
|
url
|
|
@@ -1506,7 +1506,7 @@ const track = (worker, startedIn = state$o.generation, trackedWorker) => {
|
|
|
1506
1506
|
metadataById.set(metadata.id, metadata);
|
|
1507
1507
|
workers$1.set(worker, metadata);
|
|
1508
1508
|
};
|
|
1509
|
-
const remove$
|
|
1509
|
+
const remove$6 = worker => {
|
|
1510
1510
|
const metadata = workers$1.get(worker);
|
|
1511
1511
|
workers$1.delete(worker);
|
|
1512
1512
|
if (metadata) metadataById.delete(metadata.id);
|
|
@@ -2012,6 +2012,82 @@ const initialize = () => {
|
|
|
2012
2012
|
}
|
|
2013
2013
|
};
|
|
2014
2014
|
|
|
2015
|
+
const registrations = new Map();
|
|
2016
|
+
const getRegistration = target => {
|
|
2017
|
+
if (!(target instanceof HTMLTextAreaElement) || !target.matches('.EditorInput textarea') || !target.closest('.Editor')) return undefined;
|
|
2018
|
+
const root = target.closest('[id^="Workbench-"]');
|
|
2019
|
+
return root ? registrations.get(root.id) : undefined;
|
|
2020
|
+
};
|
|
2021
|
+
const register$1 = (rootId, id, keymap) => {
|
|
2022
|
+
const root = document.getElementById(rootId);
|
|
2023
|
+
if (!root) throw new Error(`Editor keymap root not found: ${rootId}`);
|
|
2024
|
+
if (registrations.has(rootId)) throw new Error(`Editor keymap already registered: ${rootId}`);
|
|
2025
|
+
if (!Object.hasOwn(keymap.modes, keymap.initialMode)) throw new Error('Unknown initial editor keymap mode');
|
|
2026
|
+
for (const mode of Object.values(keymap.modes)) {
|
|
2027
|
+
for (const binding of Object.values(mode.bindings)) {
|
|
2028
|
+
if (binding.mode !== undefined && !Object.hasOwn(keymap.modes, binding.mode)) throw new Error('Unknown editor keymap mode');
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
const cursorStyles = ['--EditorCursorWidth', '--EditorCursorOpacity'].map(name => ({
|
|
2032
|
+
name,
|
|
2033
|
+
priority: root.style.getPropertyPriority(name),
|
|
2034
|
+
value: root.style.getPropertyValue(name)
|
|
2035
|
+
}));
|
|
2036
|
+
if (keymap.cursorStyle !== undefined) {
|
|
2037
|
+
root.style.setProperty('--EditorCursorWidth', keymap.cursorStyle === 'block' ? '1ch' : '2px');
|
|
2038
|
+
root.style.setProperty('--EditorCursorOpacity', keymap.cursorStyle === 'block' ? '0.5' : '1');
|
|
2039
|
+
}
|
|
2040
|
+
const beforeInput = event => {
|
|
2041
|
+
const registration = getRegistration(event.target);
|
|
2042
|
+
if (registration?.keymap.modes[registration.mode]?.captureText) {
|
|
2043
|
+
event.preventDefault();
|
|
2044
|
+
event.stopImmediatePropagation();
|
|
2045
|
+
}
|
|
2046
|
+
};
|
|
2047
|
+
registrations.set(rootId, {
|
|
2048
|
+
beforeInput,
|
|
2049
|
+
cursorStyles,
|
|
2050
|
+
id,
|
|
2051
|
+
keymap,
|
|
2052
|
+
mode: keymap.initialMode,
|
|
2053
|
+
root
|
|
2054
|
+
});
|
|
2055
|
+
root.addEventListener('beforeinput', beforeInput, {
|
|
2056
|
+
capture: true
|
|
2057
|
+
});
|
|
2058
|
+
};
|
|
2059
|
+
const remove$5 = (rootId, id) => {
|
|
2060
|
+
const registration = registrations.get(rootId);
|
|
2061
|
+
if (registration?.id !== id) return;
|
|
2062
|
+
registration.root.removeEventListener('beforeinput', registration.beforeInput, true);
|
|
2063
|
+
if (registration.keymap.cursorStyle !== undefined) {
|
|
2064
|
+
for (const {
|
|
2065
|
+
name,
|
|
2066
|
+
priority,
|
|
2067
|
+
value
|
|
2068
|
+
} of registration.cursorStyles) {
|
|
2069
|
+
if (value) registration.root.style.setProperty(name, value, priority);else registration.root.style.removeProperty(name);
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2072
|
+
registrations.delete(rootId);
|
|
2073
|
+
};
|
|
2074
|
+
|
|
2075
|
+
// Resolve mode transitions before the browser can produce the next input event.
|
|
2076
|
+
const handleKeyDown$5 = event => {
|
|
2077
|
+
const registration = getRegistration(event.target);
|
|
2078
|
+
if (!registration || event.altKey || event.ctrlKey || event.metaKey || event.isComposing) return false;
|
|
2079
|
+
const mode = registration.keymap.modes[registration.mode];
|
|
2080
|
+
if (!mode) return false;
|
|
2081
|
+
const binding = Object.hasOwn(mode.bindings, event.key) ? mode.bindings[event.key] : undefined;
|
|
2082
|
+
if (!binding && !(mode.captureText && (event.key.length === 1 || ['Enter', 'Backspace', 'Delete'].includes(event.key)))) return false;
|
|
2083
|
+
event.preventDefault();
|
|
2084
|
+
if (binding?.mode !== undefined) registration.mode = binding.mode;
|
|
2085
|
+
if (binding?.command) {
|
|
2086
|
+
send$1('EditorKeymap.execute', registration.id, binding.command, ...(binding.args || []));
|
|
2087
|
+
}
|
|
2088
|
+
return true;
|
|
2089
|
+
};
|
|
2090
|
+
|
|
2015
2091
|
const uidSymbol = Symbol('uid');
|
|
2016
2092
|
|
|
2017
2093
|
const getUidTarget = $Element => {
|
|
@@ -2590,6 +2666,7 @@ const BlockQuote$1 = 'blockquote';
|
|
|
2590
2666
|
const Rect$2 = 'rect';
|
|
2591
2667
|
const Svg$2 = 'svg';
|
|
2592
2668
|
const Use$2 = 'use';
|
|
2669
|
+
const Progress$1 = 'progress';
|
|
2593
2670
|
|
|
2594
2671
|
const Audio$2 = 0;
|
|
2595
2672
|
const Button = 1;
|
|
@@ -2670,6 +2747,7 @@ const Polyline$1 = 88;
|
|
|
2670
2747
|
const Rect$1 = 89;
|
|
2671
2748
|
const Svg$1 = 90;
|
|
2672
2749
|
const Use$1 = 91;
|
|
2750
|
+
const Progress = 92;
|
|
2673
2751
|
const Reference$1 = 100;
|
|
2674
2752
|
|
|
2675
2753
|
const VirtualDomElements = {
|
|
@@ -2730,6 +2808,7 @@ const VirtualDomElements = {
|
|
|
2730
2808
|
Polygon: Polygon$1,
|
|
2731
2809
|
Polyline: Polyline$1,
|
|
2732
2810
|
Pre,
|
|
2811
|
+
Progress,
|
|
2733
2812
|
Quote: Quote$2,
|
|
2734
2813
|
Rect: Rect$1,
|
|
2735
2814
|
Reference: Reference$1,
|
|
@@ -2813,6 +2892,7 @@ const elementTagMap = {
|
|
|
2813
2892
|
[Polygon$1]: Polygon$2,
|
|
2814
2893
|
[Polyline$1]: Polyline$2,
|
|
2815
2894
|
[Pre]: Pre$1,
|
|
2895
|
+
[Progress]: Progress$1,
|
|
2816
2896
|
[Quote$2]: Quote$3,
|
|
2817
2897
|
[Rect$1]: Rect$2,
|
|
2818
2898
|
[Search]: Search$1,
|
|
@@ -4427,7 +4507,7 @@ const create$y = async ({
|
|
|
4427
4507
|
break;
|
|
4428
4508
|
}
|
|
4429
4509
|
} catch (error) {
|
|
4430
|
-
remove$
|
|
4510
|
+
remove$6(worker);
|
|
4431
4511
|
worker.terminate();
|
|
4432
4512
|
throw error;
|
|
4433
4513
|
}
|
|
@@ -4663,7 +4743,7 @@ const create$t = async ({
|
|
|
4663
4743
|
const dispose$l = id => {
|
|
4664
4744
|
const worker = remove$3(id);
|
|
4665
4745
|
if (worker) {
|
|
4666
|
-
remove$
|
|
4746
|
+
remove$6(worker);
|
|
4667
4747
|
worker.terminate();
|
|
4668
4748
|
}
|
|
4669
4749
|
};
|
|
@@ -7732,6 +7812,7 @@ const isEditableTarget = target => {
|
|
|
7732
7812
|
return Boolean(target.closest('input, textarea, [contenteditable]:not([contenteditable="false"])'));
|
|
7733
7813
|
};
|
|
7734
7814
|
const handleKeyDown$2 = event => {
|
|
7815
|
+
if (handleKeyDown$5(event)) return;
|
|
7735
7816
|
if (isNativeButtonActivation(event) || isTerminalTextInput(event)) {
|
|
7736
7817
|
return;
|
|
7737
7818
|
}
|
|
@@ -12559,6 +12640,8 @@ const commandMap = {
|
|
|
12559
12640
|
'Download.downloadFile': downloadFile,
|
|
12560
12641
|
'DragAndDrop.handleMessagePort': handleMessagePort$1,
|
|
12561
12642
|
'DropData.get': get$1,
|
|
12643
|
+
'EditorKeymap.register': register$1,
|
|
12644
|
+
'EditorKeymap.remove': remove$5,
|
|
12562
12645
|
'FileHandles.get': get,
|
|
12563
12646
|
'FilePicker.showDirectoryPicker': showDirectoryPicker,
|
|
12564
12647
|
'FilePicker.showFilePicker': showFilePicker,
|