@wireai/activation 0.14.0 → 0.14.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.d.mts CHANGED
@@ -1979,7 +1979,13 @@ declare const permissionStorageKey: (appId: string) => string;
1979
1979
  * because re-showing a screen is a far cheaper failure than trusting another session's answers.
1980
1980
  */
1981
1981
  declare const readSettledPermissions: (raw: string | null | undefined, sessionId: string) => string[];
1982
- /** Read the settled ids for `sessionId`. Never throws, never hangs past the shared read ceiling. */
1982
+ /**
1983
+ * Read the settled ids for `sessionId`, collapsing "the store did not answer" to `[]`.
1984
+ *
1985
+ * Kept as the module's simple reader for callers that have no way to act on the difference. The
1986
+ * one caller that CAN — `WireOnboarding`, which would otherwise re-ask and then overwrite the
1987
+ * stored record — uses {@link loadSettledPermissionsOutcome} instead.
1988
+ */
1983
1989
  declare const loadSettledPermissions: (storage: WireOnboardingStorage, key: string, sessionId: string) => Promise<string[]>;
1984
1990
  /** Persist the settled ids for `sessionId` - fire-and-forget, all errors swallowed. */
1985
1991
  declare const saveSettledPermissions: (storage: WireOnboardingStorage, key: string, sessionId: string, ids: readonly string[]) => void;
package/dist/index.d.ts CHANGED
@@ -1979,7 +1979,13 @@ declare const permissionStorageKey: (appId: string) => string;
1979
1979
  * because re-showing a screen is a far cheaper failure than trusting another session's answers.
1980
1980
  */
1981
1981
  declare const readSettledPermissions: (raw: string | null | undefined, sessionId: string) => string[];
1982
- /** Read the settled ids for `sessionId`. Never throws, never hangs past the shared read ceiling. */
1982
+ /**
1983
+ * Read the settled ids for `sessionId`, collapsing "the store did not answer" to `[]`.
1984
+ *
1985
+ * Kept as the module's simple reader for callers that have no way to act on the difference. The
1986
+ * one caller that CAN — `WireOnboarding`, which would otherwise re-ask and then overwrite the
1987
+ * stored record — uses {@link loadSettledPermissionsOutcome} instead.
1988
+ */
1983
1989
  declare const loadSettledPermissions: (storage: WireOnboardingStorage, key: string, sessionId: string) => Promise<string[]>;
1984
1990
  /** Persist the settled ids for `sessionId` - fire-and-forget, all errors swallowed. */
1985
1991
  declare const saveSettledPermissions: (storage: WireOnboardingStorage, key: string, sessionId: string, ids: readonly string[]) => void;
package/dist/index.js CHANGED
@@ -3813,15 +3813,19 @@ var readSettledPermissions = (raw, sessionId) => {
3813
3813
  return [];
3814
3814
  }
3815
3815
  };
3816
- var loadSettledPermissions = async (storage, key, sessionId) => {
3816
+ var loadSettledPermissionsOutcome = async (storage, key, sessionId) => {
3817
3817
  try {
3818
3818
  const raw = await withTimeout(storage.getItem(key), READ_TIMEOUT_MS);
3819
- if (raw === READ_TIMED_OUT) return [];
3820
- return readSettledPermissions(raw, sessionId);
3819
+ if (raw === READ_TIMED_OUT) return { status: "unknown" };
3820
+ return { status: "read", ids: readSettledPermissions(raw, sessionId) };
3821
3821
  } catch {
3822
- return [];
3822
+ return { status: "unknown" };
3823
3823
  }
3824
3824
  };
3825
+ var loadSettledPermissions = async (storage, key, sessionId) => {
3826
+ const outcome = await loadSettledPermissionsOutcome(storage, key, sessionId);
3827
+ return outcome.status === "read" ? outcome.ids : [];
3828
+ };
3825
3829
  var saveSettledPermissions = (storage, key, sessionId, ids) => {
3826
3830
  try {
3827
3831
  const record = { sessionId, ids: [...ids] };
@@ -3976,16 +3980,33 @@ var WireOnboarding = ({
3976
3980
  const sessionId = (_c = session == null ? void 0 : session.id) != null ? _c : "";
3977
3981
  const wantsPermissionMemory = Boolean(storage) && ((_d = permissionScreens == null ? void 0 : permissionScreens.length) != null ? _d : 0) > 0;
3978
3982
  const [settledPermissions, setSettledPermissions] = React19.useState(void 0);
3983
+ const [permissionMemoryUnreadable, setPermissionMemoryUnreadable] = React19.useState(false);
3979
3984
  React19.useEffect(() => {
3980
- if (!wantsPermissionMemory || !storage || !sessionId || settledPermissions !== void 0) return;
3985
+ if (!wantsPermissionMemory || !storage || !sessionId) return;
3986
+ if (settledPermissions !== void 0 || permissionMemoryUnreadable) return;
3981
3987
  let cancelled = false;
3982
- void loadSettledPermissions(storage, permissionsKey, sessionId).then((ids) => {
3983
- if (!cancelled) setSettledPermissions(ids);
3988
+ void loadSettledPermissionsOutcome(storage, permissionsKey, sessionId).then((outcome) => {
3989
+ if (cancelled) return;
3990
+ if (outcome.status === "read") {
3991
+ setSettledPermissions(outcome.ids);
3992
+ return;
3993
+ }
3994
+ setPermissionMemoryUnreadable(true);
3995
+ warnInDev(
3996
+ "[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."
3997
+ );
3984
3998
  });
3985
3999
  return () => {
3986
4000
  cancelled = true;
3987
4001
  };
3988
- }, [wantsPermissionMemory, storage, permissionsKey, sessionId, settledPermissions]);
4002
+ }, [
4003
+ wantsPermissionMemory,
4004
+ storage,
4005
+ permissionsKey,
4006
+ sessionId,
4007
+ settledPermissions,
4008
+ permissionMemoryUnreadable
4009
+ ]);
3989
4010
  const settledPermissionsRef = React19.useRef(void 0);
3990
4011
  settledPermissionsRef.current = settledPermissions;
3991
4012
  const handlePermissionSettled = React19.useCallback(