sales-frontend-bridge 0.0.22 → 0.0.24

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 CHANGED
@@ -1450,6 +1450,9 @@ var IframeBridgeCore = class extends CommonBridgeCore {
1450
1450
  super();
1451
1451
  __publicField(this, "pendingPromises", /* @__PURE__ */ new Map());
1452
1452
  __publicField(this, "responseHandler");
1453
+ if (!salesFrontendUtils.isClient()) {
1454
+ return;
1455
+ }
1453
1456
  this.initializeIframeBridge();
1454
1457
  }
1455
1458
  /**
@@ -1575,19 +1578,35 @@ var IframeBridge = class extends CommonBridge {
1575
1578
  // TODO: 필요 플러그인들 추가
1576
1579
  };
1577
1580
  var NativeBridgeCore = class extends CommonBridgeCore {
1578
- constructor() {
1581
+ constructor(callBridgeName = "n2Bridge", promiseHandleName = "n2bridge") {
1579
1582
  super();
1580
- this.initializeWindowBridge();
1583
+ __publicField(this, "promiseHandleName");
1584
+ __publicField(this, "callBridgeName");
1585
+ this.callBridgeName = callBridgeName;
1586
+ this.promiseHandleName = promiseHandleName;
1587
+ this.initializeWindowOzBridge();
1581
1588
  }
1582
1589
  /**
1583
- * 네이티브 통신을 위해 window.n2bridge 객체 초기화
1590
+ * Promise 관리용 브릿지 객체 가져오기 (window.n2bridge)
1591
+ */
1592
+ getPromiseHandleBridge() {
1593
+ return window[this.promiseHandleName];
1594
+ }
1595
+ /**
1596
+ * 앱 호출용 브릿지 객체 가져오기 (window.n2Bridge)
1597
+ */
1598
+ getCallBridge() {
1599
+ return window[this.callBridgeName];
1600
+ }
1601
+ /**
1602
+ * 네이티브 통신을 위해 window.n2OzBridge 객체 초기화
1584
1603
  */
1585
- initializeWindowBridge() {
1604
+ initializeWindowOzBridge() {
1586
1605
  if (!salesFrontendUtils.isClient()) {
1587
1606
  return;
1588
1607
  }
1589
- if (!window.n2bridge) {
1590
- window.n2bridge = {
1608
+ if (!window[this.promiseHandleName]) {
1609
+ window[this.promiseHandleName] = {
1591
1610
  promises: {},
1592
1611
  resolvePromise: () => {
1593
1612
  },
@@ -1597,11 +1616,11 @@ var NativeBridgeCore = class extends CommonBridgeCore {
1597
1616
  }
1598
1617
  };
1599
1618
  }
1600
- window.n2bridge.resolvePromise = this.createResolvePromiseHandler();
1601
- window.n2bridge.finallyResolvePromise = this.createFinallyResolvePromiseHandler();
1602
- window.n2bridge.callFromNative = this.createCallFromNativeHandler();
1619
+ const bridge = this.getPromiseHandleBridge();
1620
+ bridge.resolvePromise = this.createResolvePromiseHandler();
1621
+ bridge.finallyResolvePromise = this.createFinallyResolvePromiseHandler();
1603
1622
  if (salesFrontendUtils.isStorybookEnv() && window.parent) {
1604
- window.parent.n2bridge = window.n2bridge;
1623
+ window.parent[this.promiseHandleName] = bridge;
1605
1624
  window.parent.dispatchEvent = (...args) => window.dispatchEvent.apply(null, args);
1606
1625
  }
1607
1626
  }
@@ -1612,7 +1631,8 @@ var NativeBridgeCore = class extends CommonBridgeCore {
1612
1631
  createResolvePromiseHandler() {
1613
1632
  return (promiseId, data, error) => {
1614
1633
  console.log("[NativeBridgeCore resolvePromise]::", promiseId, data, error);
1615
- const promise = window.n2bridge.promises[promiseId];
1634
+ const bridge = this.getPromiseHandleBridge();
1635
+ const promise = bridge.promises[promiseId];
1616
1636
  if (!promise) {
1617
1637
  console.error("[NativeBridgeCore resolvePromise] Promise not found::", promiseId);
1618
1638
  return;
@@ -1623,10 +1643,6 @@ var NativeBridgeCore = class extends CommonBridgeCore {
1623
1643
  this.cleanupPromise(promiseId);
1624
1644
  return;
1625
1645
  }
1626
- if (promise.retain) {
1627
- promise.retain(data);
1628
- return;
1629
- }
1630
1646
  promise.resolve(data);
1631
1647
  this.cleanupPromise(promiseId);
1632
1648
  } catch (err) {
@@ -1641,7 +1657,8 @@ var NativeBridgeCore = class extends CommonBridgeCore {
1641
1657
  */
1642
1658
  createFinallyResolvePromiseHandler() {
1643
1659
  return (promiseId, data, error) => {
1644
- const promise = window.n2bridge.promises[promiseId];
1660
+ const bridge = this.getPromiseHandleBridge();
1661
+ const promise = bridge.promises[promiseId];
1645
1662
  if (!promise) {
1646
1663
  console.error("[NativeBridgeCore resolvePromise] Promise not found::", promiseId);
1647
1664
  return;
@@ -1652,10 +1669,6 @@ var NativeBridgeCore = class extends CommonBridgeCore {
1652
1669
  this.cleanupPromise(promiseId);
1653
1670
  return;
1654
1671
  }
1655
- if (promise.retain) {
1656
- promise.retain(data);
1657
- return;
1658
- }
1659
1672
  promise.resolve(data);
1660
1673
  this.cleanupPromise(promiseId);
1661
1674
  } catch (err) {
@@ -1664,55 +1677,40 @@ var NativeBridgeCore = class extends CommonBridgeCore {
1664
1677
  }
1665
1678
  };
1666
1679
  }
1667
- /**
1668
- * Native 에서 웹으로 호출하는 함수
1669
- * TODO: 필요시 추가 코딩
1670
- * @returns
1671
- */
1672
- createCallFromNativeHandler() {
1673
- return (jsonStr) => {
1674
- try {
1675
- const command = JSON.parse(jsonStr);
1676
- console.log("[NativeBridgeCore callFromNative]::", command);
1677
- } catch (error) {
1678
- console.error("[NativeBridgeCore callFromNative] parse error::", error);
1679
- }
1680
- };
1681
- }
1682
1680
  /**
1683
1681
  * 네이티브 통신
1684
1682
  * @param action
1685
1683
  * @param options
1686
1684
  * @returns
1687
1685
  */
1688
- async callToTarget(action, options) {
1689
- const { retainCallback: retain, ...commandOptions } = options || {};
1686
+ async callToTarget(action, option) {
1690
1687
  return new Promise((resolve, reject) => {
1691
1688
  const promiseId = `${action}_${this.generatePromiseId()}`;
1692
1689
  console.log("[NativeBridgeCore callToNative] promiseId::", promiseId);
1693
- window.n2bridge.promises[promiseId] = {
1690
+ const bridge = this.getPromiseHandleBridge();
1691
+ bridge.promises[promiseId] = {
1694
1692
  resolve: (value) => {
1695
1693
  resolve(value);
1696
1694
  },
1697
1695
  reject: (reason) => {
1698
1696
  reject(reason);
1699
- },
1700
- retain
1697
+ }
1701
1698
  };
1702
1699
  try {
1703
1700
  const command = {
1704
1701
  action,
1705
1702
  promiseId,
1706
- option: commandOptions
1703
+ option
1707
1704
  };
1708
1705
  console.log("[NativeBridgeCore callToNative] command::", command);
1709
1706
  const platform = salesFrontendUtils.getDspExecutionEnvironment();
1710
1707
  if (platform === "android-webview") {
1711
- window.n2Bridge?.callFromWeb?.(JSON.stringify(command));
1708
+ const callBridge = this.getCallBridge();
1709
+ callBridge?.callFromWeb?.(JSON.stringify(command));
1712
1710
  return;
1713
1711
  }
1714
1712
  if (platform === "ios-webview") {
1715
- window.webkit?.messageHandlers?.n2Bridge?.postMessage(JSON.stringify(command));
1713
+ window.webkit?.messageHandlers?.[this.callBridgeName]?.postMessage(JSON.stringify(command));
1716
1714
  return;
1717
1715
  }
1718
1716
  console.warn(
@@ -1732,7 +1730,8 @@ var NativeBridgeCore = class extends CommonBridgeCore {
1732
1730
  * @param promiseId
1733
1731
  */
1734
1732
  cleanupPromise(promiseId) {
1735
- delete window.n2bridge.promises[promiseId];
1733
+ const bridge = this.getPromiseHandleBridge();
1734
+ delete bridge.promises[promiseId];
1736
1735
  }
1737
1736
  };
1738
1737
 
@@ -1775,6 +1774,22 @@ var NativeBridge = class extends CommonBridge {
1775
1774
  async jumpSafari(options) {
1776
1775
  return this.core.callToTarget("jumpSafari", options);
1777
1776
  }
1777
+ /**
1778
+ * 기능명: 본인인증 결과 정보 넘기기
1779
+ * 목적: NXL One 에서 본인인증 결과 값을 네이티브로 넘기기 위함
1780
+ * @param options
1781
+ * @returns
1782
+ */
1783
+ async onAuthenticationResult(options) {
1784
+ return this.core.callToTarget("onAuthenticationResult", options);
1785
+ }
1786
+ /**
1787
+ * Access Token 가져오기
1788
+ * @returns
1789
+ */
1790
+ async getAccessToken() {
1791
+ return this.core.callToTarget("getAccessToken");
1792
+ }
1778
1793
  /**
1779
1794
  * ### Bridge for Oz
1780
1795
  * 설정한 뷰어 파라미터를 기준으로 뷰어에 새로운 보고서를 바인딩합니다.
@@ -1802,6 +1817,60 @@ var NativeBridge = class extends CommonBridge {
1802
1817
  hideOZViewer() {
1803
1818
  return this.core.callToTarget("hideOZViewer");
1804
1819
  }
1820
+ /**
1821
+ * ### Bridge for Oz
1822
+ * 오즈 파라미터에서 사용할 OZD를 다운받는 브릿지입니다
1823
+ * @example
1824
+ * ```tsx
1825
+ * const data = [
1826
+ * { name: "문서1", file: ["doc1.ozd"], complete: true },
1827
+ * { name: "문서2", file: ["doc2.ozd", "doc3.ozd"], complete: true }
1828
+ * ]
1829
+ * await Bridge.native.downloadDocument(data)
1830
+ * ```
1831
+ * returnData는 file 경로가 절대경로로 매핑되어 돌아온다
1832
+ * ```json
1833
+ * {
1834
+ * "action":"downloadDocument",
1835
+ * "data":[
1836
+ * {
1837
+ * "name":"aaa",
1838
+ * "file":[
1839
+ * "/data/user/0/com.hanwhalife.ssp.stg/files/A0010.ozd",
1840
+ * "/data/user/0/com.hanwhalife.ssp.stg/files/C0401.ozd"
1841
+ * ],
1842
+ * "complete":false
1843
+ * },
1844
+ * {
1845
+ * "name":"bbb",
1846
+ * "file":[
1847
+ * "/data/user/0/com.hanwhalife.ssp.stg/files/A1500.ozd"
1848
+ * ],
1849
+ * "complete":false
1850
+ * }
1851
+ * ]
1852
+ * }
1853
+ * ```
1854
+ */
1855
+ async downloadDocument(options) {
1856
+ return this.core.callToTarget("downloadDocument", options);
1857
+ }
1858
+ // TODO: 필요 플러그인들 추가
1859
+ };
1860
+
1861
+ // src/native/bridge-oz/native-bridge-oz.ts
1862
+ var NativeBridgeOz = class extends CommonBridge {
1863
+ constructor() {
1864
+ super();
1865
+ __publicField(this, "core");
1866
+ this.core = new NativeBridgeCore("n2OzBridge", "n2ozBridge");
1867
+ }
1868
+ /**
1869
+ * Iframe, App 공통으로 구현해야할 함수
1870
+ */
1871
+ hello() {
1872
+ console.log("[NativeBridge] hello");
1873
+ }
1805
1874
  /**
1806
1875
  * ### Bridge for Oz
1807
1876
  * 오즈 뷰어의 정보를 가져옵니다
@@ -1914,44 +1983,6 @@ var NativeBridge = class extends CommonBridge {
1914
1983
  async getOzFontParam() {
1915
1984
  return this.core.callToTarget("getOzFontParam");
1916
1985
  }
1917
- /**
1918
- * ### Bridge for Oz
1919
- * 오즈 파라미터에서 사용할 OZD를 다운받는 브릿지입니다
1920
- * @example
1921
- * ```tsx
1922
- * const data = [
1923
- * { name: "문서1", file: ["doc1.ozd"], complete: true },
1924
- * { name: "문서2", file: ["doc2.ozd", "doc3.ozd"], complete: true }
1925
- * ]
1926
- * await Bridge.native.downloadDocument(data)
1927
- * ```
1928
- * returnData는 file 경로가 절대경로로 매핑되어 돌아온다
1929
- * ```json
1930
- * {
1931
- * "action":"downloadDocument",
1932
- * "data":[
1933
- * {
1934
- * "name":"aaa",
1935
- * "file":[
1936
- * "/data/user/0/com.hanwhalife.ssp.stg/files/A0010.ozd",
1937
- * "/data/user/0/com.hanwhalife.ssp.stg/files/C0401.ozd"
1938
- * ],
1939
- * "complete":false
1940
- * },
1941
- * {
1942
- * "name":"bbb",
1943
- * "file":[
1944
- * "/data/user/0/com.hanwhalife.ssp.stg/files/A1500.ozd"
1945
- * ],
1946
- * "complete":false
1947
- * }
1948
- * ]
1949
- * }
1950
- * ```
1951
- */
1952
- async downloadDocument(options) {
1953
- return this.core.callToTarget("downloadDocument", options);
1954
- }
1955
1986
  /**
1956
1987
  * ### Bridge for Oz
1957
1988
  * 서식의 진행중/완료 상태를 업데이트하는 브릿지
@@ -2010,15 +2041,6 @@ var NativeBridge = class extends CommonBridge {
2010
2041
  async hideOzPdfViewer() {
2011
2042
  return this.core.callToTarget("hideOzPdfViewer");
2012
2043
  }
2013
- /**
2014
- * 기능명: 본인인증 결과 정보 넘기기
2015
- * 목적: NXL One 에서 본인인증 결과 값을 네이티브로 넘기기 위함
2016
- * @param options
2017
- * @returns
2018
- */
2019
- async onAuthenticationResult(options) {
2020
- return this.core.callToTarget("onAuthenticationResult", options);
2021
- }
2022
2044
  /**
2023
2045
  * 로더 컴포넌트 show
2024
2046
  * @example
@@ -2047,6 +2069,7 @@ var NativeBridge = class extends CommonBridge {
2047
2069
  // src/bridge.ts
2048
2070
  var Bridge = {
2049
2071
  native: new NativeBridge(),
2072
+ nativeOz: new NativeBridgeOz(),
2050
2073
  iframe: new IframeBridge(),
2051
2074
  nativeCore: new NativeBridgeCore(),
2052
2075
  iframeCore: new IframeBridgeCore()
@@ -2080,17 +2103,20 @@ var commonOzParam = [
2080
2103
  `eform.inputcomponent_toolbar_button_json=${JSON.stringify({
2081
2104
  // 서명패드 버튼 배열 수정
2082
2105
  "all": {
2083
- // 왼쪽에 이전, 확인 버튼
2084
- "left_align": "prev,ok",
2085
- // 오른쪽에 성명,서명 불러오기, 초가화, 다음
2086
- "right_align": "reusablesign,clear,next"
2106
+ // 왼쪽에 이전, 다시쓰기 버튼
2107
+ "left_align": "prev,clear",
2108
+ // 오른쪽에 완료 성명,서명 불러오기, 다음
2109
+ "right_align": "ok,reusablesign,next"
2087
2110
  }
2088
2111
  })}`,
2089
2112
  `eform.signpad_show_draw_erase_button=false`,
2090
2113
  `eform.signpad_viewtype=keepratioandfittoframe`,
2091
2114
  `eform.radiobutton_type=ensurevisible_at_prev_next`,
2092
2115
  `eform.checkbox_type=ensurevisible_at_prev_next`,
2093
- // `eform.prev_next_constraint_rule=empty_only`,
2116
+ `eform.prev_next_required_rule=required_only`,
2117
+ `eform.prev_next_navigation_rule=required_only`,
2118
+ `eform.prev_next_constraint_rule=empty_only`,
2119
+ `viewer.pagenavigate_by_prev_next=true`,
2094
2120
  `eform.imagepicker_id_info=${JSON.stringify({
2095
2121
  ids: [
2096
2122
  {
@@ -2187,7 +2213,7 @@ async function fetchDocument(options) {
2187
2213
  return data.map((i) => ({ ...i, startPage: 0, endPage: 0 }));
2188
2214
  }
2189
2215
  async function fetchFont() {
2190
- const { data: fontMap } = await Bridge.native.getOzFontParam();
2216
+ const { data: fontMap } = await Bridge.nativeOz.getOzFontParam();
2191
2217
  const fontParms = Object.keys(fontMap).map((i) => `font.${i}=${fontMap[i]}`);
2192
2218
  return fontParms;
2193
2219
  }