@atlaspack/runtime-browser-hmr 2.14.21-typescript-5b4d3ad41.0 → 2.14.21

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaspack/runtime-browser-hmr
2
2
 
3
+ ## 2.14.21
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - @atlaspack/utils@2.17.3
9
+ - @atlaspack/plugin@2.14.21
10
+
3
11
  ## 2.14.20
4
12
 
5
13
  ### Patch Changes
package/lib/HMRRuntime.js CHANGED
@@ -30,9 +30,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
30
30
  // lives in `/app/packages/runtimes/...` and thus the `config` in the JSTransformer is actually the
31
31
  // user's package.json, and hmr-runtime.js is transpiled as a JSX asset.
32
32
  const FILENAME =
33
- // @ts-expect-error TS2339
33
+ // $FlowFixMe
34
34
  process.env.ATLASPACK_BUILD_REPL && process.browser ? '/' + __filename : __filename;
35
- const HMR_RUNTIME = process.env.ATLASPACK_REGISTER_USE_SRC === 'true' ? _fs().default.readFileSync(_path().default.join(__dirname, './loaders/hmr-runtime.ts'), 'utf8') : _fs().default.readFileSync(_path().default.join(__dirname, './loaders/hmr-runtime.js'), 'utf8');
35
+ const HMR_RUNTIME = _fs().default.readFileSync(_path().default.join(__dirname, './loaders/hmr-runtime.js'), 'utf8');
36
36
  var _default = exports.default = new (_plugin().Runtime)({
37
37
  apply({
38
38
  bundle,
@@ -51,7 +51,7 @@ var _default = exports.default = new (_plugin().Runtime)({
51
51
  // Default to the HTTP port in the browser, only override
52
52
  // in watch mode or if hmr port != serve port
53
53
  !options.serveOptions || options.serveOptions.port !== port) ? port : null)};` + `var HMR_SECURE = ${JSON.stringify(!!(options.serveOptions && options.serveOptions.https))};` + `var HMR_ENV_HASH = "${bundle.env.id}";` + `var HMR_USE_SSE = ${JSON.stringify(
54
- // @ts-expect-error TS2339
54
+ // $FlowFixMe
55
55
  !!(process.env.ATLASPACK_BUILD_REPL && process.browser))};` + `module.bundle.HMR_BUNDLE_ID = ${JSON.stringify(bundle.id)};` + HMR_RUNTIME,
56
56
  isEntry: true,
57
57
  env: {
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  /* global HMR_HOST, HMR_PORT, HMR_ENV_HASH, HMR_SECURE, HMR_USE_SSE, chrome, browser, __parcel__import__, __parcel__importScripts__, ServiceWorkerGlobalScope */
4
-
5
4
  /*::
6
5
  import type {
7
6
  HMRAsset,
@@ -49,76 +48,41 @@ declare var __parcel__importScripts__: (string) => Promise<void>;
49
48
  declare var globalThis: typeof self;
50
49
  declare var ServiceWorkerGlobalScope: Object;
51
50
  */
52
-
53
- // flow-to-ts helpers
54
-
55
- // /flow-to-ts helpers
56
-
57
51
  var OVERLAY_ID = '__parcel__error__overlay__';
58
-
59
- // @ts-expect-error TS2339
60
52
  var OldModule = module.bundle.Module;
61
53
  function Module(moduleName) {
62
- // @ts-expect-error TS2683
63
54
  OldModule.call(this, moduleName);
64
- // @ts-expect-error TS2683
65
55
  this.hot = {
66
- // @ts-expect-error TS2339
67
56
  data: module.bundle.hotData[moduleName],
68
57
  _acceptCallbacks: [],
69
58
  _disposeCallbacks: [],
70
- // @ts-expect-error TS7006
71
59
  accept: function (fn) {
72
60
  this._acceptCallbacks.push(fn || function () {});
73
61
  },
74
- // @ts-expect-error TS7006
75
62
  dispose: function (fn) {
76
63
  this._disposeCallbacks.push(fn);
77
64
  }
78
65
  };
79
- // @ts-expect-error TS2339
80
66
  module.bundle.hotData[moduleName] = undefined;
81
67
  }
82
- // @ts-expect-error TS2339
83
68
  module.bundle.Module = Module;
84
- // @ts-expect-error TS2339
85
69
  module.bundle.hotData = {};
86
-
87
- // @ts-expect-error TS7034
88
- var checkedAssets /*: {|[string]: boolean|} */,
89
- // @ts-expect-error TS7034
90
- disposedAssets /*: {|[string]: boolean|} */,
91
- // @ts-expect-error TS7034
92
- assetsToDispose /*: Array<[ParcelRequire, string]> */,
93
- // @ts-expect-error TS7034
94
- assetsToAccept /*: Array<[ParcelRequire, string]> */;
70
+ var checkedAssets /*: {|[string]: boolean|} */, disposedAssets /*: {|[string]: boolean|} */, assetsToDispose /*: Array<[ParcelRequire, string]> */, assetsToAccept /*: Array<[ParcelRequire, string]> */;
95
71
 
96
72
  function getHostname() {
97
- return (
98
- // @ts-expect-error TS2304
99
- HMR_HOST || (
100
- // @ts-expect-error TS2304
101
- location.protocol.indexOf('http') === 0 ? location.hostname : 'localhost')
102
- );
73
+ return HMR_HOST || (location.protocol.indexOf('http') === 0 ? location.hostname : 'localhost');
103
74
  }
104
75
  function getPort() {
105
- // @ts-expect-error TS2304
106
76
  return HMR_PORT || location.port;
107
77
  }
108
78
 
109
79
  // eslint-disable-next-line no-redeclare
110
- // @ts-expect-error TS2339
111
80
  var parent = module.bundle.parent;
112
81
  if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
113
82
  var hostname = getHostname();
114
83
  var port = getPort();
115
- var protocol =
116
- // @ts-expect-error TS2304
117
- HMR_SECURE ||
118
- // @ts-expect-error TS2304
119
- location.protocol == 'https:' && !['localhost', '127.0.0.1', '0.0.0.0'].includes(hostname) ? 'wss' : 'ws';
84
+ var protocol = HMR_SECURE || location.protocol == 'https:' && !['localhost', '127.0.0.1', '0.0.0.0'].includes(hostname) ? 'wss' : 'ws';
120
85
  var ws;
121
- // @ts-expect-error TS2304
122
86
  if (HMR_USE_SSE) {
123
87
  ws = new EventSource('/__parcel_hmr');
124
88
  } else {
@@ -133,15 +97,7 @@ if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
133
97
  }
134
98
 
135
99
  // Web extension context
136
- var extCtx =
137
- // @ts-expect-error TS2304
138
- typeof browser === 'undefined' ?
139
- // @ts-expect-error TS2304
140
- typeof chrome === 'undefined' ? null :
141
- // @ts-expect-error TS2304
142
- chrome :
143
- // @ts-expect-error TS2304
144
- browser;
100
+ var extCtx = typeof browser === 'undefined' ? typeof chrome === 'undefined' ? null : chrome : browser;
145
101
 
146
102
  // Safari doesn't support sourceURL in error stacks.
147
103
  // eval may also be disabled via CSP, so do a quick check.
@@ -152,8 +108,8 @@ if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
152
108
  supportsSourceURL = err.stack.includes('test.js');
153
109
  }
154
110
 
155
- // @ts-expect-error TS2339
156
- ws.onmessage = async function (event) {
111
+ // $FlowFixMe
112
+ ws.onmessage = async function (event /*: {data: string, ...} */) {
157
113
  checkedAssets = {} /*: {|[string]: boolean|} */;
158
114
  disposedAssets = {} /*: {|[string]: boolean|} */;
159
115
  assetsToAccept = [];
@@ -163,29 +119,20 @@ if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
163
119
  fullReload();
164
120
  } else if (data.type === 'update') {
165
121
  // Remove error overlay if there is one
166
- // @ts-expect-error TS2304
167
122
  if (typeof document !== 'undefined') {
168
123
  removeErrorOverlay();
169
124
  }
170
- let assets = data.assets.filter(
171
- // @ts-expect-error TS7006
172
- asset => asset.envHash === HMR_ENV_HASH);
125
+ let assets = data.assets.filter(asset => asset.envHash === HMR_ENV_HASH);
173
126
 
174
127
  // Handle HMR Update
175
- // @ts-expect-error TS7006
176
128
  let handled = assets.every(asset => {
177
- return asset.type === 'css' || asset.type === 'js' &&
178
- // @ts-expect-error TS2339
179
- hmrAcceptCheck(module.bundle.root, asset.id, asset.depsByBundle);
129
+ return asset.type === 'css' || asset.type === 'js' && hmrAcceptCheck(module.bundle.root, asset.id, asset.depsByBundle);
180
130
  });
181
131
  if (handled) {
182
132
  console.clear();
183
133
 
184
134
  // Dispatch custom event so other runtimes (e.g React Refresh) are aware.
185
- if (
186
- // @ts-expect-error TS2304
187
- typeof window !== 'undefined' && typeof CustomEvent !== 'undefined') {
188
- // @ts-expect-error TS2304
135
+ if (typeof window !== 'undefined' && typeof CustomEvent !== 'undefined') {
189
136
  window.dispatchEvent(new CustomEvent('parcelhmraccept'));
190
137
  }
191
138
  await hmrApplyUpdates(assets);
@@ -194,10 +141,8 @@ if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
194
141
  // Run accept callbacks. This will also re-execute other disposed assets in topological order.
195
142
  let processedAssets = {};
196
143
  for (let i = 0; i < assetsToAccept.length; i++) {
197
- // @ts-expect-error TS7005
198
144
  let id = assetsToAccept[i][1];
199
145
  if (!processedAssets[id]) {
200
- // @ts-expect-error TS7005
201
146
  hmrAccept(assetsToAccept[i][0], id);
202
147
  processedAssets[id] = true;
203
148
  }
@@ -210,13 +155,11 @@ if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
210
155
  let stack = ansiDiagnostic.codeframe ? ansiDiagnostic.codeframe : ansiDiagnostic.stack;
211
156
  console.error('🚨 [parcel]: ' + ansiDiagnostic.message + '\n' + stack + '\n\n' + ansiDiagnostic.hints.join('\n'));
212
157
  }
213
-
214
- // @ts-expect-error TS2304
215
158
  if (typeof document !== 'undefined') {
216
159
  // Render the fancy html overlay
217
160
  removeErrorOverlay();
218
161
  var overlay = createErrorOverlay(data.diagnostics.html);
219
- // @ts-expect-error TS2304
162
+ // $FlowFixMe
220
163
  document.body.appendChild(overlay);
221
164
  }
222
165
  }
@@ -235,7 +178,6 @@ if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
235
178
  }
236
179
  }
237
180
  function removeErrorOverlay() {
238
- // @ts-expect-error TS2304
239
181
  var overlay = document.getElementById(OVERLAY_ID);
240
182
  if (overlay) {
241
183
  overlay.remove();
@@ -243,14 +185,11 @@ function removeErrorOverlay() {
243
185
  }
244
186
  }
245
187
  function createErrorOverlay(diagnostics) {
246
- // @ts-expect-error TS2304
247
188
  var overlay = document.createElement('div');
248
189
  overlay.id = OVERLAY_ID;
249
190
  let errorHTML = '<div style="background: black; opacity: 0.85; font-size: 16px; color: white; position: fixed; height: 100%; width: 100%; top: 0px; left: 0px; padding: 30px; font-family: Menlo, Consolas, monospace; z-index: 9999;">';
250
191
  for (let diagnostic of diagnostics) {
251
- let stack = diagnostic.frames.length ?
252
- // @ts-expect-error TS7006
253
- diagnostic.frames.reduce((p, frame) => {
192
+ let stack = diagnostic.frames.length ? diagnostic.frames.reduce((p, frame) => {
254
193
  return `${p}
255
194
  <a href="/__parcel_launch_editor?file=${encodeURIComponent(frame.location)}" style="text-decoration: underline; color: #888" onclick="fetch(this.href); return false">${frame.location}</a>
256
195
  ${frame.code}`;
@@ -262,9 +201,7 @@ ${frame.code}`;
262
201
  </div>
263
202
  <pre>${stack}</pre>
264
203
  <div>
265
- ${diagnostic.hints
266
- // @ts-expect-error TS7006
267
- .map(hint => '<div>💡 ' + hint + '</div>').join('')}
204
+ ${diagnostic.hints.map(hint => '<div>💡 ' + hint + '</div>').join('')}
268
205
  </div>
269
206
  ${diagnostic.documentation ? `<div>📝 <a style="color: violet" href="${diagnostic.documentation}" target="_blank">Learn more</a></div>` : ''}
270
207
  </div>
@@ -275,23 +212,17 @@ ${frame.code}`;
275
212
  return overlay;
276
213
  }
277
214
  function fullReload() {
278
- // @ts-expect-error TS2304
279
215
  if ('reload' in location) {
280
- // @ts-expect-error TS2304
281
216
  location.reload();
282
217
  } else if (extCtx && extCtx.runtime && extCtx.runtime.reload) {
283
218
  extCtx.runtime.reload();
284
219
  }
285
220
  }
286
- function getParents(
287
- // @ts-expect-error TS2304
288
- bundle, id) /*: Array<[ParcelRequire, string]> */{
221
+ function getParents(bundle, id) /*: Array<[ParcelRequire, string]> */{
289
222
  var modules = bundle.modules;
290
223
  if (!modules) {
291
224
  return [];
292
225
  }
293
-
294
- // @ts-expect-error TS2304
295
226
  var parents = [];
296
227
  var k, d, dep;
297
228
  for (k in modules) {
@@ -308,43 +239,36 @@ bundle, id) /*: Array<[ParcelRequire, string]> */{
308
239
  return parents;
309
240
  }
310
241
  function updateLink(link) {
311
- // @ts-expect-error TS2339
312
242
  var href = link.getAttribute('href');
313
243
  if (!href) {
314
244
  return;
315
245
  }
316
- // @ts-expect-error TS2339
317
246
  var newLink = link.cloneNode();
318
247
  newLink.onload = function () {
319
- // @ts-expect-error TS2339
320
248
  if (link.parentNode !== null) {
321
- // @ts-expect-error TS2339
249
+ // $FlowFixMe
322
250
  link.parentNode.removeChild(link);
323
251
  }
324
252
  };
325
- newLink.setAttribute('href', href.split('?')[0] + '?' + Date.now());
326
- // @ts-expect-error TS18047
253
+ newLink.setAttribute('href',
254
+ // $FlowFixMe
255
+ href.split('?')[0] + '?' + Date.now());
256
+ // $FlowFixMe
327
257
  link.parentNode.insertBefore(newLink, link.nextSibling);
328
258
  }
329
-
330
- // @ts-expect-error TS7034
331
259
  var cssTimeout = null;
332
260
  function reloadCSS() {
333
- // @ts-expect-error TS7005
334
261
  if (cssTimeout) {
335
262
  return;
336
263
  }
337
264
  cssTimeout = setTimeout(function () {
338
- // @ts-expect-error TS18047
339
- var document = window.document;
340
265
  var links = document.querySelectorAll('link[rel="stylesheet"]');
341
266
  for (var i = 0; i < links.length; i++) {
267
+ // $FlowFixMe[incompatible-type]
342
268
  var href /*: string */ = links[i].getAttribute('href');
343
269
  var hostname = getHostname();
344
270
  var servedFromHMRServer = hostname === 'localhost' ? new RegExp('^(https?:\\/\\/(0.0.0.0|127.0.0.1)|localhost):' + getPort()).test(href) : href.indexOf(hostname + ':' + getPort());
345
- var absolute = /^https?:\/\//i.test(href) &&
346
- // @ts-expect-error TS18047
347
- href.indexOf(location.origin) !== 0 && !servedFromHMRServer;
271
+ var absolute = /^https?:\/\//i.test(href) && href.indexOf(location.origin) !== 0 && !servedFromHMRServer;
348
272
  if (!absolute) {
349
273
  updateLink(links[i]);
350
274
  }
@@ -352,13 +276,9 @@ function reloadCSS() {
352
276
  cssTimeout = null;
353
277
  }, 50);
354
278
  }
355
-
356
- // @ts-expect-error TS2304
357
279
  function hmrDownload(asset) {
358
280
  if (asset.type === 'js') {
359
- // @ts-expect-error TS18047
360
281
  if (typeof document !== 'undefined') {
361
- // @ts-expect-error TS18047
362
282
  let script = document.createElement('script');
363
283
  script.src = asset.url + '?t=' + Date.now();
364
284
  if (asset.outputFormat === 'esmodule') {
@@ -368,21 +288,16 @@ function hmrDownload(asset) {
368
288
  var _document$head;
369
289
  script.onload = () => resolve(script);
370
290
  script.onerror = reject;
371
- // @ts-expect-error TS18047
372
291
  (_document$head = document.head) === null || _document$head === void 0 || _document$head.appendChild(script);
373
292
  });
374
- // @ts-expect-error TS2304
375
293
  } else if (typeof importScripts === 'function') {
376
294
  // Worker scripts
377
295
  if (asset.outputFormat === 'esmodule') {
378
- // @ts-expect-error TS2304
379
296
  return __parcel__import__(asset.url + '?t=' + Date.now());
380
297
  } else {
381
298
  return new Promise((resolve, reject) => {
382
299
  try {
383
- // @ts-expect-error TS2304
384
300
  __parcel__importScripts__(asset.url + '?t=' + Date.now());
385
- // @ts-expect-error TS2794
386
301
  resolve();
387
302
  } catch (err) {
388
303
  reject(err);
@@ -392,10 +307,7 @@ function hmrDownload(asset) {
392
307
  }
393
308
  }
394
309
  }
395
-
396
- // @ts-expect-error TS2304
397
310
  async function hmrApplyUpdates(assets) {
398
- // @ts-expect-error TS7017
399
311
  global.parcelHotUpdate = Object.create(null);
400
312
  let scriptsToRemove;
401
313
  try {
@@ -410,11 +322,7 @@ async function hmrApplyUpdates(assets) {
410
322
  var _hmrDownload;
411
323
  return (_hmrDownload = hmrDownload(asset)) === null || _hmrDownload === void 0 ? void 0 : _hmrDownload.catch(err => {
412
324
  // Web extension fix
413
- if (extCtx && extCtx.runtime && extCtx.runtime.getManifest().manifest_version == 3 &&
414
- // @ts-expect-error TS2304
415
- typeof ServiceWorkerGlobalScope != 'undefined' &&
416
- // @ts-expect-error TS2304
417
- global instanceof ServiceWorkerGlobalScope) {
325
+ if (extCtx && extCtx.runtime && extCtx.runtime.getManifest().manifest_version == 3 && typeof ServiceWorkerGlobalScope != 'undefined' && global instanceof ServiceWorkerGlobalScope) {
418
326
  extCtx.runtime.reload();
419
327
  return;
420
328
  }
@@ -424,29 +332,21 @@ async function hmrApplyUpdates(assets) {
424
332
  scriptsToRemove = await Promise.all(promises);
425
333
  }
426
334
  assets.forEach(function (asset) {
427
- // @ts-expect-error TS2339
428
335
  hmrApply(module.bundle.root, asset);
429
336
  });
430
337
  } finally {
431
- // @ts-expect-error TS7017
432
338
  delete global.parcelHotUpdate;
433
339
  if (scriptsToRemove) {
434
- // @ts-expect-error TS7006
435
340
  scriptsToRemove.forEach(script => {
436
341
  if (script) {
437
342
  var _document$head2;
438
- // @ts-expect-error TS18047
439
343
  (_document$head2 = document.head) === null || _document$head2 === void 0 || _document$head2.removeChild(script);
440
344
  }
441
345
  });
442
346
  }
443
347
  }
444
348
  }
445
- function hmrApply(
446
- // @ts-expect-error TS2304
447
- bundle,
448
- // @ts-expect-error TS2304
449
- asset) {
349
+ function hmrApply(bundle /*: ParcelRequire */, asset /*: HMRAsset */) {
450
350
  var modules = bundle.modules;
451
351
  if (!modules) {
452
352
  return;
@@ -463,10 +363,8 @@ asset) {
463
363
  for (let dep in oldDeps) {
464
364
  if (!deps[dep] || deps[dep] !== oldDeps[dep]) {
465
365
  let id = oldDeps[dep];
466
- // @ts-expect-error TS2339
467
366
  let parents = getParents(module.bundle.root, id);
468
367
  if (parents.length === 1) {
469
- // @ts-expect-error TS2339
470
368
  hmrDelete(module.bundle.root, id);
471
369
  }
472
370
  }
@@ -478,7 +376,7 @@ asset) {
478
376
  (0, eval)(asset.output);
479
377
  }
480
378
 
481
- // @ts-expect-error TS7017
379
+ // $FlowFixMe
482
380
  let fn = global.parcelHotUpdate[asset.id];
483
381
  modules[asset.id] = [fn, deps];
484
382
  }
@@ -490,8 +388,6 @@ asset) {
490
388
  }
491
389
  }
492
390
  }
493
-
494
- // @ts-expect-error TS2304
495
391
  function hmrDelete(bundle, id) {
496
392
  let modules = bundle.modules;
497
393
  if (!modules) {
@@ -502,7 +398,6 @@ function hmrDelete(bundle, id) {
502
398
  let deps = modules[id][1];
503
399
  let orphans = [];
504
400
  for (let dep in deps) {
505
- // @ts-expect-error TS2339
506
401
  let parents = getParents(module.bundle.root, deps[dep]);
507
402
  if (parents.length === 1) {
508
403
  orphans.push(deps[dep]);
@@ -515,34 +410,28 @@ function hmrDelete(bundle, id) {
515
410
 
516
411
  // Now delete the orphans.
517
412
  orphans.forEach(id => {
518
- // @ts-expect-error TS2339
519
413
  hmrDelete(module.bundle.root, id);
520
414
  });
521
415
  } else if (bundle.parent) {
522
416
  hmrDelete(bundle.parent, id);
523
417
  }
524
418
  }
525
- function hmrAcceptCheck(
526
- // @ts-expect-error TS2304
527
- bundle, id, depsByBundle) {
419
+ function hmrAcceptCheck(bundle /*: ParcelRequire */, id /*: string */, depsByBundle /*: ?{ [string]: { [string]: string } }*/) {
528
420
  if (hmrAcceptCheckOne(bundle, id, depsByBundle)) {
529
421
  return true;
530
422
  }
531
423
 
532
424
  // Traverse parents breadth first. All possible ancestries must accept the HMR update, or we'll reload.
533
- // @ts-expect-error TS2339
534
425
  let parents = getParents(module.bundle.root, id);
535
426
  let accepted = false;
536
427
  while (parents.length > 0) {
537
428
  let v = parents.shift();
538
- // @ts-expect-error TS18048
539
429
  let a = hmrAcceptCheckOne(v[0], v[1], null);
540
430
  if (a) {
541
431
  // If this parent accepts, stop traversing upward, but still consider siblings.
542
432
  accepted = true;
543
433
  } else {
544
434
  // Otherwise, queue the parents in the next level upward.
545
- // @ts-expect-error TS2339
546
435
  let p = getParents(module.bundle.root, v[1]);
547
436
  if (p.length === 0) {
548
437
  // If there are no parents, then we've reached an entry without accepting. Reload.
@@ -554,9 +443,7 @@ bundle, id, depsByBundle) {
554
443
  }
555
444
  return accepted;
556
445
  }
557
- function hmrAcceptCheckOne(
558
- // @ts-expect-error TS2304
559
- bundle, id, depsByBundle) {
446
+ function hmrAcceptCheckOne(bundle /*: ParcelRequire */, id /*: string */, depsByBundle /*: ?{ [string]: { [string]: string } }*/) {
560
447
  var modules = bundle.modules;
561
448
  if (!modules) {
562
449
  return;
@@ -569,13 +456,9 @@ bundle, id, depsByBundle) {
569
456
  }
570
457
  return hmrAcceptCheck(bundle.parent, id, depsByBundle);
571
458
  }
572
-
573
- // @ts-expect-error TS7005
574
459
  if (checkedAssets[id]) {
575
460
  return true;
576
461
  }
577
-
578
- // @ts-expect-error TS7005
579
462
  checkedAssets[id] = true;
580
463
  var cached = bundle.cache[id];
581
464
  assetsToDispose.push([bundle, id]);
@@ -587,37 +470,28 @@ bundle, id, depsByBundle) {
587
470
  function hmrDisposeQueue() {
588
471
  // Dispose all old assets.
589
472
  for (let i = 0; i < assetsToDispose.length; i++) {
590
- // @ts-expect-error TS7005
591
473
  let id = assetsToDispose[i][1];
592
-
593
- // @ts-expect-error TS7005
594
474
  if (!disposedAssets[id]) {
595
- // @ts-expect-error TS7005
596
475
  hmrDispose(assetsToDispose[i][0], id);
597
476
  disposedAssets[id] = true;
598
477
  }
599
478
  }
600
479
  assetsToDispose = [];
601
480
  }
602
- function hmrDispose(
603
- // @ts-expect-error TS2304
604
- bundle, id) {
481
+ function hmrDispose(bundle /*: ParcelRequire */, id /*: string */) {
605
482
  var cached = bundle.cache[id];
606
483
  bundle.hotData[id] = {};
607
484
  if (cached && cached.hot) {
608
485
  cached.hot.data = bundle.hotData[id];
609
486
  }
610
487
  if (cached && cached.hot && cached.hot._disposeCallbacks.length) {
611
- // @ts-expect-error TS7006
612
488
  cached.hot._disposeCallbacks.forEach(function (cb) {
613
489
  cb(bundle.hotData[id]);
614
490
  });
615
491
  }
616
492
  delete bundle.cache[id];
617
493
  }
618
- function hmrAccept(
619
- // @ts-expect-error TS2304
620
- bundle, id) {
494
+ function hmrAccept(bundle /*: ParcelRequire */, id /*: string */) {
621
495
  // Execute the module.
622
496
  bundle(id);
623
497
 
@@ -625,20 +499,16 @@ bundle, id) {
625
499
  var cached = bundle.cache[id];
626
500
  if (cached && cached.hot && cached.hot._acceptCallbacks.length) {
627
501
  let assetsToAlsoAccept = [];
628
- // @ts-expect-error TS7006
629
502
  cached.hot._acceptCallbacks.forEach(function (cb) {
630
503
  let additionalAssets = cb(function () {
631
- // @ts-expect-error TS2339
632
504
  return getParents(module.bundle.root, id);
633
505
  });
634
506
  if (Array.isArray(additionalAssets) && additionalAssets.length) {
635
- // @ts-expect-error TS2345
636
507
  assetsToAlsoAccept.push(...additionalAssets);
637
508
  }
638
509
  });
639
510
  if (assetsToAlsoAccept.length > 0) {
640
511
  let handled = assetsToAlsoAccept.every(function (a) {
641
- // @ts-expect-error TS2554
642
512
  return hmrAcceptCheck(a[0], a[1]);
643
513
  });
644
514
  if (!handled) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/runtime-browser-hmr",
3
- "version": "2.14.21-typescript-5b4d3ad41.0",
3
+ "version": "2.14.21",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -9,19 +9,14 @@
9
9
  "type": "git",
10
10
  "url": "https://github.com/atlassian-labs/atlaspack.git"
11
11
  },
12
- "main": "./lib/HMRRuntime.js",
13
- "source": "./src/HMRRuntime.ts",
14
- "types": "./lib/HMRRuntime.d.ts",
12
+ "main": "lib/HMRRuntime.js",
13
+ "source": "src/HMRRuntime.js",
15
14
  "engines": {
16
15
  "node": ">= 16.0.0"
17
16
  },
18
17
  "dependencies": {
19
- "@atlaspack/plugin": "2.14.21-typescript-5b4d3ad41.0",
20
- "@atlaspack/utils": "2.17.3-typescript-5b4d3ad41.0"
18
+ "@atlaspack/plugin": "2.14.21",
19
+ "@atlaspack/utils": "2.17.3"
21
20
  },
22
- "type": "commonjs",
23
- "scripts": {
24
- "check-ts": "tsc --emitDeclarationOnly --rootDir src"
25
- },
26
- "gitHead": "5b4d3ad41ffa002b989ba77271bb3010a1f05b2a"
27
- }
21
+ "type": "commonjs"
22
+ }
@@ -1,3 +1,5 @@
1
+ // @flow strict-local
2
+
1
3
  import {Runtime} from '@atlaspack/plugin';
2
4
  import fs from 'fs';
3
5
  import path from 'path';
@@ -6,17 +8,17 @@ import path from 'path';
6
8
  // lives in `/app/packages/runtimes/...` and thus the `config` in the JSTransformer is actually the
7
9
  // user's package.json, and hmr-runtime.js is transpiled as a JSX asset.
8
10
  const FILENAME =
9
- // @ts-expect-error TS2339
11
+ // $FlowFixMe
10
12
  process.env.ATLASPACK_BUILD_REPL && process.browser
11
13
  ? '/' + __filename
12
14
  : __filename;
13
15
 
14
- const HMR_RUNTIME =
15
- process.env.ATLASPACK_REGISTER_USE_SRC === 'true'
16
- ? fs.readFileSync(path.join(__dirname, './loaders/hmr-runtime.ts'), 'utf8')
17
- : fs.readFileSync(path.join(__dirname, './loaders/hmr-runtime.js'), 'utf8');
16
+ const HMR_RUNTIME = fs.readFileSync(
17
+ path.join(__dirname, './loaders/hmr-runtime.js'),
18
+ 'utf8',
19
+ );
18
20
 
19
- export default new Runtime({
21
+ export default (new Runtime({
20
22
  apply({bundle, options}) {
21
23
  if (
22
24
  bundle.type !== 'js' ||
@@ -48,7 +50,7 @@ export default new Runtime({
48
50
  )};` +
49
51
  `var HMR_ENV_HASH = "${bundle.env.id}";` +
50
52
  `var HMR_USE_SSE = ${JSON.stringify(
51
- // @ts-expect-error TS2339
53
+ // $FlowFixMe
52
54
  !!(process.env.ATLASPACK_BUILD_REPL && process.browser),
53
55
  )};` +
54
56
  `module.bundle.HMR_BUNDLE_ID = ${JSON.stringify(bundle.id)};` +
@@ -59,4 +61,4 @@ export default new Runtime({
59
61
  },
60
62
  };
61
63
  },
62
- }) as Runtime<unknown>;
64
+ }): Runtime<mixed>);