@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.cjs
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/react.ts
|
|
21
21
|
var react_exports = {};
|
|
22
22
|
__export(react_exports, {
|
|
23
|
+
CrossdeckProvider: () => CrossdeckProvider,
|
|
23
24
|
useEntitlement: () => useEntitlement,
|
|
24
25
|
useEntitlements: () => useEntitlements
|
|
25
26
|
});
|
|
@@ -3590,6 +3591,39 @@ function installUnloadFlush(onUnload) {
|
|
|
3590
3591
|
}
|
|
3591
3592
|
|
|
3592
3593
|
// src/react.ts
|
|
3594
|
+
var _moduleInitDone = false;
|
|
3595
|
+
function CrossdeckProvider(props) {
|
|
3596
|
+
const { userId, children, ...initOptions } = props;
|
|
3597
|
+
const lastUserIdRef = (0, import_react.useRef)(void 0);
|
|
3598
|
+
(0, import_react.useEffect)(() => {
|
|
3599
|
+
if (_moduleInitDone) return;
|
|
3600
|
+
try {
|
|
3601
|
+
Crossdeck.init(initOptions);
|
|
3602
|
+
_moduleInitDone = true;
|
|
3603
|
+
} catch (err) {
|
|
3604
|
+
if (typeof console !== "undefined") {
|
|
3605
|
+
console.error("[CrossdeckProvider] init failed:", err);
|
|
3606
|
+
}
|
|
3607
|
+
}
|
|
3608
|
+
}, []);
|
|
3609
|
+
(0, import_react.useEffect)(() => {
|
|
3610
|
+
if (!_moduleInitDone) return;
|
|
3611
|
+
if (lastUserIdRef.current === userId) return;
|
|
3612
|
+
lastUserIdRef.current = userId;
|
|
3613
|
+
try {
|
|
3614
|
+
if (userId) {
|
|
3615
|
+
void Crossdeck.identify(userId);
|
|
3616
|
+
} else {
|
|
3617
|
+
Crossdeck.reset();
|
|
3618
|
+
}
|
|
3619
|
+
} catch (err) {
|
|
3620
|
+
if (typeof console !== "undefined") {
|
|
3621
|
+
console.error("[CrossdeckProvider] identity sync failed:", err);
|
|
3622
|
+
}
|
|
3623
|
+
}
|
|
3624
|
+
}, [userId]);
|
|
3625
|
+
return children;
|
|
3626
|
+
}
|
|
3593
3627
|
function useEntitlement(key) {
|
|
3594
3628
|
const [isEntitled, setIsEntitled] = (0, import_react.useState)(() => safeIsEntitled(key));
|
|
3595
3629
|
(0, import_react.useEffect)(() => {
|
|
@@ -3640,6 +3674,7 @@ function safeListKeys() {
|
|
|
3640
3674
|
}
|
|
3641
3675
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3642
3676
|
0 && (module.exports = {
|
|
3677
|
+
CrossdeckProvider,
|
|
3643
3678
|
useEntitlement,
|
|
3644
3679
|
useEntitlements
|
|
3645
3680
|
});
|