@apps-in-toss/framework 0.0.9 → 0.0.11
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/dist/index.cjs +46 -28
- package/dist/index.d.cts +55 -35
- package/dist/index.d.ts +55 -35
- package/dist/index.js +45 -28
- package/package.json +20 -10
- package/src/async-bridges.ts +7 -0
- package/src/constant-bridges.ts +1 -0
- package/src/event-bridges.ts +1 -0
- package/src/bridges.ts +0 -2
package/dist/index.cjs
CHANGED
|
@@ -39,6 +39,7 @@ __export(src_exports, {
|
|
|
39
39
|
fetchContacts: () => fetchContacts,
|
|
40
40
|
getClipboardText: () => getClipboardText,
|
|
41
41
|
getCurrentLocation: () => getCurrentLocation,
|
|
42
|
+
getOperationalEnvironment: () => getOperationalEnvironment,
|
|
42
43
|
openCamera: () => openCamera,
|
|
43
44
|
setClipboardText: () => setClipboardText,
|
|
44
45
|
startUpdateLocation: () => startUpdateLocation,
|
|
@@ -72,12 +73,6 @@ var AppsInToss = {
|
|
|
72
73
|
registerApp
|
|
73
74
|
};
|
|
74
75
|
|
|
75
|
-
// src/native-event-emitter/index.ts
|
|
76
|
-
var native_event_emitter_exports = {};
|
|
77
|
-
__export(native_event_emitter_exports, {
|
|
78
|
-
startUpdateLocation: () => startUpdateLocation
|
|
79
|
-
});
|
|
80
|
-
|
|
81
76
|
// src/native-event-emitter/bedrock-event.ts
|
|
82
77
|
var import_react_native_bedrock3 = require("react-native-bedrock");
|
|
83
78
|
|
|
@@ -151,18 +146,6 @@ function startUpdateLocation(eventParams) {
|
|
|
151
146
|
return appsInTossEvent.addEventListener("updateLocationEvent", eventParams);
|
|
152
147
|
}
|
|
153
148
|
|
|
154
|
-
// src/native-modules/index.ts
|
|
155
|
-
var native_modules_exports = {};
|
|
156
|
-
__export(native_modules_exports, {
|
|
157
|
-
appLogin: () => appLogin,
|
|
158
|
-
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
159
|
-
fetchContacts: () => fetchContacts,
|
|
160
|
-
getClipboardText: () => getClipboardText,
|
|
161
|
-
getCurrentLocation: () => getCurrentLocation,
|
|
162
|
-
openCamera: () => openCamera,
|
|
163
|
-
setClipboardText: () => setClipboardText
|
|
164
|
-
});
|
|
165
|
-
|
|
166
149
|
// src/native-modules/setClipboardText.ts
|
|
167
150
|
async function setClipboardText(text) {
|
|
168
151
|
const permissionStatus = await requestPermission({ name: "clipboard", access: "write" });
|
|
@@ -252,32 +235,66 @@ async function appLogin() {
|
|
|
252
235
|
return AppsInTossModule.appLogin({});
|
|
253
236
|
}
|
|
254
237
|
|
|
238
|
+
// src/native-modules/getOperationalEnvironment.ts
|
|
239
|
+
function getOperationalEnvironment() {
|
|
240
|
+
return AppsInTossModule.operationalEnvironment;
|
|
241
|
+
}
|
|
242
|
+
|
|
255
243
|
// src/components/WebView.tsx
|
|
256
244
|
var import_react_native_webview = require("@react-native-bedrock/native/react-native-webview");
|
|
257
245
|
var import_react = require("react");
|
|
258
246
|
var import_react_native_bedrock4 = require("react-native-bedrock");
|
|
259
|
-
var
|
|
260
|
-
var
|
|
247
|
+
var bedrockAsyncBridges = __toESM(require("react-native-bedrock/async-bridges"), 1);
|
|
248
|
+
var bedrockConstantBridges = __toESM(require("react-native-bedrock/constant-bridges"), 1);
|
|
249
|
+
|
|
250
|
+
// src/async-bridges.ts
|
|
251
|
+
var async_bridges_exports = {};
|
|
252
|
+
__export(async_bridges_exports, {
|
|
253
|
+
appLogin: () => appLogin,
|
|
254
|
+
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
255
|
+
fetchContacts: () => fetchContacts,
|
|
256
|
+
getClipboardText: () => getClipboardText,
|
|
257
|
+
getCurrentLocation: () => getCurrentLocation,
|
|
258
|
+
openCamera: () => openCamera,
|
|
259
|
+
setClipboardText: () => setClipboardText
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
// src/constant-bridges.ts
|
|
263
|
+
var constant_bridges_exports = {};
|
|
264
|
+
__export(constant_bridges_exports, {
|
|
265
|
+
getOperationalEnvironment: () => getOperationalEnvironment
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
// src/event-bridges.ts
|
|
269
|
+
var event_bridges_exports = {};
|
|
270
|
+
__export(event_bridges_exports, {
|
|
271
|
+
startUpdateLocation: () => startUpdateLocation
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
// src/components/WebView.tsx
|
|
261
275
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
262
|
-
function WebView({
|
|
276
|
+
function WebView({ local, onMessage, ...props }) {
|
|
263
277
|
const uri = (0, import_react.useMemo)(() => {
|
|
264
278
|
if (__DEV__) {
|
|
265
|
-
return `http
|
|
279
|
+
return `http://${local.host}:${local.port}`;
|
|
266
280
|
}
|
|
267
281
|
return AppsInTossModule.getWebBundleURL({}).url;
|
|
268
|
-
}, [
|
|
282
|
+
}, [local]);
|
|
269
283
|
const handler = (0, import_react_native_bedrock4.useBridgeHandler)({
|
|
270
284
|
onMessage,
|
|
271
285
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
272
|
-
eventListenerMap:
|
|
286
|
+
eventListenerMap: event_bridges_exports,
|
|
273
287
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
274
288
|
// @ts-expect-error
|
|
275
|
-
constantHandlerMap:
|
|
289
|
+
constantHandlerMap: {
|
|
290
|
+
...bedrockConstantBridges,
|
|
291
|
+
...constant_bridges_exports
|
|
292
|
+
},
|
|
276
293
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
277
294
|
// @ts-expect-error
|
|
278
|
-
|
|
279
|
-
...
|
|
280
|
-
...
|
|
295
|
+
asyncHandlerMap: {
|
|
296
|
+
...bedrockAsyncBridges,
|
|
297
|
+
...async_bridges_exports
|
|
281
298
|
}
|
|
282
299
|
});
|
|
283
300
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
@@ -344,6 +361,7 @@ var Accuracy2 = /* @__PURE__ */ ((Accuracy3) => {
|
|
|
344
361
|
fetchContacts,
|
|
345
362
|
getClipboardText,
|
|
346
363
|
getCurrentLocation,
|
|
364
|
+
getOperationalEnvironment,
|
|
347
365
|
openCamera,
|
|
348
366
|
setClipboardText,
|
|
349
367
|
startUpdateLocation,
|
package/dist/index.d.cts
CHANGED
|
@@ -18,7 +18,7 @@ interface EventEmitterSchema<K extends string, P extends unknown[]> {
|
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* @public
|
|
21
|
-
* @category
|
|
21
|
+
* @category 위치 정보
|
|
22
22
|
* @name Accuracy
|
|
23
23
|
* @description 위치 정확도 옵션이에요.
|
|
24
24
|
*/
|
|
@@ -50,7 +50,7 @@ declare enum Accuracy {
|
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* @public
|
|
53
|
-
* @category
|
|
53
|
+
* @category 위치 정보
|
|
54
54
|
* @name Location
|
|
55
55
|
* @description 위치 정보를 나타내는 객체예요.
|
|
56
56
|
*/
|
|
@@ -75,7 +75,7 @@ interface Location {
|
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
77
|
* @public
|
|
78
|
-
* @category
|
|
78
|
+
* @category 위치 정보
|
|
79
79
|
* @name LocationCoords
|
|
80
80
|
* @description 세부 위치 정보를 나타내는 객체예요.
|
|
81
81
|
*/
|
|
@@ -143,9 +143,7 @@ interface UpdateLocationEventEmitter extends EventEmitterSchema<'updateLocation'
|
|
|
143
143
|
}
|
|
144
144
|
/**
|
|
145
145
|
* @public
|
|
146
|
-
* @
|
|
147
|
-
* @category AppsInTossModules
|
|
148
|
-
* @kind function
|
|
146
|
+
* @category 위치 정보
|
|
149
147
|
* @name startUpdateLocation
|
|
150
148
|
* @description 디바이스의 위치 정보를 지속적으로 감지하고, 위치가 변경되면 콜백을 실행하는 함수예요. 콜백 함수를 등록하면 위치가 변경될 때마다 자동으로 호출돼요.
|
|
151
149
|
* 실시간 위치 추적이 필요한 기능을 구현할 때 사용할 수 있어요. 예를 들어 지도 앱에서 사용자의 현재 위치를 실시간으로 업데이트할 때, 운동 앱에서 사용자의 이동 거리를 기록할 때 등이에요.
|
|
@@ -210,9 +208,7 @@ declare function startUpdateLocation(eventParams: {
|
|
|
210
208
|
|
|
211
209
|
/**
|
|
212
210
|
* @public
|
|
213
|
-
* @
|
|
214
|
-
* @category AppsInTossModules
|
|
215
|
-
* @kind function
|
|
211
|
+
* @category 클립보드
|
|
216
212
|
* @name setClipboardText
|
|
217
213
|
* @description 텍스트를 클립보드에 복사해서 사용자가 다른 곳에 붙여 넣기 할 수 있어요.
|
|
218
214
|
* @param {Promise<void>} text - 클립보드에 복사할 텍스트예요. 문자열 형식으로 입력해요.
|
|
@@ -243,9 +239,7 @@ declare function setClipboardText(text: string): Promise<void>;
|
|
|
243
239
|
|
|
244
240
|
/**
|
|
245
241
|
* @public
|
|
246
|
-
* @
|
|
247
|
-
* @category AppsInTossModules
|
|
248
|
-
* @kind function
|
|
242
|
+
* @category 클립보드
|
|
249
243
|
* @name getClipboardText
|
|
250
244
|
* @description 클립보드에 저장된 텍스트를 가져오는 함수예요. 복사된 텍스트를 읽어서 다른 작업에 활용할 수 있어요.
|
|
251
245
|
* @returns {Promise<string>} - 클립보드에 저장된 텍스트를 반환해요. 클립보드에 텍스트가 없으면 빈 문자열을 반환해요.
|
|
@@ -293,9 +287,7 @@ interface ContactEntity {
|
|
|
293
287
|
}
|
|
294
288
|
/**
|
|
295
289
|
* @public
|
|
296
|
-
* @
|
|
297
|
-
* @category AppsInTossModules
|
|
298
|
-
* @kind function
|
|
290
|
+
* @category 연락처
|
|
299
291
|
* @name fetchContacts
|
|
300
292
|
* @description 사용자의 연락처 목록을 페이지 단위로 가져오는 함수예요.
|
|
301
293
|
* @param size - 한 번에 가져올 연락처 개수예요. 예를 들어, 10을 전달하면 최대 10개의 연락처를 가져와요.
|
|
@@ -386,9 +378,7 @@ interface FetchAlbumPhotosOptions {
|
|
|
386
378
|
}
|
|
387
379
|
/**
|
|
388
380
|
* @public
|
|
389
|
-
* @
|
|
390
|
-
* @category AppsInTossModules
|
|
391
|
-
* @kind function
|
|
381
|
+
* @category 사진
|
|
392
382
|
* @name fetchAlbumPhotos
|
|
393
383
|
* @description
|
|
394
384
|
* 사용자의 앨범에서 사진 목록을 불러오는 함수예요.
|
|
@@ -446,9 +436,7 @@ interface GetCurrentLocationOptions {
|
|
|
446
436
|
}
|
|
447
437
|
/**
|
|
448
438
|
* @public
|
|
449
|
-
* @
|
|
450
|
-
* @category AppsInTossModules
|
|
451
|
-
* @kind function
|
|
439
|
+
* @category 위치 정보
|
|
452
440
|
* @name getCurrentLocation
|
|
453
441
|
* @description 디바이스의 현재 위치 정보를 가져오는 함수예요.
|
|
454
442
|
* 위치 기반 서비스를 구현할 때 사용되고, 한 번만 호출되어 현재 위치를 즉시 반환해요.
|
|
@@ -510,9 +498,7 @@ interface OpenCameraOptions {
|
|
|
510
498
|
}
|
|
511
499
|
/**
|
|
512
500
|
* @public
|
|
513
|
-
* @
|
|
514
|
-
* @category AppsInTossModules
|
|
515
|
-
* @kind function
|
|
501
|
+
* @category 카메라
|
|
516
502
|
* @name openCamera
|
|
517
503
|
* @description 카메라를 실행해서 촬영된 이미지를 반환하는 함수예요.
|
|
518
504
|
* @param {OpenCameraOptions} options - 카메라 실행 시 사용되는 옵션 객체예요.
|
|
@@ -561,9 +547,7 @@ declare function openCamera(options?: OpenCameraOptions): Promise<ImageResponse>
|
|
|
561
547
|
|
|
562
548
|
/**
|
|
563
549
|
* @public
|
|
564
|
-
* @
|
|
565
|
-
* @category AppsInTossModules
|
|
566
|
-
* @kind function
|
|
550
|
+
* @category 로그인
|
|
567
551
|
* @name appLogin
|
|
568
552
|
* @description 토스 인증으로 로그인해요. 로그인이 완료되면 다시 토스 앱으로 이동해요.
|
|
569
553
|
* @example
|
|
@@ -576,9 +560,9 @@ declare function openCamera(options?: OpenCameraOptions): Promise<ImageResponse>
|
|
|
576
560
|
*
|
|
577
561
|
* function Page() {
|
|
578
562
|
* const handleLogin = async () => {
|
|
579
|
-
* const { authorizationCode } = await appLogin();
|
|
563
|
+
* const { authorizationCode, referrer } = await appLogin();
|
|
580
564
|
*
|
|
581
|
-
* // 획득한 인가 코드(`authorizationCode`)
|
|
565
|
+
* // 획득한 인가 코드(`authorizationCode`)와 `referrer`를 서버로 전달해요.
|
|
582
566
|
* }
|
|
583
567
|
*
|
|
584
568
|
* return <Button title="로그인" onPress={handleLogin} />;
|
|
@@ -587,19 +571,55 @@ declare function openCamera(options?: OpenCameraOptions): Promise<ImageResponse>
|
|
|
587
571
|
*/
|
|
588
572
|
declare function appLogin(): Promise<{
|
|
589
573
|
authorizationCode: string;
|
|
574
|
+
referrer: "DEFAULT" | "SANDBOX";
|
|
590
575
|
}>;
|
|
591
576
|
|
|
577
|
+
/**
|
|
578
|
+
* @public
|
|
579
|
+
* @category 환경 확인
|
|
580
|
+
* @kind function
|
|
581
|
+
* @name getOperationalEnvironment
|
|
582
|
+
* @description
|
|
583
|
+
* 현재 실행 중인 앱의 운영 환경을 확인해요.
|
|
584
|
+
* 토스 앱에서 실행 중이라면 `'toss'`, 샌드박스 환경에서 실행 중이라면 `'sandbox'`를 반환해요.
|
|
585
|
+
*
|
|
586
|
+
* 운영 환경은 앱이 실행되는 컨텍스트를 의미하며, 특정 기능의 사용 가능 여부를 판단하는 데 활용할 수 있어요.
|
|
587
|
+
*
|
|
588
|
+
* @returns {'toss' | 'sandbox'}
|
|
589
|
+
* 현재 운영 환경을 나타내는 문자열이에요.
|
|
590
|
+
* - `'toss'`: 토스 앱에서 실행 중이에요.
|
|
591
|
+
* - `'sandbox'`: 샌드박스 환경에서 실행 중이에요.
|
|
592
|
+
*
|
|
593
|
+
* @example
|
|
594
|
+
* ### 현재 운영 환경 확인하기
|
|
595
|
+
*
|
|
596
|
+
* ```tsx
|
|
597
|
+
* import { getOperationalEnvironment } from '@apps-in-toss/framework';
|
|
598
|
+
* import { Text } from 'react-native';
|
|
599
|
+
*
|
|
600
|
+
* function EnvironmentInfo() {
|
|
601
|
+
* const environment = getOperationalEnvironment();
|
|
602
|
+
*
|
|
603
|
+
* return (
|
|
604
|
+
* <Text>현재 운영 환경: {environment}</Text>
|
|
605
|
+
* );
|
|
606
|
+
* }
|
|
607
|
+
* ```
|
|
608
|
+
*/
|
|
609
|
+
declare function getOperationalEnvironment(): 'toss' | 'sandbox';
|
|
610
|
+
|
|
592
611
|
interface WebViewProps extends Omit<WebViewProps$1, 'source' | 'sharedCookiesEnabled' | 'thirdPartyCookiesEnabled' | 'injectedJavaScriptBeforeContentLoaded'> {
|
|
593
|
-
|
|
612
|
+
local: {
|
|
613
|
+
port: number;
|
|
614
|
+
host: number;
|
|
615
|
+
};
|
|
594
616
|
}
|
|
595
|
-
declare function WebView({
|
|
617
|
+
declare function WebView({ local, onMessage, ...props }: WebViewProps): react_jsx_runtime.JSX.Element;
|
|
596
618
|
|
|
597
619
|
type UseGeolocationOptions = Omit<StartUpdateLocationOptions, 'callback'>;
|
|
598
620
|
/**
|
|
599
621
|
* @public
|
|
600
|
-
* @
|
|
601
|
-
* @category AppsInTossModules
|
|
602
|
-
* @kind function
|
|
622
|
+
* @category 위치 정보
|
|
603
623
|
* @name useGeolocation
|
|
604
624
|
* @description 디바이스의 위치 정보를 반환하는 훅이에요. 위치가 변경되면 값도 변경돼요.
|
|
605
625
|
* GPS 정보를 활용해 현재 위치를 감지하고, 사용자의 이동에 따라 자동으로 업데이트돼요.
|
|
@@ -646,4 +666,4 @@ declare const env: {
|
|
|
646
666
|
getDeploymentId: () => string | undefined;
|
|
647
667
|
};
|
|
648
668
|
|
|
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 };
|
|
669
|
+
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, getOperationalEnvironment, openCamera, setClipboardText, startUpdateLocation, useGeolocation };
|
package/dist/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ interface EventEmitterSchema<K extends string, P extends unknown[]> {
|
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* @public
|
|
21
|
-
* @category
|
|
21
|
+
* @category 위치 정보
|
|
22
22
|
* @name Accuracy
|
|
23
23
|
* @description 위치 정확도 옵션이에요.
|
|
24
24
|
*/
|
|
@@ -50,7 +50,7 @@ declare enum Accuracy {
|
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* @public
|
|
53
|
-
* @category
|
|
53
|
+
* @category 위치 정보
|
|
54
54
|
* @name Location
|
|
55
55
|
* @description 위치 정보를 나타내는 객체예요.
|
|
56
56
|
*/
|
|
@@ -75,7 +75,7 @@ interface Location {
|
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
77
|
* @public
|
|
78
|
-
* @category
|
|
78
|
+
* @category 위치 정보
|
|
79
79
|
* @name LocationCoords
|
|
80
80
|
* @description 세부 위치 정보를 나타내는 객체예요.
|
|
81
81
|
*/
|
|
@@ -143,9 +143,7 @@ interface UpdateLocationEventEmitter extends EventEmitterSchema<'updateLocation'
|
|
|
143
143
|
}
|
|
144
144
|
/**
|
|
145
145
|
* @public
|
|
146
|
-
* @
|
|
147
|
-
* @category AppsInTossModules
|
|
148
|
-
* @kind function
|
|
146
|
+
* @category 위치 정보
|
|
149
147
|
* @name startUpdateLocation
|
|
150
148
|
* @description 디바이스의 위치 정보를 지속적으로 감지하고, 위치가 변경되면 콜백을 실행하는 함수예요. 콜백 함수를 등록하면 위치가 변경될 때마다 자동으로 호출돼요.
|
|
151
149
|
* 실시간 위치 추적이 필요한 기능을 구현할 때 사용할 수 있어요. 예를 들어 지도 앱에서 사용자의 현재 위치를 실시간으로 업데이트할 때, 운동 앱에서 사용자의 이동 거리를 기록할 때 등이에요.
|
|
@@ -210,9 +208,7 @@ declare function startUpdateLocation(eventParams: {
|
|
|
210
208
|
|
|
211
209
|
/**
|
|
212
210
|
* @public
|
|
213
|
-
* @
|
|
214
|
-
* @category AppsInTossModules
|
|
215
|
-
* @kind function
|
|
211
|
+
* @category 클립보드
|
|
216
212
|
* @name setClipboardText
|
|
217
213
|
* @description 텍스트를 클립보드에 복사해서 사용자가 다른 곳에 붙여 넣기 할 수 있어요.
|
|
218
214
|
* @param {Promise<void>} text - 클립보드에 복사할 텍스트예요. 문자열 형식으로 입력해요.
|
|
@@ -243,9 +239,7 @@ declare function setClipboardText(text: string): Promise<void>;
|
|
|
243
239
|
|
|
244
240
|
/**
|
|
245
241
|
* @public
|
|
246
|
-
* @
|
|
247
|
-
* @category AppsInTossModules
|
|
248
|
-
* @kind function
|
|
242
|
+
* @category 클립보드
|
|
249
243
|
* @name getClipboardText
|
|
250
244
|
* @description 클립보드에 저장된 텍스트를 가져오는 함수예요. 복사된 텍스트를 읽어서 다른 작업에 활용할 수 있어요.
|
|
251
245
|
* @returns {Promise<string>} - 클립보드에 저장된 텍스트를 반환해요. 클립보드에 텍스트가 없으면 빈 문자열을 반환해요.
|
|
@@ -293,9 +287,7 @@ interface ContactEntity {
|
|
|
293
287
|
}
|
|
294
288
|
/**
|
|
295
289
|
* @public
|
|
296
|
-
* @
|
|
297
|
-
* @category AppsInTossModules
|
|
298
|
-
* @kind function
|
|
290
|
+
* @category 연락처
|
|
299
291
|
* @name fetchContacts
|
|
300
292
|
* @description 사용자의 연락처 목록을 페이지 단위로 가져오는 함수예요.
|
|
301
293
|
* @param size - 한 번에 가져올 연락처 개수예요. 예를 들어, 10을 전달하면 최대 10개의 연락처를 가져와요.
|
|
@@ -386,9 +378,7 @@ interface FetchAlbumPhotosOptions {
|
|
|
386
378
|
}
|
|
387
379
|
/**
|
|
388
380
|
* @public
|
|
389
|
-
* @
|
|
390
|
-
* @category AppsInTossModules
|
|
391
|
-
* @kind function
|
|
381
|
+
* @category 사진
|
|
392
382
|
* @name fetchAlbumPhotos
|
|
393
383
|
* @description
|
|
394
384
|
* 사용자의 앨범에서 사진 목록을 불러오는 함수예요.
|
|
@@ -446,9 +436,7 @@ interface GetCurrentLocationOptions {
|
|
|
446
436
|
}
|
|
447
437
|
/**
|
|
448
438
|
* @public
|
|
449
|
-
* @
|
|
450
|
-
* @category AppsInTossModules
|
|
451
|
-
* @kind function
|
|
439
|
+
* @category 위치 정보
|
|
452
440
|
* @name getCurrentLocation
|
|
453
441
|
* @description 디바이스의 현재 위치 정보를 가져오는 함수예요.
|
|
454
442
|
* 위치 기반 서비스를 구현할 때 사용되고, 한 번만 호출되어 현재 위치를 즉시 반환해요.
|
|
@@ -510,9 +498,7 @@ interface OpenCameraOptions {
|
|
|
510
498
|
}
|
|
511
499
|
/**
|
|
512
500
|
* @public
|
|
513
|
-
* @
|
|
514
|
-
* @category AppsInTossModules
|
|
515
|
-
* @kind function
|
|
501
|
+
* @category 카메라
|
|
516
502
|
* @name openCamera
|
|
517
503
|
* @description 카메라를 실행해서 촬영된 이미지를 반환하는 함수예요.
|
|
518
504
|
* @param {OpenCameraOptions} options - 카메라 실행 시 사용되는 옵션 객체예요.
|
|
@@ -561,9 +547,7 @@ declare function openCamera(options?: OpenCameraOptions): Promise<ImageResponse>
|
|
|
561
547
|
|
|
562
548
|
/**
|
|
563
549
|
* @public
|
|
564
|
-
* @
|
|
565
|
-
* @category AppsInTossModules
|
|
566
|
-
* @kind function
|
|
550
|
+
* @category 로그인
|
|
567
551
|
* @name appLogin
|
|
568
552
|
* @description 토스 인증으로 로그인해요. 로그인이 완료되면 다시 토스 앱으로 이동해요.
|
|
569
553
|
* @example
|
|
@@ -576,9 +560,9 @@ declare function openCamera(options?: OpenCameraOptions): Promise<ImageResponse>
|
|
|
576
560
|
*
|
|
577
561
|
* function Page() {
|
|
578
562
|
* const handleLogin = async () => {
|
|
579
|
-
* const { authorizationCode } = await appLogin();
|
|
563
|
+
* const { authorizationCode, referrer } = await appLogin();
|
|
580
564
|
*
|
|
581
|
-
* // 획득한 인가 코드(`authorizationCode`)
|
|
565
|
+
* // 획득한 인가 코드(`authorizationCode`)와 `referrer`를 서버로 전달해요.
|
|
582
566
|
* }
|
|
583
567
|
*
|
|
584
568
|
* return <Button title="로그인" onPress={handleLogin} />;
|
|
@@ -587,19 +571,55 @@ declare function openCamera(options?: OpenCameraOptions): Promise<ImageResponse>
|
|
|
587
571
|
*/
|
|
588
572
|
declare function appLogin(): Promise<{
|
|
589
573
|
authorizationCode: string;
|
|
574
|
+
referrer: "DEFAULT" | "SANDBOX";
|
|
590
575
|
}>;
|
|
591
576
|
|
|
577
|
+
/**
|
|
578
|
+
* @public
|
|
579
|
+
* @category 환경 확인
|
|
580
|
+
* @kind function
|
|
581
|
+
* @name getOperationalEnvironment
|
|
582
|
+
* @description
|
|
583
|
+
* 현재 실행 중인 앱의 운영 환경을 확인해요.
|
|
584
|
+
* 토스 앱에서 실행 중이라면 `'toss'`, 샌드박스 환경에서 실행 중이라면 `'sandbox'`를 반환해요.
|
|
585
|
+
*
|
|
586
|
+
* 운영 환경은 앱이 실행되는 컨텍스트를 의미하며, 특정 기능의 사용 가능 여부를 판단하는 데 활용할 수 있어요.
|
|
587
|
+
*
|
|
588
|
+
* @returns {'toss' | 'sandbox'}
|
|
589
|
+
* 현재 운영 환경을 나타내는 문자열이에요.
|
|
590
|
+
* - `'toss'`: 토스 앱에서 실행 중이에요.
|
|
591
|
+
* - `'sandbox'`: 샌드박스 환경에서 실행 중이에요.
|
|
592
|
+
*
|
|
593
|
+
* @example
|
|
594
|
+
* ### 현재 운영 환경 확인하기
|
|
595
|
+
*
|
|
596
|
+
* ```tsx
|
|
597
|
+
* import { getOperationalEnvironment } from '@apps-in-toss/framework';
|
|
598
|
+
* import { Text } from 'react-native';
|
|
599
|
+
*
|
|
600
|
+
* function EnvironmentInfo() {
|
|
601
|
+
* const environment = getOperationalEnvironment();
|
|
602
|
+
*
|
|
603
|
+
* return (
|
|
604
|
+
* <Text>현재 운영 환경: {environment}</Text>
|
|
605
|
+
* );
|
|
606
|
+
* }
|
|
607
|
+
* ```
|
|
608
|
+
*/
|
|
609
|
+
declare function getOperationalEnvironment(): 'toss' | 'sandbox';
|
|
610
|
+
|
|
592
611
|
interface WebViewProps extends Omit<WebViewProps$1, 'source' | 'sharedCookiesEnabled' | 'thirdPartyCookiesEnabled' | 'injectedJavaScriptBeforeContentLoaded'> {
|
|
593
|
-
|
|
612
|
+
local: {
|
|
613
|
+
port: number;
|
|
614
|
+
host: number;
|
|
615
|
+
};
|
|
594
616
|
}
|
|
595
|
-
declare function WebView({
|
|
617
|
+
declare function WebView({ local, onMessage, ...props }: WebViewProps): react_jsx_runtime.JSX.Element;
|
|
596
618
|
|
|
597
619
|
type UseGeolocationOptions = Omit<StartUpdateLocationOptions, 'callback'>;
|
|
598
620
|
/**
|
|
599
621
|
* @public
|
|
600
|
-
* @
|
|
601
|
-
* @category AppsInTossModules
|
|
602
|
-
* @kind function
|
|
622
|
+
* @category 위치 정보
|
|
603
623
|
* @name useGeolocation
|
|
604
624
|
* @description 디바이스의 위치 정보를 반환하는 훅이에요. 위치가 변경되면 값도 변경돼요.
|
|
605
625
|
* GPS 정보를 활용해 현재 위치를 감지하고, 사용자의 이동에 따라 자동으로 업데이트돼요.
|
|
@@ -646,4 +666,4 @@ declare const env: {
|
|
|
646
666
|
getDeploymentId: () => string | undefined;
|
|
647
667
|
};
|
|
648
668
|
|
|
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 };
|
|
669
|
+
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, getOperationalEnvironment, openCamera, setClipboardText, startUpdateLocation, useGeolocation };
|
package/dist/index.js
CHANGED
|
@@ -30,12 +30,6 @@ var AppsInToss = {
|
|
|
30
30
|
registerApp
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
// src/native-event-emitter/index.ts
|
|
34
|
-
var native_event_emitter_exports = {};
|
|
35
|
-
__export(native_event_emitter_exports, {
|
|
36
|
-
startUpdateLocation: () => startUpdateLocation
|
|
37
|
-
});
|
|
38
|
-
|
|
39
33
|
// src/native-event-emitter/bedrock-event.ts
|
|
40
34
|
import { BedrockEvent } from "react-native-bedrock";
|
|
41
35
|
|
|
@@ -109,18 +103,6 @@ function startUpdateLocation(eventParams) {
|
|
|
109
103
|
return appsInTossEvent.addEventListener("updateLocationEvent", eventParams);
|
|
110
104
|
}
|
|
111
105
|
|
|
112
|
-
// src/native-modules/index.ts
|
|
113
|
-
var native_modules_exports = {};
|
|
114
|
-
__export(native_modules_exports, {
|
|
115
|
-
appLogin: () => appLogin,
|
|
116
|
-
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
117
|
-
fetchContacts: () => fetchContacts,
|
|
118
|
-
getClipboardText: () => getClipboardText,
|
|
119
|
-
getCurrentLocation: () => getCurrentLocation,
|
|
120
|
-
openCamera: () => openCamera,
|
|
121
|
-
setClipboardText: () => setClipboardText
|
|
122
|
-
});
|
|
123
|
-
|
|
124
106
|
// src/native-modules/setClipboardText.ts
|
|
125
107
|
async function setClipboardText(text) {
|
|
126
108
|
const permissionStatus = await requestPermission({ name: "clipboard", access: "write" });
|
|
@@ -210,34 +192,68 @@ async function appLogin() {
|
|
|
210
192
|
return AppsInTossModule.appLogin({});
|
|
211
193
|
}
|
|
212
194
|
|
|
195
|
+
// src/native-modules/getOperationalEnvironment.ts
|
|
196
|
+
function getOperationalEnvironment() {
|
|
197
|
+
return AppsInTossModule.operationalEnvironment;
|
|
198
|
+
}
|
|
199
|
+
|
|
213
200
|
// src/components/WebView.tsx
|
|
214
201
|
import {
|
|
215
202
|
WebView as OriginalWebView
|
|
216
203
|
} from "@react-native-bedrock/native/react-native-webview";
|
|
217
204
|
import { useMemo } from "react";
|
|
218
205
|
import { useBridgeHandler } from "react-native-bedrock";
|
|
219
|
-
import * as
|
|
220
|
-
import * as
|
|
206
|
+
import * as bedrockAsyncBridges from "react-native-bedrock/async-bridges";
|
|
207
|
+
import * as bedrockConstantBridges from "react-native-bedrock/constant-bridges";
|
|
208
|
+
|
|
209
|
+
// src/async-bridges.ts
|
|
210
|
+
var async_bridges_exports = {};
|
|
211
|
+
__export(async_bridges_exports, {
|
|
212
|
+
appLogin: () => appLogin,
|
|
213
|
+
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
214
|
+
fetchContacts: () => fetchContacts,
|
|
215
|
+
getClipboardText: () => getClipboardText,
|
|
216
|
+
getCurrentLocation: () => getCurrentLocation,
|
|
217
|
+
openCamera: () => openCamera,
|
|
218
|
+
setClipboardText: () => setClipboardText
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
// src/constant-bridges.ts
|
|
222
|
+
var constant_bridges_exports = {};
|
|
223
|
+
__export(constant_bridges_exports, {
|
|
224
|
+
getOperationalEnvironment: () => getOperationalEnvironment
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
// src/event-bridges.ts
|
|
228
|
+
var event_bridges_exports = {};
|
|
229
|
+
__export(event_bridges_exports, {
|
|
230
|
+
startUpdateLocation: () => startUpdateLocation
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
// src/components/WebView.tsx
|
|
221
234
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
222
|
-
function WebView({
|
|
235
|
+
function WebView({ local, onMessage, ...props }) {
|
|
223
236
|
const uri = useMemo(() => {
|
|
224
237
|
if (__DEV__) {
|
|
225
|
-
return `http
|
|
238
|
+
return `http://${local.host}:${local.port}`;
|
|
226
239
|
}
|
|
227
240
|
return AppsInTossModule.getWebBundleURL({}).url;
|
|
228
|
-
}, [
|
|
241
|
+
}, [local]);
|
|
229
242
|
const handler = useBridgeHandler({
|
|
230
243
|
onMessage,
|
|
231
244
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
232
|
-
eventListenerMap:
|
|
245
|
+
eventListenerMap: event_bridges_exports,
|
|
233
246
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
234
247
|
// @ts-expect-error
|
|
235
|
-
constantHandlerMap:
|
|
248
|
+
constantHandlerMap: {
|
|
249
|
+
...bedrockConstantBridges,
|
|
250
|
+
...constant_bridges_exports
|
|
251
|
+
},
|
|
236
252
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
237
253
|
// @ts-expect-error
|
|
238
|
-
|
|
239
|
-
...
|
|
240
|
-
...
|
|
254
|
+
asyncHandlerMap: {
|
|
255
|
+
...bedrockAsyncBridges,
|
|
256
|
+
...async_bridges_exports
|
|
241
257
|
}
|
|
242
258
|
});
|
|
243
259
|
return /* @__PURE__ */ jsx2(
|
|
@@ -303,6 +319,7 @@ export {
|
|
|
303
319
|
fetchContacts,
|
|
304
320
|
getClipboardText,
|
|
305
321
|
getCurrentLocation,
|
|
322
|
+
getOperationalEnvironment,
|
|
306
323
|
openCamera,
|
|
307
324
|
setClipboardText,
|
|
308
325
|
startUpdateLocation,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apps-in-toss/framework",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.11",
|
|
5
5
|
"description": "The framework for Apps In Toss",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"prepack": "yarn build",
|
|
@@ -23,9 +23,17 @@
|
|
|
23
23
|
"import": "./dist/plugins/index.js",
|
|
24
24
|
"require": "./dist/plugins/index.cjs"
|
|
25
25
|
},
|
|
26
|
-
"./bridges": {
|
|
27
|
-
"types": "./src/bridges.ts",
|
|
28
|
-
"default": "./src/bridges.ts"
|
|
26
|
+
"./async-bridges": {
|
|
27
|
+
"types": "./src/async-bridges.ts",
|
|
28
|
+
"default": "./src/async-bridges.ts"
|
|
29
|
+
},
|
|
30
|
+
"./constant-bridges": {
|
|
31
|
+
"types": "./src/constant-bridges.ts",
|
|
32
|
+
"default": "./src/constant-bridges.ts"
|
|
33
|
+
},
|
|
34
|
+
"./event-bridges": {
|
|
35
|
+
"types": "./src/event-bridges.ts",
|
|
36
|
+
"default": "./src/event-bridges.ts"
|
|
29
37
|
},
|
|
30
38
|
"./jest": {
|
|
31
39
|
"types": "./dist/jest/index.d.ts",
|
|
@@ -36,7 +44,9 @@
|
|
|
36
44
|
},
|
|
37
45
|
"files": [
|
|
38
46
|
"dist/**/*",
|
|
39
|
-
"src/bridges.ts",
|
|
47
|
+
"src/async-bridges.ts",
|
|
48
|
+
"src/constant-bridges.ts",
|
|
49
|
+
"src/event-bridges.ts",
|
|
40
50
|
"hermesc/**/*",
|
|
41
51
|
"plugins.d.ts",
|
|
42
52
|
"jest.d.ts"
|
|
@@ -45,11 +55,11 @@
|
|
|
45
55
|
"ait": "./bin/ait.js"
|
|
46
56
|
},
|
|
47
57
|
"dependencies": {
|
|
48
|
-
"@apps-in-toss/cli": "0.0.
|
|
58
|
+
"@apps-in-toss/cli": "0.0.11"
|
|
49
59
|
},
|
|
50
60
|
"devDependencies": {
|
|
51
|
-
"@react-native-bedrock/mpack-next": "0.0.
|
|
52
|
-
"@react-native-bedrock/native": "0.0.
|
|
61
|
+
"@react-native-bedrock/mpack-next": "0.0.13",
|
|
62
|
+
"@react-native-bedrock/native": "0.0.13",
|
|
53
63
|
"@ryoppippi/unplugin-typia": "^2.0.3",
|
|
54
64
|
"@toss-design-system/react-native": "^0",
|
|
55
65
|
"@types/archiver": "^6.0.3",
|
|
@@ -62,7 +72,7 @@
|
|
|
62
72
|
"picocolors": "^1.1.1",
|
|
63
73
|
"react": "18.2.0",
|
|
64
74
|
"react-native": "0.72.6",
|
|
65
|
-
"react-native-bedrock": "0.0.
|
|
75
|
+
"react-native-bedrock": "0.0.13",
|
|
66
76
|
"tsup": "^8.3.5",
|
|
67
77
|
"typescript": "4.9.5",
|
|
68
78
|
"typia": "^8.0.1",
|
|
@@ -80,5 +90,5 @@
|
|
|
80
90
|
"publishConfig": {
|
|
81
91
|
"access": "public"
|
|
82
92
|
},
|
|
83
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "d0dfa84af3118a71ea3705c440e639fb5b1a010b"
|
|
84
94
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './native-modules/setClipboardText.js';
|
|
2
|
+
export * from './native-modules/getClipboardText.js';
|
|
3
|
+
export * from './native-modules/fetchContacts.js';
|
|
4
|
+
export * from './native-modules/fetchAlbumPhotos.js';
|
|
5
|
+
export * from './native-modules/getCurrentLocation.js';
|
|
6
|
+
export * from './native-modules/openCamera.js';
|
|
7
|
+
export * from './native-modules/appLogin.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './native-modules/getOperationalEnvironment.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './native-event-emitter/startUpdateLocation.js';
|
package/src/bridges.ts
DELETED