@cross-deck/web 1.1.0 → 1.2.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.
- package/dist/error-codes.json +1 -1
- package/dist/index.d.mts +3 -309
- package/dist/index.d.ts +3 -309
- package/dist/react.cjs +35 -0
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.mts +24 -1
- package/dist/react.d.ts +24 -1
- package/dist/react.mjs +35 -1
- package/dist/react.mjs.map +1 -1
- package/dist/types-BzoKor4z.d.mts +310 -0
- package/dist/types-BzoKor4z.d.ts +310 -0
- package/package.json +1 -1
package/dist/react.d.mts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { C as CrossdeckOptions } from './types-BzoKor4z.mjs';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* @cross-deck/web/react — React hooks for the Crossdeck SDK.
|
|
3
6
|
*
|
|
@@ -27,6 +30,26 @@
|
|
|
27
30
|
* ships). Android => Compose `State<Boolean>` wrapper (when Android
|
|
28
31
|
* SDK ships).
|
|
29
32
|
*/
|
|
33
|
+
|
|
34
|
+
interface CrossdeckProviderProps extends Omit<CrossdeckOptions, "userId"> {
|
|
35
|
+
/**
|
|
36
|
+
* Optional. When defined, the provider calls Crossdeck.identify(userId)
|
|
37
|
+
* after init and on every change. When the prop flips back to undefined
|
|
38
|
+
* (logout), the provider calls Crossdeck.reset().
|
|
39
|
+
*
|
|
40
|
+
* Pass your auth library's stable user id directly:
|
|
41
|
+
* <CrossdeckProvider userId={session?.user?.id} … /> // NextAuth
|
|
42
|
+
* <CrossdeckProvider userId={user?.uid} … /> // Firebase
|
|
43
|
+
* <CrossdeckProvider userId={supabase.auth.user()?.id} … /> // Supabase
|
|
44
|
+
*
|
|
45
|
+
* Anonymous (pre-login) traffic stays anonymous until userId becomes
|
|
46
|
+
* defined — the SDK's anonymousId follows the same user record once
|
|
47
|
+
* identify lands, so attribution survives sign-up.
|
|
48
|
+
*/
|
|
49
|
+
userId?: string | null | undefined;
|
|
50
|
+
children: ReactNode;
|
|
51
|
+
}
|
|
52
|
+
declare function CrossdeckProvider(props: CrossdeckProviderProps): ReactNode;
|
|
30
53
|
/**
|
|
31
54
|
* Subscribe a React component to a single entitlement key.
|
|
32
55
|
*
|
|
@@ -65,4 +88,4 @@ declare function useEntitlement(key: string): boolean;
|
|
|
65
88
|
*/
|
|
66
89
|
declare function useEntitlements(): readonly string[];
|
|
67
90
|
|
|
68
|
-
export { useEntitlement, useEntitlements };
|
|
91
|
+
export { CrossdeckProvider, useEntitlement, useEntitlements };
|
package/dist/react.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { C as CrossdeckOptions } from './types-BzoKor4z.js';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* @cross-deck/web/react — React hooks for the Crossdeck SDK.
|
|
3
6
|
*
|
|
@@ -27,6 +30,26 @@
|
|
|
27
30
|
* ships). Android => Compose `State<Boolean>` wrapper (when Android
|
|
28
31
|
* SDK ships).
|
|
29
32
|
*/
|
|
33
|
+
|
|
34
|
+
interface CrossdeckProviderProps extends Omit<CrossdeckOptions, "userId"> {
|
|
35
|
+
/**
|
|
36
|
+
* Optional. When defined, the provider calls Crossdeck.identify(userId)
|
|
37
|
+
* after init and on every change. When the prop flips back to undefined
|
|
38
|
+
* (logout), the provider calls Crossdeck.reset().
|
|
39
|
+
*
|
|
40
|
+
* Pass your auth library's stable user id directly:
|
|
41
|
+
* <CrossdeckProvider userId={session?.user?.id} … /> // NextAuth
|
|
42
|
+
* <CrossdeckProvider userId={user?.uid} … /> // Firebase
|
|
43
|
+
* <CrossdeckProvider userId={supabase.auth.user()?.id} … /> // Supabase
|
|
44
|
+
*
|
|
45
|
+
* Anonymous (pre-login) traffic stays anonymous until userId becomes
|
|
46
|
+
* defined — the SDK's anonymousId follows the same user record once
|
|
47
|
+
* identify lands, so attribution survives sign-up.
|
|
48
|
+
*/
|
|
49
|
+
userId?: string | null | undefined;
|
|
50
|
+
children: ReactNode;
|
|
51
|
+
}
|
|
52
|
+
declare function CrossdeckProvider(props: CrossdeckProviderProps): ReactNode;
|
|
30
53
|
/**
|
|
31
54
|
* Subscribe a React component to a single entitlement key.
|
|
32
55
|
*
|
|
@@ -65,4 +88,4 @@ declare function useEntitlement(key: string): boolean;
|
|
|
65
88
|
*/
|
|
66
89
|
declare function useEntitlements(): readonly string[];
|
|
67
90
|
|
|
68
|
-
export { useEntitlement, useEntitlements };
|
|
91
|
+
export { CrossdeckProvider, useEntitlement, useEntitlements };
|
package/dist/react.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/react.ts
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
3
|
|
|
4
4
|
// src/errors.ts
|
|
5
5
|
var CrossdeckError = class _CrossdeckError extends Error {
|
|
@@ -3565,6 +3565,39 @@ function installUnloadFlush(onUnload) {
|
|
|
3565
3565
|
}
|
|
3566
3566
|
|
|
3567
3567
|
// src/react.ts
|
|
3568
|
+
var _moduleInitDone = false;
|
|
3569
|
+
function CrossdeckProvider(props) {
|
|
3570
|
+
const { userId, children, ...initOptions } = props;
|
|
3571
|
+
const lastUserIdRef = useRef(void 0);
|
|
3572
|
+
useEffect(() => {
|
|
3573
|
+
if (_moduleInitDone) return;
|
|
3574
|
+
try {
|
|
3575
|
+
Crossdeck.init(initOptions);
|
|
3576
|
+
_moduleInitDone = true;
|
|
3577
|
+
} catch (err) {
|
|
3578
|
+
if (typeof console !== "undefined") {
|
|
3579
|
+
console.error("[CrossdeckProvider] init failed:", err);
|
|
3580
|
+
}
|
|
3581
|
+
}
|
|
3582
|
+
}, []);
|
|
3583
|
+
useEffect(() => {
|
|
3584
|
+
if (!_moduleInitDone) return;
|
|
3585
|
+
if (lastUserIdRef.current === userId) return;
|
|
3586
|
+
lastUserIdRef.current = userId;
|
|
3587
|
+
try {
|
|
3588
|
+
if (userId) {
|
|
3589
|
+
void Crossdeck.identify(userId);
|
|
3590
|
+
} else {
|
|
3591
|
+
Crossdeck.reset();
|
|
3592
|
+
}
|
|
3593
|
+
} catch (err) {
|
|
3594
|
+
if (typeof console !== "undefined") {
|
|
3595
|
+
console.error("[CrossdeckProvider] identity sync failed:", err);
|
|
3596
|
+
}
|
|
3597
|
+
}
|
|
3598
|
+
}, [userId]);
|
|
3599
|
+
return children;
|
|
3600
|
+
}
|
|
3568
3601
|
function useEntitlement(key) {
|
|
3569
3602
|
const [isEntitled, setIsEntitled] = useState(() => safeIsEntitled(key));
|
|
3570
3603
|
useEffect(() => {
|
|
@@ -3614,6 +3647,7 @@ function safeListKeys() {
|
|
|
3614
3647
|
}
|
|
3615
3648
|
}
|
|
3616
3649
|
export {
|
|
3650
|
+
CrossdeckProvider,
|
|
3617
3651
|
useEntitlement,
|
|
3618
3652
|
useEntitlements
|
|
3619
3653
|
};
|