@atlaspack/watcher-watchman-js 2.14.18-noselfbuild-3f2849b52.0 → 2.14.18-noselfbuild-342bd6c75.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/package.json +4 -4
- package/lib/index.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/watcher-watchman-js",
|
|
3
|
-
"version": "2.14.18-noselfbuild-
|
|
3
|
+
"version": "2.14.18-noselfbuild-342bd6c75.0",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"source": "src/index.js",
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@atlaspack/logger": "2.14.13-noselfbuild-
|
|
12
|
-
"@atlaspack/utils": "2.16.2-noselfbuild-
|
|
11
|
+
"@atlaspack/logger": "2.14.13-noselfbuild-342bd6c75.0",
|
|
12
|
+
"@atlaspack/utils": "2.16.2-noselfbuild-342bd6c75.0",
|
|
13
13
|
"fb-watchman": "^2.0.2"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@parcel/watcher": "^2.4.1"
|
|
17
17
|
},
|
|
18
18
|
"type": "commonjs",
|
|
19
|
-
"gitHead": "
|
|
19
|
+
"gitHead": "342bd6c75293750e0f0a7636ddc8dfe30707efb6"
|
|
20
20
|
}
|
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,QAA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ages/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"}
|