@lvce-editor/renderer-process 30.25.2 → 30.27.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.
@@ -1277,6 +1277,14 @@ const handleClipboardDataFiles = event => {
1277
1277
  }
1278
1278
  return files;
1279
1279
  };
1280
+ const handleClipboardDataFiles2 = event => {
1281
+ if (!event.clipboardData) {
1282
+ return [];
1283
+ }
1284
+ const fileItems = [...event.clipboardData.items].filter(item => item.kind === 'file');
1285
+ const promises = fileItems.map(unwrapItem);
1286
+ return promises.map(promise => add$1(promise));
1287
+ };
1280
1288
  const getTargetName = event => {
1281
1289
  const {
1282
1290
  target
@@ -1302,6 +1310,12 @@ const getNestedProperty = (value, path) => {
1302
1310
  return current;
1303
1311
  };
1304
1312
  const getEventListenerArg = (param, event) => {
1313
+ if (param === 'event.clipboardData.files') {
1314
+ return handleClipboardDataFiles(event);
1315
+ }
1316
+ if (param === 'event.clipboardData.files2') {
1317
+ return handleClipboardDataFiles2(event);
1318
+ }
1305
1319
  switch (param) {
1306
1320
  case 'event.altKey':
1307
1321
  return event.altKey;
@@ -1311,8 +1325,6 @@ const getEventListenerArg = (param, event) => {
1311
1325
  return event.clientX;
1312
1326
  case 'event.clientY':
1313
1327
  return event.clientY;
1314
- case 'event.clipboardData.files':
1315
- return handleClipboardDataFiles(event);
1316
1328
  case 'event.ctrlKey':
1317
1329
  return event.ctrlKey;
1318
1330
  case 'event.data':
@@ -431,6 +431,14 @@ const handleClipboardDataFiles = event => {
431
431
  }
432
432
  return files;
433
433
  };
434
+ const handleClipboardDataFiles2 = event => {
435
+ if (!event.clipboardData) {
436
+ return [];
437
+ }
438
+ const fileItems = [...event.clipboardData.items].filter(item => item.kind === 'file');
439
+ const promises = fileItems.map(unwrapItem);
440
+ return promises.map(promise => add$1(promise));
441
+ };
434
442
  const getTargetName = event => {
435
443
  const {
436
444
  target
@@ -456,6 +464,12 @@ const getNestedProperty = (value, path) => {
456
464
  return current;
457
465
  };
458
466
  const getEventListenerArg = (param, event) => {
467
+ if (param === 'event.clipboardData.files') {
468
+ return handleClipboardDataFiles(event);
469
+ }
470
+ if (param === 'event.clipboardData.files2') {
471
+ return handleClipboardDataFiles2(event);
472
+ }
459
473
  switch (param) {
460
474
  case 'event.altKey':
461
475
  return event.altKey;
@@ -465,8 +479,6 @@ const getEventListenerArg = (param, event) => {
465
479
  return event.clientX;
466
480
  case 'event.clientY':
467
481
  return event.clientY;
468
- case 'event.clipboardData.files':
469
- return handleClipboardDataFiles(event);
470
482
  case 'event.ctrlKey':
471
483
  return event.ctrlKey;
472
484
  case 'event.data':
@@ -979,79 +991,360 @@ const ElementTagMap = {
979
991
  getElementTag: getElementTag$1
980
992
  };
981
993
 
982
- const {
983
- getElementTag
984
- } = ElementTagMap;
985
-
986
- const instances = Object.create(null);
987
- const get$8 = viewletId => {
988
- return instances[viewletId];
989
- };
990
- const set$a = (viewletId, instance) => {
991
- instances[viewletId] = instance;
992
- };
993
-
994
- const getEventListenerOptions = (eventName, value) => {
995
- if (value.passive) {
996
- return {
997
- passive: true
998
- };
999
- }
1000
- if (value.capture) {
1001
- return {
1002
- capture: true
1003
- };
1004
- }
1005
- switch (eventName) {
1006
- case 'wheel':
1007
- return {
1008
- passive: true
1009
- };
1010
- default:
1011
- return undefined;
1012
- }
1013
- };
1014
-
1015
- const cache = new Map();
1016
- const has$1 = listener => {
1017
- return cache.has(listener);
1018
- };
1019
- const set$9 = (listener, value) => {
1020
- cache.set(listener, value);
1021
- };
1022
- const get$7 = listener => {
1023
- return cache.get(listener);
1024
- };
994
+ const Backspace$1 = 'Backspace';
995
+ const Tab$1 = 'Tab';
996
+ const Space$1 = ' ';
997
+ const Space2 = 'Space';
998
+ const Enter$1 = 'Enter';
999
+ const Escape$1 = 'Escape';
1000
+ const PageUp$1 = 'PageUp';
1001
+ const PageDown$1 = 'PageDown';
1002
+ const Home$1 = 'Home';
1003
+ const End$1 = 'End';
1004
+ const LeftArrow$1 = 'ArrowLeft';
1005
+ const RightArrow$1 = 'ArrowRight';
1006
+ const UpArrow$1 = 'ArrowUp';
1007
+ const DownArrow$1 = 'ArrowDown';
1008
+ const Insert$1 = 'Insert';
1009
+ const Delete$1 = 'Delete';
1010
+ const Digit0$1 = '0';
1011
+ const Digit1$1 = '1';
1012
+ const Digit2$1 = '2';
1013
+ const Digit3$1 = '3';
1014
+ const Digit4$1 = '4';
1015
+ const Digit5$1 = '5';
1016
+ const Digit6$1 = '6';
1017
+ const Digit7$1 = '7';
1018
+ const Digit8$1 = '8';
1019
+ const Digit9$1 = '9';
1020
+ const KeyA$1 = 'a';
1021
+ const KeyB$1 = 'b';
1022
+ const KeyC$1 = 'c';
1023
+ const KeyD$1 = 'd';
1024
+ const KeyE$1 = 'e';
1025
+ const KeyF$1 = 'f';
1026
+ const KeyG$1 = 'g';
1027
+ const KeyH$1 = 'h';
1028
+ const KeyI$1 = 'i';
1029
+ const KeyJ$1 = 'j';
1030
+ const KeyK$1 = 'k';
1031
+ const KeyL$1 = 'l';
1032
+ const KeyM$1 = 'm';
1033
+ const KeyN$1 = 'n';
1034
+ const KeyO$1 = 'o';
1035
+ const KeyP$1 = 'p';
1036
+ const KeyQ$1 = 'q';
1037
+ const KeyR$1 = 'r';
1038
+ const KeyS$1 = 's';
1039
+ const KeyT$1 = 't';
1040
+ const KeyU$1 = 'u';
1041
+ const KeyV$1 = 'v';
1042
+ const KeyW$1 = 'w';
1043
+ const KeyX$1 = 'x';
1044
+ const KeyY$1 = 'y';
1045
+ const KeyZ$1 = 'z';
1046
+ const F1$1 = 'F1';
1047
+ const F2$1 = 'F2';
1048
+ const F3$1 = 'F3';
1049
+ const F4$1 = 'F4';
1050
+ const F5$1 = 'F5';
1051
+ const F6$1 = 'F6';
1052
+ const F7$1 = 'F7';
1053
+ const F8$1 = 'F8';
1054
+ const F9$1 = 'F9';
1055
+ const F10$1 = 'F10';
1056
+ const F11$1 = 'F11';
1057
+ const F12$1 = 'F12';
1058
+ const F13$1 = 'F13';
1059
+ const F14$1 = 'F14';
1060
+ const F15$1 = 'F15';
1061
+ const F16$1 = 'F16';
1062
+ const F17$1 = 'F17';
1063
+ const F18$1 = 'F18';
1064
+ const F19$1 = 'F19';
1065
+ const F20$1 = 'F20';
1066
+ const F21$1 = 'F21';
1067
+ const F22$1 = 'F22';
1068
+ const F23$1 = 'F23';
1069
+ const F24$1 = 'F24';
1070
+ const SemiColon$1 = ';';
1071
+ const Equal$1 = '=';
1072
+ const Comma$1 = ',';
1073
+ const Minus$1 = '-';
1074
+ const Period$1 = '.';
1075
+ const Slash$1 = '/';
1076
+ const Backquote$1 = '`';
1077
+ const Backquote2 = 'Backquote';
1078
+ const BracketLeft$1 = '[';
1079
+ const Backslash$1 = '\\';
1080
+ const BracketRight$1 = ']';
1081
+ const Quote$1 = `'`;
1082
+ const Star$1 = '*';
1083
+ const Plus$1 = '+';
1025
1084
 
1026
- const getWrappedListener = (listener, returnValue) => {
1027
- if (!returnValue) {
1028
- return listener;
1029
- }
1030
- if (!has$1(listener)) {
1031
- const wrapped = event => {
1032
- const uid = getComponentUidFromEvent(event);
1033
- const result = listener(event);
1034
- // TODO check for empty array by value
1035
- if (result.length === 0) {
1036
- return;
1037
- }
1038
- const ipc = getIpc();
1039
- ipc.send('Viewlet.executeViewletCommand', uid, ...result);
1040
- };
1041
- nameAnonymousFunction$1(wrapped, listener.name);
1042
- set$9(listener, wrapped);
1043
- }
1044
- return get$7(listener);
1045
- };
1085
+ const Unknown = 0;
1086
+ const Backspace = 1;
1087
+ const Tab = 2;
1088
+ const Enter = 3;
1089
+ const Escape = 8;
1090
+ const Space = 9;
1091
+ const PageUp = 10;
1092
+ const PageDown = 11;
1093
+ const End = 255;
1094
+ const Home = 12;
1095
+ const LeftArrow = 13;
1096
+ const UpArrow = 14;
1097
+ const RightArrow = 15;
1098
+ const DownArrow = 16;
1099
+ const Insert = 17;
1100
+ const Delete = 18;
1101
+ const Digit0 = 19;
1102
+ const Digit1 = 20;
1103
+ const Digit2 = 21;
1104
+ const Digit3 = 22;
1105
+ const Digit4 = 23;
1106
+ const Digit5 = 24;
1107
+ const Digit6 = 25;
1108
+ const Digit7 = 26;
1109
+ const Digit8 = 27;
1110
+ const Digit9 = 28;
1111
+ const KeyA = 29;
1112
+ const KeyB = 30;
1113
+ const KeyC = 31;
1114
+ const KeyD = 32;
1115
+ const KeyE = 33;
1116
+ const KeyF = 34;
1117
+ const KeyG = 35;
1118
+ const KeyH = 36;
1119
+ const KeyI = 37;
1120
+ const KeyJ = 38;
1121
+ const KeyK = 39;
1122
+ const KeyL = 40;
1123
+ const KeyM = 41;
1124
+ const KeyN = 42;
1125
+ const KeyO = 43;
1126
+ const KeyP = 44;
1127
+ const KeyQ = 45;
1128
+ const KeyR = 46;
1129
+ const KeyS = 47;
1130
+ const KeyT = 48;
1131
+ const KeyU = 49;
1132
+ const KeyV = 50;
1133
+ const KeyW = 51;
1134
+ const KeyX = 52;
1135
+ const KeyY = 53;
1136
+ const KeyZ = 54;
1137
+ const F1 = 57;
1138
+ const F2 = 58;
1139
+ const F3 = 59;
1140
+ const F4 = 60;
1141
+ const F5 = 61;
1142
+ const F6 = 62;
1143
+ const F7 = 63;
1144
+ const F8 = 64;
1145
+ const F9 = 65;
1146
+ const F10 = 66;
1147
+ const F11 = 67;
1148
+ const F12 = 68;
1149
+ const F13 = 69;
1150
+ const F14 = 70;
1151
+ const F15 = 71;
1152
+ const F16 = 72;
1153
+ const F17 = 72;
1154
+ const F18 = 74;
1155
+ const F19 = 75;
1156
+ const F20 = 76;
1157
+ const F21 = 77;
1158
+ const F22 = 78;
1159
+ const F23 = 79;
1160
+ const F24 = 80;
1161
+ const SemiColon = 83;
1162
+ const Equal = 84;
1163
+ const Comma = 85;
1164
+ const Minus = 86;
1165
+ const Period = 87;
1166
+ const Slash = 88;
1167
+ const Backquote = 89;
1168
+ const BracketLeft = 90;
1169
+ const Backslash = 91;
1170
+ const BracketRight = 92;
1171
+ const Quote = 93;
1172
+ const Star = 131;
1173
+ const Plus = 132;
1046
1174
 
1047
- const attachedListeners = new WeakMap();
1048
- const getOptions = fn => {
1049
- if (fn.passive) {
1050
- return {
1051
- passive: true
1052
- };
1053
- }
1054
- if (fn.capture) {
1175
+ const keyCodeMap$1 = {
1176
+ [Backquote$1]: Backquote,
1177
+ [Backquote2]: Backquote,
1178
+ [Backslash$1]: Backslash,
1179
+ [Backspace$1]: Backspace,
1180
+ [BracketLeft$1]: BracketLeft,
1181
+ [BracketRight$1]: BracketRight,
1182
+ [Comma$1]: Comma,
1183
+ [Delete$1]: Delete,
1184
+ [Digit0$1]: Digit0,
1185
+ [Digit1$1]: Digit1,
1186
+ [Digit2$1]: Digit2,
1187
+ [Digit3$1]: Digit3,
1188
+ [Digit4$1]: Digit4,
1189
+ [Digit5$1]: Digit5,
1190
+ [Digit6$1]: Digit6,
1191
+ [Digit7$1]: Digit7,
1192
+ [Digit8$1]: Digit8,
1193
+ [Digit9$1]: Digit9,
1194
+ [DownArrow$1]: DownArrow,
1195
+ [End$1]: End,
1196
+ [Enter$1]: Enter,
1197
+ [Equal$1]: Equal,
1198
+ [Escape$1]: Escape,
1199
+ [F1$1]: F1,
1200
+ [F10$1]: F10,
1201
+ [F11$1]: F11,
1202
+ [F12$1]: F12,
1203
+ [F13$1]: F13,
1204
+ [F14$1]: F14,
1205
+ [F15$1]: F15,
1206
+ [F16$1]: F16,
1207
+ [F17$1]: F17,
1208
+ [F18$1]: F18,
1209
+ [F19$1]: F19,
1210
+ [F2$1]: F2,
1211
+ [F20$1]: F20,
1212
+ [F21$1]: F21,
1213
+ [F22$1]: F22,
1214
+ [F23$1]: F23,
1215
+ [F24$1]: F24,
1216
+ [F3$1]: F3,
1217
+ [F4$1]: F4,
1218
+ [F5$1]: F5,
1219
+ [F6$1]: F6,
1220
+ [F7$1]: F7,
1221
+ [F8$1]: F8,
1222
+ [F9$1]: F9,
1223
+ [Home$1]: Home,
1224
+ [Insert$1]: Insert,
1225
+ [KeyA$1]: KeyA,
1226
+ [KeyB$1]: KeyB,
1227
+ [KeyC$1]: KeyC,
1228
+ [KeyD$1]: KeyD,
1229
+ [KeyE$1]: KeyE,
1230
+ [KeyF$1]: KeyF,
1231
+ [KeyG$1]: KeyG,
1232
+ [KeyH$1]: KeyH,
1233
+ [KeyI$1]: KeyI,
1234
+ [KeyJ$1]: KeyJ,
1235
+ [KeyK$1]: KeyK,
1236
+ [KeyL$1]: KeyL,
1237
+ [KeyM$1]: KeyM,
1238
+ [KeyN$1]: KeyN,
1239
+ [KeyO$1]: KeyO,
1240
+ [KeyP$1]: KeyP,
1241
+ [KeyQ$1]: KeyQ,
1242
+ [KeyR$1]: KeyR,
1243
+ [KeyS$1]: KeyS,
1244
+ [KeyT$1]: KeyT,
1245
+ [KeyU$1]: KeyU,
1246
+ [KeyV$1]: KeyV,
1247
+ [KeyW$1]: KeyW,
1248
+ [KeyX$1]: KeyX,
1249
+ [KeyY$1]: KeyY,
1250
+ [KeyZ$1]: KeyZ,
1251
+ [LeftArrow$1]: LeftArrow,
1252
+ [Minus$1]: Minus,
1253
+ [PageDown$1]: PageDown,
1254
+ [PageUp$1]: PageUp,
1255
+ [Period$1]: Period,
1256
+ [Plus$1]: Plus,
1257
+ [Quote$1]: Quote,
1258
+ [RightArrow$1]: RightArrow,
1259
+ [SemiColon$1]: SemiColon,
1260
+ [Slash$1]: Slash,
1261
+ [Space$1]: Space,
1262
+ [Space2]: Space,
1263
+ [Star$1]: Star,
1264
+ [Tab$1]: Tab,
1265
+ [UpArrow$1]: UpArrow
1266
+ };
1267
+ const getKeyCode = key => {
1268
+ return keyCodeMap$1[key] || Unknown;
1269
+ };
1270
+
1271
+ const CtrlCmd = 1 << 11 >>> 0;
1272
+ const Shift = 1 << 10 >>> 0;
1273
+ const Alt = 1 << 9 >>> 0;
1274
+
1275
+ const {
1276
+ getElementTag
1277
+ } = ElementTagMap;
1278
+
1279
+ const instances = Object.create(null);
1280
+ const get$8 = viewletId => {
1281
+ return instances[viewletId];
1282
+ };
1283
+ const set$a = (viewletId, instance) => {
1284
+ instances[viewletId] = instance;
1285
+ };
1286
+
1287
+ const getEventListenerOptions = (eventName, value) => {
1288
+ if (value.passive) {
1289
+ return {
1290
+ passive: true
1291
+ };
1292
+ }
1293
+ if (value.capture) {
1294
+ return {
1295
+ capture: true
1296
+ };
1297
+ }
1298
+ switch (eventName) {
1299
+ case 'wheel':
1300
+ return {
1301
+ passive: true
1302
+ };
1303
+ default:
1304
+ return undefined;
1305
+ }
1306
+ };
1307
+
1308
+ const cache = new Map();
1309
+ const has$1 = listener => {
1310
+ return cache.has(listener);
1311
+ };
1312
+ const set$9 = (listener, value) => {
1313
+ cache.set(listener, value);
1314
+ };
1315
+ const get$7 = listener => {
1316
+ return cache.get(listener);
1317
+ };
1318
+
1319
+ const getWrappedListener = (listener, returnValue) => {
1320
+ if (!returnValue) {
1321
+ return listener;
1322
+ }
1323
+ if (!has$1(listener)) {
1324
+ const wrapped = event => {
1325
+ const uid = getComponentUidFromEvent(event);
1326
+ const result = listener(event);
1327
+ // TODO check for empty array by value
1328
+ if (result.length === 0) {
1329
+ return;
1330
+ }
1331
+ const ipc = getIpc();
1332
+ ipc.send('Viewlet.executeViewletCommand', uid, ...result);
1333
+ };
1334
+ nameAnonymousFunction$1(wrapped, listener.name);
1335
+ set$9(listener, wrapped);
1336
+ }
1337
+ return get$7(listener);
1338
+ };
1339
+
1340
+ const attachedListeners = new WeakMap();
1341
+ const getOptions = fn => {
1342
+ if (fn.passive) {
1343
+ return {
1344
+ passive: true
1345
+ };
1346
+ }
1347
+ if (fn.capture) {
1055
1348
  return {
1056
1349
  capture: true
1057
1350
  };
@@ -4641,7 +4934,7 @@ const ConditionValues = {
4641
4934
  toHaveText: toHaveText$1
4642
4935
  };
4643
4936
 
4644
- const keyCodeMap$1 = {
4937
+ const keyCodeMap = {
4645
4938
  ' ': {
4646
4939
  code: 'Space',
4647
4940
  keyCode: 32
@@ -4668,8 +4961,8 @@ const keyCodeMap$1 = {
4668
4961
  const getKeyboardOptions = options => {
4669
4962
  const key = options.key || '';
4670
4963
  const normalizedKey = key === 'Space' ? ' ' : key;
4671
- if (keyCodeMap$1[key]) {
4672
- const mapped = keyCodeMap$1[key];
4964
+ if (keyCodeMap[key]) {
4965
+ const mapped = keyCodeMap[key];
4673
4966
  const keyCode = mapped.keyCode;
4674
4967
  return {
4675
4968
  ...options,
@@ -6869,401 +7162,120 @@ const focus$8 = state => {
6869
7162
 
6870
7163
  const ViewletImplementations = {
6871
7164
  __proto__: null,
6872
- Events: ViewletLocationsEvents,
6873
- focus: focus$8,
6874
- handleError: handleError$3,
6875
- setFocusedIndex: setFocusedIndex$1
6876
- };
6877
-
6878
- const handleScrollBarPointerDown = event => {
6879
- // TODO
6880
- };
6881
-
6882
- const ViewletInlineDiffEditorEvents = {
6883
- __proto__: null,
6884
- handleScrollBarPointerDown,
6885
- handleWheel: handleWheel$2
6886
- };
6887
-
6888
- const ViewletInlineDiffEditor = {
6889
- __proto__: null,
6890
- Events: ViewletInlineDiffEditorEvents,
6891
- setScrollBar
6892
- };
6893
-
6894
- const handleResizerPointerMove = event => {
6895
- const {
6896
- clientX
6897
- } = event;
6898
- const uid = fromEvent(event);
6899
- handleResizerMove(uid, clientX);
6900
- };
6901
-
6902
- // TODO use lostpointercapture event instead
6903
- const handleResizerPointerUp = event => {
6904
- const {
6905
- pointerId,
6906
- target
6907
- } = event;
6908
- stopTracking(target, pointerId, handleResizerPointerMove, handleResizerPointerUp);
6909
- };
6910
- const handleResizerPointerDown = event => {
6911
- const {
6912
- clientX,
6913
- pointerId,
6914
- target
6915
- } = event;
6916
- startTracking(target, pointerId, handleResizerPointerMove, handleResizerPointerUp);
6917
- const id = target.nextSibling ? 1 : 2;
6918
- const uid = fromEvent(event);
6919
- handleResizerClick(uid, id, clientX);
6920
- };
6921
- const getPointerDownFunction = event => {
6922
- const {
6923
- target
6924
- } = event;
6925
- switch (target.className) {
6926
- case 'Resizer':
6927
- return handleResizerPointerDown;
6928
- default:
6929
- return undefined;
6930
- }
6931
- };
6932
- const handlePointerDown = event => {
6933
- const pointerDownFunction = getPointerDownFunction(event);
6934
- if (!pointerDownFunction) {
6935
- return;
6936
- }
6937
- pointerDownFunction(event);
6938
- };
6939
-
6940
- const ViewletkeyBindingsEvents = {
6941
- __proto__: null,
6942
- handlePointerDown,
6943
- handleResizerPointerDown,
6944
- handleResizerPointerMove,
6945
- handleResizerPointerUp
6946
- };
6947
-
6948
- const setValue = (state, value) => {
6949
- const {
6950
- $Viewlet
6951
- } = state;
6952
- const $InputBox = $Viewlet.querySelector(':scope input');
6953
- $InputBox.value = value;
6954
- };
6955
- const setColumnWidths = (state, columnWidth1, columnWidth2, columnWidth3) => {
6956
- const paddingLeft = 15;
6957
- const {
6958
- $Viewlet
6959
- } = state;
6960
- const $$Resizers = $Viewlet.querySelectorAll(':scope .Resizer');
6961
- const $Resizer1 = $$Resizers[0];
6962
- const $Resizer2 = $$Resizers[1];
6963
- $Resizer1.style.left = `${paddingLeft + columnWidth1}px`;
6964
- $Resizer2.style.left = `${paddingLeft + columnWidth1 + columnWidth2}px`;
6965
- };
6966
- const Events$3 = ViewletkeyBindingsEvents;
6967
-
6968
- const ViewletKeyBindings = {
6969
- __proto__: null,
6970
- Events: Events$3,
6971
- setColumnWidths,
6972
- setScrollBar,
6973
- setSize,
6974
- setValue
6975
- };
6976
-
6977
- const getSashId = $Target => {
6978
- if ($Target.id === 'SashPanel') {
6979
- return 'Panel';
6980
- }
6981
- if ($Target.id === 'SashSideBar') {
6982
- return 'SideBar';
6983
- }
6984
- return '';
6985
- };
6986
-
6987
- const Backspace$1 = 'Backspace';
6988
- const Tab$1 = 'Tab';
6989
- const Space$1 = ' ';
6990
- const Space2 = 'Space';
6991
- const Enter$1 = 'Enter';
6992
- const Escape$1 = 'Escape';
6993
- const PageUp$1 = 'PageUp';
6994
- const PageDown$1 = 'PageDown';
6995
- const Home$1 = 'Home';
6996
- const End$1 = 'End';
6997
- const LeftArrow$1 = 'ArrowLeft';
6998
- const RightArrow$1 = 'ArrowRight';
6999
- const UpArrow$1 = 'ArrowUp';
7000
- const DownArrow$1 = 'ArrowDown';
7001
- const Insert$1 = 'Insert';
7002
- const Delete$1 = 'Delete';
7003
- const Digit0$1 = '0';
7004
- const Digit1$1 = '1';
7005
- const Digit2$1 = '2';
7006
- const Digit3$1 = '3';
7007
- const Digit4$1 = '4';
7008
- const Digit5$1 = '5';
7009
- const Digit6$1 = '6';
7010
- const Digit7$1 = '7';
7011
- const Digit8$1 = '8';
7012
- const Digit9$1 = '9';
7013
- const KeyA$1 = 'a';
7014
- const KeyB$1 = 'b';
7015
- const KeyC$1 = 'c';
7016
- const KeyD$1 = 'd';
7017
- const KeyE$1 = 'e';
7018
- const KeyF$1 = 'f';
7019
- const KeyG$1 = 'g';
7020
- const KeyH$1 = 'h';
7021
- const KeyI$1 = 'i';
7022
- const KeyJ$1 = 'j';
7023
- const KeyK$1 = 'k';
7024
- const KeyL$1 = 'l';
7025
- const KeyM$1 = 'm';
7026
- const KeyN$1 = 'n';
7027
- const KeyO$1 = 'o';
7028
- const KeyP$1 = 'p';
7029
- const KeyQ$1 = 'q';
7030
- const KeyR$1 = 'r';
7031
- const KeyS$1 = 's';
7032
- const KeyT$1 = 't';
7033
- const KeyU$1 = 'u';
7034
- const KeyV$1 = 'v';
7035
- const KeyW$1 = 'w';
7036
- const KeyX$1 = 'x';
7037
- const KeyY$1 = 'y';
7038
- const KeyZ$1 = 'z';
7039
- const F1$1 = 'F1';
7040
- const F2$1 = 'F2';
7041
- const F3$1 = 'F3';
7042
- const F4$1 = 'F4';
7043
- const F5$1 = 'F5';
7044
- const F6$1 = 'F6';
7045
- const F7$1 = 'F7';
7046
- const F8$1 = 'F8';
7047
- const F9$1 = 'F9';
7048
- const F10$1 = 'F10';
7049
- const F11$1 = 'F11';
7050
- const F12$1 = 'F12';
7051
- const F13$1 = 'F13';
7052
- const F14$1 = 'F14';
7053
- const F15$1 = 'F15';
7054
- const F16$1 = 'F16';
7055
- const F17$1 = 'F17';
7056
- const F18$1 = 'F18';
7057
- const F19$1 = 'F19';
7058
- const F20$1 = 'F20';
7059
- const F21$1 = 'F21';
7060
- const F22$1 = 'F22';
7061
- const F23$1 = 'F23';
7062
- const F24$1 = 'F24';
7063
- const SemiColon$1 = ';';
7064
- const Equal$1 = '=';
7065
- const Comma$1 = ',';
7066
- const Minus$1 = '-';
7067
- const Period$1 = '.';
7068
- const Slash$1 = '/';
7069
- const Backquote$1 = '`';
7070
- const Backquote2 = 'Backquote';
7071
- const BracketLeft$1 = '[';
7072
- const Backslash$1 = '\\';
7073
- const BracketRight$1 = ']';
7074
- const Quote$1 = `'`;
7075
- const Star$1 = '*';
7076
- const Plus$1 = '+';
7077
-
7078
- const Unknown = 0;
7079
- const Backspace = 1;
7080
- const Tab = 2;
7081
- const Enter = 3;
7082
- const Escape = 8;
7083
- const Space = 9;
7084
- const PageUp = 10;
7085
- const PageDown = 11;
7086
- const End = 255;
7087
- const Home = 12;
7088
- const LeftArrow = 13;
7089
- const UpArrow = 14;
7090
- const RightArrow = 15;
7091
- const DownArrow = 16;
7092
- const Insert = 17;
7093
- const Delete = 18;
7094
- const Digit0 = 19;
7095
- const Digit1 = 20;
7096
- const Digit2 = 21;
7097
- const Digit3 = 22;
7098
- const Digit4 = 23;
7099
- const Digit5 = 24;
7100
- const Digit6 = 25;
7101
- const Digit7 = 26;
7102
- const Digit8 = 27;
7103
- const Digit9 = 28;
7104
- const KeyA = 29;
7105
- const KeyB = 30;
7106
- const KeyC = 31;
7107
- const KeyD = 32;
7108
- const KeyE = 33;
7109
- const KeyF = 34;
7110
- const KeyG = 35;
7111
- const KeyH = 36;
7112
- const KeyI = 37;
7113
- const KeyJ = 38;
7114
- const KeyK = 39;
7115
- const KeyL = 40;
7116
- const KeyM = 41;
7117
- const KeyN = 42;
7118
- const KeyO = 43;
7119
- const KeyP = 44;
7120
- const KeyQ = 45;
7121
- const KeyR = 46;
7122
- const KeyS = 47;
7123
- const KeyT = 48;
7124
- const KeyU = 49;
7125
- const KeyV = 50;
7126
- const KeyW = 51;
7127
- const KeyX = 52;
7128
- const KeyY = 53;
7129
- const KeyZ = 54;
7130
- const F1 = 57;
7131
- const F2 = 58;
7132
- const F3 = 59;
7133
- const F4 = 60;
7134
- const F5 = 61;
7135
- const F6 = 62;
7136
- const F7 = 63;
7137
- const F8 = 64;
7138
- const F9 = 65;
7139
- const F10 = 66;
7140
- const F11 = 67;
7141
- const F12 = 68;
7142
- const F13 = 69;
7143
- const F14 = 70;
7144
- const F15 = 71;
7145
- const F16 = 72;
7146
- const F17 = 72;
7147
- const F18 = 74;
7148
- const F19 = 75;
7149
- const F20 = 76;
7150
- const F21 = 77;
7151
- const F22 = 78;
7152
- const F23 = 79;
7153
- const F24 = 80;
7154
- const SemiColon = 83;
7155
- const Equal = 84;
7156
- const Comma = 85;
7157
- const Minus = 86;
7158
- const Period = 87;
7159
- const Slash = 88;
7160
- const Backquote = 89;
7161
- const BracketLeft = 90;
7162
- const Backslash = 91;
7163
- const BracketRight = 92;
7164
- const Quote = 93;
7165
- const Star = 131;
7166
- const Plus = 132;
7165
+ Events: ViewletLocationsEvents,
7166
+ focus: focus$8,
7167
+ handleError: handleError$3,
7168
+ setFocusedIndex: setFocusedIndex$1
7169
+ };
7167
7170
 
7168
- const keyCodeMap = {
7169
- [Backquote$1]: Backquote,
7170
- [Backquote2]: Backquote,
7171
- [Backslash$1]: Backslash,
7172
- [Backspace$1]: Backspace,
7173
- [BracketLeft$1]: BracketLeft,
7174
- [BracketRight$1]: BracketRight,
7175
- [Comma$1]: Comma,
7176
- [Delete$1]: Delete,
7177
- [Digit0$1]: Digit0,
7178
- [Digit1$1]: Digit1,
7179
- [Digit2$1]: Digit2,
7180
- [Digit3$1]: Digit3,
7181
- [Digit4$1]: Digit4,
7182
- [Digit5$1]: Digit5,
7183
- [Digit6$1]: Digit6,
7184
- [Digit7$1]: Digit7,
7185
- [Digit8$1]: Digit8,
7186
- [Digit9$1]: Digit9,
7187
- [DownArrow$1]: DownArrow,
7188
- [End$1]: End,
7189
- [Enter$1]: Enter,
7190
- [Equal$1]: Equal,
7191
- [Escape$1]: Escape,
7192
- [F1$1]: F1,
7193
- [F10$1]: F10,
7194
- [F11$1]: F11,
7195
- [F12$1]: F12,
7196
- [F13$1]: F13,
7197
- [F14$1]: F14,
7198
- [F15$1]: F15,
7199
- [F16$1]: F16,
7200
- [F17$1]: F17,
7201
- [F18$1]: F18,
7202
- [F19$1]: F19,
7203
- [F2$1]: F2,
7204
- [F20$1]: F20,
7205
- [F21$1]: F21,
7206
- [F22$1]: F22,
7207
- [F23$1]: F23,
7208
- [F24$1]: F24,
7209
- [F3$1]: F3,
7210
- [F4$1]: F4,
7211
- [F5$1]: F5,
7212
- [F6$1]: F6,
7213
- [F7$1]: F7,
7214
- [F8$1]: F8,
7215
- [F9$1]: F9,
7216
- [Home$1]: Home,
7217
- [Insert$1]: Insert,
7218
- [KeyA$1]: KeyA,
7219
- [KeyB$1]: KeyB,
7220
- [KeyC$1]: KeyC,
7221
- [KeyD$1]: KeyD,
7222
- [KeyE$1]: KeyE,
7223
- [KeyF$1]: KeyF,
7224
- [KeyG$1]: KeyG,
7225
- [KeyH$1]: KeyH,
7226
- [KeyI$1]: KeyI,
7227
- [KeyJ$1]: KeyJ,
7228
- [KeyK$1]: KeyK,
7229
- [KeyL$1]: KeyL,
7230
- [KeyM$1]: KeyM,
7231
- [KeyN$1]: KeyN,
7232
- [KeyO$1]: KeyO,
7233
- [KeyP$1]: KeyP,
7234
- [KeyQ$1]: KeyQ,
7235
- [KeyR$1]: KeyR,
7236
- [KeyS$1]: KeyS,
7237
- [KeyT$1]: KeyT,
7238
- [KeyU$1]: KeyU,
7239
- [KeyV$1]: KeyV,
7240
- [KeyW$1]: KeyW,
7241
- [KeyX$1]: KeyX,
7242
- [KeyY$1]: KeyY,
7243
- [KeyZ$1]: KeyZ,
7244
- [LeftArrow$1]: LeftArrow,
7245
- [Minus$1]: Minus,
7246
- [PageDown$1]: PageDown,
7247
- [PageUp$1]: PageUp,
7248
- [Period$1]: Period,
7249
- [Plus$1]: Plus,
7250
- [Quote$1]: Quote,
7251
- [RightArrow$1]: RightArrow,
7252
- [SemiColon$1]: SemiColon,
7253
- [Slash$1]: Slash,
7254
- [Space$1]: Space,
7255
- [Space2]: Space,
7256
- [Star$1]: Star,
7257
- [Tab$1]: Tab,
7258
- [UpArrow$1]: UpArrow
7171
+ const handleScrollBarPointerDown = event => {
7172
+ // TODO
7259
7173
  };
7260
- const getKeyCode = key => {
7261
- return keyCodeMap[key] || Unknown;
7174
+
7175
+ const ViewletInlineDiffEditorEvents = {
7176
+ __proto__: null,
7177
+ handleScrollBarPointerDown,
7178
+ handleWheel: handleWheel$2
7262
7179
  };
7263
7180
 
7264
- const CtrlCmd = 1 << 11 >>> 0;
7265
- const Shift = 1 << 10 >>> 0;
7266
- const Alt = 1 << 9 >>> 0;
7181
+ const ViewletInlineDiffEditor = {
7182
+ __proto__: null,
7183
+ Events: ViewletInlineDiffEditorEvents,
7184
+ setScrollBar
7185
+ };
7186
+
7187
+ const handleResizerPointerMove = event => {
7188
+ const {
7189
+ clientX
7190
+ } = event;
7191
+ const uid = fromEvent(event);
7192
+ handleResizerMove(uid, clientX);
7193
+ };
7194
+
7195
+ // TODO use lostpointercapture event instead
7196
+ const handleResizerPointerUp = event => {
7197
+ const {
7198
+ pointerId,
7199
+ target
7200
+ } = event;
7201
+ stopTracking(target, pointerId, handleResizerPointerMove, handleResizerPointerUp);
7202
+ };
7203
+ const handleResizerPointerDown = event => {
7204
+ const {
7205
+ clientX,
7206
+ pointerId,
7207
+ target
7208
+ } = event;
7209
+ startTracking(target, pointerId, handleResizerPointerMove, handleResizerPointerUp);
7210
+ const id = target.nextSibling ? 1 : 2;
7211
+ const uid = fromEvent(event);
7212
+ handleResizerClick(uid, id, clientX);
7213
+ };
7214
+ const getPointerDownFunction = event => {
7215
+ const {
7216
+ target
7217
+ } = event;
7218
+ switch (target.className) {
7219
+ case 'Resizer':
7220
+ return handleResizerPointerDown;
7221
+ default:
7222
+ return undefined;
7223
+ }
7224
+ };
7225
+ const handlePointerDown = event => {
7226
+ const pointerDownFunction = getPointerDownFunction(event);
7227
+ if (!pointerDownFunction) {
7228
+ return;
7229
+ }
7230
+ pointerDownFunction(event);
7231
+ };
7232
+
7233
+ const ViewletkeyBindingsEvents = {
7234
+ __proto__: null,
7235
+ handlePointerDown,
7236
+ handleResizerPointerDown,
7237
+ handleResizerPointerMove,
7238
+ handleResizerPointerUp
7239
+ };
7240
+
7241
+ const setValue = (state, value) => {
7242
+ const {
7243
+ $Viewlet
7244
+ } = state;
7245
+ const $InputBox = $Viewlet.querySelector(':scope input');
7246
+ $InputBox.value = value;
7247
+ };
7248
+ const setColumnWidths = (state, columnWidth1, columnWidth2, columnWidth3) => {
7249
+ const paddingLeft = 15;
7250
+ const {
7251
+ $Viewlet
7252
+ } = state;
7253
+ const $$Resizers = $Viewlet.querySelectorAll(':scope .Resizer');
7254
+ const $Resizer1 = $$Resizers[0];
7255
+ const $Resizer2 = $$Resizers[1];
7256
+ $Resizer1.style.left = `${paddingLeft + columnWidth1}px`;
7257
+ $Resizer2.style.left = `${paddingLeft + columnWidth1 + columnWidth2}px`;
7258
+ };
7259
+ const Events$3 = ViewletkeyBindingsEvents;
7260
+
7261
+ const ViewletKeyBindings = {
7262
+ __proto__: null,
7263
+ Events: Events$3,
7264
+ setColumnWidths,
7265
+ setScrollBar,
7266
+ setSize,
7267
+ setValue
7268
+ };
7269
+
7270
+ const getSashId = $Target => {
7271
+ if ($Target.id === 'SashPanel') {
7272
+ return 'Panel';
7273
+ }
7274
+ if ($Target.id === 'SashSideBar') {
7275
+ return 'SideBar';
7276
+ }
7277
+ return '';
7278
+ };
7267
7279
 
7268
7280
  const normalizeKey = (key, code) => {
7269
7281
  if (key.length === 1) {
@@ -9561,6 +9573,159 @@ const dispose$2 = uid => {
9561
9573
  remove(uid);
9562
9574
  };
9563
9575
 
9576
+ const pcs = Object.create(null);
9577
+ const isAudioElement = element => {
9578
+ return element instanceof HTMLAudioElement;
9579
+ };
9580
+ const queryAudio = (uid, elementLocator) => {
9581
+ if (uid === -1) {
9582
+ const remoteAudio = document.querySelector(elementLocator);
9583
+ if (!isAudioElement(remoteAudio)) {
9584
+ console.error(`[webrtc] audio element not found`);
9585
+ }
9586
+ // @ts-ignore
9587
+ return remoteAudio;
9588
+ }
9589
+ const $Viewlet = get$8(uid);
9590
+ const remoteAudio = $Viewlet.querySelector(elementLocator);
9591
+ if (!remoteAudio) {
9592
+ console.error('[webrtc] audio element not found');
9593
+ return;
9594
+ }
9595
+ return remoteAudio;
9596
+ };
9597
+ const setupLevelMeter = (audioCtx, stream, kind) => {
9598
+ const source = audioCtx.createMediaStreamSource(stream);
9599
+ const analyser = audioCtx.createAnalyser();
9600
+ // TODO make variables confirguable
9601
+ analyser.fftSize = 512;
9602
+ analyser.smoothingTimeConstant = 0.6;
9603
+ source.connect(analyser);
9604
+ return analyser;
9605
+ };
9606
+ const startWebRtcAudioStream = async options => {
9607
+ const {
9608
+ elementLocator,
9609
+ port,
9610
+ trackAudioData,
9611
+ uid
9612
+ } = options;
9613
+
9614
+ // 2. Set up the WebRTC peer connection.
9615
+ const pc = new RTCPeerConnection();
9616
+ const remoteAudio = queryAudio(uid, elementLocator);
9617
+ if (!remoteAudio) {
9618
+ console.error('[webrtc] audio element not found');
9619
+ return;
9620
+ }
9621
+ let audioCtx;
9622
+ let micAnalyzer;
9623
+ let remoteAnalyzer;
9624
+ if (trackAudioData) {
9625
+ // @ts-ignore
9626
+ audioCtx = new (window.AudioContext || window.webkitAudioContext)();
9627
+ }
9628
+ remoteAudio.autoplay = true;
9629
+ pc.ontrack = e => {
9630
+ remoteAudio.srcObject = e.streams[0];
9631
+ if (trackAudioData && audioCtx) {
9632
+ remoteAnalyzer = setupLevelMeter(audioCtx, e.streams[0]);
9633
+ }
9634
+ };
9635
+ const micStream = await navigator.mediaDevices.getUserMedia({
9636
+ audio: true
9637
+ });
9638
+ if (trackAudioData && audioCtx) {
9639
+ micAnalyzer = setupLevelMeter(audioCtx, micStream);
9640
+ }
9641
+ pc.addTrack(micStream.getTracks()[0]);
9642
+ const dc = pc.createDataChannel('oai-events');
9643
+ dc.addEventListener('message', e => {
9644
+ port.postMessage(e.data);
9645
+ });
9646
+
9647
+ // 3. Standard WebRTC offer/answer handshake against the Realtime API.
9648
+ const offer = await pc.createOffer();
9649
+ await pc.setLocalDescription(offer);
9650
+ pcs[uid] = {
9651
+ connection: pc,
9652
+ micAnalyzer,
9653
+ micStream,
9654
+ port,
9655
+ remoteAnalyzer
9656
+ };
9657
+ return offer.sdp;
9658
+ };
9659
+ const setRemoteDescription = async options => {
9660
+ const {
9661
+ sdp,
9662
+ type,
9663
+ uid
9664
+ } = options;
9665
+ const pc = pcs[uid];
9666
+ if (!pc) {
9667
+ throw new Error(`[webrtc] pc not found`);
9668
+ }
9669
+ const {
9670
+ connection
9671
+ } = pc;
9672
+ await connection.setRemoteDescription({
9673
+ sdp,
9674
+ type
9675
+ });
9676
+ };
9677
+ const stopWebRtcAudioStream = async options => {
9678
+ const {
9679
+ uid
9680
+ } = options;
9681
+ const pc = pcs[uid];
9682
+ if (!pc) {
9683
+ return;
9684
+ }
9685
+ // TODO use disposableMap maybe?
9686
+ const {
9687
+ connection,
9688
+ micStream,
9689
+ port
9690
+ } = pc;
9691
+ delete pcs[uid];
9692
+ connection.close();
9693
+ for (const t of micStream.getTracks()) {
9694
+ t.stop();
9695
+ }
9696
+ port.close();
9697
+ };
9698
+ const readMicLevels = options => {
9699
+ const {
9700
+ uid
9701
+ } = options;
9702
+ const pc = pcs[uid];
9703
+ if (!pc) {
9704
+ return {
9705
+ micAnalyzerData: new Uint8Array(),
9706
+ remoteAnalyzerData: new Uint8Array()
9707
+ };
9708
+ }
9709
+ const {
9710
+ micAnalyzer,
9711
+ remoteAnalyzer
9712
+ } = pc;
9713
+ let micAnalyzerData = new Uint8Array();
9714
+ if (micAnalyzer) {
9715
+ micAnalyzerData = new Uint8Array(micAnalyzer.frequencyBinCount);
9716
+ micAnalyzer.getByteTimeDomainData(micAnalyzerData);
9717
+ }
9718
+ let remoteAnalyzerData = new Uint8Array();
9719
+ if (remoteAnalyzer) {
9720
+ remoteAnalyzerData = new Uint8Array(remoteAnalyzer.frequencyBinCount);
9721
+ remoteAnalyzer.getByteTimeDomainData(remoteAnalyzerData);
9722
+ }
9723
+ return {
9724
+ micAnalyzerData,
9725
+ remoteAnalyzerData
9726
+ };
9727
+ };
9728
+
9564
9729
  const commandMap = {
9565
9730
  'Audio.play': play,
9566
9731
  'ClipBoard.execCopy': execCopy,
@@ -9642,6 +9807,10 @@ const commandMap = {
9642
9807
  'Viewlet.sendMultiple': sendMultiple,
9643
9808
  'Viewlet.setBounds': setBounds$1,
9644
9809
  'Viewlet.show': show,
9810
+ 'WebRtc.readMicLevels': readMicLevels,
9811
+ 'WebRtc.setRemoteDescription': setRemoteDescription,
9812
+ 'WebRtc.startWebRtcAudioStream': startWebRtcAudioStream,
9813
+ 'WebRtc.stopWebRtcAudioStream': stopWebRtcAudioStream,
9645
9814
  'WebStorage.clear': clear,
9646
9815
  'WebStorage.getItem': getItem,
9647
9816
  'WebStorage.setItem': setItem,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "30.25.2",
3
+ "version": "30.27.0",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "renderer-process"