@apps-in-toss/framework 0.0.28 → 0.0.30

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.d.ts CHANGED
@@ -1716,6 +1716,204 @@ declare function setDeviceOrientation(options: {
1716
1716
  type: 'portrait' | 'landscape';
1717
1717
  }): Promise<void>;
1718
1718
 
1719
+ interface SaveBase64DataParams {
1720
+ data: string;
1721
+ fileName: string;
1722
+ mimeType: string;
1723
+ }
1724
+ /**
1725
+ * @public
1726
+ * @category 데이터
1727
+ * @name saveBase64Data
1728
+ * @description 문자열로 인코딩된 Base64 데이터를 지정한 파일 이름과 MIME 타입으로 사용자 기기에 저장해요. 이미지, 텍스트, PDF 등 다양한 형식의 데이터를 저장할 수 있어요.
1729
+ * @param {SaveBase64DataParams} params - 저장할 데이터와 파일 정보를 담은 객체예요.
1730
+ * @param {string} params.data - Base64 형식으로 인코딩된 데이터 문자열이에요.
1731
+ * @param {string} params.fileName - 저장할 파일 이름이에요. 확장자도 같이 붙여줘야해요. 예를 들어, 'example.png'로 저장할 수 있어요.
1732
+ * @param {string} params.mimeType - 저장할 파일의 MIME 타입이에요. 예를 들어 'image/png' 로 지정하면 이미지, 'application/pdf'는 PDF 파일이에요. 자세한 내용은 [MIME 문서](https://developer.mozilla.org/ko/docs/Web/HTTP/Guides/MIME_types)를 참고해주세요.
1733
+ *
1734
+ * @example
1735
+ * ### Base64 이미지 데이터를 사용자 기기에 저장하기
1736
+ *
1737
+ * ```tsx
1738
+ * import { Button } from 'react-native';
1739
+ * import { saveBase64Data } from '@apps-in-toss/framework';
1740
+ *
1741
+ * // '저장' 버튼을 누르면 이미지가 사용자 기기에 저장돼요.
1742
+ * function SaveButton() {
1743
+ * const handleSave = async () => {
1744
+ * try {
1745
+ * await saveBase64Data({
1746
+ * data: 'iVBORw0KGgo...',
1747
+ * fileName: 'some-photo.png',
1748
+ * mimeType: 'image/png',
1749
+ * });
1750
+ * } catch (error) {
1751
+ * console.error('데이터 저장에 실패했어요:', error);
1752
+ * }
1753
+ * };
1754
+ *
1755
+ * return <Button title="저장" onPress={handleSave} />;
1756
+ * }
1757
+ * ```
1758
+ */
1759
+ declare function saveBase64Data(params: SaveBase64DataParams): Promise<void>;
1760
+
1761
+ /**
1762
+ * @public
1763
+ * @category 인앱결제
1764
+ * @name IapCreateOneTimePurchaseOrderOptions
1765
+ * @description 인앱결제 1건을 요청할 때 필요한 정보예요.
1766
+ * @property {string} productId - 주문할 상품의 ID예요.
1767
+ */
1768
+ interface IapCreateOneTimePurchaseOrderOptions {
1769
+ productId: string;
1770
+ }
1771
+ /**
1772
+ * @public
1773
+ * @category 인앱결제
1774
+ * @name IapCreateOneTimePurchaseOrderResult
1775
+ * @description 인앱결제 1건이 완료되면 결제 세부 정보와 상품 정보를 담아 반환해요. 반환된 정보로 결제한 상품의 정보를 화면에 표시할 수 있어요.
1776
+ * @property {string | null} miniAppIconUrl - 미니앱 아이콘 이미지의 URL이에요. 아이콘은 앱인토스 콘솔에서 설정한 이미지예요. 콘솔에서 아이콘을 등록하지 않았다면 `null`로 반환돼요.
1777
+ * @property {string} displayName - 화면에 표시할 상품 이름이에요.
1778
+ * @property {string} displayAmount - 통화 단위가 포함된 가격 정보예요. 예를 들어 `1,000원`으로 가격과 통화가 함께 표시돼요.
1779
+ * @property {number} amount - 상품 가격 숫자 값이에요. 화폐 단위와 쉼표를 제외한 순수 숫자예요. 예를 들어 `1000`으로 표시돼요.
1780
+ * @property {string} currency - [ISO 4217 표준](https://ko.wikipedia.org/wiki/ISO_4217)에 따른 상품 가격 통화 단위예요. 예를 들어 원화는 `KRW`, 달러는 `USD`로 표시돼요.
1781
+ * @property {number} fraction - 가격을 표시할 때 소수점 아래 몇 자리까지 보여줄지 정하는 값이에요. 예를 들어 달러는 소수점 둘째 자리까지 보여줘서 `2`, 원화는 소수점이 필요 없어서 `0`이에요
1782
+ */
1783
+ interface IapCreateOneTimePurchaseOrderResult {
1784
+ miniAppIconUrl: string | null;
1785
+ displayName: string;
1786
+ displayAmount: string;
1787
+ amount: number;
1788
+ currency: string;
1789
+ fraction: number;
1790
+ }
1791
+ /**
1792
+ * @public
1793
+ * @category 인앱결제
1794
+ * @name iapCreateOneTimePurchaseOrder
1795
+ * @description
1796
+ * 특정 인앱결제 주문서 페이지로 이동해요. 사용자가 상품 구매 버튼을 누르는 상황 등에 사용할 수 있어요. 사용자의 결제는 이동한 페이지에서 진행돼요. 만약 결제 중에 에러가 발생하면 에러 유형에 따라 에러 페이지로 이동해요.
1797
+ * @param {IapCreateOneTimePurchaseOrderOptions} params - 인앱결제를 생성할 때 필요한 정보예요.
1798
+ * @param {string} params.productId - 주문할 상품의 ID예요.
1799
+ * @returns {Promise<IapCreateOneTimePurchaseOrderResult | undefined>} 결제에 성공하면 결제 결과 객체를 반환해요. 앱 버전이 최소 지원 버전(안드로이드 5.219.0, iOS 5.219.0)보다 낮으면 인앱결제를 실행할 수 없어서 `undefined`를 반환해요.
1800
+ *
1801
+ * @throw {code: "INVALID_PRODUCT_ID"} - 유효하지 않은 상품 ID이거나, 해당 상품이 존재하지 않을 때 발생해요.
1802
+ * @throw {code: "PAYMENT_PENDING"} - 사용자가 요청한 결제가 아직 승인을 기다리고 있을 때 발생해요.
1803
+ * @throw {code: "NETWORK_ERROR"} - 서버 내부 문제로 요청을 처리할 수 없을 때 발생해요.
1804
+ * @throw {code: "INVALID_USER_ENVIRONMENT"} - 특정 기기, 계정 또는 설정 환경에서 구매할 수 없는 상품일 때 발생해요.
1805
+ * @throw {code: "ITEM_ALREADY_OWNED"} - 사용자가 이미 구매한 상품을 다시 구매하려고 할 때 발생해요.
1806
+ * @throw {code: "APP_MARKET_VERIFICATION_FAILED"} - 사용자가 결제를 완료했지만, 앱스토어에서 사용자 정보 검증에 실패했을 때 발생해요. 사용자가 앱스토어에 문의해서 환불을 요청해야해요.
1807
+ * @throw {code: "TOSS_SERVER_VERIFICATION_FAILED"} - 사용자가 결제를 완료했지만, 서버 전송에 실패해서 결제 정보를 저장할 수 없을 때 발생해요.
1808
+ * @throw {code: "INTERNAL_ERROR"} - 서버 내부 문제로 요청을 처리할 수 없을 때 발생해요.
1809
+ * @throw {code: "KOREAN_ACCOUNT_ONLY"} - iOS 환경에서 사용자의 계정이 한국 계정이 아닐 때 발생해요.
1810
+ * @throw {code: "USER_CANCELED"} - 사용자가 결제를 완료하지 않고 주문서 페이지를 이탈했을 때 발생해요.
1811
+ *
1812
+ * @example
1813
+ * ### 특정 인앱결제 주문서 페이지로 이동하기
1814
+ *
1815
+ * ```tsx
1816
+ * import { Button } from 'react-native';
1817
+ * import { IAP } from '@apps-in-toss/framework';
1818
+ *
1819
+ * interface Props {
1820
+ * productId: string;
1821
+ * }
1822
+ *
1823
+ * function IapCreateOneTimePurchaseOrderButton({ productId }: Props) {
1824
+ * const handleClick = async () => {
1825
+ * try {
1826
+ * await IAP.createOneTimePurchaseOrder({
1827
+ * productId,
1828
+ * });
1829
+ * } catch (error) {
1830
+ * console.error('인앱결제에 실패했어요:', error);
1831
+ * }
1832
+ * };
1833
+ *
1834
+ * return <Button title="구매하기" onPress={handleClick} />;
1835
+ * }
1836
+ * ```
1837
+ */
1838
+ declare function createOneTimePurchaseOrder(params: IapCreateOneTimePurchaseOrderOptions): Promise<IapCreateOneTimePurchaseOrderResult | undefined>;
1839
+ /**
1840
+ * @public
1841
+ * @category 인앱결제
1842
+ * @name IapProductListItem
1843
+ * @description 인앱결제로 구매할 수 있는 상품 하나의 정보를 담은 객체예요. 상품 목록을 화면에 표시할 때 사용해요.
1844
+ * @property {string} sku - 상품의 고유 ID예요. [인앱결제 주문서 페이지로 이동할때](/bedrock/reference/framework/인앱결제/createOneTimePurchaseOrder.html) 사용하는 `productId`와 동일한 값이에요.
1845
+ * @property {string} displayName - 화면에 표시할 상품 이름이에요. 상품 이름은 앱인토스 콘솔에서 설정한 값이에요.
1846
+ * @property {string} displayAmount - 통화 단위가 포함된 가격 정보예요. 예를 들어 `1,000원`으로 가격과 통화가 함께 표시돼요.
1847
+ * @property {string} iconUrl - 상품 아이콘 이미지의 URL이에요. 아이콘은 앱인토스 콘솔에서 설정한 이미지예요.
1848
+ * @property {string} description - 상품에 대한 설명이에요. 설명은 앱인토스 콘솔에서 설정한 값이에요.
1849
+ */
1850
+ interface IapProductListItem {
1851
+ sku: string;
1852
+ displayAmount: string;
1853
+ displayName: string;
1854
+ iconUrl: string;
1855
+ description: string;
1856
+ }
1857
+ /**
1858
+ * @public
1859
+ * @category 인앱결제
1860
+ * @name iapGetProductItemList
1861
+ * @description 인앱결제로 구매할 수 있는 상품 목록을 가져와요. 상품 목록 화면에 진입할 때 호출해요.
1862
+ * @returns {Promise<{ products: IapProductListItem[] } | undefined>} 상품 목록을 포함한 객체를 반환해요. 앱 버전이 최소 지원 버전(안드로이드 5.219.0, iOS 5.219.0)보다 낮으면 `undefined`를 반환해요.
1863
+ *
1864
+ * @example
1865
+ * ### 구매 가능한 인앱결제 상품목록 가져오기
1866
+ *
1867
+ * ```tsx
1868
+ * import { useEffect, useState } from 'react';
1869
+ * import { List, ListRow, Txt } from '@toss-design-system/react-native';
1870
+ * import { IAP } from '@apps-in-toss/framework';
1871
+ *
1872
+ * function IapGetProductItemList() {
1873
+ * const [products, setProducts] = useState<IapProductListItem[]>([]);
1874
+ *
1875
+ * useEffect(() => {
1876
+ * async function fetchProducts() {
1877
+ * try {
1878
+ * const response = await IAP.getProductItemList();
1879
+ * setProducts(response?.products ?? []);
1880
+ * } catch (error) {
1881
+ * console.error('상품 목록을 가져오는 데 실패했어요:', error);
1882
+ * }
1883
+ * }
1884
+ *
1885
+ * fetchProducts();
1886
+ * }, []);
1887
+ *
1888
+ * return (
1889
+ * <List>
1890
+ * {products.map((product) => (
1891
+ * <ListRow
1892
+ * key={product.sku}
1893
+ * contents={<Txt>{product.displayName}</Txt>}
1894
+ * />
1895
+ * ))}
1896
+ * </List>
1897
+ * );
1898
+ * }
1899
+ * ```
1900
+ */
1901
+ declare function getProductItemList(): Promise<{
1902
+ products: IapProductListItem[];
1903
+ } | undefined>;
1904
+ /**
1905
+ * @public
1906
+ * @category 인앱결제
1907
+ * @name IAP
1908
+ * @description 인앱결제 관련 기능을 모은 객체예요. 단건 인앱결제 주문서 이동과 상품 목록 조회 기능을 제공해요.
1909
+ * @property {typeof createOneTimePurchaseOrder} [createOneTimePurchaseOrder] 특정 인앱결제 주문서 페이지로 이동해요. 자세한 내용은 [createOneTimePurchaseOrder](/bedrock/reference/framework/인앱결제/createOneTimePurchaseOrder.html) 문서를 참고하세요.
1910
+ * @property {typeof getProductItemList} [getProductItemList] 인앱결제로 구매할 수 있는 상품 목록을 가져와요. 자세한 내용은 [getProductItemList](/bedrock/reference/framework/인앱결제/getProductItemList.html) 문서를 참고하세요.
1911
+ */
1912
+ declare const IAP: {
1913
+ createOneTimePurchaseOrder: typeof createOneTimePurchaseOrder;
1914
+ getProductItemList: typeof getProductItemList;
1915
+ };
1916
+
1719
1917
  /**
1720
1918
  * @public
1721
1919
  * @category 토스페이
@@ -1765,6 +1963,17 @@ interface LocalNetwork {
1765
1963
  type InternalProps = 'source' | 'cacheEnabled' | 'sharedCookiesEnabled' | 'thirdPartyCookiesEnabled' | 'injectedJavaScriptBeforeContentLoaded';
1766
1964
  declare function WebView({ type, local, onMessage, ...props }: WebViewProps): react_jsx_runtime.JSX.Element;
1767
1965
 
1966
+ declare function useCreateUserAgent({ batteryModePreference, colorPreference, fontA11y, locale, navbarPreference, pureSafeArea, safeArea, safeAreaBottomTransparency, }: {
1967
+ batteryModePreference?: string;
1968
+ colorPreference?: string;
1969
+ fontA11y?: string;
1970
+ locale?: string;
1971
+ navbarPreference?: string;
1972
+ pureSafeArea?: string;
1973
+ safeArea?: string;
1974
+ safeAreaBottomTransparency?: string;
1975
+ }): string;
1976
+
1768
1977
  type UseGeolocationOptions = Omit<StartUpdateLocationOptions$1, 'callback'>;
1769
1978
  /**
1770
1979
  * @public
@@ -1859,7 +2068,26 @@ declare class AppBridgeCallbackEvent extends BedrockEventDefinition<void, AppBri
1859
2068
  private ensureInvokeAppBridgeCallback;
1860
2069
  }
1861
2070
 
1862
- declare const appsInTossEvent: BedrockEvent<EntryMessageExitedEvent | AppBridgeCallbackEvent | UpdateLocationEvent>;
2071
+ interface VisibilityChangedByTransparentServiceWebOptions {
2072
+ callbackId: string;
2073
+ }
2074
+ declare class VisibilityChangedByTransparentServiceWebEvent extends BedrockEventDefinition<VisibilityChangedByTransparentServiceWebOptions, boolean> {
2075
+ name: "onVisibilityChangedByTransparentServiceWeb";
2076
+ subscription: EmitterSubscription | null;
2077
+ remove(): void;
2078
+ listener(options: VisibilityChangedByTransparentServiceWebOptions, onEvent: (isVisible: boolean) => void, onError: (error: unknown) => void): void;
2079
+ private isVisibilityChangedByTransparentServiceWebResult;
2080
+ }
2081
+
2082
+ declare const appsInTossEvent: BedrockEvent<EntryMessageExitedEvent | VisibilityChangedByTransparentServiceWebEvent | UpdateLocationEvent | AppBridgeCallbackEvent>;
2083
+
2084
+ declare function onVisibilityChangedByTransparentServiceWeb(eventParams: {
2085
+ options: VisibilityChangedByTransparentServiceWebOptions;
2086
+ onEvent: (isVisible: boolean) => void;
2087
+ onError: (error: unknown) => void;
2088
+ }): () => void;
2089
+
2090
+ declare const INTERNAL__onVisibilityChangedByTransparentServiceWeb: typeof onVisibilityChangedByTransparentServiceWeb;
1863
2091
 
1864
2092
  declare const Analytics: {
1865
2093
  init: (options: _apps_in_toss_analytics.AnalyticsConfig) => void;
@@ -1868,4 +2096,4 @@ declare const Analytics: {
1868
2096
  Area: ({ children, params: _params, ...props }: _apps_in_toss_analytics.LoggingAreaProps) => react_jsx_runtime.JSX.Element;
1869
2097
  };
1870
2098
 
1871
- export { Accuracy, Analytics, AppsInToss, type ContactEntity, type EventLogParams, type ExternalWebViewProps, type FetchAlbumPhotosOptions, type GameWebViewProps, type GetCurrentLocationOptions, GoogleAdMob, type ImageResponse, type LoadAdMobInterstitialAdEvent, type LoadAdMobInterstitialAdOptions, type LoadAdMobRewardedAdEvent, type LoadAdMobRewardedAdOptions, type Location, type LocationCoords, type OpenCameraOptions, type PartnerWebViewProps, type ShowAdMobInterstitialAdEvent, type ShowAdMobInterstitialAdOptions, type ShowAdMobRewardedAdEvent, type ShowAdMobRewardedAdOptions, type StartUpdateLocationOptions$1 as StartUpdateLocationOptions, type StartUpdateLocationSubscription, Storage, TossPay, type UpdateLocationEventEmitter, type UseGeolocationOptions, WebView, type WebViewProps, appLogin, appsInTossEvent, env, eventLog, fetchAlbumPhotos, fetchContacts, getClipboardText, getCurrentLocation, getDeviceId, getOperationalEnvironment, getTossAppVersion, getTossShareLink, isMinVersionSupported, openCamera, setClipboardText, setDeviceOrientation, startUpdateLocation, useGeolocation };
2099
+ export { Accuracy, Analytics, AppsInToss, type ContactEntity, type EventLogParams, type ExternalWebViewProps, type FetchAlbumPhotosOptions, type GameWebViewProps, type GetCurrentLocationOptions, GoogleAdMob, IAP, INTERNAL__onVisibilityChangedByTransparentServiceWeb, type IapCreateOneTimePurchaseOrderOptions, type IapCreateOneTimePurchaseOrderResult, type IapProductListItem, type ImageResponse, type LoadAdMobInterstitialAdEvent, type LoadAdMobInterstitialAdOptions, type LoadAdMobRewardedAdEvent, type LoadAdMobRewardedAdOptions, type Location, type LocationCoords, type OpenCameraOptions, type PartnerWebViewProps, type SaveBase64DataParams, type ShowAdMobInterstitialAdEvent, type ShowAdMobInterstitialAdOptions, type ShowAdMobRewardedAdEvent, type ShowAdMobRewardedAdOptions, type StartUpdateLocationOptions$1 as StartUpdateLocationOptions, type StartUpdateLocationSubscription, Storage, TossPay, type UpdateLocationEventEmitter, type UseGeolocationOptions, WebView, type WebViewProps, appLogin, appsInTossEvent, env, eventLog, fetchAlbumPhotos, fetchContacts, getClipboardText, getCurrentLocation, getDeviceId, getOperationalEnvironment, getTossAppVersion, getTossShareLink, isMinVersionSupported, openCamera, saveBase64Data, setClipboardText, setDeviceOrientation, startUpdateLocation, useCreateUserAgent, useGeolocation };
package/dist/index.js CHANGED
@@ -367,11 +367,39 @@ var AppBridgeCallbackEvent = class _AppBridgeCallbackEvent extends BedrockEventD
367
367
  }
368
368
  };
369
369
 
370
+ // src/native-event-emitter/internal/VisibilityChangedByTransparentServiceWebEvent.ts
371
+ import { BedrockEventDefinition as BedrockEventDefinition4 } from "react-native-bedrock";
372
+ var VisibilityChangedByTransparentServiceWebEvent = class extends BedrockEventDefinition4 {
373
+ name = "onVisibilityChangedByTransparentServiceWeb";
374
+ subscription = null;
375
+ remove() {
376
+ this.subscription?.remove();
377
+ this.subscription = null;
378
+ }
379
+ listener(options, onEvent, onError) {
380
+ const subscription = nativeEventEmitter.addListener("visibilityChangedByTransparentServiceWeb", (params) => {
381
+ if (this.isVisibilityChangedByTransparentServiceWebResult(params)) {
382
+ if (params.callbackId === options.callbackId) {
383
+ onEvent(params.isVisible);
384
+ }
385
+ } else {
386
+ onError(new Error("Invalid visibility changed by transparent service web result"));
387
+ }
388
+ });
389
+ this.subscription = subscription;
390
+ }
391
+ isVisibilityChangedByTransparentServiceWebResult(params) {
392
+ return typeof params === "object" && typeof params.callbackId === "string" && typeof params.isVisible === "boolean";
393
+ }
394
+ };
395
+
370
396
  // src/native-event-emitter/appsInTossEvent.ts
371
397
  var appsInTossEvent = new BedrockEvent([
372
- new AppBridgeCallbackEvent(),
373
398
  new UpdateLocationEvent(),
374
- new EntryMessageExitedEvent()
399
+ new EntryMessageExitedEvent(),
400
+ // Internal events
401
+ new AppBridgeCallbackEvent(),
402
+ new VisibilityChangedByTransparentServiceWebEvent()
375
403
  ]);
376
404
 
377
405
  // src/core/utils/getAppsInTossGlobals.ts
@@ -419,6 +447,7 @@ __export(async_bridges_exports, {
419
447
  getCurrentLocation: () => getCurrentLocation,
420
448
  getTossShareLink: () => getTossShareLink,
421
449
  openCamera: () => openCamera,
450
+ saveBase64Data: () => saveBase64Data,
422
451
  setClipboardText: () => setClipboardText,
423
452
  setDeviceOrientation: () => setDeviceOrientation
424
453
  });
@@ -559,6 +588,19 @@ async function setDeviceOrientation(options) {
559
588
  return AppsInTossModule.setDeviceOrientation(options);
560
589
  }
561
590
 
591
+ // src/native-modules/saveBase64Data.ts
592
+ async function saveBase64Data(params) {
593
+ const isSupported = isMinVersionSupported({
594
+ android: "5.218.0",
595
+ ios: "5.216.0"
596
+ });
597
+ if (!isSupported) {
598
+ console.warn("saveBase64Data is not supported in this app version");
599
+ return;
600
+ }
601
+ await AppsInTossModule.saveBase64Data(params);
602
+ }
603
+
562
604
  // src/core/registerApp.tsx
563
605
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
564
606
  function AppsInTossContainer(Container, { children, ...initialProps }) {
@@ -700,7 +742,6 @@ var ENVIRONMENT = getOperationalEnvironment();
700
742
  function createIsSupported() {
701
743
  return () => {
702
744
  if (ENVIRONMENT !== "toss") {
703
- console.warn("Google AdMob is not supported in the current environment");
704
745
  return false;
705
746
  }
706
747
  return isMinVersionSupported({
@@ -747,6 +788,32 @@ var Storage = {
747
788
  clearItems
748
789
  };
749
790
 
791
+ // src/native-modules/iap.ts
792
+ async function createOneTimePurchaseOrder(params) {
793
+ const isSupported = isMinVersionSupported({
794
+ android: "5.219.0",
795
+ ios: "5.219.0"
796
+ });
797
+ if (!isSupported) {
798
+ return;
799
+ }
800
+ return AppsInTossModule.iapCreateOneTimePurchaseOrder(params);
801
+ }
802
+ async function getProductItemList() {
803
+ const isSupported = isMinVersionSupported({
804
+ android: "5.219.0",
805
+ ios: "5.219.0"
806
+ });
807
+ if (!isSupported) {
808
+ return;
809
+ }
810
+ return AppsInTossModule.iapGetProductItemList({});
811
+ }
812
+ var IAP = {
813
+ createOneTimePurchaseOrder,
814
+ getProductItemList
815
+ };
816
+
750
817
  // src/native-modules/index.ts
751
818
  var TossPay = {
752
819
  checkoutPayment
@@ -760,11 +827,12 @@ var GoogleAdMob = {
760
827
 
761
828
  // src/components/WebView.tsx
762
829
  import {
763
- PartnerWebViewScreen,
764
- ExternalWebViewScreen
830
+ ExternalWebViewScreen,
831
+ PartnerWebViewScreen
765
832
  } from "@toss-design-system/react-native";
766
833
  import { useSafeAreaBottom, useSafeAreaTop as useSafeAreaTop2 } from "@toss-design-system/react-native/private";
767
834
  import { useCallback as useCallback3, useMemo as useMemo3 } from "react";
835
+ import { Platform as Platform6 } from "react-native";
768
836
  import { getSchemeUri as getSchemeUri4, useBedrockEvent } from "react-native-bedrock";
769
837
  import * as bedrockAsyncBridges from "react-native-bedrock/async-bridges";
770
838
  import * as bedrockConstantBridges from "react-native-bedrock/constant-bridges";
@@ -1057,6 +1125,61 @@ __export(event_bridges_exports, {
1057
1125
  startUpdateLocation: () => startUpdateLocation
1058
1126
  });
1059
1127
 
1128
+ // src/hooks/useCreateUserAgent.ts
1129
+ import { useWindowDimensions } from "react-native";
1130
+ import { getPlatformOS } from "react-native-bedrock";
1131
+ function useCreateUserAgent({
1132
+ batteryModePreference,
1133
+ colorPreference,
1134
+ fontA11y,
1135
+ locale,
1136
+ navbarPreference,
1137
+ pureSafeArea,
1138
+ safeArea,
1139
+ safeAreaBottomTransparency
1140
+ }) {
1141
+ const platform = getPlatformOS();
1142
+ const appVersion = getTossAppVersion();
1143
+ const fontScale = useWindowDimensions().fontScale;
1144
+ const platformString = platform === "ios" ? "iPhone" : "Android";
1145
+ return [
1146
+ `TossApp/${appVersion}`,
1147
+ batteryModePreference && `TossBatteryModePreference/${batteryModePreference}`,
1148
+ colorPreference && `TossColorPreference/${colorPreference}`,
1149
+ fontA11y && `TossFontAccessibility/${fontA11y}`,
1150
+ fontScale && `TossFontScale/${fontScale}`,
1151
+ locale && `TossLocale/${locale}`,
1152
+ navbarPreference && `TossNavbarPreference/${navbarPreference}`,
1153
+ pureSafeArea && `TossPureSafeArea/${pureSafeArea}`,
1154
+ safeArea && `TossSafeArea/${safeArea}`,
1155
+ safeAreaBottomTransparency && `TossSafeAreaBottomTransparency/${safeAreaBottomTransparency}`,
1156
+ platformString
1157
+ ].filter(Boolean).join(" ");
1158
+ }
1159
+
1160
+ // src/hooks/useGeolocation.ts
1161
+ import { useState, useEffect as useEffect4 } from "react";
1162
+ import { useVisibility } from "react-native-bedrock";
1163
+ function useGeolocation({ accuracy, distanceInterval, timeInterval }) {
1164
+ const isVisible = useVisibility();
1165
+ const [location, setLocation] = useState(null);
1166
+ useEffect4(() => {
1167
+ if (!isVisible) {
1168
+ return;
1169
+ }
1170
+ return startUpdateLocation({
1171
+ options: {
1172
+ accuracy,
1173
+ distanceInterval,
1174
+ timeInterval
1175
+ },
1176
+ onEvent: setLocation,
1177
+ onError: console.error
1178
+ });
1179
+ }, [accuracy, distanceInterval, timeInterval, isVisible]);
1180
+ return location;
1181
+ }
1182
+
1060
1183
  // src/utils/log.ts
1061
1184
  import { getSchemeUri as getSchemeUri3 } from "react-native-bedrock";
1062
1185
 
@@ -1145,6 +1268,7 @@ function WebView({ type, local, onMessage, ...props }) {
1145
1268
  const uri = useMemo3(() => getWebViewUri(local), [local]);
1146
1269
  const top = useSafeAreaTop2();
1147
1270
  const bottom = useSafeAreaBottom();
1271
+ const global2 = getAppsInTossGlobals();
1148
1272
  const handler = useBridgeHandler({
1149
1273
  onMessage,
1150
1274
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -1166,6 +1290,7 @@ function WebView({ type, local, onMessage, ...props }) {
1166
1290
  ...constant_bridges_exports,
1167
1291
  getSafeAreaTop: () => top,
1168
1292
  getSafeAreaBottom: () => bottom,
1293
+ ...Object.fromEntries(Object.entries(global2).map(([key, value]) => [key, () => value])),
1169
1294
  /** AdMob */
1170
1295
  loadAdMobInterstitialAd_isSupported: GoogleAdMob.loadAdMobInterstitialAd.isSupported,
1171
1296
  showAdMobInterstitialAd_isSupported: GoogleAdMob.showAdMobInterstitialAd.isSupported,
@@ -1183,7 +1308,10 @@ function WebView({ type, local, onMessage, ...props }) {
1183
1308
  getStorageItem: Storage.getItem,
1184
1309
  setStorageItem: Storage.setItem,
1185
1310
  removeStorageItem: Storage.removeItem,
1186
- clearItems: Storage.clearItems
1311
+ clearItems: Storage.clearItems,
1312
+ /** IAP */
1313
+ iapCreateOneTimePurchaseOrder: IAP.createOneTimePurchaseOrder,
1314
+ iapGetProductItemList: IAP.getProductItemList
1187
1315
  }
1188
1316
  });
1189
1317
  const baseProps = useMemo3(() => {
@@ -1222,13 +1350,23 @@ function WebView({ type, local, onMessage, ...props }) {
1222
1350
  trackScreen(event.url);
1223
1351
  }
1224
1352
  }, []);
1353
+ const userAgent = useCreateUserAgent({
1354
+ colorPreference: "light"
1355
+ });
1225
1356
  return /* @__PURE__ */ jsx5(
1226
1357
  BaseWebView,
1227
1358
  {
1228
1359
  ref: handler.ref,
1229
1360
  ...props,
1230
1361
  ...baseProps,
1231
- source: { uri },
1362
+ source: {
1363
+ uri,
1364
+ // NOTE: https://github.com/react-native-webview/react-native-webview/pull/3133
1365
+ headers: {
1366
+ "User-Agent": userAgent
1367
+ }
1368
+ },
1369
+ userAgent: Platform6.OS === "ios" ? userAgent : void 0,
1232
1370
  sharedCookiesEnabled: true,
1233
1371
  webviewDebuggingEnabled: webViewDebuggingEnabled,
1234
1372
  thirdPartyCookiesEnabled: true,
@@ -1246,29 +1384,6 @@ function ensureValue(value, name) {
1246
1384
  return value;
1247
1385
  }
1248
1386
 
1249
- // src/hooks/useGeolocation.ts
1250
- import { useState, useEffect as useEffect4 } from "react";
1251
- import { useVisibility } from "react-native-bedrock";
1252
- function useGeolocation({ accuracy, distanceInterval, timeInterval }) {
1253
- const isVisible = useVisibility();
1254
- const [location, setLocation] = useState(null);
1255
- useEffect4(() => {
1256
- if (!isVisible) {
1257
- return;
1258
- }
1259
- return startUpdateLocation({
1260
- options: {
1261
- accuracy,
1262
- distanceInterval,
1263
- timeInterval
1264
- },
1265
- onEvent: setLocation,
1266
- onError: console.error
1267
- });
1268
- }, [accuracy, distanceInterval, timeInterval, isVisible]);
1269
- return location;
1270
- }
1271
-
1272
1387
  // src/types.ts
1273
1388
  var Accuracy2 = /* @__PURE__ */ ((Accuracy3) => {
1274
1389
  Accuracy3[Accuracy3["Lowest"] = 1] = "Lowest";
@@ -1280,6 +1395,14 @@ var Accuracy2 = /* @__PURE__ */ ((Accuracy3) => {
1280
1395
  return Accuracy3;
1281
1396
  })(Accuracy2 || {});
1282
1397
 
1398
+ // src/native-event-emitter/internal/onVisibilityChangedByTransparentServiceWeb.ts
1399
+ function onVisibilityChangedByTransparentServiceWeb(eventParams) {
1400
+ return appsInTossEvent.addEventListener("onVisibilityChangedByTransparentServiceWeb", eventParams);
1401
+ }
1402
+
1403
+ // src/private.ts
1404
+ var INTERNAL__onVisibilityChangedByTransparentServiceWeb = onVisibilityChangedByTransparentServiceWeb;
1405
+
1283
1406
  // src/index.ts
1284
1407
  export * from "@apps-in-toss/analytics";
1285
1408
  var Analytics2 = {
@@ -1293,6 +1416,8 @@ export {
1293
1416
  Analytics2 as Analytics,
1294
1417
  AppsInToss,
1295
1418
  GoogleAdMob,
1419
+ IAP,
1420
+ INTERNAL__onVisibilityChangedByTransparentServiceWeb,
1296
1421
  Storage,
1297
1422
  TossPay,
1298
1423
  WebView,
@@ -1310,8 +1435,10 @@ export {
1310
1435
  getTossShareLink,
1311
1436
  isMinVersionSupported,
1312
1437
  openCamera,
1438
+ saveBase64Data,
1313
1439
  setClipboardText,
1314
1440
  setDeviceOrientation,
1315
1441
  startUpdateLocation,
1442
+ useCreateUserAgent,
1316
1443
  useGeolocation
1317
1444
  };
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.28",
4
+ "version": "0.0.30",
5
5
  "description": "The framework for Apps In Toss",
6
6
  "scripts": {
7
7
  "prepack": "yarn build",
@@ -57,9 +57,9 @@
57
57
  "ait": "./bin/ait.js"
58
58
  },
59
59
  "dependencies": {
60
- "@apps-in-toss/analytics": "0.0.28",
61
- "@apps-in-toss/cli": "0.0.28",
62
- "@apps-in-toss/plugins": "0.0.28",
60
+ "@apps-in-toss/analytics": "0.0.30",
61
+ "@apps-in-toss/cli": "0.0.30",
62
+ "@apps-in-toss/plugins": "0.0.30",
63
63
  "es-hangul": "^2.3.2"
64
64
  },
65
65
  "devDependencies": {
@@ -73,6 +73,7 @@
73
73
  "es-toolkit": "^1.34.1",
74
74
  "eslint": "^9.7.0",
75
75
  "execa": "^9.5.2",
76
+ "jsdom": "^25.0.1",
76
77
  "kill-port": "^2.0.1",
77
78
  "react": "18.2.0",
78
79
  "react-native": "0.72.6",
@@ -93,5 +94,5 @@
93
94
  "publishConfig": {
94
95
  "access": "public"
95
96
  },
96
- "gitHead": "17b4c5583054e58a9da274a886ee10c76671d24d"
97
+ "gitHead": "7390d4ed0f09dec042523a302bc1aa0d21474512"
97
98
  }
@@ -9,3 +9,4 @@ export * from './native-modules/checkoutPayment';
9
9
  export * from './native-modules/eventLog';
10
10
  export * from './native-modules/getTossShareLink';
11
11
  export * from './native-modules/setDeviceOrientation';
12
+ export * from './native-modules/saveBase64Data';