@atlaspack/watcher-watchman-js 2.14.5-canary.2 → 2.14.5-canary.200

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,223 @@
1
1
  # @atlaspack/watcher-watchman-js
2
2
 
3
+ ## 2.14.31
4
+
5
+ ### Patch Changes
6
+
7
+ - [#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.
8
+
9
+ - Updated dependencies [[`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922)]:
10
+ - @atlaspack/logger@2.14.23
11
+ - @atlaspack/utils@2.19.3
12
+
13
+ ## 2.14.30
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies []:
18
+ - @atlaspack/utils@2.19.2
19
+ - @atlaspack/logger@2.14.22
20
+
21
+ ## 2.14.29
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies []:
26
+ - @atlaspack/utils@2.19.1
27
+ - @atlaspack/logger@2.14.21
28
+
29
+ ## 2.14.28
30
+
31
+ ### Patch Changes
32
+
33
+ - [#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
34
+
35
+ - Updated dependencies [[`f0349a6`](https://github.com/atlassian-labs/atlaspack/commit/f0349a6b9b04755088f121095ca6301a2ada3767)]:
36
+ - @atlaspack/utils@2.19.0
37
+ - @atlaspack/logger@2.14.20
38
+
39
+ ## 2.14.27
40
+
41
+ ### Patch Changes
42
+
43
+ - Updated dependencies []:
44
+ - @atlaspack/utils@2.18.4
45
+ - @atlaspack/logger@2.14.19
46
+
47
+ ## 2.14.26
48
+
49
+ ### Patch Changes
50
+
51
+ - [#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
52
+
53
+ - Updated dependencies [[`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd), [`889c65c`](https://github.com/atlassian-labs/atlaspack/commit/889c65cd25b811045e26a117e7404f694dde77a2)]:
54
+ - @atlaspack/logger@2.14.18
55
+ - @atlaspack/utils@2.18.3
56
+
57
+ ## 2.14.25
58
+
59
+ ### Patch Changes
60
+
61
+ - Updated dependencies []:
62
+ - @atlaspack/utils@2.18.2
63
+ - @atlaspack/logger@2.14.17
64
+
65
+ ## 2.14.24
66
+
67
+ ### Patch Changes
68
+
69
+ - Updated dependencies []:
70
+ - @atlaspack/logger@2.14.16
71
+ - @atlaspack/utils@2.18.1
72
+
73
+ ## 2.14.23
74
+
75
+ ### Patch Changes
76
+
77
+ - Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
78
+ - @atlaspack/utils@2.18.0
79
+ - @atlaspack/logger@2.14.15
80
+
81
+ ## 2.14.22
82
+
83
+ ### Patch Changes
84
+
85
+ - [#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
86
+
87
+ - Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94)]:
88
+ - @atlaspack/logger@2.14.14
89
+ - @atlaspack/utils@2.17.4
90
+
91
+ ## 2.14.21
92
+
93
+ ### Patch Changes
94
+
95
+ - Updated dependencies []:
96
+ - @atlaspack/utils@2.17.3
97
+
98
+ ## 2.14.20
99
+
100
+ ### Patch Changes
101
+
102
+ - Updated dependencies []:
103
+ - @atlaspack/utils@2.17.2
104
+
105
+ ## 2.14.19
106
+
107
+ ### Patch Changes
108
+
109
+ - Updated dependencies []:
110
+ - @atlaspack/utils@2.17.1
111
+
112
+ ## 2.14.18
113
+
114
+ ### Patch Changes
115
+
116
+ - [#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
117
+
118
+ - 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)]:
119
+ - @atlaspack/utils@2.17.0
120
+ - @atlaspack/logger@2.14.13
121
+
122
+ ## 2.14.17
123
+
124
+ ### Patch Changes
125
+
126
+ - Updated dependencies []:
127
+ - @atlaspack/logger@2.14.12
128
+ - @atlaspack/utils@2.16.1
129
+
130
+ ## 2.14.16
131
+
132
+ ### Patch Changes
133
+
134
+ - Updated dependencies [[`30ee2cf`](https://github.com/atlassian-labs/atlaspack/commit/30ee2cfcd34cf2646ded0eda13fdb80a2a5de529)]:
135
+ - @atlaspack/utils@2.16.0
136
+
137
+ ## 2.14.15
138
+
139
+ ### Patch Changes
140
+
141
+ - Updated dependencies []:
142
+ - @atlaspack/utils@2.15.3
143
+
144
+ ## 2.14.14
145
+
146
+ ### Patch Changes
147
+
148
+ - Updated dependencies []:
149
+ - @atlaspack/utils@2.15.2
150
+
151
+ ## 2.14.13
152
+
153
+ ### Patch Changes
154
+
155
+ - Updated dependencies [[`ef3d622`](https://github.com/atlassian-labs/atlaspack/commit/ef3d6228f4e006702198a19c61e051d194d325cb)]:
156
+ - @atlaspack/logger@2.14.11
157
+ - @atlaspack/utils@2.15.1
158
+
159
+ ## 2.14.12
160
+
161
+ ### Patch Changes
162
+
163
+ - Updated dependencies [[`e39c6cf`](https://github.com/atlassian-labs/atlaspack/commit/e39c6cf05f7e95ce5420dbcea66f401b1cbd397c)]:
164
+ - @atlaspack/utils@2.15.0
165
+
166
+ ## 2.14.11
167
+
168
+ ### Patch Changes
169
+
170
+ - Updated dependencies []:
171
+ - @atlaspack/utils@2.14.11
172
+
173
+ ## 2.14.10
174
+
175
+ ### Patch Changes
176
+
177
+ - Updated dependencies []:
178
+ - @atlaspack/logger@2.14.10
179
+ - @atlaspack/utils@2.14.10
180
+
181
+ ## 2.14.9
182
+
183
+ ### Patch Changes
184
+
185
+ - Updated dependencies []:
186
+ - @atlaspack/logger@2.14.9
187
+ - @atlaspack/utils@2.14.9
188
+
189
+ ## 2.14.8
190
+
191
+ ### Patch Changes
192
+
193
+ - Updated dependencies []:
194
+ - @atlaspack/utils@2.14.8
195
+ - @atlaspack/logger@2.14.8
196
+
197
+ ## 2.14.7
198
+
199
+ ### Patch Changes
200
+
201
+ - Updated dependencies [[`556d6ab`](https://github.com/atlassian-labs/atlaspack/commit/556d6ab8ede759fa7f37fcd3f4da336ef1c55e8f)]:
202
+ - @atlaspack/logger@2.14.7
203
+ - @atlaspack/utils@2.14.7
204
+
205
+ ## 2.14.6
206
+
207
+ ### Patch Changes
208
+
209
+ - Updated dependencies []:
210
+ - @atlaspack/utils@2.14.6
211
+ - @atlaspack/logger@2.14.6
212
+
213
+ ## 2.14.5
214
+
215
+ ### Patch Changes
216
+
217
+ - Updated dependencies []:
218
+ - @atlaspack/utils@2.14.5
219
+ - @atlaspack/logger@2.14.5
220
+
3
221
  ## 2.14.4
4
222
 
5
223
  ### Patch Changes
@@ -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
@@ -43,6 +43,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
43
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
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; }
45
45
  // Matches the Watcher API from "@parcel/watcher"
46
+
46
47
  class AtlaspackWatcherWatchmanJS {
47
48
  constructor() {
48
49
  this.subscriptionName = 'parcel-watcher-subscription-' + Date.now();
@@ -51,9 +52,7 @@ class AtlaspackWatcherWatchmanJS {
51
52
  commandAsync(args) {
52
53
  return new Promise((resolve, reject) => {
53
54
  const client = this.client;
54
- client.command(args,
55
- // $FlowFixMe
56
- (err, response) => {
55
+ client.command(args, (err, response) => {
57
56
  if (err) reject(err);else resolve(response);
58
57
  });
59
58
  });
@@ -61,9 +60,7 @@ class AtlaspackWatcherWatchmanJS {
61
60
  capabilityCheckAsync(args) {
62
61
  return new Promise((resolve, reject) => {
63
62
  const client = this.client;
64
- client.capabilityCheck(args,
65
- // $FlowFixMe
66
- (err, response) => {
63
+ client.capabilityCheck(args, (err, response) => {
67
64
  if (err) reject(err);else resolve(response);
68
65
  });
69
66
  });
package/package.json CHANGED
@@ -1,20 +1,24 @@
1
1
  {
2
2
  "name": "@atlaspack/watcher-watchman-js",
3
- "version": "2.14.5-canary.2+88fcaf47c",
3
+ "version": "2.14.5-canary.200+10ee3fa5b",
4
4
  "license": "(MIT OR Apache-2.0)",
5
- "main": "lib/index.js",
6
- "source": "src/index.js",
5
+ "main": "./lib/index.js",
6
+ "source": "./src/index.ts",
7
+ "types": "./lib/types/index.d.ts",
7
8
  "publishConfig": {
8
9
  "access": "public"
9
10
  },
10
11
  "dependencies": {
11
- "@atlaspack/logger": "2.14.5-canary.2+88fcaf47c",
12
- "@atlaspack/utils": "2.14.5-canary.2+88fcaf47c",
12
+ "@atlaspack/logger": "2.14.5-canary.200+10ee3fa5b",
13
+ "@atlaspack/utils": "2.14.5-canary.200+10ee3fa5b",
14
+ "@parcel/watcher": "^2.4.1",
15
+ "@types/fb-watchman": "^2.0.2",
13
16
  "fb-watchman": "^2.0.2"
14
17
  },
15
- "devDependencies": {
16
- "@parcel/watcher": "^2.4.1"
17
- },
18
18
  "type": "commonjs",
19
- "gitHead": "88fcaf47c77a6b7a16003028dd65a4b7a1f19dd7"
20
- }
19
+ "scripts": {
20
+ "check-ts": "tsc --emitDeclarationOnly --rootDir src",
21
+ "build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
22
+ },
23
+ "gitHead": "10ee3fa5b75a92acde8973673d9b3c5b6f3958e5"
24
+ }
@@ -1,6 +1,7 @@
1
1
  import {AtlaspackWatcherWatchmanJS} from './wrapper';
2
+ import type {Watcher} from './wrapper';
2
3
 
3
- const wrapper = new AtlaspackWatcherWatchmanJS();
4
+ const wrapper: Watcher = new AtlaspackWatcherWatchmanJS();
4
5
 
5
6
  export const writeSnapshot = wrapper.writeSnapshot.bind(wrapper);
6
7
  export const getEventsSince = wrapper.getEventsSince.bind(wrapper);
@@ -1,4 +1,3 @@
1
- // @flow
2
1
  import * as fs from 'fs';
3
2
  import * as path from 'path';
4
3
  import * as watchman from 'fb-watchman';
@@ -42,39 +41,44 @@ export interface Watcher {
42
41
  export class AtlaspackWatcherWatchmanJS implements Watcher {
43
42
  subscriptionName: string;
44
43
  client: watchman.Client;
45
- initPromise: Promise<void> | void;
44
+ initPromise: Promise<void> | undefined;
46
45
 
47
46
  constructor() {
48
47
  this.subscriptionName = 'parcel-watcher-subscription-' + Date.now();
49
48
  this.client = new watchman.Client();
50
49
  }
51
50
 
52
- commandAsync(args: any[]): Promise<any> {
53
- return new Promise((resolve, reject) => {
54
- const client = this.client;
55
- client.command(
56
- args,
57
- // $FlowFixMe
58
- (err: Error | null | undefined, response: any) => {
51
+ commandAsync(args: WatchmanArgs): Promise<any> {
52
+ return new Promise(
53
+ (
54
+ resolve: (result: Promise<never>) => void,
55
+ reject: (error?: any) => void,
56
+ ) => {
57
+ const client = this.client;
58
+ client.command(args, (err: Error | null | undefined, response: any) => {
59
59
  if (err) reject(err);
60
60
  else resolve(response);
61
- },
62
- );
63
- });
61
+ });
62
+ },
63
+ );
64
64
  }
65
65
 
66
66
  capabilityCheckAsync(args: any): Promise<any> {
67
- return new Promise((resolve, reject) => {
68
- const client = this.client;
69
- client.capabilityCheck(
70
- args,
71
- // $FlowFixMe
72
- (err: Error | null | undefined, response: any) => {
73
- if (err) reject(err);
74
- else resolve(response);
75
- },
76
- );
77
- });
67
+ return new Promise(
68
+ (
69
+ resolve: (result: Promise<never>) => void,
70
+ reject: (error?: any) => void,
71
+ ) => {
72
+ const client = this.client;
73
+ client.capabilityCheck(
74
+ args,
75
+ (err: Error | null | undefined, response: any) => {
76
+ if (err) reject(err);
77
+ else resolve(response);
78
+ },
79
+ );
80
+ },
81
+ );
78
82
  }
79
83
  async _init(watchDir: string): Promise<void> {
80
84
  await this.capabilityCheckAsync({optional: [], required: []});
@@ -146,17 +150,19 @@ export class AtlaspackWatcherWatchmanJS implements Watcher {
146
150
  ];
147
151
 
148
152
  if (ignore) {
149
- const customIgnores = ignore?.map((filePathOrGlob) => {
150
- const relative = path.relative(dir, filePathOrGlob);
153
+ const customIgnores = ignore?.map(
154
+ (filePathOrGlob: FilePath | GlobPattern) => {
155
+ const relative = path.relative(dir, filePathOrGlob);
151
156
 
152
- if (isGlob(filePathOrGlob)) {
153
- return ['match', relative, 'wholename'];
154
- }
157
+ if (isGlob(filePathOrGlob)) {
158
+ return ['match', relative, 'wholename'];
159
+ }
155
160
 
156
- // If pattern is not a glob, then assume it's a directory.
157
- // Ignoring single files is not currently supported
158
- return ['dirname', relative];
159
- });
161
+ // If pattern is not a glob, then assume it's a directory.
162
+ // Ignoring single files is not currently supported
163
+ return ['dirname', relative];
164
+ },
165
+ );
160
166
 
161
167
  ignores.push(...customIgnores);
162
168
  }
@@ -190,7 +196,7 @@ export class AtlaspackWatcherWatchmanJS implements Watcher {
190
196
  },
191
197
  ]);
192
198
 
193
- this.client.on('subscription', function (resp) {
199
+ this.client.on('subscription', function (resp: any) {
194
200
  if (!resp.files || resp.subscription !== subscriptionName) {
195
201
  return;
196
202
  }
package/tsconfig.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "include": ["src"]
4
+ }
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;ACyCO,MAAMA;IAKXY,aAAc;QACZ,IAAI,CAACC,gBAAgB,GAAG,iCAAiCC,KAAKC,GAAG;QACjE,IAAI,CAACC,MAAM,GAAG,IAAIP;IACpB;IAEAS,aAAaC,IAAW,EAAgB;QACtC,OAAO,IAAIC,QAAQ,CAACC,SAASC;YAC3B,MAAMN,SAAS,IAAI,CAACA,MAAM;YAC1BA,OAAOO,OAAO,CACZJ,MACA,aAAA;YACA,CAACK,KAA+BC;gBAC9B,IAAID,KAAKF,OAAOE;qBACXH,QAAQI;YACf;QAEJ;IACF;IAEAC,qBAAqBP,IAAS,EAAgB;QAC5C,OAAO,IAAIC,QAAQ,CAACC,SAASC;YAC3B,MAAMN,SAAS,IAAI,CAACA,MAAM;YAC1BA,OAAOW,eAAe,CACpBR,MACA,aAAA;YACA,CAACK,KAA+BC;gBAC9B,IA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,CAAC,gBAAgB,SAAUlC,IAAI;YAC3C,IAAI,CAACA,KAAKqB,KAAK,IAAIrB,KAAKmC,YAAY,KAAKtD,kBACvC;YAGFoD,GACE,MACAjC,KAAKqB,KAAK,CAACC,GAAG,CAAEC,CAAAA;gBACd,OAAO;oBACL/C,MAAMA,iBAAU8B,KAAKiB,KAAKC,IAAI;oBAC9BC,MAAMF,KAAKG,GAAG,GAAG,WAAWH,KAAKI,MAAM,GAAG,WAAW;gBACvD;YACF;QAEJ;QAEA,MAAMrD,cAAc;YAClB,MAAM,IAAI,CAACY,YAAY,CAAC;gBAAC;gBAAeoB;gBAAKzB;aAAiB;QAChE;QAEA,OAAO;yBACLP;QACF;IACF;IAEA,MAAMA,YAAYgC,GAAW,EAAiB;QAC5C,MAAM,IAAI,CAACpB,YAAY,CAAC;YAAC;YAAeoB;YAAK,IAAI,CAACzB,gBAAgB;SAAC;IACrE;AACF;;;AD1NA,MAAMZ,gCAAU,IAAID,CAAAA,GAAAA,yCAAAA;AAEb,MAAME,4CAAgBD,8BAAQC,aAAa,CAACC,IAAI,CAACF;AACjD,MAAMG,4CAAiBH,8BAAQG,cAAc,CAACD,IAAI,CAACF;AACnD,MAAMI,4CAAYJ,8BAAQI,SAAS,CAACF,IAAI,CAACF;AACzC,MAAMK,4CAAcL,8BAAQK,WAAW,CAACH,IAAI,CAACF","sources":["packages/utils/atlaspack-watcher-watchman-js/src/index.js","packages/utils/atlaspack-watcher-watchman-js/src/wrapper.js"],"sourcesContent":["import {AtlaspackWatcherWatchmanJS} from './wrapper';\n\nconst wrapper = new AtlaspackWatcherWatchmanJS();\n\nexport const writeSnapshot = wrapper.writeSnapshot.bind(wrapper);\nexport const getEventsSince = wrapper.getEventsSince.bind(wrapper);\nexport const subscribe = wrapper.subscribe.bind(wrapper);\nexport const unsubscribe = wrapper.unsubscribe.bind(wrapper);\n","// @flow\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as watchman from 'fb-watchman';\nimport {isGlob} from '@atlaspack/utils';\nimport logger from '@atlaspack/logger';\nimport type {\n Options,\n Event,\n SubscribeCallback,\n AsyncSubscription,\n} from '@parcel/watcher';\n\ntype WatchmanArgs = any;\ntype FilePath = string;\ntype GlobPattern = string;\n\n// Matches the Watcher API from \"@parcel/watcher\"\nexport interface Watcher {\n getEventsSince(\n dir: FilePath,\n snapshot: FilePath,\n opts?: Options,\n ): Promise<Array<Event>>;\n subscribe(\n dir: FilePath,\n fn: SubscribeCallback,\n opts?: Options,\n ): Promise<AsyncSubscription>;\n unsubscribe(\n dir: FilePath,\n fn: SubscribeCallback,\n opts?: Options,\n ): Promise<void>;\n writeSnapshot(\n dir: FilePath,\n snapshot: FilePath,\n opts?: Options,\n ): Promise<FilePath>;\n}\n\nexport class AtlaspackWatcherWatchmanJS implements Watcher {\n subscriptionName: string;\n client: watchman.Client;\n initPromise: Promise<void> | void;\n\n constructor() {\n this.subscriptionName = 'parcel-watcher-subscription-' + Date.now();\n this.client = new watchman.Client();\n }\n\n commandAsync(args: any[]): Promise<any> {\n return new Promise((resolve, reject) => {\n const client = this.client;\n client.command(\n args,\n // $FlowFixMe\n (err: Error | null | undefined, response: any) => {\n if (err) reject(err);\n else resolve(response);\n },\n );\n });\n }\n\n capabilityCheckAsync(args: any): Promise<any> {\n return new Promise((resolve, reject) => {\n const client = this.client;\n client.capabilityCheck(\n args,\n // $FlowFixMe\n (err: Error | null | undefined, response: any) => {\n if (err) reject(err);\n else resolve(response);\n },\n );\n });\n }\n async _init(watchDir: string): Promise<void> {\n await this.capabilityCheckAsync({optional: [], required: []});\n const resp = await this.commandAsync(['watch-project', watchDir]);\n\n if ('warning' in resp) {\n logger.warn({message: resp.warning});\n }\n }\n\n init(watchDir: string): Promise<void> {\n if (this.initPromise) {\n return this.initPromise;\n }\n\n this.initPromise = this._init(watchDir);\n\n return this.initPromise;\n }\n\n // Types should match @parcel/watcher/index.js.flow\n async writeSnapshot(dir: string, snapshot: FilePath): Promise<string> {\n await this.init(dir);\n\n const response = await this.commandAsync(['clock', dir]);\n fs.mkdirSync(path.dirname(snapshot), {recursive: true});\n fs.writeFileSync(snapshot, response.clock, {\n encoding: 'utf-8',\n });\n return response.clock;\n }\n\n async getEventsSince(\n dir: string,\n snapshot: FilePath,\n opts?: Options,\n ): Promise<Event[]> {\n await this.init(dir);\n\n const clock = fs.readFileSync(snapshot, {\n encoding: 'utf-8',\n });\n\n const response = await this.commandAsync([\n 'query',\n dir,\n {\n expression: this._createExpression(dir, opts?.ignore),\n fields: ['name', 'mode', 'exists', 'new'],\n since: clock,\n },\n ]);\n\n return (response.files || []).map((file: any) => ({\n path: file.name,\n type: file.new ? 'create' : file.exists ? 'update' : 'delete',\n }));\n }\n\n _createExpression(\n dir: string,\n ignore?: Array<FilePath | GlobPattern>,\n ): WatchmanArgs {\n const ignores = [\n // Ignore the watchman cookie\n ['match', '.watchman-cookie-*'],\n // Ignore directory changes as they are just noise\n ['type', 'd'],\n ];\n\n if (ignore) {\n const customIgnores = ignore?.map((filePathOrGlob) => {\n const relative = path.relative(dir, filePathOrGlob);\n\n if (isGlob(filePathOrGlob)) {\n return ['match', relative, 'wholename'];\n }\n\n // If pattern is not a glob, then assume it's a directory.\n // Ignoring single files is not currently supported\n return ['dirname', relative];\n });\n\n ignores.push(...customIgnores);\n }\n\n return ['not', ['anyof', ...ignores]];\n }\n\n async subscribe(\n dir: string,\n fn: SubscribeCallback,\n opts?: Options,\n ): Promise<AsyncSubscription> {\n await this.init(dir);\n\n const {subscriptionName} = this;\n const {clock} = await this.commandAsync(['clock', dir]);\n\n await this.commandAsync([\n 'subscribe',\n dir,\n subscriptionName,\n {\n // `defer` can be used here if you want to pause the\n // notification stream until something has finished.\n //\n // https://facebook.github.io/watchman/docs/cmd/subscribe#defer\n // defer: ['my-company-example'],\n expression: this._createExpression(dir, opts?.ignore),\n fields: ['name', 'mode', 'exists', 'new'],\n since: clock,\n },\n ]);\n\n this.client.on('subscription', function (resp) {\n if (!resp.files || resp.subscription !== subscriptionName) {\n return;\n }\n\n fn(\n null /* err */,\n resp.files.map((file: any) => {\n return {\n path: path.join(dir, file.name),\n type: file.new ? 'create' : file.exists ? 'update' : 'delete',\n };\n }),\n );\n });\n\n const unsubscribe = async () => {\n await this.commandAsync(['unsubscribe', dir, subscriptionName]);\n };\n\n return {\n unsubscribe,\n };\n }\n\n async unsubscribe(dir: string): Promise<void> {\n await this.commandAsync(['unsubscribe', dir, this.subscriptionName]);\n }\n}\n"],"names":["AtlaspackWatcherWatchmanJS","wrapper","writeSnapshot","bind","getEventsSince","subscribe","unsubscribe","fs","path","watchman","isGlob","logger","constructor","subscriptionName","Date","now","client","Client","commandAsync","args","Promise","resolve","reject","command","err","response","capabilityCheckAsync","capabilityCheck","_init","watchDir","optional","required","resp","warn","message","warning","init","initPromise","dir","snapshot","mkdirSync","dirname","recursive","writeFileSync","clock","encoding","opts","readFileSync","expression","_createExpression","ignore","fields","since","files","map","file","name","type","new","exists","ignores","customIgnores","filePathOrGlob","relative","push","fn","on","subscription","join"],"version":3,"file":"index.js.map"}