@rsbuild/core 1.1.11 → 1.1.13

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.
@@ -1,4 +1,4 @@
1
- import { Stats, Dirent } from 'fs';
1
+ import { Stats, Dirent, WatchEventType } from 'fs';
2
2
  import { EventEmitter } from 'events';
3
3
  import { Readable } from 'stream';
4
4
 
@@ -72,6 +72,11 @@ declare const EVENTS: {
72
72
  readonly ERROR: "error";
73
73
  };
74
74
  type EventName = (typeof EVENTS)[keyof typeof EVENTS];
75
+ interface WatchHandlers {
76
+ listener: (path: string) => void;
77
+ errHandler: (err: unknown) => void;
78
+ rawEmitter: (ev: WatchEventType, path: string, opts: unknown) => void;
79
+ }
75
80
  /**
76
81
  * @mixin
77
82
  */
@@ -125,6 +130,8 @@ declare class NodeFsHandler {
125
130
  _addToNodeFs(path: string, initialAdd: boolean, priorWh: WatchHelper | undefined, depth: number, target?: string): Promise<string | false | undefined>;
126
131
  }
127
132
 
133
+ /*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */
134
+
128
135
  type AWF = {
129
136
  stabilityThreshold: number;
130
137
  pollInterval: number;
@@ -156,7 +163,9 @@ type FSWInstanceOptions = BasicOpts & {
156
163
  awaitWriteFinish: false | AWF;
157
164
  };
158
165
  type ThrottleType = 'readdir' | 'watch' | 'add' | 'remove' | 'change';
159
- type EmitArgs = [EventName, Path | Error, any?, any?, any?];
166
+ type EmitArgs = [path: Path, stats?: Stats];
167
+ type EmitErrorArgs = [error: Error, stats?: Stats];
168
+ type EmitArgsWithName = [event: EventName, ...EmitArgs];
160
169
  type MatchFunction = (val: string, stats?: Stats) => boolean;
161
170
  interface MatcherObject {
162
171
  path: string;
@@ -190,6 +199,15 @@ declare class WatchHelper {
190
199
  filterPath(entry: EntryInfo): boolean;
191
200
  filterDir(entry: EntryInfo): boolean;
192
201
  }
202
+ interface FSWatcherKnownEventMap {
203
+ [EVENTS.READY]: [];
204
+ [EVENTS.RAW]: Parameters<WatchHandlers['rawEmitter']>;
205
+ [EVENTS.ERROR]: Parameters<WatchHandlers['errHandler']>;
206
+ [EVENTS.ALL]: [event: EventName, ...EmitArgs];
207
+ }
208
+ type FSWatcherEventMap = FSWatcherKnownEventMap & {
209
+ [k in Exclude<EventName, keyof FSWatcherKnownEventMap>]: EmitArgs;
210
+ };
193
211
  /**
194
212
  * Watches files & directories for changes. Emitted events:
195
213
  * `add`, `addDir`, `change`, `unlink`, `unlinkDir`, `all`, `error`
@@ -198,7 +216,7 @@ declare class WatchHelper {
198
216
  * .add(directories)
199
217
  * .on('add', path => log('File', path, 'was added'))
200
218
  */
201
- declare class FSWatcher extends EventEmitter {
219
+ declare class FSWatcher extends EventEmitter<FSWatcherEventMap> {
202
220
  closed: boolean;
203
221
  options: FSWInstanceOptions;
204
222
  _closers: Map<string, Array<any>>;
@@ -208,13 +226,13 @@ declare class FSWatcher extends EventEmitter {
208
226
  _symlinkPaths: Map<Path, string | boolean>;
209
227
  _watched: Map<string, DirEntry>;
210
228
  _pendingWrites: Map<string, any>;
211
- _pendingUnlinks: Map<string, EmitArgs>;
229
+ _pendingUnlinks: Map<string, EmitArgsWithName>;
212
230
  _readyCount: number;
213
231
  _emitReady: () => void;
214
232
  _closePromise?: Promise<void>;
215
233
  _userIgnored?: MatchFunction;
216
234
  _readyEmitted: boolean;
217
- _emitRaw: () => void;
235
+ _emitRaw: WatchHandlers['rawEmitter'];
218
236
  _boundRemove: (dir: string, item: string) => void;
219
237
  _nodeFsHandler: NodeFsHandler;
220
238
  constructor(_opts?: ChokidarOptions);
@@ -324,4 +342,4 @@ declare const _default: {
324
342
  FSWatcher: typeof FSWatcher;
325
343
  };
326
344
 
327
- export { type ChokidarOptions, type EmitArgs, type FSWInstanceOptions, FSWatcher, type MatchFunction, type Matcher, type MatcherObject, type ThrottleType, type Throttler, WatchHelper, _default as default, watch };
345
+ export { type ChokidarOptions, type EmitArgs, type EmitArgsWithName, type EmitErrorArgs, type FSWInstanceOptions, FSWatcher, type FSWatcherEventMap, type FSWatcherKnownEventMap, type MatchFunction, type Matcher, type MatcherObject, type ThrottleType, type Throttler, WatchHelper, _default as default, watch };
@@ -1,11 +1,12 @@
1
1
  (() => {
2
2
  "use strict";
3
3
  var __webpack_modules__ = {
4
- 976: (__unused_webpack_module, exports, __nccwpck_require__) => {
4
+ 457: (__unused_webpack_module, exports, __nccwpck_require__) => {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.NodeFsHandler =
7
7
  exports.EVENTS =
8
8
  exports.isIBMi =
9
+ exports.isFreeBSD =
9
10
  exports.isLinux =
10
11
  exports.isMacos =
11
12
  exports.isWindows =
@@ -30,6 +31,7 @@
30
31
  exports.isWindows = pl === "win32";
31
32
  exports.isMacos = pl === "darwin";
32
33
  exports.isLinux = pl === "linux";
34
+ exports.isFreeBSD = pl === "freebsd";
33
35
  exports.isIBMi = (0, os_1.type)() === "OS400";
34
36
  exports.EVENTS = {
35
37
  ALL: "all",
@@ -547,7 +549,7 @@
547
549
  this.fsw._emit(EV.CHANGE, file, newStats);
548
550
  }
549
551
  if (
550
- (exports.isMacos || exports.isLinux) &&
552
+ (exports.isMacos || exports.isLinux || exports.isFreeBSD) &&
551
553
  prevStats.ino !== newStats.ino
552
554
  ) {
553
555
  this.fsw._closeFile(path);
@@ -1100,12 +1102,13 @@
1100
1102
  Object.defineProperty(exports, "__esModule", { value: true });
1101
1103
  exports.FSWatcher = exports.WatchHelper = void 0;
1102
1104
  exports.watch = watch;
1103
- const fs_1 = __nccwpck_require__(147);
1105
+ /*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */ const fs_1 =
1106
+ __nccwpck_require__(147);
1104
1107
  const promises_1 = __nccwpck_require__(292);
1105
1108
  const events_1 = __nccwpck_require__(361);
1106
1109
  const sysPath = __nccwpck_require__(17);
1107
1110
  const readdirp_1 = __nccwpck_require__(9);
1108
- const handler_js_1 = __nccwpck_require__(976);
1111
+ const handler_js_1 = __nccwpck_require__(457);
1109
1112
  const SLASH = "/";
1110
1113
  const SLASH_SLASH = "//";
1111
1114
  const ONE_DOT = ".";
@@ -1480,16 +1483,16 @@
1480
1483
  return watchList;
1481
1484
  }
1482
1485
  emitWithAll(event, args) {
1483
- this.emit(...args);
1486
+ this.emit(event, ...args);
1484
1487
  if (event !== handler_js_1.EVENTS.ERROR)
1485
- this.emit(handler_js_1.EVENTS.ALL, ...args);
1488
+ this.emit(handler_js_1.EVENTS.ALL, event, ...args);
1486
1489
  }
1487
1490
  async _emit(event, path, stats) {
1488
1491
  if (this.closed) return;
1489
1492
  const opts = this.options;
1490
1493
  if (handler_js_1.isWindows) path = sysPath.normalize(path);
1491
1494
  if (opts.cwd) path = sysPath.relative(opts.cwd, path);
1492
- const args = [event, path];
1495
+ const args = [path];
1493
1496
  if (stats != null) args.push(stats);
1494
1497
  const awf = opts.awaitWriteFinish;
1495
1498
  let pw;
@@ -1499,7 +1502,7 @@
1499
1502
  }
1500
1503
  if (opts.atomic) {
1501
1504
  if (event === handler_js_1.EVENTS.UNLINK) {
1502
- this._pendingUnlinks.set(path, args);
1505
+ this._pendingUnlinks.set(path, [event, ...args]);
1503
1506
  setTimeout(
1504
1507
  () => {
1505
1508
  this._pendingUnlinks.forEach((entry, path) => {
@@ -1516,7 +1519,7 @@
1516
1519
  event === handler_js_1.EVENTS.ADD &&
1517
1520
  this._pendingUnlinks.has(path)
1518
1521
  ) {
1519
- event = args[0] = handler_js_1.EVENTS.CHANGE;
1522
+ event = handler_js_1.EVENTS.CHANGE;
1520
1523
  this._pendingUnlinks.delete(path);
1521
1524
  }
1522
1525
  }
@@ -1528,12 +1531,12 @@
1528
1531
  ) {
1529
1532
  const awfEmit = (err, stats) => {
1530
1533
  if (err) {
1531
- event = args[0] = handler_js_1.EVENTS.ERROR;
1532
- args[1] = err;
1534
+ event = handler_js_1.EVENTS.ERROR;
1535
+ args[0] = err;
1533
1536
  this.emitWithAll(event, args);
1534
1537
  } else if (stats) {
1535
- if (args.length > 2) {
1536
- args[2] = stats;
1538
+ if (args.length > 1) {
1539
+ args[1] = stats;
1537
1540
  } else {
1538
1541
  args.push(stats);
1539
1542
  }
@@ -1 +1 @@
1
- {"name":"chokidar","author":"Paul Miller (https://paulmillr.com)","version":"4.0.1","funding":"https://paulmillr.com/funding/","license":"MIT","types":"index.d.ts","type":"commonjs"}
1
+ {"name":"chokidar","author":"Paul Miller (https://paulmillr.com)","version":"4.0.3","funding":"https://paulmillr.com/funding/","license":"MIT","types":"index.d.ts","type":"commonjs"}