@mado/hooks 0.3.1 → 0.3.3
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 +13 -0
- package/dist/useOnline.cjs +2 -2
- package/dist/useOnline.cjs.map +1 -1
- package/dist/useOnline.js +1 -1
- package/dist/useOnline.js.map +1 -1
- package/dist/useVisibilityState.cjs +2 -2
- package/dist/useVisibilityState.cjs.map +1 -1
- package/dist/useVisibilityState.js +1 -1
- package/dist/useVisibilityState.js.map +1 -1
- package/package.json +2 -2
- package/src/useOnline.ts +1 -1
- package/src/useVisibilityState.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @mado/hooks
|
|
2
2
|
|
|
3
|
+
## 0.3.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [7da15aa]
|
|
8
|
+
- @mado/utils@0.3.0
|
|
9
|
+
|
|
10
|
+
## 0.3.2
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 1b8fde4: Use shim import for useSyncExternalStore for React 16/17 compatibility
|
|
15
|
+
|
|
3
16
|
## 0.3.1
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/useOnline.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
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
|
|
25
|
+
return shim.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
26
26
|
}
|
|
27
27
|
/* istanbul ignore next -- @preserve */
|
|
28
28
|
|
package/dist/useOnline.cjs.map
CHANGED
|
@@ -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
package/dist/useOnline.js.map
CHANGED
|
@@ -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
|
|
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
|
|
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 +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.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"use-sync-external-store": "^1.2.0",
|
|
50
|
-
"@mado/utils": "^0.
|
|
50
|
+
"@mado/utils": "^0.3.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/use-sync-external-store": "^0.0.6",
|
package/src/useOnline.ts
CHANGED