@pollar/core 0.7.1 → 0.8.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/README.md +153 -26
- package/dist/adapters/expo-secure-store.js.map +1 -1
- package/dist/adapters/expo-secure-store.mjs.map +1 -1
- package/dist/adapters/react-native-appstate.d.mts +10 -0
- package/dist/adapters/react-native-appstate.d.ts +10 -0
- package/dist/adapters/react-native-appstate.js +38 -0
- package/dist/adapters/react-native-appstate.js.map +1 -0
- package/dist/adapters/react-native-appstate.mjs +36 -0
- package/dist/adapters/react-native-appstate.mjs.map +1 -0
- package/dist/adapters/react-native-keychain.js.map +1 -1
- package/dist/adapters/react-native-keychain.mjs.map +1 -1
- package/dist/index.d.mts +1352 -129
- package/dist/index.d.ts +1352 -129
- package/dist/index.js +761 -140
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +761 -140
- package/dist/index.mjs.map +1 -1
- package/dist/index.rn.d.mts +2 -1
- package/dist/index.rn.d.ts +2 -1
- package/dist/index.rn.js +761 -140
- package/dist/index.rn.js.map +1 -1
- package/dist/index.rn.mjs +761 -140
- package/dist/index.rn.mjs.map +1 -1
- package/dist/types-84G_htcn.d.mts +38 -0
- package/dist/types-84G_htcn.d.ts +38 -0
- package/package.json +16 -3
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pluggable "is the user looking at this app right now?" signal.
|
|
3
|
+
*
|
|
4
|
+
* Used by the silent-refresh scheduler so token renewals are skipped while
|
|
5
|
+
* the tab is hidden / the app is backgrounded — both saves network and
|
|
6
|
+
* works around aggressive `setTimeout` throttling that web browsers and RN
|
|
7
|
+
* apply to non-foreground contexts.
|
|
8
|
+
*
|
|
9
|
+
* Default web implementation listens to `visibilitychange` plus
|
|
10
|
+
* `pageshow`/`pagehide` (covers BFCache on iOS) and `focus`/`blur` (covers
|
|
11
|
+
* the cases where `visibilitychange` lags). Default for non-browser
|
|
12
|
+
* environments is a noop that always reports "visible".
|
|
13
|
+
*
|
|
14
|
+
* TODO(@pollar/react-native): when the dedicated RN package ships, it will
|
|
15
|
+
* export an `AppState`-backed provider. Until then, RN consumers can wire
|
|
16
|
+
* one inline:
|
|
17
|
+
*
|
|
18
|
+
* import { AppState } from 'react-native';
|
|
19
|
+
* const rnVisibility = {
|
|
20
|
+
* isVisible: () => AppState.currentState === 'active',
|
|
21
|
+
* onChange: (cb) => {
|
|
22
|
+
* const sub = AppState.addEventListener('change', (s) => cb(s === 'active'));
|
|
23
|
+
* return () => sub.remove();
|
|
24
|
+
* },
|
|
25
|
+
* };
|
|
26
|
+
* new PollarClient({ apiKey, visibilityProvider: rnVisibility });
|
|
27
|
+
*/
|
|
28
|
+
interface VisibilityProvider {
|
|
29
|
+
isVisible(): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Subscribe to visibility transitions. The callback receives the new
|
|
32
|
+
* visibility state (`true` = visible). Returns an unsubscribe function
|
|
33
|
+
* that must detach every listener registered by this call.
|
|
34
|
+
*/
|
|
35
|
+
onChange(cb: (visible: boolean) => void): () => void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type { VisibilityProvider as V };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pluggable "is the user looking at this app right now?" signal.
|
|
3
|
+
*
|
|
4
|
+
* Used by the silent-refresh scheduler so token renewals are skipped while
|
|
5
|
+
* the tab is hidden / the app is backgrounded — both saves network and
|
|
6
|
+
* works around aggressive `setTimeout` throttling that web browsers and RN
|
|
7
|
+
* apply to non-foreground contexts.
|
|
8
|
+
*
|
|
9
|
+
* Default web implementation listens to `visibilitychange` plus
|
|
10
|
+
* `pageshow`/`pagehide` (covers BFCache on iOS) and `focus`/`blur` (covers
|
|
11
|
+
* the cases where `visibilitychange` lags). Default for non-browser
|
|
12
|
+
* environments is a noop that always reports "visible".
|
|
13
|
+
*
|
|
14
|
+
* TODO(@pollar/react-native): when the dedicated RN package ships, it will
|
|
15
|
+
* export an `AppState`-backed provider. Until then, RN consumers can wire
|
|
16
|
+
* one inline:
|
|
17
|
+
*
|
|
18
|
+
* import { AppState } from 'react-native';
|
|
19
|
+
* const rnVisibility = {
|
|
20
|
+
* isVisible: () => AppState.currentState === 'active',
|
|
21
|
+
* onChange: (cb) => {
|
|
22
|
+
* const sub = AppState.addEventListener('change', (s) => cb(s === 'active'));
|
|
23
|
+
* return () => sub.remove();
|
|
24
|
+
* },
|
|
25
|
+
* };
|
|
26
|
+
* new PollarClient({ apiKey, visibilityProvider: rnVisibility });
|
|
27
|
+
*/
|
|
28
|
+
interface VisibilityProvider {
|
|
29
|
+
isVisible(): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Subscribe to visibility transitions. The callback receives the new
|
|
32
|
+
* visibility state (`true` = visible). Returns an unsubscribe function
|
|
33
|
+
* that must detach every listener registered by this call.
|
|
34
|
+
*/
|
|
35
|
+
onChange(cb: (visible: boolean) => void): () => void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type { VisibilityProvider as V };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pollar/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "Core authentication functions for Pollar services",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -46,6 +46,16 @@
|
|
|
46
46
|
"types": "./dist/adapters/react-native-keychain.d.ts",
|
|
47
47
|
"default": "./dist/adapters/react-native-keychain.js"
|
|
48
48
|
}
|
|
49
|
+
},
|
|
50
|
+
"./adapters/react-native-appstate": {
|
|
51
|
+
"import": {
|
|
52
|
+
"types": "./dist/adapters/react-native-appstate.d.mts",
|
|
53
|
+
"default": "./dist/adapters/react-native-appstate.mjs"
|
|
54
|
+
},
|
|
55
|
+
"require": {
|
|
56
|
+
"types": "./dist/adapters/react-native-appstate.d.ts",
|
|
57
|
+
"default": "./dist/adapters/react-native-appstate.js"
|
|
58
|
+
}
|
|
49
59
|
}
|
|
50
60
|
},
|
|
51
61
|
"files": [
|
|
@@ -60,15 +70,18 @@
|
|
|
60
70
|
"scripts": {
|
|
61
71
|
"build": "tsup",
|
|
62
72
|
"dev": "tsup --watch",
|
|
63
|
-
"lint": "tsc --noEmit",
|
|
73
|
+
"lint": "tsc --noEmit && eslint src",
|
|
64
74
|
"clean": "rm -rf dist"
|
|
65
75
|
},
|
|
66
76
|
"engines": {
|
|
67
77
|
"node": ">=20"
|
|
68
78
|
},
|
|
69
79
|
"devDependencies": {
|
|
80
|
+
"@eslint/js": "^9.39.4",
|
|
81
|
+
"eslint": "^9.39.4",
|
|
70
82
|
"tsup": "^8.3.0",
|
|
71
|
-
"typescript": "^5.7.0"
|
|
83
|
+
"typescript": "^5.7.0",
|
|
84
|
+
"typescript-eslint": "^8.58.1"
|
|
72
85
|
},
|
|
73
86
|
"dependencies": {
|
|
74
87
|
"@noble/curves": "~1.9.7",
|