@hook-sdk/template 0.4.2 → 0.5.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/index.cjs +4 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -278,6 +278,7 @@ type SubscriptionStatus = 'active' | 'trialing' | 'expired' | 'canceled' | 'past
|
|
|
278
278
|
declare function usePaywallState(): {
|
|
279
279
|
status: SubscriptionStatus;
|
|
280
280
|
daysLeftInTrial: number | null;
|
|
281
|
+
initialLoadComplete: boolean;
|
|
281
282
|
checkout: (args: {
|
|
282
283
|
cpf: string;
|
|
283
284
|
cycle?: "MONTHLY" | "YEARLY";
|
package/dist/index.d.ts
CHANGED
|
@@ -278,6 +278,7 @@ type SubscriptionStatus = 'active' | 'trialing' | 'expired' | 'canceled' | 'past
|
|
|
278
278
|
declare function usePaywallState(): {
|
|
279
279
|
status: SubscriptionStatus;
|
|
280
280
|
daysLeftInTrial: number | null;
|
|
281
|
+
initialLoadComplete: boolean;
|
|
281
282
|
checkout: (args: {
|
|
282
283
|
cpf: string;
|
|
283
284
|
cycle?: "MONTHLY" | "YEARLY";
|
package/dist/index.js
CHANGED
|
@@ -100,6 +100,7 @@ function usePaywallState() {
|
|
|
100
100
|
const [error, setError] = useState2(null);
|
|
101
101
|
const status = subscription.status();
|
|
102
102
|
const daysLeftInTrial = subscription.daysLeftInTrial();
|
|
103
|
+
const initialLoadComplete = subscription.initialLoadComplete;
|
|
103
104
|
const checkout = useCallback(
|
|
104
105
|
async (args) => {
|
|
105
106
|
setOpening(true);
|
|
@@ -125,7 +126,7 @@ function usePaywallState() {
|
|
|
125
126
|
setError(err);
|
|
126
127
|
}
|
|
127
128
|
}, [subscription]);
|
|
128
|
-
return { status, daysLeftInTrial, checkout, cancel, opening, error };
|
|
129
|
+
return { status, daysLeftInTrial, initialLoadComplete, checkout, cancel, opening, error };
|
|
129
130
|
}
|
|
130
131
|
|
|
131
132
|
// src/internal/SubscriptionGate.tsx
|
|
@@ -138,8 +139,9 @@ var BLOCKING = /* @__PURE__ */ new Set([
|
|
|
138
139
|
]);
|
|
139
140
|
function SubscriptionGate({ Paywall, children }) {
|
|
140
141
|
const { mode } = useTemplateConfig();
|
|
141
|
-
const { status } = usePaywallState();
|
|
142
|
+
const { status, initialLoadComplete } = usePaywallState();
|
|
142
143
|
if (mode === "free") return /* @__PURE__ */ jsx5(Fragment2, { children });
|
|
144
|
+
if (!initialLoadComplete && status === "none") return null;
|
|
143
145
|
if (BLOCKING.has(status)) return /* @__PURE__ */ jsx5(Paywall, {});
|
|
144
146
|
return /* @__PURE__ */ jsx5(Fragment2, { children });
|
|
145
147
|
}
|