@rstest/core 0.5.3 → 0.6.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.
package/LICENSE.md CHANGED
@@ -682,7 +682,7 @@ Licensed under MIT license in the repository at chalk/ansi-styles.
682
682
 
683
683
  ### birpc
684
684
 
685
- Licensed under MIT license in the repository at git+https://github.com/antfu/birpc.git.
685
+ Licensed under MIT license in the repository at git+https://github.com/antfu-collective/birpc.git.
686
686
 
687
687
  > MIT License
688
688
  >
@@ -5,9 +5,9 @@ import * as __WEBPACK_EXTERNAL_MODULE_node_v8_d0df5498__ from "node:v8";
5
5
  import * as __WEBPACK_EXTERNAL_MODULE_node_events_0a6aefe7__ from "node:events";
6
6
  import * as __WEBPACK_EXTERNAL_MODULE_tinypool__ from "tinypool";
7
7
  import * as __WEBPACK_EXTERNAL_MODULE_node_inspector_dd9822d6__ from "node:inspector";
8
- export const __webpack_id__ = "816";
8
+ export const __webpack_id__ = "628";
9
9
  export const __webpack_ids__ = [
10
- "816"
10
+ "628"
11
11
  ];
12
12
  export const __webpack_modules__ = {
13
13
  "./src/core/rsbuild.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
@@ -15,6 +15,7 @@ export const __webpack_modules__ = {
15
15
  XD: ()=>createRsbuildServer,
16
16
  zh: ()=>prepareRsbuild
17
17
  });
18
+ var external_node_url_ = __webpack_require__("node:url");
18
19
  var core_ = __webpack_require__("@rsbuild/core");
19
20
  var dist = __webpack_require__("../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/index.mjs");
20
21
  var utils = __webpack_require__("./src/utils/index.ts");
@@ -108,7 +109,6 @@ export const __webpack_modules__ = {
108
109
  }
109
110
  });
110
111
  var external_node_path_ = __webpack_require__("node:path");
111
- var external_node_url_ = __webpack_require__("node:url");
112
112
  const PLUGIN_CSS_FILTER = 'rstest:css-filter';
113
113
  const css_filter_dirname = external_node_path_["default"].dirname((0, external_node_url_.fileURLToPath)(import.meta.url));
114
114
  const pluginCSSFilter = ()=>({
@@ -268,6 +268,8 @@ export const __webpack_modules__ = {
268
268
  });
269
269
  }
270
270
  } : null;
271
+ var external_node_fs_ = __webpack_require__("node:fs");
272
+ const mockRuntime_dirname = external_node_path_["default"].dirname((0, external_node_url_.fileURLToPath)(import.meta.url));
271
273
  class MockRuntimeRspackPlugin {
272
274
  apply(compiler) {
273
275
  const { RuntimeModule } = compiler.webpack;
@@ -276,109 +278,24 @@ export const __webpack_modules__ = {
276
278
  super('rstest runtime');
277
279
  }
278
280
  generate() {
279
- return `
280
- if (typeof __webpack_require__ === 'undefined') {
281
- return;
282
- }
283
-
284
- const originalRequire = __webpack_require__;
285
- __webpack_require__ = function(...args) {
286
- try {
287
- return originalRequire(...args);
288
- } catch (e) {
289
- const errMsg = e.message ?? e.toString();
290
- if (errMsg.includes('__webpack_modules__[moduleId] is not a function')) {
291
- throw new Error(\`Cannot find module '\${args[0]}'\`)
292
- }
293
- throw e;
294
- }
295
- };
296
-
297
- Object.keys(originalRequire).forEach(key => {
298
- __webpack_require__[key] = originalRequire[key];
299
- });
300
-
301
- __webpack_require__.rstest_original_modules = {};
302
-
303
- __webpack_require__.rstest_reset_modules = () => {
304
- const mockedIds = Object.keys(__webpack_require__.rstest_original_modules)
305
- Object.keys(__webpack_module_cache__).forEach(id => {
306
- // Do not reset mocks registry.
307
- if (!mockedIds.includes(id)) {
308
- delete __webpack_module_cache__[id];
309
- }
310
- });
311
- }
312
-
313
- __webpack_require__.rstest_unmock = (id) => {
314
- delete __webpack_module_cache__[id]
315
- }
316
-
317
- __webpack_require__.rstest_require_actual = __webpack_require__.rstest_import_actual = (id) => {
318
- const originalModule = __webpack_require__.rstest_original_modules[id];
319
- // Use fallback module if the module is not mocked.
320
- const fallbackMod = __webpack_require__(id);
321
- return originalModule ? originalModule : fallbackMod;
322
- }
323
-
324
- __webpack_require__.rstest_exec = async (id, modFactory) => {
325
- if (__webpack_module_cache__) {
326
- let asyncFactory = __webpack_module_cache__[id];
327
- if (asyncFactory && asyncFactory.constructor.name === 'AsyncFunction') {
328
- await asyncFactory();
329
- }
330
- }
331
- };
332
-
333
- __webpack_require__.rstest_mock = (id, modFactory) => {
334
- let requiredModule = undefined
335
- try {
336
- requiredModule = __webpack_require__(id);
337
- } catch {
338
- // TODO: non-resolved module
339
- } finally {
340
- __webpack_require__.rstest_original_modules[id] = requiredModule;
341
- }
342
- if (typeof modFactory === 'string' || typeof modFactory === 'number') {
343
- __webpack_module_cache__[id] = { exports: __webpack_require__(modFactory) };
344
- } else if (typeof modFactory === 'function') {
345
- if (modFactory.constructor.name === 'AsyncFunction') {
346
- __webpack_module_cache__[id] = async () => {
347
- const exports = await modFactory();
348
- __webpack_require__.r(exports);
349
- __webpack_module_cache__[id] = { exports, id, loaded: true };
350
- }
351
- } else {
352
- const exports = modFactory();
353
- __webpack_require__.r(exports);
354
- __webpack_module_cache__[id] = { exports, id, loaded: true };
355
- }
356
- }
357
- };
358
-
359
- __webpack_require__.rstest_do_mock = (id, modFactory) => {
360
- let requiredModule = undefined
361
- try {
362
- requiredModule = __webpack_require__(id);
363
- } catch {
364
- // TODO: non-resolved module
365
- } finally {
366
- __webpack_require__.rstest_original_modules[id] = requiredModule;
367
- }
368
- if (typeof modFactory === 'string' || typeof modFactory === 'number') {
369
- __webpack_module_cache__[id] = { exports: __webpack_require__(modFactory) };
370
- } else if (typeof modFactory === 'function') {
371
- const exports = modFactory();
372
- __webpack_require__.r(exports);
373
- __webpack_module_cache__[id] = { exports, id, loaded: true };
374
- }
375
- };
376
-
377
- `;
281
+ const code = external_node_fs_["default"].readFileSync(external_node_path_["default"].join(mockRuntime_dirname, './mockRuntimeCode.js'), 'utf8');
282
+ return code;
378
283
  }
379
284
  }
380
- compiler.hooks.thisCompilation.tap('CustomPlugin', (compilation)=>{
381
- compilation.hooks.additionalTreeRuntimeRequirements.tap('CustomPlugin', (chunk)=>{
285
+ compiler.hooks.compilation.tap('RstestMockPlugin', (compilation)=>{
286
+ compilation.hooks.runtimeModule.tap('RstestMockChunkLoadingRuntimePlugin', (module)=>{
287
+ if ('require_chunk_loading' === module.name) {
288
+ const finalSource = module.source.source.toString('utf-8').replace('for (var moduleId in moreModules) {', "for (var moduleId in moreModules) {\n if (Object.keys(__webpack_require__.rstest_original_modules).includes(moduleId)) continue;");
289
+ module.source.source = Buffer.from(finalSource);
290
+ }
291
+ if ('define_property_getters' === module.name) {
292
+ const finalSource = module.source.source.toString('utf-8').replace('enumerable: true, get:', 'enumerable: true, configurable: true, get:');
293
+ module.source.source = Buffer.from(finalSource);
294
+ }
295
+ });
296
+ });
297
+ compiler.hooks.thisCompilation.tap('RstestMockPlugin', (compilation)=>{
298
+ compilation.hooks.additionalTreeRuntimeRequirements.tap('RstestAddMockRuntimePlugin', (chunk)=>{
382
299
  compilation.addRuntimeModule(chunk, new RetestImportRuntimeModule());
383
300
  });
384
301
  });
@@ -418,8 +335,8 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
418
335
  `;
419
336
  }
420
337
  }
421
- compiler.hooks.thisCompilation.tap('CustomPlugin', (compilation)=>{
422
- compilation.hooks.additionalTreeRuntimeRequirements.tap('CustomPlugin', (chunk)=>{
338
+ compiler.hooks.thisCompilation.tap('RstestCacheControlPlugin', (compilation)=>{
339
+ compilation.hooks.additionalTreeRuntimeRequirements.tap('RstestAddCacheControlRuntimePlugin', (chunk)=>{
423
340
  compilation.addRuntimeModule(chunk, new RetestCacheControlModule());
424
341
  });
425
342
  });
@@ -443,6 +360,7 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
443
360
  });
444
361
  }
445
362
  });
363
+ const rsbuild_dirname = dist.Ay.dirname((0, external_node_url_.fileURLToPath)(import.meta.url));
446
364
  function parseInlineSourceMapStr(code) {
447
365
  const inlineSourceMapRegex = /\/\/# sourceMappingURL=data:application\/json(?:;charset=utf-8)?;base64,(.+)\s*$/m;
448
366
  const match = code.match(inlineSourceMapRegex);
@@ -574,6 +492,11 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
574
492
  const rstestCompilerPlugin = {
575
493
  name: 'rstest:compiler',
576
494
  setup: (api)=>{
495
+ api.modifyBundlerChain((chain)=>{
496
+ chain.module.rule('rstest-mock-module-doppelgangers').test(/\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/).with({
497
+ rstest: 'importActual'
498
+ }).use('import-actual-loader').loader(dist.Ay.resolve(rsbuild_dirname, './importActualLoader.mjs')).end();
499
+ });
577
500
  api.onAfterCreateCompiler(({ compiler })=>{
578
501
  rspackCompiler = compiler;
579
502
  });
@@ -728,6 +651,7 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
728
651
  b: ()=>createPool
729
652
  });
730
653
  var external_node_os_ = __webpack_require__("node:os");
654
+ var pathe_M_eThtNZ = __webpack_require__("../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs");
731
655
  var utils = __webpack_require__("./src/utils/index.ts");
732
656
  var memory = __webpack_require__("./src/utils/memory.ts");
733
657
  var external_node_url_ = __webpack_require__("node:url");
@@ -839,7 +763,7 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
839
763
  if (msg.t === TYPE_REQUEST) {
840
764
  const { m: method, a: args } = msg;
841
765
  let result, error;
842
- const fn = resolver ? resolver(method, functions[method]) : functions[method];
766
+ const fn = await (resolver ? resolver(method, functions[method]) : functions[method]);
843
767
  if (fn) try {
844
768
  result = await fn.apply("rpc" === bind ? rpc : functions, args);
845
769
  } catch (e) {
@@ -893,7 +817,6 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
893
817
  while(i--)id += urlAlphabet[64 * random() | 0];
894
818
  return id;
895
819
  }
896
- var pathe_M_eThtNZ = __webpack_require__("../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs");
897
820
  const forks_filename = (0, external_node_url_.fileURLToPath)(import.meta.url);
898
821
  const forks_dirname = (0, pathe_M_eThtNZ.d)(forks_filename);
899
822
  function createChannel(rpcMethods) {
@@ -1047,6 +970,12 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
1047
970
  },
1048
971
  onTestFileStart: async (test)=>{
1049
972
  await Promise.all(reporters.map((reporter)=>reporter.onTestFileStart?.(test)));
973
+ },
974
+ resolveSnapshotPath: (testPath)=>{
975
+ const snapExtension = '.snap';
976
+ const resolver = context.normalizedConfig.resolveSnapshotPath || (()=>(0, pathe_M_eThtNZ.j)((0, pathe_M_eThtNZ.d)(testPath), '__snapshots__', `${(0, pathe_M_eThtNZ.c)(testPath)}${snapExtension}`));
977
+ const snapshotPath = resolver(testPath, snapExtension);
978
+ return snapshotPath;
1050
979
  }
1051
980
  };
1052
981
  return {
@@ -1054,11 +983,12 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
1054
983
  const projectName = context.normalizedConfig.name;
1055
984
  const runtimeConfig = getRuntimeConfig(project);
1056
985
  const setupAssets = setupEntries.flatMap((entry)=>entry.files || []);
1057
- const results = await Promise.all(entries.map(async (entryInfo)=>{
986
+ const results = await Promise.all(entries.map(async (entryInfo, index)=>{
1058
987
  const result = await pool.runTest({
1059
988
  options: {
1060
989
  entryInfo,
1061
990
  context: {
991
+ taskId: index + 1,
1062
992
  project: projectName,
1063
993
  rootPath: context.rootPath,
1064
994
  projectRoot: project.rootPath,
@@ -1101,10 +1031,11 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
1101
1031
  const runtimeConfig = getRuntimeConfig(project);
1102
1032
  const projectName = project.normalizedConfig.name;
1103
1033
  const setupAssets = setupEntries.flatMap((entry)=>entry.files || []);
1104
- return Promise.all(entries.map(async (entryInfo)=>pool.collectTests({
1034
+ return Promise.all(entries.map(async (entryInfo, index)=>pool.collectTests({
1105
1035
  options: {
1106
1036
  entryInfo,
1107
1037
  context: {
1038
+ taskId: index + 1,
1108
1039
  project: projectName,
1109
1040
  rootPath: context.rootPath,
1110
1041
  projectRoot: project.rootPath,
package/dist/0~655.js CHANGED
@@ -1541,7 +1541,7 @@ export const __webpack_modules__ = {
1541
1541
  const string = `${options.stylize(helpers_truncate(array[i], options.truncate), 'number')}${i === array.length - 1 ? '' : ', '}`;
1542
1542
  options.truncate -= string.length;
1543
1543
  if (array[i] !== array.length && options.truncate <= 3) {
1544
- output += `${truncator}(${array.length - array[i] + 1})`;
1544
+ output += `…(${array.length - array[i] + 1})`;
1545
1545
  break;
1546
1546
  }
1547
1547
  output += string;
@@ -1598,7 +1598,7 @@ export const __webpack_modules__ = {
1598
1598
  }
1599
1599
  function inspectBigInt(number, options) {
1600
1600
  let nums = helpers_truncate(number.toString(), options.truncate - 1);
1601
- if (nums !== truncator) nums += 'n';
1601
+ if ("…" !== nums) nums += 'n';
1602
1602
  return options.stylize(nums, 'bigint');
1603
1603
  }
1604
1604
  function inspectRegExp(value, options) {
@@ -1754,7 +1754,7 @@ export const __webpack_modules__ = {
1754
1754
  options.truncate -= propertyContents.length;
1755
1755
  const truncate = options.truncate;
1756
1756
  let children = inspectNodeCollection(element.children, options);
1757
- if (children && children.length > truncate) children = `${truncator}(${element.children.length})`;
1757
+ if (children && children.length > truncate) children = `…(${element.children.length})`;
1758
1758
  return `${head}${propertyContents}${headClose}${children}${tail}`;
1759
1759
  }
1760
1760
  const symbolsSupported = 'function' == typeof Symbol && 'function' == typeof Symbol.for;
@@ -3285,7 +3285,7 @@ export const __webpack_modules__ = {
3285
3285
  function getCommonAndChangedSubstrings(diffs, op, hasCommonDiff) {
3286
3286
  return diffs.reduce((reduced, diff)=>reduced + (diff[0] === DIFF_EQUAL ? diff[1] : diff[0] === op ? hasCommonDiff ? dist_node.Ay.inverse(diff[1]) : diff[1] : ""), "");
3287
3287
  }
3288
- __webpack_require__("../../node_modules/.pnpm/tinyspy@4.0.3/node_modules/tinyspy/dist/index.js");
3288
+ __webpack_require__("../../node_modules/.pnpm/tinyspy@4.0.4/node_modules/tinyspy/dist/index.js");
3289
3289
  new Set();
3290
3290
  function isMockFunction(fn) {
3291
3291
  return "function" == typeof fn && "_isMockFunction" in fn && fn._isMockFunction;
@@ -11369,165 +11369,165 @@ deep-eql/index.js:
11369
11369
  var node_r = void 0 !== process.env.FORCE_TTY || (0, external_node_tty_.isatty)(1);
11370
11370
  var node_u = p(node_r);
11371
11371
  },
11372
- "../../node_modules/.pnpm/tinyspy@4.0.3/node_modules/tinyspy/dist/index.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
11372
+ "../../node_modules/.pnpm/tinyspy@4.0.4/node_modules/tinyspy/dist/index.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
11373
11373
  __webpack_require__.d(__webpack_exports__, {
11374
- jo: ()=>internalSpyOn,
11375
- lf: ()=>getInternalState
11374
+ jo: ()=>M,
11375
+ lf: ()=>T
11376
11376
  });
11377
- function assert(condition, message) {
11378
- if (!condition) throw new Error(message);
11377
+ function S(e, t) {
11378
+ if (!e) throw new Error(t);
11379
11379
  }
11380
- function isType(type, value) {
11381
- return typeof value === type;
11380
+ function f(e, t) {
11381
+ return typeof t === e;
11382
11382
  }
11383
- function isPromise(value) {
11384
- return value instanceof Promise;
11383
+ function w(e) {
11384
+ return e instanceof Promise;
11385
11385
  }
11386
- function define(obj, key, descriptor) {
11387
- Object.defineProperty(obj, key, descriptor);
11386
+ function u(e, t, r) {
11387
+ Object.defineProperty(e, t, r);
11388
11388
  }
11389
- function defineValue(obj, key, value) {
11390
- define(obj, key, {
11391
- value,
11389
+ function l(e, t, r) {
11390
+ u(e, t, {
11391
+ value: r,
11392
11392
  configurable: !0,
11393
11393
  writable: !0
11394
11394
  });
11395
11395
  }
11396
- var SYMBOL_STATE = Symbol.for("tinyspy:spy");
11397
- var spies = /* @__PURE__ */ new Set(), reset = (state)=>{
11398
- state.called = !1, state.callCount = 0, state.calls = [], state.results = [], state.resolves = [], state.next = [];
11399
- }, defineState = (spy2)=>(define(spy2, SYMBOL_STATE, {
11396
+ var y = Symbol.for("tinyspy:spy");
11397
+ var x = /* @__PURE__ */ new Set(), h = (e)=>{
11398
+ e.called = !1, e.callCount = 0, e.calls = [], e.results = [], e.resolves = [], e.next = [];
11399
+ }, k = (e)=>(u(e, y, {
11400
11400
  value: {
11401
- reset: ()=>reset(spy2[SYMBOL_STATE])
11402
- }
11403
- }), spy2[SYMBOL_STATE]), getInternalState = (spy2)=>spy2[SYMBOL_STATE] || defineState(spy2);
11404
- function createInternalSpy(cb) {
11405
- assert(isType("function", cb) || isType("undefined", cb), "cannot spy on a non-function value");
11406
- let fn = function(...args) {
11407
- let state2 = getInternalState(fn);
11408
- state2.called = !0, state2.callCount++, state2.calls.push(args);
11409
- let next = state2.next.shift();
11410
- if (next) {
11411
- state2.results.push(next);
11412
- let [type2, result2] = next;
11413
- if ("ok" === type2) return result2;
11414
- throw result2;
11415
- }
11416
- let result, type = "ok", resultIndex = state2.results.length;
11417
- if (state2.impl) try {
11418
- new.target ? result = Reflect.construct(state2.impl, args, new.target) : result = state2.impl.apply(this, args), type = "ok";
11419
- } catch (err) {
11420
- throw result = err, type = "error", state2.results.push([
11421
- type,
11422
- err
11423
- ]), err;
11424
- }
11425
- let resultTuple = [
11426
- type,
11427
- result
11401
+ reset: ()=>h(e[y])
11402
+ }
11403
+ }), e[y]), T = (e)=>e[y] || k(e);
11404
+ function R(e) {
11405
+ S(f("function", e) || f("undefined", e), "cannot spy on a non-function value");
11406
+ let t = function(...s) {
11407
+ let n = T(t);
11408
+ n.called = !0, n.callCount++, n.calls.push(s);
11409
+ let d = n.next.shift();
11410
+ if (d) {
11411
+ n.results.push(d);
11412
+ let [a, i] = d;
11413
+ if ("ok" === a) return i;
11414
+ throw i;
11415
+ }
11416
+ let o, c = "ok", p = n.results.length;
11417
+ if (n.impl) try {
11418
+ new.target ? o = Reflect.construct(n.impl, s, new.target) : o = n.impl.apply(this, s), c = "ok";
11419
+ } catch (a) {
11420
+ throw o = a, c = "error", n.results.push([
11421
+ c,
11422
+ a
11423
+ ]), a;
11424
+ }
11425
+ let g = [
11426
+ c,
11427
+ o
11428
11428
  ];
11429
- return isPromise(result) && result.then((r)=>state2.resolves[resultIndex] = [
11429
+ return w(o) && o.then((a)=>n.resolves[p] = [
11430
11430
  "ok",
11431
- r
11432
- ], (e)=>state2.resolves[resultIndex] = [
11431
+ a
11432
+ ], (a)=>n.resolves[p] = [
11433
11433
  "error",
11434
- e
11435
- ]), state2.results.push(resultTuple), result;
11434
+ a
11435
+ ]), n.results.push(g), o;
11436
11436
  };
11437
- defineValue(fn, "_isMockFunction", !0), defineValue(fn, "length", cb ? cb.length : 0), defineValue(fn, "name", cb && cb.name || "spy");
11438
- let state = getInternalState(fn);
11439
- return state.reset(), state.impl = cb, fn;
11440
- }
11441
- function isMockFunction(obj) {
11442
- return !!obj && !0 === obj._isMockFunction;
11443
- }
11444
- var getDescriptor = (obj, method)=>{
11445
- let objDescriptor = Object.getOwnPropertyDescriptor(obj, method);
11446
- if (objDescriptor) return [
11447
- obj,
11448
- objDescriptor
11437
+ l(t, "_isMockFunction", !0), l(t, "length", e ? e.length : 0), l(t, "name", e && e.name || "spy");
11438
+ let r = T(t);
11439
+ return r.reset(), r.impl = e, t;
11440
+ }
11441
+ function v(e) {
11442
+ return !!e && !0 === e._isMockFunction;
11443
+ }
11444
+ var b = (e, t)=>{
11445
+ let r = Object.getOwnPropertyDescriptor(e, t);
11446
+ if (r) return [
11447
+ e,
11448
+ r
11449
11449
  ];
11450
- let currentProto = Object.getPrototypeOf(obj);
11451
- for(; null !== currentProto;){
11452
- let descriptor = Object.getOwnPropertyDescriptor(currentProto, method);
11453
- if (descriptor) return [
11454
- currentProto,
11455
- descriptor
11450
+ let s = Object.getPrototypeOf(e);
11451
+ for(; null !== s;){
11452
+ let n = Object.getOwnPropertyDescriptor(s, t);
11453
+ if (n) return [
11454
+ s,
11455
+ n
11456
11456
  ];
11457
- currentProto = Object.getPrototypeOf(currentProto);
11457
+ s = Object.getPrototypeOf(s);
11458
11458
  }
11459
- }, setPototype = (fn, val)=>{
11460
- null != val && "function" == typeof val && null != val.prototype && Object.setPrototypeOf(fn.prototype, val.prototype);
11459
+ }, P = (e, t)=>{
11460
+ null != t && "function" == typeof t && null != t.prototype && Object.setPrototypeOf(e.prototype, t.prototype);
11461
11461
  };
11462
- function internalSpyOn(obj, methodName, mock) {
11463
- assert(!isType("undefined", obj), "spyOn could not find an object to spy upon"), assert(isType("object", obj) || isType("function", obj), "cannot spyOn on a primitive value");
11464
- let [accessName, accessType] = (()=>{
11465
- if (!isType("object", methodName)) return [
11466
- methodName,
11462
+ function M(e, t, r) {
11463
+ S(!f("undefined", e), "spyOn could not find an object to spy upon"), S(f("object", e) || f("function", e), "cannot spyOn on a primitive value");
11464
+ let [s, n] = (()=>{
11465
+ if (!f("object", t)) return [
11466
+ t,
11467
11467
  "value"
11468
11468
  ];
11469
- if ("getter" in methodName && "setter" in methodName) throw new Error("cannot spy on both getter and setter");
11470
- if ("getter" in methodName) return [
11471
- methodName.getter,
11469
+ if ("getter" in t && "setter" in t) throw new Error("cannot spy on both getter and setter");
11470
+ if ("getter" in t) return [
11471
+ t.getter,
11472
11472
  "get"
11473
11473
  ];
11474
- if ("setter" in methodName) return [
11475
- methodName.setter,
11474
+ if ("setter" in t) return [
11475
+ t.setter,
11476
11476
  "set"
11477
11477
  ];
11478
11478
  throw new Error("specify getter or setter to spy on");
11479
- })(), [originalDescriptorObject, originalDescriptor] = getDescriptor(obj, accessName) || [];
11480
- assert(originalDescriptor || accessName in obj, `${String(accessName)} does not exist`);
11481
- let ssr = !1;
11482
- "value" === accessType && originalDescriptor && !originalDescriptor.value && originalDescriptor.get && (accessType = "get", ssr = !0, mock = originalDescriptor.get());
11483
- let original;
11484
- originalDescriptor ? original = originalDescriptor[accessType] : "value" !== accessType ? original = ()=>obj[accessName] : original = obj[accessName], original && isSpyFunction(original) && (original = original[SYMBOL_STATE].getOriginal());
11485
- let reassign = (cb)=>{
11486
- let { value, ...desc } = originalDescriptor || {
11479
+ })(), [d, o] = b(e, s) || [];
11480
+ S(o || s in e, `${String(s)} does not exist`);
11481
+ let c = !1;
11482
+ "value" === n && o && !o.value && o.get && (n = "get", c = !0, r = o.get());
11483
+ let p;
11484
+ o ? p = o[n] : "value" !== n ? p = ()=>e[s] : p = e[s], p && j(p) && (p = p[y].getOriginal());
11485
+ let g = (I)=>{
11486
+ let { value: F, ...O } = o || {
11487
11487
  configurable: !0,
11488
11488
  writable: !0
11489
11489
  };
11490
- "value" !== accessType && delete desc.writable, desc[accessType] = cb, define(obj, accessName, desc);
11491
- }, restore = ()=>{
11492
- originalDescriptorObject !== obj ? Reflect.deleteProperty(obj, accessName) : originalDescriptor && !original ? define(obj, accessName, originalDescriptor) : reassign(original);
11490
+ "value" !== n && delete O.writable, O[n] = I, u(e, s, O);
11491
+ }, a = ()=>{
11492
+ d !== e ? Reflect.deleteProperty(e, s) : o && !p ? u(e, s, o) : g(p);
11493
11493
  };
11494
- mock || (mock = original);
11495
- let spy2 = wrap(createInternalSpy(mock), mock);
11496
- "value" === accessType && setPototype(spy2, original);
11497
- let state = spy2[SYMBOL_STATE];
11498
- return defineValue(state, "restore", restore), defineValue(state, "getOriginal", ()=>ssr ? original() : original), defineValue(state, "willCall", (newCb)=>(state.impl = newCb, spy2)), reassign(ssr ? ()=>(setPototype(spy2, mock), spy2) : spy2), spies.add(spy2), spy2;
11494
+ r || (r = p);
11495
+ let i = E(R(r), r);
11496
+ "value" === n && P(i, p);
11497
+ let m = i[y];
11498
+ return l(m, "restore", a), l(m, "getOriginal", ()=>c ? p() : p), l(m, "willCall", (I)=>(m.impl = I, i)), g(c ? ()=>(P(i, r), i) : i), x.add(i), i;
11499
11499
  }
11500
- var ignoreProperties = /* @__PURE__ */ new Set([
11500
+ var K = /* @__PURE__ */ new Set([
11501
11501
  "length",
11502
11502
  "name",
11503
11503
  "prototype"
11504
11504
  ]);
11505
- function getAllProperties(original) {
11506
- let properties = /* @__PURE__ */ new Set(), descriptors2 = {};
11507
- for(; original && original !== Object.prototype && original !== Function.prototype;){
11508
- let ownProperties = [
11509
- ...Object.getOwnPropertyNames(original),
11510
- ...Object.getOwnPropertySymbols(original)
11505
+ function D(e) {
11506
+ let t = /* @__PURE__ */ new Set(), r = {};
11507
+ for(; e && e !== Object.prototype && e !== Function.prototype;){
11508
+ let s = [
11509
+ ...Object.getOwnPropertyNames(e),
11510
+ ...Object.getOwnPropertySymbols(e)
11511
11511
  ];
11512
- for (let prop of ownProperties)descriptors2[prop] || ignoreProperties.has(prop) || (properties.add(prop), descriptors2[prop] = Object.getOwnPropertyDescriptor(original, prop));
11513
- original = Object.getPrototypeOf(original);
11512
+ for (let n of s)r[n] || K.has(n) || (t.add(n), r[n] = Object.getOwnPropertyDescriptor(e, n));
11513
+ e = Object.getPrototypeOf(e);
11514
11514
  }
11515
11515
  return {
11516
- properties,
11517
- descriptors: descriptors2
11516
+ properties: t,
11517
+ descriptors: r
11518
11518
  };
11519
11519
  }
11520
- function wrap(mock, original) {
11521
- if (!original || SYMBOL_STATE in original) return mock;
11522
- let { properties, descriptors: descriptors2 } = getAllProperties(original);
11523
- for (let key of properties){
11524
- let descriptor = descriptors2[key];
11525
- getDescriptor(mock, key) || define(mock, key, descriptor);
11520
+ function E(e, t) {
11521
+ if (!t || y in t) return e;
11522
+ let { properties: r, descriptors: s } = D(t);
11523
+ for (let n of r){
11524
+ let d = s[n];
11525
+ b(e, n) || u(e, n, d);
11526
11526
  }
11527
- return mock;
11527
+ return e;
11528
11528
  }
11529
- function isSpyFunction(obj) {
11530
- return isMockFunction(obj) && "getOriginal" in obj[SYMBOL_STATE];
11529
+ function j(e) {
11530
+ return v(e) && "getOriginal" in e[y];
11531
11531
  }
11532
11532
  }
11533
11533
  };
package/dist/0~85.js CHANGED
@@ -1511,7 +1511,7 @@ export const __webpack_modules__ = {
1511
1511
  return this._fakingTime;
1512
1512
  }
1513
1513
  }
1514
- var tinyspy_dist = __webpack_require__("../../node_modules/.pnpm/tinyspy@4.0.3/node_modules/tinyspy/dist/index.js");
1514
+ var tinyspy_dist = __webpack_require__("../../node_modules/.pnpm/tinyspy@4.0.4/node_modules/tinyspy/dist/index.js");
1515
1515
  let callOrder = 0;
1516
1516
  const mocks = new Set();
1517
1517
  const wrapSpy = (obj, methodName, mockFn)=>{
@@ -0,0 +1 @@
1
+ export default ((source)=>source);