@apps-in-toss/web-framework 0.0.8 → 0.0.10
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/LICENSE +674 -0
- package/README.md +20 -0
- package/bin.js +2 -1
- package/dist/chunk-CH3CIAIW.js +7688 -0
- package/dist/chunk-DI2VGQ6M.js +53 -0
- package/dist/chunk-HL7M3JLX.js +53 -0
- package/dist/chunk-I3ZDGLIW.js +19 -0
- package/dist/chunk-LJBVSTWE.js +7687 -0
- package/dist/chunk-TZCMTMV7.js +38 -0
- package/dist/{chunk-MHAJE5QI.js → cli/chunk-HDRFXOPA.js} +30 -1
- package/dist/cli/chunk-RUDG2MMT.js +173587 -0
- package/dist/cli/index.cjs +644 -0
- package/dist/cli/index.d.cts +2 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +96448 -0
- package/dist/{lib-EUN4APCZ.js → cli/lib-NMFBQRQ2.js} +1 -1
- package/dist/cli/typescript-THSIDFIK.js +6 -0
- package/dist/cli.cjs +480 -4518
- package/dist/cli.d.cts +1 -2
- package/dist/cli.d.ts +1 -2
- package/dist/cli.js +446 -3492
- package/dist/closeView.d.ts +24 -0
- package/dist/config/index.d.ts +47 -60
- package/dist/config/index.js +6 -7974
- package/dist/fetchAlbumPhotos.d.ts +75 -0
- package/dist/fetchContacts.d.ts +92 -0
- package/dist/generateHapticFeedback.d.ts +52 -0
- package/dist/getClipboardText.d.ts +42 -0
- package/dist/getCurrentLocation.d.ts +109 -0
- package/dist/getDeviceId.d.ts +32 -0
- package/dist/getLocale.d.ts +31 -0
- package/dist/getNetworkStatus.d.ts +55 -0
- package/dist/getSchemeUri.d.ts +26 -0
- package/dist/index.cjs +18 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +1 -0
- package/dist/openCamera.d.ts +75 -0
- package/dist/plugins/index.cjs +7682 -0
- package/dist/plugins/index.d.cts +15 -0
- package/dist/plugins/index.d.ts +15 -0
- package/dist/plugins/index.js +11 -0
- package/dist/prebuilt/dev.android.js +155792 -0
- package/dist/prebuilt/dev.ios.js +155733 -0
- package/dist/prebuilt/prod.android.js +20 -0
- package/dist/prebuilt/prod.ios.js +20 -0
- package/dist/prebuilt/prod.json +14 -0
- package/dist/setClipboardText.d.ts +34 -0
- package/dist/setScreenAwakeMode.d.ts +69 -0
- package/dist/setSecureScreen.d.ts +34 -0
- package/dist/share.d.ts +37 -0
- package/dist/startUpdateLocation.d.ts +151 -0
- package/hermesc/0_72_6/linux64-bin/hermesc +0 -0
- package/hermesc/0_72_6/osx-bin/hermesc +0 -0
- package/hermesc/0_72_6/win64-bin/hermesc.exe +0 -0
- package/hermesc/0_72_6/win64-bin/icudt64.dll +0 -0
- package/hermesc/0_72_6/win64-bin/icuin64.dll +0 -0
- package/hermesc/0_72_6/win64-bin/icuio64.dll +0 -0
- package/hermesc/0_72_6/win64-bin/icutest64.dll +0 -0
- package/hermesc/0_72_6/win64-bin/icutu64.dll +0 -0
- package/hermesc/0_72_6/win64-bin/icuuc64.dll +0 -0
- package/hermesc/0_72_6/win64-bin/msvcp140.dll +0 -0
- package/hermesc/0_72_6/win64-bin/vcruntime140.dll +0 -0
- package/hermesc/0_72_6/win64-bin/vcruntime140_1.dll +0 -0
- package/package.json +52 -29
- package/src-web/appLogin.d.ts +30 -0
- package/src-web/closeView.d.ts +1 -2
- package/src-web/fetchAlbumPhotos.d.ts +2 -4
- package/src-web/fetchContacts.d.ts +1 -3
- package/src-web/generateHapticFeedback.d.ts +24 -27
- package/src-web/getClipboardText.d.ts +1 -3
- package/src-web/getCurrentLocation.d.ts +48 -13
- package/src-web/getDeviceId.d.ts +1 -2
- package/src-web/getLocale.d.ts +1 -2
- package/src-web/getNetworkStatus.d.ts +1 -2
- package/src-web/getOperationalEnvironment.d.ts +35 -0
- package/src-web/getPlatformOS.d.ts +28 -0
- package/src-web/getSchemeUri.d.ts +1 -2
- package/src-web/index.d.ts +3 -0
- package/src-web/index.js +1 -1
- package/src-web/openCamera.d.ts +1 -3
- package/src-web/setClipboardText.d.ts +1 -3
- package/src-web/setScreenAwakeMode.d.ts +1 -2
- package/src-web/setSecureScreen.d.ts +1 -2
- package/src-web/share.d.ts +1 -2
- package/src-web/startUpdateLocation.d.ts +45 -13
- package/dist/chunk-5AYTRYXW.js +0 -27
- package/dist/lib-OD73GAMK.js +0 -1007
- package/react-native/.babelrc +0 -41
- package/react-native/ait.d.ts +0 -8
- package/react-native/context.ts +0 -10
- package/react-native/index.ts +0 -4
- package/react-native/pages/_404.tsx +0 -1
- package/react-native/pages/index.tsx +0 -10
- package/react-native/react-native.config.cjs +0 -3
- package/react-native/src/_app.tsx +0 -12
|
@@ -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,52 @@
|
|
|
1
|
+
export type HapticFeedbackType = "tickWeak" | "tap" | "tickMedium" | "softMedium" | "basicWeak" | "basicMedium" | "success" | "error" | "wiggle" | "confetti";
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
* @tag HapticFeedbackType
|
|
5
|
+
* @category Types
|
|
6
|
+
* @name HapticFeedbackOptions
|
|
7
|
+
* @description
|
|
8
|
+
* generateHapticFeedback 함수에 전달할 햅틱진동의 타입을 나타내요. 진동타입의 종류는 다음과 같아요.
|
|
9
|
+
* ```typescript
|
|
10
|
+
* type HapticFeedbackType =
|
|
11
|
+
* | "tickWeak"
|
|
12
|
+
* | "tap"
|
|
13
|
+
* | "tickMedium"
|
|
14
|
+
* | "softMedium"
|
|
15
|
+
* | "basicWeak"
|
|
16
|
+
* | "basicMedium"
|
|
17
|
+
* | "success"
|
|
18
|
+
* | "error"
|
|
19
|
+
* | "wiggle"
|
|
20
|
+
* | "confetti";
|
|
21
|
+
* ```
|
|
22
|
+
* @typedef { type: HapticFeedbackType } HapticFeedbackOptions
|
|
23
|
+
* @typedef { "tickWeak" | "tap" | "tickMedium" | "softMedium" | "basicWeak" | "basicMedium" | "success" | "error" | "wiggle" | "confetti" } HapticFeedbackType
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
export interface HapticFeedbackOptions {
|
|
27
|
+
type: HapticFeedbackType;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @public
|
|
31
|
+
* @tag BedrockModule
|
|
32
|
+
* @category BedrockModules
|
|
33
|
+
* @kind function
|
|
34
|
+
* @name generateHapticFeedback
|
|
35
|
+
* @description 디바이스에 햅틱 진동을 일으키는 함수예요. 예를 들어, 버튼 터치나 화면전환에 드라마틱한 효과를 주고 싶을 때 사용할 수 있어요. [HapticFeedbackOptions](../Types/HapticFeedbackOptions.html)에서 진동타입을 확인해 보세요.
|
|
36
|
+
* @returns {void}
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ### 버튼을 눌러 햅틱 일으키기
|
|
40
|
+
*
|
|
41
|
+
* ```tsx
|
|
42
|
+
*
|
|
43
|
+
* import { generateHapticFeedback } from '@apps-in-toss/web-framework';
|
|
44
|
+
*
|
|
45
|
+
* function GenerateHapticFeedback() {
|
|
46
|
+
* return <input type="button" value="햅틱" onClick={() => { generateHapticFeedback( { type: "tickWeak"}) }} />;
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function generateHapticFeedback(options: HapticFeedbackOptions): Promise<void>;
|
|
51
|
+
|
|
52
|
+
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 {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @public
|
|
3
|
+
* @tag BedrockModule
|
|
4
|
+
* @category BedrockModules
|
|
5
|
+
* @kind function
|
|
6
|
+
* @name getDeviceId
|
|
7
|
+
* @description
|
|
8
|
+
* 사용 중인 기기의 고유 식별자를 문자열로 반환해요.
|
|
9
|
+
*
|
|
10
|
+
* 이 함수는 현재 사용 중인 기기의 고유 식별자를 문자열로 반환해요. 기기별로 설정이나 데이터를 저장하거나 사용자의 기기를 식별해서 로그를 기록하고 분석하는 데 사용할 수 있어요. 같은 사용자의 여러 기기를 구분하는 데도 유용해요.
|
|
11
|
+
*
|
|
12
|
+
* @returns {string} 기기의 고유 식별자를 나타내는 문자열이에요.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ### 기기 고유 식별자 가져오기
|
|
16
|
+
*
|
|
17
|
+
* ```tsx
|
|
18
|
+
* import { getDeviceId } from '@apps-in-toss/web-framework';
|
|
19
|
+
*
|
|
20
|
+
*
|
|
21
|
+
* function MyPage() {
|
|
22
|
+
* const id = getDeviceId();
|
|
23
|
+
*
|
|
24
|
+
* return (
|
|
25
|
+
* <span>사용자의 기기 고유 식별자: {id}</span>
|
|
26
|
+
* );
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function getDeviceId(): string;
|
|
31
|
+
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @public
|
|
3
|
+
* @tag BedrockModule
|
|
4
|
+
* @category BedrockModules
|
|
5
|
+
* @kind function
|
|
6
|
+
* @name getLocale
|
|
7
|
+
* @description
|
|
8
|
+
* 사용자의 로케일(locale) 정보를 반환해요. 네이티브 모듈에서 로케일 정보를 가져올 수 없을 때는 기본값으로 'ko-KR'을 반환합니다. 앱의 현지화 및 언어 설정과 관련된 기능을 구현할 때 사용하세요.
|
|
9
|
+
*
|
|
10
|
+
* @returns {string} 사용자의 로케일 정보를 반환해요.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ### 현재 사용자의 로케일 정보 가져오기
|
|
14
|
+
*
|
|
15
|
+
* ```tsx
|
|
16
|
+
* import { getLocale } from '@apps-in-toss/web-framework';
|
|
17
|
+
*
|
|
18
|
+
*
|
|
19
|
+
* function MyPage() {
|
|
20
|
+
* const locale = getLocale();
|
|
21
|
+
*
|
|
22
|
+
* return (
|
|
23
|
+
* <span>사용자의 로케일 정보: {locale}</span>
|
|
24
|
+
* )
|
|
25
|
+
* }
|
|
26
|
+
*
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function getLocale(): string;
|
|
30
|
+
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export type NetworkStatus = "OFFLINE" | "WIFI" | "2G" | "3G" | "4G" | "5G" | "WWAN" | "UNKNOWN";
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
* @tag BedrockModule
|
|
5
|
+
* @category BedrockModules
|
|
6
|
+
* @kind function
|
|
7
|
+
* @name getNetworkStatus
|
|
8
|
+
* @description
|
|
9
|
+
* 디바이스의 현재 네트워크 연결 상태를 가져오는 함수예요.
|
|
10
|
+
* 반환 값은 `NetworkStatus` 타입으로, 인터넷 연결 여부와 연결 유형(Wi-Fi, 모바일 데이터 등)을 나타내요. 값은 다음 중 하나예요.
|
|
11
|
+
*
|
|
12
|
+
* - `OFFLINE`: 인터넷에 연결되지 않은 상태예요.
|
|
13
|
+
* - `WIFI`: Wi-Fi에 연결된 상태예요.
|
|
14
|
+
* - `2G`: 2G 네트워크에 연결된 상태예요.
|
|
15
|
+
* - `3G`: 3G 네트워크에 연결된 상태예요.
|
|
16
|
+
* - `4G`: 4G 네트워크에 연결된 상태예요.
|
|
17
|
+
* - `5G`: 5G 네트워크에 연결된 상태예요.
|
|
18
|
+
* - `WWAN`: 인터넷은 연결되었지만, 연결 유형(Wi-Fi, 2G~5G)을 알 수 없는 상태예요. 이 상태는 iOS에서만 확인할 수 있어요.
|
|
19
|
+
* - `UNKNOWN`: 인터넷 연결 상태를 알 수 없는 상태예요. 이 상태는 안드로이드에서만 확인할 수 있어요.
|
|
20
|
+
*
|
|
21
|
+
* @returns {Promise<NetworkStatus>} 네트워크 상태를 반환해요.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ### 현재 네트워크 상태 가져오기
|
|
25
|
+
*
|
|
26
|
+
* 네트워크 연결 상태를 가져와 화면에 표시하는 예제예요.
|
|
27
|
+
*
|
|
28
|
+
* ```tsx
|
|
29
|
+
* import { useState, useEffect } from 'react';
|
|
30
|
+
*
|
|
31
|
+
* import { getNetworkStatus, NetworkStatus } from '@apps-in-toss/web-framework';
|
|
32
|
+
*
|
|
33
|
+
* function GetNetworkStatus() {
|
|
34
|
+
* const [status, setStatus] = useState<NetworkStatus | ''>('');
|
|
35
|
+
*
|
|
36
|
+
* useEffect(() => {
|
|
37
|
+
* async function fetchStatus() {
|
|
38
|
+
* const networkStatus = await getNetworkStatus();
|
|
39
|
+
* setStatus(networkStatus);
|
|
40
|
+
* }
|
|
41
|
+
*
|
|
42
|
+
* fetchStatus();
|
|
43
|
+
* }, []);
|
|
44
|
+
*
|
|
45
|
+
* return (
|
|
46
|
+
* <div>
|
|
47
|
+
* <span>현재 네트워크 상태: {status}</span>
|
|
48
|
+
* </div>
|
|
49
|
+
* );
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function getNetworkStatus(): Promise<NetworkStatus>;
|
|
54
|
+
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @public
|
|
3
|
+
* @name getSchemeUri
|
|
4
|
+
* @tag BedrockModule
|
|
5
|
+
* @category BedrockModules
|
|
6
|
+
* @kind function
|
|
7
|
+
* @description 처음에 화면에 진입한 스킴 값이에요. 페이지 이동으로 인한 URI 변경은 반영되지 않아요.
|
|
8
|
+
* @returns {string} 처음에 화면에 진입한 스킴 값을 반환해요.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ### 처음 진입한 스킴 값 가져오기
|
|
12
|
+
*
|
|
13
|
+
* ```tsx
|
|
14
|
+
* import { getSchemeUri } from '@apps-in-toss/web-framework';
|
|
15
|
+
*
|
|
16
|
+
*
|
|
17
|
+
* function MyPage() {
|
|
18
|
+
* const schemeUri = getSchemeUri();
|
|
19
|
+
*
|
|
20
|
+
* return <span>처음에 화면에 진입한 스킴 값: {schemeUri}</span>
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function getSchemeUri(): string;
|
|
25
|
+
|
|
26
|
+
export {};
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/index.ts
|
|
17
|
+
var src_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(src_exports);
|
package/dist/index.d.cts
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from './closeView';
|
|
2
|
+
export * from './generateHapticFeedback';
|
|
3
|
+
export * from './share';
|
|
4
|
+
export * from './setSecureScreen';
|
|
5
|
+
export * from './setScreenAwakeMode';
|
|
6
|
+
export * from './getNetworkStatus';
|
|
7
|
+
export * from './getLocale';
|
|
8
|
+
export * from './getSchemeUri';
|
|
9
|
+
export * from './getDeviceId';
|
|
10
|
+
export * from './setClipboardText';
|
|
11
|
+
export * from './getClipboardText';
|
|
12
|
+
export * from './fetchContacts';
|
|
13
|
+
export * from './fetchAlbumPhotos';
|
|
14
|
+
export * from './getCurrentLocation';
|
|
15
|
+
export * from './openCamera';
|
|
16
|
+
export * from './startUpdateLocation';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const createEvents=()=>({emit(event,args){for(let callbacks=this.events[event]||[],i=0,length=callbacks.length;i<length;i++){callbacks[i](args)}},events:{},on(event,cb){var _this_events,_event;((_this_events=this.events)[_event=event]||(_this_events[_event]=[])).push(cb);return()=>{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(i=>cb!==i)}}});const createEventId=()=>Math.random().toString(36).substring(2,15);const deserializeError=value=>{if(value&&value.__isError){const err=new Error(value.message);err.name=value.name;err.stack=value.stack;return err}return value};window.__BEDROCK_NATIVE_EMITTER=createEvents();export function closeView(...args){if(!window.ReactNativeWebView){throw new Error("This closeView is not available in browser environment")}const eventId=createEventId();const emitters=[];const unsubscribe=()=>{for(const emitter of emitters){emitter()}};return new Promise((resolve,reject)=>{emitters.push(window.__BEDROCK_NATIVE_EMITTER.on(`closeView/resolve/${eventId}`,args=>{unsubscribe();resolve(args)}));emitters.push(window.__BEDROCK_NATIVE_EMITTER.on(`closeView/reject/${eventId}`,error=>{unsubscribe();reject(deserializeError(error))}));window.ReactNativeWebView.postMessage(JSON.stringify({type:"method",functionName:"closeView",eventId,args}))})}export function generateHapticFeedback(...args){if(!window.ReactNativeWebView){throw new Error("This generateHapticFeedback is not available in browser environment")}const eventId=createEventId();const emitters=[];const unsubscribe=()=>{for(const emitter of emitters){emitter()}};return new Promise((resolve,reject)=>{emitters.push(window.__BEDROCK_NATIVE_EMITTER.on(`generateHapticFeedback/resolve/${eventId}`,args=>{unsubscribe();resolve(args)}));emitters.push(window.__BEDROCK_NATIVE_EMITTER.on(`generateHapticFeedback/reject/${eventId}`,error=>{unsubscribe();reject(deserializeError(error))}));window.ReactNativeWebView.postMessage(JSON.stringify({type:"method",functionName:"generateHapticFeedback",eventId,args}))})}export function share(...args){if(!window.ReactNativeWebView){throw new Error("This share is not available in browser environment")}const eventId=createEventId();const emitters=[];const unsubscribe=()=>{for(const emitter of emitters){emitter()}};return new Promise((resolve,reject)=>{emitters.push(window.__BEDROCK_NATIVE_EMITTER.on(`share/resolve/${eventId}`,args=>{unsubscribe();resolve(args)}));emitters.push(window.__BEDROCK_NATIVE_EMITTER.on(`share/reject/${eventId}`,error=>{unsubscribe();reject(deserializeError(error))}));window.ReactNativeWebView.postMessage(JSON.stringify({type:"method",functionName:"share",eventId,args}))})}export function setSecureScreen(...args){if(!window.ReactNativeWebView){throw new Error("This setSecureScreen is not available in browser environment")}const eventId=createEventId();const emitters=[];const unsubscribe=()=>{for(const emitter of emitters){emitter()}};return new Promise((resolve,reject)=>{emitters.push(window.__BEDROCK_NATIVE_EMITTER.on(`setSecureScreen/resolve/${eventId}`,args=>{unsubscribe();resolve(args)}));emitters.push(window.__BEDROCK_NATIVE_EMITTER.on(`setSecureScreen/reject/${eventId}`,error=>{unsubscribe();reject(deserializeError(error))}));window.ReactNativeWebView.postMessage(JSON.stringify({type:"method",functionName:"setSecureScreen",eventId,args}))})}export function setScreenAwakeMode(...args){if(!window.ReactNativeWebView){throw new Error("This setScreenAwakeMode is not available in browser environment")}const eventId=createEventId();const emitters=[];const unsubscribe=()=>{for(const emitter of emitters){emitter()}};return new Promise((resolve,reject)=>{emitters.push(window.__BEDROCK_NATIVE_EMITTER.on(`setScreenAwakeMode/resolve/${eventId}`,args=>{unsubscribe();resolve(args)}));emitters.push(window.__BEDROCK_NATIVE_EMITTER.on(`setScreenAwakeMode/reject/${eventId}`,error=>{unsubscribe();reject(deserializeError(error))}));window.ReactNativeWebView.postMessage(JSON.stringify({type:"method",functionName:"setScreenAwakeMode",eventId,args}))})}export function getNetworkStatus(...args){if(!window.ReactNativeWebView){throw new Error("This getNetworkStatus is not available in browser environment")}const eventId=createEventId();const emitters=[];const unsubscribe=()=>{for(const emitter of emitters){emitter()}};return new Promise((resolve,reject)=>{emitters.push(window.__BEDROCK_NATIVE_EMITTER.on(`getNetworkStatus/resolve/${eventId}`,args=>{unsubscribe();resolve(args)}));emitters.push(window.__BEDROCK_NATIVE_EMITTER.on(`getNetworkStatus/reject/${eventId}`,error=>{unsubscribe();reject(deserializeError(error))}));window.ReactNativeWebView.postMessage(JSON.stringify({type:"method",functionName:"getNetworkStatus",eventId,args}))})}export function getLocale(){if(!window.ReactNativeWebView){throw new Error("This getLocale is not available in browser environment")}if("getLocale"in window.__CONSTANT_HANDLER_MAP){return window.__CONSTANT_HANDLER_MAP["getLocale"]}throw new Error("getLocale is not a constant handler")}export function getSchemeUri(){if(!window.ReactNativeWebView){throw new Error("This getSchemeUri is not available in browser environment")}if("getSchemeUri"in window.__CONSTANT_HANDLER_MAP){return window.__CONSTANT_HANDLER_MAP["getSchemeUri"]}throw new Error("getSchemeUri is not a constant handler")}export function getDeviceId(){if(!window.ReactNativeWebView){throw new Error("This getDeviceId is not available in browser environment")}if("getDeviceId"in window.__CONSTANT_HANDLER_MAP){return window.__CONSTANT_HANDLER_MAP["getDeviceId"]}throw new Error("getDeviceId is not a constant handler")}export function setClipboardText(...args){if(!window.ReactNativeWebView){throw new Error("This setClipboardText is not available in browser environment")}const eventId=createEventId();const emitters=[];const unsubscribe=()=>{for(const emitter of emitters){emitter()}};return new Promise((resolve,reject)=>{emitters.push(window.__BEDROCK_NATIVE_EMITTER.on(`setClipboardText/resolve/${eventId}`,args=>{unsubscribe();resolve(args)}));emitters.push(window.__BEDROCK_NATIVE_EMITTER.on(`setClipboardText/reject/${eventId}`,error=>{unsubscribe();reject(deserializeError(error))}));window.ReactNativeWebView.postMessage(JSON.stringify({type:"method",functionName:"setClipboardText",eventId,args}))})}export function getClipboardText(...args){if(!window.ReactNativeWebView){throw new Error("This getClipboardText is not available in browser environment")}const eventId=createEventId();const emitters=[];const unsubscribe=()=>{for(const emitter of emitters){emitter()}};return new Promise((resolve,reject)=>{emitters.push(window.__BEDROCK_NATIVE_EMITTER.on(`getClipboardText/resolve/${eventId}`,args=>{unsubscribe();resolve(args)}));emitters.push(window.__BEDROCK_NATIVE_EMITTER.on(`getClipboardText/reject/${eventId}`,error=>{unsubscribe();reject(deserializeError(error))}));window.ReactNativeWebView.postMessage(JSON.stringify({type:"method",functionName:"getClipboardText",eventId,args}))})}export function fetchContacts(...args){if(!window.ReactNativeWebView){throw new Error("This fetchContacts is not available in browser environment")}const eventId=createEventId();const emitters=[];const unsubscribe=()=>{for(const emitter of emitters){emitter()}};return new Promise((resolve,reject)=>{emitters.push(window.__BEDROCK_NATIVE_EMITTER.on(`fetchContacts/resolve/${eventId}`,args=>{unsubscribe();resolve(args)}));emitters.push(window.__BEDROCK_NATIVE_EMITTER.on(`fetchContacts/reject/${eventId}`,error=>{unsubscribe();reject(deserializeError(error))}));window.ReactNativeWebView.postMessage(JSON.stringify({type:"method",functionName:"fetchContacts",eventId,args}))})}export function fetchAlbumPhotos(...args){if(!window.ReactNativeWebView){throw new Error("This fetchAlbumPhotos is not available in browser environment")}const eventId=createEventId();const emitters=[];const unsubscribe=()=>{for(const emitter of emitters){emitter()}};return new Promise((resolve,reject)=>{emitters.push(window.__BEDROCK_NATIVE_EMITTER.on(`fetchAlbumPhotos/resolve/${eventId}`,args=>{unsubscribe();resolve(args)}));emitters.push(window.__BEDROCK_NATIVE_EMITTER.on(`fetchAlbumPhotos/reject/${eventId}`,error=>{unsubscribe();reject(deserializeError(error))}));window.ReactNativeWebView.postMessage(JSON.stringify({type:"method",functionName:"fetchAlbumPhotos",eventId,args}))})}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}({});export function getCurrentLocation(...args){if(!window.ReactNativeWebView){throw new Error("This getCurrentLocation is not available in browser environment")}const eventId=createEventId();const emitters=[];const unsubscribe=()=>{for(const emitter of emitters){emitter()}};return new Promise((resolve,reject)=>{emitters.push(window.__BEDROCK_NATIVE_EMITTER.on(`getCurrentLocation/resolve/${eventId}`,args=>{unsubscribe();resolve(args)}));emitters.push(window.__BEDROCK_NATIVE_EMITTER.on(`getCurrentLocation/reject/${eventId}`,error=>{unsubscribe();reject(deserializeError(error))}));window.ReactNativeWebView.postMessage(JSON.stringify({type:"method",functionName:"getCurrentLocation",eventId,args}))})}export function openCamera(...args){if(!window.ReactNativeWebView){throw new Error("This openCamera is not available in browser environment")}const eventId=createEventId();const emitters=[];const unsubscribe=()=>{for(const emitter of emitters){emitter()}};return new Promise((resolve,reject)=>{emitters.push(window.__BEDROCK_NATIVE_EMITTER.on(`openCamera/resolve/${eventId}`,args=>{unsubscribe();resolve(args)}));emitters.push(window.__BEDROCK_NATIVE_EMITTER.on(`openCamera/reject/${eventId}`,error=>{unsubscribe();reject(deserializeError(error))}));window.ReactNativeWebView.postMessage(JSON.stringify({type:"method",functionName:"openCamera",eventId,args}))})}export function startUpdateLocation({onEvent,onError,options}){if(!window.ReactNativeWebView){onError(new Error("This startUpdateLocation is not available in browser environment"));return()=>{}}const eventId=createEventId();const removes=[window.__BEDROCK_NATIVE_EMITTER.on(`startUpdateLocation/onEvent/${eventId}`,response=>{onEvent(response)}),window.__BEDROCK_NATIVE_EMITTER.on(`startUpdateLocation/onError/${eventId}`,error=>{onError(deserializeError(error))})];window.ReactNativeWebView.postMessage(JSON.stringify({type:"addEventListener",functionName:"startUpdateLocation",eventId,args:options}));return()=>{window.ReactNativeWebView.postMessage(JSON.stringify({type:"removeEventListener",functionName:"startUpdateLocation",eventId}));for(const remove of removes){remove()}}}
|
|
@@ -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
|
+
export interface OpenCameraOptions {
|
|
11
|
+
/**
|
|
12
|
+
* 이미지를 Base64 형식으로 반환할지 여부를 나타내는 불리언 값이에요.
|
|
13
|
+
*
|
|
14
|
+
* 기본값: `false`.
|
|
15
|
+
*/
|
|
16
|
+
base64?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* 이미지의 최대 너비를 나타내는 숫자 값이에요.
|
|
19
|
+
*
|
|
20
|
+
* 기본값: `1024`.
|
|
21
|
+
*/
|
|
22
|
+
maxWidth?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @public
|
|
26
|
+
* @tag AppsInTossModule
|
|
27
|
+
* @category AppsInTossModules
|
|
28
|
+
* @kind function
|
|
29
|
+
* @name openCamera
|
|
30
|
+
* @description 카메라를 실행해서 촬영된 이미지를 반환하는 함수예요.
|
|
31
|
+
* @param {OpenCameraOptions} options - 카메라 실행 시 사용되는 옵션 객체예요.
|
|
32
|
+
* @param {boolean} [options.base64=false] - 이미지를 Base64 형식으로 반환할지 여부를 나타내는 불리언 값이에요. 기본값은 `false`예요. `true`로 설정하면 `dataUri` 대신 Base64 인코딩된 문자열을 반환해요.
|
|
33
|
+
* @param {number} [options.maxWidth=1024] - 이미지의 최대 너비를 나타내는 숫자 값이에요. 기본값은 `1024`예요.
|
|
34
|
+
* @returns {Promise<ImageResponse>}
|
|
35
|
+
* 촬영된 이미지 정보를 포함한 객체를 반환해요. 반환 객체의 구성은 다음과 같아요:
|
|
36
|
+
* - `id`: 이미지의 고유 식별자예요.
|
|
37
|
+
* - `dataUri`: 이미지 데이터를 표현하는 데이터 URI예요.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ### 카메라 실행 후 촬영된 사진 가져오기
|
|
41
|
+
*
|
|
42
|
+
* ```tsx
|
|
43
|
+
* import React, { useState } from 'react';
|
|
44
|
+
*
|
|
45
|
+
* import { openCamera } from '@apps-in-toss/web-framework';
|
|
46
|
+
*
|
|
47
|
+
* // 카메라를 실행하고 촬영된 이미지를 화면에 표시하는 컴포넌트
|
|
48
|
+
* function Camera() {
|
|
49
|
+
* const [image, setImage] = useState(null);
|
|
50
|
+
*
|
|
51
|
+
* const handlePress = async () => {
|
|
52
|
+
* try {
|
|
53
|
+
* const response = await openCamera({ base64: true });
|
|
54
|
+
* setImage(response);
|
|
55
|
+
* } catch (error) {
|
|
56
|
+
* console.error('사진을 가져오는 데 실패했어요:', error);
|
|
57
|
+
* }
|
|
58
|
+
* };
|
|
59
|
+
*
|
|
60
|
+
* return (
|
|
61
|
+
* <div>
|
|
62
|
+
* {image ? (
|
|
63
|
+
* <img src={`data:image/jpeg;base64,${image.dataUri}`} style={{ width: 200, height: 200 }} />
|
|
64
|
+
* ) : (
|
|
65
|
+
* <span>사진이 없어요</span>
|
|
66
|
+
* )}
|
|
67
|
+
* <input type="button" value="사진 촬영하기" onClick={handlePress} />
|
|
68
|
+
* </div>
|
|
69
|
+
* );
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare function openCamera(options?: OpenCameraOptions): Promise<ImageResponse>;
|
|
74
|
+
|
|
75
|
+
export {};
|