@atlaspack/runtime-browser-hmr 2.14.19 → 2.14.21-typescript-08dcc1c9b.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.
@@ -1,4 +1,4 @@
1
- // @flow
1
+ import {Flow} from 'flow-to-typescript-codemod';
2
2
  /* global HMR_HOST, HMR_PORT, HMR_ENV_HASH, HMR_SECURE, HMR_USE_SSE, chrome, browser, __parcel__import__, __parcel__importScripts__, ServiceWorkerGlobalScope */
3
3
 
4
4
  /*::
@@ -51,55 +51,75 @@ declare var ServiceWorkerGlobalScope: Object;
51
51
 
52
52
  var OVERLAY_ID = '__parcel__error__overlay__';
53
53
 
54
+ // @ts-expect-error TS2339
54
55
  var OldModule = module.bundle.Module;
55
56
 
56
- function Module(moduleName) {
57
+ function Module(moduleName: any) {
58
+ // @ts-expect-error TS2683
57
59
  OldModule.call(this, moduleName);
60
+ // @ts-expect-error TS2683
58
61
  this.hot = {
62
+ // @ts-expect-error TS2339
59
63
  data: module.bundle.hotData[moduleName],
60
64
  _acceptCallbacks: [],
61
65
  _disposeCallbacks: [],
66
+ // @ts-expect-error TS7006
62
67
  accept: function (fn) {
63
68
  this._acceptCallbacks.push(fn || function () {});
64
69
  },
70
+ // @ts-expect-error TS7006
65
71
  dispose: function (fn) {
66
72
  this._disposeCallbacks.push(fn);
67
73
  },
68
74
  };
75
+ // @ts-expect-error TS2339
69
76
  module.bundle.hotData[moduleName] = undefined;
70
77
  }
78
+ // @ts-expect-error TS2339
71
79
  module.bundle.Module = Module;
80
+ // @ts-expect-error TS2339
72
81
  module.bundle.hotData = {};
73
82
 
83
+ // @ts-expect-error TS7034
74
84
  var checkedAssets /*: {|[string]: boolean|} */,
85
+ // @ts-expect-error TS7034
75
86
  disposedAssets /*: {|[string]: boolean|} */,
87
+ // @ts-expect-error TS7034
76
88
  assetsToDispose /*: Array<[ParcelRequire, string]> */,
89
+ // @ts-expect-error TS7034
77
90
  assetsToAccept /*: Array<[ParcelRequire, string]> */;
78
91
 
79
92
  function getHostname() {
80
93
  return (
94
+ // @ts-expect-error TS2304
81
95
  HMR_HOST ||
96
+ // @ts-expect-error TS2304
82
97
  (location.protocol.indexOf('http') === 0 ? location.hostname : 'localhost')
83
98
  );
84
99
  }
85
100
 
86
101
  function getPort() {
102
+ // @ts-expect-error TS2304
87
103
  return HMR_PORT || location.port;
88
104
  }
89
105
 
90
106
  // eslint-disable-next-line no-redeclare
107
+ // @ts-expect-error TS2339
91
108
  var parent = module.bundle.parent;
92
109
  if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
93
110
  var hostname = getHostname();
94
111
  var port = getPort();
95
112
  var protocol =
113
+ // @ts-expect-error TS2304
96
114
  HMR_SECURE ||
115
+ // @ts-expect-error TS2304
97
116
  (location.protocol == 'https:' &&
98
117
  !['localhost', '127.0.0.1', '0.0.0.0'].includes(hostname))
99
118
  ? 'wss'
100
119
  : 'ws';
101
120
 
102
121
  var ws;
122
+ // @ts-expect-error TS2304
103
123
  if (HMR_USE_SSE) {
104
124
  ws = new EventSource('/__parcel_hmr');
105
125
  } else {
@@ -107,7 +127,7 @@ if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
107
127
  ws = new WebSocket(
108
128
  protocol + '://' + hostname + (port ? ':' + port : '') + '/',
109
129
  );
110
- } catch (err) {
130
+ } catch (err: any) {
111
131
  if (err.message) {
112
132
  console.error(err.message);
113
133
  }
@@ -117,25 +137,33 @@ if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
117
137
 
118
138
  // Web extension context
119
139
  var extCtx =
140
+ // @ts-expect-error TS2304
120
141
  typeof browser === 'undefined'
121
- ? typeof chrome === 'undefined'
142
+ ? // @ts-expect-error TS2304
143
+ typeof chrome === 'undefined'
122
144
  ? null
123
- : chrome
124
- : browser;
145
+ : // @ts-expect-error TS2304
146
+ chrome
147
+ : // @ts-expect-error TS2304
148
+ browser;
125
149
 
126
150
  // Safari doesn't support sourceURL in error stacks.
127
151
  // eval may also be disabled via CSP, so do a quick check.
128
152
  var supportsSourceURL = false;
129
153
  try {
130
154
  (0, eval)('throw new Error("test"); //# sourceURL=test.js');
131
- } catch (err) {
155
+ } catch (err: any) {
132
156
  supportsSourceURL = err.stack.includes('test.js');
133
157
  }
134
158
 
135
- // $FlowFixMe
136
- ws.onmessage = async function (event /*: {data: string, ...} */) {
137
- checkedAssets = ({} /*: {|[string]: boolean|} */);
138
- disposedAssets = ({} /*: {|[string]: boolean|} */);
159
+ // @ts-expect-error TS2339
160
+ ws.onmessage = async function (
161
+ event: {
162
+ data: string;
163
+ } /*: {data: string, ...} */,
164
+ ) {
165
+ checkedAssets = {} /*: {|[string]: boolean|} */;
166
+ disposedAssets = {} /*: {|[string]: boolean|} */;
139
167
  assetsToAccept = [];
140
168
  assetsToDispose = [];
141
169
 
@@ -145,19 +173,23 @@ if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
145
173
  fullReload();
146
174
  } else if (data.type === 'update') {
147
175
  // Remove error overlay if there is one
176
+ // @ts-expect-error TS2304
148
177
  if (typeof document !== 'undefined') {
149
178
  removeErrorOverlay();
150
179
  }
151
180
 
152
181
  let assets = data.assets.filter(
182
+ // @ts-expect-error TS7006
153
183
  (asset) => asset.envHash === HMR_ENV_HASH,
154
184
  );
155
185
 
156
186
  // Handle HMR Update
187
+ // @ts-expect-error TS7006
157
188
  let handled = assets.every((asset) => {
158
189
  return (
159
190
  asset.type === 'css' ||
160
191
  (asset.type === 'js' &&
192
+ // @ts-expect-error TS2339
161
193
  hmrAcceptCheck(module.bundle.root, asset.id, asset.depsByBundle))
162
194
  );
163
195
  });
@@ -167,9 +199,11 @@ if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
167
199
 
168
200
  // Dispatch custom event so other runtimes (e.g React Refresh) are aware.
169
201
  if (
202
+ // @ts-expect-error TS2304
170
203
  typeof window !== 'undefined' &&
171
204
  typeof CustomEvent !== 'undefined'
172
205
  ) {
206
+ // @ts-expect-error TS2304
173
207
  window.dispatchEvent(new CustomEvent('parcelhmraccept'));
174
208
  }
175
209
 
@@ -178,11 +212,13 @@ if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
178
212
  hmrDisposeQueue();
179
213
 
180
214
  // Run accept callbacks. This will also re-execute other disposed assets in topological order.
181
- let processedAssets = {};
215
+ let processedAssets: Record<string, any> = {};
182
216
  for (let i = 0; i < assetsToAccept.length; i++) {
217
+ // @ts-expect-error TS7005
183
218
  let id = assetsToAccept[i][1];
184
219
 
185
220
  if (!processedAssets[id]) {
221
+ // @ts-expect-error TS7005
186
222
  hmrAccept(assetsToAccept[i][0], id);
187
223
  processedAssets[id] = true;
188
224
  }
@@ -207,22 +243,23 @@ if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
207
243
  );
208
244
  }
209
245
 
246
+ // @ts-expect-error TS2304
210
247
  if (typeof document !== 'undefined') {
211
248
  // Render the fancy html overlay
212
249
  removeErrorOverlay();
213
250
  var overlay = createErrorOverlay(data.diagnostics.html);
214
- // $FlowFixMe
251
+ // @ts-expect-error TS2304
215
252
  document.body.appendChild(overlay);
216
253
  }
217
254
  }
218
255
  };
219
256
  if (ws instanceof WebSocket) {
220
- ws.onerror = function (e) {
257
+ ws.onerror = function (e: any) {
221
258
  if (e.message) {
222
259
  console.error(e.message);
223
260
  }
224
261
  };
225
- ws.onclose = function (e) {
262
+ ws.onclose = function (e: CloseEvent) {
226
263
  if (process.env.ATLASPACK_BUILD_ENV !== 'test') {
227
264
  console.warn('[parcel] 🚨 Connection to the HMR server was lost');
228
265
  }
@@ -231,6 +268,7 @@ if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
231
268
  }
232
269
 
233
270
  function removeErrorOverlay() {
271
+ // @ts-expect-error TS2304
234
272
  var overlay = document.getElementById(OVERLAY_ID);
235
273
  if (overlay) {
236
274
  overlay.remove();
@@ -238,7 +276,20 @@ function removeErrorOverlay() {
238
276
  }
239
277
  }
240
278
 
241
- function createErrorOverlay(diagnostics) {
279
+ function createErrorOverlay(
280
+ diagnostics: Array<
281
+ Partial<
282
+ Flow.Diff<
283
+ // @ts-expect-error TS2304
284
+ AnsiDiagnosticResult,
285
+ {
286
+ codeframe: string;
287
+ }
288
+ >
289
+ >
290
+ >,
291
+ ) {
292
+ // @ts-expect-error TS2304
242
293
  var overlay = document.createElement('div');
243
294
  overlay.id = OVERLAY_ID;
244
295
 
@@ -247,7 +298,8 @@ function createErrorOverlay(diagnostics) {
247
298
 
248
299
  for (let diagnostic of diagnostics) {
249
300
  let stack = diagnostic.frames.length
250
- ? diagnostic.frames.reduce((p, frame) => {
301
+ ? // @ts-expect-error TS7006
302
+ diagnostic.frames.reduce((p, frame) => {
251
303
  return `${p}
252
304
  <a href="/__parcel_launch_editor?file=${encodeURIComponent(
253
305
  frame.location,
@@ -266,6 +318,7 @@ ${frame.code}`;
266
318
  <pre>${stack}</pre>
267
319
  <div>
268
320
  ${diagnostic.hints
321
+ // @ts-expect-error TS7006
269
322
  .map((hint) => '<div>💡 ' + hint + '</div>')
270
323
  .join('')}
271
324
  </div>
@@ -286,20 +339,27 @@ ${frame.code}`;
286
339
  }
287
340
 
288
341
  function fullReload() {
342
+ // @ts-expect-error TS2304
289
343
  if ('reload' in location) {
344
+ // @ts-expect-error TS2304
290
345
  location.reload();
291
346
  } else if (extCtx && extCtx.runtime && extCtx.runtime.reload) {
292
347
  extCtx.runtime.reload();
293
348
  }
294
349
  }
295
350
 
296
- function getParents(bundle, id) /*: Array<[ParcelRequire, string]> */ {
351
+ function getParents(
352
+ // @ts-expect-error TS2304
353
+ bundle: ParcelRequire,
354
+ id: string,
355
+ ) /*: Array<[ParcelRequire, string]> */ {
297
356
  var modules = bundle.modules;
298
357
  if (!modules) {
299
358
  return [];
300
359
  }
301
360
 
302
- var parents = [];
361
+ // @ts-expect-error TS2304
362
+ var parents: Array<[ParcelRequire, string]> = [];
303
363
  var k, d, dep;
304
364
 
305
365
  for (k in modules) {
@@ -319,38 +379,40 @@ function getParents(bundle, id) /*: Array<[ParcelRequire, string]> */ {
319
379
  return parents;
320
380
  }
321
381
 
322
- function updateLink(link) {
382
+ function updateLink(link: HTMLElement) {
383
+ // @ts-expect-error TS2339
323
384
  var href = link.getAttribute('href');
324
385
 
325
386
  if (!href) {
326
387
  return;
327
388
  }
389
+ // @ts-expect-error TS2339
328
390
  var newLink = link.cloneNode();
329
391
  newLink.onload = function () {
392
+ // @ts-expect-error TS2339
330
393
  if (link.parentNode !== null) {
331
- // $FlowFixMe
394
+ // @ts-expect-error TS2339
332
395
  link.parentNode.removeChild(link);
333
396
  }
334
397
  };
335
- newLink.setAttribute(
336
- 'href',
337
- // $FlowFixMe
338
- href.split('?')[0] + '?' + Date.now(),
339
- );
340
- // $FlowFixMe
398
+ newLink.setAttribute('href', href.split('?')[0] + '?' + Date.now());
399
+ // @ts-expect-error TS18047
341
400
  link.parentNode.insertBefore(newLink, link.nextSibling);
342
401
  }
343
402
 
403
+ // @ts-expect-error TS7034
344
404
  var cssTimeout = null;
345
405
  function reloadCSS() {
406
+ // @ts-expect-error TS7005
346
407
  if (cssTimeout) {
347
408
  return;
348
409
  }
349
410
 
350
411
  cssTimeout = setTimeout(function () {
412
+ // @ts-expect-error TS18047
413
+ var document = window.document;
351
414
  var links = document.querySelectorAll('link[rel="stylesheet"]');
352
415
  for (var i = 0; i < links.length; i++) {
353
- // $FlowFixMe[incompatible-type]
354
416
  var href /*: string */ = links[i].getAttribute('href');
355
417
  var hostname = getHostname();
356
418
  var servedFromHMRServer =
@@ -361,6 +423,7 @@ function reloadCSS() {
361
423
  : href.indexOf(hostname + ':' + getPort());
362
424
  var absolute =
363
425
  /^https?:\/\//i.test(href) &&
426
+ // @ts-expect-error TS18047
364
427
  href.indexOf(location.origin) !== 0 &&
365
428
  !servedFromHMRServer;
366
429
  if (!absolute) {
@@ -372,38 +435,60 @@ function reloadCSS() {
372
435
  }, 50);
373
436
  }
374
437
 
375
- function hmrDownload(asset) {
438
+ // @ts-expect-error TS2304
439
+ function hmrDownload(asset: HMRAsset) {
376
440
  if (asset.type === 'js') {
441
+ // @ts-expect-error TS18047
377
442
  if (typeof document !== 'undefined') {
443
+ // @ts-expect-error TS18047
378
444
  let script = document.createElement('script');
379
445
  script.src = asset.url + '?t=' + Date.now();
380
446
  if (asset.outputFormat === 'esmodule') {
381
447
  script.type = 'module';
382
448
  }
383
- return new Promise((resolve, reject) => {
384
- script.onload = () => resolve(script);
385
- script.onerror = reject;
386
- document.head?.appendChild(script);
387
- });
449
+ return new Promise(
450
+ (
451
+ resolve: (
452
+ result: Promise<HTMLScriptElement> | HTMLScriptElement,
453
+ ) => void,
454
+ reject: (error?: any) => void,
455
+ ) => {
456
+ script.onload = () => resolve(script);
457
+ script.onerror = reject;
458
+ // @ts-expect-error TS18047
459
+ document.head?.appendChild(script);
460
+ },
461
+ );
462
+ // @ts-expect-error TS2304
388
463
  } else if (typeof importScripts === 'function') {
389
464
  // Worker scripts
390
465
  if (asset.outputFormat === 'esmodule') {
466
+ // @ts-expect-error TS2304
391
467
  return __parcel__import__(asset.url + '?t=' + Date.now());
392
468
  } else {
393
- return new Promise((resolve, reject) => {
394
- try {
395
- __parcel__importScripts__(asset.url + '?t=' + Date.now());
396
- resolve();
397
- } catch (err) {
398
- reject(err);
399
- }
400
- });
469
+ return new Promise(
470
+ (
471
+ resolve: (result: Promise<undefined> | undefined) => void,
472
+ reject: (error?: any) => void,
473
+ ) => {
474
+ try {
475
+ // @ts-expect-error TS2304
476
+ __parcel__importScripts__(asset.url + '?t=' + Date.now());
477
+ // @ts-expect-error TS2794
478
+ resolve();
479
+ } catch (err: any) {
480
+ reject(err);
481
+ }
482
+ },
483
+ );
401
484
  }
402
485
  }
403
486
  }
404
487
  }
405
488
 
406
- async function hmrApplyUpdates(assets) {
489
+ // @ts-expect-error TS2304
490
+ async function hmrApplyUpdates(assets: Array<HMRAsset>) {
491
+ // @ts-expect-error TS7017
407
492
  global.parcelHotUpdate = Object.create(null);
408
493
 
409
494
  let scriptsToRemove;
@@ -416,13 +501,15 @@ async function hmrApplyUpdates(assets) {
416
501
  // This path is also taken if a CSP disallows eval.
417
502
  if (!supportsSourceURL) {
418
503
  let promises = assets.map((asset) =>
419
- hmrDownload(asset)?.catch((err) => {
504
+ hmrDownload(asset)?.catch((err: any) => {
420
505
  // Web extension fix
421
506
  if (
422
507
  extCtx &&
423
508
  extCtx.runtime &&
424
509
  extCtx.runtime.getManifest().manifest_version == 3 &&
510
+ // @ts-expect-error TS2304
425
511
  typeof ServiceWorkerGlobalScope != 'undefined' &&
512
+ // @ts-expect-error TS2304
426
513
  global instanceof ServiceWorkerGlobalScope
427
514
  ) {
428
515
  extCtx.runtime.reload();
@@ -436,14 +523,18 @@ async function hmrApplyUpdates(assets) {
436
523
  }
437
524
 
438
525
  assets.forEach(function (asset) {
526
+ // @ts-expect-error TS2339
439
527
  hmrApply(module.bundle.root, asset);
440
528
  });
441
529
  } finally {
530
+ // @ts-expect-error TS7017
442
531
  delete global.parcelHotUpdate;
443
532
 
444
533
  if (scriptsToRemove) {
534
+ // @ts-expect-error TS7006
445
535
  scriptsToRemove.forEach((script) => {
446
536
  if (script) {
537
+ // @ts-expect-error TS18047
447
538
  document.head?.removeChild(script);
448
539
  }
449
540
  });
@@ -451,7 +542,12 @@ async function hmrApplyUpdates(assets) {
451
542
  }
452
543
  }
453
544
 
454
- function hmrApply(bundle /*: ParcelRequire */, asset /*: HMRAsset */) {
545
+ function hmrApply(
546
+ // @ts-expect-error TS2304
547
+ bundle: ParcelRequire /*: ParcelRequire */,
548
+ // @ts-expect-error TS2304
549
+ asset: HMRAsset /*: HMRAsset */,
550
+ ) {
455
551
  var modules = bundle.modules;
456
552
  if (!modules) {
457
553
  return;
@@ -469,8 +565,10 @@ function hmrApply(bundle /*: ParcelRequire */, asset /*: HMRAsset */) {
469
565
  for (let dep in oldDeps) {
470
566
  if (!deps[dep] || deps[dep] !== oldDeps[dep]) {
471
567
  let id = oldDeps[dep];
568
+ // @ts-expect-error TS2339
472
569
  let parents = getParents(module.bundle.root, id);
473
570
  if (parents.length === 1) {
571
+ // @ts-expect-error TS2339
474
572
  hmrDelete(module.bundle.root, id);
475
573
  }
476
574
  }
@@ -483,7 +581,7 @@ function hmrApply(bundle /*: ParcelRequire */, asset /*: HMRAsset */) {
483
581
  (0, eval)(asset.output);
484
582
  }
485
583
 
486
- // $FlowFixMe
584
+ // @ts-expect-error TS7017
487
585
  let fn = global.parcelHotUpdate[asset.id];
488
586
  modules[asset.id] = [fn, deps];
489
587
  }
@@ -496,7 +594,8 @@ function hmrApply(bundle /*: ParcelRequire */, asset /*: HMRAsset */) {
496
594
  }
497
595
  }
498
596
 
499
- function hmrDelete(bundle, id) {
597
+ // @ts-expect-error TS2304
598
+ function hmrDelete(bundle: ParcelRequire, id: string) {
500
599
  let modules = bundle.modules;
501
600
  if (!modules) {
502
601
  return;
@@ -505,8 +604,9 @@ function hmrDelete(bundle, id) {
505
604
  if (modules[id]) {
506
605
  // Collect dependencies that will become orphaned when this module is deleted.
507
606
  let deps = modules[id][1];
508
- let orphans = [];
607
+ let orphans: Array<string> = [];
509
608
  for (let dep in deps) {
609
+ // @ts-expect-error TS2339
510
610
  let parents = getParents(module.bundle.root, deps[dep]);
511
611
  if (parents.length === 1) {
512
612
  orphans.push(deps[dep]);
@@ -519,6 +619,7 @@ function hmrDelete(bundle, id) {
519
619
 
520
620
  // Now delete the orphans.
521
621
  orphans.forEach((id) => {
622
+ // @ts-expect-error TS2339
522
623
  hmrDelete(module.bundle.root, id);
523
624
  });
524
625
  } else if (bundle.parent) {
@@ -527,25 +628,36 @@ function hmrDelete(bundle, id) {
527
628
  }
528
629
 
529
630
  function hmrAcceptCheck(
530
- bundle /*: ParcelRequire */,
531
- id /*: string */,
532
- depsByBundle /*: ?{ [string]: { [string]: string } }*/,
631
+ // @ts-expect-error TS2304
632
+ bundle: ParcelRequire /*: ParcelRequire */,
633
+ id: string /*: string */,
634
+ depsByBundle:
635
+ | {
636
+ [key: string]: {
637
+ [key: string]: string;
638
+ };
639
+ }
640
+ | null
641
+ | undefined /*: ?{ [string]: { [string]: string } }*/,
533
642
  ) {
534
643
  if (hmrAcceptCheckOne(bundle, id, depsByBundle)) {
535
644
  return true;
536
645
  }
537
646
 
538
647
  // Traverse parents breadth first. All possible ancestries must accept the HMR update, or we'll reload.
648
+ // @ts-expect-error TS2339
539
649
  let parents = getParents(module.bundle.root, id);
540
650
  let accepted = false;
541
651
  while (parents.length > 0) {
542
652
  let v = parents.shift();
653
+ // @ts-expect-error TS18048
543
654
  let a = hmrAcceptCheckOne(v[0], v[1], null);
544
655
  if (a) {
545
656
  // If this parent accepts, stop traversing upward, but still consider siblings.
546
657
  accepted = true;
547
658
  } else {
548
659
  // Otherwise, queue the parents in the next level upward.
660
+ // @ts-expect-error TS2339
549
661
  let p = getParents(module.bundle.root, v[1]);
550
662
  if (p.length === 0) {
551
663
  // If there are no parents, then we've reached an entry without accepting. Reload.
@@ -560,9 +672,17 @@ function hmrAcceptCheck(
560
672
  }
561
673
 
562
674
  function hmrAcceptCheckOne(
563
- bundle /*: ParcelRequire */,
564
- id /*: string */,
565
- depsByBundle /*: ?{ [string]: { [string]: string } }*/,
675
+ // @ts-expect-error TS2304
676
+ bundle: ParcelRequire /*: ParcelRequire */,
677
+ id: string /*: string */,
678
+ depsByBundle:
679
+ | {
680
+ [key: string]: {
681
+ [key: string]: string;
682
+ };
683
+ }
684
+ | null
685
+ | undefined /*: ?{ [string]: { [string]: string } }*/,
566
686
  ) {
567
687
  var modules = bundle.modules;
568
688
  if (!modules) {
@@ -579,10 +699,12 @@ function hmrAcceptCheckOne(
579
699
  return hmrAcceptCheck(bundle.parent, id, depsByBundle);
580
700
  }
581
701
 
702
+ // @ts-expect-error TS7005
582
703
  if (checkedAssets[id]) {
583
704
  return true;
584
705
  }
585
706
 
707
+ // @ts-expect-error TS7005
586
708
  checkedAssets[id] = true;
587
709
 
588
710
  var cached = bundle.cache[id];
@@ -597,9 +719,12 @@ function hmrAcceptCheckOne(
597
719
  function hmrDisposeQueue() {
598
720
  // Dispose all old assets.
599
721
  for (let i = 0; i < assetsToDispose.length; i++) {
722
+ // @ts-expect-error TS7005
600
723
  let id = assetsToDispose[i][1];
601
724
 
725
+ // @ts-expect-error TS7005
602
726
  if (!disposedAssets[id]) {
727
+ // @ts-expect-error TS7005
603
728
  hmrDispose(assetsToDispose[i][0], id);
604
729
  disposedAssets[id] = true;
605
730
  }
@@ -608,7 +733,11 @@ function hmrDisposeQueue() {
608
733
  assetsToDispose = [];
609
734
  }
610
735
 
611
- function hmrDispose(bundle /*: ParcelRequire */, id /*: string */) {
736
+ function hmrDispose(
737
+ // @ts-expect-error TS2304
738
+ bundle: ParcelRequire /*: ParcelRequire */,
739
+ id: string /*: string */,
740
+ ) {
612
741
  var cached = bundle.cache[id];
613
742
  bundle.hotData[id] = {};
614
743
  if (cached && cached.hot) {
@@ -616,6 +745,7 @@ function hmrDispose(bundle /*: ParcelRequire */, id /*: string */) {
616
745
  }
617
746
 
618
747
  if (cached && cached.hot && cached.hot._disposeCallbacks.length) {
748
+ // @ts-expect-error TS7006
619
749
  cached.hot._disposeCallbacks.forEach(function (cb) {
620
750
  cb(bundle.hotData[id]);
621
751
  });
@@ -624,25 +754,33 @@ function hmrDispose(bundle /*: ParcelRequire */, id /*: string */) {
624
754
  delete bundle.cache[id];
625
755
  }
626
756
 
627
- function hmrAccept(bundle /*: ParcelRequire */, id /*: string */) {
757
+ function hmrAccept(
758
+ // @ts-expect-error TS2304
759
+ bundle: ParcelRequire /*: ParcelRequire */,
760
+ id: string /*: string */,
761
+ ) {
628
762
  // Execute the module.
629
763
  bundle(id);
630
764
 
631
765
  // Run the accept callbacks in the new version of the module.
632
766
  var cached = bundle.cache[id];
633
767
  if (cached && cached.hot && cached.hot._acceptCallbacks.length) {
634
- let assetsToAlsoAccept = [];
768
+ let assetsToAlsoAccept: Array<never> = [];
769
+ // @ts-expect-error TS7006
635
770
  cached.hot._acceptCallbacks.forEach(function (cb) {
636
771
  let additionalAssets = cb(function () {
772
+ // @ts-expect-error TS2339
637
773
  return getParents(module.bundle.root, id);
638
774
  });
639
775
  if (Array.isArray(additionalAssets) && additionalAssets.length) {
776
+ // @ts-expect-error TS2345
640
777
  assetsToAlsoAccept.push(...additionalAssets);
641
778
  }
642
779
  });
643
780
 
644
781
  if (assetsToAlsoAccept.length > 0) {
645
782
  let handled = assetsToAlsoAccept.every(function (a) {
783
+ // @ts-expect-error TS2554
646
784
  return hmrAcceptCheck(a[0], a[1]);
647
785
  });
648
786
 
package/tsconfig.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "include": ["src"]
4
+ }