@apps-in-toss/web-bridge 1.0.3 → 1.1.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/built/bridge.d.ts CHANGED
@@ -6,6 +6,9 @@ export * from './setScreenAwakeMode';
6
6
  export * from './getNetworkStatus';
7
7
  export * from './setIosSwipeGestureEnabled';
8
8
  export * from './openURL';
9
+ export * from './openPermissionDialog';
10
+ export * from './getPermission';
11
+ export * from './requestPermission';
9
12
  export * from './setClipboardText';
10
13
  export * from './getClipboardText';
11
14
  export * from './fetchContacts';
@@ -27,7 +30,7 @@ export * from './getPlatformOS';
27
30
  export * from './getOperationalEnvironment';
28
31
  export * from './getTossAppVersion';
29
32
  export * from './getDeviceId';
33
+ export * from './contactsViral';
30
34
  export * from './startUpdateLocation';
31
35
  export * from './onVisibilityChangedByTransparentServiceWeb';
32
- export * from './contactsViral';
33
36
  export * from './types';
package/built/bridge.js CHANGED
@@ -1 +1 @@
1
- import{createAsyncBridge,createConstantBridge,createEventBridge}from"@apps-in-toss/bridge-core";var createEvents=function(){return{emit:function emit(event,args){for(var callbacks=this.events[event]||[],i=0,length=callbacks.length;i<length;i++){callbacks[i](args)}},events:{},on:function on(event,cb){var _this=this;var _this_events,_event;((_this_events=this.events)[_event=event]||(_this_events[_event]=[])).push(cb);return function(){var _this_events_event;_this.events[event]=(_this_events_event=_this.events[event])===null||_this_events_event===void 0?void 0:_this_events_event.filter(function(i){return cb!==i})}}}};if(typeof window!=="undefined"){window.__GRANITE_NATIVE_EMITTER=createEvents()}export var closeView=createAsyncBridge("closeView");export var generateHapticFeedback=createAsyncBridge("generateHapticFeedback");export var share=createAsyncBridge("share");export var setSecureScreen=createAsyncBridge("setSecureScreen");export var setScreenAwakeMode=createAsyncBridge("setScreenAwakeMode");export var getNetworkStatus=createAsyncBridge("getNetworkStatus");export var setIosSwipeGestureEnabled=createAsyncBridge("setIosSwipeGestureEnabled");export var openURL=createAsyncBridge("openURL");export var setClipboardText=createAsyncBridge("setClipboardText");export var getClipboardText=createAsyncBridge("getClipboardText");export var fetchContacts=createAsyncBridge("fetchContacts");export var fetchAlbumPhotos=createAsyncBridge("fetchAlbumPhotos");export var getCurrentLocation=createAsyncBridge("getCurrentLocation");export var openCamera=createAsyncBridge("openCamera");export var appLogin=createAsyncBridge("appLogin");export var eventLog=createAsyncBridge("eventLog");export var getTossShareLink=createAsyncBridge("getTossShareLink");export var setDeviceOrientation=createAsyncBridge("setDeviceOrientation");export var checkoutPayment=createAsyncBridge("checkoutPayment");export var saveBase64Data=createAsyncBridge("saveBase64Data");export var getGameCenterGameProfile=createAsyncBridge("getGameCenterGameProfile");export var openGameCenterLeaderboard=createAsyncBridge("openGameCenterLeaderboard");export var submitGameCenterLeaderBoardScore=createAsyncBridge("submitGameCenterLeaderBoardScore");export var getLocale=createConstantBridge("getLocale");export var getSchemeUri=createConstantBridge("getSchemeUri");export var getPlatformOS=createConstantBridge("getPlatformOS");export var getOperationalEnvironment=createConstantBridge("getOperationalEnvironment");export var getTossAppVersion=createConstantBridge("getTossAppVersion");export var getDeviceId=createConstantBridge("getDeviceId");export var startUpdateLocation=createEventBridge("startUpdateLocation");export var onVisibilityChangedByTransparentServiceWeb=createEventBridge("onVisibilityChangedByTransparentServiceWeb");export var contactsViral=createEventBridge("contactsViral");export var Accuracy=function(Accuracy){Accuracy[Accuracy["Lowest"]=1]="Lowest";Accuracy[Accuracy["Low"]=2]="Low";Accuracy[Accuracy["Balanced"]=3]="Balanced";Accuracy[Accuracy["High"]=4]="High";Accuracy[Accuracy["Highest"]=5]="Highest";Accuracy[Accuracy["BestForNavigation"]=6]="BestForNavigation";return Accuracy}({});
1
+ import{createAsyncBridge,createConstantBridge,createEventBridge}from"@apps-in-toss/bridge-core";var createEvents=function(){return{emit:function emit(event,args){for(var callbacks=this.events[event]||[],i=0,length=callbacks.length;i<length;i++){callbacks[i](args)}},events:{},on:function on(event,cb){var _this=this;var _this_events,_event;((_this_events=this.events)[_event=event]||(_this_events[_event]=[])).push(cb);return function(){var _this_events_event;_this.events[event]=(_this_events_event=_this.events[event])===null||_this_events_event===void 0?void 0:_this_events_event.filter(function(i){return cb!==i})}}}};if(typeof window!=="undefined"){window.__GRANITE_NATIVE_EMITTER=createEvents()}export var closeView=createAsyncBridge("closeView");export var generateHapticFeedback=createAsyncBridge("generateHapticFeedback");export var share=createAsyncBridge("share");export var setSecureScreen=createAsyncBridge("setSecureScreen");export var setScreenAwakeMode=createAsyncBridge("setScreenAwakeMode");export var getNetworkStatus=createAsyncBridge("getNetworkStatus");export var setIosSwipeGestureEnabled=createAsyncBridge("setIosSwipeGestureEnabled");export var openURL=createAsyncBridge("openURL");export var openPermissionDialog=createAsyncBridge("openPermissionDialog");export var getPermission=createAsyncBridge("getPermission");export var requestPermission=createAsyncBridge("requestPermission");export var setClipboardText=createConstantBridge("setClipboardText");export var getClipboardText=createConstantBridge("getClipboardText");export var fetchContacts=createConstantBridge("fetchContacts");export var fetchAlbumPhotos=createConstantBridge("fetchAlbumPhotos");export var getCurrentLocation=createConstantBridge("getCurrentLocation");export var openCamera=createConstantBridge("openCamera");export var appLogin=createAsyncBridge("appLogin");export var eventLog=createAsyncBridge("eventLog");export var getTossShareLink=createAsyncBridge("getTossShareLink");export var setDeviceOrientation=createAsyncBridge("setDeviceOrientation");export var checkoutPayment=createAsyncBridge("checkoutPayment");export var saveBase64Data=createAsyncBridge("saveBase64Data");export var getGameCenterGameProfile=createAsyncBridge("getGameCenterGameProfile");export var openGameCenterLeaderboard=createAsyncBridge("openGameCenterLeaderboard");export var submitGameCenterLeaderBoardScore=createAsyncBridge("submitGameCenterLeaderBoardScore");export var getLocale=createConstantBridge("getLocale");export var getSchemeUri=createConstantBridge("getSchemeUri");export var getPlatformOS=createConstantBridge("getPlatformOS");export var getOperationalEnvironment=createConstantBridge("getOperationalEnvironment");export var getTossAppVersion=createConstantBridge("getTossAppVersion");export var getDeviceId=createConstantBridge("getDeviceId");export var contactsViral=createEventBridge("contactsViral");export var startUpdateLocation=createEventBridge("startUpdateLocation");export var onVisibilityChangedByTransparentServiceWeb=createEventBridge("onVisibilityChangedByTransparentServiceWeb");
@@ -1,12 +1,3 @@
1
- /**
2
- * 사진 조회 결과를 나타내는 타입이에요.
3
- */
4
- export interface ImageResponse {
5
- /** 가져온 사진의 고유 ID예요. */
6
- id: string;
7
- /** 사진의 데이터 URI예요. `base64` 옵션이 `true`인 경우 Base64 문자열로 반환돼요. */
8
- dataUri: string;
9
- }
10
1
  /**
11
2
  * 앨범 사진을 조회할 때 사용하는 옵션 타입이에요.
12
3
  */
@@ -18,6 +9,23 @@ export interface FetchAlbumPhotosOptions {
18
9
  /** 이미지를 base64 형식으로 반환할지 설정해요. 기본값은 `false`예요. */
19
10
  base64?: boolean;
20
11
  }
12
+ /**
13
+ * 사진 조회 결과를 나타내는 타입이에요.
14
+ */
15
+ export interface ImageResponse {
16
+ /** 가져온 사진의 고유 ID예요. */
17
+ id: string;
18
+ /** 사진의 데이터 URI예요. `base64` 옵션이 `true`인 경우 Base64 문자열로 반환돼요. */
19
+ dataUri: string;
20
+ }
21
+ export type FetchAlbumPhotos = (options?: FetchAlbumPhotosOptions) => Promise<ImageResponse[]>;
22
+ type PermissionStatus$1 = "notDetermined" | "denied" | "allowed";
23
+ export type PermissionDialogFunction = () => Promise<Exclude<PermissionStatus$1, "notDetermined">>;
24
+ export type GetPermissionFunction = () => Promise<PermissionStatus$1>;
25
+ export type PermissionFunctionWithDialog<T extends (...args: any[]) => any> = T & {
26
+ getPermission: GetPermissionFunction;
27
+ openPermissionDialog: PermissionDialogFunction;
28
+ };
21
29
  /**
22
30
  * @public
23
31
  * @category 사진
@@ -30,22 +38,38 @@ export interface FetchAlbumPhotosOptions {
30
38
  * @param {number} [options.maxCount=10] 가져올 사진의 최대 개수를 설정해요. 숫자로 입력하며 기본값은 10이에요.
31
39
  * @param {number} [options.maxWidth=1024] 사진의 최대 폭을 제한해요. 단위는 픽셀이며 기본값은 `1024`이에요.
32
40
  * @param {boolean} [options.base64=false] 이미지를 base64 형식으로 반환할지 설정해요. 기본값은 `false`예요.
41
+ * @property [openPermissionDialog] - 사진첩 읽기 권한을 다시 요청하는 다이얼로그를 표시해요. 사용자는 "허용", "한 번만 허용", "안하기" 중 하나를 선택할 수 있어요. "허용"이나 "한 번만 허용"을 선택하면 `allowed`를 반환하고, "안하기"를 선택하면 `denied`를 반환해요.
42
+ * @property [getPermission] - 사진첩 읽기 권한의 현재 상태를 반환해요. `allowed`는 사용자가 사진첩 읽기 권한을 허용한 상태예요. `denied`는 사용자가 사진첩 읽기 권한을 거부한 상태예요. `notDetermined`는 사진첩 읽기 권한 요청을 한 번도 하지 않은 상태예요.
33
43
  * @returns {Promise<ImageResponse[]>}
34
44
  * 앨범 사진의 고유 ID와 데이터 URI를 포함한 배열을 반환해요.
35
45
  *
46
+ * @signature
47
+ * ```typescript
48
+ * function fetchAlbumPhotos(options: {
49
+ * maxCount: number;
50
+ * maxWidth: number;
51
+ * base64: boolean;
52
+ * }): Promise<ImageResponse[]>;
53
+ * ```
54
+ *
36
55
  * @example
37
56
  * ### 사진의 최대 폭을 360px로 제한하여 가져오기
38
57
  *
58
+ * 사진을 가져오는 예제예요.
59
+ * "권한 확인하기"버튼을 눌러서 현재 사진첩 읽기 권한을 확인해요.
60
+ * 사용자가 권한을 거부했거나 시스템에서 권한이 제한된 경우에는 [`FetchAlbumPhotosPermissionError`](/react-native/reference/types/권한/FetchAlbumPhotosPermissionError)를 반환해요.
61
+ * "권한 요청하기"버튼을 눌러서 사진첩 읽기 권한을 요청할 수 있어요.
62
+ *
39
63
  * ```tsx
40
- * import React, { useState } from 'react';
64
+ * import { fetchAlbumPhotos, FetchAlbumPhotosPermissionError, ImageResponse } from '@apps-in-toss/web-framework';
65
+ * import { useState } from 'react';
41
66
  *
42
- * import { fetchAlbumPhotos } from '@apps-in-toss/web-framework';
43
67
  *
44
68
  * const base64 = true;
45
69
  *
46
70
  * // 앨범 사진 목록을 가져와 화면에 표시하는 컴포넌트
47
71
  * function AlbumPhotoList() {
48
- * const [albumPhotos, setAlbumPhotos] = useState([]);
72
+ * const [albumPhotos, setAlbumPhotos] = useState<ImageResponse[]>([]);
49
73
  *
50
74
  * const handlePress = async () => {
51
75
  * try {
@@ -53,8 +77,11 @@ export interface FetchAlbumPhotosOptions {
53
77
  * base64,
54
78
  * maxWidth: 360,
55
79
  * });
56
- * setAlbumPhotos((prev) => ([...prev, ...response]));
80
+ * setAlbumPhotos((prev) => [...prev, ...response]);
57
81
  * } catch (error) {
82
+ * if (error instanceof FetchAlbumPhotosPermissionError) {
83
+ * // 앨범 읽기 권한 없음
84
+ * }
58
85
  * console.error('앨범을 가져오는 데 실패했어요:', error);
59
86
  * }
60
87
  * };
@@ -68,11 +95,25 @@ export interface FetchAlbumPhotosOptions {
68
95
  * return <Image source={{ uri: imageUri }} key={image.id} />;
69
96
  * })}
70
97
  * <input type="button" value="앨범 가져오기" onClick={handlePress} />
98
+ * <input type="button"
99
+ * value="권한 확인하기"
100
+ * onClick={async () => {
101
+ * const permission = await fetchAlbumPhotos.getPermission();
102
+ * Alert.alert(permission);
103
+ * }}
104
+ * />
105
+ * <input type="button"
106
+ * value="권한 요청하기"
107
+ * onClick={async () => {
108
+ * const permission = await fetchAlbumPhotos.openPermissionDialog();
109
+ * Alert.alert(permission);
110
+ * }}
111
+ * />
71
112
  * </div>
72
113
  * );
73
114
  * }
74
115
  * ```
75
116
  */
76
- export declare function fetchAlbumPhotos(options: FetchAlbumPhotosOptions): Promise<ImageResponse[]>;
117
+ export declare const fetchAlbumPhotos: PermissionFunctionWithDialog<FetchAlbumPhotos>;
77
118
 
78
119
  export {};
@@ -1,3 +1,10 @@
1
+ export interface FetchContactsOptions {
2
+ size: number;
3
+ offset: number;
4
+ query?: {
5
+ contains?: string;
6
+ };
7
+ }
1
8
  /**
2
9
  * 연락처 정보를 나타내는 타입이에요.
3
10
  */
@@ -12,6 +19,14 @@ export interface ContactResult {
12
19
  nextOffset: number | null;
13
20
  done: boolean;
14
21
  }
22
+ export type FetchContacts = (options: FetchContactsOptions) => Promise<ContactResult>;
23
+ type PermissionStatus$1 = "notDetermined" | "denied" | "allowed";
24
+ export type PermissionDialogFunction = () => Promise<Exclude<PermissionStatus$1, "notDetermined">>;
25
+ export type GetPermissionFunction = () => Promise<PermissionStatus$1>;
26
+ export type PermissionFunctionWithDialog<T extends (...args: any[]) => any> = T & {
27
+ getPermission: GetPermissionFunction;
28
+ openPermissionDialog: PermissionDialogFunction;
29
+ };
15
30
  /**
16
31
  * @public
17
32
  * @category 연락처
@@ -22,6 +37,9 @@ export interface ContactResult {
22
37
  * @param options.offset - 가져올 연락처의 시작 지점이에요. 처음 호출할 때는 `0`을 전달해야 해요. 이후에는 이전 호출에서 반환된 `nextOffset` 값을 사용해요.
23
38
  * @param options.query - 추가적인 필터링 옵션이에요.
24
39
  * @param options.query.contains - 이름에 특정 문자열이 포함된 연락처만 가져오고 싶을 때 사용해요. 이 값을 전달하지 않으면 모든 연락처를 가져와요.
40
+ * @property [openPermissionDialog] - 연락처 읽기 권한을 다시 요청하는 다이얼로그를 표시해요. 사용자는 "허용", "한 번만 허용", "안하기" 중 하나를 선택할 수 있어요. "허용"이나 "한 번만 허용"을 선택하면 `allowed`를 반환하고, "안하기"를 선택하면 `denied`를 반환해요.
41
+ * @property [getPermission] - 연락처 읽기 권한의 현재 상태를 반환해요. `allowed`는 사용자가 연락처 읽기 권한을 허용한 상태예요. `denied`는 사용자가 연락처 읽기 권한을 거부한 상태예요. `notDetermined`는 연락처 읽기 권한 요청을 한 번도 하지 않은 상태예요.
42
+ *
25
43
  * @returns {Promise<ContactResult>}
26
44
  * 연락처 목록과 페이지네이션 정보를 포함한 객체를 반환해요.
27
45
  * - `result`: 가져온 연락처 목록이에요.
@@ -42,10 +60,15 @@ export interface ContactResult {
42
60
  * @example
43
61
  * ### 특정 문자열이 포함된 연락처 목록 가져오기
44
62
  *
63
+ * 연락처 목록을 가져오는 예제예요.
64
+ * "권한 확인하기"버튼을 눌러서 현재 연락처 읽기 권한을 확인해요.
65
+ * 사용자가 권한을 거부했거나 시스템에서 권한이 제한된 경우에는 [`FetchContactsPermissionError`](/react-native/reference/types/권한/FetchContactsPermissionError)를 반환해요.
66
+ * "권한 요청하기"버튼을 눌러서 연락처 읽기 권한을 요청할 수 있어요.
67
+ *
45
68
  * ```tsx
46
- * import React, { useState } from 'react';
69
+ * import { ContactEntity, fetchContacts, FetchContactsPermissionError } from '@apps-in-toss/web-framework';
70
+ * import { useState } from 'react';
47
71
  *
48
- * import { fetchContacts, ContactEntity } from '@apps-in-toss/web-framework';
49
72
  *
50
73
  * // 특정 문자열을 포함한 연락처 목록을 가져와 화면에 표시하는 컴포넌트
51
74
  * function ContactsList() {
@@ -77,6 +100,9 @@ export interface ContactResult {
77
100
  * done: response.done,
78
101
  * }));
79
102
  * } catch (error) {
103
+ * if (error instanceof FetchContactsPermissionError) {
104
+ * // 연락처 읽기 권한 없음
105
+ * }
80
106
  * console.error('연락처를 가져오는 데 실패했어요:', error);
81
107
  * }
82
108
  * };
@@ -84,24 +110,34 @@ export interface ContactResult {
84
110
  * return (
85
111
  * <div>
86
112
  * {contacts.result.map((contact, index) => (
87
- * <span key={index}>{contact.name}: {contact.phoneNumber}</span>
113
+ * <span key={index}>
114
+ * {contact.name}: {contact.phoneNumber}
115
+ * </span>
88
116
  * ))}
89
117
  * <input type="button"
90
118
  * value={contacts.done ? '모든 연락처를 가져왔어요.' : '다음 연락처 가져오기'}
91
119
  * disabled={contacts.done}
92
120
  * onClick={handlePress}
93
121
  * />
122
+ * <input type="button"
123
+ * value="권한 확인하기"
124
+ * onClick={async () => {
125
+ * const permission = await fetchContacts.getPermission();
126
+ * Alert.alert(permission);
127
+ * }}
128
+ * />
129
+ * <input type="button"
130
+ * value="권한 요청하기"
131
+ * onClick={async () => {
132
+ * const permission = await fetchContacts.openPermissionDialog();
133
+ * Alert.alert(permission);
134
+ * }}
135
+ * />
94
136
  * </div>
95
137
  * );
96
138
  * }
97
139
  * ```
98
140
  */
99
- export declare function fetchContacts(options: {
100
- size: number;
101
- offset: number;
102
- query?: {
103
- contains?: string;
104
- };
105
- }): Promise<ContactResult>;
141
+ export declare const fetchContacts: PermissionFunctionWithDialog<FetchContacts>;
106
142
 
107
143
  export {};
@@ -1,40 +1,84 @@
1
+ export type GetClipboardText = () => Promise<string>;
2
+ type PermissionStatus$1 = "notDetermined" | "denied" | "allowed";
3
+ export type PermissionDialogFunction = () => Promise<Exclude<PermissionStatus$1, "notDetermined">>;
4
+ export type GetPermissionFunction = () => Promise<PermissionStatus$1>;
5
+ export type PermissionFunctionWithDialog<T extends (...args: any[]) => any> = T & {
6
+ getPermission: GetPermissionFunction;
7
+ openPermissionDialog: PermissionDialogFunction;
8
+ };
1
9
  /**
2
10
  * @public
3
11
  * @category 클립보드
4
12
  * @name getClipboardText
5
13
  * @description 클립보드에 저장된 텍스트를 가져오는 함수예요. 복사된 텍스트를 읽어서 다른 작업에 활용할 수 있어요.
14
+ * @property [openPermissionDialog] - 클립보드 읽기 권한을 다시 요청하는 다이얼로그를 표시해요. 사용자는 "허용", "한 번만 허용", "안하기" 중 하나를 선택할 수 있어요. "허용"이나 "한 번만 허용"을 선택하면 `allowed`를 반환하고, "안하기"를 선택하면 `denied`를 반환해요.
15
+ * @property [getPermission] - 클립보드 읽기 권한의 현재 상태를 반환해요. `allowed`는 사용자가 클립보드 읽기 권한을 허용한 상태예요. `denied`는 사용자가 클립보드 읽기 권한을 거부한 상태예요. `notDetermined`는 클립보드 읽기 권한 요청을 한 번도 하지 않은 상태예요.
6
16
  * @returns {Promise<string>} - 클립보드에 저장된 텍스트를 반환해요. 클립보드에 텍스트가 없으면 빈 문자열을 반환해요.
7
17
  *
18
+ * @signature
19
+ * ```typescript
20
+ * function getClipboardText(): Promise<string>;
21
+ * ```
22
+ *
8
23
  * @example
9
24
  * ### 클립보드의 텍스트 가져오기
10
25
  *
11
- * ```tsx
12
- * import React, { useState } from 'react';
13
- *
14
- * import { getClipboardText } from '@apps-in-toss/web-framework';
26
+ * 클립보드의 텍스트를 가져오는 예제예요.
27
+ * "권한 확인하기"버튼을 눌러서 현재 클립보드 읽기 권한을 확인해요.
28
+ * 사용자가 권한을 거부했거나 시스템에서 권한이 제한된 경우에는 [`GetClipboardTextPermissionError`](/react-native/reference/types/권한/GetClipboardTextPermissionError)를 반환해요.
29
+ * "권한 요청하기"버튼을 눌러서 클립보드 읽기 권한을 요청할 수 있어요.
15
30
  *
31
+ * ```tsx
32
+ * import {
33
+ * getClipboardText,
34
+ * GetClipboardTextPermissionError,
35
+ * SetClipboardTextPermissionError,
36
+ * } from '@apps-in-toss/web-framework';
37
+ * import { useState } from 'react';
38
+ * *
39
+
16
40
  * // '붙여넣기' 버튼을 누르면 클립보드에 저장된 텍스트를 가져와 화면에 표시해요.
17
41
  * function PasteButton() {
18
- * const [text, setText] = useState('');
19
- *
42
+ * const [text, setText] = useState(''); *
43
+
20
44
  * const handlePress = async () => {
21
45
  * try {
22
46
  * const clipboardText = await getClipboardText();
23
47
  * setText(clipboardText || '클립보드에 텍스트가 없어요.');
24
48
  * } catch (error) {
25
- * console.error('클립보드에서 텍스트를 가져오지 못했어요:', error);
49
+ * if (error instanceof GetClipboardTextPermissionError) {
50
+ * // 클립보드 읽기 권한 없음
51
+ * } *
52
+
53
+ * if (error instanceof SetClipboardTextPermissionError) {
54
+ * // 클립보드 쓰기 권한 없음
55
+ * }
26
56
  * }
27
- * };
28
- *
57
+ * }; *
58
+
29
59
  * return (
30
60
  * <div>
31
61
  * <span>{text}</span>
32
62
  * <input type="button" value="붙여넣기" onClick={handlePress} />
63
+ * <input type="button"
64
+ * value="권한 확인하기"
65
+ * onClick={async () => {
66
+ * const permission = await getClipboardText.getPermission();
67
+ * Alert.alert(permission);
68
+ * }}
69
+ * />
70
+ * <input type="button"
71
+ * value="권한 요청하기"
72
+ * onClick={async () => {
73
+ * const permission = await getClipboardText.openPermissionDialog();
74
+ * Alert.alert(permission);
75
+ * }}
76
+ * />
33
77
  * </div>
34
78
  * );
35
79
  * }
36
80
  * ```
37
81
  */
38
- export declare function getClipboardText(): Promise<string>;
82
+ export declare const getClipboardText: PermissionFunctionWithDialog<GetClipboardText>;
39
83
 
40
84
  export {};
@@ -24,6 +24,12 @@ declare enum Accuracy {
24
24
  */
25
25
  BestForNavigation = 6
26
26
  }
27
+ export interface GetCurrentLocationOptions {
28
+ /**
29
+ * 위치 정보를 가져올 정확도 수준이에요.
30
+ */
31
+ accuracy: Accuracy;
32
+ }
27
33
  interface Location$1 {
28
34
  /**
29
35
  * Android에서만 지원하는 옵션이에요.
@@ -75,12 +81,14 @@ export interface LocationCoords {
75
81
  */
76
82
  heading: number;
77
83
  }
78
- export interface GetCurrentLocationOptions {
79
- /**
80
- * 위치 정보를 가져올 정확도 수준이에요.
81
- */
82
- accuracy: Accuracy;
83
- }
84
+ export type GetCurrentLocation = (options: GetCurrentLocationOptions) => Promise<Location$1>;
85
+ type PermissionStatus$1 = "notDetermined" | "denied" | "allowed";
86
+ export type PermissionDialogFunction = () => Promise<Exclude<PermissionStatus$1, "notDetermined">>;
87
+ export type GetPermissionFunction = () => Promise<PermissionStatus$1>;
88
+ export type PermissionFunctionWithDialog<T extends (...args: any[]) => any> = T & {
89
+ getPermission: GetPermissionFunction;
90
+ openPermissionDialog: PermissionDialogFunction;
91
+ };
84
92
  /**
85
93
  * @public
86
94
  * @category 위치 정보
@@ -91,19 +99,32 @@ export interface GetCurrentLocationOptions {
91
99
  *
92
100
  * @param {GetCurrentLocationOptions} options 위치 정보를 가져올 때 사용하는 옵션 객체예요.
93
101
  * @param {Accuracy} [options.accuracy] 위치 정보의 정확도 수준이에요. 정확도는 `Accuracy` 타입으로 설정돼요.
102
+ * @property [openPermissionDialog] - 위치 정보 권한을 다시 요청하는 다이얼로그를 표시해요. 사용자는 "허용", "한 번만 허용", "안하기" 중 하나를 선택할 수 있어요. "허용"이나 "한 번만 허용"을 선택하면 `allowed`를 반환하고, "안하기"를 선택하면 `denied`를 반환해요.
103
+ * @property [getPermission] - 위치 정보 권한의 현재 상태를 반환해요. `allowed`는 사용자가 위치 정보 권한을 허용한 상태예요. `denied`는 사용자가 위치 정보 권한을 거부한 상태예요. `notDetermined`는 위치 정보 권한 요청을 한 번도 하지 않은 상태예요.
94
104
  * @returns {Promise<Location>} 디바이스의 위치 정보가 담긴 객체를 반환해요. 자세한 내용은 [Location](/react-native/reference/native-modules/Types/Location.html)을 참고해주세요.
95
105
  *
106
+ * @signature
107
+ * ```typescript
108
+ * function getCurrentLocation(options: {
109
+ * accuracy: Accuracy;
110
+ * }): Promise<Location>;
111
+ * ```
112
+ *
96
113
  * @example
97
114
  * ### 디바이스의 현재 위치 정보 가져오기
98
115
  *
116
+ * "권한 확인하기"버튼을 눌러서 현재 위치정보 권한을 확인해요.
117
+ * 사용자가 권한을 거부했거나 시스템에서 권한이 제한된 경우에는 [`GetCurrentLocationPermissionError`](/react-native/reference/types/권한/GetCurrentLocationPermissionError)를 반환해요.
118
+ * "권한 요청하기"버튼을 눌러서 위치정보 권한을 요청할 수 있어요.
119
+ *
99
120
  * ```tsx
100
- * import React, { useState } from 'react';
121
+ * import { Accuracy, getCurrentLocation, Location } from '@apps-in-toss/web-framework';
122
+ * import { useState } from 'react';
101
123
  *
102
- * import { getCurrentLocation } from '@apps-in-toss/web-framework';
103
124
  *
104
125
  * // 현재 위치 정보를 가져와 화면에 표시하는 컴포넌트
105
126
  * function CurrentPosition() {
106
- * const [position, setPosition] = useState(null);
127
+ * const [position, setPosition] = useState<Location | null>(null);
107
128
  *
108
129
  * const handlePress = async () => {
109
130
  * try {
@@ -117,16 +138,31 @@ export interface GetCurrentLocationOptions {
117
138
  * return (
118
139
  * <div>
119
140
  * {position ? (
120
- * <span>위치: {position.coords.latitude}, {position.coords.longitude}</span>
141
+ * <span>
142
+ * 위치: {position.coords.latitude}, {position.coords.longitude}
143
+ * </span>
121
144
  * ) : (
122
145
  * <span>위치 정보를 아직 가져오지 않았어요</span>
123
146
  * )}
124
147
  * <input type="button" value="현재 위치 정보 가져오기" onClick={handlePress} />
148
+ * <input type="button"
149
+ * value="권한 확인하기"
150
+ * onClick={async () => {
151
+ * Alert.alert(await getCurrentLocation.getPermission());
152
+ * }}
153
+ * />
154
+ * <input type="button"
155
+ * value="권한 요청하기"
156
+ * onClick={async () => {
157
+ * Alert.alert(await getCurrentLocation.openPermissionDialog());
158
+ * }}
159
+ * />
125
160
  * </div>
126
161
  * );
127
162
  * }
163
+ *
128
164
  * ```
129
165
  */
130
- export declare function getCurrentLocation(options: GetCurrentLocationOptions): Promise<Location$1>;
166
+ export declare const getCurrentLocation: PermissionFunctionWithDialog<GetCurrentLocation>;
131
167
 
132
168
  export {};
@@ -0,0 +1,58 @@
1
+ type PermissionStatus$1 = "notDetermined" | "denied" | "allowed";
2
+ export type PermissionAccess = "read" | "write" | "access";
3
+ type PermissionName$1 = "clipboard" | "contacts" | "photos" | "geolocation" | "camera";
4
+ /**
5
+ * @category AppsInTossModules
6
+ * @name getPermission
7
+ * @description 특정 권한의 현재 상태를 확인하는 함수예요. 사용자가 권한을 허용했는지, 거부했는지, 또는 아직 선택하지 않았는지를 알 수 있어요.
8
+ * @param permission.name {PermissionName} 요청할 권한의 이름이에요. 예를 들어 `clipboard`는 클립보드 접근 권한을, `camera`는 카메라 접근 권한을 나타내요.
9
+ * @param permission.access {PermissionAccess} 요청할 권한의 접근 유형이에요. 예를 들어 `read`는 읽기 권한, `write`는 쓰기 권한을 의미해요.
10
+ * @returns {Promise<'allowed' | 'denied' | 'notDetermined'>} 권한의 현재 상태를 반환해요. 반환값은 다음 중 하나예요:
11
+ * - `allowed`: 권한이 허용된 상태예요.
12
+ * - `denied`: 권한이 거부된 상태예요.
13
+ * - `notDetermined`: 아직 권한 요청에 대한 결정이 이루어지지 않은 상태예요.
14
+ *
15
+ * @example
16
+ * ### 클립보드 읽기 권한 상태 확인하기
17
+ *
18
+ * ```tsx
19
+ * import React, { useEffect, useState } from 'react';
20
+ *
21
+ * import { getPermission, type PermissionStatus } from '@apps-in-toss/web-framework';
22
+ *
23
+ * function PermissionCheck() {
24
+ * const [permission, setPermission] = useState<PermissionStatus | null>(null);
25
+ *
26
+ * useEffect(() => {
27
+ * async function checkPermission() {
28
+ * try {
29
+ * // 'clipboard'는 권한 이름, 'read'는 접근 유형을 나타내요.
30
+ * const status = await getPermission({
31
+ * name: 'clipboard', // 클립보드 접근 권한
32
+ * access: 'read', // 읽기 권한 요청
33
+ * });
34
+ * setPermission(status); // 권한 상태를 업데이트해요.
35
+ * } catch (error) {
36
+ * console.error('권한 상태를 확인하지 못했어요:', error);
37
+ * }
38
+ * }
39
+ *
40
+ * checkPermission();
41
+ * }, []);
42
+ *
43
+ * return (
44
+ * <div>
45
+ * <span>
46
+ * 클립보드 읽기 권한 상태: {permission ? permission : '확인 중...'}
47
+ * </span>
48
+ * </div>
49
+ * );
50
+ * }
51
+ * ```
52
+ */
53
+ export declare function getPermission(permission: {
54
+ name: PermissionName$1;
55
+ access: PermissionAccess;
56
+ }): Promise<PermissionStatus$1>;
57
+
58
+ export {};