@ohos-ports/rsbuild-core 2.2.9-beta.0 → 2.3.3-beta.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 (68) hide show
  1. package/README.md +10 -0
  2. package/bin/rsbuild.js +3 -1
  3. package/compiled/@rstackjs/load-config/index.d.ts +10 -1
  4. package/compiled/@rstackjs/load-config/package.json +1 -1
  5. package/compiled/chokidar/index.d.ts +448 -161
  6. package/compiled/chokidar/package.json +1 -1
  7. package/compiled/css-loader/index.js +2 -2
  8. package/compiled/html-rspack-plugin/index.d.ts +16 -2
  9. package/compiled/html-rspack-plugin/index.js +78 -28
  10. package/compiled/http-proxy-middleware/index.d.ts +10 -10
  11. package/compiled/http-proxy-middleware/package.json +1 -1
  12. package/compiled/jiti/dist/babel.cjs +1 -1
  13. package/compiled/jiti/lib/jiti-cli.mjs +0 -0
  14. package/compiled/postcss/index.js +1 -1
  15. package/compiled/postcss/lib/declaration.d.ts +2 -2
  16. package/compiled/postcss/package.json +1 -1
  17. package/compiled/postcss-loader/index.js +6 -6
  18. package/compiled/rspack-chain/package.json +1 -1
  19. package/compiled/rspack-chain/types/index.d.ts +1 -0
  20. package/compiled/ws/index.d.ts +4 -0
  21. package/compiled/ws/package.json +1 -1
  22. package/dist/1.js +85 -0
  23. package/dist/chokidar.js +1 -1
  24. package/dist/client/hmr.js +31 -8
  25. package/dist/client/overlay.js +15 -11
  26. package/dist/cssUrlLoader.mjs +18 -7
  27. package/dist/defaultConfig.d.ts +7 -2
  28. package/dist/helpers/compilation.d.ts +2 -0
  29. package/dist/helpers/index.d.ts +1 -0
  30. package/dist/helpers/path.d.ts +9 -0
  31. package/dist/helpers/stats.d.ts +1 -0
  32. package/dist/helpers/workspace.d.ts +1 -0
  33. package/dist/hooks.d.ts +2 -1
  34. package/dist/http-proxy-middleware.js +4 -4
  35. package/dist/index.d.ts +1 -1
  36. package/dist/index.js +2 -1
  37. package/dist/launch-editor-middleware.js +1 -1
  38. package/dist/loader/cssUrlLoader.d.ts +1 -0
  39. package/dist/m.js +1902 -1681
  40. package/dist/m.js.LICENSE.txt +0 -13
  41. package/dist/manifest-plugin.js +1 -1
  42. package/dist/memfs.js +1 -1
  43. package/dist/open.js +2 -2
  44. package/dist/plugins/fileSize.d.ts +11 -0
  45. package/dist/server/assets-middleware/getFileFromUrl.d.ts +4 -1
  46. package/dist/server/assets-middleware/index.d.ts +2 -1
  47. package/dist/server/assets-middleware/middleware.d.ts +4 -6
  48. package/dist/server/assets-middleware/setupMemoryFileSystemCleanup.d.ts +3 -0
  49. package/dist/server/assets-middleware/setupOutputFileSystem.d.ts +1 -2
  50. package/dist/server/assets-middleware/setupWriteToDisk.d.ts +19 -7
  51. package/dist/server/browserLogs.d.ts +5 -2
  52. package/dist/server/devMiddlewares.d.ts +1 -1
  53. package/dist/server/gracefulShutdown.d.ts +1 -2
  54. package/dist/server/helper.d.ts +6 -3
  55. package/dist/server/hostCheck.d.ts +7 -0
  56. package/dist/server/socketServer.d.ts +18 -2
  57. package/dist/server/watchFiles.d.ts +3 -1
  58. package/dist/sirv.js +3 -2
  59. package/dist/trace-mapping.js +16 -14
  60. package/dist/transformLoader.mjs +10 -10
  61. package/dist/transformRawLoader.mjs +2 -2
  62. package/dist/types/config.d.ts +38 -6
  63. package/dist/types/hooks.d.ts +1 -0
  64. package/dist/types/plugin.d.ts +27 -4
  65. package/dist/types/rsbuild.d.ts +1 -1
  66. package/dist/workerLoader.mjs +3 -3
  67. package/dist/ws.js +2 -2
  68. package/package.json +9 -50
@@ -60,11 +60,17 @@ interface Hook<T = any, R = any, AdditionalOptions = UnsetAdditionalOptions> {
60
60
  withOptions(opt: TapOptions & IfSet<AdditionalOptions>): Hook<T, R, AdditionalOptions>;
61
61
  queryStageRange(stageRange: StageRange): QueriedHook<T, R, AdditionalOptions>;
62
62
  }
63
+ type AllStageTaps<Tap> = {
64
+ source: Tap[];
65
+ length: number;
66
+ taps: Tap[];
67
+ };
63
68
  declare class HookBase<T, R, AdditionalOptions = UnsetAdditionalOptions> implements Hook<T, R, AdditionalOptions> {
64
69
  args: ArgumentNames<AsArray<T>>;
65
70
  name?: string;
66
71
  taps: (FullTap & IfSet<AdditionalOptions>)[];
67
72
  interceptors: HookInterceptor<T, R, AdditionalOptions>[];
73
+ _allStageTaps: AllStageTaps<FullTap & IfSet<AdditionalOptions>> | undefined;
68
74
  constructor(args?: ArgumentNames<AsArray<T>>, name?: string);
69
75
  intercept(interceptor: HookInterceptor<T, R, AdditionalOptions>): void;
70
76
  _runRegisterInterceptors(options: FullTap & IfSet<AdditionalOptions>): FullTap & IfSet<AdditionalOptions>;
@@ -85,6 +91,14 @@ declare class HookBase<T, R, AdditionalOptions = UnsetAdditionalOptions> impleme
85
91
  tapPromise(options: Options<AdditionalOptions>, fn: FnPromise<T, R>): void;
86
92
  _tap(type: 'sync' | 'async' | 'promise', options: Options<AdditionalOptions>, fn: TapFunction): void;
87
93
  _insert(item: FullTap & IfSet<AdditionalOptions>): void;
94
+ /**
95
+ * The taps `queryStageRange(allStageRange)` would select, reused across calls.
96
+ *
97
+ * `tap()` always grows `this.taps`, and code that replaces or splices it changes its
98
+ * identity or length, so both are checked. An interceptor's `register` rewrites taps in
99
+ * place, but hooks with interceptors never take the path that reads this.
100
+ */
101
+ _tapsInAllStages(): (FullTap & IfSet<AdditionalOptions>)[];
88
102
  _prepareArgs(args: AsArray<T>): (T | undefined)[];
89
103
  }
90
104
  type StageRange = readonly [number, number];
@@ -98,9 +112,9 @@ declare class QueriedHook<T, R, AdditionalOptions = UnsetAdditionalOptions> {
98
112
  callAsync(...args: Append<AsArray<T>, Callback<Error, R>>): void;
99
113
  promise(...args: AsArray<T>): Promise<R>;
100
114
  }
101
- declare class AsyncSeriesWaterfallHook<T, AdditionalOptions = UnsetAdditionalOptions> extends HookBase<T, AsArray<T>[0], AdditionalOptions> {
115
+ declare class AsyncSeriesWaterfallHook<T, R = AsArray<T>[0], AdditionalOptions = UnsetAdditionalOptions> extends HookBase<T, R, AdditionalOptions> {
102
116
  constructor(args?: ArgumentNames<AsArray<T>>, name?: string);
103
- callAsyncStageRange(queried: QueriedHook<T, AsArray<T>[0], AdditionalOptions>, ...args: Append<AsArray<T>, Callback<Error, AsArray<T>[0]>>): void;
117
+ callAsyncStageRange(queried: QueriedHook<T, R, AdditionalOptions>, ...args: Append<AsArray<T>, Callback<Error, R>>): void;
104
118
  }
105
119
 
106
120
  declare class HtmlRspackPlugin {
@@ -1,8 +1,8 @@
1
1
  (() => {
2
2
  var __webpack_modules__ = {
3
- 535: (module, __unused_webpack_exports, __nccwpck_require__) => {
3
+ 428: (module, __unused_webpack_exports, __nccwpck_require__) => {
4
4
  "use strict";
5
- const { HtmlWebpackChildCompiler } = __nccwpck_require__(284);
5
+ const { HtmlWebpackChildCompiler } = __nccwpck_require__(297);
6
6
  const compilerMap = new WeakMap();
7
7
  class CachedChildCompilation {
8
8
  constructor(compiler) {
@@ -307,7 +307,7 @@
307
307
  }
308
308
  module.exports = { CachedChildCompilation };
309
309
  },
310
- 284: (module) => {
310
+ 297: (module) => {
311
311
  "use strict";
312
312
  class HtmlWebpackChildCompiler {
313
313
  compilationPromise;
@@ -476,7 +476,7 @@
476
476
  }
477
477
  module.exports = { HtmlWebpackChildCompiler };
478
478
  },
479
- 876: (module) => {
479
+ 455: (module) => {
480
480
  "use strict";
481
481
  function none(chunks) {
482
482
  return chunks;
@@ -492,7 +492,7 @@
492
492
  }
493
493
  module.exports = { auto: none, manual, none };
494
494
  },
495
- 123: (module) => {
495
+ 34: (module) => {
496
496
  "use strict";
497
497
  module.exports = function (err) {
498
498
  return {
@@ -516,9 +516,9 @@
516
516
  };
517
517
  };
518
518
  },
519
- 90: (module, __unused_webpack_exports, __nccwpck_require__) => {
519
+ 649: (module, __unused_webpack_exports, __nccwpck_require__) => {
520
520
  "use strict";
521
- const { AsyncSeriesWaterfallHook } = __nccwpck_require__(176);
521
+ const { AsyncSeriesWaterfallHook } = __nccwpck_require__(537);
522
522
  const htmlWebpackPluginHooksMap = new WeakMap();
523
523
  function getHtmlRspackPluginHooks(compilation) {
524
524
  let hooks = htmlWebpackPluginHooksMap.get(compilation);
@@ -542,7 +542,7 @@
542
542
  }
543
543
  module.exports = { getHtmlRspackPluginHooks };
544
544
  },
545
- 527: (module) => {
545
+ 136: (module) => {
546
546
  const voidTags = [
547
547
  "area",
548
548
  "base",
@@ -610,19 +610,19 @@
610
610
  htmlTagObjectToString,
611
611
  };
612
612
  },
613
- 718: (module, __unused_webpack_exports, __nccwpck_require__) => {
613
+ 629: (module, __unused_webpack_exports, __nccwpck_require__) => {
614
614
  "use strict";
615
615
  const promisify = __nccwpck_require__(23).promisify;
616
616
  const vm = __nccwpck_require__(154);
617
617
  const fs = __nccwpck_require__(896);
618
618
  const path = __nccwpck_require__(928);
619
- const { CachedChildCompilation } = __nccwpck_require__(535);
619
+ const { CachedChildCompilation } = __nccwpck_require__(428);
620
620
  const { createHtmlTagObject, htmlTagObjectToString, HtmlTagArray } =
621
- __nccwpck_require__(527);
622
- const prettyError = __nccwpck_require__(123);
623
- const chunkSorter = __nccwpck_require__(876);
621
+ __nccwpck_require__(136);
622
+ const prettyError = __nccwpck_require__(34);
623
+ const chunkSorter = __nccwpck_require__(455);
624
624
  const getHtmlRspackPluginHooks =
625
- __nccwpck_require__(90).getHtmlRspackPluginHooks;
625
+ __nccwpck_require__(649).getHtmlRspackPluginHooks;
626
626
  const WITH_PLACEHOLDER = "function __with_placeholder__";
627
627
  class HtmlRspackPlugin {
628
628
  constructor(userOptions = {}) {
@@ -1520,7 +1520,7 @@
1520
1520
  "use strict";
1521
1521
  module.exports = require("vm");
1522
1522
  },
1523
- 176: (__unused_webpack_module, exports) => {
1523
+ 537: (__unused_webpack_module, exports) => {
1524
1524
  "use strict";
1525
1525
  var __nested_webpack_require_18__ = {};
1526
1526
  (() => {
@@ -1700,6 +1700,22 @@
1700
1700
  }
1701
1701
  this.taps[i] = item;
1702
1702
  }
1703
+ _tapsInAllStages() {
1704
+ const cached = this._allStageTaps;
1705
+ if (
1706
+ void 0 !== cached &&
1707
+ cached.source === this.taps &&
1708
+ cached.length === this.taps.length
1709
+ )
1710
+ return cached.taps;
1711
+ const taps = this.queryStageRange(allStageRange).tapsInRange;
1712
+ this._allStageTaps = {
1713
+ source: this.taps,
1714
+ length: this.taps.length,
1715
+ taps,
1716
+ };
1717
+ return taps;
1718
+ }
1703
1719
  _prepareArgs(args) {
1704
1720
  const len = this.args.length;
1705
1721
  if (args.length < len) {
@@ -1714,10 +1730,12 @@
1714
1730
  _define_property(this, "name", void 0);
1715
1731
  _define_property(this, "taps", void 0);
1716
1732
  _define_property(this, "interceptors", void 0);
1733
+ _define_property(this, "_allStageTaps", void 0);
1717
1734
  this.args = args;
1718
1735
  this.name = name;
1719
1736
  this.taps = [];
1720
1737
  this.interceptors = [];
1738
+ this._allStageTaps = void 0;
1721
1739
  }
1722
1740
  }
1723
1741
  const minStage = -1 / 0;
@@ -1801,10 +1819,18 @@
1801
1819
  }
1802
1820
  }
1803
1821
  call(...args) {
1804
- return this.callStageRange(
1805
- this.queryStageRange(allStageRange),
1806
- ...args,
1807
- );
1822
+ if (this.interceptors.length > 0)
1823
+ return this.callStageRange(
1824
+ this.queryStageRange(allStageRange),
1825
+ ...args,
1826
+ );
1827
+ const taps = this._tapsInAllStages();
1828
+ const args2 = this._prepareArgs(args);
1829
+ try {
1830
+ for (let i = 0; i < taps.length; i++) taps[i].fn(...args2);
1831
+ } catch (e) {
1832
+ if (e) throw e;
1833
+ }
1808
1834
  }
1809
1835
  callStageRange(queried, ...args) {
1810
1836
  let result;
@@ -1854,10 +1880,21 @@
1854
1880
  }
1855
1881
  }
1856
1882
  call(...args) {
1857
- return this.callStageRange(
1858
- this.queryStageRange(allStageRange),
1859
- ...args,
1860
- );
1883
+ if (this.interceptors.length > 0)
1884
+ return this.callStageRange(
1885
+ this.queryStageRange(allStageRange),
1886
+ ...args,
1887
+ );
1888
+ const taps = this._tapsInAllStages();
1889
+ const args2 = this._prepareArgs(args);
1890
+ try {
1891
+ for (let i = 0; i < taps.length; i++) {
1892
+ const r = taps[i].fn(...args2);
1893
+ if (void 0 !== r) return r;
1894
+ }
1895
+ } catch (e) {
1896
+ if (e) throw e;
1897
+ }
1861
1898
  }
1862
1899
  callStageRange(queried, ...args) {
1863
1900
  let result;
@@ -1903,10 +1940,23 @@
1903
1940
  }
1904
1941
  }
1905
1942
  call(...args) {
1906
- return this.callStageRange(
1907
- this.queryStageRange(allStageRange),
1908
- ...args,
1909
- );
1943
+ if (this.interceptors.length > 0)
1944
+ return this.callStageRange(
1945
+ this.queryStageRange(allStageRange),
1946
+ ...args,
1947
+ );
1948
+ const taps = this._tapsInAllStages();
1949
+ const args2 = this._prepareArgs(args);
1950
+ try {
1951
+ for (let i = 0; i < taps.length; i++) {
1952
+ const r = taps[i].fn(...args2);
1953
+ if (void 0 !== r) args2[0] = r;
1954
+ }
1955
+ } catch (e) {
1956
+ if (e) throw e;
1957
+ return;
1958
+ }
1959
+ return args2[0];
1910
1960
  }
1911
1961
  callStageRange(queried, ...args) {
1912
1962
  let result;
@@ -2395,6 +2445,6 @@
2395
2445
  }
2396
2446
  if (typeof __nccwpck_require__ !== "undefined")
2397
2447
  __nccwpck_require__.ab = __dirname + "/";
2398
- var __webpack_exports__ = __nccwpck_require__(718);
2448
+ var __webpack_exports__ = __nccwpck_require__(629);
2399
2449
  module.exports = __webpack_exports__;
2400
2450
  })();
@@ -136,7 +136,7 @@ declare class ProxyServer<Req extends http__default.IncomingMessage | http2.Http
136
136
  * https://github.com/DefinitelyTyped/DefinitelyTyped/blob/6f529c6c67a447190f86bfbf894d1061e41e07b7/types/http-proxy-middleware/index.d.ts
137
137
  */
138
138
 
139
- type NextFunction<T = (err?: any) => void> = T;
139
+ type NextFunction<T = (err?: unknown) => void> = T;
140
140
  interface RequestHandler<TReq extends http.IncomingMessage = http.IncomingMessage, TRes extends http.ServerResponse = http.ServerResponse, TNext = NextFunction> {
141
141
  (req: TReq, res: TRes, next?: TNext): Promise<void>;
142
142
  upgrade: (req: TReq, socket: net.Socket, head: Buffer) => void;
@@ -149,15 +149,15 @@ interface Plugin<TReq extends http.IncomingMessage = http.IncomingMessage, TRes
149
149
  (proxyServer: ProxyServer<TReq, TRes>, options: Options<TReq, TRes>): void;
150
150
  }
151
151
  interface OnProxyEvent<TReq extends http.IncomingMessage = http.IncomingMessage, TRes extends http.ServerResponse = http.ServerResponse> {
152
- error?: (err: Error, req: TReq, res: TRes | net.Socket, target?: string | Partial<URL>) => void;
152
+ error?: (err: Error, req: TReq, res: TRes | net.Socket, target?: ProxyTarget) => void;
153
153
  proxyReq?: (proxyReq: http.ClientRequest, req: TReq, res: TRes, options: ProxyServerOptions) => void;
154
- proxyReqWs?: (proxyReq: http.ClientRequest, req: TReq, socket: net.Socket, options: ProxyServerOptions, head: any) => void;
154
+ proxyReqWs?: (proxyReq: http.ClientRequest, req: TReq, socket: net.Socket, options: ProxyServerOptions, head: Buffer) => void;
155
155
  proxyRes?: (proxyRes: TReq, req: TReq, res: TRes) => void | Promise<void>;
156
156
  open?: (proxySocket: net.Socket) => void;
157
- close?: (proxyRes: TReq, proxySocket: net.Socket, proxyHead: any) => void;
158
- start?: (req: TReq, res: TRes, target: string | Partial<URL>) => void;
157
+ close?: (proxyRes: TReq, proxySocket: net.Socket, proxyHead: Buffer) => void;
158
+ start?: (req: TReq, res: TRes, target: ProxyTarget) => void;
159
159
  end?: (req: TReq, res: TRes, proxyRes: TReq) => void;
160
- econnreset?: (err: Error, req: TReq, res: TRes, target: string | Partial<URL>) => void;
160
+ econnreset?: (err: Error, req: TReq, res: TRes, target: ProxyTarget) => void;
161
161
  }
162
162
  type Logger = Pick<Console, 'info' | 'warn' | 'error'>;
163
163
  type PathRewriteConfig<TReq extends http.IncomingMessage = http.IncomingMessage, TRes extends http.ServerResponse = http.ServerResponse> = {
@@ -254,7 +254,7 @@ interface Options<TReq extends http.IncomingMessage = http.IncomingMessage, TRes
254
254
  *
255
255
  * @link https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/router.md
256
256
  */
257
- router?: Record<string, ProxyServerOptions['target']> | ((req: TReq, res: TRes | undefined, options: Options<TReq, TRes>) => ProxyServerOptions['target']) | ((req: TReq, res: TRes | undefined, options: Options<TReq, TRes>) => Promise<ProxyServerOptions['target']>);
257
+ router?: Record<string, ProxyTarget> | ((req: TReq, res: TRes | undefined, options: Options<TReq, TRes>) => ProxyTarget) | ((req: TReq, res: TRes | undefined, options: Options<TReq, TRes>) => Promise<ProxyTarget>);
258
258
  /**
259
259
  * Log information from http-proxy-middleware
260
260
  * @example
@@ -345,7 +345,7 @@ interface Options<TReq extends http.IncomingMessage = http.IncomingMessage, TRes
345
345
  * @see https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/pathRewrite.md
346
346
  * @see https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/response-interceptor.md
347
347
  */
348
- declare function createProxyMiddleware<TReq extends http.IncomingMessage = http.IncomingMessage, TRes extends http.ServerResponse = http.ServerResponse, TNext = NextFunction>(options: Options<TReq, TRes>): RequestHandler<TReq, TRes, TNext>;
348
+ declare function createProxyMiddleware<TReq extends http.IncomingMessage = http.IncomingMessage, TRes extends http.ServerResponse = http.ServerResponse, TNext extends (err?: unknown) => void = NextFunction>(options: Options<TReq, TRes>): RequestHandler<TReq, TRes, TNext>;
349
349
 
350
350
  type Interceptor<TReq = http.IncomingMessage, TRes = http.ServerResponse> = (buffer: Buffer, proxyRes: http.IncomingMessage, req: TReq, res: TRes) => Promise<Buffer | string>;
351
351
  /**
@@ -373,8 +373,8 @@ type Interceptor<TReq = http.IncomingMessage, TRes = http.ServerResponse> = (buf
373
373
  */
374
374
  declare function responseInterceptor<TReq extends http.IncomingMessage = http.IncomingMessage, TRes extends http.ServerResponse = http.ServerResponse>(interceptor: Interceptor<TReq, TRes>): (proxyRes: http.IncomingMessage, req: TReq, res: TRes) => Promise<void>;
375
375
 
376
- type BodyParserLikeRequest = http.IncomingMessage & {
377
- body?: any;
376
+ type BodyParserLikeRequest<TBody = unknown> = http.IncomingMessage & {
377
+ body?: TBody;
378
378
  };
379
379
  /**
380
380
  * Fix proxied body if bodyParser is involved.
@@ -1 +1 @@
1
- {"name":"http-proxy-middleware","author":"Steven Chim","version":"4.2.0","license":"MIT","types":"index.d.ts","type":"module"}
1
+ {"name":"http-proxy-middleware","author":"Steven Chim","version":"4.2.1","license":"MIT","types":"index.d.ts","type":"module"}
@@ -2008,7 +2008,7 @@
2008
2008
  if (t.minimal && !l.test(e)) return e;
2009
2009
  const d = hexadecimal(e.charCodeAt(0), y);
2010
2010
  return u || d.length > 2 ? fourHexEscape(d) : "\\x" + ("00" + d).slice(-2);
2011
- }), "`" == m && (T = T.replace(/\$\{/g, "\\${")), t.isScriptContext && (T = T.replace(/<\/(script|style)/gi, "<\\/$1").replace(/<!--/g, u ? "\\u003C!--" : "\\x3C!--")), t.wrap && (T = m + T + m), T;
2011
+ }), "`" == m && (T = T.replace(/\$\{/g, "\\${")), t.isScriptContext && (T = T.replace(/<\/(script|style)/gi, "<\\/$1").replace(/<\x21--/g, u ? "\\u003C!--" : "\\x3C!--")), t.wrap && (T = m + T + m), T;
2012
2012
  };
2013
2013
  jsesc.version = "3.0.2", e.exports = jsesc;
2014
2014
  },
File without changes