sales-frontend-bridge 0.0.35 → 0.0.36

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
@@ -2315,7 +2315,11 @@ var ExtraData = {
2315
2315
  A0010_mysg_sign: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAABDElEQVR4nOzSsQkCYRgEUZXDVgTtxdDIYgR7sFkTG/iTiT4P3qtgGXa7vp+H//M5PqYnLJymB+yJWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgVjBdj9fpjcsvG7f6QkLnhWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBWIFYgViBX8AgAA//9+7gTkg4AcBQAAAABJRU5ErkJggg=="
2316
2316
  },
2317
2317
  // 기타 공통으로 사용하지 않을 파라미터
2318
- extraParam: [`viewer.zoom=137`]
2318
+ extraParam: [`viewer.zoom=137`],
2319
+ args: [`roleCd=11,21`, `ccc=ddd`]
2320
+ },
2321
+ A0900: {
2322
+ args: [`roleCd=11,21`, `aaa=bbb`]
2319
2323
  }
2320
2324
  };
2321
2325
 
@@ -2453,27 +2457,6 @@ function PromiseWithResolvers() {
2453
2457
  return { promise, resolve, reject };
2454
2458
  }
2455
2459
 
2456
- // src/oz/utils/bridge-util/focus-util.ts
2457
- async function setFocusOnValidation(enable, reportCount) {
2458
- const count = reportCount ?? await getReportCount();
2459
- const expectedValue = enable ? "1" : "0";
2460
- const { data: prev } = await Bridge.nativeOz.getGlobal({ key: "chkFlag", docIndex: 0 });
2461
- if (prev === expectedValue) {
2462
- return;
2463
- }
2464
- for (let i = 0; i < count; i++) {
2465
- await sleep();
2466
- await Bridge.nativeOz.setGlobal({ key: "chkFlag", value: expectedValue, docIndex: i });
2467
- }
2468
- return;
2469
- }
2470
- async function enableFocusOnValidation(reportCount) {
2471
- return setFocusOnValidation(true, reportCount);
2472
- }
2473
- async function disableFocusOnValidation(reportCount) {
2474
- return setFocusOnValidation(false, reportCount);
2475
- }
2476
-
2477
2460
  // src/oz/utils/bridge-util/oz-wrapper-util.ts
2478
2461
  async function CreateOzViewer(ozParam) {
2479
2462
  const { promise, resolve } = PromiseWithResolvers();
@@ -2487,21 +2470,170 @@ async function CreateOzViewer(ozParam) {
2487
2470
  await Bridge.native.createOZViewer({ param: ozParam.join("\n") });
2488
2471
  return await promise;
2489
2472
  }
2490
- async function getReportCount() {
2491
- const { data } = await Bridge.nativeOz.getInformation({ command: "REPORT_COUNT" });
2492
- return Number(data);
2493
- }
2494
2473
  async function MovePage(page) {
2495
2474
  return await Bridge.nativeOz.script({ command: `movepage=${page}` });
2496
2475
  }
2497
- async function getTotalPage() {
2498
- const { data } = await Bridge.nativeOz.getInformation({ command: "TOTAL_PAGE" });
2499
- return Number(data);
2500
- }
2501
2476
  async function getCurrentPage() {
2502
2477
  const { data } = await Bridge.nativeOz.getInformation({ command: `CURRENT_PAGE` });
2503
2478
  return Number(data);
2504
2479
  }
2480
+ var getTotalPageMemo = (() => {
2481
+ let cache = null;
2482
+ async function getTotalPage() {
2483
+ if (cache) {
2484
+ return cache;
2485
+ }
2486
+ cache = (async () => {
2487
+ try {
2488
+ const { data } = await Bridge.nativeOz.getInformation({ command: "TOTAL_PAGE" });
2489
+ return Number(data);
2490
+ } catch (e) {
2491
+ cache = null;
2492
+ throw e;
2493
+ }
2494
+ })();
2495
+ return await cache;
2496
+ }
2497
+ getTotalPage.clearCache = () => {
2498
+ cache = null;
2499
+ };
2500
+ return getTotalPage;
2501
+ })();
2502
+ var getReportCountMemo = (() => {
2503
+ let cache = null;
2504
+ async function getReportCount() {
2505
+ if (cache) {
2506
+ return await cache;
2507
+ }
2508
+ cache = (async () => {
2509
+ try {
2510
+ const { data } = await Bridge.nativeOz.getInformation({ command: "REPORT_COUNT" });
2511
+ return Number(data);
2512
+ } catch (e) {
2513
+ cache = null;
2514
+ throw e;
2515
+ }
2516
+ })();
2517
+ return await cache;
2518
+ }
2519
+ getReportCount.clearCache = () => {
2520
+ cache = null;
2521
+ };
2522
+ return getReportCount;
2523
+ })();
2524
+
2525
+ // src/oz/utils/bridge-util/btn-touch-event-util/category-handler.ts
2526
+ async function CategoryHandler(documentInfo, { type, btnID }) {
2527
+ if (type !== "category") {
2528
+ throw `Unexpected Type ${type}`;
2529
+ }
2530
+ const target = documentInfo.find((i) => i.name === btnID);
2531
+ if (!target) {
2532
+ throw `Unexpected btnID ${target}`;
2533
+ }
2534
+ await MovePage(target.startPage);
2535
+ }
2536
+
2537
+ // src/oz/utils/bridge-util/btn-touch-event-util/top-handler.ts
2538
+ async function TopHandler({ type, btnID }) {
2539
+ if (type !== "top") {
2540
+ throw `Unexpected Type ${type}`;
2541
+ }
2542
+ if (btnID === "btnExit") {
2543
+ await Bridge.native.hideOZViewer();
2544
+ } else {
2545
+ throw `Unexpected btnID ${btnID}`;
2546
+ }
2547
+ }
2548
+
2549
+ // src/oz/utils/bridge-util/btn-touch-event-util/comment-handler.ts
2550
+ async function CommentHandler({ type, btnID }) {
2551
+ if (type !== "comment") {
2552
+ throw `Unexpected Type ${type}`;
2553
+ }
2554
+ if (btnID === "yellow") {
2555
+ await setEnableCommentMode("yellow");
2556
+ } else if (btnID === "pink") {
2557
+ await setEnableCommentMode("pink");
2558
+ } else if (btnID === "green") {
2559
+ await setEnableCommentMode("green");
2560
+ } else if (btnID === "eraser") {
2561
+ await setEnableCommentMode("eraser");
2562
+ } else if (btnID === "disable") {
2563
+ await setDisableCommentMode();
2564
+ } else {
2565
+ throw `Unexpected btnID ${btnID}`;
2566
+ }
2567
+ }
2568
+ async function isCommentMode() {
2569
+ const { data } = await Bridge.nativeOz.getInformation({
2570
+ command: `COMMENT_MODE`
2571
+ });
2572
+ return data === "comment";
2573
+ }
2574
+ async function setCommentMode(penConfig) {
2575
+ const command = `mode_comment_all`;
2576
+ const commentEnabled = await isCommentMode();
2577
+ const param = [
2578
+ ...commentEnabled ? [] : [`viewer.screentool=comment`],
2579
+ ...penConfig
2580
+ ].join("\n");
2581
+ await sleep();
2582
+ return await Bridge.nativeOz.scriptEx({ command, param });
2583
+ }
2584
+ async function setEnableCommentMode(type = "yellow") {
2585
+ let param;
2586
+ if (type === "yellow") {
2587
+ param = commentPenYellow;
2588
+ } else if (type === "pink") {
2589
+ param = commentPenPink;
2590
+ } else if (type === "green") {
2591
+ param = commentPenGreen;
2592
+ } else {
2593
+ param = commentPenEraser;
2594
+ }
2595
+ return await setCommentMode(param);
2596
+ }
2597
+ async function setDisableCommentMode() {
2598
+ const command = `mode_input_all`;
2599
+ return await Bridge.nativeOz.script({ command });
2600
+ }
2601
+
2602
+ // src/oz/utils/bridge-util/btn-touch-event-util/pdf-handler.ts
2603
+ async function PdfHandler({ type, btnID }) {
2604
+ if (type !== "pdf") {
2605
+ throw `Unexpected Type ${type}`;
2606
+ }
2607
+ if (btnID === "modify") {
2608
+ await Bridge.nativeOz.hideOzPdfViewer();
2609
+ } else if (btnID === "submit") {
2610
+ await Bridge.nativeOz.hideOzPdfViewer();
2611
+ await Bridge.native.hideOZViewer();
2612
+ } else {
2613
+ throw `Unexpected btnID ${btnID}`;
2614
+ }
2615
+ }
2616
+
2617
+ // src/oz/utils/bridge-util/focus-util.ts
2618
+ async function setFocusOnValidation(enable, reportCount) {
2619
+ const count = reportCount ?? await getReportCountMemo();
2620
+ const expectedValue = enable ? "1" : "0";
2621
+ const { data: prev } = await Bridge.nativeOz.getGlobal({ key: "chkFlag", docIndex: 0 });
2622
+ if (prev === expectedValue) {
2623
+ return;
2624
+ }
2625
+ for (let i = 0; i < count; i++) {
2626
+ await sleep();
2627
+ await Bridge.nativeOz.setGlobal({ key: "chkFlag", value: expectedValue, docIndex: i });
2628
+ }
2629
+ return;
2630
+ }
2631
+ async function enableFocusOnValidation(reportCount) {
2632
+ return setFocusOnValidation(true, reportCount);
2633
+ }
2634
+ async function disableFocusOnValidation(reportCount) {
2635
+ return setFocusOnValidation(false, reportCount);
2636
+ }
2505
2637
 
2506
2638
  // src/oz/utils/bridge-util/validation-util.ts
2507
2639
  async function checkDocumentsValidityByIndex(indexList) {
@@ -2517,7 +2649,7 @@ async function checkDocumentsValidityByIndex(indexList) {
2517
2649
  return true;
2518
2650
  }
2519
2651
  async function validateAllPages(pageCount) {
2520
- const count = pageCount ?? await getTotalPage();
2652
+ const count = pageCount ?? await getTotalPageMemo();
2521
2653
  for (let i = 1; i <= count; i++) {
2522
2654
  await sleep();
2523
2655
  const isValid = await checkValidPageMemo(i);
@@ -2561,65 +2693,48 @@ var checkValidPageMemo = (() => {
2561
2693
  return checkValidPage;
2562
2694
  })();
2563
2695
 
2564
- // src/oz/utils/bridge-util/btn-touch-event-util.ts
2565
- async function CategoryHandler(documentInfo, { type, btnID }) {
2566
- if (type !== "category") {
2567
- throw `Unexpected Type ${type}`;
2568
- }
2569
- const target = documentInfo.find((i) => i.name === btnID);
2570
- if (!target) {
2571
- return;
2572
- }
2573
- await MovePage(target.startPage);
2574
- }
2696
+ // src/oz/utils/bridge-util/btn-touch-event-util/signature-handler.ts
2575
2697
  async function SignatureHandler({ type, btnID }) {
2576
2698
  if (type !== "signature") {
2577
2699
  throw `Unexpected Type ${type}`;
2578
2700
  }
2579
- const reportCount = await getReportCount();
2580
- const pageCount = await getTotalPage();
2581
2701
  if (btnID === "signatureInProgress") {
2582
- await enableFocusOnValidation(reportCount);
2583
- await validateAllPages(pageCount);
2702
+ await SignatureInProgressHandler();
2703
+ } else if (btnID === "signatureComplete") {
2704
+ await SignatureCompleteHandler();
2584
2705
  } else {
2585
- try {
2586
- await Bridge.native.showLoader();
2587
- await disableFocusOnValidation(reportCount);
2588
- checkValidPageMemo.clearCache();
2589
- const isAllValid = await validateAllPages(pageCount);
2590
- if (!isAllValid) {
2591
- throw "MissingAlert";
2592
- }
2593
- const filePath = await SaveTotalPdf();
2594
- await Bridge.nativeOz.createOzPdfViewer({ filePath });
2595
- } catch (e) {
2596
- if (e === "MissingAlert") {
2597
- await Bridge.nativeOz.showMissingAlert();
2598
- } else {
2599
- alert("PDF export \uC911 \uC624\uB958\uAC00 \uBC1C\uC0DD\uD558\uC600\uC2B5\uB2C8\uB2E4");
2600
- }
2601
- } finally {
2602
- await Bridge.native.hideLoader();
2603
- }
2706
+ throw `Unexpected btnID ${btnID}`;
2604
2707
  }
2605
2708
  }
2606
- async function TopHandler({ type, btnID }) {
2607
- if (type !== "top") {
2608
- throw `Unexpected Type ${type}`;
2609
- }
2610
- if (btnID === "btnExit") {
2611
- await Bridge.native.hideOZViewer();
2612
- }
2709
+ async function SignatureInProgressHandler() {
2710
+ const reportCount = await getReportCountMemo();
2711
+ const pageCount = await getTotalPageMemo();
2712
+ await enableFocusOnValidation(reportCount);
2713
+ await validateAllPages(pageCount);
2613
2714
  }
2614
- async function PdfHandler({ type, btnID }) {
2615
- if (type !== "pdf") {
2616
- throw `Unexpected Type ${type}`;
2617
- }
2618
- if (btnID === "modify") {
2619
- await Bridge.nativeOz.hideOzPdfViewer();
2620
- } else {
2621
- await Bridge.nativeOz.hideOzPdfViewer();
2622
- await Bridge.native.hideOZViewer();
2715
+ async function SignatureCompleteHandler() {
2716
+ try {
2717
+ await Bridge.native.showLoader();
2718
+ checkValidPageMemo.clearCache();
2719
+ getReportCountMemo.clearCache();
2720
+ getTotalPageMemo.clearCache();
2721
+ const reportCount = await getReportCountMemo();
2722
+ const pageCount = await getTotalPageMemo();
2723
+ await disableFocusOnValidation(reportCount);
2724
+ const isAllValid = await validateAllPages(pageCount);
2725
+ if (!isAllValid) {
2726
+ throw "MissingAlert";
2727
+ }
2728
+ const filePath = await SaveTotalPdf();
2729
+ await Bridge.nativeOz.createOzPdfViewer({ filePath });
2730
+ } catch (e) {
2731
+ if (e === "MissingAlert") {
2732
+ await Bridge.nativeOz.showMissingAlert();
2733
+ } else {
2734
+ alert("PDF export \uC911 \uC624\uB958\uAC00 \uBC1C\uC0DD\uD558\uC600\uC2B5\uB2C8\uB2E4");
2735
+ }
2736
+ } finally {
2737
+ await Bridge.native.hideLoader();
2623
2738
  }
2624
2739
  }
2625
2740
  async function SaveTotalPdf() {
@@ -2631,7 +2746,7 @@ async function SaveTotalPdf() {
2631
2746
  // 이벤트 리스너는 한 번만 실행되도록 설정
2632
2747
  { once: true }
2633
2748
  );
2634
- const totalPage = await getTotalPage();
2749
+ const totalPage = await getTotalPageMemo();
2635
2750
  await Bridge.nativeOz.savePdf({
2636
2751
  param: [
2637
2752
  // 저장할 파일명 설정
@@ -2645,55 +2760,6 @@ async function SaveTotalPdf() {
2645
2760
  const filepath = await promise;
2646
2761
  return filepath;
2647
2762
  }
2648
- async function isCommentMode() {
2649
- const { data } = await Bridge.nativeOz.getInformation({
2650
- command: `COMMENT_MODE`
2651
- });
2652
- return data === "comment";
2653
- }
2654
- async function setCommentMode(penConfig) {
2655
- const command = `mode_comment_all`;
2656
- const commentEnabled = await isCommentMode();
2657
- const param = [
2658
- ...commentEnabled ? [] : [`viewer.screentool=comment`],
2659
- ...penConfig
2660
- ].join("\n");
2661
- await sleep();
2662
- return await Bridge.nativeOz.scriptEx({ command, param });
2663
- }
2664
- async function setEnableCommentMode(type = "yellow") {
2665
- let param;
2666
- if (type === "yellow") {
2667
- param = commentPenYellow;
2668
- } else if (type === "pink") {
2669
- param = commentPenPink;
2670
- } else if (type === "green") {
2671
- param = commentPenGreen;
2672
- } else {
2673
- param = commentPenEraser;
2674
- }
2675
- return await setCommentMode(param);
2676
- }
2677
- async function setDisableCommentMode() {
2678
- const command = `mode_input_all`;
2679
- return await Bridge.nativeOz.script({ command });
2680
- }
2681
- async function CommentHandler({ type, btnID }) {
2682
- if (type !== "comment") {
2683
- throw `Unexpected Type ${type}`;
2684
- }
2685
- if (btnID === "yellow") {
2686
- await setEnableCommentMode("yellow");
2687
- } else if (btnID === "pink") {
2688
- await setEnableCommentMode("pink");
2689
- } else if (btnID === "green") {
2690
- await setEnableCommentMode("green");
2691
- } else if (btnID === "eraser") {
2692
- await setEnableCommentMode("eraser");
2693
- } else {
2694
- await setDisableCommentMode();
2695
- }
2696
- }
2697
2763
 
2698
2764
  // src/oz/utils/bridge-util/fetch-util.ts
2699
2765
  async function fetchDocument(options) {
@@ -2724,8 +2790,11 @@ async function CreateOzParam(documentList, extraData = {}) {
2724
2790
  if (data.inputJson) {
2725
2791
  result.push(`${prefix}connection.inputjson=${JSON.stringify(data.inputJson)}`);
2726
2792
  }
2793
+ if (data.args) {
2794
+ data.args.forEach((arg, idx2) => result.push(`${prefix}connection.args${idx2 + 1}=${arg}`));
2795
+ }
2727
2796
  if (data.extraParam) {
2728
- result.push(data.extraParam.map((param) => `${prefix}${param}`).join("\n"));
2797
+ data.extraParam.forEach((param) => result.push(`${prefix}${param}`));
2729
2798
  }
2730
2799
  return result;
2731
2800
  });
@@ -2739,14 +2808,14 @@ async function CreateOzParam(documentList, extraData = {}) {
2739
2808
  return params;
2740
2809
  }
2741
2810
  async function setCheckEform(reportCount) {
2742
- const count = reportCount ?? await getReportCount();
2811
+ const count = reportCount ?? await getReportCountMemo();
2743
2812
  for (let i = 0; i < count; i++) {
2744
2813
  await sleep();
2745
2814
  await Bridge.nativeOz.setGlobal({ key: "checkeForm", value: "Y", docIndex: i });
2746
2815
  }
2747
2816
  }
2748
2817
  async function triggerClickOnAllDocuments(reportCount) {
2749
- const count = reportCount ?? await getReportCount();
2818
+ const count = reportCount ?? await getReportCountMemo();
2750
2819
  for (let i = 0; i < count; i++) {
2751
2820
  await sleep();
2752
2821
  const command = `INPUT_TRIGGER_CLICK_AT=${i}`;
@@ -2754,14 +2823,14 @@ async function triggerClickOnAllDocuments(reportCount) {
2754
2823
  }
2755
2824
  }
2756
2825
  async function triggerCropImageOnAllDocuments(reportCount) {
2757
- const count = reportCount ?? await getReportCount();
2826
+ const count = reportCount ?? await getReportCountMemo();
2758
2827
  for (let i = 0; i < count; i++) {
2759
2828
  await sleep();
2760
2829
  await Bridge.nativeOz.triggerExternalEventByDocIndex({ docIndex: Number(i), param1: "cropimage" });
2761
2830
  }
2762
2831
  }
2763
2832
  async function getTotalPageOnAllDocuments(reportCount) {
2764
- const count = reportCount ?? await getReportCount();
2833
+ const count = reportCount ?? await getReportCountMemo();
2765
2834
  const totalPages = [];
2766
2835
  for (let i = 0; i < count; i++) {
2767
2836
  await sleep();
@@ -2827,8 +2896,8 @@ exports.fetchDocument = fetchDocument;
2827
2896
  exports.fetchFont = fetchFont;
2828
2897
  exports.getCurrentPage = getCurrentPage;
2829
2898
  exports.getFileListByGlobalIndex = getFileListByGlobalIndex;
2830
- exports.getReportCount = getReportCount;
2831
- exports.getTotalPage = getTotalPage;
2899
+ exports.getReportCountMemo = getReportCountMemo;
2900
+ exports.getTotalPageMemo = getTotalPageMemo;
2832
2901
  exports.getTotalPageOnAllDocuments = getTotalPageOnAllDocuments;
2833
2902
  exports.isCommentMode = isCommentMode;
2834
2903
  exports.setCheckEform = setCheckEform;