sales-frontend-bridge 0.0.21 → 0.0.23
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 +200 -101
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +259 -130
- package/dist/index.d.ts +259 -130
- package/dist/index.js +201 -103
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MessageEventManager, getDspExecutionEnvironment,
|
|
1
|
+
import { isClient, MessageEventManager, getDspExecutionEnvironment, isStorybookEnv } from 'sales-frontend-utils';
|
|
2
2
|
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -1448,6 +1448,9 @@ var IframeBridgeCore = class extends CommonBridgeCore {
|
|
|
1448
1448
|
super();
|
|
1449
1449
|
__publicField(this, "pendingPromises", /* @__PURE__ */ new Map());
|
|
1450
1450
|
__publicField(this, "responseHandler");
|
|
1451
|
+
if (!isClient()) {
|
|
1452
|
+
return;
|
|
1453
|
+
}
|
|
1451
1454
|
this.initializeIframeBridge();
|
|
1452
1455
|
}
|
|
1453
1456
|
/**
|
|
@@ -1573,19 +1576,35 @@ var IframeBridge = class extends CommonBridge {
|
|
|
1573
1576
|
// TODO: 필요 플러그인들 추가
|
|
1574
1577
|
};
|
|
1575
1578
|
var NativeBridgeCore = class extends CommonBridgeCore {
|
|
1576
|
-
constructor() {
|
|
1579
|
+
constructor(callBridgeName = "n2Bridge", promiseHandleName = "n2bridge") {
|
|
1577
1580
|
super();
|
|
1578
|
-
this
|
|
1581
|
+
__publicField(this, "promiseHandleName");
|
|
1582
|
+
__publicField(this, "callBridgeName");
|
|
1583
|
+
this.callBridgeName = callBridgeName;
|
|
1584
|
+
this.promiseHandleName = promiseHandleName;
|
|
1585
|
+
this.initializeWindowOzBridge();
|
|
1579
1586
|
}
|
|
1580
1587
|
/**
|
|
1581
|
-
*
|
|
1588
|
+
* Promise 관리용 브릿지 객체 가져오기 (window.n2bridge)
|
|
1589
|
+
*/
|
|
1590
|
+
getPromiseHandleBridge() {
|
|
1591
|
+
return window[this.promiseHandleName];
|
|
1592
|
+
}
|
|
1593
|
+
/**
|
|
1594
|
+
* 앱 호출용 브릿지 객체 가져오기 (window.n2Bridge)
|
|
1595
|
+
*/
|
|
1596
|
+
getCallBridge() {
|
|
1597
|
+
return window[this.callBridgeName];
|
|
1598
|
+
}
|
|
1599
|
+
/**
|
|
1600
|
+
* 네이티브 통신을 위해 window.n2OzBridge 객체 초기화
|
|
1582
1601
|
*/
|
|
1583
|
-
|
|
1602
|
+
initializeWindowOzBridge() {
|
|
1584
1603
|
if (!isClient()) {
|
|
1585
1604
|
return;
|
|
1586
1605
|
}
|
|
1587
|
-
if (!window.
|
|
1588
|
-
window.
|
|
1606
|
+
if (!window[this.promiseHandleName]) {
|
|
1607
|
+
window[this.promiseHandleName] = {
|
|
1589
1608
|
promises: {},
|
|
1590
1609
|
resolvePromise: () => {
|
|
1591
1610
|
},
|
|
@@ -1595,11 +1614,11 @@ var NativeBridgeCore = class extends CommonBridgeCore {
|
|
|
1595
1614
|
}
|
|
1596
1615
|
};
|
|
1597
1616
|
}
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1617
|
+
const bridge = this.getPromiseHandleBridge();
|
|
1618
|
+
bridge.resolvePromise = this.createResolvePromiseHandler();
|
|
1619
|
+
bridge.finallyResolvePromise = this.createFinallyResolvePromiseHandler();
|
|
1601
1620
|
if (isStorybookEnv() && window.parent) {
|
|
1602
|
-
window.parent.
|
|
1621
|
+
window.parent[this.promiseHandleName] = bridge;
|
|
1603
1622
|
window.parent.dispatchEvent = (...args) => window.dispatchEvent.apply(null, args);
|
|
1604
1623
|
}
|
|
1605
1624
|
}
|
|
@@ -1610,7 +1629,8 @@ var NativeBridgeCore = class extends CommonBridgeCore {
|
|
|
1610
1629
|
createResolvePromiseHandler() {
|
|
1611
1630
|
return (promiseId, data, error) => {
|
|
1612
1631
|
console.log("[NativeBridgeCore resolvePromise]::", promiseId, data, error);
|
|
1613
|
-
const
|
|
1632
|
+
const bridge = this.getPromiseHandleBridge();
|
|
1633
|
+
const promise = bridge.promises[promiseId];
|
|
1614
1634
|
if (!promise) {
|
|
1615
1635
|
console.error("[NativeBridgeCore resolvePromise] Promise not found::", promiseId);
|
|
1616
1636
|
return;
|
|
@@ -1621,10 +1641,6 @@ var NativeBridgeCore = class extends CommonBridgeCore {
|
|
|
1621
1641
|
this.cleanupPromise(promiseId);
|
|
1622
1642
|
return;
|
|
1623
1643
|
}
|
|
1624
|
-
if (promise.retain) {
|
|
1625
|
-
promise.retain(data);
|
|
1626
|
-
return;
|
|
1627
|
-
}
|
|
1628
1644
|
promise.resolve(data);
|
|
1629
1645
|
this.cleanupPromise(promiseId);
|
|
1630
1646
|
} catch (err) {
|
|
@@ -1639,7 +1655,8 @@ var NativeBridgeCore = class extends CommonBridgeCore {
|
|
|
1639
1655
|
*/
|
|
1640
1656
|
createFinallyResolvePromiseHandler() {
|
|
1641
1657
|
return (promiseId, data, error) => {
|
|
1642
|
-
const
|
|
1658
|
+
const bridge = this.getPromiseHandleBridge();
|
|
1659
|
+
const promise = bridge.promises[promiseId];
|
|
1643
1660
|
if (!promise) {
|
|
1644
1661
|
console.error("[NativeBridgeCore resolvePromise] Promise not found::", promiseId);
|
|
1645
1662
|
return;
|
|
@@ -1650,10 +1667,6 @@ var NativeBridgeCore = class extends CommonBridgeCore {
|
|
|
1650
1667
|
this.cleanupPromise(promiseId);
|
|
1651
1668
|
return;
|
|
1652
1669
|
}
|
|
1653
|
-
if (promise.retain) {
|
|
1654
|
-
promise.retain(data);
|
|
1655
|
-
return;
|
|
1656
|
-
}
|
|
1657
1670
|
promise.resolve(data);
|
|
1658
1671
|
this.cleanupPromise(promiseId);
|
|
1659
1672
|
} catch (err) {
|
|
@@ -1662,55 +1675,40 @@ var NativeBridgeCore = class extends CommonBridgeCore {
|
|
|
1662
1675
|
}
|
|
1663
1676
|
};
|
|
1664
1677
|
}
|
|
1665
|
-
/**
|
|
1666
|
-
* Native 에서 웹으로 호출하는 함수
|
|
1667
|
-
* TODO: 필요시 추가 코딩
|
|
1668
|
-
* @returns
|
|
1669
|
-
*/
|
|
1670
|
-
createCallFromNativeHandler() {
|
|
1671
|
-
return (jsonStr) => {
|
|
1672
|
-
try {
|
|
1673
|
-
const command = JSON.parse(jsonStr);
|
|
1674
|
-
console.log("[NativeBridgeCore callFromNative]::", command);
|
|
1675
|
-
} catch (error) {
|
|
1676
|
-
console.error("[NativeBridgeCore callFromNative] parse error::", error);
|
|
1677
|
-
}
|
|
1678
|
-
};
|
|
1679
|
-
}
|
|
1680
1678
|
/**
|
|
1681
1679
|
* 네이티브 통신
|
|
1682
1680
|
* @param action
|
|
1683
1681
|
* @param options
|
|
1684
1682
|
* @returns
|
|
1685
1683
|
*/
|
|
1686
|
-
async callToTarget(action,
|
|
1687
|
-
const { retainCallback: retain, ...commandOptions } = options || {};
|
|
1684
|
+
async callToTarget(action, option) {
|
|
1688
1685
|
return new Promise((resolve, reject) => {
|
|
1689
1686
|
const promiseId = `${action}_${this.generatePromiseId()}`;
|
|
1690
1687
|
console.log("[NativeBridgeCore callToNative] promiseId::", promiseId);
|
|
1691
|
-
|
|
1688
|
+
const bridge = this.getPromiseHandleBridge();
|
|
1689
|
+
bridge.promises[promiseId] = {
|
|
1692
1690
|
resolve: (value) => {
|
|
1693
1691
|
resolve(value);
|
|
1694
1692
|
},
|
|
1695
1693
|
reject: (reason) => {
|
|
1696
1694
|
reject(reason);
|
|
1697
|
-
}
|
|
1698
|
-
retain
|
|
1695
|
+
}
|
|
1699
1696
|
};
|
|
1700
1697
|
try {
|
|
1701
1698
|
const command = {
|
|
1702
1699
|
action,
|
|
1703
1700
|
promiseId,
|
|
1704
|
-
option
|
|
1701
|
+
option
|
|
1705
1702
|
};
|
|
1706
1703
|
console.log("[NativeBridgeCore callToNative] command::", command);
|
|
1707
1704
|
const platform = getDspExecutionEnvironment();
|
|
1708
1705
|
if (platform === "android-webview") {
|
|
1709
|
-
|
|
1706
|
+
const callBridge = this.getCallBridge();
|
|
1707
|
+
callBridge?.callFromWeb?.(JSON.stringify(command));
|
|
1710
1708
|
return;
|
|
1711
1709
|
}
|
|
1712
1710
|
if (platform === "ios-webview") {
|
|
1713
|
-
window.webkit?.messageHandlers?.
|
|
1711
|
+
window.webkit?.messageHandlers?.[this.callBridgeName]?.postMessage(JSON.stringify(command));
|
|
1714
1712
|
return;
|
|
1715
1713
|
}
|
|
1716
1714
|
console.warn(
|
|
@@ -1730,7 +1728,8 @@ var NativeBridgeCore = class extends CommonBridgeCore {
|
|
|
1730
1728
|
* @param promiseId
|
|
1731
1729
|
*/
|
|
1732
1730
|
cleanupPromise(promiseId) {
|
|
1733
|
-
|
|
1731
|
+
const bridge = this.getPromiseHandleBridge();
|
|
1732
|
+
delete bridge.promises[promiseId];
|
|
1734
1733
|
}
|
|
1735
1734
|
};
|
|
1736
1735
|
|
|
@@ -1773,6 +1772,22 @@ var NativeBridge = class extends CommonBridge {
|
|
|
1773
1772
|
async jumpSafari(options) {
|
|
1774
1773
|
return this.core.callToTarget("jumpSafari", options);
|
|
1775
1774
|
}
|
|
1775
|
+
/**
|
|
1776
|
+
* 기능명: 본인인증 결과 정보 넘기기
|
|
1777
|
+
* 목적: NXL One 에서 본인인증 결과 값을 네이티브로 넘기기 위함
|
|
1778
|
+
* @param options
|
|
1779
|
+
* @returns
|
|
1780
|
+
*/
|
|
1781
|
+
async onAuthenticationResult(options) {
|
|
1782
|
+
return this.core.callToTarget("onAuthenticationResult", options);
|
|
1783
|
+
}
|
|
1784
|
+
/**
|
|
1785
|
+
* Access Token 가져오기
|
|
1786
|
+
* @returns
|
|
1787
|
+
*/
|
|
1788
|
+
async getAccessToken() {
|
|
1789
|
+
return this.core.callToTarget("getAccessToken");
|
|
1790
|
+
}
|
|
1776
1791
|
/**
|
|
1777
1792
|
* ### Bridge for Oz
|
|
1778
1793
|
* 설정한 뷰어 파라미터를 기준으로 뷰어에 새로운 보고서를 바인딩합니다.
|
|
@@ -1782,9 +1797,9 @@ var NativeBridge = class extends CommonBridge {
|
|
|
1782
1797
|
* Bridge.native.createReportEx({ param: "connection.openfile=sample.ozd" });
|
|
1783
1798
|
* ```
|
|
1784
1799
|
*/
|
|
1785
|
-
|
|
1800
|
+
createOZViewer(options) {
|
|
1786
1801
|
return this.core.callToTarget(
|
|
1787
|
-
"
|
|
1802
|
+
"createOZViewer",
|
|
1788
1803
|
Object.assign({ delimiter: "\n" }, options)
|
|
1789
1804
|
);
|
|
1790
1805
|
}
|
|
@@ -1797,8 +1812,62 @@ var NativeBridge = class extends CommonBridge {
|
|
|
1797
1812
|
* Bridge.native.hideViewer();
|
|
1798
1813
|
* ```
|
|
1799
1814
|
*/
|
|
1800
|
-
|
|
1801
|
-
return this.core.callToTarget("
|
|
1815
|
+
hideOZViewer() {
|
|
1816
|
+
return this.core.callToTarget("hideOZViewer");
|
|
1817
|
+
}
|
|
1818
|
+
/**
|
|
1819
|
+
* ### Bridge for Oz
|
|
1820
|
+
* 오즈 파라미터에서 사용할 OZD를 다운받는 브릿지입니다
|
|
1821
|
+
* @example
|
|
1822
|
+
* ```tsx
|
|
1823
|
+
* const data = [
|
|
1824
|
+
* { name: "문서1", file: ["doc1.ozd"], complete: true },
|
|
1825
|
+
* { name: "문서2", file: ["doc2.ozd", "doc3.ozd"], complete: true }
|
|
1826
|
+
* ]
|
|
1827
|
+
* await Bridge.native.downloadDocument(data)
|
|
1828
|
+
* ```
|
|
1829
|
+
* returnData는 file 경로가 절대경로로 매핑되어 돌아온다
|
|
1830
|
+
* ```json
|
|
1831
|
+
* {
|
|
1832
|
+
* "action":"downloadDocument",
|
|
1833
|
+
* "data":[
|
|
1834
|
+
* {
|
|
1835
|
+
* "name":"aaa",
|
|
1836
|
+
* "file":[
|
|
1837
|
+
* "/data/user/0/com.hanwhalife.ssp.stg/files/A0010.ozd",
|
|
1838
|
+
* "/data/user/0/com.hanwhalife.ssp.stg/files/C0401.ozd"
|
|
1839
|
+
* ],
|
|
1840
|
+
* "complete":false
|
|
1841
|
+
* },
|
|
1842
|
+
* {
|
|
1843
|
+
* "name":"bbb",
|
|
1844
|
+
* "file":[
|
|
1845
|
+
* "/data/user/0/com.hanwhalife.ssp.stg/files/A1500.ozd"
|
|
1846
|
+
* ],
|
|
1847
|
+
* "complete":false
|
|
1848
|
+
* }
|
|
1849
|
+
* ]
|
|
1850
|
+
* }
|
|
1851
|
+
* ```
|
|
1852
|
+
*/
|
|
1853
|
+
async downloadDocument(options) {
|
|
1854
|
+
return this.core.callToTarget("downloadDocument", options);
|
|
1855
|
+
}
|
|
1856
|
+
// TODO: 필요 플러그인들 추가
|
|
1857
|
+
};
|
|
1858
|
+
|
|
1859
|
+
// src/native/bridge-oz/native-bridge-oz.ts
|
|
1860
|
+
var NativeBridgeOz = class extends CommonBridge {
|
|
1861
|
+
constructor() {
|
|
1862
|
+
super();
|
|
1863
|
+
__publicField(this, "core");
|
|
1864
|
+
this.core = new NativeBridgeCore("n2OzBridge", "n2OzBridge");
|
|
1865
|
+
}
|
|
1866
|
+
/**
|
|
1867
|
+
* Iframe, App 공통으로 구현해야할 함수
|
|
1868
|
+
*/
|
|
1869
|
+
hello() {
|
|
1870
|
+
console.log("[NativeBridge] hello");
|
|
1802
1871
|
}
|
|
1803
1872
|
/**
|
|
1804
1873
|
* ### Bridge for Oz
|
|
@@ -1912,44 +1981,6 @@ var NativeBridge = class extends CommonBridge {
|
|
|
1912
1981
|
async getOzFontParam() {
|
|
1913
1982
|
return this.core.callToTarget("getOzFontParam");
|
|
1914
1983
|
}
|
|
1915
|
-
/**
|
|
1916
|
-
* ### Bridge for Oz
|
|
1917
|
-
* 오즈 파라미터에서 사용할 OZD를 다운받는 브릿지입니다
|
|
1918
|
-
* @example
|
|
1919
|
-
* ```tsx
|
|
1920
|
-
* const data = [
|
|
1921
|
-
* { name: "문서1", file: ["doc1.ozd"], complete: true },
|
|
1922
|
-
* { name: "문서2", file: ["doc2.ozd", "doc3.ozd"], complete: true }
|
|
1923
|
-
* ]
|
|
1924
|
-
* await Bridge.native.downloadDocument(data)
|
|
1925
|
-
* ```
|
|
1926
|
-
* returnData는 file 경로가 절대경로로 매핑되어 돌아온다
|
|
1927
|
-
* ```json
|
|
1928
|
-
* {
|
|
1929
|
-
* "action":"downloadDocument",
|
|
1930
|
-
* "data":[
|
|
1931
|
-
* {
|
|
1932
|
-
* "name":"aaa",
|
|
1933
|
-
* "file":[
|
|
1934
|
-
* "/data/user/0/com.hanwhalife.ssp.stg/files/A0010.ozd",
|
|
1935
|
-
* "/data/user/0/com.hanwhalife.ssp.stg/files/C0401.ozd"
|
|
1936
|
-
* ],
|
|
1937
|
-
* "complete":false
|
|
1938
|
-
* },
|
|
1939
|
-
* {
|
|
1940
|
-
* "name":"bbb",
|
|
1941
|
-
* "file":[
|
|
1942
|
-
* "/data/user/0/com.hanwhalife.ssp.stg/files/A1500.ozd"
|
|
1943
|
-
* ],
|
|
1944
|
-
* "complete":false
|
|
1945
|
-
* }
|
|
1946
|
-
* ]
|
|
1947
|
-
* }
|
|
1948
|
-
* ```
|
|
1949
|
-
*/
|
|
1950
|
-
async downloadDocument(options) {
|
|
1951
|
-
return this.core.callToTarget("downloadDocument", options);
|
|
1952
|
-
}
|
|
1953
1984
|
/**
|
|
1954
1985
|
* ### Bridge for Oz
|
|
1955
1986
|
* 서식의 진행중/완료 상태를 업데이트하는 브릿지
|
|
@@ -2009,13 +2040,26 @@ var NativeBridge = class extends CommonBridge {
|
|
|
2009
2040
|
return this.core.callToTarget("hideOzPdfViewer");
|
|
2010
2041
|
}
|
|
2011
2042
|
/**
|
|
2012
|
-
*
|
|
2013
|
-
*
|
|
2014
|
-
*
|
|
2015
|
-
*
|
|
2043
|
+
* 로더 컴포넌트 show
|
|
2044
|
+
* @example
|
|
2045
|
+
* ```tsx
|
|
2046
|
+
* // 사용 예시
|
|
2047
|
+
* await Bridge.native.showLoader()
|
|
2048
|
+
* ```
|
|
2016
2049
|
*/
|
|
2017
|
-
async
|
|
2018
|
-
return this.core.callToTarget("
|
|
2050
|
+
async showLoader() {
|
|
2051
|
+
return this.core.callToTarget("showLoader");
|
|
2052
|
+
}
|
|
2053
|
+
/**
|
|
2054
|
+
* 로더 컴포넌트 hide
|
|
2055
|
+
* @example
|
|
2056
|
+
* ```tsx
|
|
2057
|
+
* // 사용 예시
|
|
2058
|
+
* await Bridge.native.hideLoader()
|
|
2059
|
+
* ```
|
|
2060
|
+
*/
|
|
2061
|
+
async hideLoader() {
|
|
2062
|
+
return this.core.callToTarget("hideLoader");
|
|
2019
2063
|
}
|
|
2020
2064
|
// TODO: 필요 플러그인들 추가
|
|
2021
2065
|
};
|
|
@@ -2023,6 +2067,7 @@ var NativeBridge = class extends CommonBridge {
|
|
|
2023
2067
|
// src/bridge.ts
|
|
2024
2068
|
var Bridge = {
|
|
2025
2069
|
native: new NativeBridge(),
|
|
2070
|
+
nativeOz: new NativeBridgeOz(),
|
|
2026
2071
|
iframe: new IframeBridge(),
|
|
2027
2072
|
nativeCore: new NativeBridgeCore(),
|
|
2028
2073
|
iframeCore: new IframeBridgeCore()
|
|
@@ -2051,10 +2096,25 @@ var commonOzParam = [
|
|
|
2051
2096
|
`eform.signpad_type=embedded`,
|
|
2052
2097
|
// `eform.signpad_type=keypad`,
|
|
2053
2098
|
`eform.show_prev_next_input=true`,
|
|
2054
|
-
`eform.signpad_prev_next_iconposition=sign_top_left`,
|
|
2099
|
+
// `eform.signpad_prev_next_iconposition=sign_top_left`,
|
|
2100
|
+
`eform.signpad_prev_next_iconposition=sign_top`,
|
|
2101
|
+
`eform.inputcomponent_toolbar_button_json=${JSON.stringify({
|
|
2102
|
+
// 서명패드 버튼 배열 수정
|
|
2103
|
+
"all": {
|
|
2104
|
+
// 왼쪽에 이전, 다시쓰기 버튼
|
|
2105
|
+
"left_align": "prev,clear",
|
|
2106
|
+
// 오른쪽에 완료 성명,서명 불러오기, 다음
|
|
2107
|
+
"right_align": "ok,reusablesign,next"
|
|
2108
|
+
}
|
|
2109
|
+
})}`,
|
|
2055
2110
|
`eform.signpad_show_draw_erase_button=false`,
|
|
2111
|
+
`eform.signpad_viewtype=keepratioandfittoframe`,
|
|
2056
2112
|
`eform.radiobutton_type=ensurevisible_at_prev_next`,
|
|
2057
2113
|
`eform.checkbox_type=ensurevisible_at_prev_next`,
|
|
2114
|
+
`eform.prev_next_required_rule=required_only`,
|
|
2115
|
+
`eform.prev_next_navigation_rule=required_only`,
|
|
2116
|
+
`eform.prev_next_constraint_rule=empty_only`,
|
|
2117
|
+
`viewer.pagenavigate_by_prev_next=true`,
|
|
2058
2118
|
`eform.imagepicker_id_info=${JSON.stringify({
|
|
2059
2119
|
ids: [
|
|
2060
2120
|
{
|
|
@@ -2151,7 +2211,7 @@ async function fetchDocument(options) {
|
|
|
2151
2211
|
return data.map((i) => ({ ...i, startPage: 0, endPage: 0 }));
|
|
2152
2212
|
}
|
|
2153
2213
|
async function fetchFont() {
|
|
2154
|
-
const { data: fontMap } = await Bridge.
|
|
2214
|
+
const { data: fontMap } = await Bridge.nativeOz.getOzFontParam();
|
|
2155
2215
|
const fontParms = Object.keys(fontMap).map((i) => `font.${i}=${fontMap[i]}`);
|
|
2156
2216
|
return fontParms;
|
|
2157
2217
|
}
|
|
@@ -2200,8 +2260,7 @@ function getFileListByGlobalIndex(index, data) {
|
|
|
2200
2260
|
}
|
|
2201
2261
|
|
|
2202
2262
|
// src/oz/use-create-report.ts
|
|
2203
|
-
function useCreateReport({
|
|
2204
|
-
const documentList = (0, import_react.useMemo)(() => documentInfo.map((i) => i.file).flat(1), [documentInfo]);
|
|
2263
|
+
function useCreateReport({ documentList, extraData = {} }) {
|
|
2205
2264
|
const CreateReport = (0, import_react.useCallback)(async () => {
|
|
2206
2265
|
if (documentList.length === 0) {
|
|
2207
2266
|
throw new Error("\uBB38\uC11C\uBAA9\uB85D\uC774 \uBE44\uC5B4\uC788\uC2B5\uB2C8\uB2E4");
|
|
@@ -2231,25 +2290,64 @@ function useCreateReport({ documentInfo, extraData = {} }) {
|
|
|
2231
2290
|
...fontParms,
|
|
2232
2291
|
...extraParams.flat(1)
|
|
2233
2292
|
];
|
|
2234
|
-
Bridge.native.
|
|
2293
|
+
Bridge.native.createOZViewer({ param: params.join("\n") });
|
|
2235
2294
|
}, [documentList, extraData]);
|
|
2295
|
+
return { CreateReport };
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2298
|
+
// src/oz/use-document-info.tsx
|
|
2299
|
+
var import_react2 = __toESM(require_react());
|
|
2300
|
+
function useDocumentInfo(initialValue) {
|
|
2301
|
+
const [documentInfo, setDocumentInfo] = (0, import_react2.useState)([...initialValue]);
|
|
2302
|
+
const documentList = (0, import_react2.useMemo)(() => documentInfo.map((i) => i.file).flat(1), [documentInfo]);
|
|
2303
|
+
const documentIndexMap = documentList.reduce((acc, cur, index) => {
|
|
2304
|
+
acc[cur] = index;
|
|
2305
|
+
return acc;
|
|
2306
|
+
}, {});
|
|
2307
|
+
const documentTemplateMap = (0, import_react2.useMemo)(() => documentInfo.reduce((map, doc) => {
|
|
2308
|
+
doc.file.forEach((file) => {
|
|
2309
|
+
map[file] = { ...doc };
|
|
2310
|
+
});
|
|
2311
|
+
return map;
|
|
2312
|
+
}, {}), [documentInfo]);
|
|
2313
|
+
const nameTemplateMap = documentInfo.reduce((acc, doc) => {
|
|
2314
|
+
acc[doc.name] = doc;
|
|
2315
|
+
return acc;
|
|
2316
|
+
}, {});
|
|
2317
|
+
const groupIndexes = (0, import_react2.useMemo)(() => documentInfo.reduce((acc, item) => {
|
|
2318
|
+
item.file.forEach((file) => {
|
|
2319
|
+
const currentIndex = documentIndexMap[file];
|
|
2320
|
+
if (!acc[currentIndex]) {
|
|
2321
|
+
acc[currentIndex] = [];
|
|
2322
|
+
}
|
|
2323
|
+
item.file.forEach((groupFile) => {
|
|
2324
|
+
acc[currentIndex].push(documentIndexMap[groupFile]);
|
|
2325
|
+
});
|
|
2326
|
+
});
|
|
2327
|
+
return acc;
|
|
2328
|
+
}, []), [documentIndexMap, documentInfo]);
|
|
2236
2329
|
return {
|
|
2330
|
+
setDocumentInfo,
|
|
2331
|
+
documentInfo,
|
|
2237
2332
|
documentList,
|
|
2238
|
-
|
|
2333
|
+
documentTemplateMap,
|
|
2334
|
+
documentIndexMap,
|
|
2335
|
+
nameTemplateMap,
|
|
2336
|
+
groupIndexes
|
|
2239
2337
|
};
|
|
2240
2338
|
}
|
|
2241
2339
|
|
|
2242
2340
|
// src/oz/use-oz-event-listener.tsx
|
|
2243
|
-
var
|
|
2341
|
+
var import_react3 = __toESM(require_react());
|
|
2244
2342
|
function useOzEventListener({ event, handler }) {
|
|
2245
|
-
const handleEvent = (0,
|
|
2343
|
+
const handleEvent = (0, import_react3.useCallback)(
|
|
2246
2344
|
async (e) => {
|
|
2247
2345
|
const customEvent = e;
|
|
2248
2346
|
return await handler(customEvent);
|
|
2249
2347
|
},
|
|
2250
2348
|
[handler]
|
|
2251
2349
|
);
|
|
2252
|
-
(0,
|
|
2350
|
+
(0, import_react3.useEffect)(() => {
|
|
2253
2351
|
window.addEventListener(event, handleEvent);
|
|
2254
2352
|
return () => {
|
|
2255
2353
|
window.removeEventListener(event, handleEvent);
|
|
@@ -2281,6 +2379,6 @@ react/cjs/react.development.js:
|
|
|
2281
2379
|
*)
|
|
2282
2380
|
*/
|
|
2283
2381
|
|
|
2284
|
-
export { Bridge, OZViewerEvent, btnStyle, categorizeByPageRange, commonOzParam, commonPdfExportParam, extractFileName, fetchDocument, fetchFont, getFileListByGlobalIndex, useCreateReport, useOzEventListener, wrapperStyle };
|
|
2382
|
+
export { Bridge, OZViewerEvent, btnStyle, categorizeByPageRange, commonOzParam, commonPdfExportParam, extractFileName, fetchDocument, fetchFont, getFileListByGlobalIndex, useCreateReport, useDocumentInfo, useOzEventListener, wrapperStyle };
|
|
2285
2383
|
//# sourceMappingURL=index.js.map
|
|
2286
2384
|
//# sourceMappingURL=index.js.map
|