@apps-in-toss/web-framework 0.0.0-dev.1739416338672 → 0.0.0-dev.1740737494440
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/ait.js +3 -0
- package/bin.js +2 -1
- package/config.d.ts +1 -0
- package/dist/{chunk-EFYYFBU5.js → chunk-DI2VGQ6M.js} +3 -2
- package/dist/chunk-I3ZDGLIW.js +19 -0
- package/dist/chunk-LJBVSTWE.js +7687 -0
- package/dist/chunk-TZCMTMV7.js +38 -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 +592 -0
- package/dist/cli.cjs +14 -78
- package/dist/cli.js +15 -78
- package/dist/closeView.d.ts +1 -0
- package/dist/config/index.cjs +7962 -0
- package/dist/config/index.d.cts +57 -0
- package/dist/config/index.d.ts +57 -0
- package/dist/config/index.js +290 -0
- package/dist/fetchAlbumPhotos.d.ts +75 -0
- package/dist/fetchContacts.d.ts +92 -0
- package/dist/generateHapticFeedback.d.ts +1 -0
- package/dist/getClipboardText.d.ts +42 -0
- package/dist/getCurrentLocation.d.ts +109 -0
- package/dist/getDeviceId.d.ts +1 -0
- package/dist/getLocale.d.ts +1 -0
- package/dist/getNetworkStatus.d.ts +1 -0
- package/dist/getSchemeUri.d.ts +1 -0
- package/dist/index.cjs +0 -45
- package/dist/index.d.cts +1 -53
- package/dist/index.d.ts +16 -54
- package/dist/index.js +1 -9
- package/dist/openCamera.d.ts +75 -0
- package/dist/plugins/index.cjs +7681 -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/setClipboardText.d.ts +34 -0
- package/dist/setScreenAwakeMode.d.ts +1 -0
- package/dist/setSecureScreen.d.ts +1 -0
- package/dist/share.d.ts +1 -0
- package/dist/startUpdateLocation.d.ts +151 -0
- package/package.json +21 -18
- package/react-native/react-native.config.cjs +0 -2
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.cjs
CHANGED
|
@@ -3,10 +3,6 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
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
6
|
var __copyProps = (to, from, except, desc) => {
|
|
11
7
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
8
|
for (let key of __getOwnPropNames(from))
|
|
@@ -19,45 +15,4 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
15
|
|
|
20
16
|
// src/index.ts
|
|
21
17
|
var src_exports = {};
|
|
22
|
-
__export(src_exports, {
|
|
23
|
-
defineConfig: () => defineConfig,
|
|
24
|
-
loadConfig: () => loadConfig
|
|
25
|
-
});
|
|
26
18
|
module.exports = __toCommonJS(src_exports);
|
|
27
|
-
|
|
28
|
-
// src/defineConfig.ts
|
|
29
|
-
var import_zod = require("zod");
|
|
30
|
-
var AppsInTossConfigSchema = import_zod.z.object({
|
|
31
|
-
appName: import_zod.z.string(),
|
|
32
|
-
web: import_zod.z.object({
|
|
33
|
-
port: import_zod.z.number(),
|
|
34
|
-
commands: import_zod.z.object({
|
|
35
|
-
dev: import_zod.z.string(),
|
|
36
|
-
build: import_zod.z.string()
|
|
37
|
-
})
|
|
38
|
-
})
|
|
39
|
-
});
|
|
40
|
-
var defineConfig = (config) => {
|
|
41
|
-
return AppsInTossConfigSchema.parse(config);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
// src/loadConfig.ts
|
|
45
|
-
var import_cosmiconfig = require("cosmiconfig");
|
|
46
|
-
var import_cosmiconfig_typescript_loader = require("cosmiconfig-typescript-loader");
|
|
47
|
-
var loadConfig = async () => {
|
|
48
|
-
const explorer = (0, import_cosmiconfig.cosmiconfig)("apps-in-toss", {
|
|
49
|
-
searchPlaces: ["apps-in-toss.config.web.ts", "apps-in-toss.config.web.mts"],
|
|
50
|
-
loaders: {
|
|
51
|
-
".ts": (0, import_cosmiconfig_typescript_loader.TypeScriptLoader)(),
|
|
52
|
-
".mts": (0, import_cosmiconfig_typescript_loader.TypeScriptLoader)()
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
const result = await explorer.search(process.cwd());
|
|
56
|
-
const config = defineConfig(result?.config ?? {});
|
|
57
|
-
return config;
|
|
58
|
-
};
|
|
59
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
-
0 && (module.exports = {
|
|
61
|
-
defineConfig,
|
|
62
|
-
loadConfig
|
|
63
|
-
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,54 +1,2 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
|
|
3
|
-
|
|
4
|
-
appName: z.ZodString;
|
|
5
|
-
web: z.ZodObject<{
|
|
6
|
-
port: z.ZodNumber;
|
|
7
|
-
commands: z.ZodObject<{
|
|
8
|
-
dev: z.ZodString;
|
|
9
|
-
build: z.ZodString;
|
|
10
|
-
}, "strip", z.ZodTypeAny, {
|
|
11
|
-
dev: string;
|
|
12
|
-
build: string;
|
|
13
|
-
}, {
|
|
14
|
-
dev: string;
|
|
15
|
-
build: string;
|
|
16
|
-
}>;
|
|
17
|
-
}, "strip", z.ZodTypeAny, {
|
|
18
|
-
port: number;
|
|
19
|
-
commands: {
|
|
20
|
-
dev: string;
|
|
21
|
-
build: string;
|
|
22
|
-
};
|
|
23
|
-
}, {
|
|
24
|
-
port: number;
|
|
25
|
-
commands: {
|
|
26
|
-
dev: string;
|
|
27
|
-
build: string;
|
|
28
|
-
};
|
|
29
|
-
}>;
|
|
30
|
-
}, "strip", z.ZodTypeAny, {
|
|
31
|
-
appName: string;
|
|
32
|
-
web: {
|
|
33
|
-
port: number;
|
|
34
|
-
commands: {
|
|
35
|
-
dev: string;
|
|
36
|
-
build: string;
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
}, {
|
|
40
|
-
appName: string;
|
|
41
|
-
web: {
|
|
42
|
-
port: number;
|
|
43
|
-
commands: {
|
|
44
|
-
dev: string;
|
|
45
|
-
build: string;
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
}>;
|
|
49
|
-
type AppsInTossConfig = z.infer<typeof AppsInTossConfigSchema>;
|
|
50
|
-
declare const defineConfig: (config: z.input<typeof AppsInTossConfigSchema>) => AppsInTossConfig;
|
|
51
|
-
|
|
52
|
-
declare const loadConfig: () => Promise<AppsInTossConfig>;
|
|
53
|
-
|
|
54
|
-
export { type AppsInTossConfig, defineConfig, loadConfig };
|
|
2
|
+
export { }
|
package/dist/index.d.ts
CHANGED
|
@@ -1,54 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}, "strip", z.ZodTypeAny, {
|
|
18
|
-
port: number;
|
|
19
|
-
commands: {
|
|
20
|
-
dev: string;
|
|
21
|
-
build: string;
|
|
22
|
-
};
|
|
23
|
-
}, {
|
|
24
|
-
port: number;
|
|
25
|
-
commands: {
|
|
26
|
-
dev: string;
|
|
27
|
-
build: string;
|
|
28
|
-
};
|
|
29
|
-
}>;
|
|
30
|
-
}, "strip", z.ZodTypeAny, {
|
|
31
|
-
appName: string;
|
|
32
|
-
web: {
|
|
33
|
-
port: number;
|
|
34
|
-
commands: {
|
|
35
|
-
dev: string;
|
|
36
|
-
build: string;
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
}, {
|
|
40
|
-
appName: string;
|
|
41
|
-
web: {
|
|
42
|
-
port: number;
|
|
43
|
-
commands: {
|
|
44
|
-
dev: string;
|
|
45
|
-
build: string;
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
}>;
|
|
49
|
-
type AppsInTossConfig = z.infer<typeof AppsInTossConfigSchema>;
|
|
50
|
-
declare const defineConfig: (config: z.input<typeof AppsInTossConfigSchema>) => AppsInTossConfig;
|
|
51
|
-
|
|
52
|
-
declare const loadConfig: () => Promise<AppsInTossConfig>;
|
|
53
|
-
|
|
54
|
-
export { type AppsInTossConfig, defineConfig, loadConfig };
|
|
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
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
defineConfig,
|
|
4
|
-
loadConfig
|
|
5
|
-
} from "./chunk-HL7M3JLX.js";
|
|
6
|
-
export {
|
|
7
|
-
defineConfig,
|
|
8
|
-
loadConfig
|
|
9
|
-
};
|
|
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(){if(!window.ReactNativeWebView){throw new Error("This closeView is not available in browser environment")}if("closeView"in window.__CONSTANT_HANDLER_MAP){return window.__CONSTANT_HANDLER_MAP["closeView"]}throw new Error("closeView is not a constant handler")}export function generateHapticFeedback(){if(!window.ReactNativeWebView){throw new Error("This generateHapticFeedback is not available in browser environment")}if("generateHapticFeedback"in window.__CONSTANT_HANDLER_MAP){return window.__CONSTANT_HANDLER_MAP["generateHapticFeedback"]}throw new Error("generateHapticFeedback is not a constant handler")}export function share(){if(!window.ReactNativeWebView){throw new Error("This share is not available in browser environment")}if("share"in window.__CONSTANT_HANDLER_MAP){return window.__CONSTANT_HANDLER_MAP["share"]}throw new Error("share is not a constant handler")}export function setSecureScreen(){if(!window.ReactNativeWebView){throw new Error("This setSecureScreen is not available in browser environment")}if("setSecureScreen"in window.__CONSTANT_HANDLER_MAP){return window.__CONSTANT_HANDLER_MAP["setSecureScreen"]}throw new Error("setSecureScreen is not a constant handler")}export function setScreenAwakeMode(){if(!window.ReactNativeWebView){throw new Error("This setScreenAwakeMode is not available in browser environment")}if("setScreenAwakeMode"in window.__CONSTANT_HANDLER_MAP){return window.__CONSTANT_HANDLER_MAP["setScreenAwakeMode"]}throw new Error("setScreenAwakeMode is not a constant handler")}export function getNetworkStatus(){if(!window.ReactNativeWebView){throw new Error("This getNetworkStatus is not available in browser environment")}if("getNetworkStatus"in window.__CONSTANT_HANDLER_MAP){return window.__CONSTANT_HANDLER_MAP["getNetworkStatus"]}throw new Error("getNetworkStatus is not a constant handler")}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 {};
|