@wireai/activation 0.14.0 → 0.14.2

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.mjs CHANGED
@@ -3807,15 +3807,19 @@ var readSettledPermissions = (raw, sessionId) => {
3807
3807
  return [];
3808
3808
  }
3809
3809
  };
3810
- var loadSettledPermissions = async (storage, key, sessionId) => {
3810
+ var loadSettledPermissionsOutcome = async (storage, key, sessionId) => {
3811
3811
  try {
3812
3812
  const raw = await withTimeout(storage.getItem(key), READ_TIMEOUT_MS);
3813
- if (raw === READ_TIMED_OUT) return [];
3814
- return readSettledPermissions(raw, sessionId);
3813
+ if (raw === READ_TIMED_OUT) return { status: "unknown" };
3814
+ return { status: "read", ids: readSettledPermissions(raw, sessionId) };
3815
3815
  } catch {
3816
- return [];
3816
+ return { status: "unknown" };
3817
3817
  }
3818
3818
  };
3819
+ var loadSettledPermissions = async (storage, key, sessionId) => {
3820
+ const outcome = await loadSettledPermissionsOutcome(storage, key, sessionId);
3821
+ return outcome.status === "read" ? outcome.ids : [];
3822
+ };
3819
3823
  var saveSettledPermissions = (storage, key, sessionId, ids) => {
3820
3824
  try {
3821
3825
  const record = { sessionId, ids: [...ids] };
@@ -3970,16 +3974,33 @@ var WireOnboarding = ({
3970
3974
  const sessionId = (_c = session == null ? void 0 : session.id) != null ? _c : "";
3971
3975
  const wantsPermissionMemory = Boolean(storage) && ((_d = permissionScreens == null ? void 0 : permissionScreens.length) != null ? _d : 0) > 0;
3972
3976
  const [settledPermissions, setSettledPermissions] = useState(void 0);
3977
+ const [permissionMemoryUnreadable, setPermissionMemoryUnreadable] = useState(false);
3973
3978
  useEffect(() => {
3974
- if (!wantsPermissionMemory || !storage || !sessionId || settledPermissions !== void 0) return;
3979
+ if (!wantsPermissionMemory || !storage || !sessionId) return;
3980
+ if (settledPermissions !== void 0 || permissionMemoryUnreadable) return;
3975
3981
  let cancelled = false;
3976
- void loadSettledPermissions(storage, permissionsKey, sessionId).then((ids) => {
3977
- if (!cancelled) setSettledPermissions(ids);
3982
+ void loadSettledPermissionsOutcome(storage, permissionsKey, sessionId).then((outcome) => {
3983
+ if (cancelled) return;
3984
+ if (outcome.status === "read") {
3985
+ setSettledPermissions(outcome.ids);
3986
+ return;
3987
+ }
3988
+ setPermissionMemoryUnreadable(true);
3989
+ warnInDev(
3990
+ "[wireai] the permission-screen memory could not be read (the storage adapter timed out or threw), so permission screens are suppressed for this session rather than re-asking a permission the OS grants once. Check the `storage` adapter passed to WireOnboarding."
3991
+ );
3978
3992
  });
3979
3993
  return () => {
3980
3994
  cancelled = true;
3981
3995
  };
3982
- }, [wantsPermissionMemory, storage, permissionsKey, sessionId, settledPermissions]);
3996
+ }, [
3997
+ wantsPermissionMemory,
3998
+ storage,
3999
+ permissionsKey,
4000
+ sessionId,
4001
+ settledPermissions,
4002
+ permissionMemoryUnreadable
4003
+ ]);
3983
4004
  const settledPermissionsRef = useRef(void 0);
3984
4005
  settledPermissionsRef.current = settledPermissions;
3985
4006
  const handlePermissionSettled = useCallback(