react-alp-connection-state 4.1.1 → 5.0.1
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/.eslintrc.json +1 -1
- package/CHANGELOG.md +45 -0
- package/dist/index-browser.es.js +2 -2
- package/dist/index-browser.es.js.map +1 -1
- package/dist/index-browsermodern.es.js +2 -2
- package/dist/index-browsermodern.es.js.map +1 -1
- package/dist/{index-node12.mjs → index-node14.mjs} +3 -3
- package/dist/index-node14.mjs.map +1 -0
- package/package.json +25 -48
- package/rollup.config.mjs +3 -0
- package/src/.eslintrc.json +18 -1
- package/src/index.tsx +1 -1
- package/dist/index-browser-dev.cjs.js +0 -46
- package/dist/index-browser-dev.cjs.js.map +0 -1
- package/dist/index-browser-dev.es.js +0 -37
- package/dist/index-browser-dev.es.js.map +0 -1
- package/dist/index-browser.cjs.js +0 -46
- package/dist/index-browser.cjs.js.map +0 -1
- package/dist/index-browsermodern-dev.es.js +0 -38
- package/dist/index-browsermodern-dev.es.js.map +0 -1
- package/dist/index-node12-dev.cjs.js +0 -46
- package/dist/index-node12-dev.cjs.js.map +0 -1
- package/dist/index-node12-dev.mjs +0 -37
- package/dist/index-node12-dev.mjs.map +0 -1
- package/dist/index-node12.cjs.js +0 -46
- package/dist/index-node12.cjs.js.map +0 -1
- package/dist/index-node12.mjs.map +0 -1
- package/index.js +0 -6
package/.eslintrc.json
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,51 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [5.0.1](https://github.com/christophehurpeau/alp/compare/react-alp-connection-state@5.0.0...react-alp-connection-state@5.0.1) (2022-01-15)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package react-alp-connection-state
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [5.0.0](https://github.com/christophehurpeau/alp/compare/react-alp-connection-state@4.1.3...react-alp-connection-state@5.0.0) (2022-01-02)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* update nightingale and fix tests ([3691716](https://github.com/christophehurpeau/alp/commit/36917162d0ee3dccc07384caf018b7760d98b744))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* use ESM and drop node 12 ([f45054e](https://github.com/christophehurpeau/alp/commit/f45054e931eea88451d183722797eba057511236))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### BREAKING CHANGES
|
|
28
|
+
|
|
29
|
+
* requires node 14 and ESM
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
## [4.1.3](https://github.com/christophehurpeau/alp/compare/react-alp-connection-state@4.1.2...react-alp-connection-state@4.1.3) (2021-04-10)
|
|
36
|
+
|
|
37
|
+
**Note:** Version bump only for package react-alp-connection-state
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
## [4.1.2](https://github.com/christophehurpeau/alp/compare/react-alp-connection-state@4.1.1...react-alp-connection-state@4.1.2) (2021-03-28)
|
|
44
|
+
|
|
45
|
+
**Note:** Version bump only for package react-alp-connection-state
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
6
51
|
## [4.1.1](https://github.com/christophehurpeau/alp/compare/react-alp-connection-state@4.1.0...react-alp-connection-state@4.1.1) (2021-03-28)
|
|
7
52
|
|
|
8
53
|
**Note:** Version bump only for package react-alp-connection-state
|
package/dist/index-browser.es.js
CHANGED
|
@@ -10,7 +10,7 @@ function ConnectionState(_ref) {
|
|
|
10
10
|
var unloadingRef = useRef(false);
|
|
11
11
|
var currentStateRef = useRef(state);
|
|
12
12
|
|
|
13
|
-
if (unloadingRef.current
|
|
13
|
+
if (!unloadingRef.current) {
|
|
14
14
|
currentStateRef.current = state;
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -33,5 +33,5 @@ function ConnectionState(_ref) {
|
|
|
33
33
|
})));
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
export default
|
|
36
|
+
export { ConnectionState as default };
|
|
37
37
|
//# sourceMappingURL=index-browser.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-browser.es.js","sources":["../src/index.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport React, { useContext, useEffect, useRef } from 'react';\nimport ReactAlpContext from 'react-alp-context';\nimport { T } from 'react-alp-translate';\nimport '../ConnectionState.global.scss';\n\ntype State = null | 'connecting' | 'connected' | 'disconnected';\n\ninterface ConnectionStateProps {\n state: State;\n}\n\nexport default function ConnectionState({\n state,\n}: ConnectionStateProps): ReactElement {\n const ctx = useContext(ReactAlpContext);\n const notLoggedIn = !(ctx.sanitizedState as { user?: unknown }).user;\n\n const unloadingRef = useRef<boolean>(false);\n const currentStateRef = useRef(state);\n if (unloadingRef.current
|
|
1
|
+
{"version":3,"file":"index-browser.es.js","sources":["../src/index.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport React, { useContext, useEffect, useRef } from 'react';\nimport ReactAlpContext from 'react-alp-context';\nimport { T } from 'react-alp-translate';\nimport '../ConnectionState.global.scss';\n\ntype State = null | 'connecting' | 'connected' | 'disconnected';\n\ninterface ConnectionStateProps {\n state: State;\n}\n\nexport default function ConnectionState({\n state,\n}: ConnectionStateProps): ReactElement {\n const ctx = useContext(ReactAlpContext);\n const notLoggedIn = !(ctx.sanitizedState as { user?: unknown }).user;\n\n const unloadingRef = useRef<boolean>(false);\n const currentStateRef = useRef(state);\n if (!unloadingRef.current) {\n currentStateRef.current = state;\n }\n const currentState = currentStateRef.current;\n\n useEffect((): (() => void) => {\n const beforeUnloadHandler = (): void => {\n unloadingRef.current = true;\n };\n window.addEventListener('beforeunload', beforeUnloadHandler);\n\n return (): void => {\n window.removeEventListener('beforeunload', beforeUnloadHandler);\n };\n }, []);\n\n return (\n <div\n hidden={!state || notLoggedIn || currentState === 'connected'}\n className=\"alp-connection-state\"\n >\n {!state || notLoggedIn ? null : (\n <div>\n <T id={`connectionState.${currentState as string}`} />\n </div>\n )}\n </div>\n );\n}\n"],"names":["ConnectionState","state","ctx","useContext","ReactAlpContext","notLoggedIn","sanitizedState","user","unloadingRef","useRef","currentStateRef","current","currentState","useEffect","beforeUnloadHandler","window","addEventListener","removeEventListener"],"mappings":";;;;;AAYe,SAASA,eAAT,OAEwB;AAAA,MADrCC,KACqC,QADrCA,KACqC;AACrC,MAAMC,GAAG,GAAGC,UAAU,CAACC,eAAD,CAAtB;AACA,MAAMC,WAAW,GAAG,CAAEH,GAAG,CAACI,cAAL,CAA2CC,IAAhE;AAEA,MAAMC,YAAY,GAAGC,MAAM,CAAU,KAAV,CAA3B;AACA,MAAMC,eAAe,GAAGD,MAAM,CAACR,KAAD,CAA9B;;AACA,MAAI,CAACO,YAAY,CAACG,OAAlB,EAA2B;AACzBD,IAAAA,eAAe,CAACC,OAAhB,GAA0BV,KAA1B;AACD;;AACD,MAAMW,YAAY,GAAGF,eAAe,CAACC,OAArC;AAEAE,EAAAA,SAAS,CAAC,YAAoB;AAC5B,QAAMC,mBAAmB,GAAG,SAAtBA,mBAAsB,GAAY;AACtCN,MAAAA,YAAY,CAACG,OAAb,GAAuB,IAAvB;AACD,KAFD;;AAGAI,IAAAA,MAAM,CAACC,gBAAP,CAAwB,cAAxB,EAAwCF,mBAAxC;AAEA,WAAO,YAAY;AACjBC,MAAAA,MAAM,CAACE,mBAAP,CAA2B,cAA3B,EAA2CH,mBAA3C;AACD,KAFD;AAGD,GATQ,EASN,EATM,CAAT;AAWA,sBACE;AACE,IAAA,MAAM,EAAE,CAACb,KAAD,IAAUI,WAAV,IAAyBO,YAAY,KAAK,WADpD;AAEE,IAAA,SAAS,EAAC;AAFZ,KAIG,CAACX,KAAD,IAAUI,WAAV,GAAwB,IAAxB,gBACC,8CACE,oBAAC,CAAD;AAAG,IAAA,EAAE,uBAAqBO;AAA1B,IADF,CALJ,CADF;AAYD;;;;"}
|
|
@@ -11,7 +11,7 @@ function ConnectionState({
|
|
|
11
11
|
const unloadingRef = useRef(false);
|
|
12
12
|
const currentStateRef = useRef(state);
|
|
13
13
|
|
|
14
|
-
if (unloadingRef.current
|
|
14
|
+
if (!unloadingRef.current) {
|
|
15
15
|
currentStateRef.current = state;
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -34,5 +34,5 @@ function ConnectionState({
|
|
|
34
34
|
})));
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export default
|
|
37
|
+
export { ConnectionState as default };
|
|
38
38
|
//# sourceMappingURL=index-browsermodern.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-browsermodern.es.js","sources":["../src/index.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport React, { useContext, useEffect, useRef } from 'react';\nimport ReactAlpContext from 'react-alp-context';\nimport { T } from 'react-alp-translate';\nimport '../ConnectionState.global.scss';\n\ntype State = null | 'connecting' | 'connected' | 'disconnected';\n\ninterface ConnectionStateProps {\n state: State;\n}\n\nexport default function ConnectionState({\n state,\n}: ConnectionStateProps): ReactElement {\n const ctx = useContext(ReactAlpContext);\n const notLoggedIn = !(ctx.sanitizedState as { user?: unknown }).user;\n\n const unloadingRef = useRef<boolean>(false);\n const currentStateRef = useRef(state);\n if (unloadingRef.current
|
|
1
|
+
{"version":3,"file":"index-browsermodern.es.js","sources":["../src/index.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport React, { useContext, useEffect, useRef } from 'react';\nimport ReactAlpContext from 'react-alp-context';\nimport { T } from 'react-alp-translate';\nimport '../ConnectionState.global.scss';\n\ntype State = null | 'connecting' | 'connected' | 'disconnected';\n\ninterface ConnectionStateProps {\n state: State;\n}\n\nexport default function ConnectionState({\n state,\n}: ConnectionStateProps): ReactElement {\n const ctx = useContext(ReactAlpContext);\n const notLoggedIn = !(ctx.sanitizedState as { user?: unknown }).user;\n\n const unloadingRef = useRef<boolean>(false);\n const currentStateRef = useRef(state);\n if (!unloadingRef.current) {\n currentStateRef.current = state;\n }\n const currentState = currentStateRef.current;\n\n useEffect((): (() => void) => {\n const beforeUnloadHandler = (): void => {\n unloadingRef.current = true;\n };\n window.addEventListener('beforeunload', beforeUnloadHandler);\n\n return (): void => {\n window.removeEventListener('beforeunload', beforeUnloadHandler);\n };\n }, []);\n\n return (\n <div\n hidden={!state || notLoggedIn || currentState === 'connected'}\n className=\"alp-connection-state\"\n >\n {!state || notLoggedIn ? null : (\n <div>\n <T id={`connectionState.${currentState as string}`} />\n </div>\n )}\n </div>\n );\n}\n"],"names":["ConnectionState","state","ctx","useContext","ReactAlpContext","notLoggedIn","sanitizedState","user","unloadingRef","useRef","currentStateRef","current","currentState","useEffect","beforeUnloadHandler","window","addEventListener","removeEventListener"],"mappings":";;;;;AAYe,SAASA,eAAT,CAAyB;AACtCC,EAAAA;AADsC,CAAzB,EAEwB;AACrC,QAAMC,GAAG,GAAGC,UAAU,CAACC,eAAD,CAAtB;AACA,QAAMC,WAAW,GAAG,CAAEH,GAAG,CAACI,cAAL,CAA2CC,IAAhE;AAEA,QAAMC,YAAY,GAAGC,MAAM,CAAU,KAAV,CAA3B;AACA,QAAMC,eAAe,GAAGD,MAAM,CAACR,KAAD,CAA9B;;AACA,MAAI,CAACO,YAAY,CAACG,OAAlB,EAA2B;AACzBD,IAAAA,eAAe,CAACC,OAAhB,GAA0BV,KAA1B;AACD;;AACD,QAAMW,YAAY,GAAGF,eAAe,CAACC,OAArC;AAEAE,EAAAA,SAAS,CAAC,MAAoB;AAC5B,UAAMC,mBAAmB,GAAG,MAAY;AACtCN,MAAAA,YAAY,CAACG,OAAb,GAAuB,IAAvB;AACD,KAFD;;AAGAI,IAAAA,MAAM,CAACC,gBAAP,CAAwB,cAAxB,EAAwCF,mBAAxC;AAEA,WAAO,MAAY;AACjBC,MAAAA,MAAM,CAACE,mBAAP,CAA2B,cAA3B,EAA2CH,mBAA3C;AACD,KAFD;AAGD,GATQ,EASN,EATM,CAAT;AAWA,sBACE;AACE,IAAA,MAAM,EAAE,CAACb,KAAD,IAAUI,WAAV,IAAyBO,YAAY,KAAK,WADpD;AAEE,IAAA,SAAS,EAAC;AAFZ,KAIG,CAACX,KAAD,IAAUI,WAAV,GAAwB,IAAxB,gBACC,8CACE,oBAAC,CAAD;AAAG,IAAA,EAAE,EAAG,mBAAkBO,YAAuB;AAAjD,IADF,CALJ,CADF;AAYD;;;;"}
|
|
@@ -10,7 +10,7 @@ function ConnectionState({
|
|
|
10
10
|
const unloadingRef = useRef(false);
|
|
11
11
|
const currentStateRef = useRef(state);
|
|
12
12
|
|
|
13
|
-
if (unloadingRef.current
|
|
13
|
+
if (!unloadingRef.current) {
|
|
14
14
|
currentStateRef.current = state;
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -33,5 +33,5 @@ function ConnectionState({
|
|
|
33
33
|
})));
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
export default
|
|
37
|
-
//# sourceMappingURL=index-
|
|
36
|
+
export { ConnectionState as default };
|
|
37
|
+
//# sourceMappingURL=index-node14.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-node14.mjs","sources":["../src/index.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport React, { useContext, useEffect, useRef } from 'react';\nimport ReactAlpContext from 'react-alp-context';\nimport { T } from 'react-alp-translate';\nimport '../ConnectionState.global.scss';\n\ntype State = null | 'connecting' | 'connected' | 'disconnected';\n\ninterface ConnectionStateProps {\n state: State;\n}\n\nexport default function ConnectionState({\n state,\n}: ConnectionStateProps): ReactElement {\n const ctx = useContext(ReactAlpContext);\n const notLoggedIn = !(ctx.sanitizedState as { user?: unknown }).user;\n\n const unloadingRef = useRef<boolean>(false);\n const currentStateRef = useRef(state);\n if (!unloadingRef.current) {\n currentStateRef.current = state;\n }\n const currentState = currentStateRef.current;\n\n useEffect((): (() => void) => {\n const beforeUnloadHandler = (): void => {\n unloadingRef.current = true;\n };\n window.addEventListener('beforeunload', beforeUnloadHandler);\n\n return (): void => {\n window.removeEventListener('beforeunload', beforeUnloadHandler);\n };\n }, []);\n\n return (\n <div\n hidden={!state || notLoggedIn || currentState === 'connected'}\n className=\"alp-connection-state\"\n >\n {!state || notLoggedIn ? null : (\n <div>\n <T id={`connectionState.${currentState as string}`} />\n </div>\n )}\n </div>\n );\n}\n"],"names":["ConnectionState","state","ctx","useContext","ReactAlpContext","notLoggedIn","sanitizedState","user","unloadingRef","useRef","currentStateRef","current","currentState","useEffect","beforeUnloadHandler","window","addEventListener","removeEventListener"],"mappings":";;;;AAYe,SAASA,eAAT,CAAyB;AACtCC,EAAAA;AADsC,CAAzB,EAEwB;AACrC,QAAMC,GAAG,GAAGC,UAAU,CAACC,eAAD,CAAtB;AACA,QAAMC,WAAW,GAAG,CAAEH,GAAG,CAACI,cAAL,CAA2CC,IAAhE;AAEA,QAAMC,YAAY,GAAGC,MAAM,CAAU,KAAV,CAA3B;AACA,QAAMC,eAAe,GAAGD,MAAM,CAACR,KAAD,CAA9B;;AACA,MAAI,CAACO,YAAY,CAACG,OAAlB,EAA2B;AACzBD,IAAAA,eAAe,CAACC,OAAhB,GAA0BV,KAA1B;AACD;;AACD,QAAMW,YAAY,GAAGF,eAAe,CAACC,OAArC;AAEAE,EAAAA,SAAS,CAAC,MAAoB;AAC5B,UAAMC,mBAAmB,GAAG,MAAY;AACtCN,MAAAA,YAAY,CAACG,OAAb,GAAuB,IAAvB;AACD,KAFD;;AAGAI,IAAAA,MAAM,CAACC,gBAAP,CAAwB,cAAxB,EAAwCF,mBAAxC;AAEA,WAAO,MAAY;AACjBC,MAAAA,MAAM,CAACE,mBAAP,CAA2B,cAA3B,EAA2CH,mBAA3C;AACD,KAFD;AAGD,GATQ,EASN,EATM,CAAT;AAWA,sBACE;AACE,IAAA,MAAM,EAAE,CAACb,KAAD,IAAUI,WAAV,IAAyBO,YAAY,KAAK,WADpD;AAEE,IAAA,SAAS,EAAC;AAFZ,KAIG,CAACX,KAAD,IAAUI,WAAV,GAAwB,IAAxB,gBACC,8CACE,oBAAC,CAAD;AAAG,IAAA,EAAE,EAAG,mBAAkBO,YAAuB;AAAjD,IADF,CALJ,CADF;AAYD;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-alp-connection-state",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "connection state",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "Christophe Hurpeau <christophe@hurpeau.com> (https://christophe.hurpeau.com)",
|
|
@@ -11,64 +11,44 @@
|
|
|
11
11
|
"directory": "packages/react-alp-connection-state"
|
|
12
12
|
},
|
|
13
13
|
"homepage": "https://github.com/christophehurpeau/alp",
|
|
14
|
+
"type": "module",
|
|
14
15
|
"engines": {
|
|
15
|
-
"node": ">=
|
|
16
|
+
"node": "^14.13.1 || >=16.0.0"
|
|
16
17
|
},
|
|
17
18
|
"browserslist": [
|
|
19
|
+
"defaults",
|
|
18
20
|
"> 0.2%",
|
|
19
|
-
"Firefox ESR",
|
|
20
|
-
"last 2 Chrome versions",
|
|
21
|
-
"last 2 iOS versions",
|
|
22
|
-
"last 2 Edge versions",
|
|
23
|
-
"last 2 Safari versions",
|
|
24
21
|
"not ie < 12",
|
|
25
|
-
"not
|
|
26
|
-
"not
|
|
27
|
-
"not op_mini all"
|
|
22
|
+
"not safari < 10",
|
|
23
|
+
"not ios_saf < 10"
|
|
28
24
|
],
|
|
29
|
-
"main": "./index.
|
|
25
|
+
"main": "./dist/index-node14.mjs",
|
|
30
26
|
"types": "./dist/index.d.ts",
|
|
31
27
|
"module": "./dist/index-browser.es.js",
|
|
32
28
|
"browser": "./dist/index-browser.es.js",
|
|
33
29
|
"exports": {
|
|
30
|
+
"./package.json": "./package.json",
|
|
34
31
|
".": {
|
|
35
32
|
"node": {
|
|
36
|
-
"
|
|
37
|
-
"import": "./dist/index-node12-dev.mjs",
|
|
38
|
-
"require": "./dist/index-node12-dev.cjs.js"
|
|
39
|
-
},
|
|
40
|
-
"import": "./dist/index-node12.mjs",
|
|
41
|
-
"require": "./dist/index-node12.cjs.js"
|
|
33
|
+
"import": "./dist/index-node14.mjs"
|
|
42
34
|
},
|
|
43
35
|
"browser": {
|
|
44
36
|
"browser:modern": {
|
|
45
|
-
"development": {
|
|
46
|
-
"import": "./dist/index-browsermodern-dev.es.js"
|
|
47
|
-
},
|
|
48
37
|
"import": "./dist/index-browsermodern.es.js"
|
|
49
38
|
},
|
|
50
|
-
"
|
|
51
|
-
"import": "./dist/index-browser-dev.es.js",
|
|
52
|
-
"require": "./dist/index-browser-dev.cjs.js"
|
|
53
|
-
},
|
|
54
|
-
"import": "./dist/index-browser.es.js",
|
|
55
|
-
"require": "./dist/index-browser.cjs.js"
|
|
39
|
+
"import": "./dist/index-browser.es.js"
|
|
56
40
|
}
|
|
57
41
|
}
|
|
58
42
|
},
|
|
59
|
-
"module:node": "./dist/index-
|
|
60
|
-
"module:node-dev": "./dist/index-node12-dev.mjs",
|
|
61
|
-
"module:browser": "./dist/index-browser.es.js",
|
|
62
|
-
"module:browser-dev": "./dist/index-browser-dev.es.js",
|
|
43
|
+
"module:node": "./dist/index-node14.mjs",
|
|
63
44
|
"module:modern-browsers": "./dist/index-browsermodern.es.js",
|
|
64
|
-
"module:modern-browsers-dev": "./dist/index-browsermodern-dev.es.js",
|
|
65
45
|
"sideEffects": false,
|
|
66
46
|
"scripts": {
|
|
67
47
|
"build": "pob-build && yarn run build:definitions",
|
|
68
48
|
"build:definitions": "tsc -p tsconfig.build.json",
|
|
69
|
-
"clean": "rm -Rf
|
|
49
|
+
"clean": "rm -Rf dist",
|
|
70
50
|
"lint": "yarn run lint:eslint",
|
|
71
|
-
"lint:eslint": "
|
|
51
|
+
"lint:eslint": "cd ../.. && yarn run eslint --report-unused-disable-directives --resolve-plugins-relative-to . --quiet packages/react-alp-connection-state",
|
|
72
52
|
"watch": "pob-watch"
|
|
73
53
|
},
|
|
74
54
|
"prettier": {
|
|
@@ -80,9 +60,8 @@
|
|
|
80
60
|
"babelEnvs": [
|
|
81
61
|
{
|
|
82
62
|
"target": "node",
|
|
83
|
-
"version": "
|
|
63
|
+
"version": "14",
|
|
84
64
|
"formats": [
|
|
85
|
-
"cjs",
|
|
86
65
|
"es"
|
|
87
66
|
]
|
|
88
67
|
},
|
|
@@ -96,7 +75,6 @@
|
|
|
96
75
|
{
|
|
97
76
|
"target": "browser",
|
|
98
77
|
"formats": [
|
|
99
|
-
"cjs",
|
|
100
78
|
"es"
|
|
101
79
|
]
|
|
102
80
|
}
|
|
@@ -107,25 +85,24 @@
|
|
|
107
85
|
"jsx": true
|
|
108
86
|
},
|
|
109
87
|
"peerDependencies": {
|
|
110
|
-
"react": "^
|
|
88
|
+
"react": "^17.0.2",
|
|
111
89
|
"ynnub": "^1.0.0 || ^2.0.0"
|
|
112
90
|
},
|
|
113
91
|
"dependencies": {
|
|
114
|
-
"@babel/runtime": "^7.
|
|
92
|
+
"@babel/runtime": "^7.16.7",
|
|
115
93
|
"alp-types": "^3.0.0",
|
|
116
|
-
"react-alp-context": "
|
|
117
|
-
"react-alp-translate": "
|
|
94
|
+
"react-alp-context": "4.0.1",
|
|
95
|
+
"react-alp-translate": "6.0.1"
|
|
118
96
|
},
|
|
119
97
|
"devDependencies": {
|
|
120
|
-
"@babel/core": "7.
|
|
121
|
-
"@babel/preset-env": "7.
|
|
122
|
-
"@babel/preset-react": "7.
|
|
123
|
-
"babel-preset-latest-node": "5.5.1",
|
|
98
|
+
"@babel/core": "7.16.7",
|
|
99
|
+
"@babel/preset-env": "7.16.8",
|
|
100
|
+
"@babel/preset-react": "7.16.7",
|
|
124
101
|
"babel-preset-modern-browsers": "15.0.2",
|
|
125
|
-
"pob-babel": "
|
|
126
|
-
"react": "
|
|
127
|
-
"
|
|
102
|
+
"pob-babel": "29.6.1",
|
|
103
|
+
"react": "17.0.2",
|
|
104
|
+
"typescript": "4.5.4",
|
|
128
105
|
"ynnub": "2.0.0"
|
|
129
106
|
},
|
|
130
|
-
"gitHead": "
|
|
107
|
+
"gitHead": "a69797c459e219e09fcf22cc2ea46aa60dce396b"
|
|
131
108
|
}
|
package/src/.eslintrc.json
CHANGED
|
@@ -9,5 +9,22 @@
|
|
|
9
9
|
"@pob/eslint-config-typescript",
|
|
10
10
|
"@pob/eslint-config-typescript-react"
|
|
11
11
|
],
|
|
12
|
-
"ignorePatterns": ["*.d.ts"]
|
|
12
|
+
"ignorePatterns": ["*.d.ts"],
|
|
13
|
+
"overrides": [
|
|
14
|
+
{
|
|
15
|
+
"files": ["**/*.test.{ts,tsx}", "__tests__/**/*.{ts,tsx}"],
|
|
16
|
+
"extends": ["@pob/eslint-config-typescript/test"],
|
|
17
|
+
"env": {
|
|
18
|
+
"jest": true
|
|
19
|
+
},
|
|
20
|
+
"rules": {
|
|
21
|
+
"import/no-extraneous-dependencies": [
|
|
22
|
+
"error",
|
|
23
|
+
{
|
|
24
|
+
"devDependencies": true
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
]
|
|
13
30
|
}
|
package/src/index.tsx
CHANGED
|
@@ -18,7 +18,7 @@ export default function ConnectionState({
|
|
|
18
18
|
|
|
19
19
|
const unloadingRef = useRef<boolean>(false);
|
|
20
20
|
const currentStateRef = useRef(state);
|
|
21
|
-
if (unloadingRef.current
|
|
21
|
+
if (!unloadingRef.current) {
|
|
22
22
|
currentStateRef.current = state;
|
|
23
23
|
}
|
|
24
24
|
const currentState = currentStateRef.current;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var React = require('react');
|
|
6
|
-
var ReactAlpContext = require('react-alp-context');
|
|
7
|
-
var reactAlpTranslate = require('react-alp-translate');
|
|
8
|
-
require('../ConnectionState.global.scss');
|
|
9
|
-
|
|
10
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
|
|
11
|
-
|
|
12
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
13
|
-
var ReactAlpContext__default = /*#__PURE__*/_interopDefaultLegacy(ReactAlpContext);
|
|
14
|
-
|
|
15
|
-
function ConnectionState(_ref) {
|
|
16
|
-
var state = _ref.state;
|
|
17
|
-
var ctx = React.useContext(ReactAlpContext__default);
|
|
18
|
-
var notLoggedIn = !ctx.sanitizedState.user;
|
|
19
|
-
var unloadingRef = React.useRef(false);
|
|
20
|
-
var currentStateRef = React.useRef(state);
|
|
21
|
-
|
|
22
|
-
if (unloadingRef.current === false) {
|
|
23
|
-
currentStateRef.current = state;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
var currentState = currentStateRef.current;
|
|
27
|
-
React.useEffect(function () {
|
|
28
|
-
var beforeUnloadHandler = function beforeUnloadHandler() {
|
|
29
|
-
unloadingRef.current = true;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
window.addEventListener('beforeunload', beforeUnloadHandler);
|
|
33
|
-
return function () {
|
|
34
|
-
window.removeEventListener('beforeunload', beforeUnloadHandler);
|
|
35
|
-
};
|
|
36
|
-
}, []);
|
|
37
|
-
return /*#__PURE__*/React__default.createElement("div", {
|
|
38
|
-
hidden: !state || notLoggedIn || currentState === 'connected',
|
|
39
|
-
className: "alp-connection-state"
|
|
40
|
-
}, !state || notLoggedIn ? null : /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(reactAlpTranslate.T, {
|
|
41
|
-
id: "connectionState." + currentState
|
|
42
|
-
})));
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
exports.default = ConnectionState;
|
|
46
|
-
//# sourceMappingURL=index-browser-dev.cjs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-browser-dev.cjs.js","sources":["../src/index.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport React, { useContext, useEffect, useRef } from 'react';\nimport ReactAlpContext from 'react-alp-context';\nimport { T } from 'react-alp-translate';\nimport '../ConnectionState.global.scss';\n\ntype State = null | 'connecting' | 'connected' | 'disconnected';\n\ninterface ConnectionStateProps {\n state: State;\n}\n\nexport default function ConnectionState({\n state,\n}: ConnectionStateProps): ReactElement {\n const ctx = useContext(ReactAlpContext);\n const notLoggedIn = !(ctx.sanitizedState as { user?: unknown }).user;\n\n const unloadingRef = useRef<boolean>(false);\n const currentStateRef = useRef(state);\n if (unloadingRef.current === false) {\n currentStateRef.current = state;\n }\n const currentState = currentStateRef.current;\n\n useEffect((): (() => void) => {\n const beforeUnloadHandler = (): void => {\n unloadingRef.current = true;\n };\n window.addEventListener('beforeunload', beforeUnloadHandler);\n\n return (): void => {\n window.removeEventListener('beforeunload', beforeUnloadHandler);\n };\n }, []);\n\n return (\n <div\n hidden={!state || notLoggedIn || currentState === 'connected'}\n className=\"alp-connection-state\"\n >\n {!state || notLoggedIn ? null : (\n <div>\n <T id={`connectionState.${currentState as string}`} />\n </div>\n )}\n </div>\n );\n}\n"],"names":["ConnectionState","state","ctx","useContext","ReactAlpContext","notLoggedIn","sanitizedState","user","unloadingRef","useRef","currentStateRef","current","currentState","useEffect","beforeUnloadHandler","window","addEventListener","removeEventListener","React","T"],"mappings":";;;;;;;;;;;;;;AAYe,SAASA,eAAT,OAEwB;AAAA,MADrCC,KACqC,QADrCA,KACqC;AACrC,MAAMC,GAAG,GAAGC,gBAAU,CAACC,wBAAD,CAAtB;AACA,MAAMC,WAAW,GAAG,CAAEH,GAAG,CAACI,cAAL,CAA2CC,IAAhE;AAEA,MAAMC,YAAY,GAAGC,YAAM,CAAU,KAAV,CAA3B;AACA,MAAMC,eAAe,GAAGD,YAAM,CAACR,KAAD,CAA9B;;AACA,MAAIO,YAAY,CAACG,OAAb,KAAyB,KAA7B,EAAoC;AAClCD,IAAAA,eAAe,CAACC,OAAhB,GAA0BV,KAA1B;AACD;;AACD,MAAMW,YAAY,GAAGF,eAAe,CAACC,OAArC;AAEAE,EAAAA,eAAS,CAAC,YAAoB;AAC5B,QAAMC,mBAAmB,GAAG,SAAtBA,mBAAsB,GAAY;AACtCN,MAAAA,YAAY,CAACG,OAAb,GAAuB,IAAvB;AACD,KAFD;;AAGAI,IAAAA,MAAM,CAACC,gBAAP,CAAwB,cAAxB,EAAwCF,mBAAxC;AAEA,WAAO,YAAY;AACjBC,MAAAA,MAAM,CAACE,mBAAP,CAA2B,cAA3B,EAA2CH,mBAA3C;AACD,KAFD;AAGD,GATQ,EASN,EATM,CAAT;AAWA,sBACEI;AACE,IAAA,MAAM,EAAE,CAACjB,KAAD,IAAUI,WAAV,IAAyBO,YAAY,KAAK,WADpD;AAEE,IAAA,SAAS,EAAC;AAFZ,KAIG,CAACX,KAAD,IAAUI,WAAV,GAAwB,IAAxB,gBACCa,uDACEA,6BAACC,mBAAD;AAAG,IAAA,EAAE,uBAAqBP;AAA1B,IADF,CALJ,CADF;AAYD;;;;"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import React, { useContext, useRef, useEffect } from 'react';
|
|
2
|
-
import ReactAlpContext from 'react-alp-context';
|
|
3
|
-
import { T } from 'react-alp-translate';
|
|
4
|
-
import '../ConnectionState.global.scss';
|
|
5
|
-
|
|
6
|
-
function ConnectionState(_ref) {
|
|
7
|
-
var state = _ref.state;
|
|
8
|
-
var ctx = useContext(ReactAlpContext);
|
|
9
|
-
var notLoggedIn = !ctx.sanitizedState.user;
|
|
10
|
-
var unloadingRef = useRef(false);
|
|
11
|
-
var currentStateRef = useRef(state);
|
|
12
|
-
|
|
13
|
-
if (unloadingRef.current === false) {
|
|
14
|
-
currentStateRef.current = state;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
var currentState = currentStateRef.current;
|
|
18
|
-
useEffect(function () {
|
|
19
|
-
var beforeUnloadHandler = function beforeUnloadHandler() {
|
|
20
|
-
unloadingRef.current = true;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
window.addEventListener('beforeunload', beforeUnloadHandler);
|
|
24
|
-
return function () {
|
|
25
|
-
window.removeEventListener('beforeunload', beforeUnloadHandler);
|
|
26
|
-
};
|
|
27
|
-
}, []);
|
|
28
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
29
|
-
hidden: !state || notLoggedIn || currentState === 'connected',
|
|
30
|
-
className: "alp-connection-state"
|
|
31
|
-
}, !state || notLoggedIn ? null : /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(T, {
|
|
32
|
-
id: "connectionState." + currentState
|
|
33
|
-
})));
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export default ConnectionState;
|
|
37
|
-
//# sourceMappingURL=index-browser-dev.es.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-browser-dev.es.js","sources":["../src/index.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport React, { useContext, useEffect, useRef } from 'react';\nimport ReactAlpContext from 'react-alp-context';\nimport { T } from 'react-alp-translate';\nimport '../ConnectionState.global.scss';\n\ntype State = null | 'connecting' | 'connected' | 'disconnected';\n\ninterface ConnectionStateProps {\n state: State;\n}\n\nexport default function ConnectionState({\n state,\n}: ConnectionStateProps): ReactElement {\n const ctx = useContext(ReactAlpContext);\n const notLoggedIn = !(ctx.sanitizedState as { user?: unknown }).user;\n\n const unloadingRef = useRef<boolean>(false);\n const currentStateRef = useRef(state);\n if (unloadingRef.current === false) {\n currentStateRef.current = state;\n }\n const currentState = currentStateRef.current;\n\n useEffect((): (() => void) => {\n const beforeUnloadHandler = (): void => {\n unloadingRef.current = true;\n };\n window.addEventListener('beforeunload', beforeUnloadHandler);\n\n return (): void => {\n window.removeEventListener('beforeunload', beforeUnloadHandler);\n };\n }, []);\n\n return (\n <div\n hidden={!state || notLoggedIn || currentState === 'connected'}\n className=\"alp-connection-state\"\n >\n {!state || notLoggedIn ? null : (\n <div>\n <T id={`connectionState.${currentState as string}`} />\n </div>\n )}\n </div>\n );\n}\n"],"names":["ConnectionState","state","ctx","useContext","ReactAlpContext","notLoggedIn","sanitizedState","user","unloadingRef","useRef","currentStateRef","current","currentState","useEffect","beforeUnloadHandler","window","addEventListener","removeEventListener"],"mappings":";;;;;AAYe,SAASA,eAAT,OAEwB;AAAA,MADrCC,KACqC,QADrCA,KACqC;AACrC,MAAMC,GAAG,GAAGC,UAAU,CAACC,eAAD,CAAtB;AACA,MAAMC,WAAW,GAAG,CAAEH,GAAG,CAACI,cAAL,CAA2CC,IAAhE;AAEA,MAAMC,YAAY,GAAGC,MAAM,CAAU,KAAV,CAA3B;AACA,MAAMC,eAAe,GAAGD,MAAM,CAACR,KAAD,CAA9B;;AACA,MAAIO,YAAY,CAACG,OAAb,KAAyB,KAA7B,EAAoC;AAClCD,IAAAA,eAAe,CAACC,OAAhB,GAA0BV,KAA1B;AACD;;AACD,MAAMW,YAAY,GAAGF,eAAe,CAACC,OAArC;AAEAE,EAAAA,SAAS,CAAC,YAAoB;AAC5B,QAAMC,mBAAmB,GAAG,SAAtBA,mBAAsB,GAAY;AACtCN,MAAAA,YAAY,CAACG,OAAb,GAAuB,IAAvB;AACD,KAFD;;AAGAI,IAAAA,MAAM,CAACC,gBAAP,CAAwB,cAAxB,EAAwCF,mBAAxC;AAEA,WAAO,YAAY;AACjBC,MAAAA,MAAM,CAACE,mBAAP,CAA2B,cAA3B,EAA2CH,mBAA3C;AACD,KAFD;AAGD,GATQ,EASN,EATM,CAAT;AAWA,sBACE;AACE,IAAA,MAAM,EAAE,CAACb,KAAD,IAAUI,WAAV,IAAyBO,YAAY,KAAK,WADpD;AAEE,IAAA,SAAS,EAAC;AAFZ,KAIG,CAACX,KAAD,IAAUI,WAAV,GAAwB,IAAxB,gBACC,8CACE,oBAAC,CAAD;AAAG,IAAA,EAAE,uBAAqBO;AAA1B,IADF,CALJ,CADF;AAYD;;;;"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var React = require('react');
|
|
6
|
-
var ReactAlpContext = require('react-alp-context');
|
|
7
|
-
var reactAlpTranslate = require('react-alp-translate');
|
|
8
|
-
require('../ConnectionState.global.scss');
|
|
9
|
-
|
|
10
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
|
|
11
|
-
|
|
12
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
13
|
-
var ReactAlpContext__default = /*#__PURE__*/_interopDefaultLegacy(ReactAlpContext);
|
|
14
|
-
|
|
15
|
-
function ConnectionState(_ref) {
|
|
16
|
-
var state = _ref.state;
|
|
17
|
-
var ctx = React.useContext(ReactAlpContext__default);
|
|
18
|
-
var notLoggedIn = !ctx.sanitizedState.user;
|
|
19
|
-
var unloadingRef = React.useRef(false);
|
|
20
|
-
var currentStateRef = React.useRef(state);
|
|
21
|
-
|
|
22
|
-
if (unloadingRef.current === false) {
|
|
23
|
-
currentStateRef.current = state;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
var currentState = currentStateRef.current;
|
|
27
|
-
React.useEffect(function () {
|
|
28
|
-
var beforeUnloadHandler = function beforeUnloadHandler() {
|
|
29
|
-
unloadingRef.current = true;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
window.addEventListener('beforeunload', beforeUnloadHandler);
|
|
33
|
-
return function () {
|
|
34
|
-
window.removeEventListener('beforeunload', beforeUnloadHandler);
|
|
35
|
-
};
|
|
36
|
-
}, []);
|
|
37
|
-
return /*#__PURE__*/React__default.createElement("div", {
|
|
38
|
-
hidden: !state || notLoggedIn || currentState === 'connected',
|
|
39
|
-
className: "alp-connection-state"
|
|
40
|
-
}, !state || notLoggedIn ? null : /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(reactAlpTranslate.T, {
|
|
41
|
-
id: "connectionState." + currentState
|
|
42
|
-
})));
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
exports.default = ConnectionState;
|
|
46
|
-
//# sourceMappingURL=index-browser.cjs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-browser.cjs.js","sources":["../src/index.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport React, { useContext, useEffect, useRef } from 'react';\nimport ReactAlpContext from 'react-alp-context';\nimport { T } from 'react-alp-translate';\nimport '../ConnectionState.global.scss';\n\ntype State = null | 'connecting' | 'connected' | 'disconnected';\n\ninterface ConnectionStateProps {\n state: State;\n}\n\nexport default function ConnectionState({\n state,\n}: ConnectionStateProps): ReactElement {\n const ctx = useContext(ReactAlpContext);\n const notLoggedIn = !(ctx.sanitizedState as { user?: unknown }).user;\n\n const unloadingRef = useRef<boolean>(false);\n const currentStateRef = useRef(state);\n if (unloadingRef.current === false) {\n currentStateRef.current = state;\n }\n const currentState = currentStateRef.current;\n\n useEffect((): (() => void) => {\n const beforeUnloadHandler = (): void => {\n unloadingRef.current = true;\n };\n window.addEventListener('beforeunload', beforeUnloadHandler);\n\n return (): void => {\n window.removeEventListener('beforeunload', beforeUnloadHandler);\n };\n }, []);\n\n return (\n <div\n hidden={!state || notLoggedIn || currentState === 'connected'}\n className=\"alp-connection-state\"\n >\n {!state || notLoggedIn ? null : (\n <div>\n <T id={`connectionState.${currentState as string}`} />\n </div>\n )}\n </div>\n );\n}\n"],"names":["ConnectionState","state","ctx","useContext","ReactAlpContext","notLoggedIn","sanitizedState","user","unloadingRef","useRef","currentStateRef","current","currentState","useEffect","beforeUnloadHandler","window","addEventListener","removeEventListener","React","T"],"mappings":";;;;;;;;;;;;;;AAYe,SAASA,eAAT,OAEwB;AAAA,MADrCC,KACqC,QADrCA,KACqC;AACrC,MAAMC,GAAG,GAAGC,gBAAU,CAACC,wBAAD,CAAtB;AACA,MAAMC,WAAW,GAAG,CAAEH,GAAG,CAACI,cAAL,CAA2CC,IAAhE;AAEA,MAAMC,YAAY,GAAGC,YAAM,CAAU,KAAV,CAA3B;AACA,MAAMC,eAAe,GAAGD,YAAM,CAACR,KAAD,CAA9B;;AACA,MAAIO,YAAY,CAACG,OAAb,KAAyB,KAA7B,EAAoC;AAClCD,IAAAA,eAAe,CAACC,OAAhB,GAA0BV,KAA1B;AACD;;AACD,MAAMW,YAAY,GAAGF,eAAe,CAACC,OAArC;AAEAE,EAAAA,eAAS,CAAC,YAAoB;AAC5B,QAAMC,mBAAmB,GAAG,SAAtBA,mBAAsB,GAAY;AACtCN,MAAAA,YAAY,CAACG,OAAb,GAAuB,IAAvB;AACD,KAFD;;AAGAI,IAAAA,MAAM,CAACC,gBAAP,CAAwB,cAAxB,EAAwCF,mBAAxC;AAEA,WAAO,YAAY;AACjBC,MAAAA,MAAM,CAACE,mBAAP,CAA2B,cAA3B,EAA2CH,mBAA3C;AACD,KAFD;AAGD,GATQ,EASN,EATM,CAAT;AAWA,sBACEI;AACE,IAAA,MAAM,EAAE,CAACjB,KAAD,IAAUI,WAAV,IAAyBO,YAAY,KAAK,WADpD;AAEE,IAAA,SAAS,EAAC;AAFZ,KAIG,CAACX,KAAD,IAAUI,WAAV,GAAwB,IAAxB,gBACCa,uDACEA,6BAACC,mBAAD;AAAG,IAAA,EAAE,uBAAqBP;AAA1B,IADF,CALJ,CADF;AAYD;;;;"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import React, { useContext, useRef, useEffect } from 'react';
|
|
2
|
-
import ReactAlpContext from 'react-alp-context';
|
|
3
|
-
import { T } from 'react-alp-translate';
|
|
4
|
-
import '../ConnectionState.global.scss';
|
|
5
|
-
|
|
6
|
-
function ConnectionState({
|
|
7
|
-
state
|
|
8
|
-
}) {
|
|
9
|
-
const ctx = useContext(ReactAlpContext);
|
|
10
|
-
const notLoggedIn = !ctx.sanitizedState.user;
|
|
11
|
-
const unloadingRef = useRef(false);
|
|
12
|
-
const currentStateRef = useRef(state);
|
|
13
|
-
|
|
14
|
-
if (unloadingRef.current === false) {
|
|
15
|
-
currentStateRef.current = state;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const currentState = currentStateRef.current;
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
const beforeUnloadHandler = () => {
|
|
21
|
-
unloadingRef.current = true;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
window.addEventListener('beforeunload', beforeUnloadHandler);
|
|
25
|
-
return () => {
|
|
26
|
-
window.removeEventListener('beforeunload', beforeUnloadHandler);
|
|
27
|
-
};
|
|
28
|
-
}, []);
|
|
29
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
30
|
-
hidden: !state || notLoggedIn || currentState === 'connected',
|
|
31
|
-
className: "alp-connection-state"
|
|
32
|
-
}, !state || notLoggedIn ? null : /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(T, {
|
|
33
|
-
id: `connectionState.${currentState}`
|
|
34
|
-
})));
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export default ConnectionState;
|
|
38
|
-
//# sourceMappingURL=index-browsermodern-dev.es.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-browsermodern-dev.es.js","sources":["../src/index.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport React, { useContext, useEffect, useRef } from 'react';\nimport ReactAlpContext from 'react-alp-context';\nimport { T } from 'react-alp-translate';\nimport '../ConnectionState.global.scss';\n\ntype State = null | 'connecting' | 'connected' | 'disconnected';\n\ninterface ConnectionStateProps {\n state: State;\n}\n\nexport default function ConnectionState({\n state,\n}: ConnectionStateProps): ReactElement {\n const ctx = useContext(ReactAlpContext);\n const notLoggedIn = !(ctx.sanitizedState as { user?: unknown }).user;\n\n const unloadingRef = useRef<boolean>(false);\n const currentStateRef = useRef(state);\n if (unloadingRef.current === false) {\n currentStateRef.current = state;\n }\n const currentState = currentStateRef.current;\n\n useEffect((): (() => void) => {\n const beforeUnloadHandler = (): void => {\n unloadingRef.current = true;\n };\n window.addEventListener('beforeunload', beforeUnloadHandler);\n\n return (): void => {\n window.removeEventListener('beforeunload', beforeUnloadHandler);\n };\n }, []);\n\n return (\n <div\n hidden={!state || notLoggedIn || currentState === 'connected'}\n className=\"alp-connection-state\"\n >\n {!state || notLoggedIn ? null : (\n <div>\n <T id={`connectionState.${currentState as string}`} />\n </div>\n )}\n </div>\n );\n}\n"],"names":["ConnectionState","state","ctx","useContext","ReactAlpContext","notLoggedIn","sanitizedState","user","unloadingRef","useRef","currentStateRef","current","currentState","useEffect","beforeUnloadHandler","window","addEventListener","removeEventListener"],"mappings":";;;;;AAYe,SAASA,eAAT,CAAyB;AACtCC,EAAAA;AADsC,CAAzB,EAEwB;AACrC,QAAMC,GAAG,GAAGC,UAAU,CAACC,eAAD,CAAtB;AACA,QAAMC,WAAW,GAAG,CAAEH,GAAG,CAACI,cAAL,CAA2CC,IAAhE;AAEA,QAAMC,YAAY,GAAGC,MAAM,CAAU,KAAV,CAA3B;AACA,QAAMC,eAAe,GAAGD,MAAM,CAACR,KAAD,CAA9B;;AACA,MAAIO,YAAY,CAACG,OAAb,KAAyB,KAA7B,EAAoC;AAClCD,IAAAA,eAAe,CAACC,OAAhB,GAA0BV,KAA1B;AACD;;AACD,QAAMW,YAAY,GAAGF,eAAe,CAACC,OAArC;AAEAE,EAAAA,SAAS,CAAC,MAAoB;AAC5B,UAAMC,mBAAmB,GAAG,MAAY;AACtCN,MAAAA,YAAY,CAACG,OAAb,GAAuB,IAAvB;AACD,KAFD;;AAGAI,IAAAA,MAAM,CAACC,gBAAP,CAAwB,cAAxB,EAAwCF,mBAAxC;AAEA,WAAO,MAAY;AACjBC,MAAAA,MAAM,CAACE,mBAAP,CAA2B,cAA3B,EAA2CH,mBAA3C;AACD,KAFD;AAGD,GATQ,EASN,EATM,CAAT;AAWA,sBACE;AACE,IAAA,MAAM,EAAE,CAACb,KAAD,IAAUI,WAAV,IAAyBO,YAAY,KAAK,WADpD;AAEE,IAAA,SAAS,EAAC;AAFZ,KAIG,CAACX,KAAD,IAAUI,WAAV,GAAwB,IAAxB,gBACC,8CACE,oBAAC,CAAD;AAAG,IAAA,EAAE,EAAG,mBAAkBO,YAAuB;AAAjD,IADF,CALJ,CADF;AAYD;;;;"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const React = require('react');
|
|
6
|
-
const ReactAlpContext = require('react-alp-context');
|
|
7
|
-
const reactAlpTranslate = require('react-alp-translate');
|
|
8
|
-
|
|
9
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
|
|
10
|
-
|
|
11
|
-
const React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
12
|
-
const ReactAlpContext__default = /*#__PURE__*/_interopDefaultLegacy(ReactAlpContext);
|
|
13
|
-
|
|
14
|
-
function ConnectionState({
|
|
15
|
-
state
|
|
16
|
-
}) {
|
|
17
|
-
const ctx = React.useContext(ReactAlpContext__default);
|
|
18
|
-
const notLoggedIn = !ctx.sanitizedState.user;
|
|
19
|
-
const unloadingRef = React.useRef(false);
|
|
20
|
-
const currentStateRef = React.useRef(state);
|
|
21
|
-
|
|
22
|
-
if (unloadingRef.current === false) {
|
|
23
|
-
currentStateRef.current = state;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const currentState = currentStateRef.current;
|
|
27
|
-
React.useEffect(() => {
|
|
28
|
-
const beforeUnloadHandler = () => {
|
|
29
|
-
unloadingRef.current = true;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
window.addEventListener('beforeunload', beforeUnloadHandler);
|
|
33
|
-
return () => {
|
|
34
|
-
window.removeEventListener('beforeunload', beforeUnloadHandler);
|
|
35
|
-
};
|
|
36
|
-
}, []);
|
|
37
|
-
return /*#__PURE__*/React__default.createElement("div", {
|
|
38
|
-
hidden: !state || notLoggedIn || currentState === 'connected',
|
|
39
|
-
className: "alp-connection-state"
|
|
40
|
-
}, !state || notLoggedIn ? null : /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(reactAlpTranslate.T, {
|
|
41
|
-
id: `connectionState.${currentState}`
|
|
42
|
-
})));
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
exports.default = ConnectionState;
|
|
46
|
-
//# sourceMappingURL=index-node12-dev.cjs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-node12-dev.cjs.js","sources":["../src/index.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport React, { useContext, useEffect, useRef } from 'react';\nimport ReactAlpContext from 'react-alp-context';\nimport { T } from 'react-alp-translate';\nimport '../ConnectionState.global.scss';\n\ntype State = null | 'connecting' | 'connected' | 'disconnected';\n\ninterface ConnectionStateProps {\n state: State;\n}\n\nexport default function ConnectionState({\n state,\n}: ConnectionStateProps): ReactElement {\n const ctx = useContext(ReactAlpContext);\n const notLoggedIn = !(ctx.sanitizedState as { user?: unknown }).user;\n\n const unloadingRef = useRef<boolean>(false);\n const currentStateRef = useRef(state);\n if (unloadingRef.current === false) {\n currentStateRef.current = state;\n }\n const currentState = currentStateRef.current;\n\n useEffect((): (() => void) => {\n const beforeUnloadHandler = (): void => {\n unloadingRef.current = true;\n };\n window.addEventListener('beforeunload', beforeUnloadHandler);\n\n return (): void => {\n window.removeEventListener('beforeunload', beforeUnloadHandler);\n };\n }, []);\n\n return (\n <div\n hidden={!state || notLoggedIn || currentState === 'connected'}\n className=\"alp-connection-state\"\n >\n {!state || notLoggedIn ? null : (\n <div>\n <T id={`connectionState.${currentState as string}`} />\n </div>\n )}\n </div>\n );\n}\n"],"names":["ConnectionState","state","ctx","useContext","ReactAlpContext","notLoggedIn","sanitizedState","user","unloadingRef","useRef","currentStateRef","current","currentState","useEffect","beforeUnloadHandler","window","addEventListener","removeEventListener","React","T"],"mappings":";;;;;;;;;;;;;AAYe,SAASA,eAAT,CAAyB;AACtCC,EAAAA;AADsC,CAAzB,EAEwB;AACrC,QAAMC,GAAG,GAAGC,gBAAU,CAACC,wBAAD,CAAtB;AACA,QAAMC,WAAW,GAAG,CAAEH,GAAG,CAACI,cAAL,CAA2CC,IAAhE;AAEA,QAAMC,YAAY,GAAGC,YAAM,CAAU,KAAV,CAA3B;AACA,QAAMC,eAAe,GAAGD,YAAM,CAACR,KAAD,CAA9B;;AACA,MAAIO,YAAY,CAACG,OAAb,KAAyB,KAA7B,EAAoC;AAClCD,IAAAA,eAAe,CAACC,OAAhB,GAA0BV,KAA1B;AACD;;AACD,QAAMW,YAAY,GAAGF,eAAe,CAACC,OAArC;AAEAE,EAAAA,eAAS,CAAC,MAAoB;AAC5B,UAAMC,mBAAmB,GAAG,MAAY;AACtCN,MAAAA,YAAY,CAACG,OAAb,GAAuB,IAAvB;AACD,KAFD;;AAGAI,IAAAA,MAAM,CAACC,gBAAP,CAAwB,cAAxB,EAAwCF,mBAAxC;AAEA,WAAO,MAAY;AACjBC,MAAAA,MAAM,CAACE,mBAAP,CAA2B,cAA3B,EAA2CH,mBAA3C;AACD,KAFD;AAGD,GATQ,EASN,EATM,CAAT;AAWA,sBACEI;AACE,IAAA,MAAM,EAAE,CAACjB,KAAD,IAAUI,WAAV,IAAyBO,YAAY,KAAK,WADpD;AAEE,IAAA,SAAS,EAAC;AAFZ,KAIG,CAACX,KAAD,IAAUI,WAAV,GAAwB,IAAxB,gBACCa,uDACEA,6BAACC,mBAAD;AAAG,IAAA,EAAE,EAAG,mBAAkBP,YAAuB;AAAjD,IADF,CALJ,CADF;AAYD;;;;"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import React, { useContext, useRef, useEffect } from 'react';
|
|
2
|
-
import ReactAlpContext from 'react-alp-context';
|
|
3
|
-
import { T } from 'react-alp-translate';
|
|
4
|
-
|
|
5
|
-
function ConnectionState({
|
|
6
|
-
state
|
|
7
|
-
}) {
|
|
8
|
-
const ctx = useContext(ReactAlpContext);
|
|
9
|
-
const notLoggedIn = !ctx.sanitizedState.user;
|
|
10
|
-
const unloadingRef = useRef(false);
|
|
11
|
-
const currentStateRef = useRef(state);
|
|
12
|
-
|
|
13
|
-
if (unloadingRef.current === false) {
|
|
14
|
-
currentStateRef.current = state;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const currentState = currentStateRef.current;
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
const beforeUnloadHandler = () => {
|
|
20
|
-
unloadingRef.current = true;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
window.addEventListener('beforeunload', beforeUnloadHandler);
|
|
24
|
-
return () => {
|
|
25
|
-
window.removeEventListener('beforeunload', beforeUnloadHandler);
|
|
26
|
-
};
|
|
27
|
-
}, []);
|
|
28
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
29
|
-
hidden: !state || notLoggedIn || currentState === 'connected',
|
|
30
|
-
className: "alp-connection-state"
|
|
31
|
-
}, !state || notLoggedIn ? null : /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(T, {
|
|
32
|
-
id: `connectionState.${currentState}`
|
|
33
|
-
})));
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export default ConnectionState;
|
|
37
|
-
//# sourceMappingURL=index-node12-dev.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-node12-dev.mjs","sources":["../src/index.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport React, { useContext, useEffect, useRef } from 'react';\nimport ReactAlpContext from 'react-alp-context';\nimport { T } from 'react-alp-translate';\nimport '../ConnectionState.global.scss';\n\ntype State = null | 'connecting' | 'connected' | 'disconnected';\n\ninterface ConnectionStateProps {\n state: State;\n}\n\nexport default function ConnectionState({\n state,\n}: ConnectionStateProps): ReactElement {\n const ctx = useContext(ReactAlpContext);\n const notLoggedIn = !(ctx.sanitizedState as { user?: unknown }).user;\n\n const unloadingRef = useRef<boolean>(false);\n const currentStateRef = useRef(state);\n if (unloadingRef.current === false) {\n currentStateRef.current = state;\n }\n const currentState = currentStateRef.current;\n\n useEffect((): (() => void) => {\n const beforeUnloadHandler = (): void => {\n unloadingRef.current = true;\n };\n window.addEventListener('beforeunload', beforeUnloadHandler);\n\n return (): void => {\n window.removeEventListener('beforeunload', beforeUnloadHandler);\n };\n }, []);\n\n return (\n <div\n hidden={!state || notLoggedIn || currentState === 'connected'}\n className=\"alp-connection-state\"\n >\n {!state || notLoggedIn ? null : (\n <div>\n <T id={`connectionState.${currentState as string}`} />\n </div>\n )}\n </div>\n );\n}\n"],"names":["ConnectionState","state","ctx","useContext","ReactAlpContext","notLoggedIn","sanitizedState","user","unloadingRef","useRef","currentStateRef","current","currentState","useEffect","beforeUnloadHandler","window","addEventListener","removeEventListener"],"mappings":";;;;AAYe,SAASA,eAAT,CAAyB;AACtCC,EAAAA;AADsC,CAAzB,EAEwB;AACrC,QAAMC,GAAG,GAAGC,UAAU,CAACC,eAAD,CAAtB;AACA,QAAMC,WAAW,GAAG,CAAEH,GAAG,CAACI,cAAL,CAA2CC,IAAhE;AAEA,QAAMC,YAAY,GAAGC,MAAM,CAAU,KAAV,CAA3B;AACA,QAAMC,eAAe,GAAGD,MAAM,CAACR,KAAD,CAA9B;;AACA,MAAIO,YAAY,CAACG,OAAb,KAAyB,KAA7B,EAAoC;AAClCD,IAAAA,eAAe,CAACC,OAAhB,GAA0BV,KAA1B;AACD;;AACD,QAAMW,YAAY,GAAGF,eAAe,CAACC,OAArC;AAEAE,EAAAA,SAAS,CAAC,MAAoB;AAC5B,UAAMC,mBAAmB,GAAG,MAAY;AACtCN,MAAAA,YAAY,CAACG,OAAb,GAAuB,IAAvB;AACD,KAFD;;AAGAI,IAAAA,MAAM,CAACC,gBAAP,CAAwB,cAAxB,EAAwCF,mBAAxC;AAEA,WAAO,MAAY;AACjBC,MAAAA,MAAM,CAACE,mBAAP,CAA2B,cAA3B,EAA2CH,mBAA3C;AACD,KAFD;AAGD,GATQ,EASN,EATM,CAAT;AAWA,sBACE;AACE,IAAA,MAAM,EAAE,CAACb,KAAD,IAAUI,WAAV,IAAyBO,YAAY,KAAK,WADpD;AAEE,IAAA,SAAS,EAAC;AAFZ,KAIG,CAACX,KAAD,IAAUI,WAAV,GAAwB,IAAxB,gBACC,8CACE,oBAAC,CAAD;AAAG,IAAA,EAAE,EAAG,mBAAkBO,YAAuB;AAAjD,IADF,CALJ,CADF;AAYD;;;;"}
|
package/dist/index-node12.cjs.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const React = require('react');
|
|
6
|
-
const ReactAlpContext = require('react-alp-context');
|
|
7
|
-
const reactAlpTranslate = require('react-alp-translate');
|
|
8
|
-
|
|
9
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
|
|
10
|
-
|
|
11
|
-
const React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
12
|
-
const ReactAlpContext__default = /*#__PURE__*/_interopDefaultLegacy(ReactAlpContext);
|
|
13
|
-
|
|
14
|
-
function ConnectionState({
|
|
15
|
-
state
|
|
16
|
-
}) {
|
|
17
|
-
const ctx = React.useContext(ReactAlpContext__default);
|
|
18
|
-
const notLoggedIn = !ctx.sanitizedState.user;
|
|
19
|
-
const unloadingRef = React.useRef(false);
|
|
20
|
-
const currentStateRef = React.useRef(state);
|
|
21
|
-
|
|
22
|
-
if (unloadingRef.current === false) {
|
|
23
|
-
currentStateRef.current = state;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const currentState = currentStateRef.current;
|
|
27
|
-
React.useEffect(() => {
|
|
28
|
-
const beforeUnloadHandler = () => {
|
|
29
|
-
unloadingRef.current = true;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
window.addEventListener('beforeunload', beforeUnloadHandler);
|
|
33
|
-
return () => {
|
|
34
|
-
window.removeEventListener('beforeunload', beforeUnloadHandler);
|
|
35
|
-
};
|
|
36
|
-
}, []);
|
|
37
|
-
return /*#__PURE__*/React__default.createElement("div", {
|
|
38
|
-
hidden: !state || notLoggedIn || currentState === 'connected',
|
|
39
|
-
className: "alp-connection-state"
|
|
40
|
-
}, !state || notLoggedIn ? null : /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(reactAlpTranslate.T, {
|
|
41
|
-
id: `connectionState.${currentState}`
|
|
42
|
-
})));
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
exports.default = ConnectionState;
|
|
46
|
-
//# sourceMappingURL=index-node12.cjs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-node12.cjs.js","sources":["../src/index.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport React, { useContext, useEffect, useRef } from 'react';\nimport ReactAlpContext from 'react-alp-context';\nimport { T } from 'react-alp-translate';\nimport '../ConnectionState.global.scss';\n\ntype State = null | 'connecting' | 'connected' | 'disconnected';\n\ninterface ConnectionStateProps {\n state: State;\n}\n\nexport default function ConnectionState({\n state,\n}: ConnectionStateProps): ReactElement {\n const ctx = useContext(ReactAlpContext);\n const notLoggedIn = !(ctx.sanitizedState as { user?: unknown }).user;\n\n const unloadingRef = useRef<boolean>(false);\n const currentStateRef = useRef(state);\n if (unloadingRef.current === false) {\n currentStateRef.current = state;\n }\n const currentState = currentStateRef.current;\n\n useEffect((): (() => void) => {\n const beforeUnloadHandler = (): void => {\n unloadingRef.current = true;\n };\n window.addEventListener('beforeunload', beforeUnloadHandler);\n\n return (): void => {\n window.removeEventListener('beforeunload', beforeUnloadHandler);\n };\n }, []);\n\n return (\n <div\n hidden={!state || notLoggedIn || currentState === 'connected'}\n className=\"alp-connection-state\"\n >\n {!state || notLoggedIn ? null : (\n <div>\n <T id={`connectionState.${currentState as string}`} />\n </div>\n )}\n </div>\n );\n}\n"],"names":["ConnectionState","state","ctx","useContext","ReactAlpContext","notLoggedIn","sanitizedState","user","unloadingRef","useRef","currentStateRef","current","currentState","useEffect","beforeUnloadHandler","window","addEventListener","removeEventListener","React","T"],"mappings":";;;;;;;;;;;;;AAYe,SAASA,eAAT,CAAyB;AACtCC,EAAAA;AADsC,CAAzB,EAEwB;AACrC,QAAMC,GAAG,GAAGC,gBAAU,CAACC,wBAAD,CAAtB;AACA,QAAMC,WAAW,GAAG,CAAEH,GAAG,CAACI,cAAL,CAA2CC,IAAhE;AAEA,QAAMC,YAAY,GAAGC,YAAM,CAAU,KAAV,CAA3B;AACA,QAAMC,eAAe,GAAGD,YAAM,CAACR,KAAD,CAA9B;;AACA,MAAIO,YAAY,CAACG,OAAb,KAAyB,KAA7B,EAAoC;AAClCD,IAAAA,eAAe,CAACC,OAAhB,GAA0BV,KAA1B;AACD;;AACD,QAAMW,YAAY,GAAGF,eAAe,CAACC,OAArC;AAEAE,EAAAA,eAAS,CAAC,MAAoB;AAC5B,UAAMC,mBAAmB,GAAG,MAAY;AACtCN,MAAAA,YAAY,CAACG,OAAb,GAAuB,IAAvB;AACD,KAFD;;AAGAI,IAAAA,MAAM,CAACC,gBAAP,CAAwB,cAAxB,EAAwCF,mBAAxC;AAEA,WAAO,MAAY;AACjBC,MAAAA,MAAM,CAACE,mBAAP,CAA2B,cAA3B,EAA2CH,mBAA3C;AACD,KAFD;AAGD,GATQ,EASN,EATM,CAAT;AAWA,sBACEI;AACE,IAAA,MAAM,EAAE,CAACjB,KAAD,IAAUI,WAAV,IAAyBO,YAAY,KAAK,WADpD;AAEE,IAAA,SAAS,EAAC;AAFZ,KAIG,CAACX,KAAD,IAAUI,WAAV,GAAwB,IAAxB,gBACCa,uDACEA,6BAACC,mBAAD;AAAG,IAAA,EAAE,EAAG,mBAAkBP,YAAuB;AAAjD,IADF,CALJ,CADF;AAYD;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-node12.mjs","sources":["../src/index.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport React, { useContext, useEffect, useRef } from 'react';\nimport ReactAlpContext from 'react-alp-context';\nimport { T } from 'react-alp-translate';\nimport '../ConnectionState.global.scss';\n\ntype State = null | 'connecting' | 'connected' | 'disconnected';\n\ninterface ConnectionStateProps {\n state: State;\n}\n\nexport default function ConnectionState({\n state,\n}: ConnectionStateProps): ReactElement {\n const ctx = useContext(ReactAlpContext);\n const notLoggedIn = !(ctx.sanitizedState as { user?: unknown }).user;\n\n const unloadingRef = useRef<boolean>(false);\n const currentStateRef = useRef(state);\n if (unloadingRef.current === false) {\n currentStateRef.current = state;\n }\n const currentState = currentStateRef.current;\n\n useEffect((): (() => void) => {\n const beforeUnloadHandler = (): void => {\n unloadingRef.current = true;\n };\n window.addEventListener('beforeunload', beforeUnloadHandler);\n\n return (): void => {\n window.removeEventListener('beforeunload', beforeUnloadHandler);\n };\n }, []);\n\n return (\n <div\n hidden={!state || notLoggedIn || currentState === 'connected'}\n className=\"alp-connection-state\"\n >\n {!state || notLoggedIn ? null : (\n <div>\n <T id={`connectionState.${currentState as string}`} />\n </div>\n )}\n </div>\n );\n}\n"],"names":["ConnectionState","state","ctx","useContext","ReactAlpContext","notLoggedIn","sanitizedState","user","unloadingRef","useRef","currentStateRef","current","currentState","useEffect","beforeUnloadHandler","window","addEventListener","removeEventListener"],"mappings":";;;;AAYe,SAASA,eAAT,CAAyB;AACtCC,EAAAA;AADsC,CAAzB,EAEwB;AACrC,QAAMC,GAAG,GAAGC,UAAU,CAACC,eAAD,CAAtB;AACA,QAAMC,WAAW,GAAG,CAAEH,GAAG,CAACI,cAAL,CAA2CC,IAAhE;AAEA,QAAMC,YAAY,GAAGC,MAAM,CAAU,KAAV,CAA3B;AACA,QAAMC,eAAe,GAAGD,MAAM,CAACR,KAAD,CAA9B;;AACA,MAAIO,YAAY,CAACG,OAAb,KAAyB,KAA7B,EAAoC;AAClCD,IAAAA,eAAe,CAACC,OAAhB,GAA0BV,KAA1B;AACD;;AACD,QAAMW,YAAY,GAAGF,eAAe,CAACC,OAArC;AAEAE,EAAAA,SAAS,CAAC,MAAoB;AAC5B,UAAMC,mBAAmB,GAAG,MAAY;AACtCN,MAAAA,YAAY,CAACG,OAAb,GAAuB,IAAvB;AACD,KAFD;;AAGAI,IAAAA,MAAM,CAACC,gBAAP,CAAwB,cAAxB,EAAwCF,mBAAxC;AAEA,WAAO,MAAY;AACjBC,MAAAA,MAAM,CAACE,mBAAP,CAA2B,cAA3B,EAA2CH,mBAA3C;AACD,KAFD;AAGD,GATQ,EASN,EATM,CAAT;AAWA,sBACE;AACE,IAAA,MAAM,EAAE,CAACb,KAAD,IAAUI,WAAV,IAAyBO,YAAY,KAAK,WADpD;AAEE,IAAA,SAAS,EAAC;AAFZ,KAIG,CAACX,KAAD,IAAUI,WAAV,GAAwB,IAAxB,gBACC,8CACE,oBAAC,CAAD;AAAG,IAAA,EAAE,EAAG,mBAAkBO,YAAuB;AAAjD,IADF,CALJ,CADF;AAYD;;;;"}
|