zartui 2.0.91 → 2.1.1-beta

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/lib/zart.js CHANGED
@@ -91,7 +91,7 @@ return /******/ (function(modules) { // webpackBootstrap
91
91
  /******/
92
92
  /******/
93
93
  /******/ // Load entry module and return exports
94
- /******/ return __webpack_require__(__webpack_require__.s = 13);
94
+ /******/ return __webpack_require__(__webpack_require__.s = 12);
95
95
  /******/ })
96
96
  /************************************************************************/
97
97
  /******/ ([
@@ -159,7 +159,7 @@ function createBEM(name) {
159
159
  };
160
160
  }
161
161
  // EXTERNAL MODULE: ./es/locale/index.js + 2 modules
162
- var locale = __webpack_require__(9);
162
+ var locale = __webpack_require__(8);
163
163
 
164
164
  // EXTERNAL MODULE: ./es/utils/format/string.js
165
165
  var string = __webpack_require__(5);
@@ -412,7 +412,7 @@ module.exports = mergeJsxProps;
412
412
  /* 2 */
413
413
  /***/ (function(module, exports, __webpack_require__) {
414
414
 
415
- module.exports = __webpack_require__(12);
415
+ module.exports = __webpack_require__(11);
416
416
 
417
417
  /***/ }),
418
418
  /* 3 */
@@ -584,6 +584,197 @@ function isNaN(val) {
584
584
 
585
585
  /***/ }),
586
586
  /* 8 */
587
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
588
+
589
+ "use strict";
590
+
591
+ // EXTERNAL MODULE: external {"root":"Vue","commonjs":"vue","commonjs2":"vue","amd":"vue"}
592
+ var external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_ = __webpack_require__(3);
593
+ var external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_default = /*#__PURE__*/__webpack_require__.n(external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_);
594
+
595
+ // EXTERNAL MODULE: ./es/utils/index.js + 5 modules
596
+ var utils = __webpack_require__(0);
597
+
598
+ // CONCATENATED MODULE: ./es/utils/deep-assign.js
599
+
600
+ var deep_assign_hasOwnProperty = Object.prototype.hasOwnProperty;
601
+
602
+ function assignKey(to, from, key) {
603
+ var val = from[key];
604
+
605
+ if (!Object(utils["e" /* isDef */])(val)) {
606
+ return;
607
+ }
608
+
609
+ if (!deep_assign_hasOwnProperty.call(to, key) || !Object(utils["g" /* isObject */])(val)) {
610
+ to[key] = val;
611
+ } else {
612
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
613
+ to[key] = deepAssign(Object(to[key]), from[key]);
614
+ }
615
+ }
616
+
617
+ function deepAssign(to, from) {
618
+ Object.keys(from).forEach(function (key) {
619
+ assignKey(to, from, key);
620
+ });
621
+ return to;
622
+ }
623
+ // CONCATENATED MODULE: ./es/locale/lang/zh-CN.js
624
+ /* harmony default export */ var zh_CN = ({
625
+ name: '姓名',
626
+ tel: '电话',
627
+ save: '保存',
628
+ confirm: '确认',
629
+ cancel: '取消',
630
+ delete: '删除',
631
+ complete: '完成',
632
+ loading: '加载中...',
633
+ telEmpty: '请填写电话',
634
+ nameEmpty: '请填写姓名',
635
+ nameInvalid: '请输入正确的姓名',
636
+ confirmDelete: '确定要删除吗',
637
+ telInvalid: '请输入正确的手机号',
638
+ ztDateTimePicker: {
639
+ year: '年',
640
+ month: '月',
641
+ day: '日',
642
+ hour: '时',
643
+ minute: '分'
644
+ },
645
+ ztCalendar: {
646
+ end: '结束',
647
+ start: '开始',
648
+ title: '日期选择',
649
+ confirm: '确定',
650
+ startEnd: '开始/结束',
651
+ weekdays: ['日', '一', '二', '三', '四', '五', '六'],
652
+ monthTitle: function monthTitle(year, month) {
653
+ return year + "\u5E74" + month + "\u6708";
654
+ },
655
+ rangePrompt: function rangePrompt(maxRange) {
656
+ return "\u9009\u62E9\u5929\u6570\u4E0D\u80FD\u8D85\u8FC7 " + maxRange + " \u5929";
657
+ }
658
+ },
659
+ vanCascader: {
660
+ select: '请选择'
661
+ },
662
+ vanContactCard: {
663
+ addText: '添加联系人'
664
+ },
665
+ vanContactList: {
666
+ addText: '新建联系人'
667
+ },
668
+ vanPagination: {
669
+ prev: '上一页',
670
+ next: '下一页'
671
+ },
672
+ vanPullRefresh: {
673
+ pulling: '下拉即可刷新...',
674
+ loosing: '释放即可刷新...'
675
+ },
676
+ ztSubmitBar: {
677
+ label: '合计:'
678
+ },
679
+ vanCoupon: {
680
+ unlimited: '无使用门槛',
681
+ discount: function discount(_discount) {
682
+ return _discount + "\u6298";
683
+ },
684
+ condition: function condition(_condition) {
685
+ return "\u6EE1" + _condition + "\u5143\u53EF\u7528";
686
+ }
687
+ },
688
+ vanCouponCell: {
689
+ title: '优惠券',
690
+ tips: '暂无可用',
691
+ count: function count(_count) {
692
+ return _count + "\u5F20\u53EF\u7528";
693
+ }
694
+ },
695
+ vanCouponList: {
696
+ empty: '暂无优惠券',
697
+ exchange: '兑换',
698
+ close: '不使用优惠券',
699
+ enable: '可用',
700
+ disabled: '不可用',
701
+ placeholder: '请输入优惠码'
702
+ },
703
+ vanAddressEdit: {
704
+ area: '地区',
705
+ postal: '邮政编码',
706
+ areaEmpty: '请选择地区',
707
+ addressEmpty: '请填写详细地址',
708
+ postalEmpty: '邮政编码格式不正确',
709
+ defaultAddress: '设为默认收货地址',
710
+ telPlaceholder: '收货人手机号',
711
+ namePlaceholder: '收货人姓名',
712
+ areaPlaceholder: '选择省 / 市 / 区'
713
+ },
714
+ vanAddressEditDetail: {
715
+ label: '详细地址',
716
+ placeholder: '街道门牌、楼层房间号等信息'
717
+ },
718
+ vanAddressList: {
719
+ add: '新增地址'
720
+ },
721
+ ztAvatar: {
722
+ defaultSrc: "https://zartui.egova.com.cn/static/head_shot.png",
723
+ small: "small",
724
+ medium: "medium",
725
+ large: "large",
726
+ square: "square",
727
+ circle: "circle",
728
+ defaultText: "头像"
729
+ },
730
+ ztSearch: {
731
+ search: '搜索'
732
+ },
733
+ ztEmpty: {
734
+ notSearchResult: '没有搜索结果',
735
+ notFound: '页面无法访问',
736
+ developing: '项目建设中',
737
+ error: '通用错误',
738
+ notRight: '您暂未拥有访问权限'
739
+ },
740
+ ztSignature: {
741
+ hint: '请在此签名',
742
+ browserUnsupported: '对不起,当前浏览器不支持Canvas,无法使用本控件!',
743
+ screenSizeChangeTip: '旋转屏幕或者改变屏幕大小触发重新绘制',
744
+ reSign: '重签'
745
+ }
746
+ });
747
+ // CONCATENATED MODULE: ./es/locale/index.js
748
+
749
+
750
+
751
+ var proto = external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_default.a.prototype;
752
+ var defineReactive = external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_default.a.util.defineReactive;
753
+ defineReactive(proto, '$zartLang', 'zh-CN');
754
+ defineReactive(proto, '$zartMessages', {
755
+ 'zh-CN': zh_CN
756
+ });
757
+ /* harmony default export */ var locale = __webpack_exports__["a"] = ({
758
+ messages: function messages() {
759
+ return proto.$zartMessages[proto.$zartLang];
760
+ },
761
+ use: function use(lang, messages) {
762
+ var _this$add;
763
+
764
+ proto.$zartLang = lang;
765
+ this.add((_this$add = {}, _this$add[lang] = messages, _this$add));
766
+ },
767
+ add: function add(messages) {
768
+ if (messages === void 0) {
769
+ messages = {};
770
+ }
771
+
772
+ deepAssign(proto.$zartMessages, messages);
773
+ }
774
+ });
775
+
776
+ /***/ }),
777
+ /* 9 */
587
778
  /***/ (function(module, exports, __webpack_require__) {
588
779
 
589
780
  !function (t, e) {
@@ -924,197 +1115,6 @@ function isNaN(val) {
924
1115
  }, w.en = D[g], w.Ls = D, w.p = {}, w;
925
1116
  });
926
1117
 
927
- /***/ }),
928
- /* 9 */
929
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
930
-
931
- "use strict";
932
-
933
- // EXTERNAL MODULE: external {"root":"Vue","commonjs":"vue","commonjs2":"vue","amd":"vue"}
934
- var external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_ = __webpack_require__(3);
935
- var external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_default = /*#__PURE__*/__webpack_require__.n(external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_);
936
-
937
- // EXTERNAL MODULE: ./es/utils/index.js + 5 modules
938
- var utils = __webpack_require__(0);
939
-
940
- // CONCATENATED MODULE: ./es/utils/deep-assign.js
941
-
942
- var deep_assign_hasOwnProperty = Object.prototype.hasOwnProperty;
943
-
944
- function assignKey(to, from, key) {
945
- var val = from[key];
946
-
947
- if (!Object(utils["e" /* isDef */])(val)) {
948
- return;
949
- }
950
-
951
- if (!deep_assign_hasOwnProperty.call(to, key) || !Object(utils["g" /* isObject */])(val)) {
952
- to[key] = val;
953
- } else {
954
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
955
- to[key] = deepAssign(Object(to[key]), from[key]);
956
- }
957
- }
958
-
959
- function deepAssign(to, from) {
960
- Object.keys(from).forEach(function (key) {
961
- assignKey(to, from, key);
962
- });
963
- return to;
964
- }
965
- // CONCATENATED MODULE: ./es/locale/lang/zh-CN.js
966
- /* harmony default export */ var zh_CN = ({
967
- name: '姓名',
968
- tel: '电话',
969
- save: '保存',
970
- confirm: '确认',
971
- cancel: '取消',
972
- delete: '删除',
973
- complete: '完成',
974
- loading: '加载中...',
975
- telEmpty: '请填写电话',
976
- nameEmpty: '请填写姓名',
977
- nameInvalid: '请输入正确的姓名',
978
- confirmDelete: '确定要删除吗',
979
- telInvalid: '请输入正确的手机号',
980
- ztDateTimePicker: {
981
- year: '年',
982
- month: '月',
983
- day: '日',
984
- hour: '时',
985
- minute: '分'
986
- },
987
- ztCalendar: {
988
- end: '结束',
989
- start: '开始',
990
- title: '日期选择',
991
- confirm: '确定',
992
- startEnd: '开始/结束',
993
- weekdays: ['日', '一', '二', '三', '四', '五', '六'],
994
- monthTitle: function monthTitle(year, month) {
995
- return year + "\u5E74" + month + "\u6708";
996
- },
997
- rangePrompt: function rangePrompt(maxRange) {
998
- return "\u9009\u62E9\u5929\u6570\u4E0D\u80FD\u8D85\u8FC7 " + maxRange + " \u5929";
999
- }
1000
- },
1001
- vanCascader: {
1002
- select: '请选择'
1003
- },
1004
- vanContactCard: {
1005
- addText: '添加联系人'
1006
- },
1007
- vanContactList: {
1008
- addText: '新建联系人'
1009
- },
1010
- vanPagination: {
1011
- prev: '上一页',
1012
- next: '下一页'
1013
- },
1014
- vanPullRefresh: {
1015
- pulling: '下拉即可刷新...',
1016
- loosing: '释放即可刷新...'
1017
- },
1018
- ztSubmitBar: {
1019
- label: '合计:'
1020
- },
1021
- vanCoupon: {
1022
- unlimited: '无使用门槛',
1023
- discount: function discount(_discount) {
1024
- return _discount + "\u6298";
1025
- },
1026
- condition: function condition(_condition) {
1027
- return "\u6EE1" + _condition + "\u5143\u53EF\u7528";
1028
- }
1029
- },
1030
- vanCouponCell: {
1031
- title: '优惠券',
1032
- tips: '暂无可用',
1033
- count: function count(_count) {
1034
- return _count + "\u5F20\u53EF\u7528";
1035
- }
1036
- },
1037
- vanCouponList: {
1038
- empty: '暂无优惠券',
1039
- exchange: '兑换',
1040
- close: '不使用优惠券',
1041
- enable: '可用',
1042
- disabled: '不可用',
1043
- placeholder: '请输入优惠码'
1044
- },
1045
- vanAddressEdit: {
1046
- area: '地区',
1047
- postal: '邮政编码',
1048
- areaEmpty: '请选择地区',
1049
- addressEmpty: '请填写详细地址',
1050
- postalEmpty: '邮政编码格式不正确',
1051
- defaultAddress: '设为默认收货地址',
1052
- telPlaceholder: '收货人手机号',
1053
- namePlaceholder: '收货人姓名',
1054
- areaPlaceholder: '选择省 / 市 / 区'
1055
- },
1056
- vanAddressEditDetail: {
1057
- label: '详细地址',
1058
- placeholder: '街道门牌、楼层房间号等信息'
1059
- },
1060
- vanAddressList: {
1061
- add: '新增地址'
1062
- },
1063
- ztAvatar: {
1064
- defaultSrc: "https://zartui.egova.com.cn/static/head_shot.png",
1065
- small: "small",
1066
- medium: "medium",
1067
- large: "large",
1068
- square: "square",
1069
- circle: "circle",
1070
- defaultText: "头像"
1071
- },
1072
- ztSearch: {
1073
- search: '搜索'
1074
- },
1075
- ztEmpty: {
1076
- notSearchResult: '没有搜索结果',
1077
- notFound: '页面无法访问',
1078
- developing: '项目建设中',
1079
- error: '通用错误',
1080
- notRight: '您暂未拥有访问权限'
1081
- },
1082
- ztSignature: {
1083
- hint: '请在此签名',
1084
- browserUnsupported: '对不起,当前浏览器不支持Canvas,无法使用本控件!',
1085
- screenSizeChangeTip: '旋转屏幕或者改变屏幕大小触发重新绘制',
1086
- reSign: '重签'
1087
- }
1088
- });
1089
- // CONCATENATED MODULE: ./es/locale/index.js
1090
-
1091
-
1092
-
1093
- var proto = external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_default.a.prototype;
1094
- var defineReactive = external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_default.a.util.defineReactive;
1095
- defineReactive(proto, '$zartLang', 'zh-CN');
1096
- defineReactive(proto, '$zartMessages', {
1097
- 'zh-CN': zh_CN
1098
- });
1099
- /* harmony default export */ var locale = __webpack_exports__["a"] = ({
1100
- messages: function messages() {
1101
- return proto.$zartMessages[proto.$zartLang];
1102
- },
1103
- use: function use(lang, messages) {
1104
- var _this$add;
1105
-
1106
- proto.$zartLang = lang;
1107
- this.add((_this$add = {}, _this$add[lang] = messages, _this$add));
1108
- },
1109
- add: function add(messages) {
1110
- if (messages === void 0) {
1111
- messages = {};
1112
- }
1113
-
1114
- deepAssign(proto.$zartMessages, messages);
1115
- }
1116
- });
1117
-
1118
1118
  /***/ }),
1119
1119
  /* 10 */
1120
1120
  /***/ (function(module, exports) {
@@ -1142,70 +1142,6 @@ module.exports = g;
1142
1142
  /* 11 */
1143
1143
  /***/ (function(module, exports, __webpack_require__) {
1144
1144
 
1145
- !function (e, _) {
1146
- true ? module.exports = _(__webpack_require__(8)) : undefined;
1147
- }(this, function (e) {
1148
- "use strict";
1149
-
1150
- function _(e) {
1151
- return e && "object" == typeof e && "default" in e ? e : {
1152
- default: e
1153
- };
1154
- }
1155
-
1156
- var t = _(e),
1157
- d = {
1158
- name: "zh-cn",
1159
- weekdays: "星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),
1160
- weekdaysShort: "周日_周一_周二_周三_周四_周五_周六".split("_"),
1161
- weekdaysMin: "日_一_二_三_四_五_六".split("_"),
1162
- months: "一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),
1163
- monthsShort: "1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),
1164
- ordinal: function ordinal(e, _) {
1165
- return "W" === _ ? e + "周" : e + "日";
1166
- },
1167
- weekStart: 1,
1168
- yearStart: 4,
1169
- formats: {
1170
- LT: "HH:mm",
1171
- LTS: "HH:mm:ss",
1172
- L: "YYYY/MM/DD",
1173
- LL: "YYYY年M月D日",
1174
- LLL: "YYYY年M月D日Ah点mm分",
1175
- LLLL: "YYYY年M月D日ddddAh点mm分",
1176
- l: "YYYY/M/D",
1177
- ll: "YYYY年M月D日",
1178
- lll: "YYYY年M月D日 HH:mm",
1179
- llll: "YYYY年M月D日dddd HH:mm"
1180
- },
1181
- relativeTime: {
1182
- future: "%s内",
1183
- past: "%s前",
1184
- s: "几秒",
1185
- m: "1 分钟",
1186
- mm: "%d 分钟",
1187
- h: "1 小时",
1188
- hh: "%d 小时",
1189
- d: "1 天",
1190
- dd: "%d 天",
1191
- M: "1 个月",
1192
- MM: "%d 个月",
1193
- y: "1 年",
1194
- yy: "%d 年"
1195
- },
1196
- meridiem: function meridiem(e, _) {
1197
- var t = 100 * e + _;
1198
- return t < 600 ? "凌晨" : t < 900 ? "早上" : t < 1100 ? "上午" : t < 1300 ? "中午" : t < 1800 ? "下午" : "晚上";
1199
- }
1200
- };
1201
-
1202
- return t.default.locale(d, null, !0), d;
1203
- });
1204
-
1205
- /***/ }),
1206
- /* 12 */
1207
- /***/ (function(module, exports, __webpack_require__) {
1208
-
1209
1145
  /**
1210
1146
  * Copyright (c) 2014-present, Facebook, Inc.
1211
1147
  *
@@ -1931,7 +1867,7 @@ try {
1931
1867
  }
1932
1868
 
1933
1869
  /***/ }),
1934
- /* 13 */
1870
+ /* 12 */
1935
1871
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
1936
1872
 
1937
1873
  "use strict";
@@ -2001,7 +1937,7 @@ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return /* re
2001
1937
  __webpack_require__.d(__webpack_exports__, "Slider", function() { return /* reexport */ slider; });
2002
1938
  __webpack_require__.d(__webpack_exports__, "Step", function() { return /* reexport */ es_step; });
2003
1939
  __webpack_require__.d(__webpack_exports__, "Stepper", function() { return /* reexport */ stepper; });
2004
- __webpack_require__.d(__webpack_exports__, "Steps", function() { return /* reexport */ es_steps; });
1940
+ __webpack_require__.d(__webpack_exports__, "Steps", function() { return /* reexport */ steps; });
2005
1941
  __webpack_require__.d(__webpack_exports__, "Sticky", function() { return /* reexport */ es_sticky; });
2006
1942
  __webpack_require__.d(__webpack_exports__, "Swipe", function() { return /* reexport */ swipe; });
2007
1943
  __webpack_require__.d(__webpack_exports__, "SwipeCell", function() { return /* reexport */ swipe_cell; });
@@ -4683,6 +4619,11 @@ var picker_createNamespace = Object(utils["b" /* createNamespace */])('picker'),
4683
4619
  "closeOnClickOverlay": this.closeOnClickOverlay,
4684
4620
  "customOnClickOverlay": this.onClickOverlay,
4685
4621
  "getContainer": this.getContainer
4622
+ },
4623
+ "on": {
4624
+ "input": function input(val) {
4625
+ _this7.$emit('update:showPicker', val);
4626
+ }
4686
4627
  }
4687
4628
  }, [renderPicker()]);
4688
4629
  }
@@ -11824,7 +11765,7 @@ var DatePicker_createNamespace = Object(utils["b" /* createNamespace */])('date-
11824
11765
  }
11825
11766
  }));
11826
11767
  // EXTERNAL MODULE: ./node_modules/dayjs/dayjs.min.js
11827
- var dayjs_min = __webpack_require__(8);
11768
+ var dayjs_min = __webpack_require__(9);
11828
11769
  var dayjs_min_default = /*#__PURE__*/__webpack_require__.n(dayjs_min);
11829
11770
 
11830
11771
  // CONCATENATED MODULE: ./es/datetime-picker/index.js
@@ -20348,7 +20289,7 @@ var list_createNamespace = Object(utils["b" /* createNamespace */])('list'),
20348
20289
  }
20349
20290
  }));
20350
20291
  // EXTERNAL MODULE: ./es/locale/index.js + 2 modules
20351
- var locale = __webpack_require__(9);
20292
+ var locale = __webpack_require__(8);
20352
20293
 
20353
20294
  // CONCATENATED MODULE: ./es/media-picker/type.js
20354
20295
  var MediaUploadStatus;
@@ -20542,92 +20483,414 @@ var media_player_createNamespace = Object(utils["b" /* createNamespace */])('med
20542
20483
  }, ["\u5173\u95ED"])]);
20543
20484
  }
20544
20485
  }));
20545
- // CONCATENATED MODULE: ./node_modules/@egova/util/lib/type-check.js
20546
- // code from: https://segmentfault.com/a/1190000022221464
20486
+ // CONCATENATED MODULE: ./node_modules/@egova-mobile/app-media-utils/dist/index.esm.mjs
20487
+ var __create = Object.create;
20488
+ var __defProp = Object.defineProperty;
20489
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
20490
+ var __getOwnPropNames = Object.getOwnPropertyNames;
20491
+ var __getProtoOf = Object.getPrototypeOf;
20492
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
20493
+ var __commonJS = (cb, mod) => function __require() {
20494
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
20495
+ };
20496
+ var __copyProps = (to, from, except, desc) => {
20497
+ if (from && typeof from === "object" || typeof from === "function") {
20498
+ for (let key of __getOwnPropNames(from))
20499
+ if (!__hasOwnProp.call(to, key) && key !== except)
20500
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20501
+ }
20502
+ return to;
20503
+ };
20504
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20505
+ // If the importer is in node compatibility mode or this is not an ESM
20506
+ // file that has been converted to a CommonJS file using a Babel-
20507
+ // compatible transform (i.e. "__esModule" has not been set), then set
20508
+ // "default" to the CommonJS "module.exports" for node compatibility.
20509
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
20510
+ mod
20511
+ ));
20512
+ var __async = (__this, __arguments, generator) => {
20513
+ return new Promise((resolve, reject) => {
20514
+ var fulfilled = (value) => {
20515
+ try {
20516
+ step(generator.next(value));
20517
+ } catch (e) {
20518
+ reject(e);
20519
+ }
20520
+ };
20521
+ var rejected = (value) => {
20522
+ try {
20523
+ step(generator.throw(value));
20524
+ } catch (e) {
20525
+ reject(e);
20526
+ }
20527
+ };
20528
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
20529
+ step((generator = generator.apply(__this, __arguments)).next());
20530
+ });
20531
+ };
20532
+
20533
+ // ../../node_modules/.pnpm/dayjs@1.11.10/node_modules/dayjs/dayjs.min.js
20534
+ var require_dayjs_min = __commonJS({
20535
+ "../../node_modules/.pnpm/dayjs@1.11.10/node_modules/dayjs/dayjs.min.js"(exports, module) {
20536
+ !function(t, e) {
20537
+ "object" == typeof exports && "undefined" != typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : (t = "undefined" != typeof globalThis ? globalThis : t || self).dayjs = e();
20538
+ }(exports, function() {
20539
+ "use strict";
20540
+ var t = 1e3, e = 6e4, n = 36e5, r = "millisecond", i = "second", s = "minute", u = "hour", a = "day", o = "week", c = "month", f = "quarter", h = "year", d = "date", l = "Invalid Date", $ = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, y = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, M = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(t2) {
20541
+ var e2 = ["th", "st", "nd", "rd"], n2 = t2 % 100;
20542
+ return "[" + t2 + (e2[(n2 - 20) % 10] || e2[n2] || e2[0]) + "]";
20543
+ } }, m = function(t2, e2, n2) {
20544
+ var r2 = String(t2);
20545
+ return !r2 || r2.length >= e2 ? t2 : "" + Array(e2 + 1 - r2.length).join(n2) + t2;
20546
+ }, v = { s: m, z: function(t2) {
20547
+ var e2 = -t2.utcOffset(), n2 = Math.abs(e2), r2 = Math.floor(n2 / 60), i2 = n2 % 60;
20548
+ return (e2 <= 0 ? "+" : "-") + m(r2, 2, "0") + ":" + m(i2, 2, "0");
20549
+ }, m: function t2(e2, n2) {
20550
+ if (e2.date() < n2.date())
20551
+ return -t2(n2, e2);
20552
+ var r2 = 12 * (n2.year() - e2.year()) + (n2.month() - e2.month()), i2 = e2.clone().add(r2, c), s2 = n2 - i2 < 0, u2 = e2.clone().add(r2 + (s2 ? -1 : 1), c);
20553
+ return +(-(r2 + (n2 - i2) / (s2 ? i2 - u2 : u2 - i2)) || 0);
20554
+ }, a: function(t2) {
20555
+ return t2 < 0 ? Math.ceil(t2) || 0 : Math.floor(t2);
20556
+ }, p: function(t2) {
20557
+ return { M: c, y: h, w: o, d: a, D: d, h: u, m: s, s: i, ms: r, Q: f }[t2] || String(t2 || "").toLowerCase().replace(/s$/, "");
20558
+ }, u: function(t2) {
20559
+ return void 0 === t2;
20560
+ } }, g = "en", D = {};
20561
+ D[g] = M;
20562
+ var p = "$isDayjsObject", S = function(t2) {
20563
+ return t2 instanceof _ || !(!t2 || !t2[p]);
20564
+ }, w = function t2(e2, n2, r2) {
20565
+ var i2;
20566
+ if (!e2)
20567
+ return g;
20568
+ if ("string" == typeof e2) {
20569
+ var s2 = e2.toLowerCase();
20570
+ D[s2] && (i2 = s2), n2 && (D[s2] = n2, i2 = s2);
20571
+ var u2 = e2.split("-");
20572
+ if (!i2 && u2.length > 1)
20573
+ return t2(u2[0]);
20574
+ } else {
20575
+ var a2 = e2.name;
20576
+ D[a2] = e2, i2 = a2;
20577
+ }
20578
+ return !r2 && i2 && (g = i2), i2 || !r2 && g;
20579
+ }, O = function(t2, e2) {
20580
+ if (S(t2))
20581
+ return t2.clone();
20582
+ var n2 = "object" == typeof e2 ? e2 : {};
20583
+ return n2.date = t2, n2.args = arguments, new _(n2);
20584
+ }, b = v;
20585
+ b.l = w, b.i = S, b.w = function(t2, e2) {
20586
+ return O(t2, { locale: e2.$L, utc: e2.$u, x: e2.$x, $offset: e2.$offset });
20587
+ };
20588
+ var _ = function() {
20589
+ function M2(t2) {
20590
+ this.$L = w(t2.locale, null, true), this.parse(t2), this.$x = this.$x || t2.x || {}, this[p] = true;
20591
+ }
20592
+ var m2 = M2.prototype;
20593
+ return m2.parse = function(t2) {
20594
+ this.$d = function(t3) {
20595
+ var e2 = t3.date, n2 = t3.utc;
20596
+ if (null === e2)
20597
+ return /* @__PURE__ */ new Date(NaN);
20598
+ if (b.u(e2))
20599
+ return /* @__PURE__ */ new Date();
20600
+ if (e2 instanceof Date)
20601
+ return new Date(e2);
20602
+ if ("string" == typeof e2 && !/Z$/i.test(e2)) {
20603
+ var r2 = e2.match($);
20604
+ if (r2) {
20605
+ var i2 = r2[2] - 1 || 0, s2 = (r2[7] || "0").substring(0, 3);
20606
+ return n2 ? new Date(Date.UTC(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2)) : new Date(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2);
20607
+ }
20608
+ }
20609
+ return new Date(e2);
20610
+ }(t2), this.init();
20611
+ }, m2.init = function() {
20612
+ var t2 = this.$d;
20613
+ this.$y = t2.getFullYear(), this.$M = t2.getMonth(), this.$D = t2.getDate(), this.$W = t2.getDay(), this.$H = t2.getHours(), this.$m = t2.getMinutes(), this.$s = t2.getSeconds(), this.$ms = t2.getMilliseconds();
20614
+ }, m2.$utils = function() {
20615
+ return b;
20616
+ }, m2.isValid = function() {
20617
+ return !(this.$d.toString() === l);
20618
+ }, m2.isSame = function(t2, e2) {
20619
+ var n2 = O(t2);
20620
+ return this.startOf(e2) <= n2 && n2 <= this.endOf(e2);
20621
+ }, m2.isAfter = function(t2, e2) {
20622
+ return O(t2) < this.startOf(e2);
20623
+ }, m2.isBefore = function(t2, e2) {
20624
+ return this.endOf(e2) < O(t2);
20625
+ }, m2.$g = function(t2, e2, n2) {
20626
+ return b.u(t2) ? this[e2] : this.set(n2, t2);
20627
+ }, m2.unix = function() {
20628
+ return Math.floor(this.valueOf() / 1e3);
20629
+ }, m2.valueOf = function() {
20630
+ return this.$d.getTime();
20631
+ }, m2.startOf = function(t2, e2) {
20632
+ var n2 = this, r2 = !!b.u(e2) || e2, f2 = b.p(t2), l2 = function(t3, e3) {
20633
+ var i2 = b.w(n2.$u ? Date.UTC(n2.$y, e3, t3) : new Date(n2.$y, e3, t3), n2);
20634
+ return r2 ? i2 : i2.endOf(a);
20635
+ }, $2 = function(t3, e3) {
20636
+ return b.w(n2.toDate()[t3].apply(n2.toDate("s"), (r2 ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e3)), n2);
20637
+ }, y2 = this.$W, M3 = this.$M, m3 = this.$D, v2 = "set" + (this.$u ? "UTC" : "");
20638
+ switch (f2) {
20639
+ case h:
20640
+ return r2 ? l2(1, 0) : l2(31, 11);
20641
+ case c:
20642
+ return r2 ? l2(1, M3) : l2(0, M3 + 1);
20643
+ case o:
20644
+ var g2 = this.$locale().weekStart || 0, D2 = (y2 < g2 ? y2 + 7 : y2) - g2;
20645
+ return l2(r2 ? m3 - D2 : m3 + (6 - D2), M3);
20646
+ case a:
20647
+ case d:
20648
+ return $2(v2 + "Hours", 0);
20649
+ case u:
20650
+ return $2(v2 + "Minutes", 1);
20651
+ case s:
20652
+ return $2(v2 + "Seconds", 2);
20653
+ case i:
20654
+ return $2(v2 + "Milliseconds", 3);
20655
+ default:
20656
+ return this.clone();
20657
+ }
20658
+ }, m2.endOf = function(t2) {
20659
+ return this.startOf(t2, false);
20660
+ }, m2.$set = function(t2, e2) {
20661
+ var n2, o2 = b.p(t2), f2 = "set" + (this.$u ? "UTC" : ""), l2 = (n2 = {}, n2[a] = f2 + "Date", n2[d] = f2 + "Date", n2[c] = f2 + "Month", n2[h] = f2 + "FullYear", n2[u] = f2 + "Hours", n2[s] = f2 + "Minutes", n2[i] = f2 + "Seconds", n2[r] = f2 + "Milliseconds", n2)[o2], $2 = o2 === a ? this.$D + (e2 - this.$W) : e2;
20662
+ if (o2 === c || o2 === h) {
20663
+ var y2 = this.clone().set(d, 1);
20664
+ y2.$d[l2]($2), y2.init(), this.$d = y2.set(d, Math.min(this.$D, y2.daysInMonth())).$d;
20665
+ } else
20666
+ l2 && this.$d[l2]($2);
20667
+ return this.init(), this;
20668
+ }, m2.set = function(t2, e2) {
20669
+ return this.clone().$set(t2, e2);
20670
+ }, m2.get = function(t2) {
20671
+ return this[b.p(t2)]();
20672
+ }, m2.add = function(r2, f2) {
20673
+ var d2, l2 = this;
20674
+ r2 = Number(r2);
20675
+ var $2 = b.p(f2), y2 = function(t2) {
20676
+ var e2 = O(l2);
20677
+ return b.w(e2.date(e2.date() + Math.round(t2 * r2)), l2);
20678
+ };
20679
+ if ($2 === c)
20680
+ return this.set(c, this.$M + r2);
20681
+ if ($2 === h)
20682
+ return this.set(h, this.$y + r2);
20683
+ if ($2 === a)
20684
+ return y2(1);
20685
+ if ($2 === o)
20686
+ return y2(7);
20687
+ var M3 = (d2 = {}, d2[s] = e, d2[u] = n, d2[i] = t, d2)[$2] || 1, m3 = this.$d.getTime() + r2 * M3;
20688
+ return b.w(m3, this);
20689
+ }, m2.subtract = function(t2, e2) {
20690
+ return this.add(-1 * t2, e2);
20691
+ }, m2.format = function(t2) {
20692
+ var e2 = this, n2 = this.$locale();
20693
+ if (!this.isValid())
20694
+ return n2.invalidDate || l;
20695
+ var r2 = t2 || "YYYY-MM-DDTHH:mm:ssZ", i2 = b.z(this), s2 = this.$H, u2 = this.$m, a2 = this.$M, o2 = n2.weekdays, c2 = n2.months, f2 = n2.meridiem, h2 = function(t3, n3, i3, s3) {
20696
+ return t3 && (t3[n3] || t3(e2, r2)) || i3[n3].slice(0, s3);
20697
+ }, d2 = function(t3) {
20698
+ return b.s(s2 % 12 || 12, t3, "0");
20699
+ }, $2 = f2 || function(t3, e3, n3) {
20700
+ var r3 = t3 < 12 ? "AM" : "PM";
20701
+ return n3 ? r3.toLowerCase() : r3;
20702
+ };
20703
+ return r2.replace(y, function(t3, r3) {
20704
+ return r3 || function(t4) {
20705
+ switch (t4) {
20706
+ case "YY":
20707
+ return String(e2.$y).slice(-2);
20708
+ case "YYYY":
20709
+ return b.s(e2.$y, 4, "0");
20710
+ case "M":
20711
+ return a2 + 1;
20712
+ case "MM":
20713
+ return b.s(a2 + 1, 2, "0");
20714
+ case "MMM":
20715
+ return h2(n2.monthsShort, a2, c2, 3);
20716
+ case "MMMM":
20717
+ return h2(c2, a2);
20718
+ case "D":
20719
+ return e2.$D;
20720
+ case "DD":
20721
+ return b.s(e2.$D, 2, "0");
20722
+ case "d":
20723
+ return String(e2.$W);
20724
+ case "dd":
20725
+ return h2(n2.weekdaysMin, e2.$W, o2, 2);
20726
+ case "ddd":
20727
+ return h2(n2.weekdaysShort, e2.$W, o2, 3);
20728
+ case "dddd":
20729
+ return o2[e2.$W];
20730
+ case "H":
20731
+ return String(s2);
20732
+ case "HH":
20733
+ return b.s(s2, 2, "0");
20734
+ case "h":
20735
+ return d2(1);
20736
+ case "hh":
20737
+ return d2(2);
20738
+ case "a":
20739
+ return $2(s2, u2, true);
20740
+ case "A":
20741
+ return $2(s2, u2, false);
20742
+ case "m":
20743
+ return String(u2);
20744
+ case "mm":
20745
+ return b.s(u2, 2, "0");
20746
+ case "s":
20747
+ return String(e2.$s);
20748
+ case "ss":
20749
+ return b.s(e2.$s, 2, "0");
20750
+ case "SSS":
20751
+ return b.s(e2.$ms, 3, "0");
20752
+ case "Z":
20753
+ return i2;
20754
+ }
20755
+ return null;
20756
+ }(t3) || i2.replace(":", "");
20757
+ });
20758
+ }, m2.utcOffset = function() {
20759
+ return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
20760
+ }, m2.diff = function(r2, d2, l2) {
20761
+ var $2, y2 = this, M3 = b.p(d2), m3 = O(r2), v2 = (m3.utcOffset() - this.utcOffset()) * e, g2 = this - m3, D2 = function() {
20762
+ return b.m(y2, m3);
20763
+ };
20764
+ switch (M3) {
20765
+ case h:
20766
+ $2 = D2() / 12;
20767
+ break;
20768
+ case c:
20769
+ $2 = D2();
20770
+ break;
20771
+ case f:
20772
+ $2 = D2() / 3;
20773
+ break;
20774
+ case o:
20775
+ $2 = (g2 - v2) / 6048e5;
20776
+ break;
20777
+ case a:
20778
+ $2 = (g2 - v2) / 864e5;
20779
+ break;
20780
+ case u:
20781
+ $2 = g2 / n;
20782
+ break;
20783
+ case s:
20784
+ $2 = g2 / e;
20785
+ break;
20786
+ case i:
20787
+ $2 = g2 / t;
20788
+ break;
20789
+ default:
20790
+ $2 = g2;
20791
+ }
20792
+ return l2 ? $2 : b.a($2);
20793
+ }, m2.daysInMonth = function() {
20794
+ return this.endOf(c).$D;
20795
+ }, m2.$locale = function() {
20796
+ return D[this.$L];
20797
+ }, m2.locale = function(t2, e2) {
20798
+ if (!t2)
20799
+ return this.$L;
20800
+ var n2 = this.clone(), r2 = w(t2, e2, true);
20801
+ return r2 && (n2.$L = r2), n2;
20802
+ }, m2.clone = function() {
20803
+ return b.w(this.$d, this);
20804
+ }, m2.toDate = function() {
20805
+ return new Date(this.valueOf());
20806
+ }, m2.toJSON = function() {
20807
+ return this.isValid() ? this.toISOString() : null;
20808
+ }, m2.toISOString = function() {
20809
+ return this.$d.toISOString();
20810
+ }, m2.toString = function() {
20811
+ return this.$d.toUTCString();
20812
+ }, M2;
20813
+ }(), k = _.prototype;
20814
+ return O.prototype = k, [["$ms", r], ["$s", i], ["$m", s], ["$H", u], ["$W", a], ["$M", c], ["$y", h], ["$D", d]].forEach(function(t2) {
20815
+ k[t2[1]] = function(e2) {
20816
+ return this.$g(e2, t2[0], t2[1]);
20817
+ };
20818
+ }), O.extend = function(t2, e2) {
20819
+ return t2.$i || (t2(e2, _, O), t2.$i = true), O;
20820
+ }, O.locale = w, O.isDayjs = S, O.unix = function(t2) {
20821
+ return O(1e3 * t2);
20822
+ }, O.en = D[g], O.Ls = D, O.p = {}, O;
20823
+ });
20824
+ }
20825
+ });
20826
+
20827
+ // ../../node_modules/.pnpm/dayjs@1.11.10/node_modules/dayjs/locale/zh-cn.js
20828
+ var require_zh_cn = __commonJS({
20829
+ "../../node_modules/.pnpm/dayjs@1.11.10/node_modules/dayjs/locale/zh-cn.js"(exports, module) {
20830
+ !function(e, _) {
20831
+ "object" == typeof exports && "undefined" != typeof module ? module.exports = _(require_dayjs_min()) : "function" == typeof define && define.amd ? define(["dayjs"], _) : (e = "undefined" != typeof globalThis ? globalThis : e || self).dayjs_locale_zh_cn = _(e.dayjs);
20832
+ }(exports, function(e) {
20833
+ "use strict";
20834
+ function _(e2) {
20835
+ return e2 && "object" == typeof e2 && "default" in e2 ? e2 : { default: e2 };
20836
+ }
20837
+ var t = _(e), d = { name: "zh-cn", weekdays: "星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"), weekdaysShort: "周日_周一_周二_周三_周四_周五_周六".split("_"), weekdaysMin: "日_一_二_三_四_五_六".split("_"), months: "一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"), monthsShort: "1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"), ordinal: function(e2, _2) {
20838
+ return "W" === _2 ? e2 + "周" : e2 + "日";
20839
+ }, weekStart: 1, yearStart: 4, formats: { LT: "HH:mm", LTS: "HH:mm:ss", L: "YYYY/MM/DD", LL: "YYYY年M月D日", LLL: "YYYY年M月D日Ah点mm分", LLLL: "YYYY年M月D日ddddAh点mm分", l: "YYYY/M/D", ll: "YYYY年M月D日", lll: "YYYY年M月D日 HH:mm", llll: "YYYY年M月D日dddd HH:mm" }, relativeTime: { future: "%s内", past: "%s前", s: "几秒", m: "1 分钟", mm: "%d 分钟", h: "1 小时", hh: "%d 小时", d: "1 天", dd: "%d 天", M: "1 个月", MM: "%d 个月", y: "1 年", yy: "%d 年" }, meridiem: function(e2, _2) {
20840
+ var t2 = 100 * e2 + _2;
20841
+ return t2 < 600 ? "凌晨" : t2 < 900 ? "早上" : t2 < 1100 ? "上午" : t2 < 1300 ? "中午" : t2 < 1800 ? "下午" : "晚上";
20842
+ } };
20843
+ return t.default.locale(d, null, true), d;
20844
+ });
20845
+ }
20846
+ });
20847
+
20848
+ // src/utils/type-check.ts
20547
20849
  function checkDataType(tgt, type) {
20548
- var dataType = Object.prototype.toString.call(tgt).replace(/\[object (\w+)\]/, "$1").toLowerCase();
20850
+ const dataType = Object.prototype.toString.call(tgt).replace(/\[object (\w+)\]/, "$1").toLowerCase();
20549
20851
  return type ? dataType === type : dataType;
20550
20852
  }
20551
20853
  function checkIsUndefined(tgt) {
20552
- return checkDataType(tgt, 'undefined');
20854
+ return checkDataType(tgt, "undefined");
20553
20855
  }
20554
20856
  function checkIsNull(tgt) {
20555
- return checkDataType(tgt, 'null');
20857
+ return checkDataType(tgt, "null");
20556
20858
  }
20557
20859
  function checkIsUndefinedOrNull(tgt) {
20558
20860
  return checkIsUndefined(tgt) || checkIsNull(tgt);
20559
20861
  }
20560
- function checkIsNumber(tgt) {
20561
- return checkDataType(tgt, 'number');
20562
- }
20563
20862
  function checkIsString(tgt) {
20564
- return checkDataType(tgt, 'string');
20863
+ return checkDataType(tgt, "string");
20565
20864
  }
20566
20865
  function checkIsStringValid(tgt) {
20567
- if (checkDataType(tgt, 'string')) {
20568
- return tgt !== '';
20866
+ if (checkDataType(tgt, "string")) {
20867
+ return tgt !== "";
20569
20868
  } else {
20570
20869
  return false;
20571
20870
  }
20572
20871
  }
20573
- function checkIsBoolean(tgt) {
20574
- return checkDataType(tgt, 'boolean');
20575
- }
20576
- function checkIsSymbol(tgt) {
20577
- return checkDataType(tgt, 'symbol');
20578
- }
20579
- function checkIsObject(tgt) {
20580
- return checkDataType(tgt, 'object');
20581
- }
20582
- function checkIsArray(tgt) {
20583
- return checkDataType(tgt, 'array');
20584
- }
20585
- function checkIsFunction(tgt) {
20586
- return checkDataType(tgt, 'function');
20587
- }
20588
- function checkIsDate(tgt) {
20589
- return checkDataType(tgt, 'date');
20590
- }
20591
20872
  function checkIsRegExp(tgt) {
20592
- return checkDataType(tgt, 'regexp');
20873
+ return checkDataType(tgt, "regexp");
20593
20874
  }
20594
- function checkIsError(tgt) {
20595
- return checkDataType(tgt, 'error');
20596
- }
20597
- // CONCATENATED MODULE: ./node_modules/@egova/util/lib/type-parse.js
20598
- /**
20599
- * 解析整数
20600
- * @param obj, 输入字符串
20601
- * @param defaultValue,默认值
20602
- */
20603
- function parseInteger(obj, defaultValue) {
20604
- var result = parseInt(obj, 10);
20605
20875
 
20876
+ // src/utils/type-parse.ts
20877
+ function parseInteger(obj, defaultValue) {
20878
+ let result = parseInt(obj, 10);
20606
20879
  if (isNaN(result)) {
20607
20880
  result = defaultValue || 0;
20608
20881
  }
20609
-
20610
20882
  return result;
20611
20883
  }
20612
- /**
20613
- * 解析小数
20614
- * @param obj, 输入字符串
20615
- * @param defaultValue,默认值
20616
- */
20617
-
20618
20884
  function parseDecimal(obj, defaultValue) {
20619
- var result = parseFloat(obj);
20620
-
20885
+ let result = parseFloat(obj);
20621
20886
  if (isNaN(result)) {
20622
20887
  result = defaultValue || 0;
20623
20888
  }
20624
-
20625
20889
  return result;
20626
20890
  }
20627
- // CONCATENATED MODULE: ./node_modules/@egova/util/lib/date.js
20628
20891
 
20629
- var date_weekList = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
20630
- var date_FORMAT = {
20892
+ // src/utils/date.ts
20893
+ var index_esm_FORMAT = {
20631
20894
  //英文简写如:12:01
20632
20895
  FORMAT_HM: "HH:mm",
20633
20896
  //英文简写如:1-12 12:01
@@ -20661,325 +20924,42 @@ var date_FORMAT = {
20661
20924
  FORMAT_YMDHMS_CN: "yyyy年MM月dd日 HH时mm分ss秒"
20662
20925
  };
20663
20926
 
20664
- var date_formatNumber_ = function __formatNumber__(number) {
20665
- if (number < 10) {
20666
- return "0" + number;
20667
- }
20668
-
20669
- return number + "";
20670
- };
20671
- /**
20672
- * 创建 Date对象
20673
- * @param dateObj 可传入:
20674
- * 1. number格式的timestamp;
20675
- * 2. string格式的日期字符串
20676
- * 3. Date对象将原封不动的返回
20677
- * @returns {null|Date|*}
20678
- */
20679
-
20680
-
20681
- function createDate(dateObj) {
20682
- if (checkIsUndefinedOrNull(dateObj)) {
20683
- return null;
20684
- }
20685
-
20686
- if (typeof dateObj === 'number') {
20687
- return new Date(dateObj);
20688
- } // IOS无法解析'2018-01-02'这种格式,需要替换为'2018/01/02'
20689
-
20690
-
20691
- if (typeof dateObj === 'string') {
20692
- dateObj = dateObj.replace(/-/g, '/');
20693
-
20694
- if (dateObj.length === 7) {
20695
- // 只有月份的日期ios无法解析,例如 2021/06 , 需转换成2021/06/01
20696
- dateObj += "/01";
20697
- }
20698
-
20699
- return new Date(dateObj);
20700
- }
20701
-
20702
- if (checkIsDate(dateObj)) {
20703
- return dateObj;
20704
- }
20705
-
20706
- return null;
20707
- }
20708
- function date_formatDate(dateObj, formatType) {
20709
- if (formatType === void 0) {
20710
- formatType = date_FORMAT.FORMAT_YMDHMS;
20711
- }
20712
-
20713
- var date = createDate(dateObj);
20714
-
20715
- if (date) {
20716
- date.getFullYear();
20717
- var formatResult = formatType.replace("yyyy", date_formatNumber_(date.getFullYear()));
20718
- formatResult = formatResult.replace("yy", String(date.getFullYear()).substring(2));
20719
- formatResult = formatResult.replace("MM", date_formatNumber_(date.getMonth() + 1));
20720
- formatResult = formatResult.replace("dd", date_formatNumber_(date.getDate()));
20721
- formatResult = formatResult.replace("HH", date_formatNumber_(date.getHours()));
20722
- formatResult = formatResult.replace("mm", date_formatNumber_(date.getMinutes()));
20723
- formatResult = formatResult.replace("ss", date_formatNumber_(date.getSeconds()));
20724
- formatResult = formatResult.replace("msms", date_formatNumber_(date.getMilliseconds()));
20725
- return formatResult;
20726
- } else {
20727
- return null;
20728
- }
20729
- }
20730
- // CONCATENATED MODULE: ./node_modules/@egova/util/lib/system-check.js
20927
+ // src/utils/system-check.ts
20731
20928
  function checkIsAndroid() {
20732
- /* istanbul ignore next */
20733
20929
  return /android/.test(navigator.userAgent.toLowerCase());
20734
20930
  }
20735
20931
  function checkIsIOS() {
20736
- /* istanbul ignore next */
20737
20932
  return /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase());
20738
20933
  }
20739
- function checkIsMacOS() {
20740
- return navigator.platform.indexOf('Mac') > -1;
20741
- }
20742
20934
  function checkIsWindows() {
20743
- return navigator.platform.indexOf('Win') > -1;
20935
+ return navigator.platform.indexOf("Win") > -1;
20744
20936
  }
20745
- // CONCATENATED MODULE: ./node_modules/@egova/util/lib/index.js
20746
- // Replace the contents of this file with your own exported values.
20747
-
20748
-
20749
-
20750
-
20751
- // EXTERNAL MODULE: ./node_modules/dayjs/locale/zh-cn.js
20752
- var zh_cn = __webpack_require__(11);
20753
-
20754
- // CONCATENATED MODULE: ./node_modules/@egova/media/lib/watermark.js
20755
- /**
20756
- * 水印配置 {@link http://faq.egova.com.cn:7777/projects/redmine/wiki/%E6%8B%8D%E7%85%A7%E6%B0%B4%E5%8D%B0%E9%85%8D%E7%BD%AE|文档}
20757
- * @description 水印渲染类
20758
- * @author Jiaji Yin
20759
- * @date 2021-11-05
20760
- */
20761
- var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
20762
- function adopt(value) {
20763
- return value instanceof P ? value : new P(function (resolve) {
20764
- resolve(value);
20765
- });
20766
- }
20767
-
20768
- return new (P || (P = Promise))(function (resolve, reject) {
20769
- function fulfilled(value) {
20770
- try {
20771
- step(generator.next(value));
20772
- } catch (e) {
20773
- reject(e);
20774
- }
20775
- }
20776
-
20777
- function rejected(value) {
20778
- try {
20779
- step(generator["throw"](value));
20780
- } catch (e) {
20781
- reject(e);
20782
- }
20783
- }
20784
-
20785
- function step(result) {
20786
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
20787
- }
20788
-
20789
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20790
- });
20791
- };
20792
-
20793
- var __generator = undefined && undefined.__generator || function (thisArg, body) {
20794
- var _ = {
20795
- label: 0,
20796
- sent: function sent() {
20797
- if (t[0] & 1) throw t[1];
20798
- return t[1];
20799
- },
20800
- trys: [],
20801
- ops: []
20802
- },
20803
- f,
20804
- y,
20805
- t,
20806
- g;
20807
- return g = {
20808
- next: verb(0),
20809
- "throw": verb(1),
20810
- "return": verb(2)
20811
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
20812
- return this;
20813
- }), g;
20814
20937
 
20815
- function verb(n) {
20816
- return function (v) {
20817
- return step([n, v]);
20818
- };
20819
- }
20820
-
20821
- function step(op) {
20822
- if (f) throw new TypeError("Generator is already executing.");
20823
-
20824
- while (_) {
20825
- try {
20826
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
20827
- if (y = 0, t) op = [op[0] & 2, t.value];
20828
-
20829
- switch (op[0]) {
20830
- case 0:
20831
- case 1:
20832
- t = op;
20833
- break;
20834
-
20835
- case 4:
20836
- _.label++;
20837
- return {
20838
- value: op[1],
20839
- done: false
20840
- };
20841
-
20842
- case 5:
20843
- _.label++;
20844
- y = op[1];
20845
- op = [0];
20846
- continue;
20847
-
20848
- case 7:
20849
- op = _.ops.pop();
20850
-
20851
- _.trys.pop();
20852
-
20853
- continue;
20854
-
20855
- default:
20856
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
20857
- _ = 0;
20858
- continue;
20859
- }
20860
-
20861
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
20862
- _.label = op[1];
20863
- break;
20864
- }
20865
-
20866
- if (op[0] === 6 && _.label < t[1]) {
20867
- _.label = t[1];
20868
- t = op;
20869
- break;
20870
- }
20871
-
20872
- if (t && _.label < t[2]) {
20873
- _.label = t[2];
20874
-
20875
- _.ops.push(op);
20876
-
20877
- break;
20878
- }
20879
-
20880
- if (t[2]) _.ops.pop();
20881
-
20882
- _.trys.pop();
20883
-
20884
- continue;
20885
- }
20886
-
20887
- op = body.call(thisArg, _);
20888
- } catch (e) {
20889
- op = [6, e];
20890
- y = 0;
20891
- } finally {
20892
- f = t = 0;
20893
- }
20894
- }
20895
-
20896
- if (op[0] & 5) throw op[1];
20897
- return {
20898
- value: op[0] ? op[1] : void 0,
20899
- done: true
20900
- };
20901
- }
20902
- };
20903
-
20904
-
20905
-
20906
-
20907
- dayjs_min_default.a.locale("zh-cn");
20908
- var WatermarkImageEnum;
20909
-
20910
- (function (WatermarkImageEnum) {
20911
- WatermarkImageEnum[WatermarkImageEnum["POSITION_LEFT"] = 0] = "POSITION_LEFT";
20912
- WatermarkImageEnum[WatermarkImageEnum["POSITION_RIGHT"] = 1] = "POSITION_RIGHT";
20913
- })(WatermarkImageEnum || (WatermarkImageEnum = {}));
20914
-
20915
- var Point = function () {
20916
- function Point(x, y) {
20938
+ // src/image/watermark.ts
20939
+ var import_dayjs = __toESM(require_dayjs_min());
20940
+ var import_zh_cn = __toESM(require_zh_cn());
20941
+ import_dayjs.default.locale("zh-cn");
20942
+ var Point = class {
20943
+ constructor(x, y) {
20917
20944
  this.x = x;
20918
20945
  this.y = y;
20919
20946
  }
20920
-
20921
- return Point;
20922
- }();
20923
-
20924
- var Size = function () {
20925
- function Size(width, height) {
20947
+ };
20948
+ var Size = class {
20949
+ constructor(width, height) {
20926
20950
  this.width = width;
20927
20951
  this.height = height;
20928
20952
  }
20929
-
20930
- return Size;
20931
- }();
20932
-
20933
- var clamp = function clamp(value, min, max) {
20934
- return Math.min(Math.max(value, min), max);
20935
20953
  };
20936
-
20937
- var watermark_subString = function subString(str, startIndex, length) {
20954
+ var clamp = (value, min, max) => Math.min(Math.max(value, min), max);
20955
+ var subString = (str, startIndex, length) => {
20938
20956
  if (checkIsUndefinedOrNull(length)) {
20939
20957
  return str.substring(startIndex);
20940
20958
  } else {
20941
20959
  return str.substring(startIndex, startIndex + length);
20942
20960
  }
20943
20961
  };
20944
- /**
20945
- * {@link http://faq.egova.com.cn:7777/files/ueditor/image/20180621/1529574697677847.png|水印位置图}
20946
- */
20947
-
20948
-
20949
- var WatermarkPosition;
20950
-
20951
- (function (WatermarkPosition) {
20952
- WatermarkPosition["LeftTop"] = "lefttop";
20953
- WatermarkPosition["CenterTop"] = "centertop";
20954
- WatermarkPosition["RightTop"] = "righttop";
20955
- WatermarkPosition["LeftCenter"] = "leftcenter";
20956
- WatermarkPosition["Center"] = "center";
20957
- WatermarkPosition["RightCenter"] = "rightcenter";
20958
- WatermarkPosition["LeftBottom"] = "leftbottom";
20959
- WatermarkPosition["CenterBottom"] = "centerbottom";
20960
- WatermarkPosition["RightBottom"] = "rightbottom";
20961
- })(WatermarkPosition || (WatermarkPosition = {}));
20962
-
20963
- var WatermarkFontWeight;
20964
-
20965
- (function (WatermarkFontWeight) {
20966
- WatermarkFontWeight["Normal"] = "normal";
20967
- WatermarkFontWeight["Bold"] = "bold";
20968
- })(WatermarkFontWeight || (WatermarkFontWeight = {}));
20969
-
20970
20962
  var DEFAULT_ADDRESS_ICON = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAAAXNSR0IArs4c6QAACjpJREFUeF7tnQGO2zgMRe2TtT1Z25Nte7IsFNitG9iJKUvWJ/kGKHYwKznRp54+KTnOPPGDAihwqMCMNiiAAscKAAizAwXeKAAgTA8UABDmAArUKYCD1OlGryQKAEiSQDPMOgUApE43eiVRAECSBJph1ikAIHW60SuJAgCSJNAMs04BAKnTjV5JFACQJIFmmHUKAEidbvRKogCAJAk0w6xTAEDqdKNXEgUAJEmgGWadAgBSpxu9kigAIEkCzTDrFACQOt3olUQBAEkSaIZZpwCA1OlGryQKAEiSQDPMOgUApE43eiVRAECSBJph1ikAIHW6mXs9Ho+v0zSVf+vPl83v27+vf/618yK/p2l6/n2e573/b35fdHivAIB0mCEbGAoEe5O/1auukDzBAZpWsv69DoA00vTxePxYLvW90SVrL1Og+YnL1Mr3bz8AuaDjAsVoIN6N4AkLzlIfZAAxaifkFMZ3/qxdgMWoGoCcFMyBW5wcybNZAWVNCS390rUFkA8hDwbG62gB5UP8AeRAoOBgAMpJLwSQF6GSgfE6Tb5R0LOLdbh2JIdj1YVifjNDcJBpmgBjd82gPil3LJxMxcI2ezwe/3U+7fasXXo3SQsIrmHiNm1tkhIQ4DDBsTZOmXKlAwQ4quD4U8DP8/zt0hWcdU4FCPVGk9lZ7hpOA0kKQJbbz0sxzk8bBdIU7+EBAY42RBxcJXzxHhoQ4OgKx3rx0JCEBQQ4boEjPCSRAeEA8EZG5nkOOZdCDordqhvJ+PtSIXe3wgECHEPgCHuYGAoQDgGHwhESkjCAUJRLwBEOkhCAAIcUHM83E6VojwIIO1Z6jIQo2t0DQt2hR8bmHbm/A9g1IKRW0nCEqEe8A0Jqpc+I61TLLSCkVvpkREi1PAPycDVF3r/Z7VPaP30tgsthe93VcgmIc/d4Pnnd8nUFS61V+pQHZff8OoWe8Lks2N0B4rQwL1A0+/6ORYP1qfJugPHoIh4B8VKYr9/R0fUh0RtYPIDizkVcAeLIPW6fCF5A8eYi3gBRd4/bwXgtGhzUZ8M1shRa3gBR3bmS2+tXvu3fk4u4AUR4ZZRdEdHM4hX7bT0BougesnCs4VaFxIuLuABEtDiXh0McEhf6eQFErTh3Edxt0iDoJC409AKIUnrlIrB7GbUaJB7SLHlAxNIrud0qaxkqBon8YuMBEJX0yj0cm5pERVMAsa5wOwdfKulVmEdsKrmyepol7SBCgZRf6awLkVCqJb3wqANSbvRb71q1zoFm7dVXudqBPh4PBXeWXnzUAVHIlaUDWAtH6SfiItK1nTogw1e4qO6xKdjR+M0qIwuISP0hnR9fcQ+xU3ZZnQHk3eoR9JH+gjuFsmmsMiCjC3Tp3LiFewi5CIBYAyrweQZZ27dq+am9QLEuuxgpO8joHaw0gCw7WiOLdQD5tIqJ5cWyAbPqeLb9aMdW3S2UdBCBHSzZnPjshLe2G51mAYghYgKApEqvlhSrPDaopLWjfiQ1x0H2p4NksHrOXBalfXUBBED+KDD43izJRQlAdgBRzYd7OojATpZk3acKyNBDQgDpjeLu9QHkrOyDd1TSbfFuTtRHnj0BCICcVWBMu8FnIQByNuyDHSTMVxif1RsHOVaKGoQiXWUXCwc5u6KN3pOnSD8bqabt2OY9K+doQKZpkgzWWf1q2qE5B4WWeQMgFrXatJXUXLUGGX1fkGQ+3GYe7l8FB3HkIJzq9kThEJCRZyCyO4eSDiIAiGzAeqEz+D4sWb2VARm6ok3TlCbNEkivZO9eUAZk6P1YyQAZvRgBiDU1GH2aXt5vlvOQ0emV8mKEg7wnN3yaJZBelQhIbvE+F0nryn5ne1a2/moPvkHxOUBlp1YHZHRuXOIX1kVE3EO2/vDgIKMLdfkV7orHKLjHNE0AUhtEhUJ9ee/hXETEPaTrD3kHUTgwXOFWzpNrFiAR9wCQmuBt+wgFMoyLCDmzdHrlxUEk6pAoqZYQHPLu4QIQpTTLOyRCdceaJMief/xJra+mQHf0F0qz3AT2NS6CcMinV54cRCnNKrq5CK5oLedqkZE+KHwJ8MjvrzgySvkUQdA5AKRH2iVWXG6HKLu7JayZGwf25CBqaZY0JMJwuNi9clWkr29WPOi/lvu2yn+H/qjrNM/zt6ECGV7cjYMs273KLrLKPizlEgfDVe3h0kEEz0TerUW3geIEDJe7f64cxJGLrOCs6VaBpWnqtexOlccjfTdkDKObyu/6vQrkDpAFEoXPiVgn22VYFqcor+sJij+Lhafaw22K5dBFjkDaOsrvcvi4aVicYf35svyy/ZsVToX27tyjiObSQQJBojBx73gPbs49QqRY6yAEPrN+x+SK8Bou3cO1g+Aibri5bTevhyJuU6yNi3gs2HvEUvGablMr10X6diYI34ynOGHvfk9uU6swgJBq3T3nT7+e69QqFCBAcnrS3tXQfWoVDpAFEsXPjNw1KVVeJwwc7nexXmcE9YgEI+7rjq2K7nexdiDxcMevxEzu8CZCwRHOQTZbv0DSYfZ/uGSIovx1jOEcBEjuJyPyA77DAsLO1m2ghHSOkLtYe1PC0YeJbpvRDV8oNBxhaxAK94YIHF8qPBxpACHdag5MCjhSAQIkzSBJA0c6QIDkMiSp4EgJCJBUQ5IOjrSAAIkZkpRwpAYESE5DkhaO9IAAyUdIUsMBIMv84DBxF5T0cADIZl4AyT+QAMciR+h7sT4mEC8NBL/qzTqEFu1DfeDpqiAAAiRbBYDjZT4AyM4Sk9RJgGNnLgDIgQcngwQ4DuYBgLxJUpNAAhxv5gCAfKjigkMCHB/iDyAntjmCQgIcJ2IPICdEWk7cIz0DGDhOxh1ATgoVCBLgMMQcQAxiBYAEOIzxBhCjYI4hAY6KWANIhWgOIQGOyjgDSKVwjiABjgsxBpAL4jmABDguxhdALgooDAlwNIgtgDQQURAS4GgUVwBpJKQQJMDRMKYA0lBMAUiAo3E8AaSxoAMhAY4OsQSQDqIOgAQ4OsURQDoJeyMkwNExhgDSUdwbIAGOzvEDkM4Cd/7m3XBfmtk5HObLA4hZMnuHTpAAhz0U5h4AYpasrkNjSICjLgzmXgBilqy+QyNIgKM+BOaeAGKW7FqHi5AAxzX5zb0BxCzZ9Q6VkADHdenNVwAQs2RtOhghAY42spuvAiBmydp1WCD5Pk3T14Or8pT1dnJXXQlAqmRr22kDSrlwgeVn+WWe5x9tX4mrWRUAEKtitE+lAICkCjeDtSoAIFbFaJ9KAQBJFW4Ga1UAQKyK0T6VAgCSKtwM1qoAgFgVo30qBQAkVbgZrFUBALEqRvtUCgBIqnAzWKsCAGJVjPapFACQVOFmsFYFAMSqGO1TKQAgqcLNYK0KAIhVMdqnUgBAUoWbwVoVABCrYrRPpQCApAo3g7UqACBWxWifSgEASRVuBmtVAECsitE+lQIAkircDNaqAIBYFaN9KgUAJFW4GaxVAQCxKkb7VAr8D3T7HgXIMUYQAAAAAElFTkSuQmCC";
20971
- var WatermarkContent;
20972
-
20973
- (function (WatermarkContent) {
20974
- WatermarkContent["Raw"] = "";
20975
- WatermarkContent["Date"] = "date{(.*?)}|date";
20976
- WatermarkContent["Time"] = "time";
20977
- WatermarkContent["Address"] = "address";
20978
- WatermarkContent["HumanName"] = "humanname";
20979
- WatermarkContent["ProjectName"] = "projectName";
20980
- WatermarkContent["ApplicationName"] = "applicationName";
20981
- })(WatermarkContent || (WatermarkContent = {}));
20982
-
20983
20963
  var ColorMap = {
20984
20964
  transparent: "#00000000",
20985
20965
  white: "#FFFFFF",
@@ -21007,27 +20987,22 @@ var ColorMap = {
21007
20987
  teal: "#008080",
21008
20988
  orange: "#FF9933"
21009
20989
  };
21010
-
21011
20990
  function getColorValue(key) {
21012
- for (var _i = 0, _a = Object.getOwnPropertyNames(ColorMap); _i < _a.length; _i++) {
21013
- var k = _a[_i];
21014
-
20991
+ for (const k of Object.getOwnPropertyNames(ColorMap)) {
21015
20992
  if (k === key) {
21016
20993
  return ColorMap[k];
21017
20994
  }
21018
20995
  }
21019
-
21020
20996
  return null;
21021
20997
  }
21022
-
21023
20998
  var CONTENT_PADDING = 10;
21024
20999
  var DEFAULT_PADDING = 2;
21025
- var DEFAULT_FONT_SIZE = 25.0;
21026
- var DEFAULT_CANVAS_SIZE = 480.0;
21000
+ var DEFAULT_FONT_SIZE = 25;
21001
+ var DEFAULT_CANVAS_SIZE = 480;
21027
21002
  var DEFAULT_BACKGROUND_OPACITY = 128;
21028
21003
  var LOGO_DEFAULT_PADDING = 4;
21029
-
21030
- var WatermarkStyle = function () {
21004
+ var WatermarkStyle = class {
21005
+ //是否是简化配置
21031
21006
  /**
21032
21007
  * Watermark Style
21033
21008
  * @param fontName
@@ -21042,7 +21017,7 @@ var WatermarkStyle = function () {
21042
21017
  * @param scale
21043
21018
  * @param simplified
21044
21019
  */
21045
- function WatermarkStyle(fontName, fontWeight, fontColor, fontSize, backgroundColor, backgroundOpacity, paddingTop, paddingBottom, position, scale, simplified) {
21020
+ constructor(fontName, fontWeight, fontColor, fontSize, backgroundColor, backgroundOpacity, paddingTop, paddingBottom, position, scale, simplified) {
21046
21021
  this.fontName = fontName;
21047
21022
  this.fontWeight = fontWeight;
21048
21023
  this.fontColor = fontColor;
@@ -21055,53 +21030,28 @@ var WatermarkStyle = function () {
21055
21030
  this.scale = scale;
21056
21031
  this.simplified = simplified;
21057
21032
  }
21058
-
21059
- return WatermarkStyle;
21060
- }();
21061
-
21062
- var WatermarkImage = function () {
21063
- function WatermarkImage(image, width, height, position) {
21064
- if (image === void 0) {
21065
- image = "";
21066
- }
21067
-
21068
- if (width === void 0) {
21069
- width = 20;
21070
- }
21071
-
21072
- if (height === void 0) {
21073
- height = 20;
21074
- }
21075
-
21076
- if (position === void 0) {
21077
- position = WatermarkImageEnum.POSITION_LEFT;
21078
- }
21079
-
21033
+ };
21034
+ var WatermarkImage = class {
21035
+ constructor(image = "", width = 20, height = 20, position = 0 /* POSITION_LEFT */) {
21080
21036
  this.image = image;
21081
21037
  this.width = width;
21082
21038
  this.height = height;
21083
21039
  this.position = position;
21084
21040
  }
21085
-
21086
- return WatermarkImage;
21087
- }();
21088
-
21089
- var Watermark = function () {
21041
+ };
21042
+ var Watermark = class {
21090
21043
  /**
21091
21044
  * 水印对象,包含需要渲染的文本、图像,以及相应的style
21092
21045
  * @param content
21093
21046
  * @param watermarkStyle
21094
21047
  */
21095
- function Watermark(content, watermarkStyle, watermarkImage) {
21048
+ constructor(content, watermarkStyle, watermarkImage) {
21096
21049
  this.content = content;
21097
21050
  this.style = watermarkStyle;
21098
21051
  this.watermarkImage = watermarkImage;
21099
21052
  }
21100
-
21101
- return Watermark;
21102
- }();
21103
-
21104
- var WatermarkContext = function () {
21053
+ };
21054
+ var WatermarkContext = class {
21105
21055
  /**
21106
21056
  * 打水印需要的环境信息
21107
21057
  * @param address
@@ -21110,406 +21060,346 @@ var WatermarkContext = function () {
21110
21060
  * @param projectName
21111
21061
  * @param logo
21112
21062
  */
21113
- function WatermarkContext(params) {
21063
+ constructor(params) {
21114
21064
  this.address = params.address;
21115
21065
  this.watermarkTime = params.watermarkTime;
21116
21066
  this.humanName = params.humanName;
21117
21067
  this.projectName = params.projectName;
21118
21068
  this.logo = params.logo;
21119
21069
  this.applicationName = params.applicationName;
21070
+ this.pixel = params.pixel;
21071
+ this.width = params.width;
21072
+ this.height = params.height;
21120
21073
  }
21121
-
21122
- return WatermarkContext;
21123
- }();
21124
-
21125
-
21126
-
21127
- var WatermarkOptions = function () {
21074
+ };
21075
+ var WatermarkOptions = class {
21128
21076
  /**
21129
21077
  * 水印配置项
21130
21078
  * @param enabled, 是否开启水印
21131
21079
  * @param watermarkConfigString,水印配置的字符串
21132
21080
  * @param context,打水印需要的环境信息
21133
21081
  */
21134
- function WatermarkOptions(params) {
21082
+ constructor(params) {
21135
21083
  this.enabled = params.enabled;
21136
21084
  this.watermarkConfigString = params.watermarkConfigString;
21137
21085
  this.context = params.context;
21138
21086
  }
21139
-
21140
- return WatermarkOptions;
21141
- }();
21142
-
21143
-
21144
- /**
21145
- * 画水印默认使用黑体
21146
- * @see {@link https://www.zhihu.com/question/19911793|使用黑体}
21147
- */
21148
-
21149
- function getHeitiFontFamily(fontFamily) {
21150
- if (fontFamily === void 0) {
21151
- fontFamily = "";
21152
- }
21153
-
21154
- var defaultFontFamily;
21155
-
21087
+ };
21088
+ function getHeitiFontFamily(fontFamily = "") {
21089
+ let defaultFontFamily;
21156
21090
  if (checkIsWindows()) {
21157
- // ios对黑体的行高绘制有问题
21158
21091
  if (fontFamily.includes("黑体")) {
21159
21092
  fontFamily = "";
21160
21093
  }
21161
-
21162
21094
  defaultFontFamily = "'Roboto Black', 'Droid Sans'";
21163
21095
  } else if (checkIsIOS()) {
21164
- // ios对黑体的行高绘制有问题
21165
21096
  if (fontFamily.includes("黑体")) {
21166
21097
  fontFamily = "";
21167
21098
  }
21168
-
21169
21099
  defaultFontFamily = "'PingFang SC Medium'";
21170
21100
  } else if (checkIsAndroid()) {
21171
21101
  defaultFontFamily = "'Roboto Black', 'Droid Sans'";
21172
21102
  } else {
21173
21103
  defaultFontFamily = '"PingFang SC Medium", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif';
21174
21104
  }
21175
-
21176
- return fontFamily ? fontFamily + ", " + defaultFontFamily : defaultFontFamily;
21105
+ return fontFamily ? `${fontFamily}, ${defaultFontFamily}` : defaultFontFamily;
21177
21106
  }
21178
-
21179
21107
  function parseWatermarkStyle(styleString, canvasSize) {
21180
21108
  if (!checkIsStringValid(styleString)) {
21181
21109
  return null;
21182
21110
  }
21183
-
21184
- var styleParts = styleString.split("$");
21185
-
21111
+ const styleParts = styleString.split("$");
21186
21112
  if (styleParts.length <= 0) {
21187
21113
  return null;
21188
21114
  }
21189
-
21190
- var scale = Math.min(canvasSize.width, canvasSize.height) / DEFAULT_CANVAS_SIZE;
21191
- /**
21192
- 1. 20190314版本开始可以使用简化版配置,格式为[文字大小]$[水印位置]$[上下padding]*#*[水印内容] 其中[上下padding]一般不设置,如需设置,格式为"上padding_下padding",下padding可省略
21193
- 2. 简化版配置使用条件:字体(黑体)、字体样式(normal)、文字颜色(transparent)、背景颜色(transparent)、背景不透明度(128)全部使用默认值(括号中的值)
21194
- */
21195
-
21115
+ const scale = Math.min(canvasSize.width, canvasSize.height) / DEFAULT_CANVAS_SIZE;
21196
21116
  if (parseInteger(styleParts[0], -1) !== -1) {
21197
- // 第一项为数字,则为新的简化配置
21198
- var fontSize = Math.round(parseDecimal(styleParts[0], DEFAULT_FONT_SIZE) * scale);
21199
- var position = WatermarkPosition.LeftTop;
21200
-
21117
+ const fontSize = Math.round(
21118
+ parseDecimal(styleParts[0], DEFAULT_FONT_SIZE) * scale
21119
+ );
21120
+ let position = "lefttop" /* LeftTop */;
21201
21121
  if (styleParts[1]) {
21202
21122
  position = styleParts[1];
21203
21123
  }
21204
-
21205
- var paddingTop = DEFAULT_PADDING * scale;
21206
- var paddingBottom = DEFAULT_PADDING * scale;
21207
-
21124
+ let paddingTop = DEFAULT_PADDING * scale;
21125
+ let paddingBottom = DEFAULT_PADDING * scale;
21208
21126
  if (styleParts[2]) {
21209
- var paddingParts = styleParts[2].split("_");
21127
+ const paddingParts = styleParts[2].split("_");
21210
21128
  paddingTop = parseInteger(paddingParts[0], DEFAULT_PADDING) * scale;
21211
-
21212
21129
  if (paddingParts[1]) {
21213
21130
  paddingBottom = parseInteger(paddingParts[1], DEFAULT_PADDING) * scale;
21214
21131
  }
21215
21132
  }
21216
-
21217
- var fontName = getHeitiFontFamily();
21218
- var fontWeight = WatermarkFontWeight.Normal;
21219
- var fontColor = ColorMap.transparent;
21220
- var backgroundColor = ColorMap.transparent;
21221
- var backgroundOpacity = 128;
21222
- return new WatermarkStyle(fontName, fontWeight, fontColor, fontSize, backgroundColor, backgroundOpacity, paddingTop, paddingBottom, position, scale, true);
21133
+ const fontName = getHeitiFontFamily();
21134
+ const fontWeight = "normal" /* Normal */;
21135
+ const fontColor = ColorMap.transparent;
21136
+ const backgroundColor = ColorMap.transparent;
21137
+ const backgroundOpacity = 128;
21138
+ return new WatermarkStyle(
21139
+ fontName,
21140
+ fontWeight,
21141
+ fontColor,
21142
+ fontSize,
21143
+ backgroundColor,
21144
+ backgroundOpacity,
21145
+ paddingTop,
21146
+ paddingBottom,
21147
+ position,
21148
+ scale,
21149
+ true
21150
+ );
21223
21151
  } else {
21224
- // [字体]$[文字样式]$[文字颜色]$[文字大小]$[背景颜色]$[水印位置]$[背景不透明度]$[上下padding]*#*[水印内容]
21225
- var fontName = getHeitiFontFamily(styleParts[0]);
21226
- var fontWeight = WatermarkFontWeight.Normal;
21227
-
21152
+ const fontName = getHeitiFontFamily(styleParts[0]);
21153
+ let fontWeight = "normal" /* Normal */;
21228
21154
  if (styleParts[1]) {
21229
21155
  fontWeight = styleParts[1];
21230
21156
  }
21231
-
21232
- var fontColor = ColorMap.white;
21233
-
21157
+ let fontColor = ColorMap.white;
21234
21158
  if (styleParts[2]) {
21235
- var color = getColorValue(styleParts[2]);
21236
-
21159
+ const color = getColorValue(styleParts[2]);
21237
21160
  if (color) {
21238
21161
  fontColor = color;
21239
21162
  }
21240
21163
  }
21241
-
21242
- var fontSize = Math.round(DEFAULT_FONT_SIZE * scale);
21243
-
21164
+ let fontSize = Math.round(DEFAULT_FONT_SIZE * scale);
21244
21165
  if (styleParts[3]) {
21245
- fontSize = Math.round(parseDecimal(styleParts[3], DEFAULT_FONT_SIZE) * scale);
21166
+ fontSize = Math.round(
21167
+ parseDecimal(styleParts[3], DEFAULT_FONT_SIZE) * scale
21168
+ );
21246
21169
  }
21247
-
21248
- var backgroundColor = ColorMap.blue;
21249
-
21170
+ let backgroundColor = ColorMap.blue;
21250
21171
  if (styleParts[4]) {
21251
- var color = getColorValue(styleParts[4]);
21252
-
21172
+ const color = getColorValue(styleParts[4]);
21253
21173
  if (color) {
21254
21174
  backgroundColor = color;
21255
21175
  }
21256
21176
  }
21257
-
21258
- var position = WatermarkPosition.LeftTop;
21259
-
21177
+ let position = "lefttop" /* LeftTop */;
21260
21178
  if (styleParts[5]) {
21261
21179
  position = styleParts[5];
21262
21180
  }
21263
-
21264
- var backgroundOpacity = 255;
21265
-
21181
+ let backgroundOpacity = 255;
21266
21182
  if (styleParts[6]) {
21267
- var opacity = parseInteger(styleParts[6], DEFAULT_BACKGROUND_OPACITY);
21183
+ let opacity = parseInteger(styleParts[6], DEFAULT_BACKGROUND_OPACITY);
21268
21184
  opacity = clamp(opacity, 0, 255);
21269
21185
  backgroundOpacity = opacity;
21270
21186
  }
21271
-
21272
- var paddingTop = DEFAULT_PADDING * scale;
21273
- var paddingBottom = DEFAULT_PADDING * scale;
21274
-
21187
+ let paddingTop = DEFAULT_PADDING * scale;
21188
+ let paddingBottom = DEFAULT_PADDING * scale;
21275
21189
  if (styleParts[7]) {
21276
- var paddingParts = styleParts[7].split("_");
21190
+ const paddingParts = styleParts[7].split("_");
21277
21191
  paddingTop = parseInteger(paddingParts[0], DEFAULT_PADDING) * scale;
21278
-
21279
21192
  if (paddingParts[1]) {
21280
21193
  paddingBottom = parseInteger(paddingParts[1], DEFAULT_PADDING) * scale;
21281
21194
  }
21282
21195
  }
21283
-
21284
- return new WatermarkStyle(fontName, fontWeight, fontColor, fontSize, backgroundColor, backgroundOpacity, paddingTop, paddingBottom, position, scale, false);
21196
+ return new WatermarkStyle(
21197
+ fontName,
21198
+ fontWeight,
21199
+ fontColor,
21200
+ fontSize,
21201
+ backgroundColor,
21202
+ backgroundOpacity,
21203
+ paddingTop,
21204
+ paddingBottom,
21205
+ position,
21206
+ scale,
21207
+ false
21208
+ );
21285
21209
  }
21286
21210
  }
21287
- /**
21288
- * A JavaScript Scanner like Java's
21289
- * @see java.util.Scanner
21290
- */
21291
-
21292
-
21293
- var watermark_TextScanner = function () {
21211
+ var TextScanner = class {
21294
21212
  /**
21295
21213
  * The content to scan
21296
21214
  * @param text
21297
21215
  */
21298
- function TextScanner(text) {
21216
+ constructor(text) {
21299
21217
  this.text = text;
21300
21218
  this.cursor = 0;
21301
21219
  }
21302
-
21303
- TextScanner.prototype.hasNext = function (obj) {
21220
+ hasNext(obj) {
21304
21221
  if (checkIsUndefinedOrNull(obj)) {
21305
21222
  return this.cursor < this.text.length;
21306
21223
  } else if (checkIsString(obj)) {
21307
- var str = obj;
21308
- var current = watermark_subString(this.text, this.cursor, str.length);
21309
-
21224
+ const str = obj;
21225
+ const current = subString(this.text, this.cursor, str.length);
21310
21226
  if (current === str) {
21311
21227
  return true;
21312
21228
  }
21313
21229
  } else if (checkIsRegExp(obj)) {
21314
- var regex = obj;
21315
- var subText = watermark_subString(this.text, this.cursor);
21316
- var matchResults = subText.match(regex);
21317
-
21230
+ const regex = obj;
21231
+ const subText = subString(this.text, this.cursor);
21232
+ const matchResults = subText.match(regex);
21318
21233
  if (matchResults) {
21319
21234
  if (matchResults.index === 0) {
21320
21235
  return true;
21321
21236
  }
21322
21237
  }
21323
21238
  }
21324
-
21325
21239
  return false;
21326
- };
21327
-
21328
- TextScanner.prototype.next = function (obj) {
21240
+ }
21241
+ next(obj) {
21329
21242
  if (checkIsUndefinedOrNull(obj)) {
21330
- return watermark_subString(this.text, this.cursor, 1);
21243
+ return subString(this.text, this.cursor, 1);
21331
21244
  } else if (checkIsString(obj)) {
21332
- var str = obj;
21333
-
21334
- if (watermark_subString(this.text, this.cursor, str.length) === str) {
21245
+ const str = obj;
21246
+ if (subString(this.text, this.cursor, str.length) === str) {
21335
21247
  return str;
21336
21248
  }
21337
21249
  } else if (checkIsRegExp(obj)) {
21338
- var regex = obj;
21339
- var subText = watermark_subString(this.text, this.cursor);
21340
- var matchResults = subText.match(regex);
21341
-
21250
+ const regex = obj;
21251
+ const subText = subString(this.text, this.cursor);
21252
+ const matchResults = subText.match(regex);
21342
21253
  if (matchResults) {
21343
21254
  if (matchResults.index === 0) {
21344
21255
  return matchResults;
21345
21256
  }
21346
21257
  }
21347
21258
  }
21348
-
21349
21259
  return null;
21350
- };
21351
-
21352
- TextScanner.prototype.skip = function (obj) {
21260
+ }
21261
+ skip(obj) {
21353
21262
  if (checkIsUndefinedOrNull(obj)) {
21354
21263
  this.cursor += 1;
21355
21264
  } else if (checkIsStringValid(obj)) {
21356
- var str = obj;
21265
+ const str = obj;
21357
21266
  this.cursor += str.length;
21358
21267
  }
21359
-
21360
21268
  return this;
21361
- };
21362
-
21363
- return TextScanner;
21364
- }();
21365
-
21366
-
21367
-
21269
+ }
21270
+ };
21368
21271
  function transformFormatString(format) {
21369
- var transformString = format;
21370
-
21272
+ let transformString = format;
21371
21273
  if (format.includes("d")) {
21372
21274
  transformString = transformString.replace(/d/g, "D");
21373
21275
  }
21374
-
21375
21276
  if (format.includes("y")) {
21376
21277
  transformString = transformString.replace(/y/g, "Y");
21377
21278
  }
21378
-
21379
21279
  if (format.includes("E")) {
21380
21280
  transformString = transformString.replace(/E/g, "d");
21381
21281
  }
21382
-
21383
21282
  return transformString;
21384
21283
  }
21385
-
21386
- function buildContent(contentConfigString, watermarkContext, style) {
21387
- var content = "";
21388
- var watermarkImage = new WatermarkImage();
21389
-
21284
+ function buildContent(contentConfigString, watermarkContext, style, canvasSize) {
21285
+ let content = "";
21286
+ const watermarkImage = new WatermarkImage();
21390
21287
  if (contentConfigString.includes("{logo")) {
21391
- var start = contentConfigString.indexOf("{logo");
21392
- var end = contentConfigString.indexOf("}", start);
21393
-
21288
+ const start = contentConfigString.indexOf("{logo");
21289
+ const end = contentConfigString.indexOf("}", start);
21394
21290
  if (end != -1) {
21395
- var logoConfigWithBrace = contentConfigString.substring(start, end + 1);
21396
-
21291
+ const logoConfigWithBrace = contentConfigString.substring(start, end + 1);
21397
21292
  if (contentConfigString.startsWith(logoConfigWithBrace) || contentConfigString.endsWith(logoConfigWithBrace)) {
21398
21293
  if (contentConfigString.startsWith(logoConfigWithBrace)) {
21399
- watermarkImage.position = WatermarkImageEnum.POSITION_LEFT;
21294
+ watermarkImage.position = 0 /* POSITION_LEFT */;
21400
21295
  } else {
21401
- watermarkImage.position = WatermarkImageEnum.POSITION_RIGHT;
21296
+ watermarkImage.position = 1 /* POSITION_RIGHT */;
21402
21297
  }
21403
-
21404
- var imgWidthHeight = (style === null || style === void 0 ? void 0 : style.fontSize) || 20;
21298
+ const imgWidthHeight = (style == null ? void 0 : style.fontSize) || 20;
21405
21299
  watermarkImage.image = watermarkContext.logo;
21406
21300
  watermarkImage.height = imgWidthHeight;
21407
21301
  watermarkImage.width = imgWidthHeight;
21408
21302
  }
21409
-
21410
- contentConfigString = contentConfigString.replace(logoConfigWithBrace, "");
21303
+ contentConfigString = contentConfigString.replace(
21304
+ logoConfigWithBrace,
21305
+ ""
21306
+ );
21411
21307
  }
21412
21308
  }
21413
-
21414
- var scanner = new watermark_TextScanner(contentConfigString);
21415
- var steps = 0;
21416
-
21417
- while (scanner.hasNext() &&
21418
- /* 防止scanner代码错误产生无限循环,设置一个最大scan步数*/
21309
+ const scanner = new TextScanner(contentConfigString);
21310
+ let steps = 0;
21311
+ while (scanner.hasNext() && /* 防止scanner代码错误产生无限循环,设置一个最大scan步数*/
21419
21312
  steps < contentConfigString.length) {
21420
- var dateRegex = new RegExp(WatermarkContent.Date);
21421
-
21313
+ const dateRegex = new RegExp("date{(.*?)}|date" /* Date */);
21422
21314
  if (scanner.hasNext(dateRegex)) {
21423
- var regexResult = scanner.next(dateRegex);
21424
-
21315
+ const regexResult = scanner.next(dateRegex);
21425
21316
  if (regexResult) {
21426
- var matchResults = regexResult;
21427
- var format = date_FORMAT.FORMAT_YMD;
21428
-
21317
+ const matchResults = regexResult;
21318
+ let format = index_esm_FORMAT.FORMAT_YMD;
21429
21319
  if (matchResults && matchResults.length >= 2) {
21430
21320
  if (checkIsStringValid(matchResults[1])) {
21431
21321
  format = matchResults[1];
21432
21322
  }
21433
21323
  }
21434
-
21435
- content += dayjs_min_default()(watermarkContext.watermarkTime).format(transformFormatString(format));
21324
+ content += (0, import_dayjs.default)(watermarkContext.watermarkTime).format(
21325
+ transformFormatString(format)
21326
+ );
21436
21327
  scanner.skip(matchResults.input);
21437
21328
  }
21438
- } else if (scanner.hasNext(WatermarkContent.Time)) {
21439
- var value = dayjs_min_default()(watermarkContext.watermarkTime).format(date_FORMAT.FORMAT_HM);
21329
+ } else if (scanner.hasNext("time" /* Time */)) {
21330
+ const value = (0, import_dayjs.default)(watermarkContext.watermarkTime).format(
21331
+ index_esm_FORMAT.FORMAT_HM
21332
+ );
21440
21333
  content += value;
21441
- scanner.skip(WatermarkContent.Time);
21442
- } else if (scanner.hasNext(WatermarkContent.Address)) {
21334
+ scanner.skip("time" /* Time */);
21335
+ } else if (scanner.hasNext("address" /* Address */)) {
21443
21336
  content += watermarkContext.address;
21444
-
21445
21337
  if (!watermarkImage.image) {
21446
- var imgWidthHeight = (style === null || style === void 0 ? void 0 : style.fontSize) || 20;
21338
+ const imgWidthHeight = (style == null ? void 0 : style.fontSize) || 20;
21447
21339
  watermarkImage.image = DEFAULT_ADDRESS_ICON;
21448
21340
  watermarkImage.height = imgWidthHeight;
21449
21341
  watermarkImage.width = imgWidthHeight;
21450
21342
  }
21451
-
21452
- scanner.skip(WatermarkContent.Address);
21453
- } else if (scanner.hasNext(WatermarkContent.HumanName)) {
21343
+ scanner.skip("address" /* Address */);
21344
+ } else if (scanner.hasNext("humanname" /* HumanName */)) {
21454
21345
  content += watermarkContext.humanName;
21455
- scanner.skip(WatermarkContent.HumanName);
21456
- } else if (scanner.hasNext(WatermarkContent.ProjectName)) {
21346
+ scanner.skip("humanname" /* HumanName */);
21347
+ } else if (scanner.hasNext("projectName" /* ProjectName */)) {
21457
21348
  content += watermarkContext.projectName;
21458
- scanner.skip(WatermarkContent.ProjectName);
21459
- } else if (scanner.hasNext(WatermarkContent.ApplicationName)) {
21349
+ scanner.skip("projectName" /* ProjectName */);
21350
+ } else if (scanner.hasNext("applicationName" /* ApplicationName */)) {
21460
21351
  content += watermarkContext.applicationName;
21461
- scanner.skip(WatermarkContent.ApplicationName);
21352
+ scanner.skip("applicationName" /* ApplicationName */);
21353
+ } else if (scanner.hasNext("pixel" /* Pixel */)) {
21354
+ content += `${canvasSize.width} * ${canvasSize.height}`;
21355
+ scanner.skip("pixel" /* Pixel */);
21356
+ } else if (scanner.hasNext("width" /* Width */)) {
21357
+ content += canvasSize.width;
21358
+ scanner.skip("width" /* Width */);
21359
+ } else if (scanner.hasNext("height" /* Height */)) {
21360
+ content += canvasSize.height;
21361
+ scanner.skip("height" /* Height */);
21462
21362
  } else {
21463
- var nextChar = scanner.next(); // console.log(`next out "${nextChar}"`)
21464
-
21363
+ const nextChar = scanner.next();
21465
21364
  if (checkIsString(nextChar)) {
21466
- // console.log(`next in "${nextChar}"`)
21467
21365
  content += nextChar;
21468
21366
  }
21469
-
21470
21367
  scanner.skip();
21471
21368
  }
21472
-
21473
21369
  steps++;
21474
21370
  }
21475
-
21476
- return {
21477
- content: content,
21478
- watermarkImage: watermarkImage
21479
- };
21371
+ return { content, watermarkImage };
21480
21372
  }
21481
-
21482
21373
  function parseWatermarks(watermarkConfigString, canvasSize, watermarkContext) {
21483
- var watermarks = [];
21484
- var configStringArray = watermarkConfigString.split("###");
21485
-
21486
- for (var i = 0; i < configStringArray.length; i++) {
21487
- var configString = configStringArray[i]; //console.log('config string ' + configString);
21488
-
21489
- var configParts = configString.split("*#*"); //console.log(JSON.stringify(configParts));
21490
-
21374
+ const watermarks = [];
21375
+ const configStringArray = watermarkConfigString.split("###");
21376
+ for (let i = 0; i < configStringArray.length; i++) {
21377
+ const configString = configStringArray[i];
21378
+ const configParts = configString.split("*#*");
21491
21379
  if (configParts.length === 2) {
21492
- var styleString = configParts[0];
21493
- var contentString = configParts[1];
21494
- var style = parseWatermarkStyle(styleString, canvasSize);
21495
- var data = buildContent(contentString, watermarkContext, style);
21496
-
21380
+ const styleString = configParts[0];
21381
+ const contentString = configParts[1];
21382
+ const style = parseWatermarkStyle(styleString, canvasSize);
21383
+ const data = buildContent(
21384
+ contentString,
21385
+ watermarkContext,
21386
+ style,
21387
+ canvasSize
21388
+ );
21497
21389
  if (style && (data.content || data.watermarkImage.image)) {
21498
- var watermark = new Watermark(data.content, style, data.watermarkImage);
21390
+ const watermark = new Watermark(
21391
+ data.content,
21392
+ style,
21393
+ data.watermarkImage
21394
+ );
21499
21395
  watermarks.push(watermark);
21500
21396
  }
21501
21397
  }
21502
21398
  }
21503
-
21504
21399
  return watermarks;
21505
21400
  }
21506
- /**
21507
- * 可以渲染的内容
21508
- */
21509
-
21510
-
21511
- var Tile = function () {
21512
- function Tile(origin, size, lineHeight, lineWidths, lines, style, watermarkImage) {
21401
+ var Tile = class {
21402
+ constructor(origin, size, lineHeight, lineWidths, lines, style, watermarkImage) {
21513
21403
  this.origin = origin;
21514
21404
  this.size = size;
21515
21405
  this.lineHeight = lineHeight;
@@ -21518,87 +21408,70 @@ var Tile = function () {
21518
21408
  this.style = style;
21519
21409
  this.watermarkImage = watermarkImage;
21520
21410
  }
21521
-
21522
- return Tile;
21523
- }();
21524
-
21411
+ };
21525
21412
  function getCanvasScale(canvas, len) {
21526
- var min = Math.min(canvas.width, canvas.height);
21413
+ const min = Math.min(canvas.width, canvas.height);
21527
21414
  return min / DEFAULT_CANVAS_SIZE * len;
21528
21415
  }
21529
-
21530
21416
  function buildTile(canvas, watermark) {
21531
- var content = watermark.content,
21532
- style = watermark.style,
21533
- watermarkImage = watermark.watermarkImage;
21534
- var origin = new Point(0, 0);
21535
- var size = new Size(0, 0);
21536
- var lines = [];
21537
- var ctx = canvas.getContext("2d");
21538
-
21417
+ const { content, style, watermarkImage } = watermark;
21418
+ const origin = new Point(0, 0);
21419
+ const size = new Size(0, 0);
21420
+ const lines = [];
21421
+ const ctx = canvas.getContext("2d");
21539
21422
  if (!ctx) {
21540
21423
  return null;
21541
21424
  }
21542
-
21543
- var imageWidth = 0;
21544
-
21425
+ let imageWidth = 0;
21545
21426
  if (watermarkImage.image) {
21546
21427
  imageWidth = watermarkImage.width + LOGO_DEFAULT_PADDING * style.scale;
21547
21428
  }
21548
-
21549
- ctx.font = style.fontWeight + " " + style.fontSize + "px " + style.fontName;
21550
- var contentPadding = getCanvasScale(canvas, CONTENT_PADDING);
21551
- var contentWidth = canvas.width - contentPadding * 2 - imageWidth; // @see {@link https://stackoverflow.com/questions/1134586/how-can-you-find-the-height-of-text-on-an-html-canvas}
21552
-
21553
- var lineHeight = ctx.measureText("M").width;
21554
- var lineWidths = []; // content超过宽度的前一位就换行,已经超出可能会导致超出屏幕
21555
-
21556
- var temp = "";
21557
- var lastWidth = 0;
21558
-
21559
- for (var i = 0; i < content.length; i++) {
21560
- var lineWidth = ctx.measureText(temp).width;
21561
-
21429
+ ctx.font = `${style.fontWeight} ${style.fontSize}px ${style.fontName}`;
21430
+ const contentPadding = getCanvasScale(canvas, CONTENT_PADDING);
21431
+ const contentWidth = canvas.width - contentPadding * 2 - imageWidth;
21432
+ const lineHeight = ctx.measureText("M").width;
21433
+ const lineWidths = [];
21434
+ let temp = "";
21435
+ let lastWidth = 0;
21436
+ for (let i = 0; i < content.length; i++) {
21437
+ const lineWidth = ctx.measureText(temp).width;
21562
21438
  if (lineWidth >= contentWidth) {
21563
- var line = temp.substring(0, temp.length - 1);
21564
- var preLineWidth = ctx.measureText(line).width;
21439
+ const line = temp.substring(0, temp.length - 1);
21440
+ const preLineWidth = ctx.measureText(line).width;
21565
21441
  lines.push(line);
21566
21442
  lineWidths.push(preLineWidth);
21567
21443
  temp = temp.substring(temp.length - 1);
21568
21444
  }
21569
-
21570
21445
  lastWidth = lineWidth;
21571
21446
  temp += content[i];
21572
21447
  }
21573
-
21574
21448
  lines.push(temp);
21575
21449
  lineWidths.push(lastWidth);
21576
21450
  size.width = contentWidth;
21577
21451
  size.height = lines.length * lineHeight;
21578
- return new Tile(origin, size, lineHeight, lineWidths, lines, style, watermarkImage);
21452
+ return new Tile(
21453
+ origin,
21454
+ size,
21455
+ lineHeight,
21456
+ lineWidths,
21457
+ lines,
21458
+ style,
21459
+ watermarkImage
21460
+ );
21579
21461
  }
21580
-
21581
21462
  function getAxisPoint(canvasWidth, width, tile, origin, line) {
21582
- var style = tile.style,
21583
- watermarkImage = tile.watermarkImage,
21584
- lines = tile.lines,
21585
- lineHeight = tile.lineHeight;
21586
- var padding = (CONTENT_PADDING + DEFAULT_PADDING) * style.scale;
21587
- var axisPoint = new Point(padding, origin.y);
21588
-
21463
+ const { style, watermarkImage, lines, lineHeight } = tile;
21464
+ const padding = (CONTENT_PADDING + DEFAULT_PADDING) * style.scale;
21465
+ let axisPoint = new Point(padding, origin.y);
21589
21466
  if (style.position.startsWith("center")) {
21590
21467
  axisPoint = new Point(canvasWidth / 2, origin.y);
21591
21468
  } else if (style.position.startsWith("right")) {
21592
21469
  axisPoint = new Point(canvasWidth - padding, origin.y);
21593
21470
  }
21594
-
21595
- var imagePoint = new Point(axisPoint.x, axisPoint.y);
21596
-
21471
+ const imagePoint = new Point(axisPoint.x, axisPoint.y);
21597
21472
  if (watermarkImage.image) {
21598
- // 当存在多行文本时,由于不同系统对全角半角的处理不同,存在行宽不同的情况,这时计算logo与文本间距需要区最长的文本计算
21599
- var maxWidth = Math.max.apply(Math, tile.lineWidths);
21600
-
21601
- if (watermarkImage.position === WatermarkImageEnum.POSITION_LEFT) {
21473
+ const maxWidth = Math.max(...tile.lineWidths);
21474
+ if (watermarkImage.position === 0 /* POSITION_LEFT */) {
21602
21475
  if (style.position.startsWith("left")) {
21603
21476
  axisPoint.x = axisPoint.x + watermarkImage.width + LOGO_DEFAULT_PADDING * style.scale;
21604
21477
  } else if (style.position.startsWith("center")) {
@@ -21606,14 +21479,12 @@ function getAxisPoint(canvasWidth, width, tile, origin, line) {
21606
21479
  axisPoint.x = axisPoint.x + watermarkImage.width / 2 + LOGO_DEFAULT_PADDING / 2 * style.scale;
21607
21480
  imagePoint.x = lines.length === 1 ? imagePoint.x - width / 2 - watermarkImage.width - LOGO_DEFAULT_PADDING / 2 * style.scale : imagePoint.x - maxWidth / 2 - watermarkImage.width / 2 - LOGO_DEFAULT_PADDING / 2 * style.scale;
21608
21481
  } else {
21609
- // 只有logo图标时计算逻辑, 没有文本
21610
21482
  imagePoint.x = imagePoint.x - watermarkImage.width / 2;
21611
21483
  }
21612
21484
  } else {
21613
21485
  if (line) {
21614
21486
  imagePoint.x = lines.length === 1 ? imagePoint.x - width - 2 * watermarkImage.width - LOGO_DEFAULT_PADDING / 2 * style.scale : imagePoint.x - maxWidth - watermarkImage.width - LOGO_DEFAULT_PADDING / 2 * style.scale;
21615
21487
  } else {
21616
- // 只有logo图标时计算逻辑, 没有文本
21617
21488
  imagePoint.x = imagePoint.x - watermarkImage.width;
21618
21489
  }
21619
21490
  }
@@ -21627,39 +21498,31 @@ function getAxisPoint(canvasWidth, width, tile, origin, line) {
21627
21498
  axisPoint.x = axisPoint.x - watermarkImage.width;
21628
21499
  imagePoint.x = imagePoint.x - watermarkImage.width + LOGO_DEFAULT_PADDING / 2 * style.scale;
21629
21500
  }
21630
- } // 多行文本时图标上下居中
21631
-
21632
-
21501
+ }
21633
21502
  if (lines.length > 1) {
21634
21503
  imagePoint.y = imagePoint.y + lines.length * lineHeight / 2 - watermarkImage.height / 2;
21635
21504
  }
21636
21505
  }
21637
-
21638
21506
  return {
21639
21507
  text: axisPoint,
21640
21508
  image: imagePoint
21641
21509
  };
21642
21510
  }
21643
-
21644
21511
  function getTextAlign(style) {
21645
- var align = "left";
21646
-
21512
+ let align = "left";
21647
21513
  if (style.position.startsWith("center")) {
21648
21514
  align = "center";
21649
21515
  } else if (style.position.startsWith("right")) {
21650
21516
  align = "right";
21651
21517
  }
21652
-
21653
21518
  return align;
21654
21519
  }
21655
-
21656
21520
  function loadImage(url) {
21657
- return new Promise(function (resolve, reject) {
21658
- var img = new Image();
21521
+ return new Promise((resolve, reject) => {
21522
+ const img = new Image();
21659
21523
  img.src = url;
21660
21524
  img.crossOrigin = "anonymous";
21661
-
21662
- img.onload = function (e) {
21525
+ img.onload = function(e) {
21663
21526
  if (img.complete) {
21664
21527
  resolve(img);
21665
21528
  } else {
@@ -21669,294 +21532,197 @@ function loadImage(url) {
21669
21532
  };
21670
21533
  });
21671
21534
  }
21672
-
21673
21535
  function drawLine(canvas, line, width, origin, tile, drawImage) {
21674
- return __awaiter(this, void 0, void 0, function () {
21675
- var ctx, style, watermarkImage, point, image, offset;
21676
- return __generator(this, function (_a) {
21677
- switch (_a.label) {
21678
- case 0:
21679
- ctx = canvas.getContext("2d");
21680
-
21681
- if (!ctx) {
21682
- return [2
21683
- /*return*/
21684
- ];
21685
- }
21686
-
21687
- style = tile.style, watermarkImage = tile.watermarkImage;
21688
- /**
21689
- * The fillText's second argument is the Y coordinate for the baseline of the text (the default textBaseline is "alphabetic") ,
21690
- * so the text is being drawn above the visible canvas element when you use 0.
21691
- * @see {@link https://stackoverflow.com/questions/14289331/html5-canvas-doesnt-fill-text-at-coordinates-0-0}
21692
- */
21693
-
21694
- ctx.textBaseline = "top";
21695
- ctx.font = style.fontWeight + " " + style.fontSize + "px " + style.fontName;
21696
- point = getAxisPoint(canvas.width, width, tile, origin, line);
21697
- ctx.textAlign = getTextAlign(style);
21698
- if (!(watermarkImage.image && drawImage)) return [3
21699
- /*break*/
21700
- , 2];
21701
- return [4
21702
- /*yield*/
21703
- , loadImage(watermarkImage.image)];
21704
-
21705
- case 1:
21706
- image = _a.sent();
21707
- ctx.drawImage(image, Math.round(point.image.x), Math.round(point.image.y), watermarkImage.width, watermarkImage.height);
21708
- _a.label = 2;
21709
-
21710
- case 2:
21711
- if (style.simplified) {
21712
- ctx.shadowBlur = 4; // shadow
21713
- // ctx.shadowColor = "rgba(220,220,220,0.75)";
21714
-
21715
- ctx.shadowColor = "rgba(0, 0, 0, 0.5)";
21716
- offset = clamp(style.fontSize / 40, 2, 4);
21717
- ctx.shadowOffsetY = offset;
21718
- ctx.shadowOffsetX = offset;
21719
- ctx.fillStyle = "rgba(255,255,255, 0.5)";
21720
- } else {
21721
- ctx.fillStyle = style.fontColor;
21722
- }
21723
-
21724
- ctx.fillText(line, Math.round(point.text.x), Math.round(point.text.y));
21725
- return [2
21726
- /*return*/
21727
- ];
21728
- }
21729
- });
21536
+ return __async(this, null, function* () {
21537
+ const ctx = canvas.getContext("2d");
21538
+ if (!ctx) {
21539
+ return;
21540
+ }
21541
+ const { style, watermarkImage } = tile;
21542
+ ctx.textBaseline = "top";
21543
+ ctx.font = `${style.fontWeight} ${style.fontSize}px ${style.fontName}`;
21544
+ const point = getAxisPoint(canvas.width, width, tile, origin, line);
21545
+ ctx.textAlign = getTextAlign(style);
21546
+ if (watermarkImage.image && drawImage) {
21547
+ const image = yield loadImage(watermarkImage.image);
21548
+ ctx.drawImage(
21549
+ image,
21550
+ Math.round(point.image.x),
21551
+ Math.round(point.image.y),
21552
+ watermarkImage.width,
21553
+ watermarkImage.height
21554
+ );
21555
+ }
21556
+ if (style.simplified) {
21557
+ ctx.shadowBlur = 4;
21558
+ ctx.shadowColor = "rgba(0, 0, 0, 0.5)";
21559
+ const offset = clamp(style.fontSize / 40, 2, 4);
21560
+ ctx.shadowOffsetY = offset;
21561
+ ctx.shadowOffsetX = offset;
21562
+ ctx.fillStyle = "rgba(255,255,255, 0.5)";
21563
+ } else {
21564
+ ctx.fillStyle = style.fontColor;
21565
+ }
21566
+ ctx.fillText(line, Math.round(point.text.x), Math.round(point.text.y));
21730
21567
  });
21731
21568
  }
21732
-
21733
21569
  function hexToRGB(hex, alpha) {
21734
- var r = parseInt(hex.slice(1, 3), 16),
21735
- g = parseInt(hex.slice(3, 5), 16),
21736
- b = parseInt(hex.slice(5, 7), 16);
21737
-
21570
+ const r = parseInt(hex.slice(1, 3), 16), g = parseInt(hex.slice(3, 5), 16), b = parseInt(hex.slice(5, 7), 16);
21738
21571
  if (alpha) {
21739
21572
  return "rgba(" + r + ", " + g + ", " + b + ", " + alpha + ")";
21740
21573
  } else {
21741
21574
  return "rgb(" + r + ", " + g + ", " + b + ")";
21742
21575
  }
21743
21576
  }
21744
-
21745
21577
  function drawBackground(canvas, tile) {
21746
- var ctx = canvas.getContext("2d");
21747
-
21578
+ const ctx = canvas.getContext("2d");
21748
21579
  if (!ctx) {
21749
21580
  return;
21750
21581
  }
21751
-
21752
- var backgroundColor = tile.style.backgroundColor;
21753
- var backgroundOpacity = parseDecimal(String(tile.style.backgroundOpacity), -1);
21754
-
21582
+ let { backgroundColor } = tile.style;
21583
+ let backgroundOpacity = parseDecimal(
21584
+ String(tile.style.backgroundOpacity),
21585
+ -1
21586
+ );
21755
21587
  if (backgroundOpacity > 255) {
21756
21588
  backgroundOpacity = 255;
21757
21589
  }
21758
-
21759
- var style = tile.style;
21760
- var paddingTop = tile.style.paddingTop;
21761
- var paddingBottom = tile.style.paddingBottom;
21762
-
21590
+ const { style } = tile;
21591
+ const { paddingTop, paddingBottom } = style;
21763
21592
  if (backgroundColor !== "transparent") {
21764
21593
  if (backgroundColor.startsWith("#") && backgroundOpacity >= 0) {
21765
- backgroundColor = hexToRGB(backgroundColor, backgroundOpacity / 255.0);
21594
+ backgroundColor = hexToRGB(backgroundColor, backgroundOpacity / 255);
21766
21595
  }
21767
-
21768
21596
  ctx.fillStyle = backgroundColor;
21769
- var padding = (CONTENT_PADDING + DEFAULT_PADDING) * style.scale;
21770
- var paddingScale = tile.style.fontSize / DEFAULT_FONT_SIZE;
21771
-
21772
- for (var j = 0; j < tile.lineWidths.length; j++) {
21773
- var lineHeight = tile.lineHeight;
21774
- var lineWidth = tile.lineWidths[j];
21775
- var paddingRight = 30 * paddingScale;
21776
- var paddingLeft = 10 * paddingScale;
21777
- var axisPoint = new Point(padding - paddingLeft, tile.origin.y);
21778
-
21597
+ const padding = (CONTENT_PADDING + DEFAULT_PADDING) * style.scale;
21598
+ const paddingScale = tile.style.fontSize / DEFAULT_FONT_SIZE;
21599
+ for (let j = 0; j < tile.lineWidths.length; j++) {
21600
+ const { lineHeight } = tile;
21601
+ const lineWidth = tile.lineWidths[j];
21602
+ let paddingRight = 30 * paddingScale;
21603
+ let paddingLeft = 10 * paddingScale;
21604
+ let axisPoint = new Point(padding - paddingLeft, tile.origin.y);
21779
21605
  if (style.position.startsWith("center")) {
21780
21606
  paddingLeft = 20 * paddingScale;
21781
21607
  paddingRight = 20 * paddingScale;
21782
- axisPoint = new Point((canvas.width - lineWidth) / 2 - paddingLeft, tile.origin.y);
21608
+ axisPoint = new Point(
21609
+ (canvas.width - lineWidth) / 2 - paddingLeft,
21610
+ tile.origin.y
21611
+ );
21783
21612
  } else if (style.position.startsWith("right")) {
21784
21613
  paddingLeft = 30 * paddingScale;
21785
21614
  paddingRight = 10 * paddingScale;
21786
- axisPoint = new Point(canvas.width - lineWidth - padding - paddingLeft, tile.origin.y);
21787
- } // padding top
21788
-
21789
-
21790
- if (j === 0) {
21791
- // windows兼容问题,行高绘制不是标准高度
21792
- var top_1 = checkIsWindows() ? paddingTop + 6 * style.scale : paddingTop;
21793
- ctx.fillRect(axisPoint.x, axisPoint.y - paddingTop > 0 ? axisPoint.y - top_1 : 0, paddingLeft + lineWidth + paddingRight, top_1);
21615
+ axisPoint = new Point(
21616
+ canvas.width - lineWidth - padding - paddingLeft,
21617
+ tile.origin.y
21618
+ );
21794
21619
  }
21795
-
21796
- ctx.fillRect(axisPoint.x, axisPoint.y + j * lineHeight, paddingLeft + lineWidth + paddingRight, lineHeight); // padding bottom
21797
-
21620
+ if (j === 0) {
21621
+ const top = checkIsWindows() ? paddingTop + 6 * style.scale : paddingTop;
21622
+ ctx.fillRect(
21623
+ axisPoint.x,
21624
+ axisPoint.y - paddingTop > 0 ? axisPoint.y - top : 0,
21625
+ paddingLeft + lineWidth + paddingRight,
21626
+ top
21627
+ );
21628
+ }
21629
+ ctx.fillRect(
21630
+ axisPoint.x,
21631
+ axisPoint.y + j * lineHeight,
21632
+ paddingLeft + lineWidth + paddingRight,
21633
+ lineHeight
21634
+ );
21798
21635
  if (j === tile.lineWidths.length - 1) {
21799
- // ios兼容问题,行高绘制不是标准高度
21800
- var bottom = checkIsIOS() ? paddingBottom + 4 * style.scale : paddingBottom;
21801
- ctx.fillRect(axisPoint.x, axisPoint.y + (j + 1) * lineHeight, paddingLeft + lineWidth + paddingRight, bottom);
21636
+ const bottom = checkIsIOS() ? paddingBottom + 4 * style.scale : paddingBottom;
21637
+ ctx.fillRect(
21638
+ axisPoint.x,
21639
+ axisPoint.y + (j + 1) * lineHeight,
21640
+ paddingLeft + lineWidth + paddingRight,
21641
+ bottom
21642
+ );
21802
21643
  }
21803
21644
  }
21804
21645
  }
21805
21646
  }
21806
-
21807
21647
  function drawTile(canvas, tile) {
21808
- return __awaiter(this, void 0, void 0, function () {
21809
- var i, origin_1;
21810
- return __generator(this, function (_a) {
21811
- switch (_a.label) {
21812
- case 0:
21813
- if (!tile.style.simplified) {
21814
- // 复杂配置绘制背景颜色
21815
- drawBackground(canvas, tile);
21816
- }
21817
-
21818
- i = 0;
21819
- _a.label = 1;
21820
-
21821
- case 1:
21822
- if (!(i < tile.lines.length)) return [3
21823
- /*break*/
21824
- , 4];
21825
- origin_1 = new Point(tile.origin.x, i * tile.lineHeight + tile.origin.y);
21826
- return [4
21827
- /*yield*/
21828
- , drawLine(canvas, tile.lines[i], tile.lineWidths[i], origin_1, tile, i === 0)];
21829
-
21830
- case 2:
21831
- _a.sent();
21832
-
21833
- _a.label = 3;
21834
-
21835
- case 3:
21836
- i++;
21837
- return [3
21838
- /*break*/
21839
- , 1];
21840
-
21841
- case 4:
21842
- return [2
21843
- /*return*/
21844
- ];
21845
- }
21846
- });
21648
+ return __async(this, null, function* () {
21649
+ if (!tile.style.simplified) {
21650
+ drawBackground(canvas, tile);
21651
+ }
21652
+ for (let i = 0; i < tile.lines.length; i++) {
21653
+ const origin = new Point(
21654
+ tile.origin.x,
21655
+ i * tile.lineHeight + tile.origin.y
21656
+ );
21657
+ yield drawLine(
21658
+ canvas,
21659
+ tile.lines[i],
21660
+ tile.lineWidths[i],
21661
+ origin,
21662
+ tile,
21663
+ i === 0
21664
+ );
21665
+ }
21847
21666
  });
21848
21667
  }
21849
-
21850
- var GroupPosition;
21851
-
21852
- (function (GroupPosition) {
21853
- GroupPosition["Top"] = "top";
21854
- GroupPosition["Center"] = "center";
21855
- GroupPosition["Bottom"] = "bottom";
21856
- })(GroupPosition || (GroupPosition = {}));
21857
-
21858
21668
  function drawGroupedWatermarks(canvas, watermarks, groupPosition) {
21859
- return __awaiter(this, void 0, void 0, function () {
21860
- var tiles, totalHeight, i, watermark, tile, contentPadding, baseOrigin, lastMarginTop, i, tile, i, tile;
21861
- return __generator(this, function (_a) {
21862
- switch (_a.label) {
21863
- case 0:
21864
- if (!watermarks || watermarks.length === 0) {
21865
- return [2
21866
- /*return*/
21867
- ];
21868
- }
21869
-
21870
- tiles = [];
21871
- totalHeight = 0;
21872
-
21873
- for (i = 0; i < watermarks.length; i++) {
21874
- watermark = watermarks[i];
21875
- tile = buildTile(canvas, watermark);
21876
-
21877
- if (tile) {
21878
- tiles.push(tile);
21879
- totalHeight += tile.size.height + CONTENT_PADDING;
21880
- }
21881
- }
21882
-
21883
- if (totalHeight <= 0) {
21884
- // no need draw
21885
- console.error("watermarks height " + totalHeight);
21886
- console.error(JSON.stringify(watermarks));
21887
- return [2
21888
- /*return*/
21889
- ];
21890
- }
21891
-
21892
- contentPadding = getCanvasScale(canvas, CONTENT_PADDING);
21893
- baseOrigin = new Point(contentPadding, contentPadding);
21894
-
21895
- if (groupPosition === GroupPosition.Center) {
21896
- baseOrigin = new Point(contentPadding, Math.round((canvas.height - totalHeight) / 2));
21897
- } else if (groupPosition === GroupPosition.Bottom) {
21898
- baseOrigin = new Point(contentPadding, canvas.height - totalHeight - contentPadding);
21899
- } else if (groupPosition === GroupPosition.Top) {
21900
- baseOrigin = new Point(contentPadding, contentPadding);
21901
- }
21902
-
21903
- lastMarginTop = 0;
21904
-
21905
- for (i = 0; i < tiles.length; i++) {
21906
- tile = tiles[i];
21907
- lastMarginTop += tile.style.paddingTop;
21908
- tile.origin = new Point(tile.origin.x + baseOrigin.x, lastMarginTop + baseOrigin.y);
21909
- lastMarginTop += tile.size.height;
21910
- lastMarginTop += tile.style.paddingBottom;
21911
- }
21912
-
21913
- i = 0;
21914
- _a.label = 1;
21915
-
21916
- case 1:
21917
- if (!(i < tiles.length)) return [3
21918
- /*break*/
21919
- , 4];
21920
- tile = tiles[i];
21921
- return [4
21922
- /*yield*/
21923
- , drawTile(canvas, tile)];
21924
-
21925
- case 2:
21926
- _a.sent();
21927
-
21928
- _a.label = 3;
21929
-
21930
- case 3:
21931
- i++;
21932
- return [3
21933
- /*break*/
21934
- , 1];
21935
-
21936
- case 4:
21937
- return [2
21938
- /*return*/
21939
- ];
21669
+ return __async(this, null, function* () {
21670
+ if (!watermarks || watermarks.length === 0) {
21671
+ return;
21672
+ }
21673
+ const tiles = [];
21674
+ let totalHeight = 0;
21675
+ for (let i = 0; i < watermarks.length; i++) {
21676
+ const watermark = watermarks[i];
21677
+ const tile = buildTile(canvas, watermark);
21678
+ if (tile) {
21679
+ tiles.push(tile);
21680
+ totalHeight += tile.size.height + CONTENT_PADDING;
21940
21681
  }
21941
- });
21682
+ }
21683
+ if (totalHeight <= 0) {
21684
+ console.error("watermarks height " + totalHeight);
21685
+ console.error(JSON.stringify(watermarks));
21686
+ return;
21687
+ }
21688
+ const contentPadding = getCanvasScale(canvas, CONTENT_PADDING);
21689
+ let baseOrigin = new Point(contentPadding, contentPadding);
21690
+ if (groupPosition === "center" /* Center */) {
21691
+ baseOrigin = new Point(
21692
+ contentPadding,
21693
+ Math.round((canvas.height - totalHeight) / 2)
21694
+ );
21695
+ } else if (groupPosition === "bottom" /* Bottom */) {
21696
+ baseOrigin = new Point(
21697
+ contentPadding,
21698
+ canvas.height - totalHeight - contentPadding
21699
+ );
21700
+ } else if (groupPosition === "top" /* Top */) {
21701
+ baseOrigin = new Point(contentPadding, contentPadding);
21702
+ }
21703
+ let lastMarginTop = 0;
21704
+ for (let i = 0; i < tiles.length; i++) {
21705
+ const tile = tiles[i];
21706
+ lastMarginTop += tile.style.paddingTop;
21707
+ tile.origin = new Point(
21708
+ tile.origin.x + baseOrigin.x,
21709
+ lastMarginTop + baseOrigin.y
21710
+ );
21711
+ lastMarginTop += tile.size.height;
21712
+ lastMarginTop += tile.style.paddingBottom;
21713
+ }
21714
+ for (let i = 0; i < tiles.length; i++) {
21715
+ const tile = tiles[i];
21716
+ yield drawTile(canvas, tile);
21717
+ }
21942
21718
  });
21943
21719
  }
21944
- /**
21945
- * 把watermark 分为 上、中、三组
21946
- * @param watermarks
21947
- */
21948
-
21949
-
21950
21720
  function groupingWatermarks(watermarks) {
21951
- var _a;
21952
-
21953
- var topList = [];
21954
- var centerList = [];
21955
- var bottomList = [];
21956
-
21957
- for (var i = 0; i < watermarks.length; i++) {
21958
- var watermark = watermarks[i];
21959
-
21721
+ const topList = [];
21722
+ const centerList = [];
21723
+ const bottomList = [];
21724
+ for (let i = 0; i < watermarks.length; i++) {
21725
+ const watermark = watermarks[i];
21960
21726
  if (watermark.style.position.endsWith("top")) {
21961
21727
  topList.push(watermark);
21962
21728
  } else if (watermark.style.position.endsWith("center")) {
@@ -21965,261 +21731,146 @@ function groupingWatermarks(watermarks) {
21965
21731
  bottomList.push(watermark);
21966
21732
  }
21967
21733
  }
21968
-
21969
- return _a = {}, _a[GroupPosition.Top] = topList, _a[GroupPosition.Center] = centerList, _a[GroupPosition.Bottom] = bottomList, _a;
21734
+ return {
21735
+ ["top" /* Top */]: topList,
21736
+ ["center" /* Center */]: centerList,
21737
+ ["bottom" /* Bottom */]: bottomList
21738
+ };
21970
21739
  }
21971
-
21972
21740
  function renderWatermark(canvas, options) {
21973
- return __awaiter(this, void 0, void 0, function () {
21974
- var watermarkConfigString, watermarks, groupedWatermarks;
21975
- return __generator(this, function (_a) {
21976
- switch (_a.label) {
21977
- case 0:
21978
- // console.log("canvas width " + canvas.width);
21979
- // console.log("canvas height " + canvas.height);
21980
- if (!options.enabled || options.watermarkConfigString === "no") {
21981
- return [2
21982
- /*return*/
21983
- , Promise.resolve(canvas)];
21984
- }
21985
-
21986
- watermarkConfigString = options.watermarkConfigString;
21987
-
21988
- if (watermarkConfigString === "default") {
21989
- watermarkConfigString = "50$lefttop$50*#*time###25$lefttop*#*date";
21990
- }
21991
-
21992
- watermarks = parseWatermarks(watermarkConfigString, new Size(canvas.width, canvas.height), options.context);
21993
- groupedWatermarks = groupingWatermarks(watermarks);
21994
- return [4
21995
- /*yield*/
21996
- , drawGroupedWatermarks(canvas, groupedWatermarks[GroupPosition.Top], GroupPosition.Top)];
21997
-
21998
- case 1:
21999
- _a.sent();
22000
-
22001
- return [4
22002
- /*yield*/
22003
- , drawGroupedWatermarks(canvas, groupedWatermarks[GroupPosition.Center], GroupPosition.Center)];
22004
-
22005
- case 2:
22006
- _a.sent();
22007
-
22008
- return [4
22009
- /*yield*/
22010
- , drawGroupedWatermarks(canvas, groupedWatermarks[GroupPosition.Bottom], GroupPosition.Bottom)];
22011
-
22012
- case 3:
22013
- _a.sent();
22014
-
22015
- return [2
22016
- /*return*/
22017
- , Promise.resolve(canvas)];
22018
- }
22019
- });
21741
+ return __async(this, null, function* () {
21742
+ if (!options.enabled || options.watermarkConfigString === "no") {
21743
+ return Promise.resolve(canvas);
21744
+ }
21745
+ let { watermarkConfigString } = options;
21746
+ if (watermarkConfigString === "default") {
21747
+ watermarkConfigString = "50$lefttop$50*#*time###25$lefttop*#*date";
21748
+ }
21749
+ const watermarks = parseWatermarks(
21750
+ watermarkConfigString,
21751
+ new Size(canvas.width, canvas.height),
21752
+ options.context
21753
+ );
21754
+ const groupedWatermarks = groupingWatermarks(watermarks);
21755
+ yield drawGroupedWatermarks(
21756
+ canvas,
21757
+ groupedWatermarks["top" /* Top */],
21758
+ "top" /* Top */
21759
+ );
21760
+ yield drawGroupedWatermarks(
21761
+ canvas,
21762
+ groupedWatermarks["center" /* Center */],
21763
+ "center" /* Center */
21764
+ );
21765
+ yield drawGroupedWatermarks(
21766
+ canvas,
21767
+ groupedWatermarks["bottom" /* Bottom */],
21768
+ "bottom" /* Bottom */
21769
+ );
21770
+ return Promise.resolve(canvas);
22020
21771
  });
22021
21772
  }
22022
21773
  function checkWatermarkConfigSupported(watermarkConfigString) {
22023
- var configStringArray = watermarkConfigString.split("###");
22024
-
22025
- for (var i = 0; i < configStringArray.length; i++) {
22026
- var configString = configStringArray[i]; //console.log('config string ' + configString);
22027
-
22028
- var configParts = configString.split("*#*"); //console.log(JSON.stringify(configParts));
22029
-
21774
+ const configStringArray = watermarkConfigString.split("###");
21775
+ for (let i = 0; i < configStringArray.length; i++) {
21776
+ const configString = configStringArray[i];
21777
+ const configParts = configString.split("*#*");
22030
21778
  if (configParts.length === 2) {
22031
- var styleString = configParts[0];
22032
- var styleParts = styleString.split("$");
22033
-
21779
+ const styleString = configParts[0];
21780
+ const styleParts = styleString.split("$");
22034
21781
  if (styleParts.length <= 0) {
22035
21782
  console.error("水印配置不合法");
22036
21783
  return false;
22037
21784
  }
22038
21785
  }
22039
21786
  }
22040
-
22041
21787
  return true;
22042
21788
  }
22043
- // CONCATENATED MODULE: ./node_modules/@egova/media/lib/image-util.js
22044
- /**
22045
- * Convert File to data schema url
22046
- * @param file
22047
- */
22048
- function file2DataURL(file) {
22049
- return new Promise(function (resolve, reject) {
22050
- var a = new FileReader();
22051
21789
 
22052
- a.onload = function (res) {
21790
+ // src/image/image-util.ts
21791
+ function file2DataURL(file) {
21792
+ return new Promise((resolve, reject) => {
21793
+ const a = new FileReader();
21794
+ a.onload = function(res) {
22053
21795
  if (res && res.target) {
22054
21796
  resolve(res.target.result);
22055
21797
  } else {
22056
- reject(new Error('读取文件url失败'));
21798
+ reject(new Error("读取文件url失败"));
22057
21799
  }
22058
21800
  };
22059
-
22060
21801
  a.readAsDataURL(file);
22061
21802
  });
22062
21803
  }
22063
- /**
22064
- * Convert file to image
22065
- * @param file
22066
- */
22067
-
22068
21804
  function file2Image(file) {
22069
- return new Promise(function (resolve, reject) {
22070
- file2DataURL(file).then(function (url) {
22071
- var img = new Image();
21805
+ return new Promise((resolve, reject) => {
21806
+ file2DataURL(file).then((url) => {
21807
+ const img = new Image();
22072
21808
  img.src = url;
22073
-
22074
- img.onload = function (e) {
21809
+ img.onload = function() {
22075
21810
  if (img.complete) {
22076
21811
  resolve(img);
22077
21812
  } else {
22078
- reject(new Error('文件加载失败'));
21813
+ reject(new Error("文件加载失败"));
22079
21814
  }
22080
21815
  };
22081
21816
  }).catch(reject);
22082
21817
  });
22083
21818
  }
22084
- function image2file(img, fileName, lastModified, type, quality) {
22085
- if (type === void 0) {
22086
- type = "image/jpeg";
22087
- }
22088
-
22089
- if (quality === void 0) {
22090
- quality = 0.8;
22091
- }
22092
-
22093
- return image2Canvas(img, type).then(function (canvas) {
21819
+ function image2file(img, fileName, lastModified, type = "image/jpeg", quality = 0.8) {
21820
+ return image2Canvas(img, type).then((canvas) => {
22094
21821
  return canvas2File(canvas, fileName, lastModified, type, quality);
22095
21822
  });
22096
21823
  }
22097
- /**
22098
- * Draw image on canvas
22099
- * @param img
22100
- * @param width
22101
- * @param height
22102
- */
22103
-
22104
21824
  function image2Canvas(img, type, width, height) {
22105
- var canvas = document.createElement('canvas');
22106
-
22107
- if (!width) {
22108
- width = img.width;
22109
- }
22110
-
22111
- if (!height) {
22112
- height = img.height;
22113
- }
22114
-
22115
- canvas.width = width;
22116
- canvas.height = height;
22117
- var ctx = canvas.getContext('2d');
22118
-
21825
+ const canvas = document.createElement("canvas");
21826
+ const _width = width || img.width;
21827
+ const _height = height || img.height;
21828
+ canvas.width = _width;
21829
+ canvas.height = _height;
21830
+ const ctx = canvas.getContext("2d");
22119
21831
  if (ctx) {
22120
- // png经canvas.toDataURL转换后背景变成黑色,这里提前填充白色
22121
- ctx.fillStyle = 'transparent';
22122
-
22123
- if (type === 'image/jpeg') {
22124
- ctx.fillStyle = '#fff';
21832
+ ctx.fillStyle = "transparent";
21833
+ if (type === "image/jpeg") {
21834
+ ctx.fillStyle = "#fff";
22125
21835
  }
22126
-
22127
- ctx.drawImage(img, 0, 0, width, height);
21836
+ ctx.drawImage(img, 0, 0, _width, _height);
22128
21837
  return Promise.resolve(canvas);
22129
21838
  } else {
22130
21839
  return Promise.reject(null);
22131
21840
  }
22132
21841
  }
22133
- /**
22134
- * Export Image from canvas
22135
- * @param canvas
22136
- * @param type
22137
- * @param quality
22138
- * @see {@link https://meshworld.in/convert-canvas-to-an-image-using-javascript/}
22139
- */
22140
-
22141
- function canvas2Image(canvas, type, quality) {
22142
- if (type === void 0) {
22143
- type = "image/jpeg";
22144
- }
22145
-
22146
- if (quality === void 0) {
22147
- quality = 0.8;
22148
- }
22149
-
22150
- var image = new Image();
21842
+ function canvas2Image(canvas, type = "image/jpeg", quality = 0.8) {
21843
+ const image = new Image();
22151
21844
  image.src = canvas.toDataURL(type, quality);
22152
21845
  return Promise.resolve(image);
22153
21846
  }
22154
- /**
22155
- * Export File from canvas
22156
- * @param canvas
22157
- * @param fileName
22158
- * @param lastModified
22159
- * @param type
22160
- * @param quality
22161
- * @see {@link https://meshworld.in/convert-canvas-to-an-image-using-javascript/}
22162
- */
22163
-
22164
- function canvas2File(canvas, fileName, lastModified, type, quality) {
22165
- if (type === void 0) {
22166
- type = "image/jpeg";
22167
- }
22168
-
22169
- if (quality === void 0) {
22170
- quality = 0.8;
22171
- }
22172
-
22173
- return new Promise(function (resolve, reject) {
22174
- canvas.toBlob(function (blob) {
22175
- if (!blob) {
22176
- reject(new Error('canvas文件导出失败'));
22177
- } else {
22178
- var file = new File([blob], fileName, {
22179
- lastModified: lastModified,
22180
- type: type
22181
- }); // console.log("file size " + file.size / 1024 + "kb");
22182
- // console.log(file)
22183
-
22184
- resolve(file);
22185
- }
22186
- }, type, quality);
21847
+ function canvas2File(canvas, fileName, lastModified, type = "image/jpeg", quality = 0.8) {
21848
+ return new Promise((resolve, reject) => {
21849
+ canvas.toBlob(
21850
+ (blob) => {
21851
+ if (!blob) {
21852
+ reject(new Error("canvas文件导出失败"));
21853
+ } else {
21854
+ const file = new File([blob], fileName, { lastModified, type });
21855
+ resolve(file);
21856
+ }
21857
+ },
21858
+ type,
21859
+ quality
21860
+ );
22187
21861
  });
22188
21862
  }
22189
- /**
22190
- * 缩放图片
22191
- * @param img:HTMLImageElement 图片对象
22192
- * @param inputType 图片类型
22193
- * @param imageWidth 图片宽度
22194
- * @param imageHeight 图片高度
22195
- * @param equalProportion 是否等比例拉伸,默认是,目前只支持等比例拉伸
22196
- * @param sideLengthLimit 图片边长限制
22197
- * @param baseOnShortSide 是否以短边为限制
22198
- * @param resultType: ResizeResultType, "image" | "canvas"
22199
- */
22200
-
22201
- function resize(img, _a) {
22202
- var _b = _a.inputType,
22203
- inputType = _b === void 0 ? 'image/jpeg' : _b,
22204
- _c = _a.imageWidth,
22205
- imageWidth = _c === void 0 ? -1 : _c,
22206
- _d = _a.imageHeight,
22207
- imageHeight = _d === void 0 ? -1 : _d,
22208
- _e = _a.equalProportion,
22209
- equalProportion = _e === void 0 ? true : _e,
22210
- //等比例拉伸
22211
- _f = _a.sideLengthLimit,
22212
- //等比例拉伸
22213
- sideLengthLimit = _f === void 0 ? 640 : _f,
22214
- _g = _a.baseOnShortSide,
22215
- baseOnShortSide = _g === void 0 ? true : _g,
22216
- // 是否以短边为基准缩放
22217
- _h = _a.resultType,
22218
- // 是否以短边为基准缩放
22219
- resultType = _h === void 0 ? "image" : _h;
22220
- var scale = 1;
22221
- var scaleBaseFunc = baseOnShortSide ? Math.min : Math.max;
22222
-
21863
+ function resize(img, {
21864
+ inputType = "image/jpeg",
21865
+ imageWidth = -1,
21866
+ imageHeight = -1,
21867
+ sideLengthLimit = 640,
21868
+ baseOnShortSide = true,
21869
+ // 是否以短边为基准缩放
21870
+ resultType = "image"
21871
+ }) {
21872
+ let scale = 1;
21873
+ const scaleBaseFunc = baseOnShortSide ? Math.min : Math.max;
22223
21874
  if (imageWidth > 0 && imageHeight > 0) {
22224
21875
  scale = sideLengthLimit / scaleBaseFunc(imageWidth, imageHeight);
22225
21876
  } else if (img.width > 0 && img.height > 0) {
@@ -22227,182 +21878,35 @@ function resize(img, _a) {
22227
21878
  imageWidth = img.width;
22228
21879
  imageHeight = img.height;
22229
21880
  } else {
22230
- return Promise.reject(new Error('image width/height 无效'));
21881
+ return Promise.reject(new Error("image width/height 无效"));
22231
21882
  }
22232
-
22233
- var targetWidth = scale > 1 ? imageWidth : imageWidth * scale;
22234
- var targetHeight = scale > 1 ? imageHeight : imageHeight * scale;
22235
-
21883
+ const targetWidth = scale > 1 ? imageWidth : imageWidth * scale;
21884
+ const targetHeight = scale > 1 ? imageHeight : imageHeight * scale;
22236
21885
  if (resultType === "image") {
22237
- return image2Canvas(img, inputType, targetWidth, targetHeight).then(function (canvas) {
22238
- return canvas2Image(canvas);
22239
- });
21886
+ return image2Canvas(img, inputType, targetWidth, targetHeight).then(
21887
+ (canvas) => {
21888
+ return canvas2Image(canvas);
21889
+ }
21890
+ );
22240
21891
  } else {
22241
21892
  return image2Canvas(img, inputType, targetWidth, targetHeight);
22242
21893
  }
22243
21894
  }
22244
- // CONCATENATED MODULE: ./node_modules/@egova/media/lib/image-processor.js
22245
- var image_processor_awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
22246
- function adopt(value) {
22247
- return value instanceof P ? value : new P(function (resolve) {
22248
- resolve(value);
22249
- });
22250
- }
22251
-
22252
- return new (P || (P = Promise))(function (resolve, reject) {
22253
- function fulfilled(value) {
22254
- try {
22255
- step(generator.next(value));
22256
- } catch (e) {
22257
- reject(e);
22258
- }
22259
- }
22260
-
22261
- function rejected(value) {
22262
- try {
22263
- step(generator["throw"](value));
22264
- } catch (e) {
22265
- reject(e);
22266
- }
22267
- }
22268
-
22269
- function step(result) {
22270
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
22271
- }
22272
-
22273
- step((generator = generator.apply(thisArg, _arguments || [])).next());
22274
- });
22275
- };
22276
-
22277
- var image_processor_generator = undefined && undefined.__generator || function (thisArg, body) {
22278
- var _ = {
22279
- label: 0,
22280
- sent: function sent() {
22281
- if (t[0] & 1) throw t[1];
22282
- return t[1];
22283
- },
22284
- trys: [],
22285
- ops: []
22286
- },
22287
- f,
22288
- y,
22289
- t,
22290
- g;
22291
- return g = {
22292
- next: verb(0),
22293
- "throw": verb(1),
22294
- "return": verb(2)
22295
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
22296
- return this;
22297
- }), g;
22298
-
22299
- function verb(n) {
22300
- return function (v) {
22301
- return step([n, v]);
22302
- };
22303
- }
22304
-
22305
- function step(op) {
22306
- if (f) throw new TypeError("Generator is already executing.");
22307
-
22308
- while (_) {
22309
- try {
22310
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
22311
- if (y = 0, t) op = [op[0] & 2, t.value];
22312
-
22313
- switch (op[0]) {
22314
- case 0:
22315
- case 1:
22316
- t = op;
22317
- break;
22318
-
22319
- case 4:
22320
- _.label++;
22321
- return {
22322
- value: op[1],
22323
- done: false
22324
- };
22325
-
22326
- case 5:
22327
- _.label++;
22328
- y = op[1];
22329
- op = [0];
22330
- continue;
22331
-
22332
- case 7:
22333
- op = _.ops.pop();
22334
-
22335
- _.trys.pop();
22336
-
22337
- continue;
22338
-
22339
- default:
22340
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
22341
- _ = 0;
22342
- continue;
22343
- }
22344
-
22345
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
22346
- _.label = op[1];
22347
- break;
22348
- }
22349
-
22350
- if (op[0] === 6 && _.label < t[1]) {
22351
- _.label = t[1];
22352
- t = op;
22353
- break;
22354
- }
22355
-
22356
- if (t && _.label < t[2]) {
22357
- _.label = t[2];
22358
-
22359
- _.ops.push(op);
22360
-
22361
- break;
22362
- }
22363
-
22364
- if (t[2]) _.ops.pop();
22365
-
22366
- _.trys.pop();
22367
-
22368
- continue;
22369
- }
22370
-
22371
- op = body.call(thisArg, _);
22372
- } catch (e) {
22373
- op = [6, e];
22374
- y = 0;
22375
- } finally {
22376
- f = t = 0;
22377
- }
22378
- }
22379
-
22380
- if (op[0] & 5) throw op[1];
22381
- return {
22382
- value: op[0] ? op[1] : void 0,
22383
- done: true
22384
- };
22385
- }
22386
- };
22387
-
22388
-
22389
-
22390
21895
 
21896
+ // src/image/image-processor.ts
22391
21897
  var MAX_SIDE_LENGTH = 1920;
22392
21898
  var MIN_SIDE_LENGTH = 480;
22393
- var PHOTO_FILE_SIZE_LIMIT = 1000; // 1000kb
22394
-
21899
+ var PHOTO_FILE_SIZE_LIMIT = 1e3;
22395
21900
  var DEFAULT_JPEG_QUALITY = 0.8;
22396
21901
  var MIN_JPEG_QUALITY = 0.1;
22397
21902
  var JPEG_QUALITY_STEP = 0.05;
22398
-
22399
- var image_processor_ResizeOptions = function () {
22400
- function ResizeOptions(maxSideLength) {
21903
+ var ResizeOptions = class {
21904
+ // 最大边长
21905
+ constructor(maxSideLength) {
22401
21906
  if (checkIsUndefinedOrNull(maxSideLength)) {
22402
21907
  this.maxSideLength = MAX_SIDE_LENGTH;
22403
21908
  } else {
22404
21909
  this.maxSideLength = maxSideLength;
22405
-
22406
21910
  if (this.maxSideLength > MAX_SIDE_LENGTH) {
22407
21911
  this.maxSideLength = MAX_SIDE_LENGTH;
22408
21912
  } else if (this.maxSideLength < MIN_SIDE_LENGTH) {
@@ -22410,104 +21914,73 @@ var image_processor_ResizeOptions = function () {
22410
21914
  }
22411
21915
  }
22412
21916
  }
22413
-
22414
- return ResizeOptions;
22415
- }();
22416
-
22417
-
22418
-
22419
- var image_processor_CompressOptions = function () {
22420
- function CompressOptions(photoFileSizeLimit) {
21917
+ };
21918
+ var CompressOptions = class {
21919
+ // 图片大小限制,单位kb
21920
+ constructor(photoFileSizeLimit) {
22421
21921
  if (checkIsUndefinedOrNull(photoFileSizeLimit)) {
22422
21922
  this.photoFileSizeLimit = PHOTO_FILE_SIZE_LIMIT;
22423
21923
  } else {
22424
21924
  this.photoFileSizeLimit = photoFileSizeLimit;
22425
21925
  }
22426
21926
  }
22427
-
22428
- return CompressOptions;
22429
- }();
22430
-
22431
-
22432
-
22433
- var image_processor_ImageProcessor = function () {
22434
- function ImageProcessor(file, resizeOptions, watermarkOptions, compressOptions) {
21927
+ };
21928
+ var ImageProcessor = class {
21929
+ // 压缩图片的配置
21930
+ constructor(file, resizeOptions, watermarkOptions, compressOptions) {
22435
21931
  this.file = file;
22436
21932
  this.resizeOptions = resizeOptions;
22437
21933
  this.watermarkOptions = watermarkOptions;
22438
21934
  this.compressOptions = compressOptions;
22439
21935
  }
22440
-
22441
- ImageProcessor.prototype.process = function () {
22442
- var _this = this;
22443
-
22444
- var filename = this.file.name;
22445
- var lastModified = this.file.lastModified;
22446
- var fileType = this.file.type;
22447
-
21936
+ process() {
21937
+ const filename = this.file.name;
21938
+ const { lastModified } = this.file;
21939
+ let fileType = this.file.type;
22448
21940
  if (this.file.size > this.compressOptions.photoFileSizeLimit * 1024) {
22449
21941
  fileType = "image/jpeg";
22450
21942
  }
22451
-
22452
21943
  if (fileType === "image/gif") {
22453
21944
  fileType = "image/png";
22454
21945
  }
22455
-
22456
- return file2Image(this.file).then(function (img) {
22457
- //第一步 resize image
21946
+ return file2Image(this.file).then((img) => {
22458
21947
  return resize(img, {
22459
21948
  inputType: fileType,
22460
- sideLengthLimit: _this.resizeOptions.maxSideLength,
21949
+ sideLengthLimit: this.resizeOptions.maxSideLength,
22461
21950
  resultType: "canvas"
22462
21951
  });
22463
- }).then(function (result) {
22464
- return image_processor_awaiter(_this, void 0, void 0, function () {
22465
- var canvas;
22466
- return image_processor_generator(this, function (_a) {
22467
- switch (_a.label) {
22468
- case 0:
22469
- canvas = result;
22470
- return [4
22471
- /*yield*/
22472
- , renderWatermark(canvas, this.watermarkOptions)];
22473
-
22474
- case 1:
22475
- //第二步 打水印
22476
- return [2
22477
- /*return*/
22478
- , _a.sent()];
22479
- }
22480
- });
22481
- });
22482
- }).then(function (canvas) {
22483
- var exportFilename = filename.replace(/\./g, "-") + ".jpg";
22484
- return _this.compress(canvas, exportFilename, lastModified, fileType, DEFAULT_JPEG_QUALITY);
21952
+ }).then((result) => __async(this, null, function* () {
21953
+ const canvas = result;
21954
+ return yield renderWatermark(canvas, this.watermarkOptions);
21955
+ })).then((canvas) => {
21956
+ const exportFilename = filename.replace(/\./g, "-") + ".jpg";
21957
+ return this.compress(
21958
+ canvas,
21959
+ exportFilename,
21960
+ lastModified,
21961
+ fileType,
21962
+ DEFAULT_JPEG_QUALITY
21963
+ );
22485
21964
  });
22486
- };
22487
-
22488
- ImageProcessor.prototype.compress = function (canvas, filename, lastModified, type, quality) {
22489
- var _this = this;
22490
-
22491
- return canvas2File(canvas, filename, lastModified, type, quality).then(function (file) {
22492
- if (file.size > _this.compressOptions.photoFileSizeLimit * 1024 && quality - JPEG_QUALITY_STEP > MIN_JPEG_QUALITY) {
22493
- return _this.compress(canvas, filename, lastModified, type, quality - JPEG_QUALITY_STEP);
22494
- } else {
22495
- return Promise.resolve(file);
21965
+ }
21966
+ compress(canvas, filename, lastModified, type, quality) {
21967
+ return canvas2File(canvas, filename, lastModified, type, quality).then(
21968
+ (file) => {
21969
+ if (file.size > this.compressOptions.photoFileSizeLimit * 1024 && quality - JPEG_QUALITY_STEP > MIN_JPEG_QUALITY) {
21970
+ return this.compress(
21971
+ canvas,
21972
+ filename,
21973
+ lastModified,
21974
+ type,
21975
+ quality - JPEG_QUALITY_STEP
21976
+ );
21977
+ } else {
21978
+ return Promise.resolve(file);
21979
+ }
22496
21980
  }
22497
- });
22498
- };
22499
-
22500
- return ImageProcessor;
22501
- }();
22502
-
22503
-
22504
- // CONCATENATED MODULE: ./node_modules/@egova/media/lib/index.js
22505
- /**
22506
- * @description 水印渲染类
22507
- * @author Jiaji Yin
22508
- * @date 2021-11-05
22509
- */
22510
-
21981
+ );
21982
+ }
21983
+ };
22511
21984
 
22512
21985
 
22513
21986
  // CONCATENATED MODULE: ./es/media-picker/image/TakePhotoIcon.js
@@ -24223,8 +23696,8 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
24223
23696
  var _this5 = this;
24224
23697
 
24225
23698
  var promisesTodo = [];
24226
- var resizeOptions = new image_processor_ResizeOptions(this.maxImageSideLength);
24227
- var compressOptions = new image_processor_CompressOptions(this.maxImageFileSize);
23699
+ var resizeOptions = new ResizeOptions(this.maxImageSideLength);
23700
+ var compressOptions = new CompressOptions(this.maxImageFileSize);
24228
23701
 
24229
23702
  var _loop = function _loop(i) {
24230
23703
  var file = files[i];
@@ -24250,7 +23723,7 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
24250
23723
  });
24251
23724
  }
24252
23725
 
24253
- var promise = new image_processor_ImageProcessor(file, resizeOptions, watermarkOpt, compressOptions).process().then(function (f) {
23726
+ var promise = new ImageProcessor(file, resizeOptions, watermarkOpt, compressOptions).process().then(function (f) {
24254
23727
  if (!f) {
24255
23728
  return Promise.resolve();
24256
23729
  }
@@ -26785,10 +26258,10 @@ var esm_right = 'right';
26785
26258
  var esm_left = 'left';
26786
26259
  var auto = 'auto';
26787
26260
  var basePlacements = [esm_top, esm_bottom, esm_right, esm_left];
26788
- var esm_start = 'start';
26789
- var esm_end = 'end';
26261
+ var start = 'start';
26262
+ var end = 'end';
26790
26263
  var esm_placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
26791
- return acc.concat([placement, placement + "-" + esm_start, placement + "-" + esm_end]);
26264
+ return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
26792
26265
  }, []); // modifiers that need to read the DOM
26793
26266
 
26794
26267
  var beforeRead = 'beforeRead';
@@ -27042,11 +26515,11 @@ function computeOffsets(_ref) {
27042
26515
  var len = mainAxis === 'y' ? 'height' : 'width';
27043
26516
 
27044
26517
  switch (variation) {
27045
- case esm_start:
26518
+ case start:
27046
26519
  offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
27047
26520
  break;
27048
26521
 
27049
- case esm_end:
26522
+ case end:
27050
26523
  offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
27051
26524
  break;
27052
26525
  }
@@ -32912,7 +32385,7 @@ var steps_createNamespace = Object(utils["b" /* createNamespace */])('steps'),
32912
32385
  steps_createComponent = steps_createNamespace[0],
32913
32386
  steps_bem = steps_createNamespace[1];
32914
32387
 
32915
- /* harmony default export */ var es_steps = (steps_createComponent({
32388
+ /* harmony default export */ var steps = (steps_createComponent({
32916
32389
  mixins: [ParentMixin('ztSteps')],
32917
32390
  props: {
32918
32391
  activeColor: String,
@@ -34626,8 +34099,8 @@ var uploader_createNamespace = Object(utils["b" /* createNamespace */])('uploade
34626
34099
  var processImagePromises = [];
34627
34100
  files.forEach(function (file, index) {
34628
34101
  if (file.type.indexOf('image') === 0) {
34629
- var resizeOptions = new image_processor_ResizeOptions(_this.watermarkOptions.maxImageSideLength || 640);
34630
- var compressOptions = new image_processor_CompressOptions(_this.maxSize);
34102
+ var resizeOptions = new ResizeOptions(_this.watermarkOptions.maxImageSideLength || 640);
34103
+ var compressOptions = new CompressOptions(_this.maxSize);
34631
34104
  var watermarkContext = new WatermarkContext({
34632
34105
  address: _this.watermarkOptions.address || "",
34633
34106
  watermarkTime: new Date(),
@@ -34641,7 +34114,7 @@ var uploader_createNamespace = Object(utils["b" /* createNamespace */])('uploade
34641
34114
  watermarkConfigString: _this.watermarkOptions.watermarkConfigString,
34642
34115
  context: watermarkContext
34643
34116
  });
34644
- var processor = new image_processor_ImageProcessor(file, resizeOptions, watermarkOptions, compressOptions);
34117
+ var processor = new ImageProcessor(file, resizeOptions, watermarkOptions, compressOptions);
34645
34118
  var proc = processor.process().then(function (file) {
34646
34119
  var uniqueFileName = _this.getNewFileName(file);
34647
34120
 
@@ -35119,10 +34592,10 @@ var uploader_createNamespace = Object(utils["b" /* createNamespace */])('uploade
35119
34592
 
35120
34593
 
35121
34594
 
35122
- var version = '2.0.90';
34595
+ var version = '2.1.0';
35123
34596
 
35124
34597
  function install(Vue) {
35125
- var components = [action_sheet, es_area, avatar, back_top, badge, es_button, calendar, cascader, cell, cell_group, es_checkbox, checkbox_group, col, collapse, collapse_item, count_down, datetime_picker, dialog, divider, dropdown_item, dropdown_menu, empty, es_field, fold_dialog, es_form, grid, grid_item, hierarchy_select, es_icon, es_image, image_preview, index_anchor, index_bar, es_info, lazyload, es_list, es_loading, locale["a" /* default */], media_picker, media_player, multiple_picker, nav_bar, notice_bar, number_keyboard, es_overlay, password_input, es_picker, popover, popup, pull_refresh, es_radio, radio_group, rate, row, search, signature, skeleton, slider, es_step, stepper, es_steps, es_sticky, swipe, swipe_cell, swipe_item, es_switch, switch_cell, tab, tabbar, tabbar_item, table, tabs, es_tag, text_ellipsis, timeline, es_toast, uploader];
34598
+ var components = [action_sheet, es_area, avatar, back_top, badge, es_button, calendar, cascader, cell, cell_group, es_checkbox, checkbox_group, col, collapse, collapse_item, count_down, datetime_picker, dialog, divider, dropdown_item, dropdown_menu, empty, es_field, fold_dialog, es_form, grid, grid_item, hierarchy_select, es_icon, es_image, image_preview, index_anchor, index_bar, es_info, lazyload, es_list, es_loading, locale["a" /* default */], media_picker, media_player, multiple_picker, nav_bar, notice_bar, number_keyboard, es_overlay, password_input, es_picker, popover, popup, pull_refresh, es_radio, radio_group, rate, row, search, signature, skeleton, slider, es_step, stepper, steps, es_sticky, swipe, swipe_cell, swipe_item, es_switch, switch_cell, tab, tabbar, tabbar_item, table, tabs, es_tag, text_ellipsis, timeline, es_toast, uploader];
35126
34599
  components.forEach(function (item) {
35127
34600
  if (item.install) {
35128
34601
  Vue.use(item);