@apps-in-toss/framework 0.0.4 → 0.0.6
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/bin.js +4 -0
- package/dist/index.cjs +146 -69
- package/dist/index.d.cts +32 -17
- package/dist/index.d.ts +32 -17
- package/dist/index.js +139 -66
- package/dist/plugins/index.cjs +33154 -0
- package/dist/plugins/index.d.cts +36 -0
- package/dist/plugins/index.d.ts +36 -0
- package/dist/plugins/index.js +33159 -0
- package/package.json +29 -18
- package/plugins.d.ts +1 -0
- package/dist/cli-presets.cjs +0 -24
- package/dist/cli-presets.d.cts +0 -1
- package/dist/cli-presets.d.ts +0 -1
- package/dist/cli-presets.js +0 -2
package/bin.js
ADDED
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,12 +17,22 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
21
31
|
var src_exports = {};
|
|
22
32
|
__export(src_exports, {
|
|
23
|
-
Accuracy: () =>
|
|
33
|
+
Accuracy: () => Accuracy2,
|
|
34
|
+
WebView: () => WebView,
|
|
35
|
+
env: () => env,
|
|
24
36
|
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
25
37
|
fetchContacts: () => fetchContacts,
|
|
26
38
|
getClipboardText: () => getClipboardText,
|
|
@@ -32,17 +44,23 @@ __export(src_exports, {
|
|
|
32
44
|
});
|
|
33
45
|
module.exports = __toCommonJS(src_exports);
|
|
34
46
|
|
|
35
|
-
// src/native-event-emitter/
|
|
36
|
-
var
|
|
47
|
+
// src/native-event-emitter/index.ts
|
|
48
|
+
var native_event_emitter_exports = {};
|
|
49
|
+
__export(native_event_emitter_exports, {
|
|
50
|
+
startUpdateLocation: () => startUpdateLocation
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// src/native-event-emitter/bedrock-event.ts
|
|
54
|
+
var import_react_native_bedrock2 = require("react-native-bedrock");
|
|
55
|
+
|
|
56
|
+
// src/native-event-emitter/event-plugins/UpdateLocationEvent.ts
|
|
57
|
+
var import_react_native_bedrock = require("react-native-bedrock");
|
|
37
58
|
|
|
38
59
|
// src/native-modules/AppsInTossModule.ts
|
|
39
60
|
var import_react_native = require("react-native");
|
|
40
61
|
var AppsInTossModuleInstance = import_react_native.NativeModules.AppsInTossModule;
|
|
41
62
|
var AppsInTossModule = AppsInTossModuleInstance;
|
|
42
63
|
|
|
43
|
-
// src/native-event-emitter/nativeEventEmitter.ts
|
|
44
|
-
var nativeEventEmitter = new import_react_native2.NativeEventEmitter(AppsInTossModuleInstance);
|
|
45
|
-
|
|
46
64
|
// src/native-modules/getPermission.ts
|
|
47
65
|
function getPermission(permission) {
|
|
48
66
|
return AppsInTossModule.getPermission(permission);
|
|
@@ -65,32 +83,56 @@ async function requestPermission(permission) {
|
|
|
65
83
|
}
|
|
66
84
|
}
|
|
67
85
|
|
|
68
|
-
// src/native-event-emitter/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
86
|
+
// src/native-event-emitter/nativeEventEmitter.ts
|
|
87
|
+
var import_react_native2 = require("react-native");
|
|
88
|
+
var nativeEventEmitter = new import_react_native2.NativeEventEmitter(AppsInTossModuleInstance);
|
|
89
|
+
|
|
90
|
+
// src/native-event-emitter/event-plugins/UpdateLocationEvent.ts
|
|
91
|
+
var UpdateLocationEvent = class extends import_react_native_bedrock.BedrockEventDefinition {
|
|
92
|
+
name = "updateLocationEvent";
|
|
93
|
+
subscriptionCount = 0;
|
|
94
|
+
ref = {
|
|
95
|
+
remove: () => {
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
remove() {
|
|
99
|
+
--this.subscriptionCount === 0 && AppsInTossModuleInstance.stopUpdateLocation({});
|
|
100
|
+
this.ref.remove();
|
|
74
101
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const result = Reflect.get(target, key, receiver);
|
|
81
|
-
if (key === "remove") {
|
|
82
|
-
return async () => {
|
|
83
|
-
await (--subscriptionCount === 0 && AppsInTossModuleInstance.stopUpdateLocation({}));
|
|
84
|
-
const remove = result;
|
|
85
|
-
remove();
|
|
86
|
-
};
|
|
102
|
+
listener(options, onEvent, onError) {
|
|
103
|
+
requestPermission({ name: "geolocation", access: "access" }).then((permissionStatus) => {
|
|
104
|
+
if (permissionStatus === "denied") {
|
|
105
|
+
onError(new Error("\uC704\uCE58 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694."));
|
|
106
|
+
return;
|
|
87
107
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
108
|
+
void AppsInTossModuleInstance.startUpdateLocation(options).catch(onError);
|
|
109
|
+
const subscription = nativeEventEmitter.addListener("updateLocation", onEvent);
|
|
110
|
+
this.ref = {
|
|
111
|
+
remove: () => subscription?.remove()
|
|
112
|
+
};
|
|
113
|
+
this.subscriptionCount++;
|
|
114
|
+
}).catch(onError);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// src/native-event-emitter/bedrock-event.ts
|
|
119
|
+
var appsInTossEvent = new import_react_native_bedrock2.BedrockEvent([new UpdateLocationEvent()]);
|
|
120
|
+
|
|
121
|
+
// src/native-event-emitter/startUpdateLocation.ts
|
|
122
|
+
function startUpdateLocation(eventParams) {
|
|
123
|
+
return appsInTossEvent.addEventListener("updateLocationEvent", eventParams);
|
|
92
124
|
}
|
|
93
|
-
|
|
125
|
+
|
|
126
|
+
// src/native-modules/index.ts
|
|
127
|
+
var native_modules_exports = {};
|
|
128
|
+
__export(native_modules_exports, {
|
|
129
|
+
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
130
|
+
fetchContacts: () => fetchContacts,
|
|
131
|
+
getClipboardText: () => getClipboardText,
|
|
132
|
+
getCurrentLocation: () => getCurrentLocation,
|
|
133
|
+
openCamera: () => openCamera,
|
|
134
|
+
setClipboardText: () => setClipboardText
|
|
135
|
+
});
|
|
94
136
|
|
|
95
137
|
// src/native-modules/setClipboardText.ts
|
|
96
138
|
async function setClipboardText(text) {
|
|
@@ -168,57 +210,92 @@ async function openCamera(options) {
|
|
|
168
210
|
return photo;
|
|
169
211
|
}
|
|
170
212
|
|
|
171
|
-
// src/
|
|
213
|
+
// src/components/WebView.tsx
|
|
214
|
+
var import_react_native_webview = require("@react-native-bedrock/native/react-native-webview");
|
|
172
215
|
var import_react = require("react");
|
|
173
|
-
var
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
216
|
+
var import_react_native_bedrock3 = require("react-native-bedrock");
|
|
217
|
+
var bridges = __toESM(require("react-native-bedrock/bridges"), 1);
|
|
218
|
+
var constantBridges = __toESM(require("react-native-bedrock/constants"), 1);
|
|
219
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
220
|
+
function WebView({ localhostPort = 5173, onMessage, ...props }) {
|
|
221
|
+
const uri = (0, import_react.useMemo)(() => {
|
|
222
|
+
if (__DEV__) {
|
|
223
|
+
return `http://localhost:${localhostPort}`;
|
|
224
|
+
}
|
|
225
|
+
return AppsInTossModule.getWebBundleURL({}).url;
|
|
226
|
+
}, [localhostPort]);
|
|
227
|
+
const handler = (0, import_react_native_bedrock3.useBridgeHandler)({
|
|
228
|
+
onMessage,
|
|
229
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
230
|
+
eventListenerMap: native_event_emitter_exports,
|
|
231
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
232
|
+
// @ts-expect-error
|
|
233
|
+
constantHandlerMap: constantBridges,
|
|
234
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
235
|
+
// @ts-expect-error
|
|
236
|
+
handlerMap: {
|
|
237
|
+
...bridges,
|
|
238
|
+
...native_modules_exports
|
|
189
239
|
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
240
|
+
});
|
|
241
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
242
|
+
import_react_native_webview.WebView,
|
|
243
|
+
{
|
|
244
|
+
ref: handler.ref,
|
|
245
|
+
...props,
|
|
246
|
+
source: { uri },
|
|
247
|
+
sharedCookiesEnabled: true,
|
|
248
|
+
thirdPartyCookiesEnabled: true,
|
|
249
|
+
onMessage: handler.onMessage,
|
|
250
|
+
injectedJavaScript: handler.injectedJavaScript,
|
|
251
|
+
injectedJavaScriptBeforeContentLoaded: handler.injectedJavaScript
|
|
198
252
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// src/hooks/useGeolocation.ts
|
|
257
|
+
var import_react2 = require("react");
|
|
258
|
+
var import_react_native_bedrock4 = require("react-native-bedrock");
|
|
259
|
+
function useGeolocation({ accuracy, distanceInterval, timeInterval }) {
|
|
260
|
+
const isVisible = (0, import_react_native_bedrock4.useVisibility)();
|
|
261
|
+
const [location, setLocation] = (0, import_react2.useState)(null);
|
|
262
|
+
(0, import_react2.useEffect)(() => {
|
|
263
|
+
if (!isVisible) {
|
|
264
|
+
return;
|
|
203
265
|
}
|
|
204
|
-
return (
|
|
205
|
-
|
|
266
|
+
return startUpdateLocation({
|
|
267
|
+
options: {
|
|
268
|
+
accuracy,
|
|
269
|
+
distanceInterval,
|
|
270
|
+
timeInterval
|
|
271
|
+
},
|
|
272
|
+
onEvent: setLocation,
|
|
273
|
+
onError: console.error
|
|
274
|
+
});
|
|
275
|
+
}, [accuracy, distanceInterval, timeInterval, isVisible]);
|
|
206
276
|
return location;
|
|
207
277
|
}
|
|
208
278
|
|
|
279
|
+
// src/env.ts
|
|
280
|
+
var env = {
|
|
281
|
+
getDeploymentId: () => __DEV__ ? "local" : global.__appsInToss?.deploymentId
|
|
282
|
+
};
|
|
283
|
+
|
|
209
284
|
// src/types.ts
|
|
210
|
-
var
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
return
|
|
218
|
-
})(
|
|
285
|
+
var Accuracy2 = /* @__PURE__ */ ((Accuracy3) => {
|
|
286
|
+
Accuracy3[Accuracy3["Lowest"] = 1] = "Lowest";
|
|
287
|
+
Accuracy3[Accuracy3["Low"] = 2] = "Low";
|
|
288
|
+
Accuracy3[Accuracy3["Balanced"] = 3] = "Balanced";
|
|
289
|
+
Accuracy3[Accuracy3["High"] = 4] = "High";
|
|
290
|
+
Accuracy3[Accuracy3["Highest"] = 5] = "Highest";
|
|
291
|
+
Accuracy3[Accuracy3["BestForNavigation"] = 6] = "BestForNavigation";
|
|
292
|
+
return Accuracy3;
|
|
293
|
+
})(Accuracy2 || {});
|
|
219
294
|
// Annotate the CommonJS export names for ESM import in node:
|
|
220
295
|
0 && (module.exports = {
|
|
221
296
|
Accuracy,
|
|
297
|
+
WebView,
|
|
298
|
+
env,
|
|
222
299
|
fetchAlbumPhotos,
|
|
223
300
|
fetchContacts,
|
|
224
301
|
getClipboardText,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { EmitterSubscription } from 'react-native';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { WebViewProps as WebViewProps$1 } from '@react-native-bedrock/native/react-native-webview';
|
|
2
4
|
|
|
3
5
|
interface EventEmitterSchema<K extends string, P extends unknown[]> {
|
|
4
6
|
name: K;
|
|
@@ -80,10 +82,6 @@ interface StartUpdateLocationOptions {
|
|
|
80
82
|
* 위치 변경 거리를 미터(m) 단위로 설정해요.
|
|
81
83
|
*/
|
|
82
84
|
distanceInterval: number;
|
|
83
|
-
/**
|
|
84
|
-
* 위치 정보가 변경될 때 호출되는 콜백 함수예요.
|
|
85
|
-
*/
|
|
86
|
-
callback: (location: Location) => void;
|
|
87
85
|
}
|
|
88
86
|
interface StartUpdateLocationSubscription extends EmitterSubscription {
|
|
89
87
|
remove: () => Promise<void>;
|
|
@@ -126,16 +124,19 @@ interface UpdateLocationEventEmitter extends EventEmitterSchema<'updateLocation'
|
|
|
126
124
|
* const [location, setLocation] = useState(null);
|
|
127
125
|
*
|
|
128
126
|
* useEffect(() => {
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
127
|
+
* return startUpdateLocation({
|
|
128
|
+
* options: {
|
|
129
|
+
* accuracy: Accuracy.Default,
|
|
130
|
+
* timeInterval: 3000,
|
|
131
|
+
* distanceInterval: 10,
|
|
132
|
+
* },
|
|
133
|
+
* onEvent: (location) => {
|
|
134
134
|
* setLocation(location);
|
|
135
135
|
* },
|
|
136
|
+
* onError: (error) => {
|
|
137
|
+
* console.error('위치 정보를 가져오는데 실패했어요:', error);
|
|
138
|
+
* },
|
|
136
139
|
* });
|
|
137
|
-
*
|
|
138
|
-
* return () => subscription.remove();
|
|
139
140
|
* }, []);
|
|
140
141
|
*
|
|
141
142
|
* if (location == null) {
|
|
@@ -155,7 +156,11 @@ interface UpdateLocationEventEmitter extends EventEmitterSchema<'updateLocation'
|
|
|
155
156
|
* }
|
|
156
157
|
* ```
|
|
157
158
|
*/
|
|
158
|
-
declare function startUpdateLocation(
|
|
159
|
+
declare function startUpdateLocation(eventParams: {
|
|
160
|
+
onEvent: (response: Location) => void;
|
|
161
|
+
onError: (error: unknown) => void;
|
|
162
|
+
options: StartUpdateLocationOptions;
|
|
163
|
+
}): () => void;
|
|
159
164
|
|
|
160
165
|
/**
|
|
161
166
|
* @public
|
|
@@ -355,7 +360,7 @@ interface FetchAlbumPhotosOptions {
|
|
|
355
360
|
*
|
|
356
361
|
* ```tsx
|
|
357
362
|
* import React, { useState } from 'react';
|
|
358
|
-
* import { View,
|
|
363
|
+
* import { View, Image, Button } from 'react-native';
|
|
359
364
|
* import { fetchAlbumPhotos } from '@apps-in-toss/framework';
|
|
360
365
|
*
|
|
361
366
|
* // 앨범 사진 목록을 가져와 화면에 표시하는 컴포넌트
|
|
@@ -365,6 +370,7 @@ interface FetchAlbumPhotosOptions {
|
|
|
365
370
|
* const handlePress = async () => {
|
|
366
371
|
* try {
|
|
367
372
|
* const response = await fetchAlbumPhotos({
|
|
373
|
+
* base64: true,
|
|
368
374
|
* maxWidth: 360,
|
|
369
375
|
* });
|
|
370
376
|
* setAlbumPhotos((prev) => ([...prev, ...response]));
|
|
@@ -375,8 +381,8 @@ interface FetchAlbumPhotosOptions {
|
|
|
375
381
|
*
|
|
376
382
|
* return (
|
|
377
383
|
* <View>
|
|
378
|
-
* {albumPhotos.map((
|
|
379
|
-
* <
|
|
384
|
+
* {albumPhotos.map((image) => (
|
|
385
|
+
* <Image source={{ uri: image.dataUri }} key={image.id} />
|
|
380
386
|
* ))}
|
|
381
387
|
* <Button title="앨범 가져오기" onPress={handlePress} />
|
|
382
388
|
* </View>
|
|
@@ -465,7 +471,7 @@ interface OpenCameraOptions {
|
|
|
465
471
|
* @description 카메라를 실행해서 촬영된 이미지를 반환하는 함수예요.
|
|
466
472
|
* @param {OpenCameraOptions} options - 카메라 실행 시 사용되는 옵션 객체예요.
|
|
467
473
|
* @param {boolean} [options.base64=false] - 이미지를 Base64 형식으로 반환할지 여부를 나타내는 불리언 값이에요. 기본값은 `false`예요. `true`로 설정하면 `dataUri` 대신 Base64 인코딩된 문자열을 반환해요.
|
|
468
|
-
* @param {
|
|
474
|
+
* @param {number} [options.maxWidth=1024] - 이미지의 최대 너비를 나타내는 숫자 값이에요. 기본값은 `1024`예요.
|
|
469
475
|
* @returns {Promise<ImageResponse>}
|
|
470
476
|
* 촬영된 이미지 정보를 포함한 객체를 반환해요. 반환 객체의 구성은 다음과 같아요:
|
|
471
477
|
* - `id`: 이미지의 고유 식별자예요.
|
|
@@ -507,6 +513,11 @@ interface OpenCameraOptions {
|
|
|
507
513
|
*/
|
|
508
514
|
declare function openCamera(options?: OpenCameraOptions): Promise<ImageResponse>;
|
|
509
515
|
|
|
516
|
+
interface WebViewProps extends Omit<WebViewProps$1, 'source' | 'sharedCookiesEnabled' | 'thirdPartyCookiesEnabled' | 'injectedJavaScriptBeforeContentLoaded'> {
|
|
517
|
+
localhostPort?: number;
|
|
518
|
+
}
|
|
519
|
+
declare function WebView({ localhostPort, onMessage, ...props }: WebViewProps): react_jsx_runtime.JSX.Element;
|
|
520
|
+
|
|
510
521
|
type UseGeolocationOptions = Omit<StartUpdateLocationOptions, 'callback'>;
|
|
511
522
|
/**
|
|
512
523
|
* @public
|
|
@@ -554,4 +565,8 @@ type UseGeolocationOptions = Omit<StartUpdateLocationOptions, 'callback'>;
|
|
|
554
565
|
*/
|
|
555
566
|
declare function useGeolocation({ accuracy, distanceInterval, timeInterval }: UseGeolocationOptions): Location | null;
|
|
556
567
|
|
|
557
|
-
|
|
568
|
+
declare const env: {
|
|
569
|
+
getDeploymentId: () => string | undefined;
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
export { Accuracy, type ContactEntity, type FetchAlbumPhotosOptions, type GetCurrentLocationOptions, type ImageResponse, type Location, type OpenCameraOptions, type StartUpdateLocationOptions, type StartUpdateLocationSubscription, type UpdateLocationEventEmitter, type UseGeolocationOptions, WebView, type WebViewProps, env, fetchAlbumPhotos, fetchContacts, getClipboardText, getCurrentLocation, openCamera, setClipboardText, startUpdateLocation, useGeolocation };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { EmitterSubscription } from 'react-native';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { WebViewProps as WebViewProps$1 } from '@react-native-bedrock/native/react-native-webview';
|
|
2
4
|
|
|
3
5
|
interface EventEmitterSchema<K extends string, P extends unknown[]> {
|
|
4
6
|
name: K;
|
|
@@ -80,10 +82,6 @@ interface StartUpdateLocationOptions {
|
|
|
80
82
|
* 위치 변경 거리를 미터(m) 단위로 설정해요.
|
|
81
83
|
*/
|
|
82
84
|
distanceInterval: number;
|
|
83
|
-
/**
|
|
84
|
-
* 위치 정보가 변경될 때 호출되는 콜백 함수예요.
|
|
85
|
-
*/
|
|
86
|
-
callback: (location: Location) => void;
|
|
87
85
|
}
|
|
88
86
|
interface StartUpdateLocationSubscription extends EmitterSubscription {
|
|
89
87
|
remove: () => Promise<void>;
|
|
@@ -126,16 +124,19 @@ interface UpdateLocationEventEmitter extends EventEmitterSchema<'updateLocation'
|
|
|
126
124
|
* const [location, setLocation] = useState(null);
|
|
127
125
|
*
|
|
128
126
|
* useEffect(() => {
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
127
|
+
* return startUpdateLocation({
|
|
128
|
+
* options: {
|
|
129
|
+
* accuracy: Accuracy.Default,
|
|
130
|
+
* timeInterval: 3000,
|
|
131
|
+
* distanceInterval: 10,
|
|
132
|
+
* },
|
|
133
|
+
* onEvent: (location) => {
|
|
134
134
|
* setLocation(location);
|
|
135
135
|
* },
|
|
136
|
+
* onError: (error) => {
|
|
137
|
+
* console.error('위치 정보를 가져오는데 실패했어요:', error);
|
|
138
|
+
* },
|
|
136
139
|
* });
|
|
137
|
-
*
|
|
138
|
-
* return () => subscription.remove();
|
|
139
140
|
* }, []);
|
|
140
141
|
*
|
|
141
142
|
* if (location == null) {
|
|
@@ -155,7 +156,11 @@ interface UpdateLocationEventEmitter extends EventEmitterSchema<'updateLocation'
|
|
|
155
156
|
* }
|
|
156
157
|
* ```
|
|
157
158
|
*/
|
|
158
|
-
declare function startUpdateLocation(
|
|
159
|
+
declare function startUpdateLocation(eventParams: {
|
|
160
|
+
onEvent: (response: Location) => void;
|
|
161
|
+
onError: (error: unknown) => void;
|
|
162
|
+
options: StartUpdateLocationOptions;
|
|
163
|
+
}): () => void;
|
|
159
164
|
|
|
160
165
|
/**
|
|
161
166
|
* @public
|
|
@@ -355,7 +360,7 @@ interface FetchAlbumPhotosOptions {
|
|
|
355
360
|
*
|
|
356
361
|
* ```tsx
|
|
357
362
|
* import React, { useState } from 'react';
|
|
358
|
-
* import { View,
|
|
363
|
+
* import { View, Image, Button } from 'react-native';
|
|
359
364
|
* import { fetchAlbumPhotos } from '@apps-in-toss/framework';
|
|
360
365
|
*
|
|
361
366
|
* // 앨범 사진 목록을 가져와 화면에 표시하는 컴포넌트
|
|
@@ -365,6 +370,7 @@ interface FetchAlbumPhotosOptions {
|
|
|
365
370
|
* const handlePress = async () => {
|
|
366
371
|
* try {
|
|
367
372
|
* const response = await fetchAlbumPhotos({
|
|
373
|
+
* base64: true,
|
|
368
374
|
* maxWidth: 360,
|
|
369
375
|
* });
|
|
370
376
|
* setAlbumPhotos((prev) => ([...prev, ...response]));
|
|
@@ -375,8 +381,8 @@ interface FetchAlbumPhotosOptions {
|
|
|
375
381
|
*
|
|
376
382
|
* return (
|
|
377
383
|
* <View>
|
|
378
|
-
* {albumPhotos.map((
|
|
379
|
-
* <
|
|
384
|
+
* {albumPhotos.map((image) => (
|
|
385
|
+
* <Image source={{ uri: image.dataUri }} key={image.id} />
|
|
380
386
|
* ))}
|
|
381
387
|
* <Button title="앨범 가져오기" onPress={handlePress} />
|
|
382
388
|
* </View>
|
|
@@ -465,7 +471,7 @@ interface OpenCameraOptions {
|
|
|
465
471
|
* @description 카메라를 실행해서 촬영된 이미지를 반환하는 함수예요.
|
|
466
472
|
* @param {OpenCameraOptions} options - 카메라 실행 시 사용되는 옵션 객체예요.
|
|
467
473
|
* @param {boolean} [options.base64=false] - 이미지를 Base64 형식으로 반환할지 여부를 나타내는 불리언 값이에요. 기본값은 `false`예요. `true`로 설정하면 `dataUri` 대신 Base64 인코딩된 문자열을 반환해요.
|
|
468
|
-
* @param {
|
|
474
|
+
* @param {number} [options.maxWidth=1024] - 이미지의 최대 너비를 나타내는 숫자 값이에요. 기본값은 `1024`예요.
|
|
469
475
|
* @returns {Promise<ImageResponse>}
|
|
470
476
|
* 촬영된 이미지 정보를 포함한 객체를 반환해요. 반환 객체의 구성은 다음과 같아요:
|
|
471
477
|
* - `id`: 이미지의 고유 식별자예요.
|
|
@@ -507,6 +513,11 @@ interface OpenCameraOptions {
|
|
|
507
513
|
*/
|
|
508
514
|
declare function openCamera(options?: OpenCameraOptions): Promise<ImageResponse>;
|
|
509
515
|
|
|
516
|
+
interface WebViewProps extends Omit<WebViewProps$1, 'source' | 'sharedCookiesEnabled' | 'thirdPartyCookiesEnabled' | 'injectedJavaScriptBeforeContentLoaded'> {
|
|
517
|
+
localhostPort?: number;
|
|
518
|
+
}
|
|
519
|
+
declare function WebView({ localhostPort, onMessage, ...props }: WebViewProps): react_jsx_runtime.JSX.Element;
|
|
520
|
+
|
|
510
521
|
type UseGeolocationOptions = Omit<StartUpdateLocationOptions, 'callback'>;
|
|
511
522
|
/**
|
|
512
523
|
* @public
|
|
@@ -554,4 +565,8 @@ type UseGeolocationOptions = Omit<StartUpdateLocationOptions, 'callback'>;
|
|
|
554
565
|
*/
|
|
555
566
|
declare function useGeolocation({ accuracy, distanceInterval, timeInterval }: UseGeolocationOptions): Location | null;
|
|
556
567
|
|
|
557
|
-
|
|
568
|
+
declare const env: {
|
|
569
|
+
getDeploymentId: () => string | undefined;
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
export { Accuracy, type ContactEntity, type FetchAlbumPhotosOptions, type GetCurrentLocationOptions, type ImageResponse, type Location, type OpenCameraOptions, type StartUpdateLocationOptions, type StartUpdateLocationSubscription, type UpdateLocationEventEmitter, type UseGeolocationOptions, WebView, type WebViewProps, env, fetchAlbumPhotos, fetchContacts, getClipboardText, getCurrentLocation, openCamera, setClipboardText, startUpdateLocation, useGeolocation };
|