@apps-in-toss/framework 0.0.17 → 0.0.18
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 +53 -5
- package/dist/index.d.cts +118 -4
- package/dist/index.d.ts +118 -4
- package/dist/index.js +51 -5
- package/package.json +16 -8
- package/src/constant-bridges.ts +1 -0
package/dist/index.cjs
CHANGED
|
@@ -32,6 +32,7 @@ var src_exports = {};
|
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
Accuracy: () => Accuracy2,
|
|
34
34
|
AppsInToss: () => AppsInToss,
|
|
35
|
+
Storage: () => Storage,
|
|
35
36
|
TossPay: () => TossPay,
|
|
36
37
|
WebView: () => WebView,
|
|
37
38
|
appLogin: () => appLogin,
|
|
@@ -41,6 +42,7 @@ __export(src_exports, {
|
|
|
41
42
|
getClipboardText: () => getClipboardText,
|
|
42
43
|
getCurrentLocation: () => getCurrentLocation,
|
|
43
44
|
getOperationalEnvironment: () => getOperationalEnvironment,
|
|
45
|
+
getTossAppVersion: () => getTossAppVersion,
|
|
44
46
|
openCamera: () => openCamera,
|
|
45
47
|
setClipboardText: () => setClipboardText,
|
|
46
48
|
startUpdateLocation: () => startUpdateLocation,
|
|
@@ -282,6 +284,34 @@ function getOperationalEnvironment() {
|
|
|
282
284
|
return AppsInTossModule.operationalEnvironment;
|
|
283
285
|
}
|
|
284
286
|
|
|
287
|
+
// src/native-modules/getTossAppVersion.ts
|
|
288
|
+
function getTossAppVersion() {
|
|
289
|
+
return AppsInTossModule.tossAppVersion;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// src/native-modules/storage.ts
|
|
293
|
+
function getItem(key) {
|
|
294
|
+
return AppsInTossModule.getStorageItem({ key });
|
|
295
|
+
}
|
|
296
|
+
function setItem(key, value) {
|
|
297
|
+
return AppsInTossModule.setStorageItem({
|
|
298
|
+
key,
|
|
299
|
+
value
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
function removeItem(key) {
|
|
303
|
+
return AppsInTossModule.removeStorageItem({ key });
|
|
304
|
+
}
|
|
305
|
+
function clearItems() {
|
|
306
|
+
return AppsInTossModule.clearStorage({});
|
|
307
|
+
}
|
|
308
|
+
var Storage = {
|
|
309
|
+
getItem,
|
|
310
|
+
setItem,
|
|
311
|
+
removeItem,
|
|
312
|
+
clearItems
|
|
313
|
+
};
|
|
314
|
+
|
|
285
315
|
// src/native-modules/index.ts
|
|
286
316
|
var TossPay = {
|
|
287
317
|
checkoutPayment,
|
|
@@ -290,6 +320,7 @@ var TossPay = {
|
|
|
290
320
|
|
|
291
321
|
// src/components/WebView.tsx
|
|
292
322
|
var import_react_native11 = require("@toss-design-system/react-native");
|
|
323
|
+
var import_private = require("@toss-design-system/react-native/private");
|
|
293
324
|
var import_react3 = require("react");
|
|
294
325
|
var import_react_native_bedrock5 = require("react-native-bedrock");
|
|
295
326
|
var bedrockAsyncBridges = __toESM(require("react-native-bedrock/async-bridges"), 1);
|
|
@@ -427,7 +458,8 @@ __export(async_bridges_exports, {
|
|
|
427
458
|
// src/constant-bridges.ts
|
|
428
459
|
var constant_bridges_exports = {};
|
|
429
460
|
__export(constant_bridges_exports, {
|
|
430
|
-
getOperationalEnvironment: () => getOperationalEnvironment
|
|
461
|
+
getOperationalEnvironment: () => getOperationalEnvironment,
|
|
462
|
+
getTossAppVersion: () => getTossAppVersion
|
|
431
463
|
});
|
|
432
464
|
|
|
433
465
|
// src/env.ts
|
|
@@ -477,6 +509,8 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
477
509
|
throw new Error(`Invalid WebView type: '${type}'`);
|
|
478
510
|
}
|
|
479
511
|
const uri = (0, import_react3.useMemo)(() => getWebViewUri(local), [local]);
|
|
512
|
+
const top = (0, import_private.useSafeAreaTop)();
|
|
513
|
+
const bottom = (0, import_private.useSafeAreaBottom)();
|
|
480
514
|
const handler = (0, import_react_native_bedrock5.useBridgeHandler)({
|
|
481
515
|
onMessage,
|
|
482
516
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -485,13 +519,22 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
485
519
|
// @ts-expect-error
|
|
486
520
|
constantHandlerMap: {
|
|
487
521
|
...bedrockConstantBridges,
|
|
488
|
-
...constant_bridges_exports
|
|
522
|
+
...constant_bridges_exports,
|
|
523
|
+
getSafeAreaTop: () => top,
|
|
524
|
+
getSafeAreaBottom: () => bottom
|
|
489
525
|
},
|
|
490
526
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
491
527
|
// @ts-expect-error
|
|
492
528
|
asyncHandlerMap: {
|
|
493
529
|
...bedrockAsyncBridges,
|
|
494
|
-
...async_bridges_exports
|
|
530
|
+
...async_bridges_exports,
|
|
531
|
+
// internal
|
|
532
|
+
openPermissionDialog: AppsInTossModule.openPermissionDialog,
|
|
533
|
+
/** Storage */
|
|
534
|
+
getStorageItem: Storage.getItem,
|
|
535
|
+
setStorageItem: Storage.setItem,
|
|
536
|
+
removeStorageItem: Storage.removeItem,
|
|
537
|
+
clearItems: Storage.clearItems
|
|
495
538
|
}
|
|
496
539
|
});
|
|
497
540
|
const baseProps = (0, import_react3.useMemo)(() => {
|
|
@@ -524,6 +567,10 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
524
567
|
}
|
|
525
568
|
}, [type, props]);
|
|
526
569
|
const BaseWebView = WEBVIEW_TYPES[type];
|
|
570
|
+
const webviewDebuggingEnabled = (0, import_react3.useMemo)(
|
|
571
|
+
() => getOperationalEnvironment() === "sandbox",
|
|
572
|
+
[]
|
|
573
|
+
);
|
|
527
574
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
528
575
|
BaseWebView,
|
|
529
576
|
{
|
|
@@ -532,9 +579,8 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
532
579
|
...baseProps,
|
|
533
580
|
source: { uri },
|
|
534
581
|
sharedCookiesEnabled: true,
|
|
582
|
+
webviewDebuggingEnabled,
|
|
535
583
|
thirdPartyCookiesEnabled: true,
|
|
536
|
-
cacheEnabled: false,
|
|
537
|
-
cacheMode: "LOAD_NO_CACHE",
|
|
538
584
|
onMessage: handler.onMessage,
|
|
539
585
|
injectedJavaScript: handler.injectedJavaScript,
|
|
540
586
|
injectedJavaScriptBeforeContentLoaded: handler.injectedJavaScript
|
|
@@ -585,6 +631,7 @@ var Accuracy2 = /* @__PURE__ */ ((Accuracy3) => {
|
|
|
585
631
|
0 && (module.exports = {
|
|
586
632
|
Accuracy,
|
|
587
633
|
AppsInToss,
|
|
634
|
+
Storage,
|
|
588
635
|
TossPay,
|
|
589
636
|
WebView,
|
|
590
637
|
appLogin,
|
|
@@ -594,6 +641,7 @@ var Accuracy2 = /* @__PURE__ */ ((Accuracy3) => {
|
|
|
594
641
|
getClipboardText,
|
|
595
642
|
getCurrentLocation,
|
|
596
643
|
getOperationalEnvironment,
|
|
644
|
+
getTossAppVersion,
|
|
597
645
|
openCamera,
|
|
598
646
|
setClipboardText,
|
|
599
647
|
startUpdateLocation,
|
package/dist/index.d.cts
CHANGED
|
@@ -569,7 +569,7 @@ interface TossMoneyExecutePaymentResult {
|
|
|
569
569
|
* @param {ExecutePaymentOptions} options 결제를 실행할 때 필요한 옵션이에요.
|
|
570
570
|
* @param {string} options.orderNo 결제를 생성할 때 사용한 주문번호예요.
|
|
571
571
|
* @param {string} options.payToken 결제 인증 과정에서 전달받은 결제 토큰이에요. 결제를 실행할 때 사용해요.
|
|
572
|
-
* @returns {Promise<CardExecutePaymentResult | TossMoneyExecutePaymentResult>} 결제 결과 객체를 반환해요. 자세한 내용은 [카드 결제 결과](reference/framework/토스페이/CardExecutePaymentResult.html) 또는 [토스머니 결제 결과](reference/framework/토스페이/TossMoneyExecutePaymentResult.html)를 참고하세요.
|
|
572
|
+
* @returns {Promise<CardExecutePaymentResult | TossMoneyExecutePaymentResult>} 결제 결과 객체를 반환해요. 자세한 내용은 [카드 결제 결과](/react-native/reference/framework/토스페이/CardExecutePaymentResult.html) 또는 [토스머니 결제 결과](/react-native/reference/framework/토스페이/TossMoneyExecutePaymentResult.html)를 참고하세요.
|
|
573
573
|
*
|
|
574
574
|
* @example
|
|
575
575
|
*
|
|
@@ -1027,13 +1027,127 @@ declare function appLogin(): Promise<{
|
|
|
1027
1027
|
*/
|
|
1028
1028
|
declare function getOperationalEnvironment(): 'toss' | 'sandbox';
|
|
1029
1029
|
|
|
1030
|
+
/**
|
|
1031
|
+
* @public
|
|
1032
|
+
* @category 환경 확인
|
|
1033
|
+
* @name getTossAppVersion
|
|
1034
|
+
* @description 토스 앱 버전을 가져옵니다. 예를 들어, `5.206.0`과 같은 형태로 반환돼요. 토스 앱 버전을 로그로 남기거나, 특정 기능이 특정 버전 이상에서만 실행될 때 사용돼요.
|
|
1035
|
+
* @signature
|
|
1036
|
+
* ```typescript
|
|
1037
|
+
* function getTossAppVersion(): string
|
|
1038
|
+
* ```
|
|
1039
|
+
*
|
|
1040
|
+
* @returns {string} 토스 앱 버전
|
|
1041
|
+
*
|
|
1042
|
+
* @example
|
|
1043
|
+
*
|
|
1044
|
+
*
|
|
1045
|
+
* ### 토스 앱 버전 확인하기
|
|
1046
|
+
*
|
|
1047
|
+
* ```tsx
|
|
1048
|
+
* import { getTossAppVersion } from '@apps-in-toss/framework';
|
|
1049
|
+
* import { Text } from 'react-native';
|
|
1050
|
+
*
|
|
1051
|
+
* export function TossAppVersionPage() {
|
|
1052
|
+
* return (
|
|
1053
|
+
* <Text>{getTossAppVersion()}</Text>
|
|
1054
|
+
* )
|
|
1055
|
+
* }
|
|
1056
|
+
* ```
|
|
1057
|
+
*/
|
|
1058
|
+
declare function getTossAppVersion(): string;
|
|
1059
|
+
|
|
1060
|
+
/**
|
|
1061
|
+
* @public
|
|
1062
|
+
* @category 저장소
|
|
1063
|
+
* @name getItem
|
|
1064
|
+
* @description 모바일 앱의 로컬 저장소에서 문자열 데이터를 가져와요. 주로 앱이 종료되었다가 다시 시작해도 데이터가 유지되어야 하는 경우에 사용해요.
|
|
1065
|
+
* @param {string} key - 가져올 아이템의 키를 입력해요.
|
|
1066
|
+
* @returns {Promise<string | null>} 지정한 키에 저장된 문자열 값을 반환해요. 값이 없으면 `null`을 반환해요.
|
|
1067
|
+
* @example
|
|
1068
|
+
*
|
|
1069
|
+
* ### `my-key`에 저장된 아이템 가져오기
|
|
1070
|
+
* ```ts
|
|
1071
|
+
* const value = await Storage.getItem('my-key');
|
|
1072
|
+
* console.log(value); // 'value'
|
|
1073
|
+
* ```
|
|
1074
|
+
*/
|
|
1075
|
+
declare function getItem(key: string): Promise<string | null>;
|
|
1076
|
+
/**
|
|
1077
|
+
* @public
|
|
1078
|
+
* @category 저장소
|
|
1079
|
+
* @name setItem
|
|
1080
|
+
* @description 모바일 앱의 로컬 저장소에 문자열 데이터를 저장해요. 주로 앱이 종료되었다가 다시 시작해도 데이터가 유지되어야 하는 경우에 사용해요.
|
|
1081
|
+
* @param {string} key - 저장할 아이템의 키를 입력해요.
|
|
1082
|
+
* @param {string} value - 저장할 아이템의 값을 입력해요.
|
|
1083
|
+
* @returns {Promise<void>} 아이템을 성공적으로 저장하면 아무 값도 반환하지 않아요.
|
|
1084
|
+
* @example
|
|
1085
|
+
*
|
|
1086
|
+
* ### `my-key`에 아이템 저장하기
|
|
1087
|
+
* ```ts
|
|
1088
|
+
* import { Storage } from '@apps-in-toss/framework';
|
|
1089
|
+
*
|
|
1090
|
+
* await Storage.setItem('my-key', 'value');
|
|
1091
|
+
* ```
|
|
1092
|
+
*/
|
|
1093
|
+
declare function setItem(key: string, value: string): Promise<void>;
|
|
1094
|
+
/**
|
|
1095
|
+
* @public
|
|
1096
|
+
* @category 저장소
|
|
1097
|
+
* @name removeItem
|
|
1098
|
+
* @description 모바일 앱의 로컬 저장소에서 특정 키에 해당하는 아이템을 삭제해요.
|
|
1099
|
+
* @param {string} key - 삭제할 아이템의 키를 입력해요.
|
|
1100
|
+
* @returns {Promise<void>} 아이템을 삭제하면 아무 값도 반환하지 않아요.
|
|
1101
|
+
* @example
|
|
1102
|
+
*
|
|
1103
|
+
* ### `my-key`에 저장된 아이템 삭제하기
|
|
1104
|
+
* ```ts
|
|
1105
|
+
* import { Storage } from '@apps-in-toss/framework';
|
|
1106
|
+
*
|
|
1107
|
+
* await Storage.removeItem('my-key');
|
|
1108
|
+
* ```
|
|
1109
|
+
*/
|
|
1110
|
+
declare function removeItem(key: string): Promise<void>;
|
|
1111
|
+
/**
|
|
1112
|
+
* @public
|
|
1113
|
+
* @category 저장소
|
|
1114
|
+
* @name clearItems
|
|
1115
|
+
* @description 모바일 앱의 로컬 저장소의 모든 아이템을 삭제해요.
|
|
1116
|
+
* @returns {Promise<void>} 아이템을 삭제하면 아무 값도 반환하지 않고 저장소가 초기화돼요.
|
|
1117
|
+
* @example
|
|
1118
|
+
*
|
|
1119
|
+
* ### 저장소 초기화하기
|
|
1120
|
+
* ```ts
|
|
1121
|
+
* import { Storage } from '@apps-in-toss/framework';
|
|
1122
|
+
*
|
|
1123
|
+
* await Storage.clearItems();
|
|
1124
|
+
* ```
|
|
1125
|
+
*/
|
|
1126
|
+
declare function clearItems(): Promise<void>;
|
|
1127
|
+
/**
|
|
1128
|
+
* @public
|
|
1129
|
+
* @category 저장소
|
|
1130
|
+
* @name Storage
|
|
1131
|
+
* @description 네이티브의 저장소를 사용해요.
|
|
1132
|
+
* @property {typeof getItem} [getItem] 모바일 앱의 로컬 저장소에서 아이템을 가져오는 함수예요. 자세한 내용은 [getItem](/react-native/reference/framework/저장소/getItem)을 참고하세요.
|
|
1133
|
+
* @property {typeof setItem} [setItem] 모바일 앱의 로컬 저장소에 아이템을 저장하는 함수예요. 자세한 내용은 [setItem](/react-native/reference/framework/저장소/setItem)을 참고하세요.
|
|
1134
|
+
* @property {typeof removeItem} [removeItem] 모바일 앱의 로컬 저장소에서 아이템을 삭제하는 함수예요. 자세한 내용은 [removeItem](/react-native/reference/framework/저장소/removeItem)을 참고하세요.
|
|
1135
|
+
* @property {typeof clearItems} [clearItems] 모바일 앱의 로컬 저장소를 초기화하는 함수예요. 자세한 내용은 [clearItems](/react-native/reference/framework/저장소/clearItems)을 참고하세요.
|
|
1136
|
+
*/
|
|
1137
|
+
declare const Storage: {
|
|
1138
|
+
getItem: typeof getItem;
|
|
1139
|
+
setItem: typeof setItem;
|
|
1140
|
+
removeItem: typeof removeItem;
|
|
1141
|
+
clearItems: typeof clearItems;
|
|
1142
|
+
};
|
|
1143
|
+
|
|
1030
1144
|
/**
|
|
1031
1145
|
* @public
|
|
1032
1146
|
* @category 토스페이
|
|
1033
1147
|
* @name TossPay
|
|
1034
1148
|
* @description 토스페이 결제 관련 함수를 모아둔 객체예요.
|
|
1035
|
-
* @property {typeof checkoutPayment} [checkoutPayment] 토스페이 결제를 생성하는 함수예요. 자세한 내용은 [checkoutPayment](reference/framework/토스페이/checkoutPayment)를 참고하세요.
|
|
1036
|
-
* @property {typeof executePayment} [executePayment] 토스페이 결제를 실행하는 함수예요. 자세한 내용은 [executePayment](reference/framework/토스페이/executePayment)를 참고하세요.
|
|
1149
|
+
* @property {typeof checkoutPayment} [checkoutPayment] 토스페이 결제를 생성하는 함수예요. 자세한 내용은 [checkoutPayment](/react-native/reference/framework/토스페이/checkoutPayment)를 참고하세요.
|
|
1150
|
+
* @property {typeof executePayment} [executePayment] 토스페이 결제를 실행하는 함수예요. 자세한 내용은 [executePayment](/react-native/reference/framework/토스페이/executePayment)를 참고하세요.
|
|
1037
1151
|
*/
|
|
1038
1152
|
declare const TossPay: {
|
|
1039
1153
|
checkoutPayment: typeof checkoutPayment;
|
|
@@ -1112,4 +1226,4 @@ declare const env: {
|
|
|
1112
1226
|
getDeploymentId: () => string | undefined;
|
|
1113
1227
|
};
|
|
1114
1228
|
|
|
1115
|
-
export { Accuracy, AppsInToss, type ContactEntity, type ExternalWebViewProps, type FetchAlbumPhotosOptions, type GameWebViewProps, type GetCurrentLocationOptions, type ImageResponse, type Location, type LocationCoords, type OpenCameraOptions, type PartnerWebViewProps, type StartUpdateLocationOptions, type StartUpdateLocationSubscription, TossPay, type UpdateLocationEventEmitter, type UseGeolocationOptions, WebView, type WebViewProps, appLogin, env, fetchAlbumPhotos, fetchContacts, getClipboardText, getCurrentLocation, getOperationalEnvironment, openCamera, setClipboardText, startUpdateLocation, useGeolocation };
|
|
1229
|
+
export { Accuracy, AppsInToss, type ContactEntity, type ExternalWebViewProps, type FetchAlbumPhotosOptions, type GameWebViewProps, type GetCurrentLocationOptions, type ImageResponse, type Location, type LocationCoords, type OpenCameraOptions, type PartnerWebViewProps, type StartUpdateLocationOptions, type StartUpdateLocationSubscription, Storage, TossPay, type UpdateLocationEventEmitter, type UseGeolocationOptions, WebView, type WebViewProps, appLogin, env, fetchAlbumPhotos, fetchContacts, getClipboardText, getCurrentLocation, getOperationalEnvironment, getTossAppVersion, openCamera, setClipboardText, startUpdateLocation, useGeolocation };
|
package/dist/index.d.ts
CHANGED
|
@@ -569,7 +569,7 @@ interface TossMoneyExecutePaymentResult {
|
|
|
569
569
|
* @param {ExecutePaymentOptions} options 결제를 실행할 때 필요한 옵션이에요.
|
|
570
570
|
* @param {string} options.orderNo 결제를 생성할 때 사용한 주문번호예요.
|
|
571
571
|
* @param {string} options.payToken 결제 인증 과정에서 전달받은 결제 토큰이에요. 결제를 실행할 때 사용해요.
|
|
572
|
-
* @returns {Promise<CardExecutePaymentResult | TossMoneyExecutePaymentResult>} 결제 결과 객체를 반환해요. 자세한 내용은 [카드 결제 결과](reference/framework/토스페이/CardExecutePaymentResult.html) 또는 [토스머니 결제 결과](reference/framework/토스페이/TossMoneyExecutePaymentResult.html)를 참고하세요.
|
|
572
|
+
* @returns {Promise<CardExecutePaymentResult | TossMoneyExecutePaymentResult>} 결제 결과 객체를 반환해요. 자세한 내용은 [카드 결제 결과](/react-native/reference/framework/토스페이/CardExecutePaymentResult.html) 또는 [토스머니 결제 결과](/react-native/reference/framework/토스페이/TossMoneyExecutePaymentResult.html)를 참고하세요.
|
|
573
573
|
*
|
|
574
574
|
* @example
|
|
575
575
|
*
|
|
@@ -1027,13 +1027,127 @@ declare function appLogin(): Promise<{
|
|
|
1027
1027
|
*/
|
|
1028
1028
|
declare function getOperationalEnvironment(): 'toss' | 'sandbox';
|
|
1029
1029
|
|
|
1030
|
+
/**
|
|
1031
|
+
* @public
|
|
1032
|
+
* @category 환경 확인
|
|
1033
|
+
* @name getTossAppVersion
|
|
1034
|
+
* @description 토스 앱 버전을 가져옵니다. 예를 들어, `5.206.0`과 같은 형태로 반환돼요. 토스 앱 버전을 로그로 남기거나, 특정 기능이 특정 버전 이상에서만 실행될 때 사용돼요.
|
|
1035
|
+
* @signature
|
|
1036
|
+
* ```typescript
|
|
1037
|
+
* function getTossAppVersion(): string
|
|
1038
|
+
* ```
|
|
1039
|
+
*
|
|
1040
|
+
* @returns {string} 토스 앱 버전
|
|
1041
|
+
*
|
|
1042
|
+
* @example
|
|
1043
|
+
*
|
|
1044
|
+
*
|
|
1045
|
+
* ### 토스 앱 버전 확인하기
|
|
1046
|
+
*
|
|
1047
|
+
* ```tsx
|
|
1048
|
+
* import { getTossAppVersion } from '@apps-in-toss/framework';
|
|
1049
|
+
* import { Text } from 'react-native';
|
|
1050
|
+
*
|
|
1051
|
+
* export function TossAppVersionPage() {
|
|
1052
|
+
* return (
|
|
1053
|
+
* <Text>{getTossAppVersion()}</Text>
|
|
1054
|
+
* )
|
|
1055
|
+
* }
|
|
1056
|
+
* ```
|
|
1057
|
+
*/
|
|
1058
|
+
declare function getTossAppVersion(): string;
|
|
1059
|
+
|
|
1060
|
+
/**
|
|
1061
|
+
* @public
|
|
1062
|
+
* @category 저장소
|
|
1063
|
+
* @name getItem
|
|
1064
|
+
* @description 모바일 앱의 로컬 저장소에서 문자열 데이터를 가져와요. 주로 앱이 종료되었다가 다시 시작해도 데이터가 유지되어야 하는 경우에 사용해요.
|
|
1065
|
+
* @param {string} key - 가져올 아이템의 키를 입력해요.
|
|
1066
|
+
* @returns {Promise<string | null>} 지정한 키에 저장된 문자열 값을 반환해요. 값이 없으면 `null`을 반환해요.
|
|
1067
|
+
* @example
|
|
1068
|
+
*
|
|
1069
|
+
* ### `my-key`에 저장된 아이템 가져오기
|
|
1070
|
+
* ```ts
|
|
1071
|
+
* const value = await Storage.getItem('my-key');
|
|
1072
|
+
* console.log(value); // 'value'
|
|
1073
|
+
* ```
|
|
1074
|
+
*/
|
|
1075
|
+
declare function getItem(key: string): Promise<string | null>;
|
|
1076
|
+
/**
|
|
1077
|
+
* @public
|
|
1078
|
+
* @category 저장소
|
|
1079
|
+
* @name setItem
|
|
1080
|
+
* @description 모바일 앱의 로컬 저장소에 문자열 데이터를 저장해요. 주로 앱이 종료되었다가 다시 시작해도 데이터가 유지되어야 하는 경우에 사용해요.
|
|
1081
|
+
* @param {string} key - 저장할 아이템의 키를 입력해요.
|
|
1082
|
+
* @param {string} value - 저장할 아이템의 값을 입력해요.
|
|
1083
|
+
* @returns {Promise<void>} 아이템을 성공적으로 저장하면 아무 값도 반환하지 않아요.
|
|
1084
|
+
* @example
|
|
1085
|
+
*
|
|
1086
|
+
* ### `my-key`에 아이템 저장하기
|
|
1087
|
+
* ```ts
|
|
1088
|
+
* import { Storage } from '@apps-in-toss/framework';
|
|
1089
|
+
*
|
|
1090
|
+
* await Storage.setItem('my-key', 'value');
|
|
1091
|
+
* ```
|
|
1092
|
+
*/
|
|
1093
|
+
declare function setItem(key: string, value: string): Promise<void>;
|
|
1094
|
+
/**
|
|
1095
|
+
* @public
|
|
1096
|
+
* @category 저장소
|
|
1097
|
+
* @name removeItem
|
|
1098
|
+
* @description 모바일 앱의 로컬 저장소에서 특정 키에 해당하는 아이템을 삭제해요.
|
|
1099
|
+
* @param {string} key - 삭제할 아이템의 키를 입력해요.
|
|
1100
|
+
* @returns {Promise<void>} 아이템을 삭제하면 아무 값도 반환하지 않아요.
|
|
1101
|
+
* @example
|
|
1102
|
+
*
|
|
1103
|
+
* ### `my-key`에 저장된 아이템 삭제하기
|
|
1104
|
+
* ```ts
|
|
1105
|
+
* import { Storage } from '@apps-in-toss/framework';
|
|
1106
|
+
*
|
|
1107
|
+
* await Storage.removeItem('my-key');
|
|
1108
|
+
* ```
|
|
1109
|
+
*/
|
|
1110
|
+
declare function removeItem(key: string): Promise<void>;
|
|
1111
|
+
/**
|
|
1112
|
+
* @public
|
|
1113
|
+
* @category 저장소
|
|
1114
|
+
* @name clearItems
|
|
1115
|
+
* @description 모바일 앱의 로컬 저장소의 모든 아이템을 삭제해요.
|
|
1116
|
+
* @returns {Promise<void>} 아이템을 삭제하면 아무 값도 반환하지 않고 저장소가 초기화돼요.
|
|
1117
|
+
* @example
|
|
1118
|
+
*
|
|
1119
|
+
* ### 저장소 초기화하기
|
|
1120
|
+
* ```ts
|
|
1121
|
+
* import { Storage } from '@apps-in-toss/framework';
|
|
1122
|
+
*
|
|
1123
|
+
* await Storage.clearItems();
|
|
1124
|
+
* ```
|
|
1125
|
+
*/
|
|
1126
|
+
declare function clearItems(): Promise<void>;
|
|
1127
|
+
/**
|
|
1128
|
+
* @public
|
|
1129
|
+
* @category 저장소
|
|
1130
|
+
* @name Storage
|
|
1131
|
+
* @description 네이티브의 저장소를 사용해요.
|
|
1132
|
+
* @property {typeof getItem} [getItem] 모바일 앱의 로컬 저장소에서 아이템을 가져오는 함수예요. 자세한 내용은 [getItem](/react-native/reference/framework/저장소/getItem)을 참고하세요.
|
|
1133
|
+
* @property {typeof setItem} [setItem] 모바일 앱의 로컬 저장소에 아이템을 저장하는 함수예요. 자세한 내용은 [setItem](/react-native/reference/framework/저장소/setItem)을 참고하세요.
|
|
1134
|
+
* @property {typeof removeItem} [removeItem] 모바일 앱의 로컬 저장소에서 아이템을 삭제하는 함수예요. 자세한 내용은 [removeItem](/react-native/reference/framework/저장소/removeItem)을 참고하세요.
|
|
1135
|
+
* @property {typeof clearItems} [clearItems] 모바일 앱의 로컬 저장소를 초기화하는 함수예요. 자세한 내용은 [clearItems](/react-native/reference/framework/저장소/clearItems)을 참고하세요.
|
|
1136
|
+
*/
|
|
1137
|
+
declare const Storage: {
|
|
1138
|
+
getItem: typeof getItem;
|
|
1139
|
+
setItem: typeof setItem;
|
|
1140
|
+
removeItem: typeof removeItem;
|
|
1141
|
+
clearItems: typeof clearItems;
|
|
1142
|
+
};
|
|
1143
|
+
|
|
1030
1144
|
/**
|
|
1031
1145
|
* @public
|
|
1032
1146
|
* @category 토스페이
|
|
1033
1147
|
* @name TossPay
|
|
1034
1148
|
* @description 토스페이 결제 관련 함수를 모아둔 객체예요.
|
|
1035
|
-
* @property {typeof checkoutPayment} [checkoutPayment] 토스페이 결제를 생성하는 함수예요. 자세한 내용은 [checkoutPayment](reference/framework/토스페이/checkoutPayment)를 참고하세요.
|
|
1036
|
-
* @property {typeof executePayment} [executePayment] 토스페이 결제를 실행하는 함수예요. 자세한 내용은 [executePayment](reference/framework/토스페이/executePayment)를 참고하세요.
|
|
1149
|
+
* @property {typeof checkoutPayment} [checkoutPayment] 토스페이 결제를 생성하는 함수예요. 자세한 내용은 [checkoutPayment](/react-native/reference/framework/토스페이/checkoutPayment)를 참고하세요.
|
|
1150
|
+
* @property {typeof executePayment} [executePayment] 토스페이 결제를 실행하는 함수예요. 자세한 내용은 [executePayment](/react-native/reference/framework/토스페이/executePayment)를 참고하세요.
|
|
1037
1151
|
*/
|
|
1038
1152
|
declare const TossPay: {
|
|
1039
1153
|
checkoutPayment: typeof checkoutPayment;
|
|
@@ -1112,4 +1226,4 @@ declare const env: {
|
|
|
1112
1226
|
getDeploymentId: () => string | undefined;
|
|
1113
1227
|
};
|
|
1114
1228
|
|
|
1115
|
-
export { Accuracy, AppsInToss, type ContactEntity, type ExternalWebViewProps, type FetchAlbumPhotosOptions, type GameWebViewProps, type GetCurrentLocationOptions, type ImageResponse, type Location, type LocationCoords, type OpenCameraOptions, type PartnerWebViewProps, type StartUpdateLocationOptions, type StartUpdateLocationSubscription, TossPay, type UpdateLocationEventEmitter, type UseGeolocationOptions, WebView, type WebViewProps, appLogin, env, fetchAlbumPhotos, fetchContacts, getClipboardText, getCurrentLocation, getOperationalEnvironment, openCamera, setClipboardText, startUpdateLocation, useGeolocation };
|
|
1229
|
+
export { Accuracy, AppsInToss, type ContactEntity, type ExternalWebViewProps, type FetchAlbumPhotosOptions, type GameWebViewProps, type GetCurrentLocationOptions, type ImageResponse, type Location, type LocationCoords, type OpenCameraOptions, type PartnerWebViewProps, type StartUpdateLocationOptions, type StartUpdateLocationSubscription, Storage, TossPay, type UpdateLocationEventEmitter, type UseGeolocationOptions, WebView, type WebViewProps, appLogin, env, fetchAlbumPhotos, fetchContacts, getClipboardText, getCurrentLocation, getOperationalEnvironment, getTossAppVersion, openCamera, setClipboardText, startUpdateLocation, useGeolocation };
|
package/dist/index.js
CHANGED
|
@@ -238,6 +238,34 @@ function getOperationalEnvironment() {
|
|
|
238
238
|
return AppsInTossModule.operationalEnvironment;
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
+
// src/native-modules/getTossAppVersion.ts
|
|
242
|
+
function getTossAppVersion() {
|
|
243
|
+
return AppsInTossModule.tossAppVersion;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// src/native-modules/storage.ts
|
|
247
|
+
function getItem(key) {
|
|
248
|
+
return AppsInTossModule.getStorageItem({ key });
|
|
249
|
+
}
|
|
250
|
+
function setItem(key, value) {
|
|
251
|
+
return AppsInTossModule.setStorageItem({
|
|
252
|
+
key,
|
|
253
|
+
value
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
function removeItem(key) {
|
|
257
|
+
return AppsInTossModule.removeStorageItem({ key });
|
|
258
|
+
}
|
|
259
|
+
function clearItems() {
|
|
260
|
+
return AppsInTossModule.clearStorage({});
|
|
261
|
+
}
|
|
262
|
+
var Storage = {
|
|
263
|
+
getItem,
|
|
264
|
+
setItem,
|
|
265
|
+
removeItem,
|
|
266
|
+
clearItems
|
|
267
|
+
};
|
|
268
|
+
|
|
241
269
|
// src/native-modules/index.ts
|
|
242
270
|
var TossPay = {
|
|
243
271
|
checkoutPayment,
|
|
@@ -249,6 +277,7 @@ import {
|
|
|
249
277
|
PartnerWebViewScreen,
|
|
250
278
|
ExternalWebViewScreen
|
|
251
279
|
} from "@toss-design-system/react-native";
|
|
280
|
+
import { useSafeAreaBottom, useSafeAreaTop as useSafeAreaTop2 } from "@toss-design-system/react-native/private";
|
|
252
281
|
import { useMemo } from "react";
|
|
253
282
|
import { getSchemeUri, useBridgeHandler } from "react-native-bedrock";
|
|
254
283
|
import * as bedrockAsyncBridges from "react-native-bedrock/async-bridges";
|
|
@@ -388,7 +417,8 @@ __export(async_bridges_exports, {
|
|
|
388
417
|
// src/constant-bridges.ts
|
|
389
418
|
var constant_bridges_exports = {};
|
|
390
419
|
__export(constant_bridges_exports, {
|
|
391
|
-
getOperationalEnvironment: () => getOperationalEnvironment
|
|
420
|
+
getOperationalEnvironment: () => getOperationalEnvironment,
|
|
421
|
+
getTossAppVersion: () => getTossAppVersion
|
|
392
422
|
});
|
|
393
423
|
|
|
394
424
|
// src/env.ts
|
|
@@ -438,6 +468,8 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
438
468
|
throw new Error(`Invalid WebView type: '${type}'`);
|
|
439
469
|
}
|
|
440
470
|
const uri = useMemo(() => getWebViewUri(local), [local]);
|
|
471
|
+
const top = useSafeAreaTop2();
|
|
472
|
+
const bottom = useSafeAreaBottom();
|
|
441
473
|
const handler = useBridgeHandler({
|
|
442
474
|
onMessage,
|
|
443
475
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -446,13 +478,22 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
446
478
|
// @ts-expect-error
|
|
447
479
|
constantHandlerMap: {
|
|
448
480
|
...bedrockConstantBridges,
|
|
449
|
-
...constant_bridges_exports
|
|
481
|
+
...constant_bridges_exports,
|
|
482
|
+
getSafeAreaTop: () => top,
|
|
483
|
+
getSafeAreaBottom: () => bottom
|
|
450
484
|
},
|
|
451
485
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
452
486
|
// @ts-expect-error
|
|
453
487
|
asyncHandlerMap: {
|
|
454
488
|
...bedrockAsyncBridges,
|
|
455
|
-
...async_bridges_exports
|
|
489
|
+
...async_bridges_exports,
|
|
490
|
+
// internal
|
|
491
|
+
openPermissionDialog: AppsInTossModule.openPermissionDialog,
|
|
492
|
+
/** Storage */
|
|
493
|
+
getStorageItem: Storage.getItem,
|
|
494
|
+
setStorageItem: Storage.setItem,
|
|
495
|
+
removeStorageItem: Storage.removeItem,
|
|
496
|
+
clearItems: Storage.clearItems
|
|
456
497
|
}
|
|
457
498
|
});
|
|
458
499
|
const baseProps = useMemo(() => {
|
|
@@ -485,6 +526,10 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
485
526
|
}
|
|
486
527
|
}, [type, props]);
|
|
487
528
|
const BaseWebView = WEBVIEW_TYPES[type];
|
|
529
|
+
const webviewDebuggingEnabled = useMemo(
|
|
530
|
+
() => getOperationalEnvironment() === "sandbox",
|
|
531
|
+
[]
|
|
532
|
+
);
|
|
488
533
|
return /* @__PURE__ */ jsx5(
|
|
489
534
|
BaseWebView,
|
|
490
535
|
{
|
|
@@ -493,9 +538,8 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
493
538
|
...baseProps,
|
|
494
539
|
source: { uri },
|
|
495
540
|
sharedCookiesEnabled: true,
|
|
541
|
+
webviewDebuggingEnabled,
|
|
496
542
|
thirdPartyCookiesEnabled: true,
|
|
497
|
-
cacheEnabled: false,
|
|
498
|
-
cacheMode: "LOAD_NO_CACHE",
|
|
499
543
|
onMessage: handler.onMessage,
|
|
500
544
|
injectedJavaScript: handler.injectedJavaScript,
|
|
501
545
|
injectedJavaScriptBeforeContentLoaded: handler.injectedJavaScript
|
|
@@ -545,6 +589,7 @@ var Accuracy2 = /* @__PURE__ */ ((Accuracy3) => {
|
|
|
545
589
|
export {
|
|
546
590
|
Accuracy2 as Accuracy,
|
|
547
591
|
AppsInToss,
|
|
592
|
+
Storage,
|
|
548
593
|
TossPay,
|
|
549
594
|
WebView,
|
|
550
595
|
appLogin,
|
|
@@ -554,6 +599,7 @@ export {
|
|
|
554
599
|
getClipboardText,
|
|
555
600
|
getCurrentLocation,
|
|
556
601
|
getOperationalEnvironment,
|
|
602
|
+
getTossAppVersion,
|
|
557
603
|
openCamera,
|
|
558
604
|
setClipboardText,
|
|
559
605
|
startUpdateLocation,
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apps-in-toss/framework",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.18",
|
|
5
5
|
"description": "The framework for Apps In Toss",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"prepack": "yarn build",
|
|
8
8
|
"typecheck": "tsc --noEmit",
|
|
9
|
+
"test:no-parallel": "vitest --no-watch",
|
|
9
10
|
"lint": "eslint .",
|
|
10
11
|
"build": "tsup"
|
|
11
12
|
},
|
|
@@ -55,21 +56,28 @@
|
|
|
55
56
|
"ait": "./bin/ait.js"
|
|
56
57
|
},
|
|
57
58
|
"dependencies": {
|
|
58
|
-
"@apps-in-toss/cli": "0.0.
|
|
59
|
-
"@apps-in-toss/plugins": "0.0.
|
|
59
|
+
"@apps-in-toss/cli": "0.0.18",
|
|
60
|
+
"@apps-in-toss/plugins": "0.0.18"
|
|
60
61
|
},
|
|
61
62
|
"devDependencies": {
|
|
62
|
-
"@react-native-bedrock/mpack-next": "0.0.
|
|
63
|
-
"@react-native-bedrock/native": "0.0.
|
|
63
|
+
"@react-native-bedrock/mpack-next": "^0.0.18",
|
|
64
|
+
"@react-native-bedrock/native": "0.0.16",
|
|
64
65
|
"@toss-design-system/react-native": "^0.4.1",
|
|
66
|
+
"@types/kill-port": "^2.0.1",
|
|
65
67
|
"@types/react": "18.3.3",
|
|
68
|
+
"@types/yauzl": "^2.10.3",
|
|
69
|
+
"es-toolkit": "^1.34.1",
|
|
66
70
|
"eslint": "^9.7.0",
|
|
71
|
+
"execa": "^9.5.2",
|
|
72
|
+
"kill-port": "^2.0.1",
|
|
67
73
|
"react": "18.2.0",
|
|
68
74
|
"react-native": "0.72.6",
|
|
69
|
-
"react-native-bedrock": "0.0.
|
|
75
|
+
"react-native-bedrock": "^0.0.18",
|
|
70
76
|
"tsup": "^8.3.5",
|
|
71
77
|
"typescript": "4.9.5",
|
|
72
|
-
"vitest": "^3.0.3"
|
|
78
|
+
"vitest": "^3.0.3",
|
|
79
|
+
"workspace-tools": "^0.38.2",
|
|
80
|
+
"yauzl": "^3.2.0"
|
|
73
81
|
},
|
|
74
82
|
"peerDependencies": {
|
|
75
83
|
"@react-native-bedrock/native": "*",
|
|
@@ -82,5 +90,5 @@
|
|
|
82
90
|
"publishConfig": {
|
|
83
91
|
"access": "public"
|
|
84
92
|
},
|
|
85
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "2563312f28a4702050104bebd4c1289183c705d2"
|
|
86
94
|
}
|
package/src/constant-bridges.ts
CHANGED