@rstest/core 0.0.1 → 0.0.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.
package/dist/813.js CHANGED
@@ -10,6 +10,7 @@ export const __webpack_modules__ = {
10
10
  var node_console__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("node:console");
11
11
  var node_util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("node:util");
12
12
  var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/utils/index.ts");
13
+ const RealDate = Date;
13
14
  function createCustomConsole({ rpc, testPath, printConsoleTrace }) {
14
15
  const getConsoleTrace = ()=>{
15
16
  const limit = Error.stackTraceLimit;
@@ -92,12 +93,12 @@ export const __webpack_modules__ = {
92
93
  }
93
94
  time(label = 'default') {
94
95
  if (null != this._timers[label]) return;
95
- this._timers[label] = new Date();
96
+ this._timers[label] = new RealDate();
96
97
  }
97
98
  timeEnd(label = 'default') {
98
99
  const startTime = this._timers[label];
99
100
  if (null != startTime) {
100
- const endTime = Date.now();
101
+ const endTime = RealDate.now();
101
102
  const time = endTime - startTime.getTime();
102
103
  this._log('time', (0, node_util__WEBPACK_IMPORTED_MODULE_2__.format)(`${label}: ${(0, _utils__WEBPACK_IMPORTED_MODULE_3__.AS)(time)}`));
103
104
  delete this._timers[label];
@@ -106,7 +107,7 @@ export const __webpack_modules__ = {
106
107
  timeLog(label = 'default', ...data) {
107
108
  const startTime = this._timers[label];
108
109
  if (null != startTime) {
109
- const endTime = new Date();
110
+ const endTime = new RealDate();
110
111
  const time = endTime.getTime() - startTime.getTime();
111
112
  this._log('time', (0, node_util__WEBPACK_IMPORTED_MODULE_2__.format)(`${label}: ${(0, _utils__WEBPACK_IMPORTED_MODULE_3__.AS)(time)}`, ...data));
112
113
  }
@@ -1,5 +1,5 @@
1
1
  export const __webpack_ids__ = [
2
- "773"
2
+ "867"
3
3
  ];
4
4
  export const __webpack_modules__ = {
5
5
  "./src/runtime/api/index.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
@@ -9,6 +9,7 @@ export const __webpack_modules__ = {
9
9
  var expect_ = __webpack_require__("@vitest/expect");
10
10
  var src_utils = __webpack_require__("./src/utils/index.ts");
11
11
  var external_chai_ = __webpack_require__("chai");
12
+ var external_node_timers_ = __webpack_require__("node:timers");
12
13
  const unsupported = [
13
14
  'matchSnapshot',
14
15
  'toMatchSnapshot',
@@ -52,10 +53,10 @@ export const __webpack_modules__ = {
52
53
  clearTimeout(timeoutId);
53
54
  } catch (err) {
54
55
  lastError = err;
55
- if (!external_chai_.util.flag(assertion, '_isLastPollAttempt')) intervalId = setTimeout(check, interval);
56
+ if (!external_chai_.util.flag(assertion, '_isLastPollAttempt')) intervalId = (0, external_node_timers_.setTimeout)(check, interval);
56
57
  }
57
58
  };
58
- timeoutId = setTimeout(()=>{
59
+ timeoutId = (0, external_node_timers_.setTimeout)(()=>{
59
60
  clearTimeout(intervalId);
60
61
  external_chai_.util.flag(assertion, '_isLastPollAttempt', true);
61
62
  const rejectWithCause = (cause)=>{
@@ -568,7 +569,7 @@ export const __webpack_modules__ = {
568
569
  return async (...args)=>{
569
570
  let timeoutId;
570
571
  const timeoutPromise = new Promise((_, reject)=>{
571
- timeoutId = setTimeout(()=>reject(makeError(`${name} timed out in ${timeout}ms`, stackTraceError)), timeout);
572
+ timeoutId = (0, external_node_timers_.setTimeout)(()=>reject(makeError(`${name} timed out in ${timeout}ms`, stackTraceError)), timeout);
572
573
  });
573
574
  try {
574
575
  const result = await Promise.race([
@@ -606,6 +607,7 @@ export const __webpack_modules__ = {
606
607
  } else queue.push(task);
607
608
  });
608
609
  }
610
+ const RealDate = Date;
609
611
  class TestRunner {
610
612
  _test;
611
613
  workerState;
@@ -797,7 +799,7 @@ export const __webpack_modules__ = {
797
799
  errors.push(...(0, runtime_util.o)(error));
798
800
  }
799
801
  } else {
800
- const start = Date.now();
802
+ const start = RealDate.now();
801
803
  let result;
802
804
  let retryCount = 0;
803
805
  do {
@@ -808,12 +810,12 @@ export const __webpack_modules__ = {
808
810
  };
809
811
  retryCount++;
810
812
  }while (retryCount <= retry && 'fail' === result.status);
811
- result.duration = Date.now() - start;
813
+ result.duration = RealDate.now() - start;
812
814
  hooks.onTestCaseResult?.(result);
813
815
  results.push(result);
814
816
  }
815
817
  };
816
- const start = Date.now();
818
+ const start = RealDate.now();
817
819
  if (0 === tests.length) {
818
820
  if (passWithNoTests) return {
819
821
  testPath,
@@ -846,7 +848,7 @@ export const __webpack_modules__ = {
846
848
  results,
847
849
  snapshotResult,
848
850
  errors,
849
- duration: Date.now() - start
851
+ duration: RealDate.now() - start
850
852
  };
851
853
  }
852
854
  resetCurrentTest() {
@@ -1316,165 +1318,119 @@ export const __webpack_modules__ = {
1316
1318
  }
1317
1319
  };
1318
1320
  }
1319
- function dist_assert(condition, message) {
1320
- if (!condition) throw new Error(message);
1321
- }
1322
- function isType(type, value) {
1323
- return typeof value === type;
1324
- }
1325
- function isPromise(value) {
1326
- return value instanceof Promise;
1327
- }
1328
- function dist_define(obj, key, descriptor) {
1329
- Object.defineProperty(obj, key, descriptor);
1330
- }
1331
- function defineValue(obj, key, value) {
1332
- dist_define(obj, key, {
1333
- value,
1334
- configurable: !0,
1335
- writable: !0
1336
- });
1337
- }
1338
- var SYMBOL_STATE = Symbol.for("tinyspy:spy");
1339
- var spies = /* @__PURE__ */ new Set(), dist_reset = (state)=>{
1340
- state.called = !1, state.callCount = 0, state.calls = [], state.results = [], state.resolves = [], state.next = [];
1341
- }, defineState = (spy2)=>(dist_define(spy2, SYMBOL_STATE, {
1342
- value: {
1343
- reset: ()=>dist_reset(spy2[SYMBOL_STATE])
1321
+ var fake_timers_src = __webpack_require__("../../node_modules/.pnpm/@sinonjs+fake-timers@14.0.0/node_modules/@sinonjs/fake-timers/src/fake-timers-src.js");
1322
+ const fakeTimers_RealDate = Date;
1323
+ class FakeTimers {
1324
+ _clock;
1325
+ _config;
1326
+ _fakingTime;
1327
+ _fakeTimers;
1328
+ constructor({ global, config = {} }){
1329
+ this._config = config;
1330
+ this._fakingTime = false;
1331
+ this._fakeTimers = (0, fake_timers_src.withGlobal)(global);
1332
+ }
1333
+ clearAllTimers() {
1334
+ if (this._fakingTime) this._clock.reset();
1335
+ }
1336
+ dispose() {
1337
+ this.useRealTimers();
1338
+ }
1339
+ runAllTimers() {
1340
+ if (this._checkFakeTimers()) this._clock.runAll();
1341
+ }
1342
+ async runAllTimersAsync() {
1343
+ if (this._checkFakeTimers()) await this._clock.runAllAsync();
1344
+ }
1345
+ runOnlyPendingTimers() {
1346
+ if (this._checkFakeTimers()) this._clock.runToLast();
1347
+ }
1348
+ async runOnlyPendingTimersAsync() {
1349
+ if (this._checkFakeTimers()) await this._clock.runToLastAsync();
1350
+ }
1351
+ advanceTimersToNextTimer(steps = 1) {
1352
+ if (this._checkFakeTimers()) for(let i = steps; i > 0; i--){
1353
+ this._clock.next();
1354
+ this._clock.tick(0);
1355
+ if (0 === this._clock.countTimers()) break;
1344
1356
  }
1345
- }), spy2[SYMBOL_STATE]), getInternalState = (spy2)=>spy2[SYMBOL_STATE] || defineState(spy2);
1346
- function createInternalSpy(cb) {
1347
- dist_assert(isType("function", cb) || isType("undefined", cb), "cannot spy on a non-function value");
1348
- let fn = function(...args) {
1349
- let state2 = getInternalState(fn);
1350
- state2.called = !0, state2.callCount++, state2.calls.push(args);
1351
- let next = state2.next.shift();
1352
- if (next) {
1353
- state2.results.push(next);
1354
- let [type2, result2] = next;
1355
- if ("ok" === type2) return result2;
1356
- throw result2;
1357
+ }
1358
+ async advanceTimersToNextTimerAsync(steps = 1) {
1359
+ if (this._checkFakeTimers()) for(let i = steps; i > 0; i--){
1360
+ await this._clock.nextAsync();
1361
+ await this._clock.tickAsync(0);
1362
+ if (0 === this._clock.countTimers()) break;
1357
1363
  }
1358
- let result, type = "ok", resultIndex = state2.results.length;
1359
- if (state2.impl) try {
1360
- new.target ? result = Reflect.construct(state2.impl, args, new.target) : result = state2.impl.apply(this, args), type = "ok";
1361
- } catch (err) {
1362
- throw result = err, type = "error", state2.results.push([
1363
- type,
1364
- err
1365
- ]), err;
1364
+ }
1365
+ advanceTimersByTime(msToRun) {
1366
+ if (this._checkFakeTimers()) this._clock.tick(msToRun);
1367
+ }
1368
+ async advanceTimersByTimeAsync(msToRun) {
1369
+ if (this._checkFakeTimers()) await this._clock.tickAsync(msToRun);
1370
+ }
1371
+ advanceTimersToNextFrame() {
1372
+ if (this._checkFakeTimers()) this._clock.runToFrame();
1373
+ }
1374
+ runAllTicks() {
1375
+ if (this._checkFakeTimers()) this._clock.runMicrotasks();
1376
+ }
1377
+ useRealTimers() {
1378
+ if (this._fakingTime) {
1379
+ this._clock.uninstall();
1380
+ this._fakingTime = false;
1366
1381
  }
1367
- let resultTuple = [
1368
- type,
1369
- result
1370
- ];
1371
- return isPromise(result) && result.then((r)=>state2.resolves[resultIndex] = [
1372
- "ok",
1373
- r
1374
- ], (e)=>state2.resolves[resultIndex] = [
1375
- "error",
1376
- e
1377
- ]), state2.results.push(resultTuple), result;
1378
- };
1379
- defineValue(fn, "_isMockFunction", !0), defineValue(fn, "length", cb ? cb.length : 0), defineValue(fn, "name", cb && cb.name || "spy");
1380
- let state = getInternalState(fn);
1381
- return state.reset(), state.impl = cb, fn;
1382
- }
1383
- function isMockFunction(obj) {
1384
- return !!obj && !0 === obj._isMockFunction;
1385
- }
1386
- var getDescriptor = (obj, method)=>{
1387
- let objDescriptor = Object.getOwnPropertyDescriptor(obj, method);
1388
- if (objDescriptor) return [
1389
- obj,
1390
- objDescriptor
1391
- ];
1392
- let currentProto = Object.getPrototypeOf(obj);
1393
- for(; null !== currentProto;){
1394
- let descriptor = Object.getOwnPropertyDescriptor(currentProto, method);
1395
- if (descriptor) return [
1396
- currentProto,
1397
- descriptor
1398
- ];
1399
- currentProto = Object.getPrototypeOf(currentProto);
1400
1382
  }
1401
- }, setPototype = (fn, val)=>{
1402
- null != val && "function" == typeof val && null != val.prototype && Object.setPrototypeOf(fn.prototype, val.prototype);
1403
- };
1404
- function internalSpyOn(obj, methodName, mock) {
1405
- dist_assert(!isType("undefined", obj), "spyOn could not find an object to spy upon"), dist_assert(isType("object", obj) || isType("function", obj), "cannot spyOn on a primitive value");
1406
- let [accessName, accessType] = (()=>{
1407
- if (!isType("object", methodName)) return [
1408
- methodName,
1409
- "value"
1410
- ];
1411
- if ("getter" in methodName && "setter" in methodName) throw new Error("cannot spy on both getter and setter");
1412
- if ("getter" in methodName) return [
1413
- methodName.getter,
1414
- "get"
1415
- ];
1416
- if ("setter" in methodName) return [
1417
- methodName.setter,
1418
- "set"
1419
- ];
1420
- throw new Error("specify getter or setter to spy on");
1421
- })(), [originalDescriptorObject, originalDescriptor] = getDescriptor(obj, accessName) || [];
1422
- dist_assert(originalDescriptor || accessName in obj, `${String(accessName)} does not exist`);
1423
- let ssr = !1;
1424
- "value" === accessType && originalDescriptor && !originalDescriptor.value && originalDescriptor.get && (accessType = "get", ssr = !0, mock = originalDescriptor.get());
1425
- let original;
1426
- originalDescriptor ? original = originalDescriptor[accessType] : "value" !== accessType ? original = ()=>obj[accessName] : original = obj[accessName], original && isSpyFunction(original) && (original = original[SYMBOL_STATE].getOriginal());
1427
- let reassign = (cb)=>{
1428
- let { value, ...desc } = originalDescriptor || {
1429
- configurable: !0,
1430
- writable: !0
1431
- };
1432
- "value" !== accessType && delete desc.writable, desc[accessType] = cb, dist_define(obj, accessName, desc);
1433
- }, restore = ()=>{
1434
- originalDescriptorObject !== obj ? Reflect.deleteProperty(obj, accessName) : originalDescriptor && !original ? dist_define(obj, accessName, originalDescriptor) : reassign(original);
1435
- };
1436
- mock || (mock = original);
1437
- let spy2 = wrap(createInternalSpy(mock), mock);
1438
- "value" === accessType && setPototype(spy2, original);
1439
- let state = spy2[SYMBOL_STATE];
1440
- 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;
1441
- }
1442
- var ignoreProperties = /* @__PURE__ */ new Set([
1443
- "length",
1444
- "name",
1445
- "prototype"
1446
- ]);
1447
- function getAllProperties(original) {
1448
- let properties = /* @__PURE__ */ new Set(), descriptors2 = {};
1449
- for(; original && original !== Object.prototype && original !== Function.prototype;){
1450
- let ownProperties = [
1451
- ...Object.getOwnPropertyNames(original),
1452
- ...Object.getOwnPropertySymbols(original)
1453
- ];
1454
- for (let prop of ownProperties)descriptors2[prop] || ignoreProperties.has(prop) || (properties.add(prop), descriptors2[prop] = Object.getOwnPropertyDescriptor(original, prop));
1455
- original = Object.getPrototypeOf(original);
1383
+ useFakeTimers(fakeTimersConfig = {}) {
1384
+ if (this._fakingTime) this._clock.uninstall();
1385
+ const toFake = Object.keys(this._fakeTimers.timers).filter((timer)=>'nextTick' !== timer && 'queueMicrotask' !== timer);
1386
+ const isChildProcess = 'undefined' != typeof process && !!process.send;
1387
+ if (this._config?.toFake?.includes('nextTick') && isChildProcess) throw new Error('process.nextTick cannot be mocked inside child_process');
1388
+ this._clock = this._fakeTimers.install({
1389
+ loopLimit: 10000,
1390
+ shouldClearNativeTimers: true,
1391
+ now: Date.now(),
1392
+ toFake: [
1393
+ ...toFake
1394
+ ],
1395
+ ignoreMissingTimers: true,
1396
+ ...fakeTimersConfig
1397
+ });
1398
+ this._fakingTime = true;
1456
1399
  }
1457
- return {
1458
- properties,
1459
- descriptors: descriptors2
1460
- };
1461
- }
1462
- function wrap(mock, original) {
1463
- if (!original || SYMBOL_STATE in original) return mock;
1464
- let { properties, descriptors: descriptors2 } = getAllProperties(original);
1465
- for (let key of properties){
1466
- let descriptor = descriptors2[key];
1467
- getDescriptor(mock, key) || dist_define(mock, key, descriptor);
1400
+ reset() {
1401
+ if (this._checkFakeTimers()) {
1402
+ const { now } = this._clock;
1403
+ this._clock.reset();
1404
+ this._clock.setSystemTime(now);
1405
+ }
1406
+ }
1407
+ setSystemTime(now) {
1408
+ if (this._checkFakeTimers()) this._clock.setSystemTime(now);
1409
+ }
1410
+ getRealSystemTime() {
1411
+ return fakeTimers_RealDate.now();
1412
+ }
1413
+ now() {
1414
+ if (this._fakingTime) return this._clock.now;
1415
+ return Date.now();
1416
+ }
1417
+ getTimerCount() {
1418
+ if (this._checkFakeTimers()) return this._clock.countTimers();
1419
+ return 0;
1420
+ }
1421
+ _checkFakeTimers() {
1422
+ if (!this._fakingTime) throw new Error('Timers are not mocked. Try calling "rstest.useFakeTimers()" first.');
1423
+ return this._fakingTime;
1424
+ }
1425
+ isFakeTimers() {
1426
+ return this._fakingTime;
1468
1427
  }
1469
- return mock;
1470
- }
1471
- function isSpyFunction(obj) {
1472
- return isMockFunction(obj) && "getOriginal" in obj[SYMBOL_STATE];
1473
1428
  }
1429
+ var dist = __webpack_require__("../../node_modules/.pnpm/tinyspy@4.0.3/node_modules/tinyspy/dist/index.js");
1474
1430
  let callOrder = 0;
1475
1431
  const mocks = new Set();
1476
1432
  const wrapSpy = (obj, methodName, mockFn)=>{
1477
- const spyImpl = internalSpyOn(obj, methodName, mockFn);
1433
+ const spyImpl = (0, dist.XD)(obj, methodName, mockFn);
1478
1434
  const spyFn = spyImpl;
1479
1435
  let mockImplementationOnce = [];
1480
1436
  let implementation = mockFn;
@@ -1485,7 +1441,7 @@ export const __webpack_modules__ = {
1485
1441
  invocationCallOrder: []
1486
1442
  });
1487
1443
  let mockState = initMockState();
1488
- const spyState = getInternalState(spyImpl);
1444
+ const spyState = (0, dist.eN)(spyImpl);
1489
1445
  spyFn.getMockName = ()=>mockName || methodName;
1490
1446
  spyFn.mockName = (name)=>{
1491
1447
  mockName = name;
@@ -1597,7 +1553,7 @@ export const __webpack_modules__ = {
1597
1553
  [defaultName]: mockFn
1598
1554
  }, defaultName, mockFn);
1599
1555
  };
1600
- const spy_spyOn = (obj, methodName, accessType)=>{
1556
+ const spyOn = (obj, methodName, accessType)=>{
1601
1557
  const accessTypeMap = {
1602
1558
  get: 'getter',
1603
1559
  set: 'setter'
@@ -1607,14 +1563,21 @@ export const __webpack_modules__ = {
1607
1563
  } : methodName;
1608
1564
  return wrapSpy(obj, method);
1609
1565
  };
1610
- const spy_isMockFunction = (fn)=>'function' == typeof fn && '_isMockFunction' in fn && fn._isMockFunction;
1566
+ const isMockFunction = (fn)=>'function' == typeof fn && '_isMockFunction' in fn && fn._isMockFunction;
1611
1567
  const createRstestUtilities = ()=>{
1612
1568
  const originalEnvValues = new Map();
1613
1569
  const originalGlobalValues = new Map();
1570
+ let _timers;
1571
+ const timers = ()=>{
1572
+ if (!_timers) _timers = new FakeTimers({
1573
+ global: globalThis
1574
+ });
1575
+ return _timers;
1576
+ };
1614
1577
  const rstest = {
1615
1578
  fn: spy_fn,
1616
- spyOn: spy_spyOn,
1617
- isMockFunction: spy_isMockFunction,
1579
+ spyOn: spyOn,
1580
+ isMockFunction: isMockFunction,
1618
1581
  clearAllMocks: ()=>{
1619
1582
  for (const mock of mocks)mock.mockClear();
1620
1583
  return rstest;
@@ -1633,6 +1596,7 @@ export const __webpack_modules__ = {
1633
1596
  doUnMock: ()=>{},
1634
1597
  importMock: async ()=>({}),
1635
1598
  importActual: async ()=>({}),
1599
+ requireActual: ()=>({}),
1636
1600
  resetModules: ()=>rstest,
1637
1601
  stubEnv: (name, value)=>{
1638
1602
  if (!originalEnvValues.has(name)) originalEnvValues.set(name, process.env[name]);
@@ -1663,6 +1627,65 @@ export const __webpack_modules__ = {
1663
1627
  });
1664
1628
  originalGlobalValues.clear();
1665
1629
  return rstest;
1630
+ },
1631
+ useFakeTimers: (opts)=>{
1632
+ timers().useFakeTimers(opts);
1633
+ return rstest;
1634
+ },
1635
+ useRealTimers: ()=>{
1636
+ timers().useRealTimers();
1637
+ return rstest;
1638
+ },
1639
+ setSystemTime: (now)=>{
1640
+ timers().setSystemTime(now);
1641
+ return rstest;
1642
+ },
1643
+ getRealSystemTime: ()=>_timers ? timers().getRealSystemTime() : Date.now(),
1644
+ isFakeTimers: ()=>_timers ? timers().isFakeTimers() : false,
1645
+ runAllTimers: ()=>{
1646
+ timers().runAllTimers();
1647
+ return rstest;
1648
+ },
1649
+ runAllTimersAsync: async ()=>{
1650
+ await timers().runAllTimersAsync();
1651
+ return rstest;
1652
+ },
1653
+ runAllTicks: ()=>{
1654
+ timers().runAllTicks();
1655
+ return rstest;
1656
+ },
1657
+ runOnlyPendingTimers: ()=>{
1658
+ timers().runOnlyPendingTimers();
1659
+ return rstest;
1660
+ },
1661
+ runOnlyPendingTimersAsync: async ()=>{
1662
+ await timers().runOnlyPendingTimersAsync();
1663
+ return rstest;
1664
+ },
1665
+ advanceTimersByTime: (ms)=>{
1666
+ timers().advanceTimersByTime(ms);
1667
+ return rstest;
1668
+ },
1669
+ advanceTimersByTimeAsync: async (ms)=>{
1670
+ await timers().advanceTimersByTimeAsync(ms);
1671
+ return rstest;
1672
+ },
1673
+ advanceTimersToNextTimer: (steps)=>{
1674
+ timers().advanceTimersToNextTimer(steps);
1675
+ return rstest;
1676
+ },
1677
+ advanceTimersToNextTimerAsync: async (steps)=>{
1678
+ await timers().advanceTimersToNextTimerAsync(steps);
1679
+ return rstest;
1680
+ },
1681
+ advanceTimersToNextFrame: ()=>{
1682
+ timers().advanceTimersToNextFrame();
1683
+ return rstest;
1684
+ },
1685
+ getTimerCount: ()=>timers().getTimerCount(),
1686
+ clearAllTimers: ()=>{
1687
+ timers().clearAllTimers();
1688
+ return rstest;
1666
1689
  }
1667
1690
  };
1668
1691
  return rstest;
@@ -1680,13 +1703,15 @@ export const __webpack_modules__ = {
1680
1703
  writable: true,
1681
1704
  configurable: true
1682
1705
  });
1706
+ const rstest = createRstestUtilities();
1683
1707
  return {
1684
1708
  runner,
1685
1709
  api: {
1686
1710
  ...runnerAPI,
1687
1711
  expect,
1688
1712
  assert: external_chai_.assert,
1689
- rstest: createRstestUtilities()
1713
+ rstest,
1714
+ rs: rstest
1690
1715
  }
1691
1716
  };
1692
1717
  };
package/dist/973.js CHANGED
@@ -337,78 +337,6 @@ export const __webpack_modules__ = {
337
337
  state.lastNeedle = needle;
338
338
  return state.lastIndex = binarySearch(haystack, needle, low, high);
339
339
  }
340
- function parse(map) {
341
- return 'string' == typeof map ? JSON.parse(map) : map;
342
- }
343
- function recurse(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) {
344
- const { sections } = input;
345
- for(let i = 0; i < sections.length; i++){
346
- const { map, offset } = sections[i];
347
- let sl = stopLine;
348
- let sc = stopColumn;
349
- if (i + 1 < sections.length) {
350
- const nextOffset = sections[i + 1].offset;
351
- sl = Math.min(stopLine, lineOffset + nextOffset.line);
352
- if (sl === stopLine) sc = Math.min(stopColumn, columnOffset + nextOffset.column);
353
- else if (sl < stopLine) sc = columnOffset + nextOffset.column;
354
- }
355
- addSection(map, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset + offset.line, columnOffset + offset.column, sl, sc);
356
- }
357
- }
358
- function addSection(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) {
359
- const parsed = parse(input);
360
- if ('sections' in parsed) return recurse(...arguments);
361
- const map = new TraceMap(parsed, mapUrl);
362
- const sourcesOffset = sources.length;
363
- const namesOffset = names.length;
364
- const decoded = decodedMappings(map);
365
- const { resolvedSources, sourcesContent: contents, ignoreList: ignores } = map;
366
- append(sources, resolvedSources);
367
- append(names, map.names);
368
- if (contents) append(sourcesContent, contents);
369
- else for(let i = 0; i < resolvedSources.length; i++)sourcesContent.push(null);
370
- if (ignores) for(let i = 0; i < ignores.length; i++)ignoreList.push(ignores[i] + sourcesOffset);
371
- for(let i = 0; i < decoded.length; i++){
372
- const lineI = lineOffset + i;
373
- if (lineI > stopLine) return;
374
- const out = getLine(mappings, lineI);
375
- const cOffset = 0 === i ? columnOffset : 0;
376
- const line = decoded[i];
377
- for(let j = 0; j < line.length; j++){
378
- const seg = line[j];
379
- const column = cOffset + seg[COLUMN];
380
- if (lineI === stopLine && column >= stopColumn) return;
381
- if (1 === seg.length) {
382
- out.push([
383
- column
384
- ]);
385
- continue;
386
- }
387
- const sourcesIndex = sourcesOffset + seg[SOURCES_INDEX];
388
- const sourceLine = seg[SOURCE_LINE];
389
- const sourceColumn = seg[SOURCE_COLUMN];
390
- out.push(4 === seg.length ? [
391
- column,
392
- sourcesIndex,
393
- sourceLine,
394
- sourceColumn
395
- ] : [
396
- column,
397
- sourcesIndex,
398
- sourceLine,
399
- sourceColumn,
400
- namesOffset + seg[NAMES_INDEX]
401
- ]);
402
- }
403
- }
404
- }
405
- function append(arr, other) {
406
- for(let i = 0; i < other.length; i++)arr.push(other[i]);
407
- }
408
- function getLine(arr, index) {
409
- for(let i = arr.length; i <= index; i++)arr[i] = [];
410
- return arr[index];
411
- }
412
340
  const LINE_GTR_ZERO = '`line` must be greater than 0 (lines start at line 1)';
413
341
  const COL_GTR_EQ_ZERO = '`column` must be greater than or equal to 0 (columns start at column 0)';
414
342
  const LEAST_UPPER_BOUND = -1;