@lwrjs/fs-watch 0.11.0-alpha.11
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 +10 -0
- package/build/cjs/index.cjs +43 -0
- package/build/es/index.d.ts +17 -0
- package/build/es/index.js +27 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
MIT LICENSE
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020, Salesforce.com, Inc.
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
7
|
+
|
|
8
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
9
|
+
|
|
10
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, {get: all[name], enumerable: true});
|
|
11
|
+
};
|
|
12
|
+
var __exportStar = (target, module2, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
16
|
+
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toModule = (module2) => {
|
|
21
|
+
return __exportStar(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// packages/@lwrjs/fs-watch/src/index.ts
|
|
25
|
+
__markAsModule(exports);
|
|
26
|
+
__export(exports, {
|
|
27
|
+
WatcherFactoryImpl: () => WatcherFactoryImpl
|
|
28
|
+
});
|
|
29
|
+
var import_chokidar = __toModule(require("chokidar"));
|
|
30
|
+
var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
|
|
31
|
+
var import_diagnostics = __toModule(require("@lwrjs/diagnostics"));
|
|
32
|
+
var WatcherFactoryImpl = class {
|
|
33
|
+
createFileWatcher(options = {persistent: true, ignored: "**/node_modules/**"}) {
|
|
34
|
+
return import_chokidar.default.watch([], options);
|
|
35
|
+
}
|
|
36
|
+
setupWatcher(onModuleChange) {
|
|
37
|
+
const fileWatcher = this.createFileWatcher();
|
|
38
|
+
fileWatcher.on("change", (0, import_shared_utils.debounce)((file) => onModuleChange(file), 500));
|
|
39
|
+
fileWatcher.on("unlink", (0, import_shared_utils.debounce)((file) => onModuleChange(file), 500));
|
|
40
|
+
fileWatcher.on("add", (file) => import_diagnostics.logger.info(`Watching: ${file}`));
|
|
41
|
+
return fileWatcher;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Watcher, WatcherFactory, WatchOptions } from '@lwrjs/types';
|
|
2
|
+
/**
|
|
3
|
+
* Factory comptable with the LWR Runtime to create a file watch library for LWR dev server.
|
|
4
|
+
* When importing this module make sure the optional library 'chokidar' is installed.
|
|
5
|
+
*/
|
|
6
|
+
export declare class WatcherFactoryImpl implements WatcherFactory {
|
|
7
|
+
/**
|
|
8
|
+
* Set up a watcher with the given options
|
|
9
|
+
* @param options
|
|
10
|
+
*/
|
|
11
|
+
createFileWatcher(options?: WatchOptions): Watcher;
|
|
12
|
+
/**
|
|
13
|
+
* Set up file watcher
|
|
14
|
+
*/
|
|
15
|
+
setupWatcher(onModuleChange: Function): Watcher;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import chokidar from 'chokidar';
|
|
2
|
+
import { debounce } from '@lwrjs/shared-utils';
|
|
3
|
+
import { logger } from '@lwrjs/diagnostics';
|
|
4
|
+
/**
|
|
5
|
+
* Factory comptable with the LWR Runtime to create a file watch library for LWR dev server.
|
|
6
|
+
* When importing this module make sure the optional library 'chokidar' is installed.
|
|
7
|
+
*/
|
|
8
|
+
export class WatcherFactoryImpl {
|
|
9
|
+
/**
|
|
10
|
+
* Set up a watcher with the given options
|
|
11
|
+
* @param options
|
|
12
|
+
*/
|
|
13
|
+
createFileWatcher(options = { persistent: true, ignored: '**/node_modules/**' }) {
|
|
14
|
+
return chokidar.watch([], options);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Set up file watcher
|
|
18
|
+
*/
|
|
19
|
+
setupWatcher(onModuleChange) {
|
|
20
|
+
const fileWatcher = this.createFileWatcher();
|
|
21
|
+
fileWatcher.on('change', debounce((file) => onModuleChange(file), 500));
|
|
22
|
+
fileWatcher.on('unlink', debounce((file) => onModuleChange(file), 500));
|
|
23
|
+
fileWatcher.on('add', (file) => logger.info(`Watching: ${file}`));
|
|
24
|
+
return fileWatcher;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lwrjs/fs-watch",
|
|
3
|
+
"license": "MIT",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"version": "0.11.0-alpha.11",
|
|
8
|
+
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/salesforce-experience-platform-emu/lwr.git",
|
|
12
|
+
"directory": "packages/@lwrjs/fs-watch"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/salesforce-experience-platform-emu/lwr/issues"
|
|
16
|
+
},
|
|
17
|
+
"type": "module",
|
|
18
|
+
"types": "build/es/index.d.ts",
|
|
19
|
+
"main": "build/cjs/index.cjs",
|
|
20
|
+
"module": "build/es/index.js",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"import": "./build/es/index.js",
|
|
24
|
+
"require": "./build/cjs/index.cjs"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"build/**/*.js",
|
|
29
|
+
"build/**/*.cjs",
|
|
30
|
+
"build/**/*.d.ts"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsc -b",
|
|
34
|
+
"clean": "rm -rf build node_modules",
|
|
35
|
+
"test": "jest"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@lwrjs/types": "0.11.0-alpha.11",
|
|
39
|
+
"jest": "^26.6.3",
|
|
40
|
+
"ts-jest": "^26.5.6",
|
|
41
|
+
"typescript": "^4.9.5"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@lwrjs/diagnostics": "0.11.0-alpha.11",
|
|
45
|
+
"@lwrjs/shared-utils": "0.11.0-alpha.11",
|
|
46
|
+
"chokidar": "^3.5.3"
|
|
47
|
+
},
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=16.0.0"
|
|
50
|
+
},
|
|
51
|
+
"volta": {
|
|
52
|
+
"extends": "../../../package.json"
|
|
53
|
+
},
|
|
54
|
+
"gitHead": "acb9df6ee7887b683e28ad43e00df311256d6018"
|
|
55
|
+
}
|