@e-mc/watch 0.8.6 → 0.9.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/LICENSE CHANGED
@@ -1,11 +1,11 @@
1
- Copyright 2024 An Pham
2
-
3
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
-
5
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
-
7
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
-
9
- 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
-
1
+ Copyright 2024 An Pham
2
+
3
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
+
5
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
+
7
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
+
9
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
+
11
11
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @e-mc/watch
2
2
 
3
- * NodeJS 14
3
+ * NodeJS 14/16
4
4
  * ES2020
5
5
 
6
6
  ## General Usage
@@ -9,12 +9,12 @@
9
9
 
10
10
  ## Interface
11
11
 
12
- - https://www.unpkg.com/@e-mc/types@0.8.6/lib/index.d.ts
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.9.0/lib/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { IFileManager, ModuleConstructor } from "./index";
16
16
  import type { ExternalAsset } from "./asset";
17
- import type { IClient, IPermission } from "./core";
17
+ import type { HostInitConfig, IClient, IPermission } from "./core";
18
18
  import type { FinalizeResult, PostFinalizeCallback } from "./filemanager";
19
19
  import type { WatchModule } from "./settings";
20
20
  import type { IFileGroup, ModifiedPostFinalizeListener, SecureOptions } from "./watch";
@@ -23,6 +23,7 @@ import type * as ws from "ws";
23
23
 
24
24
  interface IWatch extends IClient<IFileManager, WatchModule, ModifiedPostFinalizeListener> {
25
25
  connectTimeout: number;
26
+ init(config?: HostInitConfig): this;
26
27
  start(assets: ExternalAsset[], permission?: IPermission | null): void;
27
28
  modified(watch: IFileGroup<ExternalAsset>): Promise<FinalizeResult | void>;
28
29
  configureServer(options: SecureOptions): boolean;
@@ -31,7 +32,7 @@ interface IWatch extends IClient<IFileManager, WatchModule, ModifiedPostFinalize
31
32
  setSSLCert(value: string): boolean;
32
33
  hasSecureProtocol(): boolean;
33
34
  whenModified?(assets: ExternalAsset[], postFinalize: PostFinalizeCallback): IFileManager;
34
- whenModified?(assets: ExternalAsset[], sanitize?: boolean | PostFinalizeCallback, postFinalize?: PostFinalizeCallback): IFileManager;
35
+ whenModified?(assets: ExternalAsset[], sanitize?: boolean, postFinalize?: PostFinalizeCallback): IFileManager;
35
36
  set assets(value: ExternalAsset[]);
36
37
  get assets(): ExternalAsset[];
37
38
  set interval(value);
@@ -50,18 +51,83 @@ interface WatchConstructor extends ModuleConstructor {
50
51
  checkTimeout(client: ws): boolean;
51
52
  readonly prototype: IWatch;
52
53
  new(module?: WatchModule): IWatch;
53
- /* @deprecated */
54
- new(interval?: number, port?: number, securePort?: number, extensions?: unknown[]): IWatch;
55
54
  }
56
55
  ```
57
56
 
57
+ ## Settings
58
+
59
+ ```typescript
60
+ import type { PermittedDirectories } from "./core";
61
+
62
+ import type { SecureVersion } from "tls";
63
+
64
+ interface WatchModule {
65
+ // handler: "@e-mc/watch";
66
+ extensions?: string[];
67
+ timeout?: number | string;
68
+ interval?: number | string;
69
+ port?: number;
70
+ secure?: {
71
+ port?: number;
72
+ ca?: string;
73
+ key?: string;
74
+ cert?: string;
75
+ passphrase?: string;
76
+ version?: SecureVersion;
77
+ };
78
+ settings?: {
79
+ broadcast_id?: string | string[];
80
+ users?: Record<string, Record<string, unknown>>;
81
+ };
82
+ permission?: PermittedDirectories;
83
+ }
84
+ ```
85
+
86
+ ### Example usage
87
+
88
+ ```javascript
89
+ const Watch = require("@e-mc/watch");
90
+
91
+ const instance = new Watch({ interval: 100, port: 8080 });
92
+ instance.init();
93
+
94
+ instance.whenModified = (assets) => {
95
+ assets.forEach(item => console.log(item.uri));
96
+ };
97
+
98
+ const assets = [
99
+ { localUri: "/path/workspace/output/image1.png", uri: "http://hostname/path/document1.png", watch: true },
100
+ { localUri: "/path/workspace/output/image2.png", uri: "http://hostname/path/document2.png", watch: true }
101
+ ];
102
+
103
+ instance.start(assets, { disk_read: ["/path/workspace/output/**"] });
104
+ ```
105
+
106
+ ## NodeJS 14 LTS
107
+
108
+ Any optional fail safe dependencies were removed as of `E-mc 0.9`. The code itself will still be *ES2020* and will continue to work equivalently when self-installing these dependencies:
109
+
110
+ ### Under 15.4 + 16.0
111
+
112
+ ```sh
113
+ npm i abort-controller event-target-shim
114
+ ```
115
+
116
+ ### Under 14.17 + 15.6
117
+
118
+ ```sh
119
+ npm i uuid
120
+ ```
121
+
58
122
  ## References
59
123
 
60
- - https://www.unpkg.com/@e-mc/types@0.8.6/lib/asset.d.ts
61
- - https://www.unpkg.com/@e-mc/types@0.8.6/lib/core.d.ts
62
- - https://www.unpkg.com/@e-mc/types@0.8.6/lib/filemanager.d.ts
63
- - https://www.unpkg.com/@e-mc/types@0.8.6/lib/settings.d.ts
64
- - https://www.unpkg.com/@e-mc/types@0.8.6/lib/watch.d.ts
124
+ - https://www.unpkg.com/@e-mc/types@0.9.0/lib/asset.d.ts
125
+ - https://www.unpkg.com/@e-mc/types@0.9.0/lib/core.d.ts
126
+ - https://www.unpkg.com/@e-mc/types@0.9.0/lib/filemanager.d.ts
127
+ - https://www.unpkg.com/@e-mc/types@0.9.0/lib/settings.d.ts
128
+ - https://www.unpkg.com/@e-mc/types@0.9.0/lib/watch.d.ts
129
+
130
+ * https://www.npmjs.com/package/@types/ws
65
131
 
66
132
  ## LICENSE
67
133
 
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  var _a, _b, _c, _d, _e, _f;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
3
  const util = require("util");
5
4
  const ws = require("ws");
6
5
  const types_1 = require("@e-mc/types");
@@ -208,9 +207,5 @@ class FileGroup extends core_1.AbortComponent {
208
207
  _a = kServer, _b = kStarted, _c = kPaused, _d = kEtag, _e = kLastModified, _f = kSockets;
209
208
  FileGroup.CONNECTION_TIMEOUT = 10 * 60000;
210
209
  FileGroup.CLIENT_SESSION = new Map();
211
- exports.default = FileGroup;
212
210
 
213
- if (exports.default) {
214
- module.exports = exports.default;
215
- module.exports.default = exports.default;
216
- }
211
+ module.exports = FileGroup;
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { IFileManager, WatchConstructor } from '../types/lib';
2
-
3
- declare const Watch: WatchConstructor<IFileManager>;
4
-
1
+ import type { IFileManager, WatchConstructor } from '../types/lib';
2
+
3
+ declare const Watch: WatchConstructor<IFileManager>;
4
+
5
5
  export = Watch;
package/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
3
  const path = require("path");
5
4
  const fs = require("fs");
6
5
  const https = require("https");
@@ -72,6 +71,23 @@ function closeServer(map) {
72
71
  }
73
72
  const formatDate = (value) => new Date(value).toLocaleString().replace(/\/20\d+, /, '@').replace(/:\d+ (AM|PM)$/, (...match) => match[1]);
74
73
  class Watch extends core_1.Client {
74
+ constructor() {
75
+ super(...arguments);
76
+ this.connectTimeout = Watch.PROCESS_TIMEOUT;
77
+ this._moduleName = 'watch';
78
+ this._assets = [];
79
+ this._extensions = [];
80
+ this._hostEvents = [];
81
+ this[_a] = types_1.THRESHOLD.WATCH_INTERVAL;
82
+ this[_b] = 80;
83
+ this[_c] = 443;
84
+ this[_d] = '';
85
+ this[_e] = '';
86
+ this[_f] = '';
87
+ this[_g] = '';
88
+ this[_h] = undefined;
89
+ this[_j] = undefined;
90
+ }
75
91
  static createServer(port, secure, active) {
76
92
  if (typeof secure === 'boolean') {
77
93
  active = secure;
@@ -85,10 +101,10 @@ class Watch extends core_1.Client {
85
101
  }
86
102
  const { ca, passphrase, version, config } = secure;
87
103
  let { key, cert } = secure;
88
- if (key && cert && (key = request_1.default.readTLSKey(key, true)) && (cert = request_1.default.readTLSKey(cert, true))) {
104
+ if (key && cert && (key = request_1.readTLSKey(key, true)) && (cert = request_1.readTLSKey(cert, true))) {
89
105
  const server = https.createServer({
90
106
  ...config,
91
- ca: ca && request_1.default.readCACert(ca, true) || undefined,
107
+ ca: ca && request_1.readCACert(ca, true) || undefined,
92
108
  key: passphrase ? [{ pem: key, passphrase }] : key,
93
109
  cert,
94
110
  minVersion: version || config?.minVersion
@@ -123,16 +139,16 @@ class Watch extends core_1.Client {
123
139
  }
124
140
  wss.on('connection', function (socket) {
125
141
  socket.on('message', function () {
126
- filegroup_1.default.CLIENT_SESSION.delete(this);
142
+ filegroup_1.CLIENT_SESSION.delete(this);
127
143
  });
128
144
  socket.on('close', function () {
129
- filegroup_1.default.CLIENT_SESSION.delete(this);
145
+ filegroup_1.CLIENT_SESSION.delete(this);
130
146
  });
131
- this.clients.forEach(client => filegroup_1.default.checkTimeout(client));
147
+ this.clients.forEach(client => filegroup_1.checkTimeout(client));
132
148
  });
133
149
  wss.on('error', function (err) {
134
150
  const data = JSON.stringify({ event: types_1.WATCH_EVENT.ERROR, errors: [err.message] });
135
- this.clients.forEach(client => filegroup_1.default.checkTimeout(client) && client.send(data));
151
+ this.clients.forEach(client => filegroup_1.checkTimeout(client) && client.send(data));
136
152
  });
137
153
  wss.on('close', function () {
138
154
  this.clients.forEach(client => client.terminate());
@@ -144,50 +160,28 @@ class Watch extends core_1.Client {
144
160
  closeFileGroup(DISK_MAP);
145
161
  closeServer(PORT_MAP);
146
162
  closeServer(SECURE_MAP);
147
- filegroup_1.default.CLIENT_SESSION.clear();
163
+ filegroup_1.CLIENT_SESSION.clear();
148
164
  STATE_MAP = new WeakSet();
149
165
  }
150
166
  static checkTimeout(client) {
151
- return filegroup_1.default.checkTimeout(client);
167
+ return filegroup_1.checkTimeout(client);
152
168
  }
153
169
  static setTimeout(value) {
154
170
  if ((value = (0, types_1.parseTime)(value)) > 0) {
155
- filegroup_1.default.CONNECTION_TIMEOUT = Math.min(value, core_1.Client.MAX_TIMEOUT);
171
+ filegroup_1.CONNECTION_TIMEOUT = Math.min(value, core_1.Client.MAX_TIMEOUT);
156
172
  }
157
173
  }
158
- constructor(data, port, securePort, extensions) {
159
- super(data);
160
- this.connectTimeout = Watch.PROCESS_TIMEOUT;
161
- this._moduleName = 'watch';
162
- this._assets = [];
163
- this._extensions = [];
164
- this._hostEvents = [];
165
- this[_a] = types_1.THRESHOLD.WATCH_INTERVAL;
166
- this[_b] = 80;
167
- this[_c] = 443;
168
- this[_d] = '';
169
- this[_e] = '';
170
- this[_f] = '';
171
- this[_g] = '';
172
- this[_h] = undefined;
173
- this[_j] = undefined;
174
- let interval;
175
- if ((0, types_1.isPlainObject)(data)) {
176
- let secure;
177
- ({ interval, port, secure, extensions } = data);
178
- if (secure) {
179
- securePort = secure.port;
180
- if (secure.cert && secure.key) {
181
- this.configureServer(secure);
182
- }
174
+ init(config) {
175
+ const { interval, port, secure } = this.module;
176
+ if (secure) {
177
+ this.securePort = (0, util_1.asInt)(secure.port);
178
+ if (secure.cert && secure.key) {
179
+ this.configureServer(secure);
183
180
  }
184
181
  }
185
182
  this.interval = (0, util_1.asInt)(interval);
186
183
  this.port = (0, util_1.asInt)(port);
187
- this.securePort = (0, util_1.asInt)(securePort);
188
- if (Array.isArray(extensions)) {
189
- this.module.extensions = extensions;
190
- }
184
+ return super.init(config);
191
185
  }
192
186
  start(assets, permission) {
193
187
  var _k;
@@ -200,15 +194,14 @@ class Watch extends core_1.Client {
200
194
  const settings = this.getUserSettings();
201
195
  const destMap = Object.create(null);
202
196
  for (const item of assets) {
203
- if ((0, types_1.ignoreFlag)(item.flags)) {
204
- continue;
205
- }
206
- const { bundleId, uri, localUri } = item;
207
- if (!(0, types_1.isEmpty)(bundleId)) {
208
- (destMap[_k = ':' + bundleId] || (destMap[_k] = [])).push(item);
209
- }
210
- else if (uri && localUri) {
211
- (destMap[localUri] || (destMap[localUri] = [])).push(item);
197
+ if (!(0, types_1.ignoreFlag)(item.flags)) {
198
+ const { bundleId, uri, localUri } = item;
199
+ if (!(0, types_1.isEmpty)(bundleId)) {
200
+ (destMap[_k = ':' + bundleId] || (destMap[_k] = [])).push(item);
201
+ }
202
+ else if (uri && localUri) {
203
+ (destMap[localUri] || (destMap[localUri] = [])).push(item);
204
+ }
212
205
  }
213
206
  }
214
207
  for (let dest in destMap) {
@@ -236,7 +229,7 @@ class Watch extends core_1.Client {
236
229
  }
237
230
  if ((0, types_1.watchFlag)(other.flags)) {
238
231
  if (!other.watch) {
239
- other = filegroup_1.default.cloneAsset(other);
232
+ other = filegroup_1.cloneAsset(other);
240
233
  other.watch = { ...watch };
241
234
  }
242
235
  other.flags &= ~1;
@@ -337,7 +330,7 @@ class Watch extends core_1.Client {
337
330
  }
338
331
  const interval = getInterval(item) || watchInterval || this.interval;
339
332
  const watching = (uri, esm) => {
340
- const group = new filegroup_1.default(uri, main ? assets : items, startTime, this.willAbort("(watch)"));
333
+ const group = new filegroup_1(uri, main ? assets : items, startTime, this.willAbort("(watch)"));
341
334
  group.add(expires, socketId, id);
342
335
  if (main) {
343
336
  group.main = main;
@@ -437,7 +430,7 @@ class Watch extends core_1.Client {
437
430
  return status;
438
431
  }
439
432
  const url = group.url || (group.url = new URL(uri));
440
- const request = this.host?.Request || new request_1.default();
433
+ const request = this.host?.Request || new request_1();
441
434
  const agentTimeout = Math.max(timeout.interval * 10, this.connectTimeout);
442
435
  const opts = request.opts(url, { method: 'HEAD', httpVersion: 1, timeout: agentTimeout, agentTimeout });
443
436
  (function recurse() {
@@ -497,15 +490,13 @@ class Watch extends core_1.Client {
497
490
  }
498
491
  else {
499
492
  if (isMap(map)) {
500
- reject(valid ? (0, types_1.errorValue)('ETag not supported', uri) : (0, types_1.errorMessage)(statusCode, 'Invalid HTTP request', uri));
493
+ reject(valid ? (0, types_1.errorValue)("ETag not supported", uri) : (0, types_1.errorMessage)(statusCode, 'Invalid HTTP request', uri));
501
494
  return;
502
495
  }
503
496
  watchExpired(HTTP_MAP, group);
504
497
  abortTimeout(target);
505
498
  }
506
- if (client) {
507
- client.destroy();
508
- }
499
+ client?.destroy();
509
500
  resolve();
510
501
  })
511
502
  .on('error', err => {
@@ -538,7 +529,7 @@ class Watch extends core_1.Client {
538
529
  }
539
530
  }
540
531
  })
541
- .catch(err => {
532
+ .catch((err) => {
542
533
  fatalError(HTTP_MAP, target, err);
543
534
  client?.destroy();
544
535
  });
@@ -557,7 +548,7 @@ class Watch extends core_1.Client {
557
548
  }
558
549
  const map = DISK_MAP.get(uri);
559
550
  switch (event) {
560
- case 'change': {
551
+ case 'change':
561
552
  if (isMap(map)) {
562
553
  try {
563
554
  const mtime = Math.floor(fs.statSync(uri).mtimeMs);
@@ -588,11 +579,8 @@ class Watch extends core_1.Client {
588
579
  this.writeFail(["Unable to read file", path.basename(uri)], err, { type: 32, fatal: false });
589
580
  }
590
581
  }
591
- }
592
582
  case 'rename':
593
- if (map) {
594
- map.clear();
595
- }
583
+ map?.clear();
596
584
  watchExpired(DISK_MAP, group, event === 'rename' ? 'File renamed: ' + filename : undefined);
597
585
  abortTimeout(target);
598
586
  break;
@@ -656,7 +644,7 @@ class Watch extends core_1.Client {
656
644
  let items, sanitize = false;
657
645
  if (watch.main) {
658
646
  sanitize = watch.assets.length > assets.length;
659
- items = sanitize ? watch.assets.map(item => filegroup_1.default.cloneAsset(item)) : assets.map(item => (0, types_1.cloneObject)(item, true));
647
+ items = sanitize ? watch.assets.map(item => filegroup_1.cloneAsset(item)) : assets.map(item => (0, types_1.cloneObject)(item, true));
660
648
  }
661
649
  else {
662
650
  items = [];
@@ -674,9 +662,9 @@ class Watch extends core_1.Client {
674
662
  sanitize = true;
675
663
  }
676
664
  if (sanitize) {
677
- items = watch.assets.map(item => filegroup_1.default.cloneAsset(item));
665
+ items = watch.assets.map(item => filegroup_1.cloneAsset(item));
678
666
  }
679
- if (watch.related.length) {
667
+ if ((0, types_1.isArray)(watch.related)) {
680
668
  items.push(...watch.related);
681
669
  }
682
670
  }
@@ -701,32 +689,31 @@ class Watch extends core_1.Client {
701
689
  catch {
702
690
  }
703
691
  }
704
- if (!manager) {
705
- return;
706
- }
707
- if (host && watch.document) {
708
- for (const { instance } of host.Document) {
709
- if (host.hasDocument(instance, watch.document)) {
710
- const result = instance.watchInit?.(watch, items, sanitize);
711
- if (result) {
712
- if ((0, types_1.isArray)(result.using)) {
713
- manager.using(...result.using);
714
- }
715
- if (Array.isArray(result.dataSource)) {
716
- const document = manager.find(instance.moduleName);
717
- if (document) {
718
- document.dataSource = result.dataSource;
692
+ if (manager) {
693
+ if (host && watch.document) {
694
+ for (const { instance } of host.Document) {
695
+ if (host.hasDocument(instance, watch.document)) {
696
+ const result = instance.watchInit?.(watch, items, sanitize);
697
+ if (result) {
698
+ if ((0, types_1.isArray)(result.using)) {
699
+ manager.using(...result.using);
700
+ }
701
+ if (Array.isArray(result.dataSource)) {
702
+ const document = manager.find(instance.moduleName);
703
+ if (document) {
704
+ document.dataSource = result.dataSource;
705
+ }
719
706
  }
720
707
  }
721
- }
722
- const listener = instance.watchModified?.(watch, items);
723
- if (typeof listener === 'function') {
724
- manager.on('end', listener);
708
+ const listener = instance.watchModified?.(watch, items);
709
+ if (typeof listener === 'function') {
710
+ manager.on('end', listener);
711
+ }
725
712
  }
726
713
  }
727
714
  }
715
+ return await manager.start();
728
716
  }
729
- return await manager.start();
730
717
  }
731
718
  catch (err) {
732
719
  this.writeFail(["Unknown", watch.url?.pathname || path.basename(watch.uri)], err);
@@ -739,10 +726,10 @@ class Watch extends core_1.Client {
739
726
  if (ca) {
740
727
  this.setCA(ca);
741
728
  }
742
- if (request_1.default.isCert(key) || core_1.Client.isPath(key = path.resolve(key = key.trim())) && this.canRead(key, { ownPermissionOnly: true })) {
729
+ if (request_1.isCert(key) || core_1.Client.isPath(key = path.resolve(key = key.trim())) && this.canRead(key, { ownPermissionOnly: true })) {
743
730
  this[kTlsKey] = key.trim();
744
731
  }
745
- if (request_1.default.isCert(cert) || core_1.Client.isPath(cert = path.resolve(cert = cert.trim())) && this.canRead(cert, { ownPermissionOnly: true })) {
732
+ if (request_1.isCert(cert) || core_1.Client.isPath(cert = path.resolve(cert = cert.trim())) && this.canRead(cert, { ownPermissionOnly: true })) {
746
733
  this[kTlsCert] = cert.trim();
747
734
  }
748
735
  if ((0, types_1.isString)(passphrase)) {
@@ -779,10 +766,10 @@ class Watch extends core_1.Client {
779
766
  setSSLKey(value) {
780
767
  this[kTlsConfig] = { secureProtocol: 'SSLv23_method' };
781
768
  this[kTlsVersion] = undefined;
782
- return !!(this[kTlsKey] = request_1.default.readTLSKey(value, true));
769
+ return !!(this[kTlsKey] = request_1.readTLSKey(value, true));
783
770
  }
784
771
  setSSLCert(value) {
785
- return !!(this[kTlsCert] = request_1.default.readTLSCert(value, true));
772
+ return !!(this[kTlsCert] = request_1.readTLSCert(value, true));
786
773
  }
787
774
  hasSecureProtocol() {
788
775
  return !!this[kTlsKey] && !!this[kTlsCert];
@@ -792,7 +779,7 @@ class Watch extends core_1.Client {
792
779
  }
793
780
  set host(value) {
794
781
  super.host = value;
795
- if (value && (0, types_1.isArray)(value.assets)) {
782
+ if ((0, types_1.isArray)(value?.assets)) {
796
783
  this.assets = value.assets;
797
784
  }
798
785
  }
@@ -837,9 +824,5 @@ class Watch extends core_1.Client {
837
824
  }
838
825
  _a = kInterval, _b = kPort, _c = kSecurePort, _d = kCa, _e = kTlsKey, _f = kTlsCert, _g = kTlsPassphrase, _h = kTlsVersion, _j = kTlsConfig;
839
826
  Watch.PROCESS_TIMEOUT = 5 * 1000;
840
- exports.default = Watch;
841
827
 
842
- if (exports.default) {
843
- module.exports = exports.default;
844
- module.exports.default = exports.default;
845
- }
828
+ module.exports = Watch;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/watch",
3
- "version": "0.8.6",
3
+ "version": "0.9.0",
4
4
  "description": "Watch constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -20,10 +20,10 @@
20
20
  "license": "BSD 3-Clause",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "@e-mc/core": "0.8.6",
24
- "@e-mc/request": "0.8.6",
25
- "@e-mc/types": "0.8.6",
26
- "picomatch": "^3.0.1",
23
+ "@e-mc/core": "0.9.0",
24
+ "@e-mc/request": "0.9.0",
25
+ "@e-mc/types": "0.9.0",
26
+ "picomatch": "^4.0.2",
27
27
  "ws": "^8.16.0"
28
28
  }
29
29
  }