sales-frontend-bridge 0.0.32 → 0.0.33

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
@@ -2105,7 +2105,17 @@ var Bridge = {
2105
2105
  iframeCore: new IframeBridgeCore()
2106
2106
  };
2107
2107
 
2108
- // src/oz/constant/index.ts
2108
+ // src/oz/constant/comment-pen-param.ts
2109
+ var commentPenDefaultParam = [
2110
+ `comment.selectedpen=highlightpen`,
2111
+ `comment.highlightpen_thick=15`
2112
+ ];
2113
+ var commentPenYellow = [...commentPenDefaultParam, `comment.highlightpen_color=ffd900`];
2114
+ var commentPenPink = [...commentPenDefaultParam, `comment.highlightpen_color=f48fb1`];
2115
+ var commentPenGreen = [...commentPenDefaultParam, `comment.highlightpen_color=81c784`];
2116
+ var commentPenEraser = [`comment.selectedpen=eraser`];
2117
+
2118
+ // src/oz/constant/oz-param.ts
2109
2119
  var commonOzParam = [
2110
2120
  `information.debug = true`,
2111
2121
  `global.inheritparameter=true`,
@@ -2206,6 +2216,8 @@ var commonOzParam = [
2206
2216
  `viewer.reportchangecommand=true`,
2207
2217
  `viewer.pagebindcommandinterval=500`
2208
2218
  ];
2219
+
2220
+ // src/oz/constant/pdf-param.ts
2209
2221
  var commonPdfExportParam = [
2210
2222
  // `pdf.filename=${"test.pdf"}`,
2211
2223
  // `export.pages=${i.startPage}-${i.endPage}`,
@@ -2218,19 +2230,100 @@ var commonPdfExportParam = [
2218
2230
  // 폰트를 포함시킬때 사용하는 글자만 포함시킨다
2219
2231
  `pdf.fontembedding_subset=true`
2220
2232
  ];
2221
- var commentPenDefaultParam = [
2222
- `comment.selectedpen=highlightpen`,
2223
- `comment.highlightpen_thick=15`
2224
- ];
2225
- var commentPenYellow = [...commentPenDefaultParam, `comment.highlightpen_color=ffd900`];
2226
- var commentPenPink = [...commentPenDefaultParam, `comment.highlightpen_color=f48fb1`];
2227
- var commentPenGreen = [...commentPenDefaultParam, `comment.highlightpen_color=81c784`];
2228
- var commentPenEraser = [`comment.selectedpen=eraser`];
2233
+
2234
+ // src/oz/constant/test-data.ts
2229
2235
  var wrapperStyle = { display: "flex", flexFlow: "column", gap: "10px" };
2230
2236
  var btnStyle = { border: "1px solid red", minHeight: "40px" };
2237
+ var DownloadDocumentList = [
2238
+ { name: "[A0010]\uCCAD\uC57D\uC11C", file: ["A0010.ozd"], complete: false, startPage: 0, endPage: 0, focus: false },
2239
+ { name: "[A0100]\uBE44\uAD50\uC548\uB0B4\uD655\uC778\uC11C", file: ["A0100.ozd"], complete: false, startPage: 0, endPage: 0, focus: false },
2240
+ { name: "[A1500]\uCCAD\uC57D\uBD80\uC18D\uC815\uBCF4\uD655\uC778\uC11C", file: ["A1500.ozd"], complete: false, startPage: 0, endPage: 0, focus: false },
2241
+ { name: "[A2215]\uBCF4\uD5D8\uACC4\uC57D\uB300\uCD9C\uC774\uD589\uAD00\uB9AC\uB3D9\uC758\uC11C", file: ["A2215.ozd"], complete: false, startPage: 0, endPage: 0, focus: false },
2242
+ { name: "[A2800]\uACC4\uC57D\uC804\uC54C\uB9B4\uC758\uBB34", file: ["A2800.ozd"], complete: false, startPage: 0, endPage: 0, focus: false },
2243
+ { name: "[A3503]\uCCAD\uC57D\uC11C\uBCC4\uC9C0(\uBCC0\uC561\uC6A9)", file: ["A3503.ozd"], complete: false, startPage: 0, endPage: 0, focus: false },
2244
+ { name: "[B0101]\uBCF4\uD5D8\uACC4\uC57D\uCCB4\uACB0\uB3D9\uC758\uC11C", file: ["B0101.ozd"], complete: false, startPage: 0, endPage: 0, focus: false },
2245
+ { name: "[C0400]\uACC4\uC57D\uCCB4\uACB0\uC774\uD589\uB3D9\uC758\uC11C", file: ["C0400.ozd"], complete: false, startPage: 0, endPage: 0, focus: false },
2246
+ { name: "[C0401]\uC0C1\uD488\uC18C\uAC1C\uC0C1\uC138\uB3D9\uC758\uC11C", file: ["C0401.ozd"], complete: false, startPage: 0, endPage: 0, focus: false },
2247
+ { name: "[C1000]\uBCF4\uD5D8\uC0C1\uD488\uD310\uB9E4\uCCB4\uD06C\uB9AC\uC2A4\uD2B8", file: ["C1000.ozd"], complete: false, startPage: 0, endPage: 0, focus: false },
2248
+ { name: "[C1300]\uACC4\uC57D\uCCB4\uACB0\uACE0\uC9C0\uC758\uBB34\uD655\uC778\uC11C", file: ["C1300.ozd"], complete: false, startPage: 0, endPage: 0, focus: false },
2249
+ { name: "[C1400]\uBCF4\uD5D8\uC0C1\uD488\uBE44\uAD50\uC124\uBA85\uD655\uC778\uC11C", file: ["C1400.ozd"], complete: false, startPage: 0, endPage: 0, focus: false }
2250
+ ];
2251
+ var ExtraData = {
2252
+ // 문서코드
2253
+ A0010: {
2254
+ // connection.inputjson으로 바인딩할 데이터
2255
+ inputJson: {
2256
+ // 계약자 성명 사인정보
2257
+ A0010_mynm_sg: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAABDUlEQVR4nOzSMQ0CQBQEUSAnAAU0iEAAPWKQgQU04gED10z1IXlPwWay6/78HH7P+3qZnrBxmh7wT8QKxArECsQKxArECsQKxArECsQKxArECsQKxArECsQKxArECsQKxArECsQKxArECsQKxArECsQKxArECsQKxArECsQKxArECsQKxArECsQKxArECsQKxArECsQKxArECtZjvaY3bNzOx+kJG54ViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgVfAMAAP//tD4Eb/yjIncAAAAASUVORK5CYII=",
2258
+ // 계약자 서명 사인정보
2259
+ A0010_mysg_sign: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAABDElEQVR4nOzSsQkCYRgEUZXDVgTtxdDIYgR7sFkTG/iTiT4P3qtgGXa7vp+H//M5PqYnLJymB+yJWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgVjBdj9fpjcsvG7f6QkLnhWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBX8AgAA//9+7gTkg4AcBQAAAABJRU5ErkJggg=="
2260
+ },
2261
+ // 기타 공통으로 사용하지 않을 파라미터
2262
+ extraParam: [`viewer.zoom=137`]
2263
+ }
2264
+ };
2231
2265
 
2232
- // src/oz/hooks/use-create-report.ts
2266
+ // src/oz/hooks/use-document-info.tsx
2233
2267
  var import_react = __toESM(require_react());
2268
+ function useDocumentInfo(initialValue) {
2269
+ const [documentInfo, setDocumentInfo] = (0, import_react.useState)([...initialValue]);
2270
+ const documentList = (0, import_react.useMemo)(() => documentInfo.map((i) => i.file).flat(1), [documentInfo]);
2271
+ const documentIndexMap = documentList.reduce((acc, cur, index) => {
2272
+ acc[cur] = index;
2273
+ return acc;
2274
+ }, {});
2275
+ const documentTemplateMap = (0, import_react.useMemo)(() => documentInfo.reduce((map, doc) => {
2276
+ doc.file.forEach((file) => {
2277
+ map[file] = { ...doc };
2278
+ });
2279
+ return map;
2280
+ }, {}), [documentInfo]);
2281
+ const nameTemplateMap = documentInfo.reduce((acc, doc) => {
2282
+ acc[doc.name] = doc;
2283
+ return acc;
2284
+ }, {});
2285
+ const groupIndexes = (0, import_react.useMemo)(() => documentInfo.reduce((acc, item) => {
2286
+ item.file.forEach((file) => {
2287
+ const currentIndex = documentIndexMap[file];
2288
+ if (!acc[currentIndex]) {
2289
+ acc[currentIndex] = [];
2290
+ }
2291
+ item.file.forEach((groupFile) => {
2292
+ acc[currentIndex].push(documentIndexMap[groupFile]);
2293
+ });
2294
+ });
2295
+ return acc;
2296
+ }, []), [documentIndexMap, documentInfo]);
2297
+ const isAllComplete = (0, import_react.useMemo)(() => documentInfo.every((i) => i.complete), [documentInfo]);
2298
+ return {
2299
+ setDocumentInfo,
2300
+ documentInfo,
2301
+ documentList,
2302
+ documentTemplateMap,
2303
+ documentIndexMap,
2304
+ nameTemplateMap,
2305
+ groupIndexes,
2306
+ isAllComplete
2307
+ };
2308
+ }
2309
+
2310
+ // src/oz/hooks/use-oz-event-listener.tsx
2311
+ var import_react2 = __toESM(require_react());
2312
+ function useOzEventListener({ event, handler }) {
2313
+ const handleEvent = (0, import_react2.useCallback)(
2314
+ async (e) => {
2315
+ const customEvent = e;
2316
+ return await handler(customEvent);
2317
+ },
2318
+ [handler]
2319
+ );
2320
+ (0, import_react2.useEffect)(() => {
2321
+ window.addEventListener(event, handleEvent);
2322
+ return () => {
2323
+ window.removeEventListener(event, handleEvent);
2324
+ };
2325
+ }, [handleEvent, event]);
2326
+ }
2234
2327
 
2235
2328
  // src/oz/types/oz-event.types.ts
2236
2329
  var OZViewerEvent = /* @__PURE__ */ ((OZViewerEvent2) => {
@@ -2305,6 +2398,49 @@ function PromiseWithResolvers() {
2305
2398
  }
2306
2399
 
2307
2400
  // src/oz/utils/bridge-util.ts
2401
+ async function CreateOzParam(documentList, extraData = {}) {
2402
+ if (documentList.length === 0) {
2403
+ throw new Error("\uBB38\uC11C\uBAA9\uB85D\uC774 \uBE44\uC5B4\uC788\uC2B5\uB2C8\uB2E4");
2404
+ }
2405
+ const fontParms = await fetchFont();
2406
+ const connectionParams = documentList.map(
2407
+ (file, idx) => idx === 0 ? `connection.openfile=${file}` : `child${idx}.connection.openfile=${file}`
2408
+ );
2409
+ const childCount = documentList.length - 1;
2410
+ const extraParams = documentList.map((file, idx) => {
2411
+ const result = [];
2412
+ const docCode = file.replace(/^.*[\\/]|(\.[^/.]+)$/g, "");
2413
+ const prefix = idx === 0 ? "" : `child${idx}.`;
2414
+ const data = extraData[docCode] || {};
2415
+ if (data.inputJson) {
2416
+ result.push(`${prefix}connection.inputjson=${JSON.stringify(data.inputJson)}`);
2417
+ }
2418
+ if (data.extraParam) {
2419
+ result.push(data.extraParam.map((param) => `${prefix}${param}`).join("\n"));
2420
+ }
2421
+ return result;
2422
+ });
2423
+ const params = [
2424
+ ...childCount > 0 ? [`viewer.childcount=${childCount}`] : [],
2425
+ ...connectionParams,
2426
+ ...commonOzParam,
2427
+ ...fontParms,
2428
+ ...extraParams.flat(1)
2429
+ ];
2430
+ return params;
2431
+ }
2432
+ async function CreateOzViewer(ozParam) {
2433
+ const { promise, resolve } = PromiseWithResolvers();
2434
+ window.addEventListener(
2435
+ "OZReportCreated" /* OZReportCreated */,
2436
+ // OZReportCreated가 트리거되면 promise resolve 처리
2437
+ (e) => resolve(e),
2438
+ // 이벤트 리스너는 한 번만 실행되도록 설정
2439
+ { once: true }
2440
+ );
2441
+ await Bridge.native.createOZViewer({ param: ozParam.join("\n") });
2442
+ return await promise;
2443
+ }
2308
2444
  async function fetchDocument(options) {
2309
2445
  const { data } = await Bridge.native.downloadDocument({ data: options });
2310
2446
  return data.map((i) => ({ ...i, startPage: 0, endPage: 0 }));
@@ -2527,104 +2663,39 @@ async function SaveTotalPdf() {
2527
2663
  const filepath = await promise;
2528
2664
  return filepath;
2529
2665
  }
2530
-
2531
- // src/oz/hooks/use-create-report.ts
2532
- function useCreateReport({ documentList, extraData = {} }) {
2533
- const CreateReport = (0, import_react.useCallback)(async () => {
2534
- if (documentList.length === 0) {
2535
- throw new Error("\uBB38\uC11C\uBAA9\uB85D\uC774 \uBE44\uC5B4\uC788\uC2B5\uB2C8\uB2E4");
2666
+ var checkValidPageMemo = (() => {
2667
+ const cache = /* @__PURE__ */ new Map();
2668
+ async function checkValidPage(page) {
2669
+ const cached = cache.get(page);
2670
+ if (cached) {
2671
+ return cached;
2536
2672
  }
2537
- const fontParms = await fetchFont();
2538
- const connectionParams = documentList.map(
2539
- (file, idx) => idx === 0 ? `connection.openfile=${file}` : `child${idx}.connection.openfile=${file}`
2540
- );
2541
- const childCount = documentList.length - 1;
2542
- const extraParams = documentList.map((file, idx) => {
2543
- const result = [];
2544
- const docCode = file.replace(/^.*[\\/]|(\.[^/.]+)$/g, "");
2545
- const prefix = idx === 0 ? "" : `child${idx}.`;
2546
- const data = extraData[docCode] || {};
2547
- if (data.inputJson) {
2548
- result.push(`${prefix}connection.inputjson=${JSON.stringify(data.inputJson)}`);
2549
- }
2550
- if (data.extraParam) {
2551
- result.push(data.extraParam.map((param) => `${prefix}${param}`).join("\n"));
2552
- }
2553
- return result;
2554
- });
2555
- const params = [
2556
- ...childCount > 0 ? [`viewer.childcount=${childCount}`] : [],
2557
- ...connectionParams,
2558
- ...commonOzParam,
2559
- ...fontParms,
2560
- ...extraParams.flat(1)
2561
- ];
2562
- Bridge.native.createOZViewer({ param: params.join("\n") });
2563
- }, [documentList, extraData]);
2564
- return { CreateReport };
2565
- }
2566
-
2567
- // src/oz/hooks/use-document-info.tsx
2568
- var import_react2 = __toESM(require_react());
2569
- function useDocumentInfo(initialValue) {
2570
- const [documentInfo, setDocumentInfo] = (0, import_react2.useState)([...initialValue]);
2571
- const documentList = (0, import_react2.useMemo)(() => documentInfo.map((i) => i.file).flat(1), [documentInfo]);
2572
- const documentIndexMap = documentList.reduce((acc, cur, index) => {
2573
- acc[cur] = index;
2574
- return acc;
2575
- }, {});
2576
- const documentTemplateMap = (0, import_react2.useMemo)(() => documentInfo.reduce((map, doc) => {
2577
- doc.file.forEach((file) => {
2578
- map[file] = { ...doc };
2579
- });
2580
- return map;
2581
- }, {}), [documentInfo]);
2582
- const nameTemplateMap = documentInfo.reduce((acc, doc) => {
2583
- acc[doc.name] = doc;
2584
- return acc;
2585
- }, {});
2586
- const groupIndexes = (0, import_react2.useMemo)(() => documentInfo.reduce((acc, item) => {
2587
- item.file.forEach((file) => {
2588
- const currentIndex = documentIndexMap[file];
2589
- if (!acc[currentIndex]) {
2590
- acc[currentIndex] = [];
2673
+ const VALID = "valid";
2674
+ const command = `INPUT_CHECK_VALIDITY_PAGE_AT=${page}`;
2675
+ const promise = (async () => {
2676
+ try {
2677
+ const { data } = await Bridge.nativeOz.getInformation({ command });
2678
+ const isValid = data === VALID;
2679
+ if (!isValid) {
2680
+ cache.delete(page);
2681
+ }
2682
+ return isValid;
2683
+ } catch (err) {
2684
+ cache.delete(page);
2685
+ throw err;
2591
2686
  }
2592
- item.file.forEach((groupFile) => {
2593
- acc[currentIndex].push(documentIndexMap[groupFile]);
2594
- });
2595
- });
2596
- return acc;
2597
- }, []), [documentIndexMap, documentInfo]);
2598
- const isAllComplete = (0, import_react2.useMemo)(() => documentInfo.every((i) => i.complete), [documentInfo]);
2599
- return {
2600
- setDocumentInfo,
2601
- documentInfo,
2602
- documentList,
2603
- documentTemplateMap,
2604
- documentIndexMap,
2605
- nameTemplateMap,
2606
- groupIndexes,
2607
- isAllComplete
2687
+ })();
2688
+ cache.set(page, promise);
2689
+ return promise;
2690
+ }
2691
+ checkValidPage.clearCache = () => {
2692
+ cache.clear();
2608
2693
  };
2609
- }
2610
-
2611
- // src/oz/hooks/use-oz-event-listener.tsx
2612
- var import_react3 = __toESM(require_react());
2613
- function useOzEventListener({ event, handler }) {
2614
- const handleEvent = (0, import_react3.useCallback)(
2615
- async (e) => {
2616
- const customEvent = e;
2617
- return await handler(customEvent);
2618
- },
2619
- [handler]
2620
- );
2621
- (0, import_react3.useEffect)(() => {
2622
- window.addEventListener(event, handleEvent);
2623
- return () => {
2624
- window.removeEventListener(event, handleEvent);
2625
- };
2626
- }, [handleEvent, event]);
2627
- }
2694
+ checkValidPage.clearCacheByPage = (page) => {
2695
+ cache.delete(page);
2696
+ };
2697
+ return checkValidPage;
2698
+ })();
2628
2699
  /*! Bundled license information:
2629
2700
 
2630
2701
  react/cjs/react.production.js:
@@ -2653,6 +2724,10 @@ react/cjs/react.development.js:
2653
2724
  exports.Bridge = Bridge;
2654
2725
  exports.CategoryHandler = CategoryHandler;
2655
2726
  exports.CommentHandler = CommentHandler;
2727
+ exports.CreateOzParam = CreateOzParam;
2728
+ exports.CreateOzViewer = CreateOzViewer;
2729
+ exports.DownloadDocumentList = DownloadDocumentList;
2730
+ exports.ExtraData = ExtraData;
2656
2731
  exports.MovePage = MovePage;
2657
2732
  exports.OZViewerEvent = OZViewerEvent;
2658
2733
  exports.PdfHandler = PdfHandler;
@@ -2663,6 +2738,7 @@ exports.TopHandler = TopHandler;
2663
2738
  exports.btnStyle = btnStyle;
2664
2739
  exports.categorizeByPageRange = categorizeByPageRange;
2665
2740
  exports.checkDocumentsValidityByIndex = checkDocumentsValidityByIndex;
2741
+ exports.checkValidPageMemo = checkValidPageMemo;
2666
2742
  exports.commentPenEraser = commentPenEraser;
2667
2743
  exports.commentPenGreen = commentPenGreen;
2668
2744
  exports.commentPenPink = commentPenPink;
@@ -2685,7 +2761,6 @@ exports.setEnableCommentMode = setEnableCommentMode;
2685
2761
  exports.sleep = sleep;
2686
2762
  exports.triggerClickOnAllDocuments = triggerClickOnAllDocuments;
2687
2763
  exports.triggerCropImageOnAllDocuments = triggerCropImageOnAllDocuments;
2688
- exports.useCreateReport = useCreateReport;
2689
2764
  exports.useDocumentInfo = useDocumentInfo;
2690
2765
  exports.useOzEventListener = useOzEventListener;
2691
2766
  exports.validateAllPages = validateAllPages;