@atlaspack/watcher-watchman-js 2.14.5-canary.49 → 2.14.5-canary.490

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/CHANGELOG.md CHANGED
@@ -1,5 +1,447 @@
1
1
  # @atlaspack/watcher-watchman-js
2
2
 
3
+ ## 2.14.63
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - @atlaspack/utils@3.4.5
9
+ - @atlaspack/logger@2.14.55
10
+
11
+ ## 2.14.62
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies []:
16
+ - @atlaspack/utils@3.4.4
17
+ - @atlaspack/logger@2.14.54
18
+
19
+ ## 2.14.61
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies [[`e898fda`](https://github.com/atlassian-labs/atlaspack/commit/e898fda7511d98e5597d847c4a32c028a8a24d6c)]:
24
+ - @atlaspack/utils@3.4.3
25
+ - @atlaspack/logger@2.14.53
26
+
27
+ ## 2.14.60
28
+
29
+ ### Patch Changes
30
+
31
+ - Updated dependencies []:
32
+ - @atlaspack/logger@2.14.52
33
+ - @atlaspack/utils@3.4.2
34
+
35
+ ## 2.14.59
36
+
37
+ ### Patch Changes
38
+
39
+ - Updated dependencies []:
40
+ - @atlaspack/logger@2.14.51
41
+ - @atlaspack/utils@3.4.1
42
+
43
+ ## 2.14.58
44
+
45
+ ### Patch Changes
46
+
47
+ - Updated dependencies [[`71981ea`](https://github.com/atlassian-labs/atlaspack/commit/71981eac258f7e6dfb40ec4b202d194f71c64ff1)]:
48
+ - @atlaspack/utils@3.4.0
49
+ - @atlaspack/logger@2.14.50
50
+
51
+ ## 2.14.57
52
+
53
+ ### Patch Changes
54
+
55
+ - Updated dependencies []:
56
+ - @atlaspack/utils@3.3.9
57
+ - @atlaspack/logger@2.14.49
58
+
59
+ ## 2.14.56
60
+
61
+ ### Patch Changes
62
+
63
+ - Updated dependencies []:
64
+ - @atlaspack/logger@2.14.48
65
+ - @atlaspack/utils@3.3.8
66
+
67
+ ## 2.14.55
68
+
69
+ ### Patch Changes
70
+
71
+ - Updated dependencies []:
72
+ - @atlaspack/logger@2.14.47
73
+ - @atlaspack/utils@3.3.7
74
+
75
+ ## 2.14.54
76
+
77
+ ### Patch Changes
78
+
79
+ - Updated dependencies [[`d8e984b`](https://github.com/atlassian-labs/atlaspack/commit/d8e984b7f6d04fa03707fa299bfd8b8bf9f58280)]:
80
+ - @atlaspack/utils@3.3.6
81
+ - @atlaspack/logger@2.14.46
82
+
83
+ ## 2.14.53
84
+
85
+ ### Patch Changes
86
+
87
+ - Updated dependencies []:
88
+ - @atlaspack/logger@2.14.45
89
+ - @atlaspack/utils@3.3.5
90
+
91
+ ## 2.14.52
92
+
93
+ ### Patch Changes
94
+
95
+ - Updated dependencies []:
96
+ - @atlaspack/logger@2.14.44
97
+ - @atlaspack/utils@3.3.4
98
+
99
+ ## 2.14.51
100
+
101
+ ### Patch Changes
102
+
103
+ - Updated dependencies []:
104
+ - @atlaspack/logger@2.14.43
105
+ - @atlaspack/utils@3.3.3
106
+
107
+ ## 2.14.50
108
+
109
+ ### Patch Changes
110
+
111
+ - Updated dependencies []:
112
+ - @atlaspack/logger@2.14.42
113
+ - @atlaspack/utils@3.3.2
114
+
115
+ ## 2.14.49
116
+
117
+ ### Patch Changes
118
+
119
+ - Updated dependencies []:
120
+ - @atlaspack/logger@2.14.41
121
+ - @atlaspack/utils@3.3.1
122
+
123
+ ## 2.14.48
124
+
125
+ ### Patch Changes
126
+
127
+ - Updated dependencies [[`47aa84e`](https://github.com/atlassian-labs/atlaspack/commit/47aa84e44c61066072a5bf3d57678565b9d2c5a3)]:
128
+ - @atlaspack/utils@3.3.0
129
+ - @atlaspack/logger@2.14.40
130
+
131
+ ## 2.14.47
132
+
133
+ ### Patch Changes
134
+
135
+ - Updated dependencies []:
136
+ - @atlaspack/logger@2.14.39
137
+ - @atlaspack/utils@3.2.8
138
+
139
+ ## 2.14.46
140
+
141
+ ### Patch Changes
142
+
143
+ - Updated dependencies []:
144
+ - @atlaspack/logger@2.14.38
145
+ - @atlaspack/utils@3.2.7
146
+
147
+ ## 2.14.45
148
+
149
+ ### Patch Changes
150
+
151
+ - Updated dependencies []:
152
+ - @atlaspack/utils@3.2.6
153
+ - @atlaspack/logger@2.14.37
154
+
155
+ ## 2.14.44
156
+
157
+ ### Patch Changes
158
+
159
+ - Updated dependencies []:
160
+ - @atlaspack/logger@2.14.36
161
+ - @atlaspack/utils@3.2.5
162
+
163
+ ## 2.14.43
164
+
165
+ ### Patch Changes
166
+
167
+ - Updated dependencies []:
168
+ - @atlaspack/logger@2.14.35
169
+ - @atlaspack/utils@3.2.4
170
+
171
+ ## 2.14.42
172
+
173
+ ### Patch Changes
174
+
175
+ - Updated dependencies []:
176
+ - @atlaspack/logger@2.14.34
177
+ - @atlaspack/utils@3.2.3
178
+
179
+ ## 2.14.41
180
+
181
+ ### Patch Changes
182
+
183
+ - Updated dependencies []:
184
+ - @atlaspack/logger@2.14.33
185
+ - @atlaspack/utils@3.2.2
186
+
187
+ ## 2.14.40
188
+
189
+ ### Patch Changes
190
+
191
+ - Updated dependencies []:
192
+ - @atlaspack/logger@2.14.32
193
+ - @atlaspack/utils@3.2.1
194
+
195
+ ## 2.14.39
196
+
197
+ ### Patch Changes
198
+
199
+ - Updated dependencies [[`73168c2`](https://github.com/atlassian-labs/atlaspack/commit/73168c275a5d9abff9907bcf536b340bca1ed5f0), [`617a318`](https://github.com/atlassian-labs/atlaspack/commit/617a318ddc9419b38360257353fec50b9051ee13)]:
200
+ - @atlaspack/utils@3.2.0
201
+ - @atlaspack/logger@2.14.31
202
+
203
+ ## 2.14.38
204
+
205
+ ### Patch Changes
206
+
207
+ - Updated dependencies [[`7d7a55d`](https://github.com/atlassian-labs/atlaspack/commit/7d7a55dd6395ec391a2e4c33b3dec0d1ea477d4c)]:
208
+ - @atlaspack/utils@3.1.2
209
+ - @atlaspack/logger@2.14.30
210
+
211
+ ## 2.14.37
212
+
213
+ ### Patch Changes
214
+
215
+ - Updated dependencies []:
216
+ - @atlaspack/logger@2.14.29
217
+ - @atlaspack/utils@3.1.1
218
+
219
+ ## 2.14.36
220
+
221
+ ### Patch Changes
222
+
223
+ - Updated dependencies [[`5776be2`](https://github.com/atlassian-labs/atlaspack/commit/5776be21f70a3f2b9471ba33da3ba1a883f21f1a)]:
224
+ - @atlaspack/utils@3.1.0
225
+ - @atlaspack/logger@2.14.28
226
+
227
+ ## 2.14.35
228
+
229
+ ### Patch Changes
230
+
231
+ - Updated dependencies [[`c372f3f`](https://github.com/atlassian-labs/atlaspack/commit/c372f3fd6fce8200d5cf47f41bc7895c6cbb5558), [`17dfea9`](https://github.com/atlassian-labs/atlaspack/commit/17dfea9e9f3169807808520df9c09ebf70dc8b10)]:
232
+ - @atlaspack/utils@3.0.3
233
+ - @atlaspack/logger@2.14.27
234
+
235
+ ## 2.14.34
236
+
237
+ ### Patch Changes
238
+
239
+ - Updated dependencies []:
240
+ - @atlaspack/utils@3.0.2
241
+ - @atlaspack/logger@2.14.26
242
+
243
+ ## 2.14.33
244
+
245
+ ### Patch Changes
246
+
247
+ - Updated dependencies [[`236e546`](https://github.com/atlassian-labs/atlaspack/commit/236e5465863dca6044a7191e05260a5b924c342e)]:
248
+ - @atlaspack/utils@3.0.1
249
+ - @atlaspack/logger@2.14.25
250
+
251
+ ## 2.14.32
252
+
253
+ ### Patch Changes
254
+
255
+ - Updated dependencies [[`1180103`](https://github.com/atlassian-labs/atlaspack/commit/118010351ed444f8178988afb3f77807154dd933)]:
256
+ - @atlaspack/utils@3.0.0
257
+ - @atlaspack/logger@2.14.24
258
+
259
+ ## 2.14.31
260
+
261
+ ### Patch Changes
262
+
263
+ - [#785](https://github.com/atlassian-labs/atlaspack/pull/785) [`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922) Thanks [@matt-koko](https://github.com/matt-koko)! - We need to re-publish every package in Atlaspack with the corrected types field.
264
+
265
+ - Updated dependencies [[`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922)]:
266
+ - @atlaspack/logger@2.14.23
267
+ - @atlaspack/utils@2.19.3
268
+
269
+ ## 2.14.30
270
+
271
+ ### Patch Changes
272
+
273
+ - Updated dependencies []:
274
+ - @atlaspack/utils@2.19.2
275
+ - @atlaspack/logger@2.14.22
276
+
277
+ ## 2.14.29
278
+
279
+ ### Patch Changes
280
+
281
+ - Updated dependencies []:
282
+ - @atlaspack/utils@2.19.1
283
+ - @atlaspack/logger@2.14.21
284
+
285
+ ## 2.14.28
286
+
287
+ ### Patch Changes
288
+
289
+ - [#758](https://github.com/atlassian-labs/atlaspack/pull/758) [`c940954`](https://github.com/atlassian-labs/atlaspack/commit/c940954d27d657c3c93cd328dfb394778da46eab) Thanks [@marcins](https://github.com/marcins)! - Type fixes
290
+
291
+ - Updated dependencies [[`f0349a6`](https://github.com/atlassian-labs/atlaspack/commit/f0349a6b9b04755088f121095ca6301a2ada3767)]:
292
+ - @atlaspack/utils@2.19.0
293
+ - @atlaspack/logger@2.14.20
294
+
295
+ ## 2.14.27
296
+
297
+ ### Patch Changes
298
+
299
+ - Updated dependencies []:
300
+ - @atlaspack/utils@2.18.4
301
+ - @atlaspack/logger@2.14.19
302
+
303
+ ## 2.14.26
304
+
305
+ ### Patch Changes
306
+
307
+ - [#742](https://github.com/atlassian-labs/atlaspack/pull/742) [`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd) Thanks [@yamadapc](https://github.com/yamadapc)! - Internal changes and bug fixes to environmentDeduplication flag
308
+
309
+ - Updated dependencies [[`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd), [`889c65c`](https://github.com/atlassian-labs/atlaspack/commit/889c65cd25b811045e26a117e7404f694dde77a2)]:
310
+ - @atlaspack/logger@2.14.18
311
+ - @atlaspack/utils@2.18.3
312
+
313
+ ## 2.14.25
314
+
315
+ ### Patch Changes
316
+
317
+ - Updated dependencies []:
318
+ - @atlaspack/utils@2.18.2
319
+ - @atlaspack/logger@2.14.17
320
+
321
+ ## 2.14.24
322
+
323
+ ### Patch Changes
324
+
325
+ - Updated dependencies []:
326
+ - @atlaspack/logger@2.14.16
327
+ - @atlaspack/utils@2.18.1
328
+
329
+ ## 2.14.23
330
+
331
+ ### Patch Changes
332
+
333
+ - Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
334
+ - @atlaspack/utils@2.18.0
335
+ - @atlaspack/logger@2.14.15
336
+
337
+ ## 2.14.22
338
+
339
+ ### Patch Changes
340
+
341
+ - [#720](https://github.com/atlassian-labs/atlaspack/pull/720) [`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94) Thanks [@alshdavid](https://github.com/alshdavid)! - Migrate to TypeScript
342
+
343
+ - Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94)]:
344
+ - @atlaspack/logger@2.14.14
345
+ - @atlaspack/utils@2.17.4
346
+
347
+ ## 2.14.21
348
+
349
+ ### Patch Changes
350
+
351
+ - Updated dependencies []:
352
+ - @atlaspack/utils@2.17.3
353
+
354
+ ## 2.14.20
355
+
356
+ ### Patch Changes
357
+
358
+ - Updated dependencies []:
359
+ - @atlaspack/utils@2.17.2
360
+
361
+ ## 2.14.19
362
+
363
+ ### Patch Changes
364
+
365
+ - Updated dependencies []:
366
+ - @atlaspack/utils@2.17.1
367
+
368
+ ## 2.14.18
369
+
370
+ ### Patch Changes
371
+
372
+ - [#682](https://github.com/atlassian-labs/atlaspack/pull/682) [`a5ed1b4`](https://github.com/atlassian-labs/atlaspack/commit/a5ed1b414498560f393ff491af4da25b6e8dde56) Thanks [@alshdavid](https://github.com/alshdavid)! - Updating build system
373
+
374
+ - Updated dependencies [[`dbb4072`](https://github.com/atlassian-labs/atlaspack/commit/dbb40721ebeb45990a14ba04e6b44e7f836fb32d), [`de23e0c`](https://github.com/atlassian-labs/atlaspack/commit/de23e0ce49d5504fe3947ac26640a3d951087da3), [`18a57cf`](https://github.com/atlassian-labs/atlaspack/commit/18a57cf8a4789b2de5ad8e2676f317a26cc91417), [`a5ed1b4`](https://github.com/atlassian-labs/atlaspack/commit/a5ed1b414498560f393ff491af4da25b6e8dde56)]:
375
+ - @atlaspack/utils@2.17.0
376
+ - @atlaspack/logger@2.14.13
377
+
378
+ ## 2.14.17
379
+
380
+ ### Patch Changes
381
+
382
+ - Updated dependencies []:
383
+ - @atlaspack/logger@2.14.12
384
+ - @atlaspack/utils@2.16.1
385
+
386
+ ## 2.14.16
387
+
388
+ ### Patch Changes
389
+
390
+ - Updated dependencies [[`30ee2cf`](https://github.com/atlassian-labs/atlaspack/commit/30ee2cfcd34cf2646ded0eda13fdb80a2a5de529)]:
391
+ - @atlaspack/utils@2.16.0
392
+
393
+ ## 2.14.15
394
+
395
+ ### Patch Changes
396
+
397
+ - Updated dependencies []:
398
+ - @atlaspack/utils@2.15.3
399
+
400
+ ## 2.14.14
401
+
402
+ ### Patch Changes
403
+
404
+ - Updated dependencies []:
405
+ - @atlaspack/utils@2.15.2
406
+
407
+ ## 2.14.13
408
+
409
+ ### Patch Changes
410
+
411
+ - Updated dependencies [[`ef3d622`](https://github.com/atlassian-labs/atlaspack/commit/ef3d6228f4e006702198a19c61e051d194d325cb)]:
412
+ - @atlaspack/logger@2.14.11
413
+ - @atlaspack/utils@2.15.1
414
+
415
+ ## 2.14.12
416
+
417
+ ### Patch Changes
418
+
419
+ - Updated dependencies [[`e39c6cf`](https://github.com/atlassian-labs/atlaspack/commit/e39c6cf05f7e95ce5420dbcea66f401b1cbd397c)]:
420
+ - @atlaspack/utils@2.15.0
421
+
422
+ ## 2.14.11
423
+
424
+ ### Patch Changes
425
+
426
+ - Updated dependencies []:
427
+ - @atlaspack/utils@2.14.11
428
+
429
+ ## 2.14.10
430
+
431
+ ### Patch Changes
432
+
433
+ - Updated dependencies []:
434
+ - @atlaspack/logger@2.14.10
435
+ - @atlaspack/utils@2.14.10
436
+
437
+ ## 2.14.9
438
+
439
+ ### Patch Changes
440
+
441
+ - Updated dependencies []:
442
+ - @atlaspack/logger@2.14.9
443
+ - @atlaspack/utils@2.14.9
444
+
3
445
  ## 2.14.8
4
446
 
5
447
  ### Patch Changes
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.unsubscribe = exports.subscribe = exports.getEventsSince = exports.writeSnapshot = void 0;
4
+ const wrapper_1 = require("./wrapper");
5
+ const wrapper = new wrapper_1.AtlaspackWatcherWatchmanJS();
6
+ exports.writeSnapshot = wrapper.writeSnapshot.bind(wrapper);
7
+ exports.getEventsSince = wrapper.getEventsSince.bind(wrapper);
8
+ exports.subscribe = wrapper.subscribe.bind(wrapper);
9
+ exports.unsubscribe = wrapper.unsubscribe.bind(wrapper);
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.AtlaspackWatcherWatchmanJS = void 0;
40
+ const fs = __importStar(require("fs"));
41
+ const path = __importStar(require("path"));
42
+ const watchman = __importStar(require("fb-watchman"));
43
+ const utils_1 = require("@atlaspack/utils");
44
+ const logger_1 = __importDefault(require("@atlaspack/logger"));
45
+ class AtlaspackWatcherWatchmanJS {
46
+ constructor() {
47
+ this.subscriptionName = 'parcel-watcher-subscription-' + Date.now();
48
+ this.client = new watchman.Client();
49
+ }
50
+ commandAsync(args) {
51
+ return new Promise((resolve, reject) => {
52
+ const client = this.client;
53
+ client.command(args, (err, response) => {
54
+ if (err)
55
+ reject(err);
56
+ else
57
+ resolve(response);
58
+ });
59
+ });
60
+ }
61
+ capabilityCheckAsync(args) {
62
+ return new Promise((resolve, reject) => {
63
+ const client = this.client;
64
+ client.capabilityCheck(args, (err, response) => {
65
+ if (err)
66
+ reject(err);
67
+ else
68
+ resolve(response);
69
+ });
70
+ });
71
+ }
72
+ async _init(watchDir) {
73
+ await this.capabilityCheckAsync({ optional: [], required: [] });
74
+ const resp = await this.commandAsync(['watch-project', watchDir]);
75
+ if ('warning' in resp) {
76
+ logger_1.default.warn({ message: resp.warning });
77
+ }
78
+ }
79
+ init(watchDir) {
80
+ if (this.initPromise) {
81
+ return this.initPromise;
82
+ }
83
+ this.initPromise = this._init(watchDir);
84
+ return this.initPromise;
85
+ }
86
+ // Types should match @parcel/watcher/index.js.flow
87
+ async writeSnapshot(dir, snapshot) {
88
+ await this.init(dir);
89
+ const response = await this.commandAsync(['clock', dir]);
90
+ fs.mkdirSync(path.dirname(snapshot), { recursive: true });
91
+ fs.writeFileSync(snapshot, response.clock, {
92
+ encoding: 'utf-8',
93
+ });
94
+ return response.clock;
95
+ }
96
+ async getEventsSince(dir, snapshot, opts) {
97
+ await this.init(dir);
98
+ const clock = fs.readFileSync(snapshot, {
99
+ encoding: 'utf-8',
100
+ });
101
+ const response = await this.commandAsync([
102
+ 'query',
103
+ dir,
104
+ {
105
+ expression: this._createExpression(dir, opts?.ignore),
106
+ fields: ['name', 'mode', 'exists', 'new'],
107
+ since: clock,
108
+ },
109
+ ]);
110
+ return (response.files || []).map((file) => ({
111
+ path: file.name,
112
+ type: file.new ? 'create' : file.exists ? 'update' : 'delete',
113
+ }));
114
+ }
115
+ _createExpression(dir, ignore) {
116
+ const ignores = [
117
+ // Ignore the watchman cookie
118
+ ['match', '.watchman-cookie-*'],
119
+ // Ignore directory changes as they are just noise
120
+ ['type', 'd'],
121
+ ];
122
+ if (ignore) {
123
+ const customIgnores = ignore?.map((filePathOrGlob) => {
124
+ const relative = path.relative(dir, filePathOrGlob);
125
+ if ((0, utils_1.isGlob)(filePathOrGlob)) {
126
+ return ['match', relative, 'wholename'];
127
+ }
128
+ // If pattern is not a glob, then assume it's a directory.
129
+ // Ignoring single files is not currently supported
130
+ return ['dirname', relative];
131
+ });
132
+ ignores.push(...customIgnores);
133
+ }
134
+ return ['not', ['anyof', ...ignores]];
135
+ }
136
+ async subscribe(dir, fn, opts) {
137
+ await this.init(dir);
138
+ const { subscriptionName } = this;
139
+ const { clock } = await this.commandAsync(['clock', dir]);
140
+ await this.commandAsync([
141
+ 'subscribe',
142
+ dir,
143
+ subscriptionName,
144
+ {
145
+ // `defer` can be used here if you want to pause the
146
+ // notification stream until something has finished.
147
+ //
148
+ // https://facebook.github.io/watchman/docs/cmd/subscribe#defer
149
+ // defer: ['my-company-example'],
150
+ expression: this._createExpression(dir, opts?.ignore),
151
+ fields: ['name', 'mode', 'exists', 'new'],
152
+ since: clock,
153
+ },
154
+ ]);
155
+ this.client.on('subscription', function (resp) {
156
+ if (!resp.files || resp.subscription !== subscriptionName) {
157
+ return;
158
+ }
159
+ fn(null /* err */, resp.files.map((file) => {
160
+ return {
161
+ path: path.join(dir, file.name),
162
+ type: file.new ? 'create' : file.exists ? 'update' : 'delete',
163
+ };
164
+ }));
165
+ });
166
+ const unsubscribe = async () => {
167
+ await this.commandAsync(['unsubscribe', dir, subscriptionName]);
168
+ };
169
+ return {
170
+ unsubscribe,
171
+ };
172
+ }
173
+ async unsubscribe(dir) {
174
+ await this.commandAsync(['unsubscribe', dir, this.subscriptionName]);
175
+ }
176
+ }
177
+ exports.AtlaspackWatcherWatchmanJS = AtlaspackWatcherWatchmanJS;
@@ -0,0 +1,4 @@
1
+ export declare const writeSnapshot: (dir: string, snapshot: string, opts?: import("@parcel/watcher").Options) => Promise<string>;
2
+ export declare const getEventsSince: (dir: string, snapshot: string, opts?: import("@parcel/watcher").Options) => Promise<Array<import("@parcel/watcher").Event>>;
3
+ export declare const subscribe: (dir: string, fn: import("@parcel/watcher").SubscribeCallback, opts?: import("@parcel/watcher").Options) => Promise<import("@parcel/watcher").AsyncSubscription>;
4
+ export declare const unsubscribe: (dir: string, fn: import("@parcel/watcher").SubscribeCallback, opts?: import("@parcel/watcher").Options) => Promise<void>;
@@ -0,0 +1,27 @@
1
+ import * as watchman from 'fb-watchman';
2
+ import type { Options, Event, SubscribeCallback, AsyncSubscription } from '@parcel/watcher';
3
+ type WatchmanArgs = any;
4
+ type FilePath = string;
5
+ type GlobPattern = string;
6
+ export interface Watcher {
7
+ getEventsSince(dir: FilePath, snapshot: FilePath, opts?: Options): Promise<Array<Event>>;
8
+ subscribe(dir: FilePath, fn: SubscribeCallback, opts?: Options): Promise<AsyncSubscription>;
9
+ unsubscribe(dir: FilePath, fn: SubscribeCallback, opts?: Options): Promise<void>;
10
+ writeSnapshot(dir: FilePath, snapshot: FilePath, opts?: Options): Promise<FilePath>;
11
+ }
12
+ export declare class AtlaspackWatcherWatchmanJS implements Watcher {
13
+ subscriptionName: string;
14
+ client: watchman.Client;
15
+ initPromise: Promise<void> | undefined;
16
+ constructor();
17
+ commandAsync(args: WatchmanArgs): Promise<any>;
18
+ capabilityCheckAsync(args: any): Promise<any>;
19
+ _init(watchDir: string): Promise<void>;
20
+ init(watchDir: string): Promise<void>;
21
+ writeSnapshot(dir: string, snapshot: FilePath): Promise<string>;
22
+ getEventsSince(dir: string, snapshot: FilePath, opts?: Options): Promise<Event[]>;
23
+ _createExpression(dir: string, ignore?: Array<FilePath | GlobPattern>): WatchmanArgs;
24
+ subscribe(dir: string, fn: SubscribeCallback, opts?: Options): Promise<AsyncSubscription>;
25
+ unsubscribe(dir: string): Promise<void>;
26
+ }
27
+ export {};
package/lib/wrapper.js CHANGED
@@ -39,10 +39,10 @@ function _logger() {
39
39
  };
40
40
  return data;
41
41
  }
42
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
43
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
44
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
42
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
43
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
45
44
  // Matches the Watcher API from "@parcel/watcher"
45
+
46
46
  class AtlaspackWatcherWatchmanJS {
47
47
  constructor() {
48
48
  this.subscriptionName = 'parcel-watcher-subscription-' + Date.now();
@@ -51,9 +51,7 @@ class AtlaspackWatcherWatchmanJS {
51
51
  commandAsync(args) {
52
52
  return new Promise((resolve, reject) => {
53
53
  const client = this.client;
54
- client.command(args,
55
- // $FlowFixMe
56
- (err, response) => {
54
+ client.command(args, (err, response) => {
57
55
  if (err) reject(err);else resolve(response);
58
56
  });
59
57
  });
@@ -61,9 +59,7 @@ class AtlaspackWatcherWatchmanJS {
61
59
  capabilityCheckAsync(args) {
62
60
  return new Promise((resolve, reject) => {
63
61
  const client = this.client;
64
- client.capabilityCheck(args,
65
- // $FlowFixMe
66
- (err, response) => {
62
+ client.capabilityCheck(args, (err, response) => {
67
63
  if (err) reject(err);else resolve(response);
68
64
  });
69
65
  });