sales-frontend-bridge 0.0.33 → 0.0.35

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
@@ -1889,6 +1889,61 @@ var NativeBridge = class extends CommonBridge {
1889
1889
  async hideLoader() {
1890
1890
  return this.core.callToTarget("hideLoader");
1891
1891
  }
1892
+ /**
1893
+ * 홈 이동
1894
+ * @example
1895
+ * ```tsx
1896
+ * // 사용 예시
1897
+ * Bridge.native.goHome()
1898
+ * ```
1899
+ */
1900
+ goHome() {
1901
+ return this.core.callToTarget("goHome");
1902
+ }
1903
+ /**
1904
+ * 전체메뉴 열기
1905
+ * @example
1906
+ * ```tsx
1907
+ * // 사용 예시
1908
+ * Bridge.native.showMenu()
1909
+ * ```
1910
+ */
1911
+ showMenu() {
1912
+ return this.core.callToTarget("showMenu");
1913
+ }
1914
+ /**
1915
+ * GA4 정보 얻기
1916
+ * @example
1917
+ * ```tsx
1918
+ * // 사용 예시
1919
+ * Bridge.native.getAnalyticsUserProperty()
1920
+ * ```
1921
+ */
1922
+ getAnalyticsUserProperty() {
1923
+ return this.core.callToTarget("getAnalyticsUserProperty");
1924
+ }
1925
+ /**
1926
+ *외부 브라우저 호출
1927
+ * @example
1928
+ * ```tsx
1929
+ * // 사용 예시
1930
+ * Bridge.native.getAnalyticsUserProperty()
1931
+ * ```
1932
+ */
1933
+ openBrowser(options) {
1934
+ return this.core.callToTarget("openBrowser", options);
1935
+ }
1936
+ /**
1937
+ * 웹뷰 닫기
1938
+ * @example
1939
+ * ```tsx
1940
+ * // 사용 예시
1941
+ * Bridge.native.hideWebPopup()
1942
+ * ```
1943
+ */
1944
+ hideWebPopup() {
1945
+ return this.core.callToTarget("hideWebPopup");
1946
+ }
1892
1947
  // TODO: 필요 플러그인들 추가
1893
1948
  };
1894
1949
 
@@ -2237,6 +2292,7 @@ var btnStyle = { border: "1px solid red", minHeight: "40px" };
2237
2292
  var DownloadDocumentList = [
2238
2293
  { name: "[A0010]\uCCAD\uC57D\uC11C", file: ["A0010.ozd"], complete: false, startPage: 0, endPage: 0, focus: false },
2239
2294
  { name: "[A0100]\uBE44\uAD50\uC548\uB0B4\uD655\uC778\uC11C", file: ["A0100.ozd"], complete: false, startPage: 0, endPage: 0, focus: false },
2295
+ // { name: '[A0900]상품설명서', file: ['A0900.ozd'], complete: false, startPage: 0, endPage: 0, focus: false },
2240
2296
  { name: "[A1500]\uCCAD\uC57D\uBD80\uC18D\uC815\uBCF4\uD655\uC778\uC11C", file: ["A1500.ozd"], complete: false, startPage: 0, endPage: 0, focus: false },
2241
2297
  { 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
2298
  { name: "[A2800]\uACC4\uC57D\uC804\uC54C\uB9B4\uC758\uBB34", file: ["A2800.ozd"], complete: false, startPage: 0, endPage: 0, focus: false },
@@ -2397,38 +2453,28 @@ function PromiseWithResolvers() {
2397
2453
  return { promise, resolve, reject };
2398
2454
  }
2399
2455
 
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");
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;
2404
2463
  }
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;
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;
2431
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
+ // src/oz/utils/bridge-util/oz-wrapper-util.ts
2432
2478
  async function CreateOzViewer(ozParam) {
2433
2479
  const { promise, resolve } = PromiseWithResolvers();
2434
2480
  window.addEventListener(
@@ -2441,15 +2487,6 @@ async function CreateOzViewer(ozParam) {
2441
2487
  await Bridge.native.createOZViewer({ param: ozParam.join("\n") });
2442
2488
  return await promise;
2443
2489
  }
2444
- async function fetchDocument(options) {
2445
- const { data } = await Bridge.native.downloadDocument({ data: options });
2446
- return data.map((i) => ({ ...i, startPage: 0, endPage: 0 }));
2447
- }
2448
- async function fetchFont() {
2449
- const { data: fontMap } = await Bridge.native.getOzFontParam();
2450
- const fontParms = Object.keys(fontMap).map((i) => `font.${i}=${fontMap[i]}`);
2451
- return fontParms;
2452
- }
2453
2490
  async function getReportCount() {
2454
2491
  const { data } = await Bridge.nativeOz.getInformation({ command: "REPORT_COUNT" });
2455
2492
  return Number(data);
@@ -2457,48 +2494,16 @@ async function getReportCount() {
2457
2494
  async function MovePage(page) {
2458
2495
  return await Bridge.nativeOz.script({ command: `movepage=${page}` });
2459
2496
  }
2460
- async function enableFocusOnValidation(reportCount) {
2461
- const count = reportCount ?? await getReportCount();
2462
- for (let i = 0; i < count; i++) {
2463
- await sleep();
2464
- await Bridge.nativeOz.setGlobal({ key: "chkFlag", value: "1", docIndex: i });
2465
- }
2466
- return;
2467
- }
2468
- async function disableFocusOnValidation(reportCount) {
2469
- const count = reportCount ?? await getReportCount();
2470
- for (let i = 0; i < count; i++) {
2471
- await sleep();
2472
- await Bridge.nativeOz.setGlobal({ key: "chkFlag", value: "0", docIndex: i });
2473
- }
2474
- return;
2475
- }
2476
- async function triggerClickOnAllDocuments(reportCount) {
2477
- const count = reportCount ?? await getReportCount();
2478
- for (let i = 0; i < count; i++) {
2479
- await sleep();
2480
- const command = `INPUT_TRIGGER_CLICK_AT=${i}`;
2481
- await Bridge.nativeOz.getInformation({ command });
2482
- }
2483
- }
2484
- async function triggerCropImageOnAllDocuments(reportCount) {
2485
- const count = reportCount ?? await getReportCount();
2486
- for (let i = 0; i < count; i++) {
2487
- await sleep();
2488
- await Bridge.nativeOz.triggerExternalEventByDocIndex({ docIndex: Number(i), param1: "cropimage" });
2489
- }
2497
+ async function getTotalPage() {
2498
+ const { data } = await Bridge.nativeOz.getInformation({ command: "TOTAL_PAGE" });
2499
+ return Number(data);
2490
2500
  }
2491
- async function getTotalPageOnAllDocuments(reportCount) {
2492
- const count = reportCount ?? await getReportCount();
2493
- const totalPages = [];
2494
- for (let i = 0; i < count; i++) {
2495
- await sleep();
2496
- const command = `TOTAL_PAGE_OF_REPORT_FILE_AT=${i}`;
2497
- const { data } = await Bridge.nativeOz.getInformation({ command });
2498
- totalPages.push(Number(data));
2499
- }
2500
- return totalPages;
2501
+ async function getCurrentPage() {
2502
+ const { data } = await Bridge.nativeOz.getInformation({ command: `CURRENT_PAGE` });
2503
+ return Number(data);
2501
2504
  }
2505
+
2506
+ // src/oz/utils/bridge-util/validation-util.ts
2502
2507
  async function checkDocumentsValidityByIndex(indexList) {
2503
2508
  const VALID = "";
2504
2509
  for (let i = 0; i < indexList.length; i++) {
@@ -2512,75 +2517,51 @@ async function checkDocumentsValidityByIndex(indexList) {
2512
2517
  return true;
2513
2518
  }
2514
2519
  async function validateAllPages(pageCount) {
2515
- const VALID = "valid";
2516
2520
  const count = pageCount ?? await getTotalPage();
2517
2521
  for (let i = 1; i <= count; i++) {
2518
2522
  await sleep();
2519
- const command = `INPUT_CHECK_VALIDITY_PAGE_AT=${i}`;
2520
- const { data } = await Bridge.nativeOz.getInformation({ command });
2521
- if (data !== VALID) {
2523
+ const isValid = await checkValidPageMemo(i);
2524
+ if (!isValid) {
2522
2525
  return false;
2523
2526
  }
2524
2527
  }
2525
2528
  return true;
2526
2529
  }
2527
- async function getTotalPage() {
2528
- const { data } = await Bridge.nativeOz.getInformation({ command: "TOTAL_PAGE" });
2529
- return Number(data);
2530
- }
2531
- async function getCurrentPage() {
2532
- const { data } = await Bridge.nativeOz.getInformation({ command: `CURRENT_PAGE` });
2533
- return Number(data);
2534
- }
2535
- async function isCommentMode() {
2536
- const { data } = await Bridge.nativeOz.getInformation({
2537
- command: `COMMENT_MODE`
2538
- });
2539
- return data === "comment";
2540
- }
2541
- async function setCommentMode(penConfig) {
2542
- const command = `mode_comment_all`;
2543
- const commentEnabled = await isCommentMode();
2544
- const param = [
2545
- ...commentEnabled ? [] : [`viewer.screentool=comment`],
2546
- ...penConfig
2547
- ].join("\n");
2548
- await sleep();
2549
- return await Bridge.nativeOz.scriptEx({ command, param });
2550
- }
2551
- async function setEnableCommentMode(type = "yellow") {
2552
- let param;
2553
- if (type === "yellow") {
2554
- param = commentPenYellow;
2555
- } else if (type === "pink") {
2556
- param = commentPenPink;
2557
- } else if (type === "green") {
2558
- param = commentPenGreen;
2559
- } else {
2560
- param = commentPenEraser;
2561
- }
2562
- return await setCommentMode(param);
2563
- }
2564
- async function setDisableCommentMode() {
2565
- const command = `mode_input_all`;
2566
- return await Bridge.nativeOz.script({ command });
2567
- }
2568
- async function CommentHandler({ type, btnID }) {
2569
- if (type !== "comment") {
2570
- throw `Unexpected Type ${type}`;
2571
- }
2572
- if (btnID === "yellow") {
2573
- await setEnableCommentMode("yellow");
2574
- } else if (btnID === "pink") {
2575
- await setEnableCommentMode("pink");
2576
- } else if (btnID === "green") {
2577
- await setEnableCommentMode("green");
2578
- } else if (btnID === "eraser") {
2579
- await setEnableCommentMode("eraser");
2580
- } else {
2581
- await setDisableCommentMode();
2530
+ var checkValidPageMemo = (() => {
2531
+ const cache = /* @__PURE__ */ new Map();
2532
+ async function checkValidPage(page) {
2533
+ const cached = cache.get(page);
2534
+ if (cached) {
2535
+ return cached;
2536
+ }
2537
+ const VALID = "valid";
2538
+ const command = `INPUT_CHECK_VALIDITY_PAGE_AT=${page}`;
2539
+ const promise = (async () => {
2540
+ try {
2541
+ const { data } = await Bridge.nativeOz.getInformation({ command });
2542
+ const isValid = data === VALID;
2543
+ if (!isValid) {
2544
+ cache.delete(page);
2545
+ }
2546
+ return isValid;
2547
+ } catch (err) {
2548
+ cache.delete(page);
2549
+ throw err;
2550
+ }
2551
+ })();
2552
+ cache.set(page, promise);
2553
+ return promise;
2582
2554
  }
2583
- }
2555
+ checkValidPage.clearCache = () => {
2556
+ cache.clear();
2557
+ };
2558
+ checkValidPage.clearCacheByPage = (page) => {
2559
+ cache.delete(page);
2560
+ };
2561
+ return checkValidPage;
2562
+ })();
2563
+
2564
+ // src/oz/utils/bridge-util/btn-touch-event-util.ts
2584
2565
  async function CategoryHandler(documentInfo, { type, btnID }) {
2585
2566
  if (type !== "category") {
2586
2567
  throw `Unexpected Type ${type}`;
@@ -2604,6 +2585,7 @@ async function SignatureHandler({ type, btnID }) {
2604
2585
  try {
2605
2586
  await Bridge.native.showLoader();
2606
2587
  await disableFocusOnValidation(reportCount);
2588
+ checkValidPageMemo.clearCache();
2607
2589
  const isAllValid = await validateAllPages(pageCount);
2608
2590
  if (!isAllValid) {
2609
2591
  throw "MissingAlert";
@@ -2663,39 +2645,132 @@ async function SaveTotalPdf() {
2663
2645
  const filepath = await promise;
2664
2646
  return filepath;
2665
2647
  }
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;
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
+
2698
+ // src/oz/utils/bridge-util/fetch-util.ts
2699
+ async function fetchDocument(options) {
2700
+ const { data } = await Bridge.native.downloadDocument({ data: options });
2701
+ return data.map((i) => ({ ...i, startPage: 0, endPage: 0 }));
2702
+ }
2703
+ async function fetchFont() {
2704
+ const { data: fontMap } = await Bridge.native.getOzFontParam();
2705
+ const fontParms = Object.keys(fontMap).map((i) => `font.${i}=${fontMap[i]}`);
2706
+ return fontParms;
2707
+ }
2708
+
2709
+ // src/oz/utils/bridge-util/create-report-util.ts
2710
+ async function CreateOzParam(documentList, extraData = {}) {
2711
+ if (documentList.length === 0) {
2712
+ throw new Error("\uBB38\uC11C\uBAA9\uB85D\uC774 \uBE44\uC5B4\uC788\uC2B5\uB2C8\uB2E4");
2713
+ }
2714
+ const fontParms = await fetchFont();
2715
+ const connectionParams = documentList.map(
2716
+ (file, idx) => idx === 0 ? `connection.openfile=${file}` : `child${idx}.connection.openfile=${file}`
2717
+ );
2718
+ const childCount = documentList.length - 1;
2719
+ const extraParams = documentList.map((file, idx) => {
2720
+ const result = [];
2721
+ const docCode = file.replace(/^.*[\\/]|(\.[^/.]+)$/g, "");
2722
+ const prefix = idx === 0 ? "" : `child${idx}.`;
2723
+ const data = extraData[docCode] || {};
2724
+ if (data.inputJson) {
2725
+ result.push(`${prefix}connection.inputjson=${JSON.stringify(data.inputJson)}`);
2672
2726
  }
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;
2686
- }
2687
- })();
2688
- cache.set(page, promise);
2689
- return promise;
2727
+ if (data.extraParam) {
2728
+ result.push(data.extraParam.map((param) => `${prefix}${param}`).join("\n"));
2729
+ }
2730
+ return result;
2731
+ });
2732
+ const params = [
2733
+ ...childCount > 0 ? [`viewer.childcount=${childCount}`] : [],
2734
+ ...connectionParams,
2735
+ ...commonOzParam,
2736
+ ...fontParms,
2737
+ ...extraParams.flat(1)
2738
+ ];
2739
+ return params;
2740
+ }
2741
+ async function setCheckEform(reportCount) {
2742
+ const count = reportCount ?? await getReportCount();
2743
+ for (let i = 0; i < count; i++) {
2744
+ await sleep();
2745
+ await Bridge.nativeOz.setGlobal({ key: "checkeForm", value: "Y", docIndex: i });
2690
2746
  }
2691
- checkValidPage.clearCache = () => {
2692
- cache.clear();
2693
- };
2694
- checkValidPage.clearCacheByPage = (page) => {
2695
- cache.delete(page);
2696
- };
2697
- return checkValidPage;
2698
- })();
2747
+ }
2748
+ async function triggerClickOnAllDocuments(reportCount) {
2749
+ const count = reportCount ?? await getReportCount();
2750
+ for (let i = 0; i < count; i++) {
2751
+ await sleep();
2752
+ const command = `INPUT_TRIGGER_CLICK_AT=${i}`;
2753
+ await Bridge.nativeOz.getInformation({ command });
2754
+ }
2755
+ }
2756
+ async function triggerCropImageOnAllDocuments(reportCount) {
2757
+ const count = reportCount ?? await getReportCount();
2758
+ for (let i = 0; i < count; i++) {
2759
+ await sleep();
2760
+ await Bridge.nativeOz.triggerExternalEventByDocIndex({ docIndex: Number(i), param1: "cropimage" });
2761
+ }
2762
+ }
2763
+ async function getTotalPageOnAllDocuments(reportCount) {
2764
+ const count = reportCount ?? await getReportCount();
2765
+ const totalPages = [];
2766
+ for (let i = 0; i < count; i++) {
2767
+ await sleep();
2768
+ const command = `TOTAL_PAGE_OF_REPORT_FILE_AT=${i}`;
2769
+ const { data } = await Bridge.nativeOz.getInformation({ command });
2770
+ totalPages.push(Number(data));
2771
+ }
2772
+ return totalPages;
2773
+ }
2699
2774
  /*! Bundled license information:
2700
2775
 
2701
2776
  react/cjs/react.production.js:
@@ -2756,6 +2831,7 @@ exports.getReportCount = getReportCount;
2756
2831
  exports.getTotalPage = getTotalPage;
2757
2832
  exports.getTotalPageOnAllDocuments = getTotalPageOnAllDocuments;
2758
2833
  exports.isCommentMode = isCommentMode;
2834
+ exports.setCheckEform = setCheckEform;
2759
2835
  exports.setDisableCommentMode = setDisableCommentMode;
2760
2836
  exports.setEnableCommentMode = setEnableCommentMode;
2761
2837
  exports.sleep = sleep;