@remotion/browser-bundler 4.0.539 → 4.0.540

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/compiler.js CHANGED
@@ -401,23 +401,22 @@ var getBrowserReactRefreshVirtualFiles = ({
401
401
  runtime,
402
402
  utils
403
403
  }) => {
404
- if (typeof { entry: `var RefreshRuntime = require('react-refresh/runtime');
405
- var safeThis = (function () {
404
+ if (typeof { entry: `import { injectIntoGlobalHook } from 'react-refresh/runtime';
405
+
406
+ const safeThis = (() => {
406
407
  // copied from core-js-pure/features/global-this
407
408
  'use strict';
408
409
 
409
- var check = function (it) {
410
- return it && it.Math == Math && it;
411
- };
410
+ const check = (it) => it && it.Math === Math && it;
412
411
 
413
412
  // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
414
413
  // eslint-disable-next-line es/no-global-this -- safe
415
414
  return (
416
- check(typeof globalThis == 'object' && globalThis) ||
417
- check(typeof window == 'object' && window) ||
415
+ check(typeof globalThis === 'object' && globalThis) ||
416
+ check(typeof window === 'object' && window) ||
418
417
  // eslint-disable-next-line no-restricted-globals -- safe
419
- check(typeof self == 'object' && self) ||
420
- check(typeof __webpack_require__.g == 'object' && __webpack_require__.g) ||
418
+ check(typeof self === 'object' && self) ||
419
+ check(typeof __webpack_require__.g === 'object' && __webpack_require__.g) ||
421
420
  // eslint-disable-next-line no-new-func -- fallback
422
421
  (function () {
423
422
  return this;
@@ -429,18 +428,18 @@ var safeThis = (function () {
429
428
 
430
429
  if (process.env.NODE_ENV !== 'production') {
431
430
  if (typeof safeThis !== 'undefined') {
432
- var $RefreshInjected$ = '__reactRefreshInjected';
431
+ let $RefreshInjected$ = '__reactRefreshInjected';
433
432
  // Namespace the injected flag (if necessary) for monorepo compatibility
434
433
  if (
435
434
  typeof __react_refresh_library__ !== 'undefined' &&
436
435
  __react_refresh_library__
437
436
  ) {
438
- $RefreshInjected$ += '_' + __react_refresh_library__;
437
+ $RefreshInjected$ += \`_\${__react_refresh_library__}\`;
439
438
  }
440
439
 
441
440
  // Only inject the runtime if it hasn't been injected
442
441
  if (!safeThis[$RefreshInjected$]) {
443
- RefreshRuntime.injectIntoGlobalHook(safeThis);
442
+ injectIntoGlobalHook(safeThis);
444
443
 
445
444
  // Empty implementation to avoid "ReferenceError: variable is not defined" in module which didn't pass builtin:react-refresh-loader
446
445
  safeThis.$RefreshSig$ = () => (type) => type;
@@ -451,47 +450,40 @@ if (process.env.NODE_ENV !== 'production') {
451
450
  }
452
451
  }
453
452
  }
454
- `, runtime: `const RefreshUtils = require('./refreshUtils');
455
- const RefreshRuntime = require('react-refresh/runtime');
456
-
457
- function refresh(moduleId, webpackHot) {
458
- const currentExports = RefreshUtils.getModuleExports(moduleId);
459
- const fn = (exports) => {
460
- var errorOverlay;
461
- if (typeof __react_refresh_error_overlay__ !== 'undefined') {
462
- errorOverlay = __react_refresh_error_overlay__;
463
- }
464
- var testMode;
465
- if (typeof __react_refresh_test__ !== 'undefined') {
466
- testMode = __react_refresh_test__;
467
- }
468
- RefreshUtils.executeRuntime(
469
- exports,
470
- moduleId,
471
- webpackHot,
472
- errorOverlay,
473
- testMode,
474
- );
453
+ `, runtime: `import {
454
+ createSignatureFunctionForTransform,
455
+ register,
456
+ } from 'react-refresh/runtime';
457
+ import { executeRuntime, getModuleExports } from './refreshUtils.js';
458
+
459
+ function refresh(moduleId, hot) {
460
+ const currentExports = getModuleExports(moduleId);
461
+ const runRefresh = (moduleExports) => {
462
+ const testMode =
463
+ typeof __react_refresh_test__ !== 'undefined'
464
+ ? __react_refresh_test__
465
+ : undefined;
466
+ executeRuntime(moduleExports, moduleId, hot, testMode);
475
467
  };
476
468
  if (typeof Promise !== 'undefined' && currentExports instanceof Promise) {
477
- currentExports.then(fn);
469
+ currentExports.then(runRefresh);
478
470
  } else {
479
- fn(currentExports);
471
+ runRefresh(currentExports);
480
472
  }
481
473
  }
482
474
 
483
- module.exports = {
484
- refresh,
485
- register: RefreshRuntime.register,
486
- createSignatureFunctionForTransform:
487
- RefreshRuntime.createSignatureFunctionForTransform,
488
- };
475
+ export { createSignatureFunctionForTransform, refresh, register };
489
476
  `, utils: `/* global __webpack_require__ */
490
- var Refresh = require('react-refresh/runtime');
477
+ import {
478
+ getFamilyByType,
479
+ isLikelyComponentType,
480
+ performReactRefresh,
481
+ register,
482
+ } from 'react-refresh/runtime';
491
483
 
492
484
  /**
493
- * Extracts exports from a webpack module object.
494
- * @param {string} moduleId A Webpack module ID.
485
+ * Extracts exports from a Rspack module object.
486
+ * @param {string} moduleId An Rspack module ID.
495
487
  * @returns {*} An exports object from the module.
496
488
  */
497
489
  function getModuleExports(moduleId) {
@@ -503,23 +495,22 @@ function getModuleExports(moduleId) {
503
495
  return {};
504
496
  }
505
497
 
506
- var maybeModule = __webpack_require__.c[moduleId];
498
+ const maybeModule = __webpack_require__.c[moduleId];
507
499
  if (typeof maybeModule === 'undefined') {
508
500
  // \`moduleId\` is available but the module in cache is unavailable,
509
- // which indicates the module is somehow corrupted (e.g. broken Webpacak \`module\` globals).
501
+ // which indicates the module is somehow corrupted (e.g. broken Rspack \`module\` globals).
510
502
  // We will warn the user (as this is likely a mistake) and assume they cannot be refreshed.
511
503
  console.warn(
512
- '[React Refresh] Failed to get exports for module: ' + moduleId + '.',
504
+ \`[React Refresh] Failed to get exports for module: \${moduleId}.\`,
513
505
  );
514
506
  return {};
515
507
  }
516
508
 
517
- var exportsOrPromise = maybeModule.exports;
509
+ const exportsOrPromise = maybeModule.exports;
518
510
  if (typeof Promise !== 'undefined' && exportsOrPromise instanceof Promise) {
519
- return exportsOrPromise.then(function (exports) {
520
- return exports;
521
- });
511
+ return exportsOrPromise.then((moduleExports) => moduleExports);
522
512
  }
513
+
523
514
  return exportsOrPromise;
524
515
  }
525
516
 
@@ -528,25 +519,24 @@ function getModuleExports(moduleId) {
528
519
  * If this signature changes, it's unsafe to accept the boundary.
529
520
  *
530
521
  * This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/907d6af22ac6ebe58572be418e9253a90665ecbd/packages/metro/src/lib/polyfills/require.js#L795-L816).
531
- * @param {*} moduleExports A Webpack module exports object.
522
+ * @param {*} moduleExports An Rspack module exports object.
532
523
  * @returns {string[]} A React refresh boundary signature array.
533
524
  */
534
525
  function getReactRefreshBoundarySignature(moduleExports) {
535
- var signature = [];
536
- signature.push(Refresh.getFamilyByType(moduleExports));
526
+ const signature = [getFamilyByType(moduleExports)];
537
527
 
538
528
  if (moduleExports == null || typeof moduleExports !== 'object') {
539
529
  // Exit if we can't iterate over exports.
540
530
  return signature;
541
531
  }
542
532
 
543
- for (var key in moduleExports) {
533
+ for (const key in moduleExports) {
544
534
  if (key === '__esModule') {
545
535
  continue;
546
536
  }
547
537
 
548
538
  signature.push(key);
549
- signature.push(Refresh.getFamilyByType(moduleExports[key]));
539
+ signature.push(getFamilyByType(moduleExports[key]));
550
540
  }
551
541
 
552
542
  return signature;
@@ -561,22 +551,26 @@ function createDebounceUpdate() {
561
551
  * A cached setTimeout handler.
562
552
  * @type {number | undefined}
563
553
  */
564
- var refreshTimeout;
554
+ let refreshTimeout;
565
555
 
566
556
  /**
567
- * Performs react refresh on a delay and clears the error overlay.
568
- * @param {function(): void} callback
557
+ * Performs React Refresh on a delay.
558
+ * @param {function(): void} [callback]
569
559
  * @returns {void}
570
560
  */
571
- function enqueueUpdate(callback) {
572
- if (typeof refreshTimeout === 'undefined') {
573
- refreshTimeout = setTimeout(function () {
574
- refreshTimeout = undefined;
575
- Refresh.performReactRefresh();
576
- callback();
577
- }, 30);
561
+ const enqueueUpdate = (callback) => {
562
+ if (typeof refreshTimeout !== 'undefined') {
563
+ return;
578
564
  }
579
- }
565
+
566
+ refreshTimeout = setTimeout(() => {
567
+ refreshTimeout = undefined;
568
+ performReactRefresh();
569
+ if (callback) {
570
+ callback();
571
+ }
572
+ }, 30);
573
+ };
580
574
 
581
575
  return enqueueUpdate;
582
576
  }
@@ -585,11 +579,11 @@ function createDebounceUpdate() {
585
579
  * Checks if all exports are likely a React component.
586
580
  *
587
581
  * This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/febdba2383113c88296c61e28e4ef6a7f4939fda/packages/metro/src/lib/polyfills/require.js#L748-L774).
588
- * @param {*} moduleExports A Webpack module exports object.
582
+ * @param {*} moduleExports An Rspack module exports object.
589
583
  * @returns {boolean} Whether the exports are React component like.
590
584
  */
591
585
  function isReactRefreshBoundary(moduleExports) {
592
- if (Refresh.isLikelyComponentType(moduleExports)) {
586
+ if (isLikelyComponentType(moduleExports)) {
593
587
  return true;
594
588
  }
595
589
  if (
@@ -601,9 +595,9 @@ function isReactRefreshBoundary(moduleExports) {
601
595
  return false;
602
596
  }
603
597
 
604
- var hasExports = false;
605
- var areAllExportsComponents = true;
606
- for (var key in moduleExports) {
598
+ let hasExports = false;
599
+ let areAllExportsComponents = true;
600
+ for (const key in moduleExports) {
607
601
  hasExports = true;
608
602
 
609
603
  // This is the ES Module indicator flag
@@ -612,11 +606,11 @@ function isReactRefreshBoundary(moduleExports) {
612
606
  }
613
607
 
614
608
  // We can (and have to) safely execute getters here,
615
- // as Webpack manually assigns harmony exports to getters,
609
+ // as Rspack/webpack manually assigns ESM exports to getters,
616
610
  // without any side-effects attached.
617
611
  // Ref: https://github.com/webpack/webpack/blob/b93048643fe74de2a6931755911da1212df55897/lib/MainTemplate.js#L281
618
- var exportValue = moduleExports[key];
619
- if (!Refresh.isLikelyComponentType(exportValue)) {
612
+ const exportValue = moduleExports[key];
613
+ if (!isLikelyComponentType(exportValue)) {
620
614
  areAllExportsComponents = false;
621
615
  }
622
616
  }
@@ -628,14 +622,14 @@ function isReactRefreshBoundary(moduleExports) {
628
622
  * Checks if exports are likely a React component and registers them.
629
623
  *
630
624
  * This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/febdba2383113c88296c61e28e4ef6a7f4939fda/packages/metro/src/lib/polyfills/require.js#L818-L835).
631
- * @param {*} moduleExports A Webpack module exports object.
632
- * @param {string} moduleId A Webpack module ID.
625
+ * @param {*} moduleExports An Rspack module exports object.
626
+ * @param {string} moduleId An Rspack module ID.
633
627
  * @returns {void}
634
628
  */
635
629
  function registerExportsForReactRefresh(moduleExports, moduleId) {
636
- if (Refresh.isLikelyComponentType(moduleExports)) {
630
+ if (isLikelyComponentType(moduleExports)) {
637
631
  // Register module.exports if it is likely a component
638
- Refresh.register(moduleExports, moduleId + ' %exports%');
632
+ register(moduleExports, \`\${moduleId} %exports%\`);
639
633
  }
640
634
 
641
635
  if (
@@ -647,16 +641,16 @@ function registerExportsForReactRefresh(moduleExports, moduleId) {
647
641
  return;
648
642
  }
649
643
 
650
- for (var key in moduleExports) {
644
+ for (const key in moduleExports) {
651
645
  // Skip registering the ES Module indicator
652
646
  if (key === '__esModule') {
653
647
  continue;
654
648
  }
655
649
 
656
- var exportValue = moduleExports[key];
657
- if (Refresh.isLikelyComponentType(exportValue)) {
658
- var typeID = moduleId + ' %exports% ' + key;
659
- Refresh.register(exportValue, typeID);
650
+ const exportValue = moduleExports[key];
651
+ if (isLikelyComponentType(exportValue)) {
652
+ const typeID = \`\${moduleId} %exports% \${key}\`;
653
+ register(exportValue, typeID);
660
654
  }
661
655
  }
662
656
  }
@@ -665,111 +659,87 @@ function registerExportsForReactRefresh(moduleExports, moduleId) {
665
659
  * Compares previous and next module objects to check for mutated boundaries.
666
660
  *
667
661
  * This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/907d6af22ac6ebe58572be418e9253a90665ecbd/packages/metro/src/lib/polyfills/require.js#L776-L792).
668
- * @param {*} prevExports The current Webpack module exports object.
669
- * @param {*} nextExports The next Webpack module exports object.
662
+ * @param {*} prevExports The current Rspack module exports object.
663
+ * @param {*} nextExports The next Rspack module exports object.
670
664
  * @returns {boolean} Whether the React refresh boundary should be invalidated.
671
665
  */
672
666
  function shouldInvalidateReactRefreshBoundary(prevExports, nextExports) {
673
- var prevSignature = getReactRefreshBoundarySignature(prevExports);
674
- var nextSignature = getReactRefreshBoundarySignature(nextExports);
675
-
676
- if (prevSignature.length !== nextSignature.length) {
677
- return true;
678
- }
679
-
680
- for (var i = 0; i < nextSignature.length; i += 1) {
681
- if (prevSignature[i] !== nextSignature[i]) {
682
- return true;
683
- }
684
- }
667
+ const prevSignature = getReactRefreshBoundarySignature(prevExports);
668
+ const nextSignature = getReactRefreshBoundarySignature(nextExports);
685
669
 
686
- return false;
670
+ return (
671
+ prevSignature.length !== nextSignature.length ||
672
+ nextSignature.some(
673
+ (signatureItem, index) => prevSignature[index] !== signatureItem,
674
+ )
675
+ );
687
676
  }
688
677
 
689
- var enqueueUpdate = createDebounceUpdate();
678
+ const enqueueUpdate = createDebounceUpdate();
690
679
 
691
- function executeRuntime(
692
- moduleExports,
693
- moduleId,
694
- webpackHot,
695
- refreshOverlay,
696
- isTest,
697
- ) {
680
+ function executeRuntime(moduleExports, moduleId, hot, isTest) {
698
681
  registerExportsForReactRefresh(moduleExports, moduleId);
699
682
 
700
- if (webpackHot) {
701
- var isHotUpdate = !!webpackHot.data;
702
- var prevExports;
683
+ if (hot) {
684
+ const isHotUpdate = Boolean(hot.data);
685
+ let prevExports;
703
686
  if (isHotUpdate) {
704
- prevExports = webpackHot.data.prevExports;
687
+ prevExports = hot.data.prevExports;
705
688
  }
706
689
 
707
690
  if (isReactRefreshBoundary(moduleExports)) {
708
- webpackHot.dispose(
709
- /**
710
- * A callback to performs a full refresh if React has unrecoverable errors,
711
- * and also caches the to-be-disposed module.
712
- * @param {*} data A hot module data object from Webpack HMR.
713
- * @returns {void}
714
- */
715
- function hotDisposeCallback(data) {
716
- // We have to mutate the data object to get data registered and cached
717
- data.prevExports = moduleExports;
718
- },
719
- );
720
- webpackHot.accept(
721
- /**
722
- * An error handler to allow self-recovering behaviours.
723
- * @param {Error} error An error occurred during evaluation of a module.
724
- * @returns {void}
725
- */
726
- function hotErrorHandler(error) {
727
- console.error(error);
728
- if (
729
- __reload_on_runtime_errors__ &&
730
- isUnrecoverableRuntimeError(error)
731
- ) {
732
- location.reload();
733
- return;
734
- }
691
+ /**
692
+ * A callback to perform a full refresh if React has unrecoverable errors,
693
+ * and also caches the to-be-disposed module.
694
+ * @param {*} data A hot module data object from Rspack HMR.
695
+ * @returns {void}
696
+ */
697
+ const hotDisposeCallback = (data) => {
698
+ // We have to mutate the data object to get data registered and cached
699
+ data.prevExports = moduleExports;
700
+ };
701
+ /**
702
+ * An error handler to allow self-recovering behaviors.
703
+ * @param {Error} error An error occurred during evaluation of a module.
704
+ * @returns {void}
705
+ */
706
+ const hotErrorHandler = (error) => {
707
+ console.error(error);
708
+ if (
709
+ __reload_on_runtime_errors__ &&
710
+ isUnrecoverableRuntimeError(error)
711
+ ) {
712
+ location.reload();
713
+ return;
714
+ }
735
715
 
736
- if (typeof refreshOverlay !== 'undefined' && refreshOverlay) {
737
- refreshOverlay.handleRuntimeError(error);
738
- }
716
+ if (
717
+ typeof isTest !== 'undefined' &&
718
+ isTest &&
719
+ window.onHotAcceptError
720
+ ) {
721
+ window.onHotAcceptError(error.message);
722
+ }
739
723
 
740
- if (typeof isTest !== 'undefined' && isTest) {
741
- if (window.onHotAcceptError) {
742
- window.onHotAcceptError(error.message);
743
- }
744
- }
724
+ __webpack_require__.c[moduleId].hot.accept(hotErrorHandler);
725
+ };
745
726
 
746
- __webpack_require__.c[moduleId].hot.accept(hotErrorHandler);
747
- },
748
- );
727
+ hot.dispose(hotDisposeCallback);
728
+ hot.accept(hotErrorHandler);
749
729
 
750
730
  if (isHotUpdate) {
751
731
  if (
752
732
  isReactRefreshBoundary(prevExports) &&
753
733
  shouldInvalidateReactRefreshBoundary(prevExports, moduleExports)
754
734
  ) {
755
- webpackHot.invalidate();
735
+ hot.invalidate();
756
736
  } else {
757
- enqueueUpdate(
758
- /**
759
- * A function to dismiss the error overlay after performing React refresh.
760
- * @returns {void}
761
- */
762
- function updateCallback() {
763
- if (typeof refreshOverlay !== 'undefined' && refreshOverlay) {
764
- refreshOverlay.clearRuntimeErrors();
765
- }
766
- },
767
- );
737
+ enqueueUpdate();
768
738
  }
769
739
  }
770
740
  } else {
771
741
  if (isHotUpdate && typeof prevExports !== 'undefined') {
772
- webpackHot.invalidate();
742
+ hot.invalidate();
773
743
  }
774
744
  }
775
745
  }
@@ -779,35 +749,34 @@ function isUnrecoverableRuntimeError(error) {
779
749
  return error.message.startsWith('RuntimeError: factory is undefined');
780
750
  }
781
751
 
782
- module.exports = Object.freeze({
783
- enqueueUpdate: enqueueUpdate,
784
- executeRuntime: executeRuntime,
785
- getModuleExports: getModuleExports,
786
- isReactRefreshBoundary: isReactRefreshBoundary,
787
- shouldInvalidateReactRefreshBoundary: shouldInvalidateReactRefreshBoundary,
788
- registerExportsForReactRefresh: registerExportsForReactRefresh,
789
- });
752
+ export {
753
+ enqueueUpdate,
754
+ executeRuntime,
755
+ getModuleExports,
756
+ isReactRefreshBoundary,
757
+ registerExportsForReactRefresh,
758
+ shouldInvalidateReactRefreshBoundary,
759
+ };
790
760
  ` } === "undefined") {
791
761
  throw new Error("Browser bundler React Refresh files were not injected.");
792
762
  }
793
763
  return {
794
- [entry]: { entry: `var RefreshRuntime = require('react-refresh/runtime');
795
- var safeThis = (function () {
764
+ [entry]: { entry: `import { injectIntoGlobalHook } from 'react-refresh/runtime';
765
+
766
+ const safeThis = (() => {
796
767
  // copied from core-js-pure/features/global-this
797
768
  'use strict';
798
769
 
799
- var check = function (it) {
800
- return it && it.Math == Math && it;
801
- };
770
+ const check = (it) => it && it.Math === Math && it;
802
771
 
803
772
  // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
804
773
  // eslint-disable-next-line es/no-global-this -- safe
805
774
  return (
806
- check(typeof globalThis == 'object' && globalThis) ||
807
- check(typeof window == 'object' && window) ||
775
+ check(typeof globalThis === 'object' && globalThis) ||
776
+ check(typeof window === 'object' && window) ||
808
777
  // eslint-disable-next-line no-restricted-globals -- safe
809
- check(typeof self == 'object' && self) ||
810
- check(typeof __webpack_require__.g == 'object' && __webpack_require__.g) ||
778
+ check(typeof self === 'object' && self) ||
779
+ check(typeof __webpack_require__.g === 'object' && __webpack_require__.g) ||
811
780
  // eslint-disable-next-line no-new-func -- fallback
812
781
  (function () {
813
782
  return this;
@@ -819,18 +788,18 @@ var safeThis = (function () {
819
788
 
820
789
  if (process.env.NODE_ENV !== 'production') {
821
790
  if (typeof safeThis !== 'undefined') {
822
- var $RefreshInjected$ = '__reactRefreshInjected';
791
+ let $RefreshInjected$ = '__reactRefreshInjected';
823
792
  // Namespace the injected flag (if necessary) for monorepo compatibility
824
793
  if (
825
794
  typeof __react_refresh_library__ !== 'undefined' &&
826
795
  __react_refresh_library__
827
796
  ) {
828
- $RefreshInjected$ += '_' + __react_refresh_library__;
797
+ $RefreshInjected$ += \`_\${__react_refresh_library__}\`;
829
798
  }
830
799
 
831
800
  // Only inject the runtime if it hasn't been injected
832
801
  if (!safeThis[$RefreshInjected$]) {
833
- RefreshRuntime.injectIntoGlobalHook(safeThis);
802
+ injectIntoGlobalHook(safeThis);
834
803
 
835
804
  // Empty implementation to avoid "ReferenceError: variable is not defined" in module which didn't pass builtin:react-refresh-loader
836
805
  safeThis.$RefreshSig$ = () => (type) => type;
@@ -841,47 +810,40 @@ if (process.env.NODE_ENV !== 'production') {
841
810
  }
842
811
  }
843
812
  }
844
- `, runtime: `const RefreshUtils = require('./refreshUtils');
845
- const RefreshRuntime = require('react-refresh/runtime');
846
-
847
- function refresh(moduleId, webpackHot) {
848
- const currentExports = RefreshUtils.getModuleExports(moduleId);
849
- const fn = (exports) => {
850
- var errorOverlay;
851
- if (typeof __react_refresh_error_overlay__ !== 'undefined') {
852
- errorOverlay = __react_refresh_error_overlay__;
853
- }
854
- var testMode;
855
- if (typeof __react_refresh_test__ !== 'undefined') {
856
- testMode = __react_refresh_test__;
857
- }
858
- RefreshUtils.executeRuntime(
859
- exports,
860
- moduleId,
861
- webpackHot,
862
- errorOverlay,
863
- testMode,
864
- );
813
+ `, runtime: `import {
814
+ createSignatureFunctionForTransform,
815
+ register,
816
+ } from 'react-refresh/runtime';
817
+ import { executeRuntime, getModuleExports } from './refreshUtils.js';
818
+
819
+ function refresh(moduleId, hot) {
820
+ const currentExports = getModuleExports(moduleId);
821
+ const runRefresh = (moduleExports) => {
822
+ const testMode =
823
+ typeof __react_refresh_test__ !== 'undefined'
824
+ ? __react_refresh_test__
825
+ : undefined;
826
+ executeRuntime(moduleExports, moduleId, hot, testMode);
865
827
  };
866
828
  if (typeof Promise !== 'undefined' && currentExports instanceof Promise) {
867
- currentExports.then(fn);
829
+ currentExports.then(runRefresh);
868
830
  } else {
869
- fn(currentExports);
831
+ runRefresh(currentExports);
870
832
  }
871
833
  }
872
834
 
873
- module.exports = {
874
- refresh,
875
- register: RefreshRuntime.register,
876
- createSignatureFunctionForTransform:
877
- RefreshRuntime.createSignatureFunctionForTransform,
878
- };
835
+ export { createSignatureFunctionForTransform, refresh, register };
879
836
  `, utils: `/* global __webpack_require__ */
880
- var Refresh = require('react-refresh/runtime');
837
+ import {
838
+ getFamilyByType,
839
+ isLikelyComponentType,
840
+ performReactRefresh,
841
+ register,
842
+ } from 'react-refresh/runtime';
881
843
 
882
844
  /**
883
- * Extracts exports from a webpack module object.
884
- * @param {string} moduleId A Webpack module ID.
845
+ * Extracts exports from a Rspack module object.
846
+ * @param {string} moduleId An Rspack module ID.
885
847
  * @returns {*} An exports object from the module.
886
848
  */
887
849
  function getModuleExports(moduleId) {
@@ -893,23 +855,22 @@ function getModuleExports(moduleId) {
893
855
  return {};
894
856
  }
895
857
 
896
- var maybeModule = __webpack_require__.c[moduleId];
858
+ const maybeModule = __webpack_require__.c[moduleId];
897
859
  if (typeof maybeModule === 'undefined') {
898
860
  // \`moduleId\` is available but the module in cache is unavailable,
899
- // which indicates the module is somehow corrupted (e.g. broken Webpacak \`module\` globals).
861
+ // which indicates the module is somehow corrupted (e.g. broken Rspack \`module\` globals).
900
862
  // We will warn the user (as this is likely a mistake) and assume they cannot be refreshed.
901
863
  console.warn(
902
- '[React Refresh] Failed to get exports for module: ' + moduleId + '.',
864
+ \`[React Refresh] Failed to get exports for module: \${moduleId}.\`,
903
865
  );
904
866
  return {};
905
867
  }
906
868
 
907
- var exportsOrPromise = maybeModule.exports;
869
+ const exportsOrPromise = maybeModule.exports;
908
870
  if (typeof Promise !== 'undefined' && exportsOrPromise instanceof Promise) {
909
- return exportsOrPromise.then(function (exports) {
910
- return exports;
911
- });
871
+ return exportsOrPromise.then((moduleExports) => moduleExports);
912
872
  }
873
+
913
874
  return exportsOrPromise;
914
875
  }
915
876
 
@@ -918,25 +879,24 @@ function getModuleExports(moduleId) {
918
879
  * If this signature changes, it's unsafe to accept the boundary.
919
880
  *
920
881
  * This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/907d6af22ac6ebe58572be418e9253a90665ecbd/packages/metro/src/lib/polyfills/require.js#L795-L816).
921
- * @param {*} moduleExports A Webpack module exports object.
882
+ * @param {*} moduleExports An Rspack module exports object.
922
883
  * @returns {string[]} A React refresh boundary signature array.
923
884
  */
924
885
  function getReactRefreshBoundarySignature(moduleExports) {
925
- var signature = [];
926
- signature.push(Refresh.getFamilyByType(moduleExports));
886
+ const signature = [getFamilyByType(moduleExports)];
927
887
 
928
888
  if (moduleExports == null || typeof moduleExports !== 'object') {
929
889
  // Exit if we can't iterate over exports.
930
890
  return signature;
931
891
  }
932
892
 
933
- for (var key in moduleExports) {
893
+ for (const key in moduleExports) {
934
894
  if (key === '__esModule') {
935
895
  continue;
936
896
  }
937
897
 
938
898
  signature.push(key);
939
- signature.push(Refresh.getFamilyByType(moduleExports[key]));
899
+ signature.push(getFamilyByType(moduleExports[key]));
940
900
  }
941
901
 
942
902
  return signature;
@@ -951,22 +911,26 @@ function createDebounceUpdate() {
951
911
  * A cached setTimeout handler.
952
912
  * @type {number | undefined}
953
913
  */
954
- var refreshTimeout;
914
+ let refreshTimeout;
955
915
 
956
916
  /**
957
- * Performs react refresh on a delay and clears the error overlay.
958
- * @param {function(): void} callback
917
+ * Performs React Refresh on a delay.
918
+ * @param {function(): void} [callback]
959
919
  * @returns {void}
960
920
  */
961
- function enqueueUpdate(callback) {
962
- if (typeof refreshTimeout === 'undefined') {
963
- refreshTimeout = setTimeout(function () {
964
- refreshTimeout = undefined;
965
- Refresh.performReactRefresh();
966
- callback();
967
- }, 30);
921
+ const enqueueUpdate = (callback) => {
922
+ if (typeof refreshTimeout !== 'undefined') {
923
+ return;
968
924
  }
969
- }
925
+
926
+ refreshTimeout = setTimeout(() => {
927
+ refreshTimeout = undefined;
928
+ performReactRefresh();
929
+ if (callback) {
930
+ callback();
931
+ }
932
+ }, 30);
933
+ };
970
934
 
971
935
  return enqueueUpdate;
972
936
  }
@@ -975,11 +939,11 @@ function createDebounceUpdate() {
975
939
  * Checks if all exports are likely a React component.
976
940
  *
977
941
  * This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/febdba2383113c88296c61e28e4ef6a7f4939fda/packages/metro/src/lib/polyfills/require.js#L748-L774).
978
- * @param {*} moduleExports A Webpack module exports object.
942
+ * @param {*} moduleExports An Rspack module exports object.
979
943
  * @returns {boolean} Whether the exports are React component like.
980
944
  */
981
945
  function isReactRefreshBoundary(moduleExports) {
982
- if (Refresh.isLikelyComponentType(moduleExports)) {
946
+ if (isLikelyComponentType(moduleExports)) {
983
947
  return true;
984
948
  }
985
949
  if (
@@ -991,9 +955,9 @@ function isReactRefreshBoundary(moduleExports) {
991
955
  return false;
992
956
  }
993
957
 
994
- var hasExports = false;
995
- var areAllExportsComponents = true;
996
- for (var key in moduleExports) {
958
+ let hasExports = false;
959
+ let areAllExportsComponents = true;
960
+ for (const key in moduleExports) {
997
961
  hasExports = true;
998
962
 
999
963
  // This is the ES Module indicator flag
@@ -1002,11 +966,11 @@ function isReactRefreshBoundary(moduleExports) {
1002
966
  }
1003
967
 
1004
968
  // We can (and have to) safely execute getters here,
1005
- // as Webpack manually assigns harmony exports to getters,
969
+ // as Rspack/webpack manually assigns ESM exports to getters,
1006
970
  // without any side-effects attached.
1007
971
  // Ref: https://github.com/webpack/webpack/blob/b93048643fe74de2a6931755911da1212df55897/lib/MainTemplate.js#L281
1008
- var exportValue = moduleExports[key];
1009
- if (!Refresh.isLikelyComponentType(exportValue)) {
972
+ const exportValue = moduleExports[key];
973
+ if (!isLikelyComponentType(exportValue)) {
1010
974
  areAllExportsComponents = false;
1011
975
  }
1012
976
  }
@@ -1018,14 +982,14 @@ function isReactRefreshBoundary(moduleExports) {
1018
982
  * Checks if exports are likely a React component and registers them.
1019
983
  *
1020
984
  * This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/febdba2383113c88296c61e28e4ef6a7f4939fda/packages/metro/src/lib/polyfills/require.js#L818-L835).
1021
- * @param {*} moduleExports A Webpack module exports object.
1022
- * @param {string} moduleId A Webpack module ID.
985
+ * @param {*} moduleExports An Rspack module exports object.
986
+ * @param {string} moduleId An Rspack module ID.
1023
987
  * @returns {void}
1024
988
  */
1025
989
  function registerExportsForReactRefresh(moduleExports, moduleId) {
1026
- if (Refresh.isLikelyComponentType(moduleExports)) {
990
+ if (isLikelyComponentType(moduleExports)) {
1027
991
  // Register module.exports if it is likely a component
1028
- Refresh.register(moduleExports, moduleId + ' %exports%');
992
+ register(moduleExports, \`\${moduleId} %exports%\`);
1029
993
  }
1030
994
 
1031
995
  if (
@@ -1037,16 +1001,16 @@ function registerExportsForReactRefresh(moduleExports, moduleId) {
1037
1001
  return;
1038
1002
  }
1039
1003
 
1040
- for (var key in moduleExports) {
1004
+ for (const key in moduleExports) {
1041
1005
  // Skip registering the ES Module indicator
1042
1006
  if (key === '__esModule') {
1043
1007
  continue;
1044
1008
  }
1045
1009
 
1046
- var exportValue = moduleExports[key];
1047
- if (Refresh.isLikelyComponentType(exportValue)) {
1048
- var typeID = moduleId + ' %exports% ' + key;
1049
- Refresh.register(exportValue, typeID);
1010
+ const exportValue = moduleExports[key];
1011
+ if (isLikelyComponentType(exportValue)) {
1012
+ const typeID = \`\${moduleId} %exports% \${key}\`;
1013
+ register(exportValue, typeID);
1050
1014
  }
1051
1015
  }
1052
1016
  }
@@ -1055,111 +1019,87 @@ function registerExportsForReactRefresh(moduleExports, moduleId) {
1055
1019
  * Compares previous and next module objects to check for mutated boundaries.
1056
1020
  *
1057
1021
  * This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/907d6af22ac6ebe58572be418e9253a90665ecbd/packages/metro/src/lib/polyfills/require.js#L776-L792).
1058
- * @param {*} prevExports The current Webpack module exports object.
1059
- * @param {*} nextExports The next Webpack module exports object.
1022
+ * @param {*} prevExports The current Rspack module exports object.
1023
+ * @param {*} nextExports The next Rspack module exports object.
1060
1024
  * @returns {boolean} Whether the React refresh boundary should be invalidated.
1061
1025
  */
1062
1026
  function shouldInvalidateReactRefreshBoundary(prevExports, nextExports) {
1063
- var prevSignature = getReactRefreshBoundarySignature(prevExports);
1064
- var nextSignature = getReactRefreshBoundarySignature(nextExports);
1065
-
1066
- if (prevSignature.length !== nextSignature.length) {
1067
- return true;
1068
- }
1069
-
1070
- for (var i = 0; i < nextSignature.length; i += 1) {
1071
- if (prevSignature[i] !== nextSignature[i]) {
1072
- return true;
1073
- }
1074
- }
1027
+ const prevSignature = getReactRefreshBoundarySignature(prevExports);
1028
+ const nextSignature = getReactRefreshBoundarySignature(nextExports);
1075
1029
 
1076
- return false;
1030
+ return (
1031
+ prevSignature.length !== nextSignature.length ||
1032
+ nextSignature.some(
1033
+ (signatureItem, index) => prevSignature[index] !== signatureItem,
1034
+ )
1035
+ );
1077
1036
  }
1078
1037
 
1079
- var enqueueUpdate = createDebounceUpdate();
1038
+ const enqueueUpdate = createDebounceUpdate();
1080
1039
 
1081
- function executeRuntime(
1082
- moduleExports,
1083
- moduleId,
1084
- webpackHot,
1085
- refreshOverlay,
1086
- isTest,
1087
- ) {
1040
+ function executeRuntime(moduleExports, moduleId, hot, isTest) {
1088
1041
  registerExportsForReactRefresh(moduleExports, moduleId);
1089
1042
 
1090
- if (webpackHot) {
1091
- var isHotUpdate = !!webpackHot.data;
1092
- var prevExports;
1043
+ if (hot) {
1044
+ const isHotUpdate = Boolean(hot.data);
1045
+ let prevExports;
1093
1046
  if (isHotUpdate) {
1094
- prevExports = webpackHot.data.prevExports;
1047
+ prevExports = hot.data.prevExports;
1095
1048
  }
1096
1049
 
1097
1050
  if (isReactRefreshBoundary(moduleExports)) {
1098
- webpackHot.dispose(
1099
- /**
1100
- * A callback to performs a full refresh if React has unrecoverable errors,
1101
- * and also caches the to-be-disposed module.
1102
- * @param {*} data A hot module data object from Webpack HMR.
1103
- * @returns {void}
1104
- */
1105
- function hotDisposeCallback(data) {
1106
- // We have to mutate the data object to get data registered and cached
1107
- data.prevExports = moduleExports;
1108
- },
1109
- );
1110
- webpackHot.accept(
1111
- /**
1112
- * An error handler to allow self-recovering behaviours.
1113
- * @param {Error} error An error occurred during evaluation of a module.
1114
- * @returns {void}
1115
- */
1116
- function hotErrorHandler(error) {
1117
- console.error(error);
1118
- if (
1119
- __reload_on_runtime_errors__ &&
1120
- isUnrecoverableRuntimeError(error)
1121
- ) {
1122
- location.reload();
1123
- return;
1124
- }
1051
+ /**
1052
+ * A callback to perform a full refresh if React has unrecoverable errors,
1053
+ * and also caches the to-be-disposed module.
1054
+ * @param {*} data A hot module data object from Rspack HMR.
1055
+ * @returns {void}
1056
+ */
1057
+ const hotDisposeCallback = (data) => {
1058
+ // We have to mutate the data object to get data registered and cached
1059
+ data.prevExports = moduleExports;
1060
+ };
1061
+ /**
1062
+ * An error handler to allow self-recovering behaviors.
1063
+ * @param {Error} error An error occurred during evaluation of a module.
1064
+ * @returns {void}
1065
+ */
1066
+ const hotErrorHandler = (error) => {
1067
+ console.error(error);
1068
+ if (
1069
+ __reload_on_runtime_errors__ &&
1070
+ isUnrecoverableRuntimeError(error)
1071
+ ) {
1072
+ location.reload();
1073
+ return;
1074
+ }
1125
1075
 
1126
- if (typeof refreshOverlay !== 'undefined' && refreshOverlay) {
1127
- refreshOverlay.handleRuntimeError(error);
1128
- }
1076
+ if (
1077
+ typeof isTest !== 'undefined' &&
1078
+ isTest &&
1079
+ window.onHotAcceptError
1080
+ ) {
1081
+ window.onHotAcceptError(error.message);
1082
+ }
1129
1083
 
1130
- if (typeof isTest !== 'undefined' && isTest) {
1131
- if (window.onHotAcceptError) {
1132
- window.onHotAcceptError(error.message);
1133
- }
1134
- }
1084
+ __webpack_require__.c[moduleId].hot.accept(hotErrorHandler);
1085
+ };
1135
1086
 
1136
- __webpack_require__.c[moduleId].hot.accept(hotErrorHandler);
1137
- },
1138
- );
1087
+ hot.dispose(hotDisposeCallback);
1088
+ hot.accept(hotErrorHandler);
1139
1089
 
1140
1090
  if (isHotUpdate) {
1141
1091
  if (
1142
1092
  isReactRefreshBoundary(prevExports) &&
1143
1093
  shouldInvalidateReactRefreshBoundary(prevExports, moduleExports)
1144
1094
  ) {
1145
- webpackHot.invalidate();
1095
+ hot.invalidate();
1146
1096
  } else {
1147
- enqueueUpdate(
1148
- /**
1149
- * A function to dismiss the error overlay after performing React refresh.
1150
- * @returns {void}
1151
- */
1152
- function updateCallback() {
1153
- if (typeof refreshOverlay !== 'undefined' && refreshOverlay) {
1154
- refreshOverlay.clearRuntimeErrors();
1155
- }
1156
- },
1157
- );
1097
+ enqueueUpdate();
1158
1098
  }
1159
1099
  }
1160
1100
  } else {
1161
1101
  if (isHotUpdate && typeof prevExports !== 'undefined') {
1162
- webpackHot.invalidate();
1102
+ hot.invalidate();
1163
1103
  }
1164
1104
  }
1165
1105
  }
@@ -1169,32 +1109,31 @@ function isUnrecoverableRuntimeError(error) {
1169
1109
  return error.message.startsWith('RuntimeError: factory is undefined');
1170
1110
  }
1171
1111
 
1172
- module.exports = Object.freeze({
1173
- enqueueUpdate: enqueueUpdate,
1174
- executeRuntime: executeRuntime,
1175
- getModuleExports: getModuleExports,
1176
- isReactRefreshBoundary: isReactRefreshBoundary,
1177
- shouldInvalidateReactRefreshBoundary: shouldInvalidateReactRefreshBoundary,
1178
- registerExportsForReactRefresh: registerExportsForReactRefresh,
1179
- });
1112
+ export {
1113
+ enqueueUpdate,
1114
+ executeRuntime,
1115
+ getModuleExports,
1116
+ isReactRefreshBoundary,
1117
+ registerExportsForReactRefresh,
1118
+ shouldInvalidateReactRefreshBoundary,
1119
+ };
1180
1120
  ` }.entry,
1181
- [runtime]: { entry: `var RefreshRuntime = require('react-refresh/runtime');
1182
- var safeThis = (function () {
1121
+ [runtime]: { entry: `import { injectIntoGlobalHook } from 'react-refresh/runtime';
1122
+
1123
+ const safeThis = (() => {
1183
1124
  // copied from core-js-pure/features/global-this
1184
1125
  'use strict';
1185
1126
 
1186
- var check = function (it) {
1187
- return it && it.Math == Math && it;
1188
- };
1127
+ const check = (it) => it && it.Math === Math && it;
1189
1128
 
1190
1129
  // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
1191
1130
  // eslint-disable-next-line es/no-global-this -- safe
1192
1131
  return (
1193
- check(typeof globalThis == 'object' && globalThis) ||
1194
- check(typeof window == 'object' && window) ||
1132
+ check(typeof globalThis === 'object' && globalThis) ||
1133
+ check(typeof window === 'object' && window) ||
1195
1134
  // eslint-disable-next-line no-restricted-globals -- safe
1196
- check(typeof self == 'object' && self) ||
1197
- check(typeof __webpack_require__.g == 'object' && __webpack_require__.g) ||
1135
+ check(typeof self === 'object' && self) ||
1136
+ check(typeof __webpack_require__.g === 'object' && __webpack_require__.g) ||
1198
1137
  // eslint-disable-next-line no-new-func -- fallback
1199
1138
  (function () {
1200
1139
  return this;
@@ -1206,18 +1145,18 @@ var safeThis = (function () {
1206
1145
 
1207
1146
  if (process.env.NODE_ENV !== 'production') {
1208
1147
  if (typeof safeThis !== 'undefined') {
1209
- var $RefreshInjected$ = '__reactRefreshInjected';
1148
+ let $RefreshInjected$ = '__reactRefreshInjected';
1210
1149
  // Namespace the injected flag (if necessary) for monorepo compatibility
1211
1150
  if (
1212
1151
  typeof __react_refresh_library__ !== 'undefined' &&
1213
1152
  __react_refresh_library__
1214
1153
  ) {
1215
- $RefreshInjected$ += '_' + __react_refresh_library__;
1154
+ $RefreshInjected$ += \`_\${__react_refresh_library__}\`;
1216
1155
  }
1217
1156
 
1218
1157
  // Only inject the runtime if it hasn't been injected
1219
1158
  if (!safeThis[$RefreshInjected$]) {
1220
- RefreshRuntime.injectIntoGlobalHook(safeThis);
1159
+ injectIntoGlobalHook(safeThis);
1221
1160
 
1222
1161
  // Empty implementation to avoid "ReferenceError: variable is not defined" in module which didn't pass builtin:react-refresh-loader
1223
1162
  safeThis.$RefreshSig$ = () => (type) => type;
@@ -1228,47 +1167,40 @@ if (process.env.NODE_ENV !== 'production') {
1228
1167
  }
1229
1168
  }
1230
1169
  }
1231
- `, runtime: `const RefreshUtils = require('./refreshUtils');
1232
- const RefreshRuntime = require('react-refresh/runtime');
1233
-
1234
- function refresh(moduleId, webpackHot) {
1235
- const currentExports = RefreshUtils.getModuleExports(moduleId);
1236
- const fn = (exports) => {
1237
- var errorOverlay;
1238
- if (typeof __react_refresh_error_overlay__ !== 'undefined') {
1239
- errorOverlay = __react_refresh_error_overlay__;
1240
- }
1241
- var testMode;
1242
- if (typeof __react_refresh_test__ !== 'undefined') {
1243
- testMode = __react_refresh_test__;
1244
- }
1245
- RefreshUtils.executeRuntime(
1246
- exports,
1247
- moduleId,
1248
- webpackHot,
1249
- errorOverlay,
1250
- testMode,
1251
- );
1170
+ `, runtime: `import {
1171
+ createSignatureFunctionForTransform,
1172
+ register,
1173
+ } from 'react-refresh/runtime';
1174
+ import { executeRuntime, getModuleExports } from './refreshUtils.js';
1175
+
1176
+ function refresh(moduleId, hot) {
1177
+ const currentExports = getModuleExports(moduleId);
1178
+ const runRefresh = (moduleExports) => {
1179
+ const testMode =
1180
+ typeof __react_refresh_test__ !== 'undefined'
1181
+ ? __react_refresh_test__
1182
+ : undefined;
1183
+ executeRuntime(moduleExports, moduleId, hot, testMode);
1252
1184
  };
1253
1185
  if (typeof Promise !== 'undefined' && currentExports instanceof Promise) {
1254
- currentExports.then(fn);
1186
+ currentExports.then(runRefresh);
1255
1187
  } else {
1256
- fn(currentExports);
1188
+ runRefresh(currentExports);
1257
1189
  }
1258
1190
  }
1259
1191
 
1260
- module.exports = {
1261
- refresh,
1262
- register: RefreshRuntime.register,
1263
- createSignatureFunctionForTransform:
1264
- RefreshRuntime.createSignatureFunctionForTransform,
1265
- };
1192
+ export { createSignatureFunctionForTransform, refresh, register };
1266
1193
  `, utils: `/* global __webpack_require__ */
1267
- var Refresh = require('react-refresh/runtime');
1194
+ import {
1195
+ getFamilyByType,
1196
+ isLikelyComponentType,
1197
+ performReactRefresh,
1198
+ register,
1199
+ } from 'react-refresh/runtime';
1268
1200
 
1269
1201
  /**
1270
- * Extracts exports from a webpack module object.
1271
- * @param {string} moduleId A Webpack module ID.
1202
+ * Extracts exports from a Rspack module object.
1203
+ * @param {string} moduleId An Rspack module ID.
1272
1204
  * @returns {*} An exports object from the module.
1273
1205
  */
1274
1206
  function getModuleExports(moduleId) {
@@ -1280,23 +1212,22 @@ function getModuleExports(moduleId) {
1280
1212
  return {};
1281
1213
  }
1282
1214
 
1283
- var maybeModule = __webpack_require__.c[moduleId];
1215
+ const maybeModule = __webpack_require__.c[moduleId];
1284
1216
  if (typeof maybeModule === 'undefined') {
1285
1217
  // \`moduleId\` is available but the module in cache is unavailable,
1286
- // which indicates the module is somehow corrupted (e.g. broken Webpacak \`module\` globals).
1218
+ // which indicates the module is somehow corrupted (e.g. broken Rspack \`module\` globals).
1287
1219
  // We will warn the user (as this is likely a mistake) and assume they cannot be refreshed.
1288
1220
  console.warn(
1289
- '[React Refresh] Failed to get exports for module: ' + moduleId + '.',
1221
+ \`[React Refresh] Failed to get exports for module: \${moduleId}.\`,
1290
1222
  );
1291
1223
  return {};
1292
1224
  }
1293
1225
 
1294
- var exportsOrPromise = maybeModule.exports;
1226
+ const exportsOrPromise = maybeModule.exports;
1295
1227
  if (typeof Promise !== 'undefined' && exportsOrPromise instanceof Promise) {
1296
- return exportsOrPromise.then(function (exports) {
1297
- return exports;
1298
- });
1228
+ return exportsOrPromise.then((moduleExports) => moduleExports);
1299
1229
  }
1230
+
1300
1231
  return exportsOrPromise;
1301
1232
  }
1302
1233
 
@@ -1305,25 +1236,24 @@ function getModuleExports(moduleId) {
1305
1236
  * If this signature changes, it's unsafe to accept the boundary.
1306
1237
  *
1307
1238
  * This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/907d6af22ac6ebe58572be418e9253a90665ecbd/packages/metro/src/lib/polyfills/require.js#L795-L816).
1308
- * @param {*} moduleExports A Webpack module exports object.
1239
+ * @param {*} moduleExports An Rspack module exports object.
1309
1240
  * @returns {string[]} A React refresh boundary signature array.
1310
1241
  */
1311
1242
  function getReactRefreshBoundarySignature(moduleExports) {
1312
- var signature = [];
1313
- signature.push(Refresh.getFamilyByType(moduleExports));
1243
+ const signature = [getFamilyByType(moduleExports)];
1314
1244
 
1315
1245
  if (moduleExports == null || typeof moduleExports !== 'object') {
1316
1246
  // Exit if we can't iterate over exports.
1317
1247
  return signature;
1318
1248
  }
1319
1249
 
1320
- for (var key in moduleExports) {
1250
+ for (const key in moduleExports) {
1321
1251
  if (key === '__esModule') {
1322
1252
  continue;
1323
1253
  }
1324
1254
 
1325
1255
  signature.push(key);
1326
- signature.push(Refresh.getFamilyByType(moduleExports[key]));
1256
+ signature.push(getFamilyByType(moduleExports[key]));
1327
1257
  }
1328
1258
 
1329
1259
  return signature;
@@ -1338,22 +1268,26 @@ function createDebounceUpdate() {
1338
1268
  * A cached setTimeout handler.
1339
1269
  * @type {number | undefined}
1340
1270
  */
1341
- var refreshTimeout;
1271
+ let refreshTimeout;
1342
1272
 
1343
1273
  /**
1344
- * Performs react refresh on a delay and clears the error overlay.
1345
- * @param {function(): void} callback
1274
+ * Performs React Refresh on a delay.
1275
+ * @param {function(): void} [callback]
1346
1276
  * @returns {void}
1347
1277
  */
1348
- function enqueueUpdate(callback) {
1349
- if (typeof refreshTimeout === 'undefined') {
1350
- refreshTimeout = setTimeout(function () {
1351
- refreshTimeout = undefined;
1352
- Refresh.performReactRefresh();
1353
- callback();
1354
- }, 30);
1278
+ const enqueueUpdate = (callback) => {
1279
+ if (typeof refreshTimeout !== 'undefined') {
1280
+ return;
1355
1281
  }
1356
- }
1282
+
1283
+ refreshTimeout = setTimeout(() => {
1284
+ refreshTimeout = undefined;
1285
+ performReactRefresh();
1286
+ if (callback) {
1287
+ callback();
1288
+ }
1289
+ }, 30);
1290
+ };
1357
1291
 
1358
1292
  return enqueueUpdate;
1359
1293
  }
@@ -1362,11 +1296,11 @@ function createDebounceUpdate() {
1362
1296
  * Checks if all exports are likely a React component.
1363
1297
  *
1364
1298
  * This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/febdba2383113c88296c61e28e4ef6a7f4939fda/packages/metro/src/lib/polyfills/require.js#L748-L774).
1365
- * @param {*} moduleExports A Webpack module exports object.
1299
+ * @param {*} moduleExports An Rspack module exports object.
1366
1300
  * @returns {boolean} Whether the exports are React component like.
1367
1301
  */
1368
1302
  function isReactRefreshBoundary(moduleExports) {
1369
- if (Refresh.isLikelyComponentType(moduleExports)) {
1303
+ if (isLikelyComponentType(moduleExports)) {
1370
1304
  return true;
1371
1305
  }
1372
1306
  if (
@@ -1378,9 +1312,9 @@ function isReactRefreshBoundary(moduleExports) {
1378
1312
  return false;
1379
1313
  }
1380
1314
 
1381
- var hasExports = false;
1382
- var areAllExportsComponents = true;
1383
- for (var key in moduleExports) {
1315
+ let hasExports = false;
1316
+ let areAllExportsComponents = true;
1317
+ for (const key in moduleExports) {
1384
1318
  hasExports = true;
1385
1319
 
1386
1320
  // This is the ES Module indicator flag
@@ -1389,11 +1323,11 @@ function isReactRefreshBoundary(moduleExports) {
1389
1323
  }
1390
1324
 
1391
1325
  // We can (and have to) safely execute getters here,
1392
- // as Webpack manually assigns harmony exports to getters,
1326
+ // as Rspack/webpack manually assigns ESM exports to getters,
1393
1327
  // without any side-effects attached.
1394
1328
  // Ref: https://github.com/webpack/webpack/blob/b93048643fe74de2a6931755911da1212df55897/lib/MainTemplate.js#L281
1395
- var exportValue = moduleExports[key];
1396
- if (!Refresh.isLikelyComponentType(exportValue)) {
1329
+ const exportValue = moduleExports[key];
1330
+ if (!isLikelyComponentType(exportValue)) {
1397
1331
  areAllExportsComponents = false;
1398
1332
  }
1399
1333
  }
@@ -1405,14 +1339,14 @@ function isReactRefreshBoundary(moduleExports) {
1405
1339
  * Checks if exports are likely a React component and registers them.
1406
1340
  *
1407
1341
  * This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/febdba2383113c88296c61e28e4ef6a7f4939fda/packages/metro/src/lib/polyfills/require.js#L818-L835).
1408
- * @param {*} moduleExports A Webpack module exports object.
1409
- * @param {string} moduleId A Webpack module ID.
1342
+ * @param {*} moduleExports An Rspack module exports object.
1343
+ * @param {string} moduleId An Rspack module ID.
1410
1344
  * @returns {void}
1411
1345
  */
1412
1346
  function registerExportsForReactRefresh(moduleExports, moduleId) {
1413
- if (Refresh.isLikelyComponentType(moduleExports)) {
1347
+ if (isLikelyComponentType(moduleExports)) {
1414
1348
  // Register module.exports if it is likely a component
1415
- Refresh.register(moduleExports, moduleId + ' %exports%');
1349
+ register(moduleExports, \`\${moduleId} %exports%\`);
1416
1350
  }
1417
1351
 
1418
1352
  if (
@@ -1424,16 +1358,16 @@ function registerExportsForReactRefresh(moduleExports, moduleId) {
1424
1358
  return;
1425
1359
  }
1426
1360
 
1427
- for (var key in moduleExports) {
1361
+ for (const key in moduleExports) {
1428
1362
  // Skip registering the ES Module indicator
1429
1363
  if (key === '__esModule') {
1430
1364
  continue;
1431
1365
  }
1432
1366
 
1433
- var exportValue = moduleExports[key];
1434
- if (Refresh.isLikelyComponentType(exportValue)) {
1435
- var typeID = moduleId + ' %exports% ' + key;
1436
- Refresh.register(exportValue, typeID);
1367
+ const exportValue = moduleExports[key];
1368
+ if (isLikelyComponentType(exportValue)) {
1369
+ const typeID = \`\${moduleId} %exports% \${key}\`;
1370
+ register(exportValue, typeID);
1437
1371
  }
1438
1372
  }
1439
1373
  }
@@ -1442,111 +1376,87 @@ function registerExportsForReactRefresh(moduleExports, moduleId) {
1442
1376
  * Compares previous and next module objects to check for mutated boundaries.
1443
1377
  *
1444
1378
  * This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/907d6af22ac6ebe58572be418e9253a90665ecbd/packages/metro/src/lib/polyfills/require.js#L776-L792).
1445
- * @param {*} prevExports The current Webpack module exports object.
1446
- * @param {*} nextExports The next Webpack module exports object.
1379
+ * @param {*} prevExports The current Rspack module exports object.
1380
+ * @param {*} nextExports The next Rspack module exports object.
1447
1381
  * @returns {boolean} Whether the React refresh boundary should be invalidated.
1448
1382
  */
1449
1383
  function shouldInvalidateReactRefreshBoundary(prevExports, nextExports) {
1450
- var prevSignature = getReactRefreshBoundarySignature(prevExports);
1451
- var nextSignature = getReactRefreshBoundarySignature(nextExports);
1452
-
1453
- if (prevSignature.length !== nextSignature.length) {
1454
- return true;
1455
- }
1456
-
1457
- for (var i = 0; i < nextSignature.length; i += 1) {
1458
- if (prevSignature[i] !== nextSignature[i]) {
1459
- return true;
1460
- }
1461
- }
1384
+ const prevSignature = getReactRefreshBoundarySignature(prevExports);
1385
+ const nextSignature = getReactRefreshBoundarySignature(nextExports);
1462
1386
 
1463
- return false;
1387
+ return (
1388
+ prevSignature.length !== nextSignature.length ||
1389
+ nextSignature.some(
1390
+ (signatureItem, index) => prevSignature[index] !== signatureItem,
1391
+ )
1392
+ );
1464
1393
  }
1465
1394
 
1466
- var enqueueUpdate = createDebounceUpdate();
1395
+ const enqueueUpdate = createDebounceUpdate();
1467
1396
 
1468
- function executeRuntime(
1469
- moduleExports,
1470
- moduleId,
1471
- webpackHot,
1472
- refreshOverlay,
1473
- isTest,
1474
- ) {
1397
+ function executeRuntime(moduleExports, moduleId, hot, isTest) {
1475
1398
  registerExportsForReactRefresh(moduleExports, moduleId);
1476
1399
 
1477
- if (webpackHot) {
1478
- var isHotUpdate = !!webpackHot.data;
1479
- var prevExports;
1400
+ if (hot) {
1401
+ const isHotUpdate = Boolean(hot.data);
1402
+ let prevExports;
1480
1403
  if (isHotUpdate) {
1481
- prevExports = webpackHot.data.prevExports;
1404
+ prevExports = hot.data.prevExports;
1482
1405
  }
1483
1406
 
1484
1407
  if (isReactRefreshBoundary(moduleExports)) {
1485
- webpackHot.dispose(
1486
- /**
1487
- * A callback to performs a full refresh if React has unrecoverable errors,
1488
- * and also caches the to-be-disposed module.
1489
- * @param {*} data A hot module data object from Webpack HMR.
1490
- * @returns {void}
1491
- */
1492
- function hotDisposeCallback(data) {
1493
- // We have to mutate the data object to get data registered and cached
1494
- data.prevExports = moduleExports;
1495
- },
1496
- );
1497
- webpackHot.accept(
1498
- /**
1499
- * An error handler to allow self-recovering behaviours.
1500
- * @param {Error} error An error occurred during evaluation of a module.
1501
- * @returns {void}
1502
- */
1503
- function hotErrorHandler(error) {
1504
- console.error(error);
1505
- if (
1506
- __reload_on_runtime_errors__ &&
1507
- isUnrecoverableRuntimeError(error)
1508
- ) {
1509
- location.reload();
1510
- return;
1511
- }
1408
+ /**
1409
+ * A callback to perform a full refresh if React has unrecoverable errors,
1410
+ * and also caches the to-be-disposed module.
1411
+ * @param {*} data A hot module data object from Rspack HMR.
1412
+ * @returns {void}
1413
+ */
1414
+ const hotDisposeCallback = (data) => {
1415
+ // We have to mutate the data object to get data registered and cached
1416
+ data.prevExports = moduleExports;
1417
+ };
1418
+ /**
1419
+ * An error handler to allow self-recovering behaviors.
1420
+ * @param {Error} error An error occurred during evaluation of a module.
1421
+ * @returns {void}
1422
+ */
1423
+ const hotErrorHandler = (error) => {
1424
+ console.error(error);
1425
+ if (
1426
+ __reload_on_runtime_errors__ &&
1427
+ isUnrecoverableRuntimeError(error)
1428
+ ) {
1429
+ location.reload();
1430
+ return;
1431
+ }
1512
1432
 
1513
- if (typeof refreshOverlay !== 'undefined' && refreshOverlay) {
1514
- refreshOverlay.handleRuntimeError(error);
1515
- }
1433
+ if (
1434
+ typeof isTest !== 'undefined' &&
1435
+ isTest &&
1436
+ window.onHotAcceptError
1437
+ ) {
1438
+ window.onHotAcceptError(error.message);
1439
+ }
1516
1440
 
1517
- if (typeof isTest !== 'undefined' && isTest) {
1518
- if (window.onHotAcceptError) {
1519
- window.onHotAcceptError(error.message);
1520
- }
1521
- }
1441
+ __webpack_require__.c[moduleId].hot.accept(hotErrorHandler);
1442
+ };
1522
1443
 
1523
- __webpack_require__.c[moduleId].hot.accept(hotErrorHandler);
1524
- },
1525
- );
1444
+ hot.dispose(hotDisposeCallback);
1445
+ hot.accept(hotErrorHandler);
1526
1446
 
1527
1447
  if (isHotUpdate) {
1528
1448
  if (
1529
1449
  isReactRefreshBoundary(prevExports) &&
1530
1450
  shouldInvalidateReactRefreshBoundary(prevExports, moduleExports)
1531
1451
  ) {
1532
- webpackHot.invalidate();
1452
+ hot.invalidate();
1533
1453
  } else {
1534
- enqueueUpdate(
1535
- /**
1536
- * A function to dismiss the error overlay after performing React refresh.
1537
- * @returns {void}
1538
- */
1539
- function updateCallback() {
1540
- if (typeof refreshOverlay !== 'undefined' && refreshOverlay) {
1541
- refreshOverlay.clearRuntimeErrors();
1542
- }
1543
- },
1544
- );
1454
+ enqueueUpdate();
1545
1455
  }
1546
1456
  }
1547
1457
  } else {
1548
1458
  if (isHotUpdate && typeof prevExports !== 'undefined') {
1549
- webpackHot.invalidate();
1459
+ hot.invalidate();
1550
1460
  }
1551
1461
  }
1552
1462
  }
@@ -1556,32 +1466,31 @@ function isUnrecoverableRuntimeError(error) {
1556
1466
  return error.message.startsWith('RuntimeError: factory is undefined');
1557
1467
  }
1558
1468
 
1559
- module.exports = Object.freeze({
1560
- enqueueUpdate: enqueueUpdate,
1561
- executeRuntime: executeRuntime,
1562
- getModuleExports: getModuleExports,
1563
- isReactRefreshBoundary: isReactRefreshBoundary,
1564
- shouldInvalidateReactRefreshBoundary: shouldInvalidateReactRefreshBoundary,
1565
- registerExportsForReactRefresh: registerExportsForReactRefresh,
1566
- });
1469
+ export {
1470
+ enqueueUpdate,
1471
+ executeRuntime,
1472
+ getModuleExports,
1473
+ isReactRefreshBoundary,
1474
+ registerExportsForReactRefresh,
1475
+ shouldInvalidateReactRefreshBoundary,
1476
+ };
1567
1477
  ` }.runtime,
1568
- [utils]: { entry: `var RefreshRuntime = require('react-refresh/runtime');
1569
- var safeThis = (function () {
1478
+ [utils]: { entry: `import { injectIntoGlobalHook } from 'react-refresh/runtime';
1479
+
1480
+ const safeThis = (() => {
1570
1481
  // copied from core-js-pure/features/global-this
1571
1482
  'use strict';
1572
1483
 
1573
- var check = function (it) {
1574
- return it && it.Math == Math && it;
1575
- };
1484
+ const check = (it) => it && it.Math === Math && it;
1576
1485
 
1577
1486
  // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
1578
1487
  // eslint-disable-next-line es/no-global-this -- safe
1579
1488
  return (
1580
- check(typeof globalThis == 'object' && globalThis) ||
1581
- check(typeof window == 'object' && window) ||
1489
+ check(typeof globalThis === 'object' && globalThis) ||
1490
+ check(typeof window === 'object' && window) ||
1582
1491
  // eslint-disable-next-line no-restricted-globals -- safe
1583
- check(typeof self == 'object' && self) ||
1584
- check(typeof __webpack_require__.g == 'object' && __webpack_require__.g) ||
1492
+ check(typeof self === 'object' && self) ||
1493
+ check(typeof __webpack_require__.g === 'object' && __webpack_require__.g) ||
1585
1494
  // eslint-disable-next-line no-new-func -- fallback
1586
1495
  (function () {
1587
1496
  return this;
@@ -1593,18 +1502,18 @@ var safeThis = (function () {
1593
1502
 
1594
1503
  if (process.env.NODE_ENV !== 'production') {
1595
1504
  if (typeof safeThis !== 'undefined') {
1596
- var $RefreshInjected$ = '__reactRefreshInjected';
1505
+ let $RefreshInjected$ = '__reactRefreshInjected';
1597
1506
  // Namespace the injected flag (if necessary) for monorepo compatibility
1598
1507
  if (
1599
1508
  typeof __react_refresh_library__ !== 'undefined' &&
1600
1509
  __react_refresh_library__
1601
1510
  ) {
1602
- $RefreshInjected$ += '_' + __react_refresh_library__;
1511
+ $RefreshInjected$ += \`_\${__react_refresh_library__}\`;
1603
1512
  }
1604
1513
 
1605
1514
  // Only inject the runtime if it hasn't been injected
1606
1515
  if (!safeThis[$RefreshInjected$]) {
1607
- RefreshRuntime.injectIntoGlobalHook(safeThis);
1516
+ injectIntoGlobalHook(safeThis);
1608
1517
 
1609
1518
  // Empty implementation to avoid "ReferenceError: variable is not defined" in module which didn't pass builtin:react-refresh-loader
1610
1519
  safeThis.$RefreshSig$ = () => (type) => type;
@@ -1615,47 +1524,40 @@ if (process.env.NODE_ENV !== 'production') {
1615
1524
  }
1616
1525
  }
1617
1526
  }
1618
- `, runtime: `const RefreshUtils = require('./refreshUtils');
1619
- const RefreshRuntime = require('react-refresh/runtime');
1620
-
1621
- function refresh(moduleId, webpackHot) {
1622
- const currentExports = RefreshUtils.getModuleExports(moduleId);
1623
- const fn = (exports) => {
1624
- var errorOverlay;
1625
- if (typeof __react_refresh_error_overlay__ !== 'undefined') {
1626
- errorOverlay = __react_refresh_error_overlay__;
1627
- }
1628
- var testMode;
1629
- if (typeof __react_refresh_test__ !== 'undefined') {
1630
- testMode = __react_refresh_test__;
1631
- }
1632
- RefreshUtils.executeRuntime(
1633
- exports,
1634
- moduleId,
1635
- webpackHot,
1636
- errorOverlay,
1637
- testMode,
1638
- );
1527
+ `, runtime: `import {
1528
+ createSignatureFunctionForTransform,
1529
+ register,
1530
+ } from 'react-refresh/runtime';
1531
+ import { executeRuntime, getModuleExports } from './refreshUtils.js';
1532
+
1533
+ function refresh(moduleId, hot) {
1534
+ const currentExports = getModuleExports(moduleId);
1535
+ const runRefresh = (moduleExports) => {
1536
+ const testMode =
1537
+ typeof __react_refresh_test__ !== 'undefined'
1538
+ ? __react_refresh_test__
1539
+ : undefined;
1540
+ executeRuntime(moduleExports, moduleId, hot, testMode);
1639
1541
  };
1640
1542
  if (typeof Promise !== 'undefined' && currentExports instanceof Promise) {
1641
- currentExports.then(fn);
1543
+ currentExports.then(runRefresh);
1642
1544
  } else {
1643
- fn(currentExports);
1545
+ runRefresh(currentExports);
1644
1546
  }
1645
1547
  }
1646
1548
 
1647
- module.exports = {
1648
- refresh,
1649
- register: RefreshRuntime.register,
1650
- createSignatureFunctionForTransform:
1651
- RefreshRuntime.createSignatureFunctionForTransform,
1652
- };
1549
+ export { createSignatureFunctionForTransform, refresh, register };
1653
1550
  `, utils: `/* global __webpack_require__ */
1654
- var Refresh = require('react-refresh/runtime');
1551
+ import {
1552
+ getFamilyByType,
1553
+ isLikelyComponentType,
1554
+ performReactRefresh,
1555
+ register,
1556
+ } from 'react-refresh/runtime';
1655
1557
 
1656
1558
  /**
1657
- * Extracts exports from a webpack module object.
1658
- * @param {string} moduleId A Webpack module ID.
1559
+ * Extracts exports from a Rspack module object.
1560
+ * @param {string} moduleId An Rspack module ID.
1659
1561
  * @returns {*} An exports object from the module.
1660
1562
  */
1661
1563
  function getModuleExports(moduleId) {
@@ -1667,23 +1569,22 @@ function getModuleExports(moduleId) {
1667
1569
  return {};
1668
1570
  }
1669
1571
 
1670
- var maybeModule = __webpack_require__.c[moduleId];
1572
+ const maybeModule = __webpack_require__.c[moduleId];
1671
1573
  if (typeof maybeModule === 'undefined') {
1672
1574
  // \`moduleId\` is available but the module in cache is unavailable,
1673
- // which indicates the module is somehow corrupted (e.g. broken Webpacak \`module\` globals).
1575
+ // which indicates the module is somehow corrupted (e.g. broken Rspack \`module\` globals).
1674
1576
  // We will warn the user (as this is likely a mistake) and assume they cannot be refreshed.
1675
1577
  console.warn(
1676
- '[React Refresh] Failed to get exports for module: ' + moduleId + '.',
1578
+ \`[React Refresh] Failed to get exports for module: \${moduleId}.\`,
1677
1579
  );
1678
1580
  return {};
1679
1581
  }
1680
1582
 
1681
- var exportsOrPromise = maybeModule.exports;
1583
+ const exportsOrPromise = maybeModule.exports;
1682
1584
  if (typeof Promise !== 'undefined' && exportsOrPromise instanceof Promise) {
1683
- return exportsOrPromise.then(function (exports) {
1684
- return exports;
1685
- });
1585
+ return exportsOrPromise.then((moduleExports) => moduleExports);
1686
1586
  }
1587
+
1687
1588
  return exportsOrPromise;
1688
1589
  }
1689
1590
 
@@ -1692,25 +1593,24 @@ function getModuleExports(moduleId) {
1692
1593
  * If this signature changes, it's unsafe to accept the boundary.
1693
1594
  *
1694
1595
  * This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/907d6af22ac6ebe58572be418e9253a90665ecbd/packages/metro/src/lib/polyfills/require.js#L795-L816).
1695
- * @param {*} moduleExports A Webpack module exports object.
1596
+ * @param {*} moduleExports An Rspack module exports object.
1696
1597
  * @returns {string[]} A React refresh boundary signature array.
1697
1598
  */
1698
1599
  function getReactRefreshBoundarySignature(moduleExports) {
1699
- var signature = [];
1700
- signature.push(Refresh.getFamilyByType(moduleExports));
1600
+ const signature = [getFamilyByType(moduleExports)];
1701
1601
 
1702
1602
  if (moduleExports == null || typeof moduleExports !== 'object') {
1703
1603
  // Exit if we can't iterate over exports.
1704
1604
  return signature;
1705
1605
  }
1706
1606
 
1707
- for (var key in moduleExports) {
1607
+ for (const key in moduleExports) {
1708
1608
  if (key === '__esModule') {
1709
1609
  continue;
1710
1610
  }
1711
1611
 
1712
1612
  signature.push(key);
1713
- signature.push(Refresh.getFamilyByType(moduleExports[key]));
1613
+ signature.push(getFamilyByType(moduleExports[key]));
1714
1614
  }
1715
1615
 
1716
1616
  return signature;
@@ -1725,22 +1625,26 @@ function createDebounceUpdate() {
1725
1625
  * A cached setTimeout handler.
1726
1626
  * @type {number | undefined}
1727
1627
  */
1728
- var refreshTimeout;
1628
+ let refreshTimeout;
1729
1629
 
1730
1630
  /**
1731
- * Performs react refresh on a delay and clears the error overlay.
1732
- * @param {function(): void} callback
1631
+ * Performs React Refresh on a delay.
1632
+ * @param {function(): void} [callback]
1733
1633
  * @returns {void}
1734
1634
  */
1735
- function enqueueUpdate(callback) {
1736
- if (typeof refreshTimeout === 'undefined') {
1737
- refreshTimeout = setTimeout(function () {
1738
- refreshTimeout = undefined;
1739
- Refresh.performReactRefresh();
1740
- callback();
1741
- }, 30);
1635
+ const enqueueUpdate = (callback) => {
1636
+ if (typeof refreshTimeout !== 'undefined') {
1637
+ return;
1742
1638
  }
1743
- }
1639
+
1640
+ refreshTimeout = setTimeout(() => {
1641
+ refreshTimeout = undefined;
1642
+ performReactRefresh();
1643
+ if (callback) {
1644
+ callback();
1645
+ }
1646
+ }, 30);
1647
+ };
1744
1648
 
1745
1649
  return enqueueUpdate;
1746
1650
  }
@@ -1749,11 +1653,11 @@ function createDebounceUpdate() {
1749
1653
  * Checks if all exports are likely a React component.
1750
1654
  *
1751
1655
  * This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/febdba2383113c88296c61e28e4ef6a7f4939fda/packages/metro/src/lib/polyfills/require.js#L748-L774).
1752
- * @param {*} moduleExports A Webpack module exports object.
1656
+ * @param {*} moduleExports An Rspack module exports object.
1753
1657
  * @returns {boolean} Whether the exports are React component like.
1754
1658
  */
1755
1659
  function isReactRefreshBoundary(moduleExports) {
1756
- if (Refresh.isLikelyComponentType(moduleExports)) {
1660
+ if (isLikelyComponentType(moduleExports)) {
1757
1661
  return true;
1758
1662
  }
1759
1663
  if (
@@ -1765,9 +1669,9 @@ function isReactRefreshBoundary(moduleExports) {
1765
1669
  return false;
1766
1670
  }
1767
1671
 
1768
- var hasExports = false;
1769
- var areAllExportsComponents = true;
1770
- for (var key in moduleExports) {
1672
+ let hasExports = false;
1673
+ let areAllExportsComponents = true;
1674
+ for (const key in moduleExports) {
1771
1675
  hasExports = true;
1772
1676
 
1773
1677
  // This is the ES Module indicator flag
@@ -1776,11 +1680,11 @@ function isReactRefreshBoundary(moduleExports) {
1776
1680
  }
1777
1681
 
1778
1682
  // We can (and have to) safely execute getters here,
1779
- // as Webpack manually assigns harmony exports to getters,
1683
+ // as Rspack/webpack manually assigns ESM exports to getters,
1780
1684
  // without any side-effects attached.
1781
1685
  // Ref: https://github.com/webpack/webpack/blob/b93048643fe74de2a6931755911da1212df55897/lib/MainTemplate.js#L281
1782
- var exportValue = moduleExports[key];
1783
- if (!Refresh.isLikelyComponentType(exportValue)) {
1686
+ const exportValue = moduleExports[key];
1687
+ if (!isLikelyComponentType(exportValue)) {
1784
1688
  areAllExportsComponents = false;
1785
1689
  }
1786
1690
  }
@@ -1792,14 +1696,14 @@ function isReactRefreshBoundary(moduleExports) {
1792
1696
  * Checks if exports are likely a React component and registers them.
1793
1697
  *
1794
1698
  * This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/febdba2383113c88296c61e28e4ef6a7f4939fda/packages/metro/src/lib/polyfills/require.js#L818-L835).
1795
- * @param {*} moduleExports A Webpack module exports object.
1796
- * @param {string} moduleId A Webpack module ID.
1699
+ * @param {*} moduleExports An Rspack module exports object.
1700
+ * @param {string} moduleId An Rspack module ID.
1797
1701
  * @returns {void}
1798
1702
  */
1799
1703
  function registerExportsForReactRefresh(moduleExports, moduleId) {
1800
- if (Refresh.isLikelyComponentType(moduleExports)) {
1704
+ if (isLikelyComponentType(moduleExports)) {
1801
1705
  // Register module.exports if it is likely a component
1802
- Refresh.register(moduleExports, moduleId + ' %exports%');
1706
+ register(moduleExports, \`\${moduleId} %exports%\`);
1803
1707
  }
1804
1708
 
1805
1709
  if (
@@ -1811,16 +1715,16 @@ function registerExportsForReactRefresh(moduleExports, moduleId) {
1811
1715
  return;
1812
1716
  }
1813
1717
 
1814
- for (var key in moduleExports) {
1718
+ for (const key in moduleExports) {
1815
1719
  // Skip registering the ES Module indicator
1816
1720
  if (key === '__esModule') {
1817
1721
  continue;
1818
1722
  }
1819
1723
 
1820
- var exportValue = moduleExports[key];
1821
- if (Refresh.isLikelyComponentType(exportValue)) {
1822
- var typeID = moduleId + ' %exports% ' + key;
1823
- Refresh.register(exportValue, typeID);
1724
+ const exportValue = moduleExports[key];
1725
+ if (isLikelyComponentType(exportValue)) {
1726
+ const typeID = \`\${moduleId} %exports% \${key}\`;
1727
+ register(exportValue, typeID);
1824
1728
  }
1825
1729
  }
1826
1730
  }
@@ -1829,111 +1733,87 @@ function registerExportsForReactRefresh(moduleExports, moduleId) {
1829
1733
  * Compares previous and next module objects to check for mutated boundaries.
1830
1734
  *
1831
1735
  * This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/907d6af22ac6ebe58572be418e9253a90665ecbd/packages/metro/src/lib/polyfills/require.js#L776-L792).
1832
- * @param {*} prevExports The current Webpack module exports object.
1833
- * @param {*} nextExports The next Webpack module exports object.
1736
+ * @param {*} prevExports The current Rspack module exports object.
1737
+ * @param {*} nextExports The next Rspack module exports object.
1834
1738
  * @returns {boolean} Whether the React refresh boundary should be invalidated.
1835
1739
  */
1836
1740
  function shouldInvalidateReactRefreshBoundary(prevExports, nextExports) {
1837
- var prevSignature = getReactRefreshBoundarySignature(prevExports);
1838
- var nextSignature = getReactRefreshBoundarySignature(nextExports);
1839
-
1840
- if (prevSignature.length !== nextSignature.length) {
1841
- return true;
1842
- }
1843
-
1844
- for (var i = 0; i < nextSignature.length; i += 1) {
1845
- if (prevSignature[i] !== nextSignature[i]) {
1846
- return true;
1847
- }
1848
- }
1741
+ const prevSignature = getReactRefreshBoundarySignature(prevExports);
1742
+ const nextSignature = getReactRefreshBoundarySignature(nextExports);
1849
1743
 
1850
- return false;
1744
+ return (
1745
+ prevSignature.length !== nextSignature.length ||
1746
+ nextSignature.some(
1747
+ (signatureItem, index) => prevSignature[index] !== signatureItem,
1748
+ )
1749
+ );
1851
1750
  }
1852
1751
 
1853
- var enqueueUpdate = createDebounceUpdate();
1752
+ const enqueueUpdate = createDebounceUpdate();
1854
1753
 
1855
- function executeRuntime(
1856
- moduleExports,
1857
- moduleId,
1858
- webpackHot,
1859
- refreshOverlay,
1860
- isTest,
1861
- ) {
1754
+ function executeRuntime(moduleExports, moduleId, hot, isTest) {
1862
1755
  registerExportsForReactRefresh(moduleExports, moduleId);
1863
1756
 
1864
- if (webpackHot) {
1865
- var isHotUpdate = !!webpackHot.data;
1866
- var prevExports;
1757
+ if (hot) {
1758
+ const isHotUpdate = Boolean(hot.data);
1759
+ let prevExports;
1867
1760
  if (isHotUpdate) {
1868
- prevExports = webpackHot.data.prevExports;
1761
+ prevExports = hot.data.prevExports;
1869
1762
  }
1870
1763
 
1871
1764
  if (isReactRefreshBoundary(moduleExports)) {
1872
- webpackHot.dispose(
1873
- /**
1874
- * A callback to performs a full refresh if React has unrecoverable errors,
1875
- * and also caches the to-be-disposed module.
1876
- * @param {*} data A hot module data object from Webpack HMR.
1877
- * @returns {void}
1878
- */
1879
- function hotDisposeCallback(data) {
1880
- // We have to mutate the data object to get data registered and cached
1881
- data.prevExports = moduleExports;
1882
- },
1883
- );
1884
- webpackHot.accept(
1885
- /**
1886
- * An error handler to allow self-recovering behaviours.
1887
- * @param {Error} error An error occurred during evaluation of a module.
1888
- * @returns {void}
1889
- */
1890
- function hotErrorHandler(error) {
1891
- console.error(error);
1892
- if (
1893
- __reload_on_runtime_errors__ &&
1894
- isUnrecoverableRuntimeError(error)
1895
- ) {
1896
- location.reload();
1897
- return;
1898
- }
1765
+ /**
1766
+ * A callback to perform a full refresh if React has unrecoverable errors,
1767
+ * and also caches the to-be-disposed module.
1768
+ * @param {*} data A hot module data object from Rspack HMR.
1769
+ * @returns {void}
1770
+ */
1771
+ const hotDisposeCallback = (data) => {
1772
+ // We have to mutate the data object to get data registered and cached
1773
+ data.prevExports = moduleExports;
1774
+ };
1775
+ /**
1776
+ * An error handler to allow self-recovering behaviors.
1777
+ * @param {Error} error An error occurred during evaluation of a module.
1778
+ * @returns {void}
1779
+ */
1780
+ const hotErrorHandler = (error) => {
1781
+ console.error(error);
1782
+ if (
1783
+ __reload_on_runtime_errors__ &&
1784
+ isUnrecoverableRuntimeError(error)
1785
+ ) {
1786
+ location.reload();
1787
+ return;
1788
+ }
1899
1789
 
1900
- if (typeof refreshOverlay !== 'undefined' && refreshOverlay) {
1901
- refreshOverlay.handleRuntimeError(error);
1902
- }
1790
+ if (
1791
+ typeof isTest !== 'undefined' &&
1792
+ isTest &&
1793
+ window.onHotAcceptError
1794
+ ) {
1795
+ window.onHotAcceptError(error.message);
1796
+ }
1903
1797
 
1904
- if (typeof isTest !== 'undefined' && isTest) {
1905
- if (window.onHotAcceptError) {
1906
- window.onHotAcceptError(error.message);
1907
- }
1908
- }
1798
+ __webpack_require__.c[moduleId].hot.accept(hotErrorHandler);
1799
+ };
1909
1800
 
1910
- __webpack_require__.c[moduleId].hot.accept(hotErrorHandler);
1911
- },
1912
- );
1801
+ hot.dispose(hotDisposeCallback);
1802
+ hot.accept(hotErrorHandler);
1913
1803
 
1914
1804
  if (isHotUpdate) {
1915
1805
  if (
1916
1806
  isReactRefreshBoundary(prevExports) &&
1917
1807
  shouldInvalidateReactRefreshBoundary(prevExports, moduleExports)
1918
1808
  ) {
1919
- webpackHot.invalidate();
1809
+ hot.invalidate();
1920
1810
  } else {
1921
- enqueueUpdate(
1922
- /**
1923
- * A function to dismiss the error overlay after performing React refresh.
1924
- * @returns {void}
1925
- */
1926
- function updateCallback() {
1927
- if (typeof refreshOverlay !== 'undefined' && refreshOverlay) {
1928
- refreshOverlay.clearRuntimeErrors();
1929
- }
1930
- },
1931
- );
1811
+ enqueueUpdate();
1932
1812
  }
1933
1813
  }
1934
1814
  } else {
1935
1815
  if (isHotUpdate && typeof prevExports !== 'undefined') {
1936
- webpackHot.invalidate();
1816
+ hot.invalidate();
1937
1817
  }
1938
1818
  }
1939
1819
  }
@@ -1943,14 +1823,14 @@ function isUnrecoverableRuntimeError(error) {
1943
1823
  return error.message.startsWith('RuntimeError: factory is undefined');
1944
1824
  }
1945
1825
 
1946
- module.exports = Object.freeze({
1947
- enqueueUpdate: enqueueUpdate,
1948
- executeRuntime: executeRuntime,
1949
- getModuleExports: getModuleExports,
1950
- isReactRefreshBoundary: isReactRefreshBoundary,
1951
- shouldInvalidateReactRefreshBoundary: shouldInvalidateReactRefreshBoundary,
1952
- registerExportsForReactRefresh: registerExportsForReactRefresh,
1953
- });
1826
+ export {
1827
+ enqueueUpdate,
1828
+ executeRuntime,
1829
+ getModuleExports,
1830
+ isReactRefreshBoundary,
1831
+ registerExportsForReactRefresh,
1832
+ shouldInvalidateReactRefreshBoundary,
1833
+ };
1954
1834
  ` }.utils
1955
1835
  };
1956
1836
  };