webpack-dev-service 0.12.0 → 0.12.2

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 (63) hide show
  1. package/cjs/client/client.cjs +1 -1
  2. package/cjs/client/events.cjs +1 -1
  3. package/cjs/client/hot.cjs +1 -1
  4. package/cjs/client/index.cjs +1 -1
  5. package/cjs/client/main.cjs +1 -1
  6. package/cjs/client/ui/Overlay.cjs +1 -1
  7. package/cjs/client/ui/Progress.cjs +1 -1
  8. package/cjs/client/ui/utils.cjs +1 -1
  9. package/cjs/server/compose.cjs +1 -1
  10. package/cjs/server/dev/Service.cjs +31 -113
  11. package/cjs/server/dev/index.cjs +1 -1
  12. package/cjs/server/dev/middleware.cjs +8 -8
  13. package/cjs/server/dev/utils/fs.cjs +1 -1
  14. package/cjs/server/dev/utils/hash.cjs +3 -3
  15. package/cjs/server/dev/utils/http.cjs +22 -19
  16. package/cjs/server/dev/utils/path.cjs +5 -5
  17. package/cjs/server/dev/utils/paths.cjs +3 -3
  18. package/cjs/server/dev/utils/ready.cjs +1 -1
  19. package/cjs/server/dev/utils/setupHooks.cjs +1 -1
  20. package/cjs/server/dev/utils/setupOutputFileSystem.cjs +1 -1
  21. package/cjs/server/dev/utils/setupWatching.cjs +1 -1
  22. package/cjs/server/dev/utils/setupWriteToDisk.cjs +6 -6
  23. package/cjs/server/dev/utils/stream.cjs +189 -0
  24. package/cjs/server/hot/Socket.cjs +8 -7
  25. package/cjs/server/hot/index.cjs +1 -1
  26. package/cjs/server/hot/utils.cjs +1 -1
  27. package/cjs/server/index.cjs +1 -1
  28. package/cjs/server/schema.cjs +1 -1
  29. package/cjs/server/utils.cjs +1 -1
  30. package/esm/client/client.js +1 -1
  31. package/esm/client/events.js +1 -1
  32. package/esm/client/hot.js +1 -1
  33. package/esm/client/index.js +1 -1
  34. package/esm/client/main.js +1 -1
  35. package/esm/client/ui/Overlay.js +1 -1
  36. package/esm/client/ui/Progress.js +1 -1
  37. package/esm/client/ui/utils.js +1 -1
  38. package/esm/server/compose.js +1 -1
  39. package/esm/server/dev/Service.js +22 -103
  40. package/esm/server/dev/index.js +1 -1
  41. package/esm/server/dev/middleware.js +8 -8
  42. package/esm/server/dev/utils/fs.js +1 -1
  43. package/esm/server/dev/utils/hash.js +2 -2
  44. package/esm/server/dev/utils/http.js +22 -19
  45. package/esm/server/dev/utils/path.js +2 -2
  46. package/esm/server/dev/utils/paths.js +2 -2
  47. package/esm/server/dev/utils/ready.js +1 -1
  48. package/esm/server/dev/utils/setupHooks.js +1 -1
  49. package/esm/server/dev/utils/setupOutputFileSystem.js +1 -1
  50. package/esm/server/dev/utils/setupWatching.js +1 -1
  51. package/esm/server/dev/utils/setupWriteToDisk.js +3 -3
  52. package/esm/server/dev/utils/stream.js +187 -0
  53. package/esm/server/hot/Socket.js +4 -3
  54. package/esm/server/hot/index.js +1 -1
  55. package/esm/server/hot/utils.js +1 -1
  56. package/esm/server/index.js +1 -1
  57. package/esm/server/schema.js +1 -1
  58. package/esm/server/utils.js +1 -1
  59. package/package.json +10 -11
  60. package/types/server/dev/Service.d.ts +15 -32
  61. package/types/server/dev/utils/fs.d.ts +7 -12
  62. package/types/server/dev/utils/http.d.ts +6 -11
  63. package/types/server/dev/utils/stream.d.ts +83 -0
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.12.0
4
+ * @version 0.12.2
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
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.12.0
4
+ * @version 0.12.2
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
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.12.0
4
+ * @version 0.12.2
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
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.12.0
4
+ * @version 0.12.2
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
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.12.0
4
+ * @version 0.12.2
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
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.12.0
4
+ * @version 0.12.2
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
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.12.0
4
+ * @version 0.12.2
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
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.12.0
4
+ * @version 0.12.2
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
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.12.0
4
+ * @version 0.12.2
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
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.12.0
4
+ * @version 0.12.2
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
@@ -9,12 +9,11 @@
9
9
 
10
10
  'use strict';
11
11
 
12
- const createEtag = require('etag');
13
- const destroy = require('destroy');
14
- const stream = require('stream');
12
+ const createETag = require('etag');
15
13
  const utils = require('../utils.cjs');
16
14
  const fs = require('./utils/fs.cjs');
17
- const path$1 = require('path');
15
+ const stream = require('./utils/stream.cjs');
16
+ const node_path = require('node:path');
18
17
  const path = require('./utils/path.cjs');
19
18
  const http = require('./utils/http.cjs');
20
19
 
@@ -22,8 +21,7 @@ function _interopDefault(e) {
22
21
  return e && e.__esModule ? e : { default: e };
23
22
  }
24
23
 
25
- const createEtag__default = /*#__PURE__*/ _interopDefault(createEtag);
26
- const destroy__default = /*#__PURE__*/ _interopDefault(destroy);
24
+ const createETag__default = /*#__PURE__*/ _interopDefault(createETag);
27
25
 
28
26
  /**
29
27
  * @module Service
@@ -37,18 +35,18 @@ class Service {
37
35
  /**
38
36
  * @constructor
39
37
  * @description Create file service.
40
- * @param root File service root.
41
- * @param options File service options.
38
+ * @param root The file service root.
39
+ * @param options The file service options.
42
40
  */
43
41
  constructor(root, options) {
44
42
  this.options = options;
45
- this.root = path.unixify(path$1.resolve(root));
43
+ this.root = path.unixify(node_path.resolve(root));
46
44
  }
47
45
  /**
48
46
  * @private
49
47
  * @method isIgnore
50
48
  * @description Check if path is ignore.
51
- * @param path File path.
49
+ * @param path The path to check.
52
50
  */
53
51
  isIgnore(path) {
54
52
  const { ignore } = this.options;
@@ -57,10 +55,10 @@ class Service {
57
55
  /**
58
56
  * @private
59
57
  * @method setupHeaders
60
- * @description Setup headers
61
- * @param context Koa context
62
- * @param path File path
63
- * @param stats File stats
58
+ * @description Setup headers.
59
+ * @param context The koa context.
60
+ * @param path The file path.
61
+ * @param stats The file stats.
64
62
  */
65
63
  setupHeaders(context, path, stats) {
66
64
  const { options } = this;
@@ -68,7 +66,7 @@ class Service {
68
66
  // Set status.
69
67
  context.status = 200;
70
68
  // Set Content-Type.
71
- context.type = path$1.extname(path);
69
+ context.type = node_path.extname(path);
72
70
  // Accept-Ranges.
73
71
  if (options.acceptRanges === false) {
74
72
  // Set Accept-Ranges to none tell client not support.
@@ -83,7 +81,7 @@ class Service {
83
81
  context.remove('ETag');
84
82
  } else {
85
83
  // Set ETag.
86
- context.set('ETag', createEtag__default.default(stats));
84
+ context.set('ETag', createETag__default.default(stats));
87
85
  }
88
86
  // Last-Modified.
89
87
  if (options.lastModified === false) {
@@ -105,97 +103,15 @@ class Service {
105
103
  }
106
104
  }
107
105
  }
108
- /**
109
- * @private
110
- * @method write
111
- * @description Write file to stream.
112
- * @param stream Destination stream.
113
- * @param path The file path to read.
114
- * @param range The range to read.
115
- * @param end Is destory destination stream after read complete.
116
- */
117
- write(stream, path, range, end) {
118
- const { fs } = this.options;
119
- return new Promise(resolve => {
120
- // Range prefix and suffix.
121
- const { prefix, suffix } = range;
122
- // Create file stream reader.
123
- const reader = fs.createReadStream(path, range);
124
- // File read stream open.
125
- if (prefix) {
126
- reader.once('open', () => {
127
- // Write prefix boundary.
128
- stream.write(prefix);
129
- });
130
- }
131
- // File read stream end.
132
- if (suffix) {
133
- reader.once('end', () => {
134
- // Push suffix boundary.
135
- stream.write(suffix);
136
- });
137
- }
138
- // File read stream error.
139
- reader.once('error', () => {
140
- // End stream.
141
- stream.end();
142
- // Unpipe.
143
- reader.unpipe();
144
- // Destroy.
145
- destroy__default.default(reader);
146
- // Resolve.
147
- resolve(false);
148
- });
149
- // File read stream close.
150
- reader.once('close', () => {
151
- // Unpipe.
152
- reader.unpipe();
153
- // Destroy.
154
- destroy__default.default(reader);
155
- // Resolve.
156
- resolve(true);
157
- });
158
- // Write data to buffer.
159
- reader.pipe(stream, { end });
160
- });
161
- }
162
- /**
163
- * @private
164
- * @method send
165
- * @description Send file.
166
- * @param context Koa context.
167
- * @param path File path.
168
- * @param ranges Read ranges.
169
- */
170
- async send(context, path, ranges) {
171
- // Set stream body, highWaterMark 64kb.
172
- const stream$1 = new stream.PassThrough({
173
- highWaterMark: 65536
174
- });
175
- // Set response body.
176
- context.body = stream$1;
177
- // Ranges length.
178
- let { length } = ranges;
179
- // Write ranges to stream.
180
- for (const range of ranges) {
181
- // Write range.
182
- const passed = await this.write(stream$1, path, range, --length === 0);
183
- // If not passed, break.
184
- if (!passed) {
185
- break;
186
- }
187
- }
188
- }
189
106
  /**
190
107
  * @public
191
- * @method response
192
- * @description Response to koa context.
193
- * @param context Koa context.
194
- * @param publicPath Public path.
108
+ * @method respond
109
+ * @description Respond file.
110
+ * @param pathname The pathname.
111
+ * @param context The koa context.
112
+ * @param publicPath The public path.
195
113
  */
196
- async response(context, publicPath) {
197
- // Get request pathname.
198
- const pathname = context.path || '/';
114
+ async respond(pathname, context, publicPath) {
199
115
  // Check public path.
200
116
  if (!pathname.startsWith(publicPath)) {
201
117
  return false;
@@ -207,17 +123,17 @@ class Service {
207
123
  // Real pathname.
208
124
  const realpath = pathname.slice(length);
209
125
  // Get path of file.
210
- const path$2 = path.unixify(path$1.join(root, realpath));
126
+ const path$1 = path.unixify(node_path.join(root, realpath));
211
127
  // Malicious path (403).
212
- if (path.isOutRoot(path$2, root)) {
128
+ if (path.isOutRoot(path$1, root)) {
213
129
  return false;
214
130
  }
215
131
  // Is ignore path or file (403).
216
- if (this.isIgnore(path$2)) {
132
+ if (this.isIgnore(path$1)) {
217
133
  return false;
218
134
  }
219
135
  // File stats.
220
- const stats = await fs.stat(this.options.fs, path$2);
136
+ const stats = await fs.stat(this.options.fs, path$1);
221
137
  // Check file stats.
222
138
  if (
223
139
  // File not exist (404 | 500).
@@ -225,12 +141,12 @@ class Service {
225
141
  // Is directory (403).
226
142
  stats.isDirectory() ||
227
143
  // Not a directory but has trailing slash (404).
228
- path.hasTrailingSlash(path$2)
144
+ path.hasTrailingSlash(path$1)
229
145
  ) {
230
146
  return false;
231
147
  }
232
148
  // Setup headers.
233
- this.setupHeaders(context, path$2, stats);
149
+ this.setupHeaders(context, path$1, stats);
234
150
  // Conditional get support.
235
151
  if (http.isConditionalGET(context)) {
236
152
  // Request precondition failure.
@@ -269,8 +185,10 @@ class Service {
269
185
  if (ranges === -2) {
270
186
  return context.throw(400);
271
187
  }
272
- // Send file.
273
- this.send(context, path$2, ranges);
188
+ // Ranges length.
189
+ const { fs: fs$1, highWaterMark } = this.options;
190
+ // Set response body.
191
+ context.body = new stream.FileReadStream(path$1, ranges, { fs: fs$1, highWaterMark });
274
192
  // File found.
275
193
  return true;
276
194
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.12.0
4
+ * @version 0.12.2
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
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.12.0
4
+ * @version 0.12.2
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
@@ -46,7 +46,7 @@ function getFileServices(context, stats) {
46
46
  // Return services.
47
47
  return services;
48
48
  }
49
- function getFileServicesAsync(context, path) {
49
+ function getFileServicesAsync(context, pathname) {
50
50
  return new Promise(resolve => {
51
51
  const { stats } = context;
52
52
  // If stats exists, resolve immediately.
@@ -54,7 +54,7 @@ function getFileServicesAsync(context, path) {
54
54
  resolve(getFileServices(context, stats));
55
55
  } else {
56
56
  // Log waiting info.
57
- context.logger.info(`wait until bundle finished: ${path}`);
57
+ context.logger.info(`wait until bundle finished: ${pathname}`);
58
58
  // Otherwise, wait until bundle finished.
59
59
  ready.ready(context, stats => {
60
60
  resolve(getFileServices(context, stats));
@@ -65,18 +65,18 @@ function getFileServicesAsync(context, path) {
65
65
  function middleware(context) {
66
66
  // Middleware.
67
67
  return async (ctx, next) => {
68
- const path = http.decodeURI(ctx.path);
69
- // Path -1 or null byte(s).
70
- if (path === -1 || path.includes('\0')) {
68
+ const pathname = http.decodeURI(ctx.path);
69
+ // Pathname decode failed or includes null byte(s).
70
+ if (pathname === -1 || pathname.includes('\0')) {
71
71
  return ctx.throw(400);
72
72
  }
73
73
  // Only support GET and HEAD (405).
74
74
  if (ctx.method === 'GET' || ctx.method === 'HEAD') {
75
75
  // Get the file services.
76
- const services = await getFileServicesAsync(context, path);
76
+ const services = await getFileServicesAsync(context, pathname);
77
77
  // Try to respond.
78
78
  for (const [publicPath, service] of services) {
79
- if (await service.response(ctx, publicPath)) {
79
+ if (await service.respond(pathname, ctx, publicPath)) {
80
80
  return;
81
81
  }
82
82
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.12.0
4
+ * @version 0.12.2
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
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.12.0
4
+ * @version 0.12.2
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
@@ -9,7 +9,7 @@
9
9
 
10
10
  'use strict';
11
11
 
12
- const crypto = require('crypto');
12
+ const node_crypto = require('node:crypto');
13
13
 
14
14
  /**
15
15
  * @module hash
@@ -34,7 +34,7 @@ const CHARS = [
34
34
  */
35
35
  function generate(length = 32) {
36
36
  let hash = '';
37
- const randomValues = crypto.getRandomValues(new Uint8Array(length));
37
+ const randomValues = node_crypto.getRandomValues(new Uint8Array(length));
38
38
  // Create hash.
39
39
  for (const value of randomValues) {
40
40
  hash += CHARS[value % 62];
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.12.0
4
+ * @version 0.12.2
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
@@ -10,6 +10,7 @@
10
10
  'use strict';
11
11
 
12
12
  const hash = require('./hash.cjs');
13
+ const node_buffer = require('node:buffer');
13
14
  const parseRange = require('range-parser');
14
15
 
15
16
  function _interopDefault(e) {
@@ -108,7 +109,7 @@ function decodeURI(URI) {
108
109
  /**
109
110
  * @function isConditionalGET
110
111
  * @description Check if request is conditional GET.
111
- * @param context Koa context.
112
+ * @param context The koa context.
112
113
  */
113
114
  function isConditionalGET(context) {
114
115
  const { request } = context;
@@ -122,7 +123,7 @@ function isConditionalGET(context) {
122
123
  /**
123
124
  * @function isPreconditionFailure
124
125
  * @description Check if request precondition failure.
125
- * @param context Koa context.
126
+ * @param context The koa context.
126
127
  */
127
128
  function isPreconditionFailure({ request, response }) {
128
129
  // If-Match.
@@ -147,8 +148,8 @@ function isPreconditionFailure({ request, response }) {
147
148
  /**
148
149
  * @function parseRanges
149
150
  * @description Parse ranges.
150
- * @param context Koa context.
151
- * @param stats File stats.
151
+ * @param context The koa context.
152
+ * @param stats The file stats.
152
153
  */
153
154
  function parseRanges(context, stats) {
154
155
  const { size } = stats;
@@ -175,42 +176,44 @@ function parseRanges(context, stats) {
175
176
  let contentLength = 0;
176
177
  // Ranges.
177
178
  const ranges = [];
179
+ // Parsed entries.
180
+ const entries = parsed.entries();
178
181
  // Range boundary.
179
182
  const boundary = `<${hash.generate()}>`;
180
- // Range suffix.
181
- const suffix = `\r\n--${boundary}--\r\n`;
182
183
  // Multipart Content-Type.
183
184
  const contentType = `Content-Type: ${context.type}`;
185
+ // Range suffix.
186
+ const suffix = node_buffer.Buffer.from(`\r\n--${boundary}--\r\n`);
184
187
  // Override Content-Type.
185
188
  context.type = `multipart/byteranges; boundary=${boundary}`;
186
189
  // Map ranges.
187
- for (let index = 0; index < length; index++) {
188
- const { start, end } = parsed[index];
189
- // The first prefix boundary no \r\n.
190
+ for (const [index, { start, end }] of entries) {
191
+ const length = end - start + 1;
190
192
  const head = index > 0 ? '\r\n' : '';
191
193
  const contentRange = `Content-Range: bytes ${start}-${end}/${size}`;
192
- const prefix = `${head}--${boundary}\r\n${contentType}\r\n${contentRange}\r\n\r\n`;
194
+ const prefix = node_buffer.Buffer.from(`${head}--${boundary}\r\n${contentType}\r\n${contentRange}\r\n\r\n`);
193
195
  // Compute Content-Length
194
- contentLength += end - start + 1 + Buffer.byteLength(prefix);
196
+ contentLength += length + prefix.length;
195
197
  // Cache range.
196
- ranges.push({ start, end, prefix });
198
+ ranges.push({ offset: start, length, prefix });
197
199
  }
198
- // The last add suffix boundary.
199
- ranges[length - 1].suffix = suffix;
200
200
  // Compute Content-Length.
201
- contentLength += Buffer.byteLength(suffix);
201
+ contentLength += suffix.length;
202
202
  // Set Content-Length.
203
203
  context.length = contentLength;
204
+ // The last add suffix boundary.
205
+ ranges[length - 1].suffix = suffix;
204
206
  // Return ranges.
205
207
  return ranges;
206
208
  } else {
207
209
  const [{ start, end }] = parsed;
210
+ const length = end - start + 1;
208
211
  // Set Content-Length.
209
- context.length = end - start + 1;
212
+ context.length = length;
210
213
  // Set Content-Range.
211
214
  context.set('Content-Range', `bytes ${start}-${end}/${size}`);
212
215
  // Return ranges.
213
- return parsed;
216
+ return [{ offset: start, length }];
214
217
  }
215
218
  }
216
219
  }
@@ -218,7 +221,7 @@ function parseRanges(context, stats) {
218
221
  // Set Content-Length.
219
222
  context.length = size;
220
223
  // Return ranges.
221
- return [{ start: 0, end: Math.max(size - 1) }];
224
+ return [{ offset: 0, length: size }];
222
225
  }
223
226
 
224
227
  exports.decodeURI = decodeURI;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.12.0
4
+ * @version 0.12.2
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
@@ -9,7 +9,7 @@
9
9
 
10
10
  'use strict';
11
11
 
12
- const path = require('path');
12
+ const node_path = require('node:path');
13
13
 
14
14
  /**
15
15
  * @module path
@@ -36,9 +36,9 @@ function hasTrailingSlash(path) {
36
36
  * @param path The path to check.
37
37
  * @param root The root path.
38
38
  */
39
- function isOutRoot(path$1, root) {
40
- path$1 = path.relative(root, path$1);
41
- return /\.\.(?:[\\/]|$)/.test(path$1) || path.isAbsolute(path$1);
39
+ function isOutRoot(path, root) {
40
+ path = node_path.relative(root, path);
41
+ return /\.\.(?:[\\/]|$)/.test(path) || node_path.isAbsolute(path);
42
42
  }
43
43
 
44
44
  exports.hasTrailingSlash = hasTrailingSlash;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.12.0
4
+ * @version 0.12.2
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
@@ -9,7 +9,7 @@
9
9
 
10
10
  'use strict';
11
11
 
12
- const url = require('url');
12
+ const node_url = require('node:url');
13
13
  const path = require('./path.cjs');
14
14
 
15
15
  /**
@@ -39,7 +39,7 @@ function getPublicPath(compilation) {
39
39
  const path = compilation.getPath(publicPath ?? '');
40
40
  // Get public path without protocol.
41
41
  try {
42
- return new url.URL(path).pathname;
42
+ return new node_url.URL(path).pathname;
43
43
  } catch {
44
44
  return normalize(path);
45
45
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.12.0
4
+ * @version 0.12.2
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
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.12.0
4
+ * @version 0.12.2
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
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.12.0
4
+ * @version 0.12.2
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
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.12.0
4
+ * @version 0.12.2
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