@lvce-editor/completion-worker 1.19.0 → 1.21.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/README.md CHANGED
@@ -1,3 +1,16 @@
1
- # completion-worker
1
+ # Completion Worker
2
2
 
3
- Completion Worker
3
+ > A Web Worker for the completion functionality in Lvce Editor.
4
+
5
+ ## Contributing
6
+
7
+ ```sh
8
+ git clone git@github.com:lvce-editor/completion-worker.git &&
9
+ cd completion-worker &&
10
+ npm ci &&
11
+ npm completion
12
+ ```
13
+
14
+ ## Gitpod
15
+
16
+ [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/lvce-editor/completion-worker)
@@ -60,43 +60,51 @@ class AssertionError extends Error {
60
60
  this.name = 'AssertionError';
61
61
  }
62
62
  }
63
+ const Object$1 = 1;
64
+ const Number$1 = 2;
65
+ const Array$1 = 3;
66
+ const String = 4;
67
+ const Boolean$1 = 5;
68
+ const Function$1 = 6;
69
+ const Null = 7;
70
+ const Unknown = 8;
63
71
  const getType = value => {
64
72
  switch (typeof value) {
65
73
  case 'number':
66
- return 'number';
74
+ return Number$1;
67
75
  case 'function':
68
- return 'function';
76
+ return Function$1;
69
77
  case 'string':
70
- return 'string';
78
+ return String;
71
79
  case 'object':
72
80
  if (value === null) {
73
- return 'null';
81
+ return Null;
74
82
  }
75
83
  if (Array.isArray(value)) {
76
- return 'array';
84
+ return Array$1;
77
85
  }
78
- return 'object';
86
+ return Object$1;
79
87
  case 'boolean':
80
- return 'boolean';
88
+ return Boolean$1;
81
89
  default:
82
- return 'unknown';
90
+ return Unknown;
83
91
  }
84
92
  };
85
93
  const object = value => {
86
94
  const type = getType(value);
87
- if (type !== 'object') {
95
+ if (type !== Object$1) {
88
96
  throw new AssertionError('expected value to be of type object');
89
97
  }
90
98
  };
91
99
  const number = value => {
92
100
  const type = getType(value);
93
- if (type !== 'number') {
101
+ if (type !== Number$1) {
94
102
  throw new AssertionError('expected value to be of type number');
95
103
  }
96
104
  };
97
105
  const string = value => {
98
106
  const type = getType(value);
99
- if (type !== 'string') {
107
+ if (type !== String) {
100
108
  throw new AssertionError('expected value to be of type string');
101
109
  }
102
110
  };
@@ -1001,7 +1009,7 @@ const WebWorkerRpcClient = {
1001
1009
  };
1002
1010
 
1003
1011
  const rpcs = Object.create(null);
1004
- const set$d = (id, rpc) => {
1012
+ const set$g = (id, rpc) => {
1005
1013
  rpcs[id] = rpc;
1006
1014
  };
1007
1015
  const get$1 = id => {
@@ -1025,7 +1033,7 @@ const create$2 = rpcId => {
1025
1033
  return rpc.invokeAndTransfer(method, ...params);
1026
1034
  },
1027
1035
  set(rpc) {
1028
- set$d(rpcId, rpc);
1036
+ set$g(rpcId, rpc);
1029
1037
  },
1030
1038
  async dispose() {
1031
1039
  const rpc = get$1(rpcId);
@@ -1036,31 +1044,28 @@ const create$2 = rpcId => {
1036
1044
  const EditorWorker$1 = 99;
1037
1045
  const ExtensionHostWorker = 44;
1038
1046
  const {
1039
- invoke: invoke$b,
1040
- invokeAndTransfer: invokeAndTransfer$b,
1041
- set: set$b
1042
- } = create$2(EditorWorker$1);
1047
+ invoke: invoke$d,
1048
+ invokeAndTransfer: invokeAndTransfer$c,
1049
+ set: set$c} = create$2(EditorWorker$1);
1043
1050
  const EditorWorker = {
1044
1051
  __proto__: null,
1045
- invoke: invoke$b,
1046
- invokeAndTransfer: invokeAndTransfer$b,
1047
- set: set$b
1052
+ invoke: invoke$d,
1053
+ invokeAndTransfer: invokeAndTransfer$c,
1054
+ set: set$c
1048
1055
  };
1049
1056
  const {
1050
- invoke: invoke$8,
1051
- set: set$8
1052
- } = create$2(ExtensionHostWorker);
1057
+ invoke: invoke$a,
1058
+ set: set$9} = create$2(ExtensionHostWorker);
1053
1059
  const ExtensionHost = {
1054
1060
  __proto__: null,
1055
- invoke: invoke$8,
1056
- set: set$8
1061
+ invoke: invoke$a,
1062
+ set: set$9
1057
1063
  };
1058
1064
 
1059
1065
  const {
1060
1066
  invoke: invoke$1,
1061
1067
  set: set$2,
1062
- invokeAndTransfer
1063
- } = EditorWorker;
1068
+ invokeAndTransfer} = EditorWorker;
1064
1069
 
1065
1070
  const FocusEditorCompletions = 9;
1066
1071
  const FocusEditorRename = 11;
@@ -1293,7 +1298,6 @@ const getSelectionText = (lines, range) => {
1293
1298
  return selectedLines;
1294
1299
  };
1295
1300
 
1296
- // TODO add more exact types
1297
1301
  const replaceRange = (lines, ranges, replacement, origin) => {
1298
1302
  const changes = [];
1299
1303
  const rangesLength = ranges.length;
@@ -1335,8 +1339,7 @@ const activateByEvent = async event => {
1335
1339
 
1336
1340
  const {
1337
1341
  invoke,
1338
- set
1339
- } = ExtensionHost;
1342
+ set} = ExtensionHost;
1340
1343
 
1341
1344
  const execute = async ({
1342
1345
  editorLanguageId,
@@ -1449,8 +1452,37 @@ const End = 255;
1449
1452
  const Home = 12;
1450
1453
  const UpArrow = 14;
1451
1454
  const DownArrow = 16;
1452
-
1455
+ const KeyCode = {
1456
+ __proto__: null,
1457
+ DownArrow,
1458
+ End,
1459
+ Enter,
1460
+ Escape,
1461
+ Home,
1462
+ Space: Space$1,
1463
+ UpArrow
1464
+ };
1453
1465
  const CtrlCmd = 1 << 11 >>> 0;
1466
+ const KeyModifier = {
1467
+ __proto__: null,
1468
+ CtrlCmd};
1469
+ const mergeClassNames = (...classNames) => {
1470
+ return classNames.filter(Boolean).join(' ');
1471
+ };
1472
+ const px = value => {
1473
+ return `${value}px`;
1474
+ };
1475
+ const position = (x, y) => {
1476
+ return `${x}px ${y}px`;
1477
+ };
1478
+ const Text = 12;
1479
+ const text = data => {
1480
+ return {
1481
+ type: Text,
1482
+ text: data,
1483
+ childCount: 0
1484
+ };
1485
+ };
1454
1486
 
1455
1487
  const getCommand = shortId => {
1456
1488
  return {
@@ -1460,31 +1492,31 @@ const getCommand = shortId => {
1460
1492
  };
1461
1493
  const getKeyBindings = () => {
1462
1494
  return [{
1463
- key: DownArrow,
1495
+ key: KeyCode.DownArrow,
1464
1496
  ...getCommand('focusNext'),
1465
1497
  when: FocusEditorCompletions
1466
1498
  }, {
1467
- key: UpArrow,
1499
+ key: KeyCode.UpArrow,
1468
1500
  ...getCommand('focusPrevious'),
1469
1501
  when: FocusEditorCompletions
1470
1502
  }, {
1471
- key: Enter,
1503
+ key: KeyCode.Enter,
1472
1504
  ...getCommand('selectCurrent'),
1473
1505
  when: FocusEditorCompletions
1474
1506
  }, {
1475
- key: End,
1507
+ key: KeyCode.End,
1476
1508
  ...getCommand('focusLast'),
1477
1509
  when: FocusEditorCompletions
1478
1510
  }, {
1479
- key: Home,
1511
+ key: KeyCode.Home,
1480
1512
  ...getCommand('focusFirst'),
1481
1513
  when: FocusEditorCompletions
1482
1514
  }, {
1483
- key: CtrlCmd | Space$1,
1515
+ key: KeyModifier.CtrlCmd | KeyCode.Space,
1484
1516
  ...getCommand('toggleDetails'),
1485
1517
  when: FocusEditorCompletions
1486
1518
  }, {
1487
- key: Escape,
1519
+ key: KeyCode.Escape,
1488
1520
  ...getCommand('close'),
1489
1521
  when: FocusEditorCompletions
1490
1522
  }];
@@ -2066,24 +2098,6 @@ const getIconDom = (fileIcon, symbolName) => {
2066
2098
  };
2067
2099
  };
2068
2100
 
2069
- const mergeClassNames = (...classNames) => {
2070
- return classNames.filter(Boolean).join(' ');
2071
- };
2072
- const Text = 12;
2073
- const text = data => {
2074
- return {
2075
- type: Text,
2076
- text: data,
2077
- childCount: 0
2078
- };
2079
- };
2080
- const px = value => {
2081
- return `${value}px`;
2082
- };
2083
- const position = (x, y) => {
2084
- return `${x}px ${y}px`;
2085
- };
2086
-
2087
2101
  const label1 = {
2088
2102
  type: Div,
2089
2103
  className: Label,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/completion-worker",
3
- "version": "1.19.0",
3
+ "version": "1.21.0",
4
4
  "description": "Web Worker for the find widget in Lvce Editor",
5
5
  "repository": {
6
6
  "type": "git",