Skip to content

Commit c9087e6

Browse files
committed
chore: normalize formatting in hooks (semicolons/spacing) and bump example iOS Podfile.lock deps
- Apply consistent TypeScript formatting (semicolons, trailing commas, minor punctuation) across hook modules: src/hooks/{error-utils,useAsyncLifecycle,useHasSecret,useSecret,useSecretItem,useSecureOperation,useSecureStorage}.ts - Update example/ios/Podfile.lock dependency versions/checksums: - SensitiveInfo -> 6.0.0-rc.8 - NitroModules -> 0.31.4 - react-native-safe-area-context -> 5.6.2
1 parent ed1b003 commit c9087e6

File tree

8 files changed

+216
-208
lines changed

8 files changed

+216
-208
lines changed

example/ios/Podfile.lock

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ PODS:
88
- hermes-engine (0.82.1):
99
- hermes-engine/Pre-built (= 0.82.1)
1010
- hermes-engine/Pre-built (0.82.1)
11-
- NitroModules (0.31.2):
11+
- NitroModules (0.31.4):
1212
- boost
1313
- DoubleConversion
1414
- fast_float
@@ -1811,7 +1811,7 @@ PODS:
18111811
- React-RCTFBReactNativeSpec
18121812
- ReactCommon/turbomodule/core
18131813
- SocketRocket
1814-
- react-native-safe-area-context (5.6.1):
1814+
- react-native-safe-area-context (5.6.2):
18151815
- boost
18161816
- DoubleConversion
18171817
- fast_float
@@ -1829,8 +1829,8 @@ PODS:
18291829
- React-graphics
18301830
- React-ImageManager
18311831
- React-jsi
1832-
- react-native-safe-area-context/common (= 5.6.1)
1833-
- react-native-safe-area-context/fabric (= 5.6.1)
1832+
- react-native-safe-area-context/common (= 5.6.2)
1833+
- react-native-safe-area-context/fabric (= 5.6.2)
18341834
- React-NativeModulesApple
18351835
- React-RCTFabric
18361836
- React-renderercss
@@ -1841,7 +1841,7 @@ PODS:
18411841
- ReactCommon/turbomodule/core
18421842
- SocketRocket
18431843
- Yoga
1844-
- react-native-safe-area-context/common (5.6.1):
1844+
- react-native-safe-area-context/common (5.6.2):
18451845
- boost
18461846
- DoubleConversion
18471847
- fast_float
@@ -1869,7 +1869,7 @@ PODS:
18691869
- ReactCommon/turbomodule/core
18701870
- SocketRocket
18711871
- Yoga
1872-
- react-native-safe-area-context/fabric (5.6.1):
1872+
- react-native-safe-area-context/fabric (5.6.2):
18731873
- boost
18741874
- DoubleConversion
18751875
- fast_float
@@ -2437,7 +2437,7 @@ PODS:
24372437
- React-perflogger (= 0.82.1)
24382438
- React-utils (= 0.82.1)
24392439
- SocketRocket
2440-
- SensitiveInfo (6.0.0-rc.4):
2440+
- SensitiveInfo (6.0.0-rc.8):
24412441
- boost
24422442
- DoubleConversion
24432443
- fast_float
@@ -2717,7 +2717,7 @@ SPEC CHECKSUMS:
27172717
fmt: a40bb5bd0294ea969aaaba240a927bd33d878cdd
27182718
glog: 5683914934d5b6e4240e497e0f4a3b42d1854183
27192719
hermes-engine: 273e30e7fb618279934b0b95ffab60ecedb7acf5
2720-
NitroModules: 2862238ccf1a30c3e3c20fb10ae297ce26168718
2720+
NitroModules: a08d4fbf973527df2d061c5f02cb192c2c261a09
27212721
RCT-Folly: 846fda9475e61ec7bcbf8a3fe81edfcaeb090669
27222722
RCTDeprecation: f17e2ebc07876ca9ab8eb6e4b0a4e4647497ae3a
27232723
RCTRequired: e2c574c1b45231f7efb0834936bd609d75072b63
@@ -2751,7 +2751,7 @@ SPEC CHECKSUMS:
27512751
React-logger: 500f2fa5697d224e63c33d913c8a4765319e19bf
27522752
React-Mapbuffer: 06d59c448da7e34eb05b3fb2189e12f6a30fec57
27532753
React-microtasksnativemodule: d1ee999dc9052e23f6488b730fa2d383a4ea40e5
2754-
react-native-safe-area-context: c6e2edd1c1da07bdce287fa9d9e60c5f7b514616
2754+
react-native-safe-area-context: c00143b4823773bba23f2f19f85663ae89ceb460
27552755
React-NativeModulesApple: 46690a0fe94ec28fc6fc686ec797b911d251ded0
27562756
React-oscompat: 95875e81f5d4b3c7b2c888d5bd2c9d83450d8bdb
27572757
React-perflogger: 2e229bf33e42c094fd64516d89ec1187a2b79b5b
@@ -2784,7 +2784,7 @@ SPEC CHECKSUMS:
27842784
ReactAppDependencyProvider: a45ef34bb22dc1c9b2ac1f74167d9a28af961176
27852785
ReactCodegen: 878add6c7d8ff8cea87697c44d29c03b79b6f2d9
27862786
ReactCommon: 804dc80944fa90b86800b43c871742ec005ca424
2787-
SensitiveInfo: 6ca5227d9f4fe12891caf373a4d4a54560d5fde0
2787+
SensitiveInfo: de10b692c50b4dfaf81507b23470ad0c616f7f5e
27882788
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
27892789
Yoga: 689c8e04277f3ad631e60fe2a08e41d411daf8eb
27902790

src/hooks/error-utils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {
22
getErrorMessage,
33
isAuthenticationCanceledError as internalIsAuthenticationCanceledError,
4-
} from '../internal/errors'
5-
import { HookError } from './types'
4+
} from '../internal/errors';
5+
import { HookError } from './types';
66

77
/**
88
* Creates a {@link HookError} enhanced with the original cause, the operation label, and an optional hint.
@@ -23,9 +23,9 @@ const createHookError = (
2323
operation,
2424
hint,
2525
}
26-
)
26+
);
2727

2828
export const isAuthenticationCanceledError =
29-
internalIsAuthenticationCanceledError
29+
internalIsAuthenticationCanceledError;
3030

31-
export default createHookError
31+
export default createHookError;

src/hooks/useAsyncLifecycle.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import { useCallback, useEffect, useRef } from 'react'
2-
import type { RefObject } from 'react'
1+
import { useCallback, useEffect, useRef } from 'react';
2+
import type { RefObject } from 'react';
33

44
export interface AsyncLifecycleControls {
55
/**
66
* Indicates whether the component that owns the hook is still mounted. Helpful when dispatching asynchronous state updates.
77
*/
8-
readonly mountedRef: RefObject<boolean>
8+
readonly mountedRef: RefObject<boolean>;
99
/**
1010
* Stores the last {@link AbortController} created by {@link begin}. Exposed for advanced scenarios such as manual cancellation.
1111
*/
12-
readonly controllerRef: RefObject<AbortController | null>
12+
readonly controllerRef: RefObject<AbortController | null>;
1313
/**
1414
* Aborts the previous async job (if any) and returns a fresh {@link AbortController} tied to the current execution flow.
1515
*/
16-
begin: () => AbortController
16+
begin: () => AbortController;
1717
}
1818

1919
/**
@@ -34,29 +34,29 @@ export interface AsyncLifecycleControls {
3434
* ```
3535
*/
3636
const useAsyncLifecycle = (): AsyncLifecycleControls => {
37-
const mountedRef = useRef(true)
38-
const controllerRef = useRef<AbortController | null>(null)
37+
const mountedRef = useRef(true);
38+
const controllerRef = useRef<AbortController | null>(null);
3939

4040
useEffect(
4141
() => () => {
42-
mountedRef.current = false
43-
controllerRef.current?.abort()
42+
mountedRef.current = false;
43+
controllerRef.current?.abort();
4444
},
4545
[]
46-
)
46+
);
4747

4848
const begin = useCallback(() => {
49-
controllerRef.current?.abort()
50-
const controller = new AbortController()
51-
controllerRef.current = controller
52-
return controller
53-
}, [])
49+
controllerRef.current?.abort();
50+
const controller = new AbortController();
51+
controllerRef.current = controller;
52+
return controller;
53+
}, []);
5454

5555
return {
5656
mountedRef,
5757
controllerRef,
5858
begin,
59-
}
60-
}
59+
};
60+
};
6161

62-
export default useAsyncLifecycle
62+
export default useAsyncLifecycle;

src/hooks/useHasSecret.ts

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
import { useCallback, useEffect, useState } from 'react'
2-
import type { SensitiveInfoOptions } from '../sensitive-info.nitro'
3-
import { hasItem } from '../core/storage'
4-
import { createInitialAsyncState } from './types'
5-
import type { AsyncState } from './types'
6-
import useAsyncLifecycle from './useAsyncLifecycle'
7-
import useStableOptions from './useStableOptions'
8-
import createHookError, { isAuthenticationCanceledError } from './error-utils'
1+
import { useCallback, useEffect, useState } from 'react';
2+
import type { SensitiveInfoOptions } from '../sensitive-info.nitro';
3+
import { hasItem } from '../core/storage';
4+
import { createInitialAsyncState } from './types';
5+
import type { AsyncState } from './types';
6+
import useAsyncLifecycle from './useAsyncLifecycle';
7+
import useStableOptions from './useStableOptions';
8+
import createHookError, { isAuthenticationCanceledError } from './error-utils';
99

1010
/**
1111
* Options accepted by {@link useHasSecret}.
1212
*/
1313
export interface UseHasSecretOptions extends SensitiveInfoOptions {
1414
/** Disable the automatic existence check while still exposing {@link UseHasSecretResult.refetch}. */
15-
readonly skip?: boolean
15+
readonly skip?: boolean;
1616
}
1717

1818
const DEFAULTS: Required<Pick<UseHasSecretOptions, 'skip'>> = {
1919
skip: false,
20-
}
20+
};
2121

2222
/**
2323
* Result bag returned by {@link useHasSecret}.
2424
*/
2525
export interface UseHasSecretResult extends AsyncState<boolean> {
2626
/** Refresh the cached boolean value. */
27-
refetch: () => Promise<void>
27+
refetch: () => Promise<void>;
2828
}
2929

3030
/**
@@ -41,37 +41,40 @@ export function useHasSecret(
4141
): UseHasSecretResult {
4242
const [state, setState] = useState<AsyncState<boolean>>(
4343
createInitialAsyncState<boolean>()
44-
)
44+
);
4545

46-
const { begin, mountedRef } = useAsyncLifecycle()
47-
const stableOptions = useStableOptions<UseHasSecretOptions>(DEFAULTS, options)
46+
const { begin, mountedRef } = useAsyncLifecycle();
47+
const stableOptions = useStableOptions<UseHasSecretOptions>(
48+
DEFAULTS,
49+
options
50+
);
4851

4952
const evaluate = useCallback(async () => {
50-
const { skip, ...requestOptions } = stableOptions
53+
const { skip, ...requestOptions } = stableOptions;
5154

5255
if (skip) {
5356
setState({
5457
data: null,
5558
error: null,
5659
isLoading: false,
5760
isPending: false,
58-
})
59-
return
61+
});
62+
return;
6063
}
6164

62-
const controller = begin()
63-
setState((prev) => ({ ...prev, isLoading: true, isPending: true }))
65+
const controller = begin();
66+
setState((prev) => ({ ...prev, isLoading: true, isPending: true }));
6467

6568
try {
66-
const exists = await hasItem(key, requestOptions)
69+
const exists = await hasItem(key, requestOptions);
6770

6871
if (mountedRef.current && !controller.signal.aborted) {
6972
setState({
7073
data: exists,
7174
error: null,
7275
isLoading: false,
7376
isPending: false,
74-
})
77+
});
7578
}
7679
} catch (errorLike) {
7780
if (mountedRef.current && !controller.signal.aborted) {
@@ -81,34 +84,34 @@ export function useHasSecret(
8184
error: null,
8285
isLoading: false,
8386
isPending: false,
84-
}))
87+
}));
8588
} else {
8689
const hookError = createHookError(
8790
'useHasSecret.evaluate',
8891
errorLike,
8992
'Most commonly triggered by an invalid key/service combination.'
90-
)
93+
);
9194
setState({
9295
data: null,
9396
error: hookError,
9497
isLoading: false,
9598
isPending: false,
96-
})
99+
});
97100
}
98101
}
99102
}
100-
}, [begin, key, mountedRef, stableOptions])
103+
}, [begin, key, mountedRef, stableOptions]);
101104

102105
useEffect(() => {
103-
evaluate().catch(() => {})
104-
}, [evaluate])
106+
evaluate().catch(() => {});
107+
}, [evaluate]);
105108

106109
const refetch = useCallback(async () => {
107-
await evaluate()
108-
}, [evaluate])
110+
await evaluate();
111+
}, [evaluate]);
109112

110113
return {
111114
...state,
112115
refetch,
113-
}
116+
};
114117
}

0 commit comments

Comments
 (0)