@lvce-editor/file-watcher-process 4.6.2 → 4.6.3

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.
Files changed (2) hide show
  1. package/dist/index.js +88 -88
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -7,79 +7,6 @@ const handleUncaughtExceptionMonitor = error => {
7
7
  console.error(`[file-watcher-process] Uncaught Exception: ${error}`);
8
8
  };
9
9
 
10
- class AssertionError extends Error {
11
- constructor(message) {
12
- super(message);
13
- this.name = 'AssertionError';
14
- }
15
- }
16
- const Object$1 = 1;
17
- const Number = 2;
18
- const Array$1 = 3;
19
- const String$1 = 4;
20
- const Boolean = 5;
21
- const Function = 6;
22
- const Null = 7;
23
- const Unknown = 8;
24
- const getType = value => {
25
- switch (typeof value) {
26
- case 'number':
27
- return Number;
28
- case 'function':
29
- return Function;
30
- case 'string':
31
- return String$1;
32
- case 'object':
33
- if (value === null) {
34
- return Null;
35
- }
36
- if (Array.isArray(value)) {
37
- return Array$1;
38
- }
39
- return Object$1;
40
- case 'boolean':
41
- return Boolean;
42
- default:
43
- return Unknown;
44
- }
45
- };
46
- const number = value => {
47
- const type = getType(value);
48
- if (type !== Number) {
49
- throw new AssertionError('expected value to be of type number');
50
- }
51
- };
52
- const string = value => {
53
- const type = getType(value);
54
- if (type !== String$1) {
55
- throw new AssertionError('expected value to be of type string');
56
- }
57
- };
58
-
59
- const watchers = Object.create(null);
60
- const add = (id, controller) => {
61
- watchers[id] = controller;
62
- };
63
- const get$2 = id => {
64
- return watchers[id];
65
- };
66
- const has = id => {
67
- return id in watchers;
68
- };
69
- const remove$1 = id => {
70
- delete watchers[id];
71
- };
72
-
73
- const disposeWatcher = id => {
74
- number(id);
75
- if (!has(id)) {
76
- return;
77
- }
78
- const controller = get$2(id);
79
- controller.abort();
80
- remove$1(id);
81
- };
82
-
83
10
  const normalizeLine = line => {
84
11
  if (line.startsWith('Error: ')) {
85
12
  return line.slice('Error: '.length);
@@ -136,6 +63,55 @@ class VError extends Error {
136
63
  }
137
64
  }
138
65
 
66
+ class AssertionError extends Error {
67
+ constructor(message) {
68
+ super(message);
69
+ this.name = 'AssertionError';
70
+ }
71
+ }
72
+ const Object$1 = 1;
73
+ const Number = 2;
74
+ const Array$1 = 3;
75
+ const String$1 = 4;
76
+ const Boolean = 5;
77
+ const Function = 6;
78
+ const Null = 7;
79
+ const Unknown = 8;
80
+ const getType = value => {
81
+ switch (typeof value) {
82
+ case 'number':
83
+ return Number;
84
+ case 'function':
85
+ return Function;
86
+ case 'string':
87
+ return String$1;
88
+ case 'object':
89
+ if (value === null) {
90
+ return Null;
91
+ }
92
+ if (Array.isArray(value)) {
93
+ return Array$1;
94
+ }
95
+ return Object$1;
96
+ case 'boolean':
97
+ return Boolean;
98
+ default:
99
+ return Unknown;
100
+ }
101
+ };
102
+ const number = value => {
103
+ const type = getType(value);
104
+ if (type !== Number) {
105
+ throw new AssertionError('expected value to be of type number');
106
+ }
107
+ };
108
+ const string = value => {
109
+ const type = getType(value);
110
+ if (type !== String$1) {
111
+ throw new AssertionError('expected value to be of type string');
112
+ }
113
+ };
114
+
139
115
  const isMessagePort = value => {
140
116
  return value && value instanceof MessagePort;
141
117
  };
@@ -619,10 +595,10 @@ const execute = (command, ...args) => {
619
595
 
620
596
  const Two$1 = '2.0';
621
597
  const callbacks = Object.create(null);
622
- const get$1 = id => {
598
+ const get$2 = id => {
623
599
  return callbacks[id];
624
600
  };
625
- const remove = id => {
601
+ const remove$1 = id => {
626
602
  delete callbacks[id];
627
603
  };
628
604
  class JsonRpcError extends Error {
@@ -768,14 +744,14 @@ const warn = (...args) => {
768
744
  console.warn(...args);
769
745
  };
770
746
  const resolve = (id, response) => {
771
- const fn = get$1(id);
747
+ const fn = get$2(id);
772
748
  if (!fn) {
773
749
  console.log(response);
774
750
  warn(`callback ${id} may already be disposed`);
775
751
  return;
776
752
  }
777
753
  fn(response);
778
- remove(id);
754
+ remove$1(id);
779
755
  };
780
756
  const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
781
757
  const getErrorType = prettyError => {
@@ -1102,6 +1078,40 @@ const create = async ({
1102
1078
  return rpc;
1103
1079
  };
1104
1080
 
1081
+ const rpcs = Object.create(null);
1082
+ const set = (id, rpc) => {
1083
+ rpcs[id] = rpc;
1084
+ };
1085
+ const get$1 = id => {
1086
+ return rpcs[id];
1087
+ };
1088
+
1089
+ const SharedProcess = 1492;
1090
+
1091
+ const watchers = Object.create(null);
1092
+ const add = (id, controller) => {
1093
+ watchers[id] = controller;
1094
+ };
1095
+ const get = id => {
1096
+ return watchers[id];
1097
+ };
1098
+ const has = id => {
1099
+ return id in watchers;
1100
+ };
1101
+ const remove = id => {
1102
+ delete watchers[id];
1103
+ };
1104
+
1105
+ const disposeWatcher = id => {
1106
+ number(id);
1107
+ if (!has(id)) {
1108
+ return;
1109
+ }
1110
+ const controller = get(id);
1111
+ controller.abort();
1112
+ remove(id);
1113
+ };
1114
+
1105
1115
  const NodeWorker = 1;
1106
1116
  const NodeForkedProcess = 2;
1107
1117
  const ElectronUtilityProcess = 3;
@@ -1148,14 +1158,6 @@ const listen$1 = async ({
1148
1158
  return rpc;
1149
1159
  };
1150
1160
 
1151
- const rpcs = Object.create(null);
1152
- const set = (id, rpc) => {
1153
- rpcs[id] = rpc;
1154
- };
1155
- const get = id => {
1156
- return rpcs[id];
1157
- };
1158
-
1159
1161
  const handleElectronMessagePort = async (messagePort, rpcId) => {
1160
1162
  const rpc = await listen$1({
1161
1163
  messagePort,
@@ -1164,10 +1166,8 @@ const handleElectronMessagePort = async (messagePort, rpcId) => {
1164
1166
  set(rpcId, rpc);
1165
1167
  };
1166
1168
 
1167
- const SharedProcess = 1;
1168
-
1169
1169
  const invoke = async (method, ...params) => {
1170
- const rpc = get(SharedProcess);
1170
+ const rpc = get$1(SharedProcess);
1171
1171
  await rpc.invoke(method, ...params);
1172
1172
  };
1173
1173
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/file-watcher-process",
3
- "version": "4.6.2",
3
+ "version": "4.6.3",
4
4
  "description": "File Watcher Process",
5
5
  "keywords": [
6
6
  "Lvce Editor",