@apps-in-toss/web-framework 0.0.0-dev.1739416338672 → 0.0.0-dev.1740740040772

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.
@@ -1,3 +1,5 @@
1
+ import { Permission } from '@apps-in-toss/framework/plugins';
2
+ import { BedrockConfigResponse } from 'react-native-bedrock/config';
1
3
  import { z } from 'zod';
2
4
 
3
5
  declare const AppsInTossConfigSchema: z.ZodObject<{
@@ -27,6 +29,7 @@ declare const AppsInTossConfigSchema: z.ZodObject<{
27
29
  build: string;
28
30
  };
29
31
  }>;
32
+ permissions: z.ZodArray<z.ZodType<Permission, z.ZodTypeDef, Permission>, "many">;
30
33
  }, "strip", z.ZodTypeAny, {
31
34
  appName: string;
32
35
  web: {
@@ -36,6 +39,7 @@ declare const AppsInTossConfigSchema: z.ZodObject<{
36
39
  build: string;
37
40
  };
38
41
  };
42
+ permissions: Permission[];
39
43
  }, {
40
44
  appName: string;
41
45
  web: {
@@ -45,10 +49,9 @@ declare const AppsInTossConfigSchema: z.ZodObject<{
45
49
  build: string;
46
50
  };
47
51
  };
52
+ permissions: Permission[];
48
53
  }>;
49
54
  type AppsInTossConfig = z.infer<typeof AppsInTossConfigSchema>;
50
- declare const defineConfig: (config: z.input<typeof AppsInTossConfigSchema>) => AppsInTossConfig;
55
+ declare const defineConfig: (config: z.input<typeof AppsInTossConfigSchema>) => Promise<BedrockConfigResponse>;
51
56
 
52
- declare const loadConfig: () => Promise<AppsInTossConfig>;
53
-
54
- export { type AppsInTossConfig, defineConfig, loadConfig };
57
+ export { type AppsInTossConfig, defineConfig };
@@ -0,0 +1,57 @@
1
+ import { Permission } from '@apps-in-toss/framework/plugins';
2
+ import { BedrockConfigResponse } from 'react-native-bedrock/config';
3
+ import { z } from 'zod';
4
+
5
+ declare const AppsInTossConfigSchema: z.ZodObject<{
6
+ appName: z.ZodString;
7
+ web: z.ZodObject<{
8
+ port: z.ZodNumber;
9
+ commands: z.ZodObject<{
10
+ dev: z.ZodString;
11
+ build: z.ZodString;
12
+ }, "strip", z.ZodTypeAny, {
13
+ dev: string;
14
+ build: string;
15
+ }, {
16
+ dev: string;
17
+ build: string;
18
+ }>;
19
+ }, "strip", z.ZodTypeAny, {
20
+ port: number;
21
+ commands: {
22
+ dev: string;
23
+ build: string;
24
+ };
25
+ }, {
26
+ port: number;
27
+ commands: {
28
+ dev: string;
29
+ build: string;
30
+ };
31
+ }>;
32
+ permissions: z.ZodArray<z.ZodType<Permission, z.ZodTypeDef, Permission>, "many">;
33
+ }, "strip", z.ZodTypeAny, {
34
+ appName: string;
35
+ web: {
36
+ port: number;
37
+ commands: {
38
+ dev: string;
39
+ build: string;
40
+ };
41
+ };
42
+ permissions: Permission[];
43
+ }, {
44
+ appName: string;
45
+ web: {
46
+ port: number;
47
+ commands: {
48
+ dev: string;
49
+ build: string;
50
+ };
51
+ };
52
+ permissions: Permission[];
53
+ }>;
54
+ type AppsInTossConfig = z.infer<typeof AppsInTossConfigSchema>;
55
+ declare const defineConfig: (config: z.input<typeof AppsInTossConfigSchema>) => Promise<BedrockConfigResponse>;
56
+
57
+ export { type AppsInTossConfig, defineConfig };
@@ -0,0 +1,290 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ __dirname,
4
+ appsInTossWeb,
5
+ init_esm_shims
6
+ } from "../chunk-LJBVSTWE.js";
7
+
8
+ // src/config/index.ts
9
+ init_esm_shims();
10
+
11
+ // src/config/defineConfig.ts
12
+ init_esm_shims();
13
+ import path3 from "path";
14
+
15
+ // ../../.yarn/cache/find-up-npm-7.0.0-a80086f7af-e6ee3e6154.zip/node_modules/find-up/index.js
16
+ init_esm_shims();
17
+ import path2 from "node:path";
18
+
19
+ // ../../.yarn/cache/locate-path-npm-7.2.0-454f209f37-139e8a7fe1.zip/node_modules/locate-path/index.js
20
+ init_esm_shims();
21
+ import process from "node:process";
22
+ import path from "node:path";
23
+ import fs, { promises as fsPromises } from "node:fs";
24
+ import { fileURLToPath } from "node:url";
25
+
26
+ // ../../.yarn/cache/p-locate-npm-6.0.0-d73b86f7fc-d72fa2f41a.zip/node_modules/p-locate/index.js
27
+ init_esm_shims();
28
+
29
+ // ../../.yarn/cache/p-limit-npm-4.0.0-6161fa2142-a56af34a77.zip/node_modules/p-limit/index.js
30
+ init_esm_shims();
31
+
32
+ // ../../.yarn/cache/yocto-queue-npm-1.1.1-3796fef980-cb287fe5e6.zip/node_modules/yocto-queue/index.js
33
+ init_esm_shims();
34
+ var Node = class {
35
+ value;
36
+ next;
37
+ constructor(value) {
38
+ this.value = value;
39
+ }
40
+ };
41
+ var Queue = class {
42
+ #head;
43
+ #tail;
44
+ #size;
45
+ constructor() {
46
+ this.clear();
47
+ }
48
+ enqueue(value) {
49
+ const node = new Node(value);
50
+ if (this.#head) {
51
+ this.#tail.next = node;
52
+ this.#tail = node;
53
+ } else {
54
+ this.#head = node;
55
+ this.#tail = node;
56
+ }
57
+ this.#size++;
58
+ }
59
+ dequeue() {
60
+ const current = this.#head;
61
+ if (!current) {
62
+ return;
63
+ }
64
+ this.#head = this.#head.next;
65
+ this.#size--;
66
+ return current.value;
67
+ }
68
+ peek() {
69
+ if (!this.#head) {
70
+ return;
71
+ }
72
+ return this.#head.value;
73
+ }
74
+ clear() {
75
+ this.#head = void 0;
76
+ this.#tail = void 0;
77
+ this.#size = 0;
78
+ }
79
+ get size() {
80
+ return this.#size;
81
+ }
82
+ *[Symbol.iterator]() {
83
+ let current = this.#head;
84
+ while (current) {
85
+ yield current.value;
86
+ current = current.next;
87
+ }
88
+ }
89
+ };
90
+
91
+ // ../../.yarn/cache/p-limit-npm-4.0.0-6161fa2142-a56af34a77.zip/node_modules/p-limit/index.js
92
+ function pLimit(concurrency) {
93
+ if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
94
+ throw new TypeError("Expected `concurrency` to be a number from 1 and up");
95
+ }
96
+ const queue = new Queue();
97
+ let activeCount = 0;
98
+ const next = () => {
99
+ activeCount--;
100
+ if (queue.size > 0) {
101
+ queue.dequeue()();
102
+ }
103
+ };
104
+ const run = async (fn, resolve, args) => {
105
+ activeCount++;
106
+ const result = (async () => fn(...args))();
107
+ resolve(result);
108
+ try {
109
+ await result;
110
+ } catch {
111
+ }
112
+ next();
113
+ };
114
+ const enqueue = (fn, resolve, args) => {
115
+ queue.enqueue(run.bind(void 0, fn, resolve, args));
116
+ (async () => {
117
+ await Promise.resolve();
118
+ if (activeCount < concurrency && queue.size > 0) {
119
+ queue.dequeue()();
120
+ }
121
+ })();
122
+ };
123
+ const generator = (fn, ...args) => new Promise((resolve) => {
124
+ enqueue(fn, resolve, args);
125
+ });
126
+ Object.defineProperties(generator, {
127
+ activeCount: {
128
+ get: () => activeCount
129
+ },
130
+ pendingCount: {
131
+ get: () => queue.size
132
+ },
133
+ clearQueue: {
134
+ value: () => {
135
+ queue.clear();
136
+ }
137
+ }
138
+ });
139
+ return generator;
140
+ }
141
+
142
+ // ../../.yarn/cache/p-locate-npm-6.0.0-d73b86f7fc-d72fa2f41a.zip/node_modules/p-locate/index.js
143
+ var EndError = class extends Error {
144
+ constructor(value) {
145
+ super();
146
+ this.value = value;
147
+ }
148
+ };
149
+ var testElement = async (element, tester) => tester(await element);
150
+ var finder = async (element) => {
151
+ const values = await Promise.all(element);
152
+ if (values[1] === true) {
153
+ throw new EndError(values[0]);
154
+ }
155
+ return false;
156
+ };
157
+ async function pLocate(iterable, tester, {
158
+ concurrency = Number.POSITIVE_INFINITY,
159
+ preserveOrder = true
160
+ } = {}) {
161
+ const limit = pLimit(concurrency);
162
+ const items = [...iterable].map((element) => [element, limit(testElement, element, tester)]);
163
+ const checkLimit = pLimit(preserveOrder ? 1 : Number.POSITIVE_INFINITY);
164
+ try {
165
+ await Promise.all(items.map((element) => checkLimit(finder, element)));
166
+ } catch (error) {
167
+ if (error instanceof EndError) {
168
+ return error.value;
169
+ }
170
+ throw error;
171
+ }
172
+ }
173
+
174
+ // ../../.yarn/cache/locate-path-npm-7.2.0-454f209f37-139e8a7fe1.zip/node_modules/locate-path/index.js
175
+ var typeMappings = {
176
+ directory: "isDirectory",
177
+ file: "isFile"
178
+ };
179
+ function checkType(type) {
180
+ if (Object.hasOwnProperty.call(typeMappings, type)) {
181
+ return;
182
+ }
183
+ throw new Error(`Invalid type specified: ${type}`);
184
+ }
185
+ var matchType = (type, stat) => stat[typeMappings[type]]();
186
+ var toPath = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
187
+ async function locatePath(paths, {
188
+ cwd = process.cwd(),
189
+ type = "file",
190
+ allowSymlinks = true,
191
+ concurrency,
192
+ preserveOrder
193
+ } = {}) {
194
+ checkType(type);
195
+ cwd = toPath(cwd);
196
+ const statFunction = allowSymlinks ? fsPromises.stat : fsPromises.lstat;
197
+ return pLocate(paths, async (path_) => {
198
+ try {
199
+ const stat = await statFunction(path.resolve(cwd, path_));
200
+ return matchType(type, stat);
201
+ } catch {
202
+ return false;
203
+ }
204
+ }, { concurrency, preserveOrder });
205
+ }
206
+
207
+ // ../../.yarn/cache/unicorn-magic-npm-0.1.0-352b6e3681-e4ed0de05b.zip/node_modules/unicorn-magic/node.js
208
+ init_esm_shims();
209
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
210
+ function toPath2(urlOrPath) {
211
+ return urlOrPath instanceof URL ? fileURLToPath2(urlOrPath) : urlOrPath;
212
+ }
213
+
214
+ // ../../.yarn/cache/path-exists-npm-5.0.0-126b43894b-b170f3060b.zip/node_modules/path-exists/index.js
215
+ init_esm_shims();
216
+
217
+ // ../../.yarn/cache/find-up-npm-7.0.0-a80086f7af-e6ee3e6154.zip/node_modules/find-up/index.js
218
+ var findUpStop = Symbol("findUpStop");
219
+ async function findUpMultiple(name, options = {}) {
220
+ let directory = path2.resolve(toPath2(options.cwd) ?? "");
221
+ const { root } = path2.parse(directory);
222
+ const stopAt = path2.resolve(directory, toPath2(options.stopAt ?? root));
223
+ const limit = options.limit ?? Number.POSITIVE_INFINITY;
224
+ const paths = [name].flat();
225
+ const runMatcher = async (locateOptions) => {
226
+ if (typeof name !== "function") {
227
+ return locatePath(paths, locateOptions);
228
+ }
229
+ const foundPath = await name(locateOptions.cwd);
230
+ if (typeof foundPath === "string") {
231
+ return locatePath([foundPath], locateOptions);
232
+ }
233
+ return foundPath;
234
+ };
235
+ const matches = [];
236
+ while (true) {
237
+ const foundPath = await runMatcher({ ...options, cwd: directory });
238
+ if (foundPath === findUpStop) {
239
+ break;
240
+ }
241
+ if (foundPath) {
242
+ matches.push(path2.resolve(directory, foundPath));
243
+ }
244
+ if (directory === stopAt || matches.length >= limit) {
245
+ break;
246
+ }
247
+ directory = path2.dirname(directory);
248
+ }
249
+ return matches;
250
+ }
251
+ async function findUp(name, options = {}) {
252
+ const matches = await findUpMultiple(name, { ...options, limit: 1 });
253
+ return matches[0];
254
+ }
255
+
256
+ // src/config/defineConfig.ts
257
+ import { defineConfig as originDefineConfig } from "react-native-bedrock/config";
258
+ import { z } from "zod";
259
+ var AppsInTossConfigSchema = z.object({
260
+ appName: z.string(),
261
+ web: z.object({
262
+ port: z.number(),
263
+ commands: z.object({
264
+ dev: z.string(),
265
+ build: z.string()
266
+ })
267
+ }),
268
+ permissions: z.array(z.custom())
269
+ });
270
+ var defineConfig = async (config) => {
271
+ const reactNativeProjectDir = await findUp("react-native", { type: "directory", cwd: __dirname });
272
+ if (!reactNativeProjectDir) {
273
+ throw new Error("react-native \uB514\uB809\uD1A0\uB9AC\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.");
274
+ }
275
+ return originDefineConfig({
276
+ appName: config.appName,
277
+ plugins: [
278
+ appsInTossWeb({
279
+ port: config.web.port,
280
+ commands: config.web.commands,
281
+ permissions: config.permissions
282
+ })
283
+ ],
284
+ cwd: reactNativeProjectDir,
285
+ entryFile: path3.join(reactNativeProjectDir, "src", "_app.tsx")
286
+ });
287
+ };
288
+ export {
289
+ defineConfig
290
+ };
@@ -0,0 +1,75 @@
1
+ /**
2
+ * 사진 조회 결과를 나타내는 타입이에요.
3
+ */
4
+ export interface ImageResponse {
5
+ /** 가져온 사진의 고유 ID예요. */
6
+ id: string;
7
+ /** 사진의 데이터 URI예요. `base64` 옵션이 `true`인 경우 Base64 문자열로 반환돼요. */
8
+ dataUri: string;
9
+ }
10
+ /**
11
+ * 앨범 사진을 조회할 때 사용하는 옵션 타입이에요.
12
+ */
13
+ export interface FetchAlbumPhotosOptions {
14
+ /** 가져올 사진의 최대 개수를 설정해요. 숫자를 입력하고 기본값은 10이에요. */
15
+ maxCount?: number;
16
+ /** 사진의 최대 폭을 제한해요. 단위는 픽셀이고 기본값은 1024이에요. */
17
+ maxWidth?: number;
18
+ /** 이미지를 base64 형식으로 반환할지 설정해요. 기본값은 `false`예요. */
19
+ base64?: boolean;
20
+ }
21
+ /**
22
+ * @public
23
+ * @tag AppsInTossModule
24
+ * @category AppsInTossModules
25
+ * @kind function
26
+ * @name fetchAlbumPhotos
27
+ * @description
28
+ * 사용자의 앨범에서 사진 목록을 불러오는 함수예요.
29
+ * 최대 개수와 해상도를 설정할 수 있고 갤러리 미리보기, 이미지 선택 기능 등에 활용할 수 있어요.
30
+ *
31
+ * @param options - 조회 옵션을 담은 객체예요.
32
+ * @param {number} [options.maxCount=10] 가져올 사진의 최대 개수를 설정해요. 숫자로 입력하며 기본값은 10이에요.
33
+ * @param {number} [options.maxWidth=1024] 사진의 최대 폭을 제한해요. 단위는 픽셀이며 기본값은 `1024`이에요.
34
+ * @param {boolean} [options.base64=false] 이미지를 base64 형식으로 반환할지 설정해요. 기본값은 `false`예요.
35
+ * @returns {Promise<AlbumResponse[]>}
36
+ * 앨범 사진의 고유 ID와 데이터 URI를 포함한 배열을 반환해요.
37
+ *
38
+ * @example
39
+ * ### 사진의 최대 폭을 360px로 제한하여 가져오기
40
+ *
41
+ * ```tsx
42
+ * import React, { useState } from 'react';
43
+ *
44
+ * import { fetchAlbumPhotos } from '@apps-in-toss/web-framework';
45
+ *
46
+ * // 앨범 사진 목록을 가져와 화면에 표시하는 컴포넌트
47
+ * function AlbumPhotoList() {
48
+ * const [albumPhotos, setAlbumPhotos] = useState([]);
49
+ *
50
+ * const handlePress = async () => {
51
+ * try {
52
+ * const response = await fetchAlbumPhotos({
53
+ * base64: true,
54
+ * maxWidth: 360,
55
+ * });
56
+ * setAlbumPhotos((prev) => ([...prev, ...response]));
57
+ * } catch (error) {
58
+ * console.error('앨범을 가져오는 데 실패했어요:', error);
59
+ * }
60
+ * };
61
+ *
62
+ * return (
63
+ * <div>
64
+ * {albumPhotos.map((image) => (
65
+ * <img src={`data:image/jpeg;base64,${image.dataUri}`} key={image.id} />
66
+ * ))}
67
+ * <input type="button" value="앨범 가져오기" onClick={handlePress} />
68
+ * </div>
69
+ * );
70
+ * }
71
+ * ```
72
+ */
73
+ export declare function fetchAlbumPhotos(options: FetchAlbumPhotosOptions): Promise<ImageResponse[]>;
74
+
75
+ export {};
@@ -0,0 +1,92 @@
1
+ /**
2
+ * 연락처 정보를 나타내는 타입이에요.
3
+ */
4
+ export interface ContactEntity {
5
+ /** 연락처 이름이에요. */
6
+ name: string;
7
+ /** 연락처 전화번호로, 문자열 형식이에요. */
8
+ phoneNumber: string;
9
+ }
10
+ /**
11
+ * @public
12
+ * @tag AppsInTossModule
13
+ * @category AppsInTossModules
14
+ * @kind function
15
+ * @name fetchContacts
16
+ * @description 사용자의 연락처 목록을 페이지 단위로 가져오는 함수예요.
17
+ * @param size - 한 번에 가져올 연락처 개수예요. 예를 들어, 10을 전달하면 최대 10개의 연락처를 가져와요.
18
+ * @param offset - 가져올 연락처의 시작 지점이에요. 처음 호출할 때는 `0`을 전달해야 해요. 이후에는 이전 호출에서 반환된 `nextOffset` 값을 사용해요.
19
+ * @param query - 추가적인 필터링 옵션이에요.
20
+ * @param query.contains - 이름에 특정 문자열이 포함된 연락처만 가져오고 싶을 때 사용해요. 이 값을 전달하지 않으면 모든 연락처를 가져와요.
21
+ * @returns {Promise<{result: { name: string; phoneNumber: string }[]; nextOffset: number | null; done: boolean}>}
22
+ * 연락처 목록과 페이지네이션 정보를 포함한 객체를 반환해요.
23
+ * - `result`: 가져온 연락처 목록이에요.
24
+ * - `nextOffset`: 다음 호출에 사용할 오프셋 값이에요. 더 가져올 연락처가 없으면 `null`이에요.
25
+ * - `done`: 모든 연락처를 다 가져왔는지 여부를 나타내요. 모두 가져왔다면 `true`예요.
26
+ *
27
+ * @example
28
+ * ### 특정 문자열이 포함된 연락처 목록 가져오기
29
+ *
30
+ * ```tsx
31
+ * import React, { useState } from 'react';
32
+ *
33
+ * import { fetchContacts } from '@apps-in-toss/web-framework';
34
+ *
35
+ * // 특정 문자열을 포함한 연락처 목록을 가져와 화면에 표시하는 컴포넌트
36
+ * function ContactsList() {
37
+ * const [contacts, setContacts] = useState({
38
+ * result: [],
39
+ * nextOffset: null,
40
+ * done: false,
41
+ * });
42
+ *
43
+ * const handlePress = async () => {
44
+ * try {
45
+ * if (contacts.done) {
46
+ * console.log('모든 연락처를 가져왔어요.');
47
+ * return;
48
+ * }
49
+ *
50
+ * const response = await fetchContacts({
51
+ * size: 10,
52
+ * offset: contacts.nextOffset ?? 0,
53
+ * query: { contains: '홍길동' },
54
+ * });
55
+ * setContacts((prev) => ({
56
+ * result: [...prev.result, ...response.result],
57
+ * nextOffset: response.nextOffset,
58
+ * done: response.done,
59
+ * }));
60
+ * } catch (error) {
61
+ * console.error('연락처를 가져오는 데 실패했어요:', error);
62
+ * }
63
+ * };
64
+ *
65
+ * return (
66
+ * <div>
67
+ * {contacts.result.map((contact, index) => (
68
+ * <span key={index}>{contact.name}: {contact.phoneNumber}</span>
69
+ * ))}
70
+ * <input type="button"
71
+ * value={contacts.done ? '모든 연락처를 가져왔어요.' : '다음 연락처 가져오기'}
72
+ * disabled={contacts.done}
73
+ * onClick={handlePress}
74
+ * />
75
+ * </div>
76
+ * );
77
+ * }
78
+ * ```
79
+ */
80
+ export declare function fetchContacts({ size, offset, query, }: {
81
+ size: number;
82
+ offset: number;
83
+ query?: {
84
+ contains?: string;
85
+ };
86
+ }): Promise<{
87
+ result: ContactEntity[];
88
+ nextOffset: number | null;
89
+ done: boolean;
90
+ }>;
91
+
92
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @public
3
+ * @tag AppsInTossModule
4
+ * @category AppsInTossModules
5
+ * @kind function
6
+ * @name getClipboardText
7
+ * @description 클립보드에 저장된 텍스트를 가져오는 함수예요. 복사된 텍스트를 읽어서 다른 작업에 활용할 수 있어요.
8
+ * @returns {Promise<string>} - 클립보드에 저장된 텍스트를 반환해요. 클립보드에 텍스트가 없으면 빈 문자열을 반환해요.
9
+ *
10
+ * @example
11
+ * ### 클립보드의 텍스트 가져오기
12
+ *
13
+ * ```tsx
14
+ * import React, { useState } from 'react';
15
+ *
16
+ * import { getClipboardText } from '@apps-in-toss/web-framework';
17
+ *
18
+ * // '붙여넣기' 버튼을 누르면 클립보드에 저장된 텍스트를 가져와 화면에 표시해요.
19
+ * function PasteButton() {
20
+ * const [text, setText] = useState('');
21
+ *
22
+ * const handlePress = async () => {
23
+ * try {
24
+ * const clipboardText = await getClipboardText();
25
+ * setText(clipboardText || '클립보드에 텍스트가 없어요.');
26
+ * } catch (error) {
27
+ * console.error('클립보드에서 텍스트를 가져오지 못했어요:', error);
28
+ * }
29
+ * };
30
+ *
31
+ * return (
32
+ * <div>
33
+ * <span>{text}</span>
34
+ * <input type="button" value="붙여넣기" onClick={handlePress} />
35
+ * </div>
36
+ * );
37
+ * }
38
+ * ```
39
+ */
40
+ export declare function getClipboardText(): Promise<string>;
41
+
42
+ export {};
@@ -0,0 +1,109 @@
1
+ /**
2
+ * 위치 정확도 옵션이에요.
3
+ */
4
+ export enum Accuracy {
5
+ /**
6
+ * 오차범위 3KM 이내
7
+ */
8
+ Lowest = 1,
9
+ /**
10
+ * 오차범위 1KM 이내
11
+ */
12
+ Low,
13
+ /**
14
+ * 오차범위 몇 백미터 이내
15
+ */
16
+ Balanced,
17
+ /**
18
+ * 오차범위 10M 이내
19
+ */
20
+ High,
21
+ /**
22
+ * 가장 높은 정확도
23
+ */
24
+ Highest,
25
+ /**
26
+ * 네비게이션을 위한 최고 정확도
27
+ */
28
+ BestForNavigation
29
+ }
30
+ export interface Location {
31
+ /**
32
+ * Android에서만 지원하는 옵션이에요.
33
+ *
34
+ * - `FINE`: 정확한 위치
35
+ * - `COARSE`: 대략적인 위치
36
+ *
37
+ * @see https://developer.android.com/codelabs/approximate-location
38
+ */
39
+ accessLocation?: "FINE" | "COARSE";
40
+ /**
41
+ * 위치가 업데이트된 시점의 유닉스 타임스탬프예요.
42
+ */
43
+ timestamp: number;
44
+ coords: {
45
+ latitude: number; // 위도
46
+ longitude: number; // 경도
47
+ altitude: number; // 높이
48
+ accuracy: number; // 위치 정확도 (미터)
49
+ altitudeAccuracy: number; // 고도 정확도 (미터)
50
+ heading: number; // 방향 (북: 0°, 동: 90°, 남: 180°, 서: 270°)
51
+ };
52
+ }
53
+ export interface GetCurrentLocationOptions {
54
+ /**
55
+ * 위치 정보를 가져올 정확도 수준이에요.
56
+ */
57
+ accuracy: Accuracy;
58
+ }
59
+ /**
60
+ * @public
61
+ * @tag AppsInTossModule
62
+ * @category AppsInTossModules
63
+ * @kind function
64
+ * @name getCurrentLocation
65
+ * @description 디바이스의 현재 위치 정보를 가져오는 함수예요.
66
+ * 위치 기반 서비스를 구현할 때 사용되고, 한 번만 호출되어 현재 위치를 즉시 반환해요.
67
+ * 예를 들어 지도 앱에서 사용자의 현재 위치를 한 번만 가져올 때, 날씨 앱에서 사용자의 위치를 기반으로 기상 정보를 제공할 때, 매장 찾기 기능에서 사용자의 위치를 기준으로 가까운 매장을 검색할 때 사용하면 유용해요.
68
+ *
69
+ * @param {GetCurrentLocationOptions} options 위치 정보를 가져올 때 사용하는 옵션 객체예요.
70
+ * @param {Accuracy} [options.accuracy] 위치 정보의 정확도 수준이에요. 정확도는 `Accuracy` 타입으로 설정돼요.
71
+ * @returns {Promise<Location>} 디바이스의 위치 정보가 담긴 객체를 반환해요.
72
+ *
73
+ * @example
74
+ * ### 디바이스의 현재 위치 정보 가져오기
75
+ *
76
+ * ```tsx
77
+ * import React, { useState } from 'react';
78
+ *
79
+ * import { getCurrentLocation } from '@apps-in-toss/web-framework';
80
+ *
81
+ * // 현재 위치 정보를 가져와 화면에 표시하는 컴포넌트
82
+ * function CurrentPosition() {
83
+ * const [position, setPosition] = useState(null);
84
+ *
85
+ * const handlePress = async () => {
86
+ * try {
87
+ * const response = await getCurrentLocation({ accuracy: Accuracy.Balanced });
88
+ * setPosition(response);
89
+ * } catch (error) {
90
+ * console.error('위치 정보를 가져오는 데 실패했어요:', error);
91
+ * }
92
+ * };
93
+ *
94
+ * return (
95
+ * <div>
96
+ * {position ? (
97
+ * <span>위치: {position.coords.latitude}, {position.coords.longitude}</span>
98
+ * ) : (
99
+ * <span>위치 정보를 아직 가져오지 않았어요</span>
100
+ * )}
101
+ * <input type="button" value="현재 위치 정보 가져오기" onClick={handlePress} />
102
+ * </div>
103
+ * );
104
+ * }
105
+ * ```
106
+ */
107
+ export declare function getCurrentLocation(options: GetCurrentLocationOptions): Promise<Location>;
108
+
109
+ export {};