@hook-sdk/template 0.7.3 → 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/dist/index.cjs +23 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +68 -47
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -278,14 +278,34 @@ function SubscriptionGate({ Paywall, children }) {
|
|
|
278
278
|
var import_react4 = require("react");
|
|
279
279
|
var import_sdk3 = require("@hook-sdk/sdk");
|
|
280
280
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
281
|
+
var SAFETY_TIMEOUT_MS = 3e3;
|
|
281
282
|
function PersistedKeysPrefetch({ children }) {
|
|
282
283
|
const { appData } = (0, import_sdk3.useHook)();
|
|
283
284
|
const config = useTemplateConfig();
|
|
285
|
+
const hasKeys = !!config.persistedKeys && config.persistedKeys.length > 0;
|
|
286
|
+
const [ready, setReady] = (0, import_react4.useState)(!hasKeys);
|
|
284
287
|
(0, import_react4.useEffect)(() => {
|
|
285
288
|
const keys = config.persistedKeys;
|
|
286
|
-
if (!keys || keys.length === 0)
|
|
289
|
+
if (!keys || keys.length === 0) {
|
|
290
|
+
setReady(true);
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
let cancelled = false;
|
|
287
294
|
appData.cache.startPrefetch(keys, (ks) => appData.bulkRead(ks));
|
|
295
|
+
void appData.cache.waitForPrimed(SAFETY_TIMEOUT_MS).then((result) => {
|
|
296
|
+
if (cancelled) return;
|
|
297
|
+
if (result === "timeout") {
|
|
298
|
+
console.warn(
|
|
299
|
+
`[@hook-sdk/template] PersistedKeysPrefetch: bulk-read n\xE3o completou em ${SAFETY_TIMEOUT_MS}ms. Liberando render mesmo assim \u2014 usePersistedState pode expor defaultValue at\xE9 o fetch terminar (G77).`
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
setReady(true);
|
|
303
|
+
});
|
|
304
|
+
return () => {
|
|
305
|
+
cancelled = true;
|
|
306
|
+
};
|
|
288
307
|
}, [appData, config.persistedKeys]);
|
|
308
|
+
if (!ready) return null;
|
|
289
309
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children });
|
|
290
310
|
}
|
|
291
311
|
|
|
@@ -1529,9 +1549,10 @@ function InstallGate({ children }) {
|
|
|
1529
1549
|
if (!enabled) return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, { children });
|
|
1530
1550
|
if (installState.isInstalled) return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, { children });
|
|
1531
1551
|
if (installState.variant === "desktop") {
|
|
1552
|
+
const showBanner = !installState.isDismissedSession && !installState.isDismissedPermanent;
|
|
1532
1553
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
1533
1554
|
children,
|
|
1534
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(DesktopVariant, { state: installState, actions: installState })
|
|
1555
|
+
showBanner && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(DesktopVariant, { state: installState, actions: installState })
|
|
1535
1556
|
] });
|
|
1536
1557
|
}
|
|
1537
1558
|
if (!shouldBlock) return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, { children });
|