0.9.1 • Published 9 days ago
@e-mc/watch v0.9.1
@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;
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.9.1/lib/asset.d.ts
- https://www.unpkg.com/@e-mc/types@0.9.1/lib/core.d.ts
- https://www.unpkg.com/@e-mc/types@0.9.1/lib/filemanager.d.ts
- https://www.unpkg.com/@e-mc/types@0.9.1/lib/settings.d.ts
- https://www.unpkg.com/@e-mc/types@0.9.1/lib/watch.d.ts
LICENSE
BSD 3-Clause
0.8.9
9 days ago
0.8.8
9 days ago
0.7.6
9 days ago
0.7.5
9 days ago
0.8.10
9 days ago
0.6.3
9 days ago
0.7.4
9 days ago
0.5.6
9 days ago
0.9.1
9 days ago
0.9.0
10 days ago
0.8.7
1 month ago
0.6.2
1 month ago
0.7.3
1 month ago
0.5.5
1 month ago
0.8.6
2 months ago
0.7.2
2 months ago
0.5.4
2 months ago
0.6.1
2 months ago
0.8.5
2 months ago
0.8.4
3 months ago
0.8.3
3 months ago
0.8.2
3 months ago
0.8.1
4 months ago
0.8.0
5 months ago
0.7.1
5 months ago
0.7.0
5 months ago
0.6.0
9 months ago
0.5.3
12 months ago
0.5.2
1 year ago
0.5.1
1 year ago
0.5.0
1 year ago
0.4.2
1 year ago
0.4.1
1 year ago
0.4.0
1 year ago
0.3.3
1 year ago
0.3.2
1 year ago
0.3.1
1 year ago
0.3.0
1 year ago
0.2.0
1 year ago
0.1.0
1 year ago
0.0.4
1 year ago
0.0.3
1 year ago
0.0.2
1 year ago
0.0.1
1 year ago