@mado/hooks 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @mado/hooks
2
2
 
3
+ ## 0.3.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 1b8fde4: Use shim import for useSyncExternalStore for React 16/17 compatibility
8
+
3
9
  ## 0.3.1
4
10
 
5
11
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var useSyncExternalStore = require('use-sync-external-store');
3
+ var shim = require('use-sync-external-store/shim');
4
4
 
5
5
  // src/useOnline.ts
6
6
  function subscribe(onStoreChange) {
@@ -22,7 +22,7 @@ function getServerSnapshot() {
22
22
  return true;
23
23
  }
24
24
  function useOnline() {
25
- return useSyncExternalStore.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
25
+ return shim.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
26
26
  }
27
27
  /* istanbul ignore next -- @preserve */
28
28
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/useOnline.ts"],"names":[],"mappings":";AAAA,SAAS,4BAA4B;AAErC,SAAS,UAAU,eAA2C;AAC5D,SAAO,iBAAiB,UAAU,eAAe;AAAA,IAC/C,SAAS;AAAA,EACX,CAAC;AACD,SAAO,iBAAiB,WAAW,eAAe;AAAA,IAChD,SAAS;AAAA,EACX,CAAC;AAED,SAAO,MAAM;AACX,WAAO,oBAAoB,UAAU,aAAa;AAClD,WAAO,oBAAoB,WAAW,aAAa;AAAA,EACrD;AACF;AAEA,SAAS,cAAuB;AAC9B,SAAO,UAAU;AACnB;AAGA,SAAS,oBAA6B;AACpC,SAAO;AACT;AAEO,SAAS,YAAqB;AACnC,SAAO,qBAAqB,WAAW,aAAa,iBAAiB;AACvE","sourcesContent":["import { useSyncExternalStore } from 'use-sync-external-store';\n\nfunction subscribe(onStoreChange: VoidFunction): VoidFunction {\n window.addEventListener('online', onStoreChange, {\n passive: true,\n });\n window.addEventListener('offline', onStoreChange, {\n passive: true,\n });\n\n return () => {\n window.removeEventListener('online', onStoreChange);\n window.removeEventListener('offline', onStoreChange);\n };\n}\n\nfunction getSnapshot(): boolean {\n return navigator.onLine;\n}\n\n/* istanbul ignore next -- @preserve */\nfunction getServerSnapshot(): boolean {\n return true;\n}\n\nexport function useOnline(): boolean {\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n"]}
1
+ {"version":3,"sources":["../src/useOnline.ts"],"names":[],"mappings":";AAAA,SAAS,4BAA4B;AAErC,SAAS,UAAU,eAA2C;AAC5D,SAAO,iBAAiB,UAAU,eAAe;AAAA,IAC/C,SAAS;AAAA,EACX,CAAC;AACD,SAAO,iBAAiB,WAAW,eAAe;AAAA,IAChD,SAAS;AAAA,EACX,CAAC;AAED,SAAO,MAAM;AACX,WAAO,oBAAoB,UAAU,aAAa;AAClD,WAAO,oBAAoB,WAAW,aAAa;AAAA,EACrD;AACF;AAEA,SAAS,cAAuB;AAC9B,SAAO,UAAU;AACnB;AAGA,SAAS,oBAA6B;AACpC,SAAO;AACT;AAEO,SAAS,YAAqB;AACnC,SAAO,qBAAqB,WAAW,aAAa,iBAAiB;AACvE","sourcesContent":["import { useSyncExternalStore } from 'use-sync-external-store/shim';\n\nfunction subscribe(onStoreChange: VoidFunction): VoidFunction {\n window.addEventListener('online', onStoreChange, {\n passive: true,\n });\n window.addEventListener('offline', onStoreChange, {\n passive: true,\n });\n\n return () => {\n window.removeEventListener('online', onStoreChange);\n window.removeEventListener('offline', onStoreChange);\n };\n}\n\nfunction getSnapshot(): boolean {\n return navigator.onLine;\n}\n\n/* istanbul ignore next -- @preserve */\nfunction getServerSnapshot(): boolean {\n return true;\n}\n\nexport function useOnline(): boolean {\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n"]}
package/dist/useOnline.js CHANGED
@@ -1,4 +1,4 @@
1
- import { useSyncExternalStore } from 'use-sync-external-store';
1
+ import { useSyncExternalStore } from 'use-sync-external-store/shim';
2
2
 
3
3
  // src/useOnline.ts
4
4
  function subscribe(onStoreChange) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/useOnline.ts"],"names":[],"mappings":";AAAA,SAAS,4BAA4B;AAErC,SAAS,UAAU,eAA2C;AAC5D,SAAO,iBAAiB,UAAU,eAAe;AAAA,IAC/C,SAAS;AAAA,EACX,CAAC;AACD,SAAO,iBAAiB,WAAW,eAAe;AAAA,IAChD,SAAS;AAAA,EACX,CAAC;AAED,SAAO,MAAM;AACX,WAAO,oBAAoB,UAAU,aAAa;AAClD,WAAO,oBAAoB,WAAW,aAAa;AAAA,EACrD;AACF;AAEA,SAAS,cAAuB;AAC9B,SAAO,UAAU;AACnB;AAGA,SAAS,oBAA6B;AACpC,SAAO;AACT;AAEO,SAAS,YAAqB;AACnC,SAAO,qBAAqB,WAAW,aAAa,iBAAiB;AACvE","sourcesContent":["import { useSyncExternalStore } from 'use-sync-external-store';\n\nfunction subscribe(onStoreChange: VoidFunction): VoidFunction {\n window.addEventListener('online', onStoreChange, {\n passive: true,\n });\n window.addEventListener('offline', onStoreChange, {\n passive: true,\n });\n\n return () => {\n window.removeEventListener('online', onStoreChange);\n window.removeEventListener('offline', onStoreChange);\n };\n}\n\nfunction getSnapshot(): boolean {\n return navigator.onLine;\n}\n\n/* istanbul ignore next -- @preserve */\nfunction getServerSnapshot(): boolean {\n return true;\n}\n\nexport function useOnline(): boolean {\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n"]}
1
+ {"version":3,"sources":["../src/useOnline.ts"],"names":[],"mappings":";AAAA,SAAS,4BAA4B;AAErC,SAAS,UAAU,eAA2C;AAC5D,SAAO,iBAAiB,UAAU,eAAe;AAAA,IAC/C,SAAS;AAAA,EACX,CAAC;AACD,SAAO,iBAAiB,WAAW,eAAe;AAAA,IAChD,SAAS;AAAA,EACX,CAAC;AAED,SAAO,MAAM;AACX,WAAO,oBAAoB,UAAU,aAAa;AAClD,WAAO,oBAAoB,WAAW,aAAa;AAAA,EACrD;AACF;AAEA,SAAS,cAAuB;AAC9B,SAAO,UAAU;AACnB;AAGA,SAAS,oBAA6B;AACpC,SAAO;AACT;AAEO,SAAS,YAAqB;AACnC,SAAO,qBAAqB,WAAW,aAAa,iBAAiB;AACvE","sourcesContent":["import { useSyncExternalStore } from 'use-sync-external-store/shim';\n\nfunction subscribe(onStoreChange: VoidFunction): VoidFunction {\n window.addEventListener('online', onStoreChange, {\n passive: true,\n });\n window.addEventListener('offline', onStoreChange, {\n passive: true,\n });\n\n return () => {\n window.removeEventListener('online', onStoreChange);\n window.removeEventListener('offline', onStoreChange);\n };\n}\n\nfunction getSnapshot(): boolean {\n return navigator.onLine;\n}\n\n/* istanbul ignore next -- @preserve */\nfunction getServerSnapshot(): boolean {\n return true;\n}\n\nexport function useOnline(): boolean {\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var useSyncExternalStore = require('use-sync-external-store');
3
+ var shim = require('use-sync-external-store/shim');
4
4
 
5
5
  // src/useVisibilityState.ts
6
6
  function subscribe(onStoreChange) {
@@ -18,7 +18,7 @@ function getServerSnapshot() {
18
18
  return "visible";
19
19
  }
20
20
  function useVisibilityState() {
21
- return useSyncExternalStore.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
21
+ return shim.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
22
22
  }
23
23
  /* istanbul ignore next -- @preserve */
24
24
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/useVisibilityState.ts"],"names":[],"mappings":";AAAA,SAAS,4BAA4B;AAErC,SAAS,UAAU,eAA2C;AAC5D,WAAS,iBAAiB,oBAAoB,eAAe;AAAA,IAC3D,SAAS;AAAA,EACX,CAAC;AAED,SAAO,MAAM;AACX,aAAS,oBAAoB,oBAAoB,aAAa;AAAA,EAChE;AACF;AAEA,SAAS,cAAuC;AAC9C,SAAO,SAAS;AAClB;AAGA,SAAS,oBAA6C;AACpD,SAAO;AACT;AAEO,SAAS,qBAA8C;AAC5D,SAAO,qBAAqB,WAAW,aAAa,iBAAiB;AACvE","sourcesContent":["import { useSyncExternalStore } from 'use-sync-external-store';\n\nfunction subscribe(onStoreChange: VoidFunction): VoidFunction {\n document.addEventListener('visibilitychange', onStoreChange, {\n passive: true,\n });\n\n return () => {\n document.removeEventListener('visibilitychange', onStoreChange);\n };\n}\n\nfunction getSnapshot(): DocumentVisibilityState {\n return document.visibilityState;\n}\n\n/* istanbul ignore next -- @preserve */\nfunction getServerSnapshot(): DocumentVisibilityState {\n return 'visible';\n}\n\nexport function useVisibilityState(): DocumentVisibilityState {\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n"]}
1
+ {"version":3,"sources":["../src/useVisibilityState.ts"],"names":[],"mappings":";AAAA,SAAS,4BAA4B;AAErC,SAAS,UAAU,eAA2C;AAC5D,WAAS,iBAAiB,oBAAoB,eAAe;AAAA,IAC3D,SAAS;AAAA,EACX,CAAC;AAED,SAAO,MAAM;AACX,aAAS,oBAAoB,oBAAoB,aAAa;AAAA,EAChE;AACF;AAEA,SAAS,cAAuC;AAC9C,SAAO,SAAS;AAClB;AAGA,SAAS,oBAA6C;AACpD,SAAO;AACT;AAEO,SAAS,qBAA8C;AAC5D,SAAO,qBAAqB,WAAW,aAAa,iBAAiB;AACvE","sourcesContent":["import { useSyncExternalStore } from 'use-sync-external-store/shim';\n\nfunction subscribe(onStoreChange: VoidFunction): VoidFunction {\n document.addEventListener('visibilitychange', onStoreChange, {\n passive: true,\n });\n\n return () => {\n document.removeEventListener('visibilitychange', onStoreChange);\n };\n}\n\nfunction getSnapshot(): DocumentVisibilityState {\n return document.visibilityState;\n}\n\n/* istanbul ignore next -- @preserve */\nfunction getServerSnapshot(): DocumentVisibilityState {\n return 'visible';\n}\n\nexport function useVisibilityState(): DocumentVisibilityState {\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { useSyncExternalStore } from 'use-sync-external-store';
1
+ import { useSyncExternalStore } from 'use-sync-external-store/shim';
2
2
 
3
3
  // src/useVisibilityState.ts
4
4
  function subscribe(onStoreChange) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/useVisibilityState.ts"],"names":[],"mappings":";AAAA,SAAS,4BAA4B;AAErC,SAAS,UAAU,eAA2C;AAC5D,WAAS,iBAAiB,oBAAoB,eAAe;AAAA,IAC3D,SAAS;AAAA,EACX,CAAC;AAED,SAAO,MAAM;AACX,aAAS,oBAAoB,oBAAoB,aAAa;AAAA,EAChE;AACF;AAEA,SAAS,cAAuC;AAC9C,SAAO,SAAS;AAClB;AAGA,SAAS,oBAA6C;AACpD,SAAO;AACT;AAEO,SAAS,qBAA8C;AAC5D,SAAO,qBAAqB,WAAW,aAAa,iBAAiB;AACvE","sourcesContent":["import { useSyncExternalStore } from 'use-sync-external-store';\n\nfunction subscribe(onStoreChange: VoidFunction): VoidFunction {\n document.addEventListener('visibilitychange', onStoreChange, {\n passive: true,\n });\n\n return () => {\n document.removeEventListener('visibilitychange', onStoreChange);\n };\n}\n\nfunction getSnapshot(): DocumentVisibilityState {\n return document.visibilityState;\n}\n\n/* istanbul ignore next -- @preserve */\nfunction getServerSnapshot(): DocumentVisibilityState {\n return 'visible';\n}\n\nexport function useVisibilityState(): DocumentVisibilityState {\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n"]}
1
+ {"version":3,"sources":["../src/useVisibilityState.ts"],"names":[],"mappings":";AAAA,SAAS,4BAA4B;AAErC,SAAS,UAAU,eAA2C;AAC5D,WAAS,iBAAiB,oBAAoB,eAAe;AAAA,IAC3D,SAAS;AAAA,EACX,CAAC;AAED,SAAO,MAAM;AACX,aAAS,oBAAoB,oBAAoB,aAAa;AAAA,EAChE;AACF;AAEA,SAAS,cAAuC;AAC9C,SAAO,SAAS;AAClB;AAGA,SAAS,oBAA6C;AACpD,SAAO;AACT;AAEO,SAAS,qBAA8C;AAC5D,SAAO,qBAAqB,WAAW,aAAa,iBAAiB;AACvE","sourcesContent":["import { useSyncExternalStore } from 'use-sync-external-store/shim';\n\nfunction subscribe(onStoreChange: VoidFunction): VoidFunction {\n document.addEventListener('visibilitychange', onStoreChange, {\n passive: true,\n });\n\n return () => {\n document.removeEventListener('visibilitychange', onStoreChange);\n };\n}\n\nfunction getSnapshot(): DocumentVisibilityState {\n return document.visibilityState;\n}\n\n/* istanbul ignore next -- @preserve */\nfunction getServerSnapshot(): DocumentVisibilityState {\n return 'visible';\n}\n\nexport function useVisibilityState(): DocumentVisibilityState {\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mado/hooks",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
package/src/useOnline.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { useSyncExternalStore } from 'use-sync-external-store';
1
+ import { useSyncExternalStore } from 'use-sync-external-store/shim';
2
2
 
3
3
  function subscribe(onStoreChange: VoidFunction): VoidFunction {
4
4
  window.addEventListener('online', onStoreChange, {
@@ -1,4 +1,4 @@
1
- import { useSyncExternalStore } from 'use-sync-external-store';
1
+ import { useSyncExternalStore } from 'use-sync-external-store/shim';
2
2
 
3
3
  function subscribe(onStoreChange: VoidFunction): VoidFunction {
4
4
  document.addEventListener('visibilitychange', onStoreChange, {