@parcel/transformer-react-refresh-wrap 2.6.2 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,7 +28,7 @@ function _plugin() {
28
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
29
 
30
30
  function shouldExclude(asset, options) {
31
- return !asset.isSource || !options.hmrOptions || !asset.env.isBrowser() || asset.env.isLibrary || asset.env.isWorker() || asset.env.isWorklet() || options.mode !== 'development' || !asset.getDependencies().find(v => v.specifier === 'react' || v.specifier === 'react/jsx-runtime' || v.specifier === 'react/jsx-dev-runtime');
31
+ return !asset.isSource || !options.hmrOptions || !asset.env.isBrowser() || asset.env.isLibrary || asset.env.isWorker() || asset.env.isWorklet() || options.mode !== 'development' || !asset.getDependencies().find(v => v.specifier === 'react' || v.specifier === 'react/jsx-runtime' || v.specifier === 'react/jsx-dev-runtime' || v.specifier === '@emotion/react' || v.specifier === '@emotion/react/jsx-runtime' || v.specifier === '@emotion/react/jsx-dev-runtime');
32
32
  }
33
33
 
34
34
  var _default = new (_plugin().Transformer)({
@@ -8,13 +8,26 @@ function debounce(func, delay) {
8
8
  func.call(null, args);
9
9
  };
10
10
  } else {
11
- var timeout = undefined;
11
+ let timeout = undefined;
12
+ let lastTime = 0;
12
13
  return function (args) {
13
- clearTimeout(timeout);
14
- timeout = setTimeout(function () {
15
- timeout = undefined;
14
+ // Call immediately if last call was more than the delay ago.
15
+ // Otherwise, set a timeout. This means the first call is fast
16
+ // (for the common case of a single update), and subsequent updates
17
+ // are batched.
18
+ let now = Date.now();
19
+
20
+ if (now - lastTime > delay) {
21
+ lastTime = now;
16
22
  func.call(null, args);
17
- }, delay);
23
+ } else {
24
+ clearTimeout(timeout);
25
+ timeout = setTimeout(function () {
26
+ timeout = undefined;
27
+ lastTime = Date.now();
28
+ func.call(null, args);
29
+ }, delay);
30
+ }
18
31
  };
19
32
  }
20
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcel/transformer-react-refresh-wrap",
3
- "version": "2.6.2",
3
+ "version": "2.8.0",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -17,12 +17,12 @@
17
17
  "source": "src/ReactRefreshWrapTransformer.js",
18
18
  "engines": {
19
19
  "node": ">= 12.0.0",
20
- "parcel": "^2.6.2"
20
+ "parcel": "^2.8.0"
21
21
  },
22
22
  "dependencies": {
23
- "@parcel/plugin": "2.6.2",
24
- "@parcel/utils": "2.6.2",
23
+ "@parcel/plugin": "2.8.0",
24
+ "@parcel/utils": "2.8.0",
25
25
  "react-refresh": "^0.9.0"
26
26
  },
27
- "gitHead": "e10fcfc1e8b71222da90978fb87f1b68e207473e"
27
+ "gitHead": "c3bbe0a6160186f496ca2f9e9bead9376c0522f1"
28
28
  }
@@ -18,7 +18,10 @@ function shouldExclude(asset, options) {
18
18
  v =>
19
19
  v.specifier === 'react' ||
20
20
  v.specifier === 'react/jsx-runtime' ||
21
- v.specifier === 'react/jsx-dev-runtime',
21
+ v.specifier === 'react/jsx-dev-runtime' ||
22
+ v.specifier === '@emotion/react' ||
23
+ v.specifier === '@emotion/react/jsx-runtime' ||
24
+ v.specifier === '@emotion/react/jsx-dev-runtime',
22
25
  )
23
26
  );
24
27
  }
@@ -6,13 +6,25 @@ function debounce(func, delay) {
6
6
  func.call(null, args);
7
7
  };
8
8
  } else {
9
- var timeout = undefined;
9
+ let timeout = undefined;
10
+ let lastTime = 0;
10
11
  return function (args) {
11
- clearTimeout(timeout);
12
- timeout = setTimeout(function () {
13
- timeout = undefined;
12
+ // Call immediately if last call was more than the delay ago.
13
+ // Otherwise, set a timeout. This means the first call is fast
14
+ // (for the common case of a single update), and subsequent updates
15
+ // are batched.
16
+ let now = Date.now();
17
+ if (now - lastTime > delay) {
18
+ lastTime = now;
14
19
  func.call(null, args);
15
- }, delay);
20
+ } else {
21
+ clearTimeout(timeout);
22
+ timeout = setTimeout(function () {
23
+ timeout = undefined;
24
+ lastTime = Date.now();
25
+ func.call(null, args);
26
+ }, delay);
27
+ }
16
28
  };
17
29
  }
18
30
  }