0.10.3 • Published 9 months ago

@e-mc/watch v0.10.3

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
9 months ago

@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

LICENSE

BSD 3-Clause

0.5.10

12 months ago

0.5.11

12 months ago

0.5.16

9 months ago

0.5.14

9 months ago

0.5.15

9 months ago

0.5.12

11 months ago

0.5.13

10 months ago

0.9.8

11 months ago

0.7.11

12 months ago

0.9.7

11 months ago

0.7.10

12 months ago

0.7.13

11 months ago

0.9.9

11 months ago

0.7.12

11 months ago

0.9.4

1 year ago

0.5.8

1 year ago

0.9.3

1 year ago

0.5.7

1 year ago

0.9.6

12 months ago

0.5.9

12 months ago

0.9.5

1 year ago

0.7.15

9 months ago

0.7.14

10 months ago

0.7.17

9 months ago

0.7.16

9 months ago

0.10.1

11 months ago

0.10.2

10 months ago

0.10.3

9 months ago

0.10.0

11 months ago

0.9.12

9 months ago

0.9.13

9 months ago

0.6.7

12 months ago

0.6.6

12 months ago

0.9.10

10 months ago

0.6.9

11 months ago

0.9.11

9 months ago

0.6.8

12 months ago

0.6.10

11 months ago

0.6.12

9 months ago

0.6.11

10 months ago

0.6.14

9 months ago

0.6.13

9 months ago

0.9.2

1 year ago

0.7.9

12 months ago

0.8.21

9 months ago

0.7.8

1 year ago

0.8.20

9 months ago

0.7.7

1 year ago

0.8.12

1 year ago

0.8.11

1 year ago

0.8.14

12 months ago

0.8.13

12 months ago

0.8.19

9 months ago

0.8.16

11 months ago

0.8.15

12 months ago

0.8.18

10 months ago

0.8.17

11 months ago

0.6.5

1 year ago

0.6.4

1 year ago

0.8.9

1 year ago

0.8.8

1 year ago

0.7.6

1 year ago

0.7.5

1 year ago

0.8.10

1 year ago

0.6.3

1 year ago

0.7.4

1 year ago

0.5.6

1 year ago

0.9.1

1 year ago

0.9.0

1 year ago

0.8.7

1 year ago

0.6.2

1 year ago

0.7.3

1 year ago

0.5.5

1 year ago

0.8.6

1 year ago

0.7.2

1 year ago

0.5.4

1 year ago

0.6.1

1 year ago

0.8.5

1 year ago

0.8.4

1 year ago

0.8.3

1 year ago

0.8.2

1 year ago

0.8.1

2 years ago

0.8.0

2 years ago

0.7.1

2 years ago

0.7.0

2 years ago

0.6.0

2 years ago

0.5.3

2 years ago

0.5.2

2 years ago

0.5.1

2 years ago

0.5.0

2 years ago

0.4.2

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.3.3

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago