@e-mc/watch v0.10.3
@e-mc/watch
- NodeJS 16
- ES2020
General Usage
Interface
import type { IFileManager, ModuleConstructor } from "./index";
import type { ExternalAsset } from "./asset";
import type { HostInitConfig, IClient, IPermission } from "./core";
import type { FinalizeResult, PostFinalizeCallback } from "./filemanager";
import type { WatchModule } from "./settings";
import type { IFileGroup, ModifiedPostFinalizeListener, SecureOptions } from "./watch";
import type * as ws from "ws";
interface IWatch extends IClient<IFileManager, WatchModule, ModifiedPostFinalizeListener> {
connectTimeout: number;
init(config?: HostInitConfig): this;
start(assets: ExternalAsset[], permission?: IPermission | null): void;
modified(watch: IFileGroup<ExternalAsset>): Promise<FinalizeResult | void>;
configureServer(options: SecureOptions): boolean;
setCA(value: string): boolean;
setSSLKey(value: string): boolean;
setSSLCert(value: string): boolean;
hasSecureProtocol(): boolean;
whenModified?(assets: ExternalAsset[], postFinalize: PostFinalizeCallback): IFileManager;
whenModified?(assets: ExternalAsset[], sanitize?: boolean, postFinalize?: PostFinalizeCallback): IFileManager;
set assets(value: ExternalAsset[]);
get assets(): ExternalAsset[];
set interval(value);
get interval(): number;
set port(value);
get port(): number;
set securePort(value);
get securePort(): number;
}
interface WatchConstructor extends ModuleConstructor {
createServer(port: number, active: boolean): ws.Server | null;
createServer(port: number, secure?: SecureOptions | null, active?: boolean): ws.Server | null;
shutdown(): void;
setTimeout(value: number | string): void;
checkTimeout(client: ws): boolean;
readonly prototype: IWatch;
new(module?: WatchModule): IWatch;
}
Settings
import type { PermittedDirectories } from "./core";
import type { SecureVersion } from "tls";
interface WatchModule {
// handler: "@e-mc/watch";
extensions?: string[];
timeout?: number | string;
interval?: number | string;
port?: number;
secure?: {
port?: number;
ca?: string;
key?: string;
cert?: string;
passphrase?: string;
ciphers?: string;
version?: SecureVersion;
};
settings?: {
broadcast_id?: string | string[];
users?: Record<string, Record<string, unknown>>;
};
permission?: PermittedDirectories;
}
Example usage
const Watch = require("@e-mc/watch");
const instance = new Watch({ interval: 100, port: 8080 });
instance.init();
instance.whenModified = (assets) => {
assets.forEach(item => console.log(item.uri));
};
const assets = [
{ localUri: "/path/workspace/output/image1.png", uri: "http://hostname/path/document1.png", watch: true },
{ localUri: "/path/workspace/output/image2.png", uri: "http://hostname/path/document2.png", watch: true }
];
instance.start(assets, { disk_read: ["/path/workspace/output/**"] });
References
- https://www.unpkg.com/@e-mc/types@0.10.3/lib/asset.d.ts
- https://www.unpkg.com/@e-mc/types@0.10.3/lib/core.d.ts
- https://www.unpkg.com/@e-mc/types@0.10.3/lib/filemanager.d.ts
- https://www.unpkg.com/@e-mc/types@0.10.3/lib/settings.d.ts
- https://www.unpkg.com/@e-mc/types@0.10.3/lib/watch.d.ts
LICENSE
BSD 3-Clause
1 year ago
1 year ago
10 months ago
10 months ago
10 months ago
11 months ago
11 months ago
11 months ago
1 year ago
12 months ago
1 year ago
11 months ago
11 months ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
10 months ago
11 months ago
10 months ago
10 months ago
11 months ago
10 months ago
10 months ago
12 months ago
10 months ago
10 months ago
1 year ago
1 year ago
11 months ago
11 months ago
10 months ago
1 year ago
11 months ago
10 months ago
11 months ago
10 months ago
10 months ago
1 year ago
1 year ago
10 months ago
1 year ago
10 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
10 months ago
11 months ago
1 year ago
11 months ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago