@apps-in-toss/framework 0.0.8 → 0.0.9
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 -202
- package/README.md +4 -5
- package/{bin.js → bin/ait.js} +0 -1
- package/dist/index.cjs +54 -10
- package/dist/index.d.cts +91 -14
- package/dist/index.d.ts +91 -14
- package/dist/index.js +44 -2
- package/dist/jest/index.cjs +24 -0
- package/dist/jest/index.d.cts +1 -0
- package/dist/jest/index.d.ts +1 -0
- package/dist/jest/index.js +4 -0
- package/dist/plugins/index.cjs +26047 -25600
- package/dist/plugins/index.d.cts +41 -1
- package/dist/plugins/index.d.ts +41 -1
- package/dist/plugins/index.js +26090 -25648
- package/jest.d.ts +1 -0
- package/package.json +22 -10
package/README.md
CHANGED
|
@@ -4,21 +4,20 @@ Hub package for Apps In Toss
|
|
|
4
4
|
|
|
5
5
|
## License
|
|
6
6
|
|
|
7
|
-
This software is licensed under the [
|
|
7
|
+
This software is licensed under the [GPL, Version 3.0](LICENSE), quoted below.
|
|
8
8
|
|
|
9
9
|
```
|
|
10
|
-
Copyright 2025 Viva Republica, Inc
|
|
10
|
+
Copyright 2025 Viva Republica, Inc.
|
|
11
11
|
|
|
12
|
-
Licensed under the
|
|
12
|
+
Licensed under the GPL, Version 3.0 (the "License");
|
|
13
13
|
you may not use this file except in compliance with the License.
|
|
14
14
|
You may obtain a copy of the License at:
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
https://www.gnu.org/licenses/gpl-3.0.html
|
|
17
17
|
|
|
18
18
|
Unless required by applicable law or agreed to in writing, software
|
|
19
19
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
20
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
21
|
See the License for the specific language governing permissions and
|
|
22
22
|
limitations under the License.
|
|
23
|
-
|
|
24
23
|
```
|
package/{bin.js → bin/ait.js}
RENAMED
package/dist/index.cjs
CHANGED
|
@@ -31,7 +31,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
Accuracy: () => Accuracy2,
|
|
34
|
+
AppsInToss: () => AppsInToss,
|
|
34
35
|
WebView: () => WebView,
|
|
36
|
+
appLogin: () => appLogin,
|
|
35
37
|
env: () => env,
|
|
36
38
|
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
37
39
|
fetchContacts: () => fetchContacts,
|
|
@@ -44,6 +46,32 @@ __export(src_exports, {
|
|
|
44
46
|
});
|
|
45
47
|
module.exports = __toCommonJS(src_exports);
|
|
46
48
|
|
|
49
|
+
// src/core/registerApp.tsx
|
|
50
|
+
var import_react_native_bedrock = require("react-native-bedrock");
|
|
51
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
52
|
+
function AppsInTossContainer(Container, { children, ...initialProps }) {
|
|
53
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Container, { ...initialProps, children });
|
|
54
|
+
}
|
|
55
|
+
function registerApp(container, { context }) {
|
|
56
|
+
return import_react_native_bedrock.Bedrock.registerApp(AppsInTossContainer.bind(null, container), {
|
|
57
|
+
appName: getAppName(),
|
|
58
|
+
context
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function getAppName() {
|
|
62
|
+
try {
|
|
63
|
+
return global.__bedrock.app.name;
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.error("unexpected error occurred while getting app name");
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// src/core/index.ts
|
|
71
|
+
var AppsInToss = {
|
|
72
|
+
registerApp
|
|
73
|
+
};
|
|
74
|
+
|
|
47
75
|
// src/native-event-emitter/index.ts
|
|
48
76
|
var native_event_emitter_exports = {};
|
|
49
77
|
__export(native_event_emitter_exports, {
|
|
@@ -51,10 +79,10 @@ __export(native_event_emitter_exports, {
|
|
|
51
79
|
});
|
|
52
80
|
|
|
53
81
|
// src/native-event-emitter/bedrock-event.ts
|
|
54
|
-
var
|
|
82
|
+
var import_react_native_bedrock3 = require("react-native-bedrock");
|
|
55
83
|
|
|
56
84
|
// src/native-event-emitter/event-plugins/UpdateLocationEvent.ts
|
|
57
|
-
var
|
|
85
|
+
var import_react_native_bedrock2 = require("react-native-bedrock");
|
|
58
86
|
|
|
59
87
|
// src/native-modules/AppsInTossModule.ts
|
|
60
88
|
var import_react_native = require("react-native");
|
|
@@ -88,7 +116,7 @@ var import_react_native2 = require("react-native");
|
|
|
88
116
|
var nativeEventEmitter = new import_react_native2.NativeEventEmitter(AppsInTossModuleInstance);
|
|
89
117
|
|
|
90
118
|
// src/native-event-emitter/event-plugins/UpdateLocationEvent.ts
|
|
91
|
-
var UpdateLocationEvent = class extends
|
|
119
|
+
var UpdateLocationEvent = class extends import_react_native_bedrock2.BedrockEventDefinition {
|
|
92
120
|
name = "updateLocationEvent";
|
|
93
121
|
subscriptionCount = 0;
|
|
94
122
|
ref = {
|
|
@@ -116,7 +144,7 @@ var UpdateLocationEvent = class extends import_react_native_bedrock.BedrockEvent
|
|
|
116
144
|
};
|
|
117
145
|
|
|
118
146
|
// src/native-event-emitter/bedrock-event.ts
|
|
119
|
-
var appsInTossEvent = new
|
|
147
|
+
var appsInTossEvent = new import_react_native_bedrock3.BedrockEvent([new UpdateLocationEvent()]);
|
|
120
148
|
|
|
121
149
|
// src/native-event-emitter/startUpdateLocation.ts
|
|
122
150
|
function startUpdateLocation(eventParams) {
|
|
@@ -126,6 +154,7 @@ function startUpdateLocation(eventParams) {
|
|
|
126
154
|
// src/native-modules/index.ts
|
|
127
155
|
var native_modules_exports = {};
|
|
128
156
|
__export(native_modules_exports, {
|
|
157
|
+
appLogin: () => appLogin,
|
|
129
158
|
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
130
159
|
fetchContacts: () => fetchContacts,
|
|
131
160
|
getClipboardText: () => getClipboardText,
|
|
@@ -187,6 +216,14 @@ async function fetchAlbumPhotos(options) {
|
|
|
187
216
|
maxCount: options.maxCount ?? DEFAULT_MAX_COUNT,
|
|
188
217
|
maxWidth: options.maxWidth ?? DEFAULT_MAX_WIDTH
|
|
189
218
|
});
|
|
219
|
+
if (options.base64) {
|
|
220
|
+
return albumPhotos.map((photo) => {
|
|
221
|
+
return {
|
|
222
|
+
...photo,
|
|
223
|
+
dataUri: `data:image/jpeg;base64,${photo.dataUri}`
|
|
224
|
+
};
|
|
225
|
+
});
|
|
226
|
+
}
|
|
190
227
|
return albumPhotos;
|
|
191
228
|
}
|
|
192
229
|
|
|
@@ -210,13 +247,18 @@ async function openCamera(options) {
|
|
|
210
247
|
return photo;
|
|
211
248
|
}
|
|
212
249
|
|
|
250
|
+
// src/native-modules/appLogin.ts
|
|
251
|
+
async function appLogin() {
|
|
252
|
+
return AppsInTossModule.appLogin({});
|
|
253
|
+
}
|
|
254
|
+
|
|
213
255
|
// src/components/WebView.tsx
|
|
214
256
|
var import_react_native_webview = require("@react-native-bedrock/native/react-native-webview");
|
|
215
257
|
var import_react = require("react");
|
|
216
|
-
var
|
|
258
|
+
var import_react_native_bedrock4 = require("react-native-bedrock");
|
|
217
259
|
var bridges = __toESM(require("react-native-bedrock/bridges"), 1);
|
|
218
260
|
var constantBridges = __toESM(require("react-native-bedrock/constants"), 1);
|
|
219
|
-
var
|
|
261
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
220
262
|
function WebView({ localhostPort = 5173, onMessage, ...props }) {
|
|
221
263
|
const uri = (0, import_react.useMemo)(() => {
|
|
222
264
|
if (__DEV__) {
|
|
@@ -224,7 +266,7 @@ function WebView({ localhostPort = 5173, onMessage, ...props }) {
|
|
|
224
266
|
}
|
|
225
267
|
return AppsInTossModule.getWebBundleURL({}).url;
|
|
226
268
|
}, [localhostPort]);
|
|
227
|
-
const handler = (0,
|
|
269
|
+
const handler = (0, import_react_native_bedrock4.useBridgeHandler)({
|
|
228
270
|
onMessage,
|
|
229
271
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
230
272
|
eventListenerMap: native_event_emitter_exports,
|
|
@@ -238,7 +280,7 @@ function WebView({ localhostPort = 5173, onMessage, ...props }) {
|
|
|
238
280
|
...native_modules_exports
|
|
239
281
|
}
|
|
240
282
|
});
|
|
241
|
-
return /* @__PURE__ */ (0,
|
|
283
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
242
284
|
import_react_native_webview.WebView,
|
|
243
285
|
{
|
|
244
286
|
ref: handler.ref,
|
|
@@ -255,9 +297,9 @@ function WebView({ localhostPort = 5173, onMessage, ...props }) {
|
|
|
255
297
|
|
|
256
298
|
// src/hooks/useGeolocation.ts
|
|
257
299
|
var import_react2 = require("react");
|
|
258
|
-
var
|
|
300
|
+
var import_react_native_bedrock5 = require("react-native-bedrock");
|
|
259
301
|
function useGeolocation({ accuracy, distanceInterval, timeInterval }) {
|
|
260
|
-
const isVisible = (0,
|
|
302
|
+
const isVisible = (0, import_react_native_bedrock5.useVisibility)();
|
|
261
303
|
const [location, setLocation] = (0, import_react2.useState)(null);
|
|
262
304
|
(0, import_react2.useEffect)(() => {
|
|
263
305
|
if (!isVisible) {
|
|
@@ -294,7 +336,9 @@ var Accuracy2 = /* @__PURE__ */ ((Accuracy3) => {
|
|
|
294
336
|
// Annotate the CommonJS export names for ESM import in node:
|
|
295
337
|
0 && (module.exports = {
|
|
296
338
|
Accuracy,
|
|
339
|
+
AppsInToss,
|
|
297
340
|
WebView,
|
|
341
|
+
appLogin,
|
|
298
342
|
env,
|
|
299
343
|
fetchAlbumPhotos,
|
|
300
344
|
fetchContacts,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,14 +1,26 @@
|
|
|
1
|
+
import { ComponentType, PropsWithChildren } from 'react';
|
|
2
|
+
import { InitialProps, BedrockProps } from 'react-native-bedrock';
|
|
1
3
|
import { EmitterSubscription } from 'react-native';
|
|
2
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
5
|
import { WebViewProps as WebViewProps$1 } from '@react-native-bedrock/native/react-native-webview';
|
|
4
6
|
|
|
7
|
+
type AppsInTossProps = Pick<BedrockProps, 'context'>;
|
|
8
|
+
declare function registerApp(container: ComponentType<PropsWithChildren<InitialProps>>, { context }: AppsInTossProps): (initialProps: InitialProps) => JSX.Element;
|
|
9
|
+
|
|
10
|
+
declare const AppsInToss: {
|
|
11
|
+
registerApp: typeof registerApp;
|
|
12
|
+
};
|
|
13
|
+
|
|
5
14
|
interface EventEmitterSchema<K extends string, P extends unknown[]> {
|
|
6
15
|
name: K;
|
|
7
16
|
params: P;
|
|
8
17
|
}
|
|
9
18
|
|
|
10
19
|
/**
|
|
11
|
-
*
|
|
20
|
+
* @public
|
|
21
|
+
* @category Types
|
|
22
|
+
* @name Accuracy
|
|
23
|
+
* @description 위치 정확도 옵션이에요.
|
|
12
24
|
*/
|
|
13
25
|
declare enum Accuracy {
|
|
14
26
|
/**
|
|
@@ -36,6 +48,12 @@ declare enum Accuracy {
|
|
|
36
48
|
*/
|
|
37
49
|
BestForNavigation = 6
|
|
38
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* @public
|
|
53
|
+
* @category Types
|
|
54
|
+
* @name Location
|
|
55
|
+
* @description 위치 정보를 나타내는 객체예요.
|
|
56
|
+
*/
|
|
39
57
|
interface Location {
|
|
40
58
|
/**
|
|
41
59
|
* Android에서만 지원하는 옵션이에요.
|
|
@@ -50,14 +68,42 @@ interface Location {
|
|
|
50
68
|
* 위치가 업데이트된 시점의 유닉스 타임스탬프예요.
|
|
51
69
|
*/
|
|
52
70
|
timestamp: number;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
71
|
+
/**
|
|
72
|
+
* @description 위치 정보를 나타내는 객체예요. 자세한 내용은 [LocationCoords](/reference/framework/Types/LocationCoords.html)을 참고해주세요.
|
|
73
|
+
*/
|
|
74
|
+
coords: LocationCoords;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* @public
|
|
78
|
+
* @category Types
|
|
79
|
+
* @name LocationCoords
|
|
80
|
+
* @description 세부 위치 정보를 나타내는 객체예요.
|
|
81
|
+
*/
|
|
82
|
+
interface LocationCoords {
|
|
83
|
+
/**
|
|
84
|
+
* 위도
|
|
85
|
+
*/
|
|
86
|
+
latitude: number;
|
|
87
|
+
/**
|
|
88
|
+
* 경도
|
|
89
|
+
*/
|
|
90
|
+
longitude: number;
|
|
91
|
+
/**
|
|
92
|
+
* 높이
|
|
93
|
+
*/
|
|
94
|
+
altitude: number;
|
|
95
|
+
/**
|
|
96
|
+
* 위치 정확도
|
|
97
|
+
*/
|
|
98
|
+
accuracy: number;
|
|
99
|
+
/**
|
|
100
|
+
* 고도 정확도
|
|
101
|
+
*/
|
|
102
|
+
altitudeAccuracy: number;
|
|
103
|
+
/**
|
|
104
|
+
* 방향
|
|
105
|
+
*/
|
|
106
|
+
heading: number;
|
|
61
107
|
}
|
|
62
108
|
/**
|
|
63
109
|
* 사진 조회 결과를 나타내는 타입이에요.
|
|
@@ -109,7 +155,7 @@ interface UpdateLocationEventEmitter extends EventEmitterSchema<'updateLocation'
|
|
|
109
155
|
* @param {number} [options.accuracy] 위치 정확도를 설정해요.
|
|
110
156
|
* @param {number} [options.timeInterval] 위치 정보를 업데이트하는 최소 주기로, 단위는 밀리초(ms)예요. 이 값은 위치 업데이트가 발생하는 가장 짧은 간격을 설정하지만, 시스템이나 환경의 영향을 받아 지정한 주기보다 더 긴 간격으로 업데이트될 수 있어요.
|
|
111
157
|
* @param {number} [options.distanceInterval] 위치 변경 거리를 미터(m) 단위로 설정해요.
|
|
112
|
-
* @param {(location: Location) => void} [options.callback] 위치 정보가 변경될 때 호출되는 콜백 함수예요.
|
|
158
|
+
* @param {(location: Location) => void} [options.callback] 위치 정보가 변경될 때 호출되는 콜백 함수예요. 자세한 내용은 [Location](/reference/framework/Types/Location.html)을 참고해주세요.
|
|
113
159
|
*
|
|
114
160
|
* @example
|
|
115
161
|
* ### 위치 정보 변경 감지하기
|
|
@@ -126,7 +172,7 @@ interface UpdateLocationEventEmitter extends EventEmitterSchema<'updateLocation'
|
|
|
126
172
|
* useEffect(() => {
|
|
127
173
|
* return startUpdateLocation({
|
|
128
174
|
* options: {
|
|
129
|
-
* accuracy: Accuracy.
|
|
175
|
+
* accuracy: Accuracy.Balanced,
|
|
130
176
|
* timeInterval: 3000,
|
|
131
177
|
* distanceInterval: 10,
|
|
132
178
|
* },
|
|
@@ -352,7 +398,7 @@ interface FetchAlbumPhotosOptions {
|
|
|
352
398
|
* @param {number} [options.maxCount=10] 가져올 사진의 최대 개수를 설정해요. 숫자로 입력하며 기본값은 10이에요.
|
|
353
399
|
* @param {number} [options.maxWidth=1024] 사진의 최대 폭을 제한해요. 단위는 픽셀이며 기본값은 `1024`이에요.
|
|
354
400
|
* @param {boolean} [options.base64=false] 이미지를 base64 형식으로 반환할지 설정해요. 기본값은 `false`예요.
|
|
355
|
-
* @returns {Promise<
|
|
401
|
+
* @returns {Promise<ImageResponse[]>}
|
|
356
402
|
* 앨범 사진의 고유 ID와 데이터 URI를 포함한 배열을 반환해요.
|
|
357
403
|
*
|
|
358
404
|
* @example
|
|
@@ -410,7 +456,7 @@ interface GetCurrentLocationOptions {
|
|
|
410
456
|
*
|
|
411
457
|
* @param {GetCurrentLocationOptions} options 위치 정보를 가져올 때 사용하는 옵션 객체예요.
|
|
412
458
|
* @param {Accuracy} [options.accuracy] 위치 정보의 정확도 수준이에요. 정확도는 `Accuracy` 타입으로 설정돼요.
|
|
413
|
-
* @returns {Promise<Location>} 디바이스의 위치 정보가 담긴 객체를 반환해요.
|
|
459
|
+
* @returns {Promise<Location>} 디바이스의 위치 정보가 담긴 객체를 반환해요. 자세한 내용은 [Location](/reference/framework/Types/Location.html)을 참고해주세요.
|
|
414
460
|
*
|
|
415
461
|
* @example
|
|
416
462
|
* ### 디바이스의 현재 위치 정보 가져오기
|
|
@@ -513,6 +559,36 @@ interface OpenCameraOptions {
|
|
|
513
559
|
*/
|
|
514
560
|
declare function openCamera(options?: OpenCameraOptions): Promise<ImageResponse>;
|
|
515
561
|
|
|
562
|
+
/**
|
|
563
|
+
* @public
|
|
564
|
+
* @tag AppsInTossModule
|
|
565
|
+
* @category AppsInTossModules
|
|
566
|
+
* @kind function
|
|
567
|
+
* @name appLogin
|
|
568
|
+
* @description 토스 인증으로 로그인해요. 로그인이 완료되면 다시 토스 앱으로 이동해요.
|
|
569
|
+
* @example
|
|
570
|
+
*
|
|
571
|
+
* ### 토스 인증을 통해 로그인을 하는 예제
|
|
572
|
+
*
|
|
573
|
+
* ```tsx
|
|
574
|
+
* import { Button } from 'react-native';
|
|
575
|
+
* import { appLogin } from '@apps-in-toss/framework';
|
|
576
|
+
*
|
|
577
|
+
* function Page() {
|
|
578
|
+
* const handleLogin = async () => {
|
|
579
|
+
* const { authorizationCode } = await appLogin();
|
|
580
|
+
*
|
|
581
|
+
* // 획득한 인가 코드(`authorizationCode`)를 서버로 전달해요.
|
|
582
|
+
* }
|
|
583
|
+
*
|
|
584
|
+
* return <Button title="로그인" onPress={handleLogin} />;
|
|
585
|
+
* }
|
|
586
|
+
* ```
|
|
587
|
+
*/
|
|
588
|
+
declare function appLogin(): Promise<{
|
|
589
|
+
authorizationCode: string;
|
|
590
|
+
}>;
|
|
591
|
+
|
|
516
592
|
interface WebViewProps extends Omit<WebViewProps$1, 'source' | 'sharedCookiesEnabled' | 'thirdPartyCookiesEnabled' | 'injectedJavaScriptBeforeContentLoaded'> {
|
|
517
593
|
localhostPort?: number;
|
|
518
594
|
}
|
|
@@ -534,6 +610,7 @@ type UseGeolocationOptions = Omit<StartUpdateLocationOptions, 'callback'>;
|
|
|
534
610
|
* @param {Accuracy} [options.accuracy] 위치 정확도를 설정해요. `Accuracy.Lowest`: 오차범위 3KM 이내, `Accuracy.Low`: 오차범위 1KM 이내, `Accuracy.Balanced`: 오차범위 몇 백미터 이내, `Accuracy.High`: 오차범위 10M 이내, `Accuracy.Highest`: 가장 높은 정확도, `Accuracy.BestForNavigation`: 네비게이션을 위한 최고 정확도
|
|
535
611
|
* @param {number} [options.timeInterval] 위치 정보를 업데이트하는 최소 주기로, 단위는 밀리초(ms)예요. 이 값은 위치 업데이트가 발생하는 가장 짧은 간격을 설정하지만, 시스템이나 환경의 영향을 받아 지정한 주기보다 더 긴 간격으로 업데이트될 수 있어요.
|
|
536
612
|
* @param {number} [options.distanceInterval] 위치 변경 거리를 미터(m) 단위로 설정해요.
|
|
613
|
+
* @returns {Location | null} 디바이스의 위치 정보가 담긴 객체를 반환해요. 자세한 내용은 [Location](/reference/framework/Types/Location.html)을 참고해주세요.
|
|
537
614
|
*
|
|
538
615
|
* @example
|
|
539
616
|
* ### 위치 정보 변경 감지하기
|
|
@@ -569,4 +646,4 @@ declare const env: {
|
|
|
569
646
|
getDeploymentId: () => string | undefined;
|
|
570
647
|
};
|
|
571
648
|
|
|
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 };
|
|
649
|
+
export { Accuracy, AppsInToss, type ContactEntity, type FetchAlbumPhotosOptions, type GetCurrentLocationOptions, type ImageResponse, type Location, type LocationCoords, type OpenCameraOptions, type StartUpdateLocationOptions, type StartUpdateLocationSubscription, type UpdateLocationEventEmitter, type UseGeolocationOptions, WebView, type WebViewProps, appLogin, env, fetchAlbumPhotos, fetchContacts, getClipboardText, getCurrentLocation, openCamera, setClipboardText, startUpdateLocation, useGeolocation };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,26 @@
|
|
|
1
|
+
import { ComponentType, PropsWithChildren } from 'react';
|
|
2
|
+
import { InitialProps, BedrockProps } from 'react-native-bedrock';
|
|
1
3
|
import { EmitterSubscription } from 'react-native';
|
|
2
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
5
|
import { WebViewProps as WebViewProps$1 } from '@react-native-bedrock/native/react-native-webview';
|
|
4
6
|
|
|
7
|
+
type AppsInTossProps = Pick<BedrockProps, 'context'>;
|
|
8
|
+
declare function registerApp(container: ComponentType<PropsWithChildren<InitialProps>>, { context }: AppsInTossProps): (initialProps: InitialProps) => JSX.Element;
|
|
9
|
+
|
|
10
|
+
declare const AppsInToss: {
|
|
11
|
+
registerApp: typeof registerApp;
|
|
12
|
+
};
|
|
13
|
+
|
|
5
14
|
interface EventEmitterSchema<K extends string, P extends unknown[]> {
|
|
6
15
|
name: K;
|
|
7
16
|
params: P;
|
|
8
17
|
}
|
|
9
18
|
|
|
10
19
|
/**
|
|
11
|
-
*
|
|
20
|
+
* @public
|
|
21
|
+
* @category Types
|
|
22
|
+
* @name Accuracy
|
|
23
|
+
* @description 위치 정확도 옵션이에요.
|
|
12
24
|
*/
|
|
13
25
|
declare enum Accuracy {
|
|
14
26
|
/**
|
|
@@ -36,6 +48,12 @@ declare enum Accuracy {
|
|
|
36
48
|
*/
|
|
37
49
|
BestForNavigation = 6
|
|
38
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* @public
|
|
53
|
+
* @category Types
|
|
54
|
+
* @name Location
|
|
55
|
+
* @description 위치 정보를 나타내는 객체예요.
|
|
56
|
+
*/
|
|
39
57
|
interface Location {
|
|
40
58
|
/**
|
|
41
59
|
* Android에서만 지원하는 옵션이에요.
|
|
@@ -50,14 +68,42 @@ interface Location {
|
|
|
50
68
|
* 위치가 업데이트된 시점의 유닉스 타임스탬프예요.
|
|
51
69
|
*/
|
|
52
70
|
timestamp: number;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
71
|
+
/**
|
|
72
|
+
* @description 위치 정보를 나타내는 객체예요. 자세한 내용은 [LocationCoords](/reference/framework/Types/LocationCoords.html)을 참고해주세요.
|
|
73
|
+
*/
|
|
74
|
+
coords: LocationCoords;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* @public
|
|
78
|
+
* @category Types
|
|
79
|
+
* @name LocationCoords
|
|
80
|
+
* @description 세부 위치 정보를 나타내는 객체예요.
|
|
81
|
+
*/
|
|
82
|
+
interface LocationCoords {
|
|
83
|
+
/**
|
|
84
|
+
* 위도
|
|
85
|
+
*/
|
|
86
|
+
latitude: number;
|
|
87
|
+
/**
|
|
88
|
+
* 경도
|
|
89
|
+
*/
|
|
90
|
+
longitude: number;
|
|
91
|
+
/**
|
|
92
|
+
* 높이
|
|
93
|
+
*/
|
|
94
|
+
altitude: number;
|
|
95
|
+
/**
|
|
96
|
+
* 위치 정확도
|
|
97
|
+
*/
|
|
98
|
+
accuracy: number;
|
|
99
|
+
/**
|
|
100
|
+
* 고도 정확도
|
|
101
|
+
*/
|
|
102
|
+
altitudeAccuracy: number;
|
|
103
|
+
/**
|
|
104
|
+
* 방향
|
|
105
|
+
*/
|
|
106
|
+
heading: number;
|
|
61
107
|
}
|
|
62
108
|
/**
|
|
63
109
|
* 사진 조회 결과를 나타내는 타입이에요.
|
|
@@ -109,7 +155,7 @@ interface UpdateLocationEventEmitter extends EventEmitterSchema<'updateLocation'
|
|
|
109
155
|
* @param {number} [options.accuracy] 위치 정확도를 설정해요.
|
|
110
156
|
* @param {number} [options.timeInterval] 위치 정보를 업데이트하는 최소 주기로, 단위는 밀리초(ms)예요. 이 값은 위치 업데이트가 발생하는 가장 짧은 간격을 설정하지만, 시스템이나 환경의 영향을 받아 지정한 주기보다 더 긴 간격으로 업데이트될 수 있어요.
|
|
111
157
|
* @param {number} [options.distanceInterval] 위치 변경 거리를 미터(m) 단위로 설정해요.
|
|
112
|
-
* @param {(location: Location) => void} [options.callback] 위치 정보가 변경될 때 호출되는 콜백 함수예요.
|
|
158
|
+
* @param {(location: Location) => void} [options.callback] 위치 정보가 변경될 때 호출되는 콜백 함수예요. 자세한 내용은 [Location](/reference/framework/Types/Location.html)을 참고해주세요.
|
|
113
159
|
*
|
|
114
160
|
* @example
|
|
115
161
|
* ### 위치 정보 변경 감지하기
|
|
@@ -126,7 +172,7 @@ interface UpdateLocationEventEmitter extends EventEmitterSchema<'updateLocation'
|
|
|
126
172
|
* useEffect(() => {
|
|
127
173
|
* return startUpdateLocation({
|
|
128
174
|
* options: {
|
|
129
|
-
* accuracy: Accuracy.
|
|
175
|
+
* accuracy: Accuracy.Balanced,
|
|
130
176
|
* timeInterval: 3000,
|
|
131
177
|
* distanceInterval: 10,
|
|
132
178
|
* },
|
|
@@ -352,7 +398,7 @@ interface FetchAlbumPhotosOptions {
|
|
|
352
398
|
* @param {number} [options.maxCount=10] 가져올 사진의 최대 개수를 설정해요. 숫자로 입력하며 기본값은 10이에요.
|
|
353
399
|
* @param {number} [options.maxWidth=1024] 사진의 최대 폭을 제한해요. 단위는 픽셀이며 기본값은 `1024`이에요.
|
|
354
400
|
* @param {boolean} [options.base64=false] 이미지를 base64 형식으로 반환할지 설정해요. 기본값은 `false`예요.
|
|
355
|
-
* @returns {Promise<
|
|
401
|
+
* @returns {Promise<ImageResponse[]>}
|
|
356
402
|
* 앨범 사진의 고유 ID와 데이터 URI를 포함한 배열을 반환해요.
|
|
357
403
|
*
|
|
358
404
|
* @example
|
|
@@ -410,7 +456,7 @@ interface GetCurrentLocationOptions {
|
|
|
410
456
|
*
|
|
411
457
|
* @param {GetCurrentLocationOptions} options 위치 정보를 가져올 때 사용하는 옵션 객체예요.
|
|
412
458
|
* @param {Accuracy} [options.accuracy] 위치 정보의 정확도 수준이에요. 정확도는 `Accuracy` 타입으로 설정돼요.
|
|
413
|
-
* @returns {Promise<Location>} 디바이스의 위치 정보가 담긴 객체를 반환해요.
|
|
459
|
+
* @returns {Promise<Location>} 디바이스의 위치 정보가 담긴 객체를 반환해요. 자세한 내용은 [Location](/reference/framework/Types/Location.html)을 참고해주세요.
|
|
414
460
|
*
|
|
415
461
|
* @example
|
|
416
462
|
* ### 디바이스의 현재 위치 정보 가져오기
|
|
@@ -513,6 +559,36 @@ interface OpenCameraOptions {
|
|
|
513
559
|
*/
|
|
514
560
|
declare function openCamera(options?: OpenCameraOptions): Promise<ImageResponse>;
|
|
515
561
|
|
|
562
|
+
/**
|
|
563
|
+
* @public
|
|
564
|
+
* @tag AppsInTossModule
|
|
565
|
+
* @category AppsInTossModules
|
|
566
|
+
* @kind function
|
|
567
|
+
* @name appLogin
|
|
568
|
+
* @description 토스 인증으로 로그인해요. 로그인이 완료되면 다시 토스 앱으로 이동해요.
|
|
569
|
+
* @example
|
|
570
|
+
*
|
|
571
|
+
* ### 토스 인증을 통해 로그인을 하는 예제
|
|
572
|
+
*
|
|
573
|
+
* ```tsx
|
|
574
|
+
* import { Button } from 'react-native';
|
|
575
|
+
* import { appLogin } from '@apps-in-toss/framework';
|
|
576
|
+
*
|
|
577
|
+
* function Page() {
|
|
578
|
+
* const handleLogin = async () => {
|
|
579
|
+
* const { authorizationCode } = await appLogin();
|
|
580
|
+
*
|
|
581
|
+
* // 획득한 인가 코드(`authorizationCode`)를 서버로 전달해요.
|
|
582
|
+
* }
|
|
583
|
+
*
|
|
584
|
+
* return <Button title="로그인" onPress={handleLogin} />;
|
|
585
|
+
* }
|
|
586
|
+
* ```
|
|
587
|
+
*/
|
|
588
|
+
declare function appLogin(): Promise<{
|
|
589
|
+
authorizationCode: string;
|
|
590
|
+
}>;
|
|
591
|
+
|
|
516
592
|
interface WebViewProps extends Omit<WebViewProps$1, 'source' | 'sharedCookiesEnabled' | 'thirdPartyCookiesEnabled' | 'injectedJavaScriptBeforeContentLoaded'> {
|
|
517
593
|
localhostPort?: number;
|
|
518
594
|
}
|
|
@@ -534,6 +610,7 @@ type UseGeolocationOptions = Omit<StartUpdateLocationOptions, 'callback'>;
|
|
|
534
610
|
* @param {Accuracy} [options.accuracy] 위치 정확도를 설정해요. `Accuracy.Lowest`: 오차범위 3KM 이내, `Accuracy.Low`: 오차범위 1KM 이내, `Accuracy.Balanced`: 오차범위 몇 백미터 이내, `Accuracy.High`: 오차범위 10M 이내, `Accuracy.Highest`: 가장 높은 정확도, `Accuracy.BestForNavigation`: 네비게이션을 위한 최고 정확도
|
|
535
611
|
* @param {number} [options.timeInterval] 위치 정보를 업데이트하는 최소 주기로, 단위는 밀리초(ms)예요. 이 값은 위치 업데이트가 발생하는 가장 짧은 간격을 설정하지만, 시스템이나 환경의 영향을 받아 지정한 주기보다 더 긴 간격으로 업데이트될 수 있어요.
|
|
536
612
|
* @param {number} [options.distanceInterval] 위치 변경 거리를 미터(m) 단위로 설정해요.
|
|
613
|
+
* @returns {Location | null} 디바이스의 위치 정보가 담긴 객체를 반환해요. 자세한 내용은 [Location](/reference/framework/Types/Location.html)을 참고해주세요.
|
|
537
614
|
*
|
|
538
615
|
* @example
|
|
539
616
|
* ### 위치 정보 변경 감지하기
|
|
@@ -569,4 +646,4 @@ declare const env: {
|
|
|
569
646
|
getDeploymentId: () => string | undefined;
|
|
570
647
|
};
|
|
571
648
|
|
|
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 };
|
|
649
|
+
export { Accuracy, AppsInToss, type ContactEntity, type FetchAlbumPhotosOptions, type GetCurrentLocationOptions, type ImageResponse, type Location, type LocationCoords, type OpenCameraOptions, type StartUpdateLocationOptions, type StartUpdateLocationSubscription, type UpdateLocationEventEmitter, type UseGeolocationOptions, WebView, type WebViewProps, appLogin, env, fetchAlbumPhotos, fetchContacts, getClipboardText, getCurrentLocation, openCamera, setClipboardText, startUpdateLocation, useGeolocation };
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,32 @@ var __export = (target, all) => {
|
|
|
4
4
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
+
// src/core/registerApp.tsx
|
|
8
|
+
import { Bedrock } from "react-native-bedrock";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
function AppsInTossContainer(Container, { children, ...initialProps }) {
|
|
11
|
+
return /* @__PURE__ */ jsx(Container, { ...initialProps, children });
|
|
12
|
+
}
|
|
13
|
+
function registerApp(container, { context }) {
|
|
14
|
+
return Bedrock.registerApp(AppsInTossContainer.bind(null, container), {
|
|
15
|
+
appName: getAppName(),
|
|
16
|
+
context
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function getAppName() {
|
|
20
|
+
try {
|
|
21
|
+
return global.__bedrock.app.name;
|
|
22
|
+
} catch (error) {
|
|
23
|
+
console.error("unexpected error occurred while getting app name");
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// src/core/index.ts
|
|
29
|
+
var AppsInToss = {
|
|
30
|
+
registerApp
|
|
31
|
+
};
|
|
32
|
+
|
|
7
33
|
// src/native-event-emitter/index.ts
|
|
8
34
|
var native_event_emitter_exports = {};
|
|
9
35
|
__export(native_event_emitter_exports, {
|
|
@@ -86,6 +112,7 @@ function startUpdateLocation(eventParams) {
|
|
|
86
112
|
// src/native-modules/index.ts
|
|
87
113
|
var native_modules_exports = {};
|
|
88
114
|
__export(native_modules_exports, {
|
|
115
|
+
appLogin: () => appLogin,
|
|
89
116
|
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
90
117
|
fetchContacts: () => fetchContacts,
|
|
91
118
|
getClipboardText: () => getClipboardText,
|
|
@@ -147,6 +174,14 @@ async function fetchAlbumPhotos(options) {
|
|
|
147
174
|
maxCount: options.maxCount ?? DEFAULT_MAX_COUNT,
|
|
148
175
|
maxWidth: options.maxWidth ?? DEFAULT_MAX_WIDTH
|
|
149
176
|
});
|
|
177
|
+
if (options.base64) {
|
|
178
|
+
return albumPhotos.map((photo) => {
|
|
179
|
+
return {
|
|
180
|
+
...photo,
|
|
181
|
+
dataUri: `data:image/jpeg;base64,${photo.dataUri}`
|
|
182
|
+
};
|
|
183
|
+
});
|
|
184
|
+
}
|
|
150
185
|
return albumPhotos;
|
|
151
186
|
}
|
|
152
187
|
|
|
@@ -170,6 +205,11 @@ async function openCamera(options) {
|
|
|
170
205
|
return photo;
|
|
171
206
|
}
|
|
172
207
|
|
|
208
|
+
// src/native-modules/appLogin.ts
|
|
209
|
+
async function appLogin() {
|
|
210
|
+
return AppsInTossModule.appLogin({});
|
|
211
|
+
}
|
|
212
|
+
|
|
173
213
|
// src/components/WebView.tsx
|
|
174
214
|
import {
|
|
175
215
|
WebView as OriginalWebView
|
|
@@ -178,7 +218,7 @@ import { useMemo } from "react";
|
|
|
178
218
|
import { useBridgeHandler } from "react-native-bedrock";
|
|
179
219
|
import * as bridges from "react-native-bedrock/bridges";
|
|
180
220
|
import * as constantBridges from "react-native-bedrock/constants";
|
|
181
|
-
import { jsx } from "react/jsx-runtime";
|
|
221
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
182
222
|
function WebView({ localhostPort = 5173, onMessage, ...props }) {
|
|
183
223
|
const uri = useMemo(() => {
|
|
184
224
|
if (__DEV__) {
|
|
@@ -200,7 +240,7 @@ function WebView({ localhostPort = 5173, onMessage, ...props }) {
|
|
|
200
240
|
...native_modules_exports
|
|
201
241
|
}
|
|
202
242
|
});
|
|
203
|
-
return /* @__PURE__ */
|
|
243
|
+
return /* @__PURE__ */ jsx2(
|
|
204
244
|
OriginalWebView,
|
|
205
245
|
{
|
|
206
246
|
ref: handler.ref,
|
|
@@ -255,7 +295,9 @@ var Accuracy2 = /* @__PURE__ */ ((Accuracy3) => {
|
|
|
255
295
|
})(Accuracy2 || {});
|
|
256
296
|
export {
|
|
257
297
|
Accuracy2 as Accuracy,
|
|
298
|
+
AppsInToss,
|
|
258
299
|
WebView,
|
|
300
|
+
appLogin,
|
|
259
301
|
env,
|
|
260
302
|
fetchAlbumPhotos,
|
|
261
303
|
fetchContacts,
|
|
@@ -0,0 +1,24 @@
|
|
|
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
|
|
17
|
+
// src/jest/index.ts
|
|
18
|
+
var jest_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(jest_exports);
|
|
20
|
+
__reExport(jest_exports, require("react-native-bedrock/jest"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("react-native-bedrock/jest")
|
|
24
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from 'react-native-bedrock/jest';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from 'react-native-bedrock/jest';
|