@apps-in-toss/types 0.0.0-dev.1757573431379
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/README.md +3 -0
- package/dist/index.cjs +108 -0
- package/dist/index.d.cts +309 -0
- package/dist/index.d.ts +309 -0
- package/dist/index.js +74 -0
- package/package.json +37 -0
- package/src/index.ts +1 -0
- package/src/permissions/FetchAlbumPhotosPermissionError.ts +13 -0
- package/src/permissions/FetchContactsPermissionError.ts +13 -0
- package/src/permissions/GetClipboardTextPermissionError.ts +13 -0
- package/src/permissions/GetCurrentLocationPermissionError.ts +13 -0
- package/src/permissions/OpenCameraPermissionError.ts +13 -0
- package/src/permissions/PermissionError.ts +15 -0
- package/src/permissions/SetClipboardTextPermissionError.ts +13 -0
- package/src/permissions/StartUpdateLocationPermissionError.ts +9 -0
- package/src/permissions/fetchAlbumPhotos.ts +23 -0
- package/src/permissions/fetchContacts.ts +25 -0
- package/src/permissions/getClipboardText.ts +1 -0
- package/src/permissions/getCurrentLocation.ts +100 -0
- package/src/permissions/index.ts +29 -0
- package/src/permissions/nativeModules.ts +8 -0
- package/src/permissions/openCamera.ts +18 -0
- package/src/permissions/permission.ts +46 -0
- package/src/permissions/setClipboardText.ts +5 -0
- package/src/permissions/startUpdateLocation.ts +24 -0
package/README.md
ADDED
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
Accuracy: () => Accuracy,
|
|
24
|
+
FetchAlbumPhotosPermissionError: () => FetchAlbumPhotosPermissionError,
|
|
25
|
+
FetchContactsPermissionError: () => FetchContactsPermissionError,
|
|
26
|
+
GetClipboardTextPermissionError: () => GetClipboardTextPermissionError,
|
|
27
|
+
GetCurrentLocationPermissionError: () => GetCurrentLocationPermissionError,
|
|
28
|
+
OpenCameraPermissionError: () => OpenCameraPermissionError,
|
|
29
|
+
SetClipboardTextPermissionError: () => SetClipboardTextPermissionError,
|
|
30
|
+
StartUpdateLocationPermissionError: () => StartUpdateLocationPermissionError
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(index_exports);
|
|
33
|
+
|
|
34
|
+
// src/permissions/PermissionError.ts
|
|
35
|
+
var PermissionError = class extends Error {
|
|
36
|
+
constructor({ methodName, message }) {
|
|
37
|
+
super();
|
|
38
|
+
this.name = `${methodName} permission error`;
|
|
39
|
+
this.message = message;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// src/permissions/FetchAlbumPhotosPermissionError.ts
|
|
44
|
+
var FetchAlbumPhotosPermissionError = class extends PermissionError {
|
|
45
|
+
constructor() {
|
|
46
|
+
super({ methodName: "fetchAlbumPhotos", message: "\uC0AC\uC9C4\uCCA9 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694." });
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// src/permissions/FetchContactsPermissionError.ts
|
|
51
|
+
var FetchContactsPermissionError = class extends PermissionError {
|
|
52
|
+
constructor() {
|
|
53
|
+
super({ methodName: "fetchContacts", message: "\uC5F0\uB77D\uCC98 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694." });
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// src/permissions/OpenCameraPermissionError.ts
|
|
58
|
+
var OpenCameraPermissionError = class extends PermissionError {
|
|
59
|
+
constructor() {
|
|
60
|
+
super({ methodName: "openCamera", message: "\uCE74\uBA54\uB77C \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694." });
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// src/permissions/getCurrentLocation.ts
|
|
65
|
+
var Accuracy = /* @__PURE__ */ ((Accuracy2) => {
|
|
66
|
+
Accuracy2[Accuracy2["Lowest"] = 1] = "Lowest";
|
|
67
|
+
Accuracy2[Accuracy2["Low"] = 2] = "Low";
|
|
68
|
+
Accuracy2[Accuracy2["Balanced"] = 3] = "Balanced";
|
|
69
|
+
Accuracy2[Accuracy2["High"] = 4] = "High";
|
|
70
|
+
Accuracy2[Accuracy2["Highest"] = 5] = "Highest";
|
|
71
|
+
Accuracy2[Accuracy2["BestForNavigation"] = 6] = "BestForNavigation";
|
|
72
|
+
return Accuracy2;
|
|
73
|
+
})(Accuracy || {});
|
|
74
|
+
|
|
75
|
+
// src/permissions/GetCurrentLocationPermissionError.ts
|
|
76
|
+
var GetCurrentLocationPermissionError = class extends PermissionError {
|
|
77
|
+
constructor() {
|
|
78
|
+
super({ methodName: "getCurrentLocation", message: "\uC704\uCE58 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694." });
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// src/permissions/StartUpdateLocationPermissionError.ts
|
|
83
|
+
var StartUpdateLocationPermissionError = GetCurrentLocationPermissionError;
|
|
84
|
+
|
|
85
|
+
// src/permissions/GetClipboardTextPermissionError.ts
|
|
86
|
+
var GetClipboardTextPermissionError = class extends PermissionError {
|
|
87
|
+
constructor() {
|
|
88
|
+
super({ methodName: "getClipboardText", message: "\uD074\uB9BD\uBCF4\uB4DC \uC77D\uAE30 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694." });
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// src/permissions/SetClipboardTextPermissionError.ts
|
|
93
|
+
var SetClipboardTextPermissionError = class extends PermissionError {
|
|
94
|
+
constructor() {
|
|
95
|
+
super({ methodName: "setClipboardText", message: "\uD074\uB9BD\uBCF4\uB4DC \uC4F0\uAE30 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694." });
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
99
|
+
0 && (module.exports = {
|
|
100
|
+
Accuracy,
|
|
101
|
+
FetchAlbumPhotosPermissionError,
|
|
102
|
+
FetchContactsPermissionError,
|
|
103
|
+
GetClipboardTextPermissionError,
|
|
104
|
+
GetCurrentLocationPermissionError,
|
|
105
|
+
OpenCameraPermissionError,
|
|
106
|
+
SetClipboardTextPermissionError,
|
|
107
|
+
StartUpdateLocationPermissionError
|
|
108
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 앨범 사진을 조회할 때 사용하는 옵션 타입이에요.
|
|
3
|
+
*/
|
|
4
|
+
interface FetchAlbumPhotosOptions {
|
|
5
|
+
/** 가져올 사진의 최대 개수를 설정해요. 숫자를 입력하고 기본값은 10이에요. */
|
|
6
|
+
maxCount?: number;
|
|
7
|
+
/** 사진의 최대 폭을 제한해요. 단위는 픽셀이고 기본값은 1024이에요. */
|
|
8
|
+
maxWidth?: number;
|
|
9
|
+
/** 이미지를 base64 형식으로 반환할지 설정해요. 기본값은 `false`예요. */
|
|
10
|
+
base64?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 사진 조회 결과를 나타내는 타입이에요.
|
|
14
|
+
*/
|
|
15
|
+
interface ImageResponse {
|
|
16
|
+
/** 가져온 사진의 고유 ID예요. */
|
|
17
|
+
id: string;
|
|
18
|
+
/** 사진의 데이터 URI예요. `base64` 옵션이 `true`인 경우 Base64 문자열로 반환돼요. */
|
|
19
|
+
dataUri: string;
|
|
20
|
+
}
|
|
21
|
+
type FetchAlbumPhotos = (options?: FetchAlbumPhotosOptions) => Promise<ImageResponse[]>;
|
|
22
|
+
|
|
23
|
+
type CompatiblePlaceholderArgument = object;
|
|
24
|
+
type PermissionFunctionName = 'getClipboardText' | 'setClipboardText' | 'fetchContacts' | 'fetchAlbumPhotos' | 'getCurrentLocation' | 'openCamera';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @public
|
|
28
|
+
* @category 권한
|
|
29
|
+
* @name PermissionError
|
|
30
|
+
* @description 권한 에러를 나타내는 클래스예요. 공통된 권한에러를 처리할 때 사용해요. 에러가 발생했을 때 `error instanceof PermissionError`를 통해 확인할 수 있어요.
|
|
31
|
+
*/
|
|
32
|
+
declare class PermissionError extends Error {
|
|
33
|
+
constructor({ methodName, message }: {
|
|
34
|
+
methodName: PermissionFunctionName;
|
|
35
|
+
message: string;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @public
|
|
41
|
+
* @category 권한
|
|
42
|
+
* @name FetchAlbumPhotosPermissionError
|
|
43
|
+
* @description 사진첩 권한이 거부되었을 때 발생하는 에러예요. 에러가 발생했을 때 `error instanceof FetchAlbumPhotosPermissionError`를 통해 확인할 수 있어요.
|
|
44
|
+
*/
|
|
45
|
+
declare class FetchAlbumPhotosPermissionError extends PermissionError {
|
|
46
|
+
constructor();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface FetchContactsOptions {
|
|
50
|
+
size: number;
|
|
51
|
+
offset: number;
|
|
52
|
+
query?: {
|
|
53
|
+
contains?: string;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* 연락처 정보를 나타내는 타입이에요.
|
|
58
|
+
*/
|
|
59
|
+
interface ContactEntity {
|
|
60
|
+
/** 연락처 이름이에요. */
|
|
61
|
+
name: string;
|
|
62
|
+
/** 연락처 전화번호로, 문자열 형식이에요. */
|
|
63
|
+
phoneNumber: string;
|
|
64
|
+
}
|
|
65
|
+
interface ContactResult {
|
|
66
|
+
result: ContactEntity[];
|
|
67
|
+
nextOffset: number | null;
|
|
68
|
+
done: boolean;
|
|
69
|
+
}
|
|
70
|
+
type FetchContacts = (options: FetchContactsOptions) => Promise<ContactResult>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @public
|
|
74
|
+
* @category 권한
|
|
75
|
+
* @name FetchContactsPermissionError
|
|
76
|
+
* @description 연락처 권한이 거부되었을 때 발생하는 에러예요. 에러가 발생했을 때 `error instanceof FetchContactsPermissionError`를 통해 확인할 수 있어요.
|
|
77
|
+
*/
|
|
78
|
+
declare class FetchContactsPermissionError extends PermissionError {
|
|
79
|
+
constructor();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
interface OpenCameraOptions {
|
|
83
|
+
/**
|
|
84
|
+
* 이미지를 Base64 형식으로 반환할지 여부를 나타내는 불리언 값이에요.
|
|
85
|
+
*
|
|
86
|
+
* 기본값: `false`.
|
|
87
|
+
*/
|
|
88
|
+
base64?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* 이미지의 최대 너비를 나타내는 숫자 값이에요.
|
|
91
|
+
*
|
|
92
|
+
* 기본값: `1024`.
|
|
93
|
+
*/
|
|
94
|
+
maxWidth?: number;
|
|
95
|
+
}
|
|
96
|
+
type OpenCamera = (options?: OpenCameraOptions) => Promise<ImageResponse>;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @public
|
|
100
|
+
* @category 권한
|
|
101
|
+
* @name OpenCameraPermissionError
|
|
102
|
+
* @description 카메라 권한이 거부되었을 때 발생하는 에러예요. 에러가 발생했을 때 `error instanceof OpenCameraPermissionError`를 통해 확인할 수 있어요.
|
|
103
|
+
*/
|
|
104
|
+
declare class OpenCameraPermissionError extends PermissionError {
|
|
105
|
+
constructor();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @public
|
|
110
|
+
* @category 위치 정보
|
|
111
|
+
* @name Accuracy
|
|
112
|
+
* @description 위치 정확도 옵션이에요.
|
|
113
|
+
*/
|
|
114
|
+
declare enum Accuracy {
|
|
115
|
+
/**
|
|
116
|
+
* 오차범위 3KM 이내
|
|
117
|
+
*/
|
|
118
|
+
Lowest = 1,
|
|
119
|
+
/**
|
|
120
|
+
* 오차범위 1KM 이내
|
|
121
|
+
*/
|
|
122
|
+
Low = 2,
|
|
123
|
+
/**
|
|
124
|
+
* 오차범위 몇 백미터 이내
|
|
125
|
+
*/
|
|
126
|
+
Balanced = 3,
|
|
127
|
+
/**
|
|
128
|
+
* 오차범위 10M 이내
|
|
129
|
+
*/
|
|
130
|
+
High = 4,
|
|
131
|
+
/**
|
|
132
|
+
* 가장 높은 정확도
|
|
133
|
+
*/
|
|
134
|
+
Highest = 5,
|
|
135
|
+
/**
|
|
136
|
+
* 네비게이션을 위한 최고 정확도
|
|
137
|
+
*/
|
|
138
|
+
BestForNavigation = 6
|
|
139
|
+
}
|
|
140
|
+
interface GetCurrentLocationOptions {
|
|
141
|
+
/**
|
|
142
|
+
* 위치 정보를 가져올 정확도 수준이에요.
|
|
143
|
+
*/
|
|
144
|
+
accuracy: Accuracy;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* @public
|
|
148
|
+
* @category 위치 정보
|
|
149
|
+
* @name Location
|
|
150
|
+
* @description 위치 정보를 나타내는 객체예요.
|
|
151
|
+
*/
|
|
152
|
+
interface Location {
|
|
153
|
+
/**
|
|
154
|
+
* Android에서만 지원하는 옵션이에요.
|
|
155
|
+
*
|
|
156
|
+
* - `FINE`: 정확한 위치
|
|
157
|
+
* - `COARSE`: 대략적인 위치
|
|
158
|
+
*
|
|
159
|
+
* @see https://developer.android.com/codelabs/approximate-location
|
|
160
|
+
*/
|
|
161
|
+
accessLocation?: 'FINE' | 'COARSE';
|
|
162
|
+
/**
|
|
163
|
+
* 위치가 업데이트된 시점의 유닉스 타임스탬프예요.
|
|
164
|
+
*/
|
|
165
|
+
timestamp: number;
|
|
166
|
+
/**
|
|
167
|
+
* @description 위치 정보를 나타내는 객체예요. 자세한 내용은 [LocationCoords](/react-native/reference/native-modules/Types/LocationCoords.html)을 참고해주세요.
|
|
168
|
+
*/
|
|
169
|
+
coords: LocationCoords;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* @public
|
|
173
|
+
* @category 위치 정보
|
|
174
|
+
* @name LocationCoords
|
|
175
|
+
* @description 세부 위치 정보를 나타내는 객체예요.
|
|
176
|
+
*/
|
|
177
|
+
interface LocationCoords {
|
|
178
|
+
/**
|
|
179
|
+
* 위도
|
|
180
|
+
*/
|
|
181
|
+
latitude: number;
|
|
182
|
+
/**
|
|
183
|
+
* 경도
|
|
184
|
+
*/
|
|
185
|
+
longitude: number;
|
|
186
|
+
/**
|
|
187
|
+
* 높이
|
|
188
|
+
*/
|
|
189
|
+
altitude: number;
|
|
190
|
+
/**
|
|
191
|
+
* 위치 정확도
|
|
192
|
+
*/
|
|
193
|
+
accuracy: number;
|
|
194
|
+
/**
|
|
195
|
+
* 고도 정확도
|
|
196
|
+
*/
|
|
197
|
+
altitudeAccuracy: number;
|
|
198
|
+
/**
|
|
199
|
+
* 방향
|
|
200
|
+
*/
|
|
201
|
+
heading: number;
|
|
202
|
+
}
|
|
203
|
+
type GetCurrentLocation = (options: GetCurrentLocationOptions) => Promise<Location>;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* @public
|
|
207
|
+
* @category 권한
|
|
208
|
+
* @name GetCurrentLocationPermissionError
|
|
209
|
+
* @description 위치 권한이 거부되었을 때 발생하는 에러예요. 에러가 발생했을 때 `error instanceof GetCurrentLocationPermissionError`를 통해 확인할 수 있어요.
|
|
210
|
+
*/
|
|
211
|
+
declare class GetCurrentLocationPermissionError extends PermissionError {
|
|
212
|
+
constructor();
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
interface StartUpdateLocationOptions {
|
|
216
|
+
/**
|
|
217
|
+
* 위치 정확도를 설정해요.
|
|
218
|
+
*/
|
|
219
|
+
accuracy: Accuracy;
|
|
220
|
+
/**
|
|
221
|
+
* 위치 업데이트 주기를 밀리초(ms) 단위로 설정해요.
|
|
222
|
+
*/
|
|
223
|
+
timeInterval: number;
|
|
224
|
+
/**
|
|
225
|
+
* 위치 변경 거리를 미터(m) 단위로 설정해요.
|
|
226
|
+
*/
|
|
227
|
+
distanceInterval: number;
|
|
228
|
+
}
|
|
229
|
+
type StartUpdateLocationEventParams = {
|
|
230
|
+
onEvent: (response: Location) => void;
|
|
231
|
+
onError: (error: unknown) => void;
|
|
232
|
+
options: StartUpdateLocationOptions;
|
|
233
|
+
};
|
|
234
|
+
type StartUpdateLocation = (eventParams: StartUpdateLocationEventParams) => () => void;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* @public
|
|
238
|
+
* @category 권한
|
|
239
|
+
* @name StartUpdateLocationPermissionError
|
|
240
|
+
* @description 위치 업데이트 권한이 거부되었을 때 발생하는 에러예요. 에러가 발생했을 때 `error instanceof StartUpdateLocationPermissionError`를 통해 확인할 수 있어요.
|
|
241
|
+
*/
|
|
242
|
+
declare const StartUpdateLocationPermissionError: typeof GetCurrentLocationPermissionError;
|
|
243
|
+
|
|
244
|
+
type GetClipboardText = () => Promise<string>;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* @public
|
|
248
|
+
* @category 권한
|
|
249
|
+
* @name GetClipboardTextPermissionError
|
|
250
|
+
* @description 클립보드 읽기 권한이 거부되었을 때 발생하는 에러예요. 에러가 발생했을 때 `error instanceof GetClipboardTextPermissionError`를 통해 확인할 수 있어요.
|
|
251
|
+
*/
|
|
252
|
+
declare class GetClipboardTextPermissionError extends PermissionError {
|
|
253
|
+
constructor();
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
interface SetClipboardTextOptions {
|
|
257
|
+
text: string;
|
|
258
|
+
}
|
|
259
|
+
type SetClipboardText = (text: string) => Promise<void>;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* @public
|
|
263
|
+
* @category 권한
|
|
264
|
+
* @name SetClipboardTextPermissionError
|
|
265
|
+
* @description 클립보드 쓰기 권한이 거부되었을 때 발생하는 에러예요. 에러가 발생했을 때 `error instanceof SetClipboardTextPermissionError`를 통해 확인할 수 있어요.
|
|
266
|
+
*/
|
|
267
|
+
declare class SetClipboardTextPermissionError extends PermissionError {
|
|
268
|
+
constructor();
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
type PermissionStatus = 'notDetermined' | 'denied' | 'allowed';
|
|
272
|
+
type PermissionAccess = 'read' | 'write' | 'access';
|
|
273
|
+
type PermissionName = 'clipboard' | 'contacts' | 'photos' | 'geolocation' | 'camera';
|
|
274
|
+
interface PermissionErrorConstructorParams {
|
|
275
|
+
methodName: PermissionFunctionName;
|
|
276
|
+
message: string;
|
|
277
|
+
}
|
|
278
|
+
interface PermissionErrorType extends Error {
|
|
279
|
+
name: string;
|
|
280
|
+
message: string;
|
|
281
|
+
}
|
|
282
|
+
interface CreatePermissionFunctionOptions<T extends (...args: any[]) => any> {
|
|
283
|
+
handler: T;
|
|
284
|
+
permission: {
|
|
285
|
+
name: PermissionName;
|
|
286
|
+
access: PermissionAccess;
|
|
287
|
+
};
|
|
288
|
+
error: new () => PermissionErrorType;
|
|
289
|
+
}
|
|
290
|
+
type RequestPermissionFunction = (permission: {
|
|
291
|
+
name: PermissionName;
|
|
292
|
+
access: PermissionAccess;
|
|
293
|
+
}) => Promise<Exclude<PermissionStatus, 'notDetermined'>>;
|
|
294
|
+
type InternalPermissionDialogFunction = (permission: {
|
|
295
|
+
name: PermissionName;
|
|
296
|
+
access: PermissionAccess;
|
|
297
|
+
}) => Promise<Exclude<PermissionStatus, 'notDetermined'>>;
|
|
298
|
+
type InternalGetPermissionFunction = (permission: {
|
|
299
|
+
name: PermissionName;
|
|
300
|
+
access: PermissionAccess;
|
|
301
|
+
}) => Promise<PermissionStatus>;
|
|
302
|
+
type PermissionDialogFunction = () => Promise<Exclude<PermissionStatus, 'notDetermined'>>;
|
|
303
|
+
type GetPermissionFunction = () => Promise<PermissionStatus>;
|
|
304
|
+
type PermissionFunctionWithDialog<T extends (...args: any[]) => any> = T & {
|
|
305
|
+
getPermission: GetPermissionFunction;
|
|
306
|
+
openPermissionDialog: PermissionDialogFunction;
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
export { Accuracy, type CompatiblePlaceholderArgument, type ContactEntity, type ContactResult, type CreatePermissionFunctionOptions, type FetchAlbumPhotos, type FetchAlbumPhotosOptions, FetchAlbumPhotosPermissionError, type FetchContacts, type FetchContactsOptions, FetchContactsPermissionError, type GetClipboardText, GetClipboardTextPermissionError, type GetCurrentLocation, type GetCurrentLocationOptions, GetCurrentLocationPermissionError, type GetPermissionFunction, type ImageResponse, type InternalGetPermissionFunction, type InternalPermissionDialogFunction, type Location, type LocationCoords, type OpenCamera, type OpenCameraOptions, OpenCameraPermissionError, type PermissionAccess, type PermissionDialogFunction, type PermissionErrorConstructorParams, type PermissionErrorType, type PermissionFunctionName, type PermissionFunctionWithDialog, type PermissionName, type PermissionStatus, type RequestPermissionFunction, type SetClipboardText, type SetClipboardTextOptions, SetClipboardTextPermissionError, type StartUpdateLocation, type StartUpdateLocationEventParams, type StartUpdateLocationOptions, StartUpdateLocationPermissionError };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 앨범 사진을 조회할 때 사용하는 옵션 타입이에요.
|
|
3
|
+
*/
|
|
4
|
+
interface FetchAlbumPhotosOptions {
|
|
5
|
+
/** 가져올 사진의 최대 개수를 설정해요. 숫자를 입력하고 기본값은 10이에요. */
|
|
6
|
+
maxCount?: number;
|
|
7
|
+
/** 사진의 최대 폭을 제한해요. 단위는 픽셀이고 기본값은 1024이에요. */
|
|
8
|
+
maxWidth?: number;
|
|
9
|
+
/** 이미지를 base64 형식으로 반환할지 설정해요. 기본값은 `false`예요. */
|
|
10
|
+
base64?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 사진 조회 결과를 나타내는 타입이에요.
|
|
14
|
+
*/
|
|
15
|
+
interface ImageResponse {
|
|
16
|
+
/** 가져온 사진의 고유 ID예요. */
|
|
17
|
+
id: string;
|
|
18
|
+
/** 사진의 데이터 URI예요. `base64` 옵션이 `true`인 경우 Base64 문자열로 반환돼요. */
|
|
19
|
+
dataUri: string;
|
|
20
|
+
}
|
|
21
|
+
type FetchAlbumPhotos = (options?: FetchAlbumPhotosOptions) => Promise<ImageResponse[]>;
|
|
22
|
+
|
|
23
|
+
type CompatiblePlaceholderArgument = object;
|
|
24
|
+
type PermissionFunctionName = 'getClipboardText' | 'setClipboardText' | 'fetchContacts' | 'fetchAlbumPhotos' | 'getCurrentLocation' | 'openCamera';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @public
|
|
28
|
+
* @category 권한
|
|
29
|
+
* @name PermissionError
|
|
30
|
+
* @description 권한 에러를 나타내는 클래스예요. 공통된 권한에러를 처리할 때 사용해요. 에러가 발생했을 때 `error instanceof PermissionError`를 통해 확인할 수 있어요.
|
|
31
|
+
*/
|
|
32
|
+
declare class PermissionError extends Error {
|
|
33
|
+
constructor({ methodName, message }: {
|
|
34
|
+
methodName: PermissionFunctionName;
|
|
35
|
+
message: string;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @public
|
|
41
|
+
* @category 권한
|
|
42
|
+
* @name FetchAlbumPhotosPermissionError
|
|
43
|
+
* @description 사진첩 권한이 거부되었을 때 발생하는 에러예요. 에러가 발생했을 때 `error instanceof FetchAlbumPhotosPermissionError`를 통해 확인할 수 있어요.
|
|
44
|
+
*/
|
|
45
|
+
declare class FetchAlbumPhotosPermissionError extends PermissionError {
|
|
46
|
+
constructor();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface FetchContactsOptions {
|
|
50
|
+
size: number;
|
|
51
|
+
offset: number;
|
|
52
|
+
query?: {
|
|
53
|
+
contains?: string;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* 연락처 정보를 나타내는 타입이에요.
|
|
58
|
+
*/
|
|
59
|
+
interface ContactEntity {
|
|
60
|
+
/** 연락처 이름이에요. */
|
|
61
|
+
name: string;
|
|
62
|
+
/** 연락처 전화번호로, 문자열 형식이에요. */
|
|
63
|
+
phoneNumber: string;
|
|
64
|
+
}
|
|
65
|
+
interface ContactResult {
|
|
66
|
+
result: ContactEntity[];
|
|
67
|
+
nextOffset: number | null;
|
|
68
|
+
done: boolean;
|
|
69
|
+
}
|
|
70
|
+
type FetchContacts = (options: FetchContactsOptions) => Promise<ContactResult>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @public
|
|
74
|
+
* @category 권한
|
|
75
|
+
* @name FetchContactsPermissionError
|
|
76
|
+
* @description 연락처 권한이 거부되었을 때 발생하는 에러예요. 에러가 발생했을 때 `error instanceof FetchContactsPermissionError`를 통해 확인할 수 있어요.
|
|
77
|
+
*/
|
|
78
|
+
declare class FetchContactsPermissionError extends PermissionError {
|
|
79
|
+
constructor();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
interface OpenCameraOptions {
|
|
83
|
+
/**
|
|
84
|
+
* 이미지를 Base64 형식으로 반환할지 여부를 나타내는 불리언 값이에요.
|
|
85
|
+
*
|
|
86
|
+
* 기본값: `false`.
|
|
87
|
+
*/
|
|
88
|
+
base64?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* 이미지의 최대 너비를 나타내는 숫자 값이에요.
|
|
91
|
+
*
|
|
92
|
+
* 기본값: `1024`.
|
|
93
|
+
*/
|
|
94
|
+
maxWidth?: number;
|
|
95
|
+
}
|
|
96
|
+
type OpenCamera = (options?: OpenCameraOptions) => Promise<ImageResponse>;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @public
|
|
100
|
+
* @category 권한
|
|
101
|
+
* @name OpenCameraPermissionError
|
|
102
|
+
* @description 카메라 권한이 거부되었을 때 발생하는 에러예요. 에러가 발생했을 때 `error instanceof OpenCameraPermissionError`를 통해 확인할 수 있어요.
|
|
103
|
+
*/
|
|
104
|
+
declare class OpenCameraPermissionError extends PermissionError {
|
|
105
|
+
constructor();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @public
|
|
110
|
+
* @category 위치 정보
|
|
111
|
+
* @name Accuracy
|
|
112
|
+
* @description 위치 정확도 옵션이에요.
|
|
113
|
+
*/
|
|
114
|
+
declare enum Accuracy {
|
|
115
|
+
/**
|
|
116
|
+
* 오차범위 3KM 이내
|
|
117
|
+
*/
|
|
118
|
+
Lowest = 1,
|
|
119
|
+
/**
|
|
120
|
+
* 오차범위 1KM 이내
|
|
121
|
+
*/
|
|
122
|
+
Low = 2,
|
|
123
|
+
/**
|
|
124
|
+
* 오차범위 몇 백미터 이내
|
|
125
|
+
*/
|
|
126
|
+
Balanced = 3,
|
|
127
|
+
/**
|
|
128
|
+
* 오차범위 10M 이내
|
|
129
|
+
*/
|
|
130
|
+
High = 4,
|
|
131
|
+
/**
|
|
132
|
+
* 가장 높은 정확도
|
|
133
|
+
*/
|
|
134
|
+
Highest = 5,
|
|
135
|
+
/**
|
|
136
|
+
* 네비게이션을 위한 최고 정확도
|
|
137
|
+
*/
|
|
138
|
+
BestForNavigation = 6
|
|
139
|
+
}
|
|
140
|
+
interface GetCurrentLocationOptions {
|
|
141
|
+
/**
|
|
142
|
+
* 위치 정보를 가져올 정확도 수준이에요.
|
|
143
|
+
*/
|
|
144
|
+
accuracy: Accuracy;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* @public
|
|
148
|
+
* @category 위치 정보
|
|
149
|
+
* @name Location
|
|
150
|
+
* @description 위치 정보를 나타내는 객체예요.
|
|
151
|
+
*/
|
|
152
|
+
interface Location {
|
|
153
|
+
/**
|
|
154
|
+
* Android에서만 지원하는 옵션이에요.
|
|
155
|
+
*
|
|
156
|
+
* - `FINE`: 정확한 위치
|
|
157
|
+
* - `COARSE`: 대략적인 위치
|
|
158
|
+
*
|
|
159
|
+
* @see https://developer.android.com/codelabs/approximate-location
|
|
160
|
+
*/
|
|
161
|
+
accessLocation?: 'FINE' | 'COARSE';
|
|
162
|
+
/**
|
|
163
|
+
* 위치가 업데이트된 시점의 유닉스 타임스탬프예요.
|
|
164
|
+
*/
|
|
165
|
+
timestamp: number;
|
|
166
|
+
/**
|
|
167
|
+
* @description 위치 정보를 나타내는 객체예요. 자세한 내용은 [LocationCoords](/react-native/reference/native-modules/Types/LocationCoords.html)을 참고해주세요.
|
|
168
|
+
*/
|
|
169
|
+
coords: LocationCoords;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* @public
|
|
173
|
+
* @category 위치 정보
|
|
174
|
+
* @name LocationCoords
|
|
175
|
+
* @description 세부 위치 정보를 나타내는 객체예요.
|
|
176
|
+
*/
|
|
177
|
+
interface LocationCoords {
|
|
178
|
+
/**
|
|
179
|
+
* 위도
|
|
180
|
+
*/
|
|
181
|
+
latitude: number;
|
|
182
|
+
/**
|
|
183
|
+
* 경도
|
|
184
|
+
*/
|
|
185
|
+
longitude: number;
|
|
186
|
+
/**
|
|
187
|
+
* 높이
|
|
188
|
+
*/
|
|
189
|
+
altitude: number;
|
|
190
|
+
/**
|
|
191
|
+
* 위치 정확도
|
|
192
|
+
*/
|
|
193
|
+
accuracy: number;
|
|
194
|
+
/**
|
|
195
|
+
* 고도 정확도
|
|
196
|
+
*/
|
|
197
|
+
altitudeAccuracy: number;
|
|
198
|
+
/**
|
|
199
|
+
* 방향
|
|
200
|
+
*/
|
|
201
|
+
heading: number;
|
|
202
|
+
}
|
|
203
|
+
type GetCurrentLocation = (options: GetCurrentLocationOptions) => Promise<Location>;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* @public
|
|
207
|
+
* @category 권한
|
|
208
|
+
* @name GetCurrentLocationPermissionError
|
|
209
|
+
* @description 위치 권한이 거부되었을 때 발생하는 에러예요. 에러가 발생했을 때 `error instanceof GetCurrentLocationPermissionError`를 통해 확인할 수 있어요.
|
|
210
|
+
*/
|
|
211
|
+
declare class GetCurrentLocationPermissionError extends PermissionError {
|
|
212
|
+
constructor();
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
interface StartUpdateLocationOptions {
|
|
216
|
+
/**
|
|
217
|
+
* 위치 정확도를 설정해요.
|
|
218
|
+
*/
|
|
219
|
+
accuracy: Accuracy;
|
|
220
|
+
/**
|
|
221
|
+
* 위치 업데이트 주기를 밀리초(ms) 단위로 설정해요.
|
|
222
|
+
*/
|
|
223
|
+
timeInterval: number;
|
|
224
|
+
/**
|
|
225
|
+
* 위치 변경 거리를 미터(m) 단위로 설정해요.
|
|
226
|
+
*/
|
|
227
|
+
distanceInterval: number;
|
|
228
|
+
}
|
|
229
|
+
type StartUpdateLocationEventParams = {
|
|
230
|
+
onEvent: (response: Location) => void;
|
|
231
|
+
onError: (error: unknown) => void;
|
|
232
|
+
options: StartUpdateLocationOptions;
|
|
233
|
+
};
|
|
234
|
+
type StartUpdateLocation = (eventParams: StartUpdateLocationEventParams) => () => void;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* @public
|
|
238
|
+
* @category 권한
|
|
239
|
+
* @name StartUpdateLocationPermissionError
|
|
240
|
+
* @description 위치 업데이트 권한이 거부되었을 때 발생하는 에러예요. 에러가 발생했을 때 `error instanceof StartUpdateLocationPermissionError`를 통해 확인할 수 있어요.
|
|
241
|
+
*/
|
|
242
|
+
declare const StartUpdateLocationPermissionError: typeof GetCurrentLocationPermissionError;
|
|
243
|
+
|
|
244
|
+
type GetClipboardText = () => Promise<string>;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* @public
|
|
248
|
+
* @category 권한
|
|
249
|
+
* @name GetClipboardTextPermissionError
|
|
250
|
+
* @description 클립보드 읽기 권한이 거부되었을 때 발생하는 에러예요. 에러가 발생했을 때 `error instanceof GetClipboardTextPermissionError`를 통해 확인할 수 있어요.
|
|
251
|
+
*/
|
|
252
|
+
declare class GetClipboardTextPermissionError extends PermissionError {
|
|
253
|
+
constructor();
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
interface SetClipboardTextOptions {
|
|
257
|
+
text: string;
|
|
258
|
+
}
|
|
259
|
+
type SetClipboardText = (text: string) => Promise<void>;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* @public
|
|
263
|
+
* @category 권한
|
|
264
|
+
* @name SetClipboardTextPermissionError
|
|
265
|
+
* @description 클립보드 쓰기 권한이 거부되었을 때 발생하는 에러예요. 에러가 발생했을 때 `error instanceof SetClipboardTextPermissionError`를 통해 확인할 수 있어요.
|
|
266
|
+
*/
|
|
267
|
+
declare class SetClipboardTextPermissionError extends PermissionError {
|
|
268
|
+
constructor();
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
type PermissionStatus = 'notDetermined' | 'denied' | 'allowed';
|
|
272
|
+
type PermissionAccess = 'read' | 'write' | 'access';
|
|
273
|
+
type PermissionName = 'clipboard' | 'contacts' | 'photos' | 'geolocation' | 'camera';
|
|
274
|
+
interface PermissionErrorConstructorParams {
|
|
275
|
+
methodName: PermissionFunctionName;
|
|
276
|
+
message: string;
|
|
277
|
+
}
|
|
278
|
+
interface PermissionErrorType extends Error {
|
|
279
|
+
name: string;
|
|
280
|
+
message: string;
|
|
281
|
+
}
|
|
282
|
+
interface CreatePermissionFunctionOptions<T extends (...args: any[]) => any> {
|
|
283
|
+
handler: T;
|
|
284
|
+
permission: {
|
|
285
|
+
name: PermissionName;
|
|
286
|
+
access: PermissionAccess;
|
|
287
|
+
};
|
|
288
|
+
error: new () => PermissionErrorType;
|
|
289
|
+
}
|
|
290
|
+
type RequestPermissionFunction = (permission: {
|
|
291
|
+
name: PermissionName;
|
|
292
|
+
access: PermissionAccess;
|
|
293
|
+
}) => Promise<Exclude<PermissionStatus, 'notDetermined'>>;
|
|
294
|
+
type InternalPermissionDialogFunction = (permission: {
|
|
295
|
+
name: PermissionName;
|
|
296
|
+
access: PermissionAccess;
|
|
297
|
+
}) => Promise<Exclude<PermissionStatus, 'notDetermined'>>;
|
|
298
|
+
type InternalGetPermissionFunction = (permission: {
|
|
299
|
+
name: PermissionName;
|
|
300
|
+
access: PermissionAccess;
|
|
301
|
+
}) => Promise<PermissionStatus>;
|
|
302
|
+
type PermissionDialogFunction = () => Promise<Exclude<PermissionStatus, 'notDetermined'>>;
|
|
303
|
+
type GetPermissionFunction = () => Promise<PermissionStatus>;
|
|
304
|
+
type PermissionFunctionWithDialog<T extends (...args: any[]) => any> = T & {
|
|
305
|
+
getPermission: GetPermissionFunction;
|
|
306
|
+
openPermissionDialog: PermissionDialogFunction;
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
export { Accuracy, type CompatiblePlaceholderArgument, type ContactEntity, type ContactResult, type CreatePermissionFunctionOptions, type FetchAlbumPhotos, type FetchAlbumPhotosOptions, FetchAlbumPhotosPermissionError, type FetchContacts, type FetchContactsOptions, FetchContactsPermissionError, type GetClipboardText, GetClipboardTextPermissionError, type GetCurrentLocation, type GetCurrentLocationOptions, GetCurrentLocationPermissionError, type GetPermissionFunction, type ImageResponse, type InternalGetPermissionFunction, type InternalPermissionDialogFunction, type Location, type LocationCoords, type OpenCamera, type OpenCameraOptions, OpenCameraPermissionError, type PermissionAccess, type PermissionDialogFunction, type PermissionErrorConstructorParams, type PermissionErrorType, type PermissionFunctionName, type PermissionFunctionWithDialog, type PermissionName, type PermissionStatus, type RequestPermissionFunction, type SetClipboardText, type SetClipboardTextOptions, SetClipboardTextPermissionError, type StartUpdateLocation, type StartUpdateLocationEventParams, type StartUpdateLocationOptions, StartUpdateLocationPermissionError };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// src/permissions/PermissionError.ts
|
|
2
|
+
var PermissionError = class extends Error {
|
|
3
|
+
constructor({ methodName, message }) {
|
|
4
|
+
super();
|
|
5
|
+
this.name = `${methodName} permission error`;
|
|
6
|
+
this.message = message;
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// src/permissions/FetchAlbumPhotosPermissionError.ts
|
|
11
|
+
var FetchAlbumPhotosPermissionError = class extends PermissionError {
|
|
12
|
+
constructor() {
|
|
13
|
+
super({ methodName: "fetchAlbumPhotos", message: "\uC0AC\uC9C4\uCCA9 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694." });
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// src/permissions/FetchContactsPermissionError.ts
|
|
18
|
+
var FetchContactsPermissionError = class extends PermissionError {
|
|
19
|
+
constructor() {
|
|
20
|
+
super({ methodName: "fetchContacts", message: "\uC5F0\uB77D\uCC98 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694." });
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// src/permissions/OpenCameraPermissionError.ts
|
|
25
|
+
var OpenCameraPermissionError = class extends PermissionError {
|
|
26
|
+
constructor() {
|
|
27
|
+
super({ methodName: "openCamera", message: "\uCE74\uBA54\uB77C \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694." });
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// src/permissions/getCurrentLocation.ts
|
|
32
|
+
var Accuracy = /* @__PURE__ */ ((Accuracy2) => {
|
|
33
|
+
Accuracy2[Accuracy2["Lowest"] = 1] = "Lowest";
|
|
34
|
+
Accuracy2[Accuracy2["Low"] = 2] = "Low";
|
|
35
|
+
Accuracy2[Accuracy2["Balanced"] = 3] = "Balanced";
|
|
36
|
+
Accuracy2[Accuracy2["High"] = 4] = "High";
|
|
37
|
+
Accuracy2[Accuracy2["Highest"] = 5] = "Highest";
|
|
38
|
+
Accuracy2[Accuracy2["BestForNavigation"] = 6] = "BestForNavigation";
|
|
39
|
+
return Accuracy2;
|
|
40
|
+
})(Accuracy || {});
|
|
41
|
+
|
|
42
|
+
// src/permissions/GetCurrentLocationPermissionError.ts
|
|
43
|
+
var GetCurrentLocationPermissionError = class extends PermissionError {
|
|
44
|
+
constructor() {
|
|
45
|
+
super({ methodName: "getCurrentLocation", message: "\uC704\uCE58 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694." });
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// src/permissions/StartUpdateLocationPermissionError.ts
|
|
50
|
+
var StartUpdateLocationPermissionError = GetCurrentLocationPermissionError;
|
|
51
|
+
|
|
52
|
+
// src/permissions/GetClipboardTextPermissionError.ts
|
|
53
|
+
var GetClipboardTextPermissionError = class extends PermissionError {
|
|
54
|
+
constructor() {
|
|
55
|
+
super({ methodName: "getClipboardText", message: "\uD074\uB9BD\uBCF4\uB4DC \uC77D\uAE30 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694." });
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// src/permissions/SetClipboardTextPermissionError.ts
|
|
60
|
+
var SetClipboardTextPermissionError = class extends PermissionError {
|
|
61
|
+
constructor() {
|
|
62
|
+
super({ methodName: "setClipboardText", message: "\uD074\uB9BD\uBCF4\uB4DC \uC4F0\uAE30 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694." });
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
export {
|
|
66
|
+
Accuracy,
|
|
67
|
+
FetchAlbumPhotosPermissionError,
|
|
68
|
+
FetchContactsPermissionError,
|
|
69
|
+
GetClipboardTextPermissionError,
|
|
70
|
+
GetCurrentLocationPermissionError,
|
|
71
|
+
OpenCameraPermissionError,
|
|
72
|
+
SetClipboardTextPermissionError,
|
|
73
|
+
StartUpdateLocationPermissionError
|
|
74
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@apps-in-toss/types",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.0-dev.1757573431379",
|
|
5
|
+
"description": "Types for Apps In Toss",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"prepack": "yarn build",
|
|
8
|
+
"typecheck": "tsc --noEmit",
|
|
9
|
+
"lint": "eslint .",
|
|
10
|
+
"build": "tsup"
|
|
11
|
+
},
|
|
12
|
+
"main": "./dist/index.cjs",
|
|
13
|
+
"module": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"require": "./dist/index.cjs",
|
|
19
|
+
"import": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"src"
|
|
26
|
+
],
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/react": "18.3.3",
|
|
29
|
+
"esbuild": "0.25.5",
|
|
30
|
+
"tsup": "^8.5.0",
|
|
31
|
+
"typescript": "4.9.5"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"gitHead": "21c448c93d9212ce09af01cc21fc39b9877aabc9"
|
|
37
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './permissions';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PermissionError } from './PermissionError';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
* @category 권한
|
|
6
|
+
* @name FetchAlbumPhotosPermissionError
|
|
7
|
+
* @description 사진첩 권한이 거부되었을 때 발생하는 에러예요. 에러가 발생했을 때 `error instanceof FetchAlbumPhotosPermissionError`를 통해 확인할 수 있어요.
|
|
8
|
+
*/
|
|
9
|
+
export class FetchAlbumPhotosPermissionError extends PermissionError {
|
|
10
|
+
constructor() {
|
|
11
|
+
super({ methodName: 'fetchAlbumPhotos', message: '사진첩 권한이 거부되었어요.' });
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PermissionError } from './PermissionError';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
* @category 권한
|
|
6
|
+
* @name FetchContactsPermissionError
|
|
7
|
+
* @description 연락처 권한이 거부되었을 때 발생하는 에러예요. 에러가 발생했을 때 `error instanceof FetchContactsPermissionError`를 통해 확인할 수 있어요.
|
|
8
|
+
*/
|
|
9
|
+
export class FetchContactsPermissionError extends PermissionError {
|
|
10
|
+
constructor() {
|
|
11
|
+
super({ methodName: 'fetchContacts', message: '연락처 권한이 거부되었어요.' });
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PermissionError } from './PermissionError';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
* @category 권한
|
|
6
|
+
* @name GetClipboardTextPermissionError
|
|
7
|
+
* @description 클립보드 읽기 권한이 거부되었을 때 발생하는 에러예요. 에러가 발생했을 때 `error instanceof GetClipboardTextPermissionError`를 통해 확인할 수 있어요.
|
|
8
|
+
*/
|
|
9
|
+
export class GetClipboardTextPermissionError extends PermissionError {
|
|
10
|
+
constructor() {
|
|
11
|
+
super({ methodName: 'getClipboardText', message: '클립보드 읽기 권한이 거부되었어요.' });
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PermissionError } from './PermissionError';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
* @category 권한
|
|
6
|
+
* @name GetCurrentLocationPermissionError
|
|
7
|
+
* @description 위치 권한이 거부되었을 때 발생하는 에러예요. 에러가 발생했을 때 `error instanceof GetCurrentLocationPermissionError`를 통해 확인할 수 있어요.
|
|
8
|
+
*/
|
|
9
|
+
export class GetCurrentLocationPermissionError extends PermissionError {
|
|
10
|
+
constructor() {
|
|
11
|
+
super({ methodName: 'getCurrentLocation', message: '위치 권한이 거부되었어요.' });
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PermissionError } from './PermissionError';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
* @category 권한
|
|
6
|
+
* @name OpenCameraPermissionError
|
|
7
|
+
* @description 카메라 권한이 거부되었을 때 발생하는 에러예요. 에러가 발생했을 때 `error instanceof OpenCameraPermissionError`를 통해 확인할 수 있어요.
|
|
8
|
+
*/
|
|
9
|
+
export class OpenCameraPermissionError extends PermissionError {
|
|
10
|
+
constructor() {
|
|
11
|
+
super({ methodName: 'openCamera', message: '카메라 권한이 거부되었어요.' });
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PermissionFunctionName } from './nativeModules';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
* @category 권한
|
|
6
|
+
* @name PermissionError
|
|
7
|
+
* @description 권한 에러를 나타내는 클래스예요. 공통된 권한에러를 처리할 때 사용해요. 에러가 발생했을 때 `error instanceof PermissionError`를 통해 확인할 수 있어요.
|
|
8
|
+
*/
|
|
9
|
+
export class PermissionError extends Error {
|
|
10
|
+
constructor({ methodName, message }: { methodName: PermissionFunctionName; message: string }) {
|
|
11
|
+
super();
|
|
12
|
+
this.name = `${methodName} permission error`;
|
|
13
|
+
this.message = message;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PermissionError } from './PermissionError';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
* @category 권한
|
|
6
|
+
* @name SetClipboardTextPermissionError
|
|
7
|
+
* @description 클립보드 쓰기 권한이 거부되었을 때 발생하는 에러예요. 에러가 발생했을 때 `error instanceof SetClipboardTextPermissionError`를 통해 확인할 수 있어요.
|
|
8
|
+
*/
|
|
9
|
+
export class SetClipboardTextPermissionError extends PermissionError {
|
|
10
|
+
constructor() {
|
|
11
|
+
super({ methodName: 'setClipboardText', message: '클립보드 쓰기 권한이 거부되었어요.' });
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GetCurrentLocationPermissionError } from './GetCurrentLocationPermissionError';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
* @category 권한
|
|
6
|
+
* @name StartUpdateLocationPermissionError
|
|
7
|
+
* @description 위치 업데이트 권한이 거부되었을 때 발생하는 에러예요. 에러가 발생했을 때 `error instanceof StartUpdateLocationPermissionError`를 통해 확인할 수 있어요.
|
|
8
|
+
*/
|
|
9
|
+
export const StartUpdateLocationPermissionError = GetCurrentLocationPermissionError;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 앨범 사진을 조회할 때 사용하는 옵션 타입이에요.
|
|
3
|
+
*/
|
|
4
|
+
export interface FetchAlbumPhotosOptions {
|
|
5
|
+
/** 가져올 사진의 최대 개수를 설정해요. 숫자를 입력하고 기본값은 10이에요. */
|
|
6
|
+
maxCount?: number;
|
|
7
|
+
/** 사진의 최대 폭을 제한해요. 단위는 픽셀이고 기본값은 1024이에요. */
|
|
8
|
+
maxWidth?: number;
|
|
9
|
+
/** 이미지를 base64 형식으로 반환할지 설정해요. 기본값은 `false`예요. */
|
|
10
|
+
base64?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 사진 조회 결과를 나타내는 타입이에요.
|
|
15
|
+
*/
|
|
16
|
+
export interface ImageResponse {
|
|
17
|
+
/** 가져온 사진의 고유 ID예요. */
|
|
18
|
+
id: string;
|
|
19
|
+
/** 사진의 데이터 URI예요. `base64` 옵션이 `true`인 경우 Base64 문자열로 반환돼요. */
|
|
20
|
+
dataUri: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type FetchAlbumPhotos = (options?: FetchAlbumPhotosOptions) => Promise<ImageResponse[]>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface FetchContactsOptions {
|
|
2
|
+
size: number;
|
|
3
|
+
offset: number;
|
|
4
|
+
query?: {
|
|
5
|
+
contains?: string;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 연락처 정보를 나타내는 타입이에요.
|
|
11
|
+
*/
|
|
12
|
+
export interface ContactEntity {
|
|
13
|
+
/** 연락처 이름이에요. */
|
|
14
|
+
name: string;
|
|
15
|
+
/** 연락처 전화번호로, 문자열 형식이에요. */
|
|
16
|
+
phoneNumber: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ContactResult {
|
|
20
|
+
result: ContactEntity[];
|
|
21
|
+
nextOffset: number | null;
|
|
22
|
+
done: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type FetchContacts = (options: FetchContactsOptions) => Promise<ContactResult>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type GetClipboardText = () => Promise<string>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @public
|
|
3
|
+
* @category 위치 정보
|
|
4
|
+
* @name Accuracy
|
|
5
|
+
* @description 위치 정확도 옵션이에요.
|
|
6
|
+
*/
|
|
7
|
+
export enum Accuracy {
|
|
8
|
+
/**
|
|
9
|
+
* 오차범위 3KM 이내
|
|
10
|
+
*/
|
|
11
|
+
Lowest = 1,
|
|
12
|
+
/**
|
|
13
|
+
* 오차범위 1KM 이내
|
|
14
|
+
*/
|
|
15
|
+
Low,
|
|
16
|
+
/**
|
|
17
|
+
* 오차범위 몇 백미터 이내
|
|
18
|
+
*/
|
|
19
|
+
Balanced,
|
|
20
|
+
/**
|
|
21
|
+
* 오차범위 10M 이내
|
|
22
|
+
*/
|
|
23
|
+
High,
|
|
24
|
+
/**
|
|
25
|
+
* 가장 높은 정확도
|
|
26
|
+
*/
|
|
27
|
+
Highest,
|
|
28
|
+
/**
|
|
29
|
+
* 네비게이션을 위한 최고 정확도
|
|
30
|
+
*/
|
|
31
|
+
BestForNavigation,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface GetCurrentLocationOptions {
|
|
35
|
+
/**
|
|
36
|
+
* 위치 정보를 가져올 정확도 수준이에요.
|
|
37
|
+
*/
|
|
38
|
+
accuracy: Accuracy;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @public
|
|
43
|
+
* @category 위치 정보
|
|
44
|
+
* @name Location
|
|
45
|
+
* @description 위치 정보를 나타내는 객체예요.
|
|
46
|
+
*/
|
|
47
|
+
export interface Location {
|
|
48
|
+
/**
|
|
49
|
+
* Android에서만 지원하는 옵션이에요.
|
|
50
|
+
*
|
|
51
|
+
* - `FINE`: 정확한 위치
|
|
52
|
+
* - `COARSE`: 대략적인 위치
|
|
53
|
+
*
|
|
54
|
+
* @see https://developer.android.com/codelabs/approximate-location
|
|
55
|
+
*/
|
|
56
|
+
accessLocation?: 'FINE' | 'COARSE';
|
|
57
|
+
/**
|
|
58
|
+
* 위치가 업데이트된 시점의 유닉스 타임스탬프예요.
|
|
59
|
+
*/
|
|
60
|
+
timestamp: number;
|
|
61
|
+
/**
|
|
62
|
+
* @description 위치 정보를 나타내는 객체예요. 자세한 내용은 [LocationCoords](/react-native/reference/native-modules/Types/LocationCoords.html)을 참고해주세요.
|
|
63
|
+
*/
|
|
64
|
+
coords: LocationCoords;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @public
|
|
69
|
+
* @category 위치 정보
|
|
70
|
+
* @name LocationCoords
|
|
71
|
+
* @description 세부 위치 정보를 나타내는 객체예요.
|
|
72
|
+
*/
|
|
73
|
+
export interface LocationCoords {
|
|
74
|
+
/**
|
|
75
|
+
* 위도
|
|
76
|
+
*/
|
|
77
|
+
latitude: number;
|
|
78
|
+
/**
|
|
79
|
+
* 경도
|
|
80
|
+
*/
|
|
81
|
+
longitude: number;
|
|
82
|
+
/**
|
|
83
|
+
* 높이
|
|
84
|
+
*/
|
|
85
|
+
altitude: number;
|
|
86
|
+
/**
|
|
87
|
+
* 위치 정확도
|
|
88
|
+
*/
|
|
89
|
+
accuracy: number;
|
|
90
|
+
/**
|
|
91
|
+
* 고도 정확도
|
|
92
|
+
*/
|
|
93
|
+
altitudeAccuracy: number;
|
|
94
|
+
/**
|
|
95
|
+
* 방향
|
|
96
|
+
*/
|
|
97
|
+
heading: number;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export type GetCurrentLocation = (options: GetCurrentLocationOptions) => Promise<Location>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** album photos */
|
|
2
|
+
export * from './fetchAlbumPhotos';
|
|
3
|
+
export * from './FetchAlbumPhotosPermissionError';
|
|
4
|
+
|
|
5
|
+
/** contacts */
|
|
6
|
+
export * from './fetchContacts';
|
|
7
|
+
export * from './FetchContactsPermissionError';
|
|
8
|
+
|
|
9
|
+
/** camera */
|
|
10
|
+
export * from './openCamera';
|
|
11
|
+
export * from './OpenCameraPermissionError';
|
|
12
|
+
|
|
13
|
+
/** location */
|
|
14
|
+
export * from './getCurrentLocation';
|
|
15
|
+
export * from './GetCurrentLocationPermissionError';
|
|
16
|
+
|
|
17
|
+
export * from './startUpdateLocation';
|
|
18
|
+
export * from './StartUpdateLocationPermissionError';
|
|
19
|
+
|
|
20
|
+
/** clipboard */
|
|
21
|
+
export * from './getClipboardText';
|
|
22
|
+
export * from './GetClipboardTextPermissionError';
|
|
23
|
+
|
|
24
|
+
export * from './setClipboardText';
|
|
25
|
+
export * from './SetClipboardTextPermissionError';
|
|
26
|
+
|
|
27
|
+
/** common */
|
|
28
|
+
export * from './nativeModules';
|
|
29
|
+
export * from './permission';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ImageResponse } from './fetchAlbumPhotos';
|
|
2
|
+
|
|
3
|
+
export interface OpenCameraOptions {
|
|
4
|
+
/**
|
|
5
|
+
* 이미지를 Base64 형식으로 반환할지 여부를 나타내는 불리언 값이에요.
|
|
6
|
+
*
|
|
7
|
+
* 기본값: `false`.
|
|
8
|
+
*/
|
|
9
|
+
base64?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* 이미지의 최대 너비를 나타내는 숫자 값이에요.
|
|
12
|
+
*
|
|
13
|
+
* 기본값: `1024`.
|
|
14
|
+
*/
|
|
15
|
+
maxWidth?: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type OpenCamera = (options?: OpenCameraOptions) => Promise<ImageResponse>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { PermissionFunctionName } from './nativeModules';
|
|
2
|
+
|
|
3
|
+
export type PermissionStatus = 'notDetermined' | 'denied' | 'allowed';
|
|
4
|
+
export type PermissionAccess = 'read' | 'write' | 'access';
|
|
5
|
+
export type PermissionName = 'clipboard' | 'contacts' | 'photos' | 'geolocation' | 'camera';
|
|
6
|
+
|
|
7
|
+
export interface PermissionErrorConstructorParams {
|
|
8
|
+
methodName: PermissionFunctionName;
|
|
9
|
+
message: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface PermissionErrorType extends Error {
|
|
13
|
+
name: string;
|
|
14
|
+
message: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface CreatePermissionFunctionOptions<T extends (...args: any[]) => any> {
|
|
18
|
+
handler: T;
|
|
19
|
+
permission: {
|
|
20
|
+
name: PermissionName;
|
|
21
|
+
access: PermissionAccess;
|
|
22
|
+
};
|
|
23
|
+
error: new () => PermissionErrorType;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type RequestPermissionFunction = (permission: {
|
|
27
|
+
name: PermissionName;
|
|
28
|
+
access: PermissionAccess;
|
|
29
|
+
}) => Promise<Exclude<PermissionStatus, 'notDetermined'>>;
|
|
30
|
+
|
|
31
|
+
export type InternalPermissionDialogFunction = (permission: {
|
|
32
|
+
name: PermissionName;
|
|
33
|
+
access: PermissionAccess;
|
|
34
|
+
}) => Promise<Exclude<PermissionStatus, 'notDetermined'>>;
|
|
35
|
+
export type InternalGetPermissionFunction = (permission: {
|
|
36
|
+
name: PermissionName;
|
|
37
|
+
access: PermissionAccess;
|
|
38
|
+
}) => Promise<PermissionStatus>;
|
|
39
|
+
|
|
40
|
+
export type PermissionDialogFunction = () => Promise<Exclude<PermissionStatus, 'notDetermined'>>;
|
|
41
|
+
export type GetPermissionFunction = () => Promise<PermissionStatus>;
|
|
42
|
+
|
|
43
|
+
export type PermissionFunctionWithDialog<T extends (...args: any[]) => any> = T & {
|
|
44
|
+
getPermission: GetPermissionFunction;
|
|
45
|
+
openPermissionDialog: PermissionDialogFunction;
|
|
46
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Accuracy, Location } from './getCurrentLocation';
|
|
2
|
+
|
|
3
|
+
export interface StartUpdateLocationOptions {
|
|
4
|
+
/**
|
|
5
|
+
* 위치 정확도를 설정해요.
|
|
6
|
+
*/
|
|
7
|
+
accuracy: Accuracy;
|
|
8
|
+
/**
|
|
9
|
+
* 위치 업데이트 주기를 밀리초(ms) 단위로 설정해요.
|
|
10
|
+
*/
|
|
11
|
+
timeInterval: number;
|
|
12
|
+
/**
|
|
13
|
+
* 위치 변경 거리를 미터(m) 단위로 설정해요.
|
|
14
|
+
*/
|
|
15
|
+
distanceInterval: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type StartUpdateLocationEventParams = {
|
|
19
|
+
onEvent: (response: Location) => void;
|
|
20
|
+
onError: (error: unknown) => void;
|
|
21
|
+
options: StartUpdateLocationOptions;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type StartUpdateLocation = (eventParams: StartUpdateLocationEventParams) => () => void;
|