webpack-dev-service 0.13.2 → 0.14.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.
Files changed (148) hide show
  1. package/README.md +9 -8
  2. package/cjs/client/client.cjs +24 -9
  3. package/cjs/client/client.d.cts +14 -0
  4. package/cjs/client/events.cjs +1 -1
  5. package/cjs/client/events.d.cts +28 -0
  6. package/cjs/client/hot.cjs +19 -21
  7. package/cjs/client/hot.d.cts +16 -0
  8. package/cjs/client/index.cjs +1 -1
  9. package/cjs/client/index.d.cts +4 -0
  10. package/cjs/client/main.cjs +4 -3
  11. package/cjs/client/main.d.cts +4 -0
  12. package/cjs/client/ui/Overlay.cjs +1 -1
  13. package/cjs/client/ui/Overlay.d.cts +12 -0
  14. package/cjs/client/ui/Progress.cjs +1 -1
  15. package/cjs/client/ui/Progress.d.cts +12 -0
  16. package/cjs/client/ui/utils.cjs +1 -1
  17. package/cjs/client/ui/utils.d.cts +15 -0
  18. package/cjs/server/compose.cjs +13 -12
  19. package/cjs/server/compose.d.cts +18 -0
  20. package/cjs/server/dev/ReadStream.cjs +1 -1
  21. package/cjs/server/dev/ReadStream.d.cts +43 -0
  22. package/cjs/server/dev/Service.cjs +1 -1
  23. package/cjs/server/dev/Service.d.cts +48 -0
  24. package/cjs/server/dev/index.cjs +1 -1
  25. package/cjs/server/dev/index.d.cts +8 -0
  26. package/cjs/server/dev/interface.d.cts +38 -0
  27. package/cjs/server/dev/middleware.cjs +1 -1
  28. package/cjs/server/dev/middleware.d.cts +6 -0
  29. package/cjs/server/dev/utils/fs.cjs +1 -1
  30. package/cjs/server/dev/utils/fs.d.cts +24 -0
  31. package/cjs/server/dev/utils/hash.cjs +1 -1
  32. package/cjs/server/dev/utils/hash.d.cts +9 -0
  33. package/cjs/server/dev/utils/http.cjs +1 -1
  34. package/cjs/server/dev/utils/http.d.cts +37 -0
  35. package/cjs/server/dev/utils/path.cjs +1 -1
  36. package/cjs/server/dev/utils/path.d.cts +22 -0
  37. package/cjs/server/dev/utils/paths.cjs +1 -1
  38. package/cjs/server/dev/utils/paths.d.cts +7 -0
  39. package/cjs/server/dev/utils/ready.cjs +1 -1
  40. package/cjs/server/dev/utils/ready.d.cts +5 -0
  41. package/cjs/server/dev/utils/setupHooks.cjs +2 -5
  42. package/cjs/server/dev/utils/setupHooks.d.cts +5 -0
  43. package/cjs/server/dev/utils/setupOutputFileSystem.cjs +1 -1
  44. package/cjs/server/dev/utils/setupOutputFileSystem.d.cts +5 -0
  45. package/cjs/server/dev/utils/setupWatching.cjs +1 -1
  46. package/cjs/server/dev/utils/setupWatching.d.cts +5 -0
  47. package/cjs/server/dev/utils/setupWriteToDisk.cjs +2 -2
  48. package/cjs/server/dev/utils/setupWriteToDisk.d.cts +5 -0
  49. package/cjs/server/hot/Message.d.cts +49 -0
  50. package/cjs/server/hot/Socket.cjs +109 -97
  51. package/cjs/server/hot/Socket.d.cts +11 -0
  52. package/cjs/server/hot/index.cjs +3 -10
  53. package/cjs/server/hot/index.d.cts +8 -0
  54. package/cjs/server/hot/interface.d.cts +22 -0
  55. package/cjs/server/hot/utils.cjs +11 -36
  56. package/cjs/server/hot/utils.d.cts +12 -0
  57. package/cjs/server/index.cjs +8 -2
  58. package/cjs/server/index.d.cts +17 -0
  59. package/cjs/server/interface.d.cts +14 -0
  60. package/cjs/server/schema.cjs +1 -1
  61. package/cjs/server/schema.d.cts +7 -0
  62. package/cjs/server/utils.cjs +1 -5
  63. package/cjs/server/utils.d.cts +11 -0
  64. package/esm/client/client.d.ts +14 -0
  65. package/esm/client/client.js +25 -10
  66. package/esm/client/events.d.ts +28 -0
  67. package/esm/client/events.js +1 -1
  68. package/esm/client/hot.d.ts +16 -0
  69. package/esm/client/hot.js +19 -19
  70. package/esm/client/index.d.ts +4 -0
  71. package/esm/client/index.js +1 -1
  72. package/esm/client/main.d.ts +4 -0
  73. package/esm/client/main.js +4 -3
  74. package/esm/client/ui/Overlay.d.ts +12 -0
  75. package/esm/client/ui/Overlay.js +1 -1
  76. package/esm/client/ui/Progress.d.ts +12 -0
  77. package/esm/client/ui/Progress.js +1 -1
  78. package/esm/client/ui/utils.d.ts +15 -0
  79. package/esm/client/ui/utils.js +1 -1
  80. package/esm/server/compose.d.ts +18 -0
  81. package/esm/server/compose.js +13 -12
  82. package/esm/server/dev/ReadStream.d.ts +43 -0
  83. package/esm/server/dev/ReadStream.js +1 -1
  84. package/esm/server/dev/Service.d.ts +48 -0
  85. package/esm/server/dev/Service.js +1 -1
  86. package/esm/server/dev/index.d.ts +8 -0
  87. package/esm/server/dev/index.js +1 -1
  88. package/esm/server/dev/interface.d.ts +38 -0
  89. package/esm/server/dev/middleware.d.ts +6 -0
  90. package/esm/server/dev/middleware.js +1 -1
  91. package/esm/server/dev/utils/fs.d.ts +24 -0
  92. package/esm/server/dev/utils/fs.js +1 -1
  93. package/esm/server/dev/utils/hash.d.ts +9 -0
  94. package/esm/server/dev/utils/hash.js +1 -1
  95. package/esm/server/dev/utils/http.d.ts +37 -0
  96. package/esm/server/dev/utils/http.js +1 -1
  97. package/esm/server/dev/utils/path.d.ts +22 -0
  98. package/esm/server/dev/utils/path.js +1 -1
  99. package/esm/server/dev/utils/paths.d.ts +7 -0
  100. package/esm/server/dev/utils/paths.js +1 -1
  101. package/esm/server/dev/utils/ready.d.ts +5 -0
  102. package/esm/server/dev/utils/ready.js +1 -1
  103. package/esm/server/dev/utils/setupHooks.d.ts +5 -0
  104. package/esm/server/dev/utils/setupHooks.js +2 -5
  105. package/esm/server/dev/utils/setupOutputFileSystem.d.ts +5 -0
  106. package/esm/server/dev/utils/setupOutputFileSystem.js +1 -1
  107. package/esm/server/dev/utils/setupWatching.d.ts +5 -0
  108. package/esm/server/dev/utils/setupWatching.js +1 -1
  109. package/esm/server/dev/utils/setupWriteToDisk.d.ts +5 -0
  110. package/esm/server/dev/utils/setupWriteToDisk.js +2 -2
  111. package/{types/client → esm/server/hot}/Message.d.ts +15 -7
  112. package/esm/server/hot/Socket.d.ts +11 -0
  113. package/esm/server/hot/Socket.js +110 -98
  114. package/esm/server/hot/index.d.ts +8 -0
  115. package/esm/server/hot/index.js +3 -10
  116. package/esm/server/hot/interface.d.ts +22 -0
  117. package/esm/server/hot/utils.d.ts +12 -0
  118. package/esm/server/hot/utils.js +12 -38
  119. package/esm/server/index.d.ts +17 -0
  120. package/esm/server/index.js +8 -2
  121. package/esm/server/interface.d.ts +14 -0
  122. package/esm/server/schema.d.ts +7 -0
  123. package/esm/server/schema.js +1 -1
  124. package/esm/server/utils.d.ts +11 -0
  125. package/esm/server/utils.js +2 -5
  126. package/global.d.ts +2 -0
  127. package/package.json +20 -19
  128. package/types/client/client.d.ts +2 -1
  129. package/types/client/events.d.ts +2 -9
  130. package/types/client/hot.d.ts +3 -14
  131. package/types/server/compose.d.ts +2 -2
  132. package/types/server/dev/index.d.ts +1 -1
  133. package/types/server/dev/interface.d.ts +2 -2
  134. package/types/server/dev/utils/fs.d.ts +2 -4
  135. package/types/server/dev/utils/paths.d.ts +1 -1
  136. package/types/server/dev/utils/ready.d.ts +1 -1
  137. package/types/server/dev/utils/setupHooks.d.ts +1 -1
  138. package/types/server/dev/utils/setupOutputFileSystem.d.ts +1 -1
  139. package/types/server/dev/utils/setupWatching.d.ts +1 -1
  140. package/types/server/dev/utils/setupWriteToDisk.d.ts +1 -1
  141. package/types/server/hot/Message.d.ts +49 -0
  142. package/types/server/hot/Socket.d.ts +1 -4
  143. package/types/server/hot/index.d.ts +4 -4
  144. package/types/server/hot/interface.d.ts +8 -6
  145. package/types/server/hot/utils.d.ts +4 -4
  146. package/types/server/index.d.ts +6 -26
  147. package/types/server/interface.d.ts +3 -0
  148. package/types/server/utils.d.ts +0 -1
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @module ReadStream
3
+ */
4
+ import { PathLike } from 'node:fs';
5
+ import { Range } from './utils/http.js';
6
+ import { FileSystem } from './utils/fs.js';
7
+ import { Readable, ReadableOptions } from 'node:stream';
8
+ export interface Options extends Pick<ReadableOptions, 'highWaterMark'> {
9
+ fs: FileSystem;
10
+ }
11
+ interface Callback {
12
+ (error?: Error | null): void;
13
+ }
14
+ export declare class ReadStream extends Readable {
15
+ #private;
16
+ /**
17
+ * @constructor
18
+ * @param path The file path.
19
+ * @param ranges The ranges to read.
20
+ * @param options The stream options.
21
+ */
22
+ constructor(path: PathLike, ranges: Range[], options: Options);
23
+ /**
24
+ * @override
25
+ * @method _construct
26
+ * @param callback The callback.
27
+ */
28
+ _construct(callback: Callback): void;
29
+ /**
30
+ * @override
31
+ * @method _read
32
+ * @param size The number of bytes to read.
33
+ */
34
+ _read(size: number): void;
35
+ /**
36
+ * @override
37
+ * @method _destroy
38
+ * @param error The error.
39
+ * @param callback The callback.
40
+ */
41
+ _destroy(error: Error | null, callback: Callback): void;
42
+ }
43
+ export {};
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.13.2
4
+ * @version 0.14.0
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @module Service
3
+ */
4
+ import { Context } from 'koa';
5
+ import { Stats } from 'node:fs';
6
+ import { FileSystem } from './utils/fs.js';
7
+ interface IgnoreFunction {
8
+ (path: string): boolean;
9
+ }
10
+ interface Headers {
11
+ [key: string]: string | string[];
12
+ }
13
+ type FileStats = Stats | null | undefined;
14
+ interface HeadersFunction {
15
+ (path: string, stats: FileStats): Promise<Headers | void> | Headers | void;
16
+ }
17
+ export interface Options {
18
+ fs: FileSystem;
19
+ etag?: boolean;
20
+ acceptRanges?: boolean;
21
+ lastModified?: boolean;
22
+ highWaterMark?: number;
23
+ ignore?: IgnoreFunction;
24
+ headers?: Headers | HeadersFunction;
25
+ }
26
+ /**
27
+ * @class Service
28
+ */
29
+ export declare class Service {
30
+ #private;
31
+ /**
32
+ * @constructor
33
+ * @description Create file service.
34
+ * @param root The file service root.
35
+ * @param options The file service options.
36
+ */
37
+ constructor(root: string, options: Options);
38
+ /**
39
+ * @public
40
+ * @method respond
41
+ * @description Respond file.
42
+ * @param pathname The pathname.
43
+ * @param context The koa context.
44
+ * @param publicPath The public path.
45
+ */
46
+ respond(pathname: string, context: Context, publicPath: string): Promise<boolean>;
47
+ }
48
+ export {};
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.13.2
4
+ * @version 0.14.0
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @module index
3
+ */
4
+ import { Middleware } from 'koa';
5
+ import { UnionCompiler } from '../interface.js';
6
+ import { Expose, Options } from './interface.js';
7
+ export { Expose, Options };
8
+ export declare function dev(compiler: UnionCompiler, options: Options): Middleware & Expose;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.13.2
4
+ * @version 0.14.0
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @module interface
3
+ */
4
+ import webpack from 'webpack';
5
+ import { FileSystem } from './utils/fs.js';
6
+ import { Options as ServiceOptions, Service } from './Service.js';
7
+ import { Logger, Optional, StatsOptions, UnionCompiler, UnionStats, UnionWatching } from '../interface.js';
8
+ export interface Callback {
9
+ (stats: UnionStats): void;
10
+ }
11
+ export interface ErrorCallback {
12
+ (error?: Error | null): void;
13
+ }
14
+ export interface Expose {
15
+ readonly logger: Logger;
16
+ readonly state: boolean;
17
+ readonly ready: (callback: Callback) => void;
18
+ readonly close: (callback: ErrorCallback) => void;
19
+ readonly invalidate: (callback: ErrorCallback) => void;
20
+ }
21
+ export type FileService = [publicPath: string, service: Service];
22
+ export interface Options extends Optional<ServiceOptions, 'fs'> {
23
+ stats?: StatsOptions;
24
+ writeToDisk?: boolean | ((targetPath: string) => boolean);
25
+ onCompilationDone?: (stats: UnionStats, statsOptions: Readonly<webpack.StatsOptions>) => void;
26
+ }
27
+ export interface Context {
28
+ logger: Logger;
29
+ callbacks: Callback[];
30
+ compiler: UnionCompiler;
31
+ watching: UnionWatching;
32
+ services?: FileService[];
33
+ stats: UnionStats | null;
34
+ options: Options & {
35
+ fs: FileSystem;
36
+ };
37
+ }
38
+ export type InitialContext = Optional<Context, 'watching'>;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @module middleware
3
+ */
4
+ import { Middleware } from 'koa';
5
+ import { Context } from './interface.js';
6
+ export declare function middleware(context: Context): Middleware;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.13.2
4
+ * @version 0.14.0
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @module fs
3
+ */
4
+ import webpack from 'webpack';
5
+ import fs, { Stats } from 'node:fs';
6
+ import { GetProp } from '../../interface.js';
7
+ export interface FileSystem extends GetProp<webpack.Compiler, 'outputFileSystem'> {
8
+ stat: typeof fs.stat;
9
+ open: typeof fs.open;
10
+ read: typeof fs.read;
11
+ close: typeof fs.close;
12
+ }
13
+ /**
14
+ * @function createMemfs
15
+ * @description Create memfs instance.
16
+ */
17
+ export declare function createMemfs(): FileSystem;
18
+ /**
19
+ * @function stat
20
+ * @description Get file stats.
21
+ * @param fs The file system to used.
22
+ * @param path The file path.
23
+ */
24
+ export declare function stat(fs: FileSystem, path: string): Promise<Stats | null>;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.13.2
4
+ * @version 0.14.0
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @module hash
3
+ */
4
+ /**
5
+ * @function generate
6
+ * @description Generate a hash.
7
+ * @param length The length of hash.
8
+ */
9
+ export declare function generate(length: number): string;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.13.2
4
+ * @version 0.14.0
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @module http
3
+ */
4
+ import { Context } from 'koa';
5
+ import { Stats } from 'node:fs';
6
+ import { Buffer } from 'node:buffer';
7
+ export interface Range {
8
+ offset: number;
9
+ length: number;
10
+ prefix?: Buffer;
11
+ suffix?: Buffer;
12
+ }
13
+ /**
14
+ * @function decodeURI
15
+ * @description Decode URI component.
16
+ * @param URI The URI to decode.
17
+ */
18
+ export declare function decodeURI(URI: string): string | -1;
19
+ /**
20
+ * @function isConditionalGET
21
+ * @description Check if request is conditional GET.
22
+ * @param context The koa context.
23
+ */
24
+ export declare function isConditionalGET({ request }: Context): boolean;
25
+ /**
26
+ * @function isPreconditionFailed
27
+ * @description Check if request precondition failed.
28
+ * @param context The koa context.
29
+ */
30
+ export declare function isPreconditionFailed({ request, response }: Context): boolean;
31
+ /**
32
+ * @function parseRanges
33
+ * @description Parse ranges.
34
+ * @param context The koa context.
35
+ * @param stats The file stats.
36
+ */
37
+ export declare function parseRanges(context: Context, stats: Stats): Range[] | -1 | -2;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.13.2
4
+ * @version 0.14.0
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @module path
3
+ */
4
+ /**
5
+ * @function unixify
6
+ * @description Convert path to unix style.
7
+ * @param path The path to convert.
8
+ */
9
+ export declare function unixify(path: string): string;
10
+ /**
11
+ * @function hasTrailingSlash
12
+ * @description Check if path has trailing slash.
13
+ * @param path The path to check.
14
+ */
15
+ export declare function hasTrailingSlash(path: string): boolean;
16
+ /**
17
+ * @function isOutRoot
18
+ * @description Check if path is out of root.
19
+ * @param path The path to check.
20
+ * @param root The root path.
21
+ */
22
+ export declare function isOutRoot(path: string, root: string): boolean;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.13.2
4
+ * @version 0.14.0
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @module paths
3
+ */
4
+ import { UnionStats } from '../../interface.js';
5
+ type PathsItem = [outputPath: string, publicPath: string];
6
+ export declare function getPaths(stats: UnionStats): PathsItem[];
7
+ export {};
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.13.2
4
+ * @version 0.14.0
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @module ready
3
+ */
4
+ import { Callback, Context } from '../interface.js';
5
+ export declare function ready({ stats, callbacks }: Context, callback: Callback): void;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.13.2
4
+ * @version 0.14.0
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @module setupHooks
3
+ */
4
+ import { InitialContext } from '../interface.js';
5
+ export declare function setupHooks(context: InitialContext): void;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.13.2
4
+ * @version 0.14.0
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -30,7 +30,7 @@ function normalizeStatsOptions(statsOptions) {
30
30
  function getStatsOptions(context) {
31
31
  const { compiler } = context;
32
32
  const { stats } = context.options;
33
- if (stats) {
33
+ if (stats != null) {
34
34
  if (isMultiCompiler(compiler)) {
35
35
  return {
36
36
  children: compiler.compilers.map(() => {
@@ -55,8 +55,6 @@ function setupHooks(context) {
55
55
  const invalid = () => {
56
56
  // We are now in invalid state.
57
57
  context.stats = null;
58
- };
59
- const watchRun = () => {
60
58
  // Log compilation starting.
61
59
  context.logger.log('compilation starting...');
62
60
  };
@@ -94,7 +92,6 @@ function setupHooks(context) {
94
92
  };
95
93
  hooks.done.tap(PLUGIN_NAME, done);
96
94
  hooks.invalid.tap(PLUGIN_NAME, invalid);
97
- hooks.watchRun.tap(PLUGIN_NAME, watchRun);
98
95
  }
99
96
 
100
97
  export { setupHooks };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @module setupOutputFileSystem
3
+ */
4
+ import { InitialContext } from '../interface.js';
5
+ export declare function setupOutputFileSystem(context: InitialContext): void;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.13.2
4
+ * @version 0.14.0
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @module setupWatching
3
+ */
4
+ import { InitialContext } from '../interface.js';
5
+ export declare function setupWatching(context: InitialContext): void;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.13.2
4
+ * @version 0.14.0
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @module setupWriteToDisk
3
+ */
4
+ import { InitialContext } from '../interface.js';
5
+ export declare function setupWriteToDisk(context: InitialContext): void;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.13.2
4
+ * @version 0.14.0
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -15,7 +15,7 @@ import { getCompilers, PLUGIN_NAME, isFunction } from '../../utils.js';
15
15
  * @module setupWriteToDisk
16
16
  */
17
17
  function getCompilerName({ options: { name } }) {
18
- return name ? `compiler "${name}": ` : '';
18
+ return `compiler ${name ? `${name}: ` : ''}`;
19
19
  }
20
20
  function isAllowWrite(targetPath, filter) {
21
21
  return isFunction(filter) ? filter(targetPath) : filter === true;
@@ -2,14 +2,15 @@
2
2
  * @module message
3
3
  */
4
4
  import webpack from 'webpack';
5
- export interface InvalidMessage {
5
+ import { GetProp } from '../interface.js';
6
+ export interface Invalid {
6
7
  action: 'invalid';
7
8
  payload: {
8
- path: string;
9
9
  timestamp: number;
10
+ path: string | null;
10
11
  };
11
12
  }
12
- export interface ProgressMessage {
13
+ export interface Progress {
13
14
  action: 'progress';
14
15
  payload: {
15
16
  status: string;
@@ -17,14 +18,14 @@ export interface ProgressMessage {
17
18
  percentage: number;
18
19
  };
19
20
  }
20
- export interface HashMessage {
21
+ export interface Hash {
21
22
  action: 'hash';
22
23
  payload: {
23
24
  hash: string;
24
25
  timestamp: number;
25
26
  };
26
27
  }
27
- export interface IssuesMessage {
28
+ export interface Issues {
28
29
  action: 'issues';
29
30
  payload: {
30
31
  timestamp: number;
@@ -32,10 +33,17 @@ export interface IssuesMessage {
32
33
  warnings: webpack.StatsError[];
33
34
  };
34
35
  }
35
- export interface OkMessage {
36
+ export interface Ok {
36
37
  action: 'ok';
37
38
  payload: {
38
39
  timestamp: number;
39
40
  };
40
41
  }
41
- export type Message = InvalidMessage | ProgressMessage | HashMessage | IssuesMessage | OkMessage;
42
+ export interface Messages {
43
+ ok: GetProp<Ok, 'payload'>;
44
+ hash: GetProp<Hash, 'payload'>;
45
+ issues: GetProp<Issues, 'payload'>;
46
+ invalid: GetProp<Invalid, 'payload'>;
47
+ progress: GetProp<Progress, 'payload'>;
48
+ }
49
+ export type Message = Invalid | Progress | Hash | Issues | Ok;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @module Socket
3
+ */
4
+ import { Context } from 'koa';
5
+ import { UnionCompiler } from '../interface.js';
6
+ import { Options } from './interface.js';
7
+ export declare class Socket {
8
+ #private;
9
+ constructor(compiler: UnionCompiler, options?: Options);
10
+ upgrade(context: Context): boolean;
11
+ }