@cross-deck/web 1.5.1 → 1.5.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/dist/contracts.json +133 -11
- package/dist/crossdeck.umd.min.js +2 -2
- package/dist/crossdeck.umd.min.js.map +1 -1
- package/dist/error-codes.json +1 -1
- package/dist/index.cjs +1081 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +51 -16
- package/dist/index.d.ts +51 -16
- package/dist/index.mjs +1081 -25
- package/dist/index.mjs.map +1 -1
- package/dist/react.cjs +950 -16
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.mjs +950 -16
- package/dist/react.mjs.map +1 -1
- package/dist/{types-Bu3jbmdq.d.ts → types-B9sxUuKh.d.mts} +71 -0
- package/dist/{types-Bu3jbmdq.d 2.mts → types-B9sxUuKh.d.ts} +71 -0
- package/dist/vue.cjs +950 -16
- package/dist/vue.cjs.map +1 -1
- package/dist/vue.mjs +950 -16
- package/dist/vue.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/contracts 2.json +0 -378
- package/dist/crossdeck.umd.min 2.js +0 -3
- package/dist/crossdeck.umd.min.js 2.map +0 -1
- package/dist/error-codes 2.json +0 -196
- package/dist/index 2.cjs +0 -4778
- package/dist/index 2.mjs +0 -4742
- package/dist/index.cjs 2.map +0 -1
- package/dist/index.d 2.mts +0 -938
- package/dist/index.d 2.ts +0 -938
- package/dist/index.mjs 2.map +0 -1
- package/dist/react 2.cjs +0 -4220
- package/dist/react 2.mjs +0 -4193
- package/dist/react.cjs 2.map +0 -1
- package/dist/react.d 2.mts +0 -91
- package/dist/react.d 2.ts +0 -91
- package/dist/react.mjs 2.map +0 -1
- package/dist/types-Bu3jbmdq.d 2.ts +0 -314
- package/dist/types-Bu3jbmdq.d.mts +0 -314
- package/dist/vue 2.cjs +0 -4185
- package/dist/vue 2.mjs +0 -4159
- package/dist/vue.cjs 2.map +0 -1
- package/dist/vue.d 2.mts +0 -37
- package/dist/vue.d 2.ts +0 -37
- package/dist/vue.mjs 2.map +0 -1
package/dist/react.d 2.mts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { C as CrossdeckOptions } from './types-Bu3jbmdq.mjs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @cross-deck/web/react — React hooks for the Crossdeck SDK.
|
|
6
|
-
*
|
|
7
|
-
* Why this exists: `Crossdeck.isEntitled("pro")` is a synchronous cache
|
|
8
|
-
* read, but the cache populates asynchronously after `getEntitlements()`
|
|
9
|
-
* lands. React has no way to know the cache changed, so a component
|
|
10
|
-
* that calls `isEntitled` directly in a render path would show the
|
|
11
|
-
* empty-cache result forever (until something else triggered a re-render).
|
|
12
|
-
*
|
|
13
|
-
* The `useEntitlement` hook below ties cache state to React state via
|
|
14
|
-
* `onEntitlementsChange`, so the component re-renders the moment the
|
|
15
|
-
* answer changes. After the first render, every subsequent check is a
|
|
16
|
-
* sync cache hit — exactly the "microsecond entitlement check" the
|
|
17
|
-
* SDK promises.
|
|
18
|
-
*
|
|
19
|
-
* Side effect: importing this module pulls in `react` as a peer
|
|
20
|
-
* dependency. Consumers who don't use React shouldn't import it.
|
|
21
|
-
*
|
|
22
|
-
* SSR safety: `useEffect` is a no-op during server-side rendering, and
|
|
23
|
-
* the initial state is conservative (`false` until proven otherwise),
|
|
24
|
-
* so server output never claims a non-existent entitlement. The hook
|
|
25
|
-
* hydrates correctly on the client.
|
|
26
|
-
*
|
|
27
|
-
* NorthStar §11.4 (reactive bindings): every SDK ships first-class
|
|
28
|
-
* framework bindings so the canonical snippet stays one line. Web =>
|
|
29
|
-
* React hook here. iOS => `@Observable` SwiftUI wrapper (when iOS SDK
|
|
30
|
-
* ships). Android => Compose `State<Boolean>` wrapper (when Android
|
|
31
|
-
* SDK ships).
|
|
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;
|
|
53
|
-
/**
|
|
54
|
-
* Subscribe a React component to a single entitlement key.
|
|
55
|
-
*
|
|
56
|
-
* The hook returns the current `isEntitled(key)` value AND keeps it in
|
|
57
|
-
* sync with the cache. When `getEntitlements()` lands, when a purchase
|
|
58
|
-
* adds an entitlement, or when `reset()` is called on logout, every
|
|
59
|
-
* component using this hook re-renders to reflect the change.
|
|
60
|
-
*
|
|
61
|
-
* Usage:
|
|
62
|
-
*
|
|
63
|
-
* import { useEntitlement } from "@cross-deck/web/react";
|
|
64
|
-
*
|
|
65
|
-
* function ProBadge() {
|
|
66
|
-
* const isPro = useEntitlement("pro");
|
|
67
|
-
* return isPro ? <span className="badge">Pro</span> : null;
|
|
68
|
-
* }
|
|
69
|
-
*
|
|
70
|
-
* Note that the hook does NOT call `getEntitlements()` itself — that's
|
|
71
|
-
* a one-time boot warm-up the consumer is expected to trigger after
|
|
72
|
-
* `Crossdeck.init()` (typically inside a top-level effect in their
|
|
73
|
-
* Providers wrapper). Once warmed, every component using this hook
|
|
74
|
-
* gets the answer for free.
|
|
75
|
-
*
|
|
76
|
-
* Pre-init: returns `false`. Calling Crossdeck.init() later doesn't
|
|
77
|
-
* automatically refresh existing hook instances — but as soon as
|
|
78
|
-
* something mutates the cache (i.e. after a successful
|
|
79
|
-
* getEntitlements() call on the new SDK instance), the hook fires.
|
|
80
|
-
*/
|
|
81
|
-
declare function useEntitlement(key: string): boolean;
|
|
82
|
-
/**
|
|
83
|
-
* Subscribe to the full entitlement list. Returns an array of active
|
|
84
|
-
* entitlement keys, kept in sync with the cache. Useful for iterating
|
|
85
|
-
* (e.g. rendering a list of unlocked features in a settings page).
|
|
86
|
-
*
|
|
87
|
-
* Same pre-init / SSR semantics as `useEntitlement`.
|
|
88
|
-
*/
|
|
89
|
-
declare function useEntitlements(): readonly string[];
|
|
90
|
-
|
|
91
|
-
export { CrossdeckProvider, useEntitlement, useEntitlements };
|
package/dist/react.d 2.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { C as CrossdeckOptions } from './types-Bu3jbmdq.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @cross-deck/web/react — React hooks for the Crossdeck SDK.
|
|
6
|
-
*
|
|
7
|
-
* Why this exists: `Crossdeck.isEntitled("pro")` is a synchronous cache
|
|
8
|
-
* read, but the cache populates asynchronously after `getEntitlements()`
|
|
9
|
-
* lands. React has no way to know the cache changed, so a component
|
|
10
|
-
* that calls `isEntitled` directly in a render path would show the
|
|
11
|
-
* empty-cache result forever (until something else triggered a re-render).
|
|
12
|
-
*
|
|
13
|
-
* The `useEntitlement` hook below ties cache state to React state via
|
|
14
|
-
* `onEntitlementsChange`, so the component re-renders the moment the
|
|
15
|
-
* answer changes. After the first render, every subsequent check is a
|
|
16
|
-
* sync cache hit — exactly the "microsecond entitlement check" the
|
|
17
|
-
* SDK promises.
|
|
18
|
-
*
|
|
19
|
-
* Side effect: importing this module pulls in `react` as a peer
|
|
20
|
-
* dependency. Consumers who don't use React shouldn't import it.
|
|
21
|
-
*
|
|
22
|
-
* SSR safety: `useEffect` is a no-op during server-side rendering, and
|
|
23
|
-
* the initial state is conservative (`false` until proven otherwise),
|
|
24
|
-
* so server output never claims a non-existent entitlement. The hook
|
|
25
|
-
* hydrates correctly on the client.
|
|
26
|
-
*
|
|
27
|
-
* NorthStar §11.4 (reactive bindings): every SDK ships first-class
|
|
28
|
-
* framework bindings so the canonical snippet stays one line. Web =>
|
|
29
|
-
* React hook here. iOS => `@Observable` SwiftUI wrapper (when iOS SDK
|
|
30
|
-
* ships). Android => Compose `State<Boolean>` wrapper (when Android
|
|
31
|
-
* SDK ships).
|
|
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;
|
|
53
|
-
/**
|
|
54
|
-
* Subscribe a React component to a single entitlement key.
|
|
55
|
-
*
|
|
56
|
-
* The hook returns the current `isEntitled(key)` value AND keeps it in
|
|
57
|
-
* sync with the cache. When `getEntitlements()` lands, when a purchase
|
|
58
|
-
* adds an entitlement, or when `reset()` is called on logout, every
|
|
59
|
-
* component using this hook re-renders to reflect the change.
|
|
60
|
-
*
|
|
61
|
-
* Usage:
|
|
62
|
-
*
|
|
63
|
-
* import { useEntitlement } from "@cross-deck/web/react";
|
|
64
|
-
*
|
|
65
|
-
* function ProBadge() {
|
|
66
|
-
* const isPro = useEntitlement("pro");
|
|
67
|
-
* return isPro ? <span className="badge">Pro</span> : null;
|
|
68
|
-
* }
|
|
69
|
-
*
|
|
70
|
-
* Note that the hook does NOT call `getEntitlements()` itself — that's
|
|
71
|
-
* a one-time boot warm-up the consumer is expected to trigger after
|
|
72
|
-
* `Crossdeck.init()` (typically inside a top-level effect in their
|
|
73
|
-
* Providers wrapper). Once warmed, every component using this hook
|
|
74
|
-
* gets the answer for free.
|
|
75
|
-
*
|
|
76
|
-
* Pre-init: returns `false`. Calling Crossdeck.init() later doesn't
|
|
77
|
-
* automatically refresh existing hook instances — but as soon as
|
|
78
|
-
* something mutates the cache (i.e. after a successful
|
|
79
|
-
* getEntitlements() call on the new SDK instance), the hook fires.
|
|
80
|
-
*/
|
|
81
|
-
declare function useEntitlement(key: string): boolean;
|
|
82
|
-
/**
|
|
83
|
-
* Subscribe to the full entitlement list. Returns an array of active
|
|
84
|
-
* entitlement keys, kept in sync with the cache. Useful for iterating
|
|
85
|
-
* (e.g. rendering a list of unlocked features in a settings page).
|
|
86
|
-
*
|
|
87
|
-
* Same pre-init / SSR semantics as `useEntitlement`.
|
|
88
|
-
*/
|
|
89
|
-
declare function useEntitlements(): readonly string[];
|
|
90
|
-
|
|
91
|
-
export { CrossdeckProvider, useEntitlement, useEntitlements };
|