mp-darkmode 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/darkmode.js CHANGED
@@ -7,132 +7,47 @@
7
7
  exports["Darkmode"] = factory();
8
8
  else
9
9
  root["Darkmode"] = factory();
10
- })(window, function() {
11
- return /******/ (function(modules) { // webpackBootstrap
12
- /******/ // The module cache
13
- /******/ var installedModules = {};
14
- /******/
15
- /******/ // The require function
16
- /******/ function __webpack_require__(moduleId) {
17
- /******/
18
- /******/ // Check if module is in cache
19
- /******/ if(installedModules[moduleId]) {
20
- /******/ return installedModules[moduleId].exports;
21
- /******/ }
22
- /******/ // Create a new module (and put it into the cache)
23
- /******/ var module = installedModules[moduleId] = {
24
- /******/ i: moduleId,
25
- /******/ l: false,
26
- /******/ exports: {}
27
- /******/ };
28
- /******/
29
- /******/ // Execute the module function
30
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
31
- /******/
32
- /******/ // Flag the module as loaded
33
- /******/ module.l = true;
34
- /******/
35
- /******/ // Return the exports of the module
36
- /******/ return module.exports;
37
- /******/ }
38
- /******/
39
- /******/
40
- /******/ // expose the modules object (__webpack_modules__)
41
- /******/ __webpack_require__.m = modules;
42
- /******/
43
- /******/ // expose the module cache
44
- /******/ __webpack_require__.c = installedModules;
45
- /******/
46
- /******/ // define getter function for harmony exports
47
- /******/ __webpack_require__.d = function(exports, name, getter) {
48
- /******/ if(!__webpack_require__.o(exports, name)) {
49
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
50
- /******/ }
51
- /******/ };
52
- /******/
53
- /******/ // define __esModule on exports
54
- /******/ __webpack_require__.r = function(exports) {
55
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
56
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
57
- /******/ }
58
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
59
- /******/ };
60
- /******/
61
- /******/ // create a fake namespace object
62
- /******/ // mode & 1: value is a module id, require it
63
- /******/ // mode & 2: merge all properties of value into the ns
64
- /******/ // mode & 4: return value when already ns object
65
- /******/ // mode & 8|1: behave like require
66
- /******/ __webpack_require__.t = function(value, mode) {
67
- /******/ if(mode & 1) value = __webpack_require__(value);
68
- /******/ if(mode & 8) return value;
69
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
70
- /******/ var ns = Object.create(null);
71
- /******/ __webpack_require__.r(ns);
72
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
73
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
74
- /******/ return ns;
75
- /******/ };
76
- /******/
77
- /******/ // getDefaultExport function for compatibility with non-harmony modules
78
- /******/ __webpack_require__.n = function(module) {
79
- /******/ var getter = module && module.__esModule ?
80
- /******/ function getDefault() { return module['default']; } :
81
- /******/ function getModuleExports() { return module; };
82
- /******/ __webpack_require__.d(getter, 'a', getter);
83
- /******/ return getter;
84
- /******/ };
85
- /******/
86
- /******/ // Object.prototype.hasOwnProperty.call
87
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
88
- /******/
89
- /******/ // __webpack_public_path__
90
- /******/ __webpack_require__.p = "";
91
- /******/
92
- /******/
93
- /******/ // Load entry module and return exports
94
- /******/ return __webpack_require__(__webpack_require__.s = "./src/darkmode.js");
95
- /******/ })
96
- /************************************************************************/
97
- /******/ ({
10
+ })(self, () => {
11
+ return /******/ (() => { // webpackBootstrap
12
+ /******/ var __webpack_modules__ = ({
98
13
 
99
- /***/ "./node_modules/color-blend/dist/index.modern.js":
14
+ /***/ "./node_modules/color-blend/dist/index.modern.js"
100
15
  /*!*******************************************************!*\
101
16
  !*** ./node_modules/color-blend/dist/index.modern.js ***!
102
17
  \*******************************************************/
103
- /*! exports provided: color, colorBurn, colorDodge, darken, difference, exclusion, hardLight, hue, lighten, luminosity, multiply, normal, overlay, saturation, screen, softLight */
104
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
18
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
105
19
 
106
20
  "use strict";
107
21
  __webpack_require__.r(__webpack_exports__);
108
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "color", function() { return R; });
109
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorBurn", function() { return H; });
110
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorDodge", function() { return G; });
111
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "darken", function() { return E; });
112
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "difference", function() { return L; });
113
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "exclusion", function() { return N; });
114
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hardLight", function() { return J; });
115
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hue", function() { return P; });
116
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lighten", function() { return F; });
117
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "luminosity", function() { return S; });
118
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiply", function() { return B; });
119
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "normal", function() { return A; });
120
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "overlay", function() { return D; });
121
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "saturation", function() { return Q; });
122
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "screen", function() { return C; });
123
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "softLight", function() { return K; });
22
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
23
+ /* harmony export */ color: () => (/* binding */ R),
24
+ /* harmony export */ colorBurn: () => (/* binding */ H),
25
+ /* harmony export */ colorDodge: () => (/* binding */ G),
26
+ /* harmony export */ darken: () => (/* binding */ E),
27
+ /* harmony export */ difference: () => (/* binding */ L),
28
+ /* harmony export */ exclusion: () => (/* binding */ N),
29
+ /* harmony export */ hardLight: () => (/* binding */ J),
30
+ /* harmony export */ hue: () => (/* binding */ P),
31
+ /* harmony export */ lighten: () => (/* binding */ F),
32
+ /* harmony export */ luminosity: () => (/* binding */ S),
33
+ /* harmony export */ multiply: () => (/* binding */ B),
34
+ /* harmony export */ normal: () => (/* binding */ A),
35
+ /* harmony export */ overlay: () => (/* binding */ D),
36
+ /* harmony export */ saturation: () => (/* binding */ Q),
37
+ /* harmony export */ screen: () => (/* binding */ C),
38
+ /* harmony export */ softLight: () => (/* binding */ K)
39
+ /* harmony export */ });
124
40
  function n(n,r,t){return{r:255*t(n.r/255,r.r/255),g:255*t(n.g/255,r.g/255),b:255*t(n.b/255,r.b/255)}}function r(n,r){return r}function t(n,r){return n*r}function u(n,r){return n+r-n*r}function i(n,r){return a(r,n)}function o(n,r){return Math.min(n,r)}function e(n,r){return Math.min(Math.max(n,r),1)}function c(n,r){return 0===n?0:1===r?1:Math.min(1,n/(1-r))}function f(n,r){return 1===n?1:0===r?0:1-Math.min(1,(1-n)/r)}function a(n,r){return r<=.5?t(n,2*r):u(n,2*r-1)}function b(n,r){return r<=.5?n-(1-2*r)*n*(1-n):n+(2*r-1)*((n<=.25?((16*n-12)*n+4)*n:Math.sqrt(n))-n)}function g(n,r){return Math.abs(n-r)}function h(n,r){return n+r-2*n*r}function M(n,r,t){return Math.min(Math.max(n||0,r),t)}function m(n){return{r:M(n.r,0,255),g:M(n.g,0,255),b:M(n.b,0,255),a:M(n.a,0,1)}}function d(n){return{r:255*n.r,g:255*n.g,b:255*n.b,a:n.a}}function p(n){return{r:n.r/255,g:n.g/255,b:n.b/255,a:n.a}}function v(n,r){void 0===r&&(r=0);var t=Math.pow(10,r);return{r:Math.round(n.r*t)/t,g:Math.round(n.g*t)/t,b:Math.round(n.b*t)/t,a:n.a}}function x(n,r,t,u,i,o){return(1-r/t)*u+r/t*Math.round((1-n)*i+n*o)}function O(n,r,t,u,i){void 0===i&&(i={unitInput:!1,unitOutput:!1,roundOutput:!0}),i.unitInput&&(n=d(n),r=d(r)),n=m(n);var o=(r=m(r)).a+n.a-r.a*n.a,e=t(n,r,u),c=m({r:x(n.a,r.a,o,n.r,r.r,e.r),g:x(n.a,r.a,o,n.g,r.g,e.g),b:x(n.a,r.a,o,n.b,r.b,e.b),a:o});return c=i.unitOutput?p(c):i.roundOutput?v(c):function(n){return v(n,9)}(c),c}function s(n,r,t){return d(t(p(n),p(r)))}function I(n){return.3*n.r+.59*n.g+.11*n.b}function q(n,r){var t=r-I(n);return function(n){var r=I(n),t=n.r,u=n.g,i=n.b,o=Math.min(t,u,i),e=Math.max(t,u,i);function c(n){return r+(n-r)*r/(r-o)}function f(n){return r+(n-r)*(1-r)/(e-r)}return o<0&&(t=c(t),u=c(u),i=c(i)),e>1&&(t=f(t),u=f(u),i=f(i)),{r:t,g:u,b:i}}({r:n.r+t,g:n.g+t,b:n.b+t})}function w(n){return Math.max(n.r,n.g,n.b)-Math.min(n.r,n.g,n.b)}function j(n,r){var t=["r","g","b"].sort(function(r,t){return n[r]-n[t]}),u=t[0],i=t[1],o=t[2],e={r:n.r,g:n.g,b:n.b};return e[o]>e[u]?(e[i]=(e[i]-e[u])*r/(e[o]-e[u]),e[o]=r):e[i]=e[o]=0,e[u]=0,e}function k(n,r){return q(j(r,w(n)),I(n))}function l(n,r){return q(j(n,w(r)),I(n))}function y(n,r){return q(r,I(n))}function z(n,r){return q(n,I(r))}function A(t,u){return O(t,u,n,r)}function B(r,u){return O(r,u,n,t)}function C(r,t){return O(r,t,n,u)}function D(r,t){return O(r,t,n,i)}function E(r,t){return O(r,t,n,o)}function F(r,t){return O(r,t,n,e)}function G(r,t){return O(r,t,n,c)}function H(r,t){return O(r,t,n,f)}function J(r,t){return O(r,t,n,a)}function K(r,t){return O(r,t,n,b)}function L(r,t){return O(r,t,n,g)}function N(r,t){return O(r,t,n,h)}function P(n,r){return O(n,r,s,k)}function Q(n,r){return O(n,r,s,l)}function R(n,r){return O(n,r,s,y)}function S(n,r){return O(n,r,s,z)}
125
41
  //# sourceMappingURL=index.modern.js.map
126
42
 
127
43
 
128
- /***/ }),
44
+ /***/ },
129
45
 
130
- /***/ "./node_modules/color-convert/conversions.js":
46
+ /***/ "./node_modules/color-convert/conversions.js"
131
47
  /*!***************************************************!*\
132
48
  !*** ./node_modules/color-convert/conversions.js ***!
133
49
  \***************************************************/
134
- /*! no static exports found */
135
- /***/ (function(module, exports, __webpack_require__) {
50
+ (module, __unused_webpack_exports, __webpack_require__) {
136
51
 
137
52
  /* MIT license */
138
53
  var cssKeywords = __webpack_require__(/*! color-name */ "./node_modules/color-convert/node_modules/color-name/index.js");
@@ -1004,14 +919,13 @@ convert.rgb.gray = function (rgb) {
1004
919
  };
1005
920
 
1006
921
 
1007
- /***/ }),
922
+ /***/ },
1008
923
 
1009
- /***/ "./node_modules/color-convert/index.js":
924
+ /***/ "./node_modules/color-convert/index.js"
1010
925
  /*!*********************************************!*\
1011
926
  !*** ./node_modules/color-convert/index.js ***!
1012
927
  \*********************************************/
1013
- /*! no static exports found */
1014
- /***/ (function(module, exports, __webpack_require__) {
928
+ (module, __unused_webpack_exports, __webpack_require__) {
1015
929
 
1016
930
  var conversions = __webpack_require__(/*! ./conversions */ "./node_modules/color-convert/conversions.js");
1017
931
  var route = __webpack_require__(/*! ./route */ "./node_modules/color-convert/route.js");
@@ -1093,14 +1007,13 @@ models.forEach(function (fromModel) {
1093
1007
  module.exports = convert;
1094
1008
 
1095
1009
 
1096
- /***/ }),
1010
+ /***/ },
1097
1011
 
1098
- /***/ "./node_modules/color-convert/node_modules/color-name/index.js":
1012
+ /***/ "./node_modules/color-convert/node_modules/color-name/index.js"
1099
1013
  /*!*********************************************************************!*\
1100
1014
  !*** ./node_modules/color-convert/node_modules/color-name/index.js ***!
1101
1015
  \*********************************************************************/
1102
- /*! no static exports found */
1103
- /***/ (function(module, exports, __webpack_require__) {
1016
+ (module) {
1104
1017
 
1105
1018
  "use strict";
1106
1019
 
@@ -1257,14 +1170,13 @@ module.exports = {
1257
1170
  };
1258
1171
 
1259
1172
 
1260
- /***/ }),
1173
+ /***/ },
1261
1174
 
1262
- /***/ "./node_modules/color-convert/route.js":
1175
+ /***/ "./node_modules/color-convert/route.js"
1263
1176
  /*!*********************************************!*\
1264
1177
  !*** ./node_modules/color-convert/route.js ***!
1265
1178
  \*********************************************/
1266
- /*! no static exports found */
1267
- /***/ (function(module, exports, __webpack_require__) {
1179
+ (module, __unused_webpack_exports, __webpack_require__) {
1268
1180
 
1269
1181
  var conversions = __webpack_require__(/*! ./conversions */ "./node_modules/color-convert/conversions.js");
1270
1182
 
@@ -1365,14 +1277,13 @@ module.exports = function (fromModel) {
1365
1277
 
1366
1278
 
1367
1279
 
1368
- /***/ }),
1280
+ /***/ },
1369
1281
 
1370
- /***/ "./node_modules/color-name/index.js":
1282
+ /***/ "./node_modules/color-name/index.js"
1371
1283
  /*!******************************************!*\
1372
1284
  !*** ./node_modules/color-name/index.js ***!
1373
1285
  \******************************************/
1374
- /*! no static exports found */
1375
- /***/ (function(module, exports, __webpack_require__) {
1286
+ (module) {
1376
1287
 
1377
1288
  "use strict";
1378
1289
 
@@ -1529,21 +1440,20 @@ module.exports = {
1529
1440
  };
1530
1441
 
1531
1442
 
1532
- /***/ }),
1443
+ /***/ },
1533
1444
 
1534
- /***/ "./node_modules/color-string/index.js":
1445
+ /***/ "./node_modules/color-string/index.js"
1535
1446
  /*!********************************************!*\
1536
1447
  !*** ./node_modules/color-string/index.js ***!
1537
1448
  \********************************************/
1538
- /*! no static exports found */
1539
- /***/ (function(module, exports, __webpack_require__) {
1449
+ (module, __unused_webpack_exports, __webpack_require__) {
1540
1450
 
1541
1451
  /* MIT license */
1542
1452
  var colorNames = __webpack_require__(/*! color-name */ "./node_modules/color-name/index.js");
1543
1453
  var swizzle = __webpack_require__(/*! simple-swizzle */ "./node_modules/simple-swizzle/index.js");
1544
1454
  var hasOwnProperty = Object.hasOwnProperty;
1545
1455
 
1546
- var reverseNames = {};
1456
+ var reverseNames = Object.create(null);
1547
1457
 
1548
1458
  // create a list of reverse color names
1549
1459
  for (var name in colorNames) {
@@ -1782,14 +1692,13 @@ function hexDouble(num) {
1782
1692
  }
1783
1693
 
1784
1694
 
1785
- /***/ }),
1695
+ /***/ },
1786
1696
 
1787
- /***/ "./node_modules/color/index.js":
1697
+ /***/ "./node_modules/color/index.js"
1788
1698
  /*!*************************************!*\
1789
1699
  !*** ./node_modules/color/index.js ***!
1790
1700
  \*************************************/
1791
- /*! no static exports found */
1792
- /***/ (function(module, exports, __webpack_require__) {
1701
+ (module, __unused_webpack_exports, __webpack_require__) {
1793
1702
 
1794
1703
  "use strict";
1795
1704
 
@@ -2276,14 +2185,13 @@ function zeroArray(arr, length) {
2276
2185
  module.exports = Color;
2277
2186
 
2278
2187
 
2279
- /***/ }),
2188
+ /***/ },
2280
2189
 
2281
- /***/ "./node_modules/is-arrayish/index.js":
2190
+ /***/ "./node_modules/is-arrayish/index.js"
2282
2191
  /*!*******************************************!*\
2283
2192
  !*** ./node_modules/is-arrayish/index.js ***!
2284
2193
  \*******************************************/
2285
- /*! no static exports found */
2286
- /***/ (function(module, exports) {
2194
+ (module) {
2287
2195
 
2288
2196
  module.exports = function isArrayish(obj) {
2289
2197
  if (!obj || typeof obj === 'string') {
@@ -2296,14 +2204,13 @@ module.exports = function isArrayish(obj) {
2296
2204
  };
2297
2205
 
2298
2206
 
2299
- /***/ }),
2207
+ /***/ },
2300
2208
 
2301
- /***/ "./node_modules/simple-swizzle/index.js":
2209
+ /***/ "./node_modules/simple-swizzle/index.js"
2302
2210
  /*!**********************************************!*\
2303
2211
  !*** ./node_modules/simple-swizzle/index.js ***!
2304
2212
  \**********************************************/
2305
- /*! no static exports found */
2306
- /***/ (function(module, exports, __webpack_require__) {
2213
+ (module, __unused_webpack_exports, __webpack_require__) {
2307
2214
 
2308
2215
  "use strict";
2309
2216
 
@@ -2337,278 +2244,27 @@ swizzle.wrap = function (fn) {
2337
2244
  };
2338
2245
 
2339
2246
 
2340
- /***/ }),
2341
-
2342
- /***/ "./src/darkmode.js":
2343
- /*!*************************!*\
2344
- !*** ./src/darkmode.js ***!
2345
- \*************************/
2346
- /*! exports provided: run, init, convertBg, updateStyle, getContrast, extend */
2347
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
2348
-
2349
- "use strict";
2350
- __webpack_require__.r(__webpack_exports__);
2351
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "run", function() { return run; });
2352
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "init", function() { return init; });
2353
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "convertBg", function() { return convertBg; });
2354
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateStyle", function() { return updateStyle; });
2355
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getContrast", function() { return getContrast; });
2356
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "extend", function() { return extend; });
2357
- /* harmony import */ var _modules_constant__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./modules/constant */ "./src/modules/constant.js");
2358
- /* harmony import */ var _modules_config__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./modules/config */ "./src/modules/config.js");
2359
- /* harmony import */ var _modules_global__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./modules/global */ "./src/modules/global.js");
2360
- /**
2361
- * @name Darkmode主入口
2362
- *
2363
- * @function run 初始化Dark Mode配置并运行Dark Mode处理
2364
- * @param {DOM Object Array} nodes 要处理的节点列表
2365
- * @param {Object} opt Dark Mode配置,详见init配置说明
2366
- * @return void
2367
- *
2368
- * @function init 初始化Dark Mode配置
2369
- * @param {Function} opt.begin 开始处理时触发的回调
2370
- * @param {Function} opt.showFirstPage 首屏处理完成时触发的回调
2371
- * @param {Function} opt.error 发生error时触发的回调
2372
- * @param {string} opt.mode 强制指定的颜色模式(dark|light), 指定了就不监听系统颜色
2373
- * @param {Object} opt.whitelist 节点白名单
2374
- * @param {Array} opt.whitelist.tagName 标签名列表
2375
- * @param {Array} opt.whitelist.attribute 属性列表
2376
- * @param {boolean} opt.needJudgeFirstPage 是否需要判断首屏
2377
- * @param {boolean} opt.delayBgJudge 是否延迟背景判断
2378
- * @param {DOM Object} opt.container 延迟运行js时使用的容器
2379
- * @param {string} opt.cssSelectorsPrefix css选择器前缀
2380
- * @param {string} opt.defaultLightTextColor 非Dark Mode下字体颜色
2381
- * @param {string} opt.defaultLightBgColor 非Dark Mode下背景颜色
2382
- * @param {string} opt.defaultDarkTextColor Dark Mode下字体颜色
2383
- * @param {string} opt.defaultDarkBgColor Dark Mode下背景颜色
2384
- * @return void
2385
- *
2386
- * @function convertBg 处理背景
2387
- * @param {DOM Object Array} nodes 要处理的节点列表
2388
- * @return void
2389
- *
2390
- * @function updateStyle 更新节点Dark Mode样式
2391
- * @param {DOM Object} node 要更新的节点
2392
- * @param {Object} styles 更新的样式键值对对象,如:{ color: '#ddd' }
2393
- * @return void
2394
- *
2395
- * @function getContrast 获取两个颜色的对比度
2396
- * @param {string} color1 要计算颜色对比度的颜色1,支持css颜色格式
2397
- * @param {string} color2 要计算颜色对比度的颜色2,支持css颜色格式
2398
- * @return {number} 颜色对比度,取值范围为`[1, 21]`
2399
- *
2400
- * @function extend 挂载插件
2401
- * @param {Array} pluginList 插件列表
2402
- * @return void
2403
- *
2404
- */
2405
-
2406
- // 常量
2407
-
2408
- var classReg = new RegExp("".concat(_modules_constant__WEBPACK_IMPORTED_MODULE_0__["CLASS_PREFIX"], "[^ ]+"), 'g');
2409
-
2410
- // Darkmode配置
2411
-
2412
-
2413
-
2414
- // Dark Mode切换
2415
- var mql = null;
2416
- var switchToDarkmode = function switchToDarkmode(mqlObj) {
2417
- var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
2418
- type: 'dom'
2419
- };
2420
- opt.force && (_modules_global__WEBPACK_IMPORTED_MODULE_2__["cssUtils"].isFinish = false); // 如果是强制运行Dark Mode处理逻辑,则重置为未运行
2421
-
2422
- if (_modules_global__WEBPACK_IMPORTED_MODULE_2__["cssUtils"].isFinish) return; // 已运行过Dark Mode处理逻辑则不再运行
2423
-
2424
- try {
2425
- _modules_global__WEBPACK_IMPORTED_MODULE_2__["sdk"].isDarkmode = _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].mode ? _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].mode === 'dark' : mqlObj.matches;
2426
- if (opt.type === 'dom') {
2427
- // 处理节点
2428
- _modules_global__WEBPACK_IMPORTED_MODULE_2__["sdk"].isDarkmode && typeof _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].begin === 'function' && _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].begin(_modules_global__WEBPACK_IMPORTED_MODULE_2__["domUtils"].hasDelay());
2429
- Array.prototype.forEach.call(_modules_global__WEBPACK_IMPORTED_MODULE_2__["domUtils"].get(), function (node) {
2430
- if (_modules_global__WEBPACK_IMPORTED_MODULE_2__["sdk"].isDarkmode && node.className && typeof node.className === 'string') {
2431
- node.className = node.className.replace(classReg, ''); // 过滤掉原有的Dark Mode class,避免外部复制文章时把文章内的Dark Mode class也复制过去导致新文章在Dark Mode下样式错乱
2432
- }
2433
-
2434
- if (_modules_global__WEBPACK_IMPORTED_MODULE_2__["sdk"].isDarkmode || _modules_global__WEBPACK_IMPORTED_MODULE_2__["plugins"].length) {
2435
- if (!_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].needJudgeFirstPage) {
2436
- // 不需要判断首屏
2437
- _modules_global__WEBPACK_IMPORTED_MODULE_2__["cssUtils"].addCss(_modules_global__WEBPACK_IMPORTED_MODULE_2__["sdk"].convert(node)); // 写入非首屏样式
2438
- } else {
2439
- // 判断首屏
2440
- var rect = node.getBoundingClientRect();
2441
- var top = rect.top;
2442
- var bottom = rect.bottom;
2443
- if (top <= 0 && bottom <= 0) {
2444
- // 首屏前面
2445
- _modules_global__WEBPACK_IMPORTED_MODULE_2__["cssUtils"].addCss(_modules_global__WEBPACK_IMPORTED_MODULE_2__["sdk"].convert(node)); // 写入非首屏样式
2446
- } else if (top > 0 && top < _modules_constant__WEBPACK_IMPORTED_MODULE_0__["PAGE_HEIGHT"] || bottom > 0 && bottom < _modules_constant__WEBPACK_IMPORTED_MODULE_0__["PAGE_HEIGHT"]) {
2447
- // 首屏
2448
- _modules_global__WEBPACK_IMPORTED_MODULE_2__["domUtils"].addFirstPageNode(node); // 记录首屏节点
2449
- _modules_global__WEBPACK_IMPORTED_MODULE_2__["cssUtils"].addCss(_modules_global__WEBPACK_IMPORTED_MODULE_2__["sdk"].convert(node), true); // 写入首屏样式
2450
- } else {
2451
- // 首屏后面,理论上,这里最多只会进来一次
2452
- _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].needJudgeFirstPage = false; // 至此,不需要再判断首屏了
2453
-
2454
- // 显示首屏
2455
- _modules_global__WEBPACK_IMPORTED_MODULE_2__["cssUtils"].writeStyle(true); // 写入首屏样式表
2456
- _modules_global__WEBPACK_IMPORTED_MODULE_2__["domUtils"].showFirstPageNodes(); // 显示首屏节点
2457
- typeof _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].showFirstPage === 'function' && _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].showFirstPage(); // 执行首屏回调
2458
-
2459
- _modules_global__WEBPACK_IMPORTED_MODULE_2__["cssUtils"].addCss(_modules_global__WEBPACK_IMPORTED_MODULE_2__["sdk"].convert(node)); // 写入非首屏样式
2460
- }
2461
- }
2462
- }
2463
- });
2464
-
2465
- _modules_global__WEBPACK_IMPORTED_MODULE_2__["plugins"].loopTimes++;
2466
- } else if (opt.type === 'bg') {
2467
- // 处理背景
2468
- _modules_global__WEBPACK_IMPORTED_MODULE_2__["sdk"].isDarkmode && _modules_global__WEBPACK_IMPORTED_MODULE_2__["tnQueue"].forEach(function (text) {
2469
- return _modules_global__WEBPACK_IMPORTED_MODULE_2__["bgStack"].contains(text, function (bg) {
2470
- _modules_global__WEBPACK_IMPORTED_MODULE_2__["cssUtils"].addCss(_modules_global__WEBPACK_IMPORTED_MODULE_2__["cssUtils"].genCss(bg.className, bg.cssKV)); // 写入非首屏样式
2471
- });
2472
- });
2473
- }
2474
-
2475
- if (_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].needJudgeFirstPage || !_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].needJudgeFirstPage && !_modules_global__WEBPACK_IMPORTED_MODULE_2__["domUtils"].showFirstPage) {
2476
- // config.needJudgeFirstPage === ture,表示需要判断首屏但是正文长度没超过一屏
2477
- // config.needJudgeFirstPage === false && domUtils.showFirstPage === false,表示不需要判断首屏且没有做首屏优化
2478
- typeof _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].showFirstPage === 'function' && _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].showFirstPage(); // 执行首屏回调
2479
- }
2480
-
2481
- _modules_global__WEBPACK_IMPORTED_MODULE_2__["cssUtils"].writeStyle(); // 写入非首屏样式表
2482
- _modules_global__WEBPACK_IMPORTED_MODULE_2__["domUtils"].emptyFirstPageNodes(); // 清空记录的首屏节点
2483
-
2484
- if (!_modules_global__WEBPACK_IMPORTED_MODULE_2__["sdk"].isDarkmode) {
2485
- // 非Dark Mode
2486
- // 首次加载页面时为非Dark Mode,标记为不需要判断首屏
2487
- _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].needJudgeFirstPage = false;
2488
-
2489
- // 首次加载页面时为非Dark Mode,标记为不延迟判断背景
2490
- _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].delayBgJudge = false;
2491
- if (_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].container === null && opt.type === 'dom' && _modules_global__WEBPACK_IMPORTED_MODULE_2__["domUtils"].length) {
2492
- _modules_global__WEBPACK_IMPORTED_MODULE_2__["domUtils"].delay(); // 将节点转移到延迟处理队列里
2493
- }
2494
- }
2495
- } catch (e) {
2496
- console.log('An error occurred when running the dark mode conversion algorithm\n', e);
2497
- typeof _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].error === 'function' && _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].error(e);
2498
- }
2499
- };
2500
-
2501
- // 初始化Dark Mode配置并运行Dark Mode处理
2502
- function run(nodes, opt) {
2503
- init(opt); // 初始化配置
2504
-
2505
- _modules_global__WEBPACK_IMPORTED_MODULE_2__["domUtils"].set(nodes);
2506
- switchToDarkmode(mql, {
2507
- force: true,
2508
- type: 'dom'
2509
- });
2510
- }
2511
- ;
2512
-
2513
- // 初始化Dark Mode配置
2514
- function init() {
2515
- var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2516
- if (_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].hasInit) return; // 只可设置一次配置
2517
-
2518
- _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].hasInit = true; // 记录为配置已设置
2519
-
2520
- var tagName = _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].whitelist.tagName;
2521
- var attribute = _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].whitelist.attribute;
2522
- if (opt.whitelist) {
2523
- opt.whitelist.tagName instanceof Array && opt.whitelist.tagName.forEach(function (item) {
2524
- item = item.toUpperCase();
2525
- tagName.indexOf(item) === -1 && tagName.push(item);
2526
- });
2527
- opt.whitelist.attribute instanceof Array && opt.whitelist.attribute.forEach(function (item) {
2528
- attribute.indexOf(item) === -1 && attribute.push(item);
2529
- });
2530
- }
2531
- if (['dark', 'light'].indexOf(opt.mode) > -1) {
2532
- _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('string', opt, 'mode');
2533
- opt.mode === 'dark' && document.getElementsByTagName('html')[0].classList.add(_modules_constant__WEBPACK_IMPORTED_MODULE_0__["HTML_CLASS"]);
2534
- }
2535
- _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('function', opt, 'begin');
2536
- _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('function', opt, 'showFirstPage');
2537
- _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('function', opt, 'error');
2538
- _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('boolean', opt, 'needJudgeFirstPage');
2539
- _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('boolean', opt, 'delayBgJudge');
2540
- _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('dom', opt, 'container');
2541
- _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('string', opt, 'cssSelectorsPrefix');
2542
- _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('string', opt, 'defaultLightTextColor');
2543
- _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('string', opt, 'defaultLightBgColor');
2544
- _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('string', opt, 'defaultDarkTextColor');
2545
- _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('string', opt, 'defaultDarkBgColor');
2546
- _modules_global__WEBPACK_IMPORTED_MODULE_2__["sdk"].init();
2547
- if (!_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].mode && mql === null && window.matchMedia) {
2548
- // 匹配媒体查询
2549
- mql = window.matchMedia(_modules_constant__WEBPACK_IMPORTED_MODULE_0__["MEDIA_QUERY"]);
2550
- mql.addListener(switchToDarkmode); // 监听
2551
- }
2552
- }
2553
-
2554
- ;
2555
-
2556
- // 处理背景
2557
- function convertBg(nodes) {
2558
- _modules_global__WEBPACK_IMPORTED_MODULE_2__["domUtils"].set(nodes);
2559
- if (_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].container !== null) {
2560
- _modules_global__WEBPACK_IMPORTED_MODULE_2__["bgStack"].update(nodes); // 更新背景堆栈
2561
- _modules_global__WEBPACK_IMPORTED_MODULE_2__["tnQueue"].update(nodes); // 更新文字队列
2562
- }
2563
-
2564
- switchToDarkmode(mql, {
2565
- force: true,
2566
- type: 'bg'
2567
- });
2568
- }
2569
- ;
2570
-
2571
- // 更新节点Dark Mode样式
2572
- function updateStyle(node, styles) {
2573
- if (!_modules_global__WEBPACK_IMPORTED_MODULE_2__["cssUtils"].isFinish) return; // 没有运行过Dark Mode处理逻辑则无需运行
2574
- _modules_global__WEBPACK_IMPORTED_MODULE_2__["cssUtils"].addCss(_modules_global__WEBPACK_IMPORTED_MODULE_2__["sdk"].convert(node, styles ? Object.keys(styles).map(function (key) {
2575
- return [key, styles[key]];
2576
- }) : undefined, true), false);
2577
- _modules_global__WEBPACK_IMPORTED_MODULE_2__["cssUtils"].writeStyle();
2578
- }
2579
- ;
2580
-
2581
- // 获取两个颜色的对比度
2582
- function getContrast(color1, color2) {
2583
- return _modules_global__WEBPACK_IMPORTED_MODULE_2__["sdk"].getContrast(color1, color2);
2584
- }
2585
- ;
2586
-
2587
- // 挂载插件
2588
- function extend(pluginList) {
2589
- pluginList.forEach(function (plugin) {
2590
- return _modules_global__WEBPACK_IMPORTED_MODULE_2__["plugins"].extend(plugin);
2591
- });
2592
- }
2593
- ;
2247
+ /***/ },
2594
2248
 
2595
- /***/ }),
2596
-
2597
- /***/ "./src/modules/bgNodeStack.js":
2249
+ /***/ "./src/modules/bgNodeStack.js"
2598
2250
  /*!************************************!*\
2599
2251
  !*** ./src/modules/bgNodeStack.js ***!
2600
2252
  \************************************/
2601
- /*! exports provided: default */
2602
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
2253
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
2603
2254
 
2604
2255
  "use strict";
2605
2256
  __webpack_require__.r(__webpack_exports__);
2606
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return BgNodeStack; });
2257
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2258
+ /* harmony export */ "default": () => (/* binding */ BgNodeStack)
2259
+ /* harmony export */ });
2607
2260
  /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./config */ "./src/modules/config.js");
2608
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2609
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
2610
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
2611
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2261
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2262
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
2263
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
2264
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
2265
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
2266
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
2267
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
2612
2268
  /**
2613
2269
  * @name 需要判断位置的背景节点堆栈
2614
2270
  *
@@ -2631,24 +2287,27 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
2631
2287
  * @param {DOM Object Array} els 要更新的节点对象列表
2632
2288
  * @return void
2633
2289
  *
2290
+ * @method clear 清空堆栈
2291
+ * @return void
2292
+ *
2634
2293
  */
2635
2294
 
2636
2295
  // Darkmode配置
2637
2296
 
2638
2297
  var BgNodeStack = /*#__PURE__*/function () {
2639
- // 需要判断位置的背景堆栈,{ el, className, cssKV, updated, rect }
2640
2298
  // 索引值
2641
2299
 
2642
2300
  function BgNodeStack(prefix) {
2643
2301
  _classCallCheck(this, BgNodeStack);
2644
2302
  _defineProperty(this, "_stack", []);
2303
+ // 需要判断位置的背景堆栈,{ el, className, cssKV, updated, rect }
2645
2304
  _defineProperty(this, "_idx", 0);
2646
2305
  this._prefix = prefix;
2647
2306
  this.classNameReg = new RegExp("".concat(this._prefix, "\\d+"));
2648
2307
  }
2649
2308
 
2650
2309
  // 背景节点入栈
2651
- _createClass(BgNodeStack, [{
2310
+ return _createClass(BgNodeStack, [{
2652
2311
  key: "push",
2653
2312
  value: function push(el, cssKV, cb) {
2654
2313
  var className = "".concat(this._prefix).concat(this._idx++);
@@ -2679,7 +2338,14 @@ var BgNodeStack = /*#__PURE__*/function () {
2679
2338
  }
2680
2339
  });
2681
2340
  while (idxStack.length) {
2682
- var item = this._stack.splice(idxStack.shift(), 1)[0];
2341
+ var idx = idxStack.shift();
2342
+ var item = null;
2343
+ if (_config__WEBPACK_IMPORTED_MODULE_0__["default"].delayBgJudge) {
2344
+ // 延迟背景判断时,先保留背景节点
2345
+ item = this._stack[idx];
2346
+ } else {
2347
+ item = this._stack.splice(idx, 1)[0];
2348
+ }
2683
2349
  typeof callback === 'function' && callback(item);
2684
2350
  }
2685
2351
  }
@@ -2701,29 +2367,36 @@ var BgNodeStack = /*#__PURE__*/function () {
2701
2367
  }
2702
2368
  });
2703
2369
  }
2370
+
2371
+ // 清空堆栈
2372
+ }, {
2373
+ key: "clear",
2374
+ value: function clear() {
2375
+ this._stack = [];
2376
+ }
2704
2377
  }]);
2705
- return BgNodeStack;
2706
2378
  }();
2707
2379
 
2708
2380
  ;
2709
2381
 
2710
- /***/ }),
2382
+ /***/ },
2711
2383
 
2712
- /***/ "./src/modules/color.js":
2384
+ /***/ "./src/modules/color.js"
2713
2385
  /*!******************************!*\
2714
2386
  !*** ./src/modules/color.js ***!
2715
2387
  \******************************/
2716
- /*! exports provided: ColorParser, parseColorName, parseWebkitFillColorAndStrokeColor, mixColors, getColorPerceivedBrightness, adjustBrightnessTo */
2717
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
2388
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
2718
2389
 
2719
2390
  "use strict";
2720
2391
  __webpack_require__.r(__webpack_exports__);
2721
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorParser", function() { return ColorParser; });
2722
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseColorName", function() { return parseColorName; });
2723
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseWebkitFillColorAndStrokeColor", function() { return parseWebkitFillColorAndStrokeColor; });
2724
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mixColors", function() { return mixColors; });
2725
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getColorPerceivedBrightness", function() { return getColorPerceivedBrightness; });
2726
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "adjustBrightnessTo", function() { return adjustBrightnessTo; });
2392
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2393
+ /* harmony export */ ColorParser: () => (/* binding */ ColorParser),
2394
+ /* harmony export */ adjustBrightnessTo: () => (/* binding */ adjustBrightnessTo),
2395
+ /* harmony export */ getColorPerceivedBrightness: () => (/* binding */ getColorPerceivedBrightness),
2396
+ /* harmony export */ mixColors: () => (/* binding */ mixColors),
2397
+ /* harmony export */ parseColorName: () => (/* binding */ parseColorName),
2398
+ /* harmony export */ parseWebkitFillColorAndStrokeColor: () => (/* binding */ parseWebkitFillColorAndStrokeColor)
2399
+ /* harmony export */ });
2727
2400
  /* harmony import */ var color__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! color */ "./node_modules/color/index.js");
2728
2401
  /* harmony import */ var color__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(color__WEBPACK_IMPORTED_MODULE_0__);
2729
2402
  /* harmony import */ var color_name__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! color-name */ "./node_modules/color-name/index.js");
@@ -2764,13 +2437,13 @@ __webpack_require__.r(__webpack_exports__);
2764
2437
 
2765
2438
 
2766
2439
 
2767
- color_name__WEBPACK_IMPORTED_MODULE_1___default.a.windowtext = [0, 0, 0]; // 补上这个colorName
2768
- color_name__WEBPACK_IMPORTED_MODULE_1___default.a.transparent = [255, 255, 255, 0]; // 支持透明,暂定用白色透明度0来表示
2440
+ (color_name__WEBPACK_IMPORTED_MODULE_1___default().windowtext) = [0, 0, 0]; // 补上这个colorName
2441
+ (color_name__WEBPACK_IMPORTED_MODULE_1___default().transparent) = [255, 255, 255, 0]; // 支持透明,暂定用白色透明度0来表示
2769
2442
 
2770
2443
 
2771
2444
  // 常量
2772
2445
 
2773
- var COLOR_NAME_REG = new RegExp(Object.keys(color_name__WEBPACK_IMPORTED_MODULE_1___default.a).map(function (colorName) {
2446
+ var COLOR_NAME_REG = new RegExp(Object.keys((color_name__WEBPACK_IMPORTED_MODULE_1___default())).map(function (colorName) {
2774
2447
  return "\\b".concat(colorName, "\\b");
2775
2448
  }).join('|'), 'ig'); // 生成正则表达式来匹配这些colorName
2776
2449
 
@@ -2793,7 +2466,7 @@ var colorBlend2Color = function colorBlend2Color(colorBlend) {
2793
2466
  var ColorParser = function ColorParser(color) {
2794
2467
  var res = null;
2795
2468
  try {
2796
- res = color instanceof color__WEBPACK_IMPORTED_MODULE_0___default.a ? color : color__WEBPACK_IMPORTED_MODULE_0___default()(color);
2469
+ res = color instanceof (color__WEBPACK_IMPORTED_MODULE_0___default()) ? color : color__WEBPACK_IMPORTED_MODULE_0___default()(color);
2797
2470
  } catch (e) {
2798
2471
  console.log("ignore the invalid color: `".concat(color, "`"));
2799
2472
  }
@@ -2802,10 +2475,10 @@ var ColorParser = function ColorParser(color) {
2802
2475
 
2803
2476
  // 处理颜色,包括清除!important和转换英文定义颜色
2804
2477
  var parseColorName = function parseColorName(color, supportTransparent) {
2805
- return color.replace(_constant__WEBPACK_IMPORTED_MODULE_3__["IMPORTANT_REGEXP"], '').replace(COLOR_NAME_REG, function (match) {
2478
+ return color.replace(_constant__WEBPACK_IMPORTED_MODULE_3__.IMPORTANT_REGEXP, '').replace(COLOR_NAME_REG, function (match) {
2806
2479
  if (!supportTransparent && match === 'transparent') return match; // 如果不支持转换transparent,直接返回transparent
2807
2480
 
2808
- var color = color_name__WEBPACK_IMPORTED_MODULE_1___default.a[match.toLowerCase()];
2481
+ var color = (color_name__WEBPACK_IMPORTED_MODULE_1___default())[match.toLowerCase()];
2809
2482
  return "".concat(color.length > 3 ? 'rgba' : 'rgb', "(").concat(color.toString(), ")");
2810
2483
  });
2811
2484
  };
@@ -2813,7 +2486,7 @@ var parseColorName = function parseColorName(color, supportTransparent) {
2813
2486
  // 处理-webkit-fill-color和-webkit-text-stroke-color,返回处理后的色值,无则返回空字符串
2814
2487
  var parseWebkitFillColorAndStrokeColor = function parseWebkitFillColorAndStrokeColor(color) {
2815
2488
  var newValue = parseColorName(color);
2816
- return _constant__WEBPACK_IMPORTED_MODULE_3__["COLOR_REGEXP"].test(newValue) ? newValue : '';
2489
+ return _constant__WEBPACK_IMPORTED_MODULE_3__.COLOR_REGEXP.test(newValue) ? newValue : '';
2817
2490
  };
2818
2491
 
2819
2492
  // 计算混合颜色
@@ -2860,20 +2533,22 @@ var adjustBrightnessTo = function adjustBrightnessTo(target, rgb) {
2860
2533
  } else if (newTextB === 0 || newTextG === 255) {
2861
2534
  newTextB = (target * 1000 - newTextR * 299 - newTextG * 587) / 114;
2862
2535
  }
2863
- return color__WEBPACK_IMPORTED_MODULE_0___default.a.rgb(newTextR, newTextG, newTextB);
2536
+ return color__WEBPACK_IMPORTED_MODULE_0___default().rgb(newTextR, newTextG, newTextB);
2864
2537
  };
2865
2538
 
2866
- /***/ }),
2539
+ /***/ },
2867
2540
 
2868
- /***/ "./src/modules/config.js":
2541
+ /***/ "./src/modules/config.js"
2869
2542
  /*!*******************************!*\
2870
2543
  !*** ./src/modules/config.js ***!
2871
2544
  \*******************************/
2872
- /*! exports provided: default */
2873
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
2545
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
2874
2546
 
2875
2547
  "use strict";
2876
2548
  __webpack_require__.r(__webpack_exports__);
2549
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2550
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
2551
+ /* harmony export */ });
2877
2552
  /* harmony import */ var _constant__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constant */ "./src/modules/constant.js");
2878
2553
  /**
2879
2554
  * @name Darkmode配置
@@ -2925,7 +2600,6 @@ var config = {
2925
2600
  // 标签名列表
2926
2601
  attribute: [] // 属性列表
2927
2602
  },
2928
-
2929
2603
  needJudgeFirstPage: true,
2930
2604
  // 是否需要判断首屏
2931
2605
  delayBgJudge: false,
@@ -2934,13 +2608,13 @@ var config = {
2934
2608
  // 延迟运行js时使用的容器
2935
2609
  cssSelectorsPrefix: '',
2936
2610
  // css选择器前缀
2937
- defaultLightTextColor: _constant__WEBPACK_IMPORTED_MODULE_0__["DEFAULT_LIGHT_TEXTCOLOR"],
2611
+ defaultLightTextColor: _constant__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_LIGHT_TEXTCOLOR,
2938
2612
  // 非Dark Mode下字体颜色
2939
- defaultLightBgColor: _constant__WEBPACK_IMPORTED_MODULE_0__["DEFAULT_LIGHT_BGCOLOR"],
2613
+ defaultLightBgColor: _constant__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_LIGHT_BGCOLOR,
2940
2614
  // 非Dark Mode下背景颜色
2941
- defaultDarkTextColor: _constant__WEBPACK_IMPORTED_MODULE_0__["DEFAULT_DARK_TEXTCOLOR"],
2615
+ defaultDarkTextColor: _constant__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_DARK_TEXTCOLOR,
2942
2616
  // Dark Mode下字体颜色
2943
- defaultDarkBgColor: _constant__WEBPACK_IMPORTED_MODULE_0__["DEFAULT_DARK_BGCOLOR"],
2617
+ defaultDarkBgColor: _constant__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_DARK_BGCOLOR,
2944
2618
  // Dark Mode下背景颜色
2945
2619
  // 设置配置
2946
2620
  set: function set(type, opt, key) {
@@ -2962,50 +2636,51 @@ var config = {
2962
2636
  }
2963
2637
  }
2964
2638
  };
2965
- /* harmony default export */ __webpack_exports__["default"] = (config);
2639
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (config);
2966
2640
 
2967
- /***/ }),
2641
+ /***/ },
2968
2642
 
2969
- /***/ "./src/modules/constant.js":
2643
+ /***/ "./src/modules/constant.js"
2970
2644
  /*!*********************************!*\
2971
2645
  !*** ./src/modules/constant.js ***!
2972
2646
  \*********************************/
2973
- /*! exports provided: MEDIA_QUERY, CLASS_PREFIX, DM_CLASSNAME_REGEXP, HTML_CLASS, COLORATTR, BGCOLORATTR, ORIGINAL_COLORATTR, ORIGINAL_BGCOLORATTR, BGIMAGEATTR, COMPLEMENTARY_BGIMAGECOLORATTR, BG_COLOR_DELIMITER, DEFAULT_LIGHT_TEXTCOLOR, DEFAULT_LIGHT_BGCOLOR, DEFAULT_DARK_TEXTCOLOR, DEFAULT_DARK_BGCOLOR, WHITE_LIKE_COLOR_BRIGHTNESS, MAX_LIMIT_BGCOLOR_BRIGHTNESS, MIN_LIMIT_OFFSET_BRIGHTNESS, HIGH_BGCOLOR_BRIGHTNESS, HIGH_BLACKWHITE_HSL_BRIGHTNESS, LOW_BLACKWHITE_HSL_BRIGHTNESS, IGNORE_ALPHA, PAGE_HEIGHT, CSS_PROP_SERIES, CSS_PROP_LIST, TABLE_NAME, IMPORTANT_REGEXP, SEMICOLON_PLACEHOLDER, SEMICOLON_PLACEHOLDER_REGEXP, COLOR_REGEXP, COLOR_REGEXP_GLOBAL */
2974
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
2647
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
2975
2648
 
2976
2649
  "use strict";
2977
2650
  __webpack_require__.r(__webpack_exports__);
2978
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MEDIA_QUERY", function() { return MEDIA_QUERY; });
2979
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CLASS_PREFIX", function() { return CLASS_PREFIX; });
2980
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DM_CLASSNAME_REGEXP", function() { return DM_CLASSNAME_REGEXP; });
2981
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HTML_CLASS", function() { return HTML_CLASS; });
2982
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "COLORATTR", function() { return COLORATTR; });
2983
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BGCOLORATTR", function() { return BGCOLORATTR; });
2984
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ORIGINAL_COLORATTR", function() { return ORIGINAL_COLORATTR; });
2985
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ORIGINAL_BGCOLORATTR", function() { return ORIGINAL_BGCOLORATTR; });
2986
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BGIMAGEATTR", function() { return BGIMAGEATTR; });
2987
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "COMPLEMENTARY_BGIMAGECOLORATTR", function() { return COMPLEMENTARY_BGIMAGECOLORATTR; });
2988
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BG_COLOR_DELIMITER", function() { return BG_COLOR_DELIMITER; });
2989
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_LIGHT_TEXTCOLOR", function() { return DEFAULT_LIGHT_TEXTCOLOR; });
2990
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_LIGHT_BGCOLOR", function() { return DEFAULT_LIGHT_BGCOLOR; });
2991
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_DARK_TEXTCOLOR", function() { return DEFAULT_DARK_TEXTCOLOR; });
2992
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_DARK_BGCOLOR", function() { return DEFAULT_DARK_BGCOLOR; });
2993
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WHITE_LIKE_COLOR_BRIGHTNESS", function() { return WHITE_LIKE_COLOR_BRIGHTNESS; });
2994
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MAX_LIMIT_BGCOLOR_BRIGHTNESS", function() { return MAX_LIMIT_BGCOLOR_BRIGHTNESS; });
2995
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MIN_LIMIT_OFFSET_BRIGHTNESS", function() { return MIN_LIMIT_OFFSET_BRIGHTNESS; });
2996
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HIGH_BGCOLOR_BRIGHTNESS", function() { return HIGH_BGCOLOR_BRIGHTNESS; });
2997
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HIGH_BLACKWHITE_HSL_BRIGHTNESS", function() { return HIGH_BLACKWHITE_HSL_BRIGHTNESS; });
2998
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LOW_BLACKWHITE_HSL_BRIGHTNESS", function() { return LOW_BLACKWHITE_HSL_BRIGHTNESS; });
2999
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IGNORE_ALPHA", function() { return IGNORE_ALPHA; });
3000
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PAGE_HEIGHT", function() { return PAGE_HEIGHT; });
3001
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CSS_PROP_SERIES", function() { return CSS_PROP_SERIES; });
3002
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CSS_PROP_LIST", function() { return CSS_PROP_LIST; });
3003
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TABLE_NAME", function() { return TABLE_NAME; });
3004
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IMPORTANT_REGEXP", function() { return IMPORTANT_REGEXP; });
3005
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SEMICOLON_PLACEHOLDER", function() { return SEMICOLON_PLACEHOLDER; });
3006
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SEMICOLON_PLACEHOLDER_REGEXP", function() { return SEMICOLON_PLACEHOLDER_REGEXP; });
3007
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "COLOR_REGEXP", function() { return COLOR_REGEXP; });
3008
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "COLOR_REGEXP_GLOBAL", function() { return COLOR_REGEXP_GLOBAL; });
2651
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2652
+ /* harmony export */ BGCOLORATTR: () => (/* binding */ BGCOLORATTR),
2653
+ /* harmony export */ BGIMAGEATTR: () => (/* binding */ BGIMAGEATTR),
2654
+ /* harmony export */ BG_COLOR_DELIMITER: () => (/* binding */ BG_COLOR_DELIMITER),
2655
+ /* harmony export */ CLASS_PREFIX: () => (/* binding */ CLASS_PREFIX),
2656
+ /* harmony export */ COLORATTR: () => (/* binding */ COLORATTR),
2657
+ /* harmony export */ COLOR_REGEXP: () => (/* binding */ COLOR_REGEXP),
2658
+ /* harmony export */ COLOR_REGEXP_GLOBAL: () => (/* binding */ COLOR_REGEXP_GLOBAL),
2659
+ /* harmony export */ COMPLEMENTARY_BGIMAGECOLORATTR: () => (/* binding */ COMPLEMENTARY_BGIMAGECOLORATTR),
2660
+ /* harmony export */ CSS_PROP_LIST: () => (/* binding */ CSS_PROP_LIST),
2661
+ /* harmony export */ CSS_PROP_SERIES: () => (/* binding */ CSS_PROP_SERIES),
2662
+ /* harmony export */ DEFAULT_DARK_BGCOLOR: () => (/* binding */ DEFAULT_DARK_BGCOLOR),
2663
+ /* harmony export */ DEFAULT_DARK_TEXTCOLOR: () => (/* binding */ DEFAULT_DARK_TEXTCOLOR),
2664
+ /* harmony export */ DEFAULT_LIGHT_BGCOLOR: () => (/* binding */ DEFAULT_LIGHT_BGCOLOR),
2665
+ /* harmony export */ DEFAULT_LIGHT_TEXTCOLOR: () => (/* binding */ DEFAULT_LIGHT_TEXTCOLOR),
2666
+ /* harmony export */ DM_CLASSNAME_REGEXP: () => (/* binding */ DM_CLASSNAME_REGEXP),
2667
+ /* harmony export */ HIGH_BGCOLOR_BRIGHTNESS: () => (/* binding */ HIGH_BGCOLOR_BRIGHTNESS),
2668
+ /* harmony export */ HIGH_BLACKWHITE_HSL_BRIGHTNESS: () => (/* binding */ HIGH_BLACKWHITE_HSL_BRIGHTNESS),
2669
+ /* harmony export */ HTML_CLASS: () => (/* binding */ HTML_CLASS),
2670
+ /* harmony export */ IGNORE_ALPHA: () => (/* binding */ IGNORE_ALPHA),
2671
+ /* harmony export */ IMPORTANT_REGEXP: () => (/* binding */ IMPORTANT_REGEXP),
2672
+ /* harmony export */ LOW_BLACKWHITE_HSL_BRIGHTNESS: () => (/* binding */ LOW_BLACKWHITE_HSL_BRIGHTNESS),
2673
+ /* harmony export */ MAX_LIMIT_BGCOLOR_BRIGHTNESS: () => (/* binding */ MAX_LIMIT_BGCOLOR_BRIGHTNESS),
2674
+ /* harmony export */ MEDIA_QUERY: () => (/* binding */ MEDIA_QUERY),
2675
+ /* harmony export */ MIN_LIMIT_OFFSET_BRIGHTNESS: () => (/* binding */ MIN_LIMIT_OFFSET_BRIGHTNESS),
2676
+ /* harmony export */ ORIGINAL_BGCOLORATTR: () => (/* binding */ ORIGINAL_BGCOLORATTR),
2677
+ /* harmony export */ ORIGINAL_COLORATTR: () => (/* binding */ ORIGINAL_COLORATTR),
2678
+ /* harmony export */ PAGE_HEIGHT: () => (/* binding */ PAGE_HEIGHT),
2679
+ /* harmony export */ SEMICOLON_PLACEHOLDER: () => (/* binding */ SEMICOLON_PLACEHOLDER),
2680
+ /* harmony export */ SEMICOLON_PLACEHOLDER_REGEXP: () => (/* binding */ SEMICOLON_PLACEHOLDER_REGEXP),
2681
+ /* harmony export */ TABLE_NAME: () => (/* binding */ TABLE_NAME),
2682
+ /* harmony export */ WHITE_LIKE_COLOR_BRIGHTNESS: () => (/* binding */ WHITE_LIKE_COLOR_BRIGHTNESS)
2683
+ /* harmony export */ });
3009
2684
  /**
3010
2685
  * @name 常量
3011
2686
  *
@@ -3058,7 +2733,6 @@ var CSS_PROP_SERIES = {
3058
2733
  // 'filter'
3059
2734
  // ],
3060
2735
  };
3061
-
3062
2736
  var CSS_PROP_LIST = Object.keys(CSS_PROP_SERIES).map(function (key) {
3063
2737
  return CSS_PROP_SERIES[key].join('|');
3064
2738
  }).join('|').split('|'); // 支持的css属性平铺列表
@@ -3071,31 +2745,35 @@ var SEMICOLON_PLACEHOLDER_REGEXP = /<\$#_SEMICOLON_#\$>/g;
3071
2745
  var COLOR_REGEXP = /\brgba?\([^)]+\)/i;
3072
2746
  var COLOR_REGEXP_GLOBAL = /\brgba?\([^)]+\)/ig;
3073
2747
 
3074
- /***/ }),
2748
+ /***/ },
3075
2749
 
3076
- /***/ "./src/modules/cssUtils.js":
2750
+ /***/ "./src/modules/cssUtils.js"
3077
2751
  /*!*********************************!*\
3078
2752
  !*** ./src/modules/cssUtils.js ***!
3079
2753
  \*********************************/
3080
- /*! exports provided: default */
3081
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
2754
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
3082
2755
 
3083
2756
  "use strict";
3084
2757
  __webpack_require__.r(__webpack_exports__);
3085
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return CssUtils; });
2758
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2759
+ /* harmony export */ "default": () => (/* binding */ CssUtils)
2760
+ /* harmony export */ });
3086
2761
  /* harmony import */ var _constant__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constant */ "./src/modules/constant.js");
3087
2762
  /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./config */ "./src/modules/config.js");
3088
2763
  /* harmony import */ var _global__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./global */ "./src/modules/global.js");
3089
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2764
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2765
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
3090
2766
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3091
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3092
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
3093
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
3094
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
3095
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3096
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
3097
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
3098
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2767
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
2768
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
2769
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
2770
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
2771
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
2772
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
2773
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
2774
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
2775
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
2776
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
3099
2777
  /**
3100
2778
  * @name 样式相关操作工具对象
3101
2779
  *
@@ -3122,6 +2800,15 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
3122
2800
  * @param {boolean} isFirstPageStyle 是否首屏样式
3123
2801
  * @return void
3124
2802
  *
2803
+ * @method watch 监听生成css键值对
2804
+ * @param {string} key css属性
2805
+ * @param {function} cb 回调函数
2806
+ * @return void
2807
+ *
2808
+ * @method unwatch 取消监听生成css键值对
2809
+ * @param {string} key css属性
2810
+ * @return void
2811
+ *
3125
2812
  */
3126
2813
 
3127
2814
  // 常量
@@ -3131,22 +2818,25 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
3131
2818
 
3132
2819
 
3133
2820
  var CssUtils = /*#__PURE__*/function () {
3134
- // 首屏样式
3135
- // 非首屏样式
3136
-
3137
2821
  // 是否运行过Dark Mode处理逻辑(写入过非首屏样式表则表示已运行过)
3138
2822
 
3139
2823
  function CssUtils() {
3140
2824
  _classCallCheck(this, CssUtils);
3141
2825
  _defineProperty(this, "_firstPageStyle", '');
2826
+ // 首屏样式
3142
2827
  _defineProperty(this, "_otherPageStyle", '');
2828
+ // 非首屏样式
2829
+ _defineProperty(this, "_watcher", {});
2830
+ // 监听器,用于监听生成css键值对
3143
2831
  _defineProperty(this, "isFinish", false);
3144
2832
  }
3145
2833
 
3146
2834
  // 生成css键值对
3147
- _createClass(CssUtils, [{
2835
+ return _createClass(CssUtils, [{
3148
2836
  key: "genCssKV",
3149
2837
  value: function genCssKV(key, val) {
2838
+ var _this$_watcher$key, _this$_watcher;
2839
+ (_this$_watcher$key = (_this$_watcher = this._watcher)[key]) === null || _this$_watcher$key === void 0 || _this$_watcher$key.call(_this$_watcher);
3150
2840
  return "".concat(key, ": ").concat(val, " !important;");
3151
2841
  }
3152
2842
 
@@ -3154,7 +2844,7 @@ var CssUtils = /*#__PURE__*/function () {
3154
2844
  }, {
3155
2845
  key: "genCss",
3156
2846
  value: function genCss(className, cssKV) {
3157
- return "".concat(_config__WEBPACK_IMPORTED_MODULE_1__["default"].mode === 'dark' ? "html.".concat(_constant__WEBPACK_IMPORTED_MODULE_0__["HTML_CLASS"], " ") : '').concat(_config__WEBPACK_IMPORTED_MODULE_1__["default"].cssSelectorsPrefix && "".concat(_config__WEBPACK_IMPORTED_MODULE_1__["default"].cssSelectorsPrefix, " "), ".").concat(className, "{").concat(cssKV, "}");
2847
+ return "".concat(_config__WEBPACK_IMPORTED_MODULE_1__["default"].mode === 'dark' ? "html.".concat(_constant__WEBPACK_IMPORTED_MODULE_0__.HTML_CLASS, " ") : '').concat(_config__WEBPACK_IMPORTED_MODULE_1__["default"].cssSelectorsPrefix && "".concat(_config__WEBPACK_IMPORTED_MODULE_1__["default"].cssSelectorsPrefix, " "), ".").concat(className, "{").concat(cssKV, "}");
3158
2848
  }
3159
2849
 
3160
2850
  // 加入css
@@ -3163,7 +2853,7 @@ var CssUtils = /*#__PURE__*/function () {
3163
2853
  value: function addCss(css) {
3164
2854
  var isFirstPageStyle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
3165
2855
  this[isFirstPageStyle ? '_firstPageStyle' : '_otherPageStyle'] += css;
3166
- _global__WEBPACK_IMPORTED_MODULE_2__["plugins"].addCss(isFirstPageStyle);
2856
+ _global__WEBPACK_IMPORTED_MODULE_2__.plugins.addCss(isFirstPageStyle);
3167
2857
  }
3168
2858
 
3169
2859
  // 写入样式表
@@ -3171,19 +2861,19 @@ var CssUtils = /*#__PURE__*/function () {
3171
2861
  key: "writeStyle",
3172
2862
  value: function writeStyle() {
3173
2863
  var isFirstPageStyle = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
3174
- !isFirstPageStyle && _global__WEBPACK_IMPORTED_MODULE_2__["sdk"].isDarkmode && (this.isFinish = true); // 在Dark Mode下一旦写入了非首屏样式表,则认为已经运行过Dark Mode处理逻辑
2864
+ !isFirstPageStyle && _global__WEBPACK_IMPORTED_MODULE_2__.sdk.isDarkmode && (this.isFinish = true); // 在Dark Mode下一旦写入了非首屏样式表,则认为已经运行过Dark Mode处理逻辑
3175
2865
 
3176
2866
  // 获取样式表内容
3177
- var styles = (_global__WEBPACK_IMPORTED_MODULE_2__["sdk"].isDarkmode ? [{
2867
+ var styles = (_global__WEBPACK_IMPORTED_MODULE_2__.sdk.isDarkmode ? [{
3178
2868
  target: this,
3179
2869
  key: ['_firstPageStyle', '_otherPageStyle'],
3180
2870
  needMediaQuery: true
3181
2871
  }] : []).concat([{
3182
- target: _global__WEBPACK_IMPORTED_MODULE_2__["plugins"],
2872
+ target: _global__WEBPACK_IMPORTED_MODULE_2__.plugins,
3183
2873
  key: ['firstPageStyle', 'otherPageStyle'],
3184
2874
  needMediaQuery: true
3185
2875
  }, {
3186
- target: _global__WEBPACK_IMPORTED_MODULE_2__["plugins"],
2876
+ target: _global__WEBPACK_IMPORTED_MODULE_2__.plugins,
3187
2877
  key: ['firstPageStyleNoMQ', 'otherPageStyleNoMQ'],
3188
2878
  needMediaQuery: false
3189
2879
  }]).map(function (_ref) {
@@ -3204,7 +2894,7 @@ var CssUtils = /*#__PURE__*/function () {
3204
2894
  var style = target[styleKey];
3205
2895
  if (style) {
3206
2896
  target[styleKey] = ''; // 写入样式表后清空内存中的数据
3207
- return _config__WEBPACK_IMPORTED_MODULE_1__["default"].mode === 'dark' || !needMediaQuery ? style : "@media ".concat(_constant__WEBPACK_IMPORTED_MODULE_0__["MEDIA_QUERY"], " {").concat(style, "}");
2897
+ return _config__WEBPACK_IMPORTED_MODULE_1__["default"].mode === 'dark' || !needMediaQuery ? style : "@media ".concat(_constant__WEBPACK_IMPORTED_MODULE_0__.MEDIA_QUERY, " {").concat(style, "}");
3208
2898
  }
3209
2899
  return '';
3210
2900
  }).join('');
@@ -3212,44 +2902,62 @@ var CssUtils = /*#__PURE__*/function () {
3212
2902
  // 写入样式表
3213
2903
  styles && document.head.insertAdjacentHTML('beforeend', "<style type=\"text/css\">".concat(styles, "</style>"));
3214
2904
  }
2905
+
2906
+ // 监听生成css键值对
2907
+ }, {
2908
+ key: "watch",
2909
+ value: function watch(key, cb) {
2910
+ this._watcher[key] = cb;
2911
+ }
2912
+
2913
+ // 取消监听生成css键值对
2914
+ }, {
2915
+ key: "unwatch",
2916
+ value: function unwatch(key) {
2917
+ delete this._watcher[key];
2918
+ }
3215
2919
  }]);
3216
- return CssUtils;
3217
2920
  }();
3218
2921
 
3219
2922
  ;
3220
2923
 
3221
- /***/ }),
2924
+ /***/ },
3222
2925
 
3223
- /***/ "./src/modules/domUtils.js":
2926
+ /***/ "./src/modules/domUtils.js"
3224
2927
  /*!*********************************!*\
3225
2928
  !*** ./src/modules/domUtils.js ***!
3226
2929
  \*********************************/
3227
- /*! exports provided: getChildrenAndIt, hasTextNode, hasTableClass, DomUtils */
3228
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
2930
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
3229
2931
 
3230
2932
  "use strict";
3231
2933
  __webpack_require__.r(__webpack_exports__);
3232
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getChildrenAndIt", function() { return getChildrenAndIt; });
3233
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasTextNode", function() { return hasTextNode; });
3234
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasTableClass", function() { return hasTableClass; });
3235
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DomUtils", function() { return DomUtils; });
2934
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2935
+ /* harmony export */ DomUtils: () => (/* binding */ DomUtils),
2936
+ /* harmony export */ getChildrenAndIt: () => (/* binding */ getChildrenAndIt),
2937
+ /* harmony export */ hasTableClass: () => (/* binding */ hasTableClass),
2938
+ /* harmony export */ hasTextNode: () => (/* binding */ hasTextNode)
2939
+ /* harmony export */ });
3236
2940
  /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./config */ "./src/modules/config.js");
3237
2941
  /* harmony import */ var _global__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./global */ "./src/modules/global.js");
3238
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3239
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
3240
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
3241
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3242
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2942
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2943
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
2944
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
2945
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
2946
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
2947
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
2948
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
2949
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
3243
2950
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3244
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3245
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
3246
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
3247
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
2951
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
2952
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
2953
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
2954
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
3248
2955
  /**
3249
2956
  * @name 节点相关操作工具API
3250
2957
  *
3251
2958
  * @function getChildrenAndIt 获取某个节点及它的所有子节点
3252
2959
  * @param {DOM Object} el 节点对象
2960
+ * @param {boolean} exceptIt 是否排除自身
3253
2961
  * @return {DOM Object Array} 节点对象列表
3254
2962
  *
3255
2963
  * @function hasTextNode 判断某个节点里是否包含文字节点
@@ -3269,7 +2977,8 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
3269
2977
  // 获取某个节点及它的所有子节点
3270
2978
  function getChildrenAndIt(el) {
3271
2979
  var _ref;
3272
- return (_ref = [el]).concat.apply(_ref, _toConsumableArray(el.querySelectorAll('*')));
2980
+ var exceptIt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
2981
+ return (_ref = exceptIt ? [] : [el]).concat.apply(_ref, _toConsumableArray(el.querySelectorAll('*')));
3273
2982
  }
3274
2983
  ;
3275
2984
 
@@ -3339,22 +3048,21 @@ function hasTableClass(el) {
3339
3048
  */
3340
3049
 
3341
3050
  var DomUtils = /*#__PURE__*/function () {
3342
- // 要处理的节点列表
3343
- // 首屏节点列表
3344
- // 延迟处理的节点列表
3345
-
3346
3051
  // 是否已显示首屏
3347
3052
 
3348
3053
  function DomUtils() {
3349
3054
  _classCallCheck(this, DomUtils);
3350
3055
  _defineProperty(this, "_els", []);
3056
+ // 要处理的节点列表
3351
3057
  _defineProperty(this, "_firstPageEls", []);
3058
+ // 首屏节点列表
3352
3059
  _defineProperty(this, "_delayEls", []);
3060
+ // 延迟处理的节点列表
3353
3061
  _defineProperty(this, "showFirstPage", false);
3354
3062
  }
3355
3063
 
3356
3064
  // 要处理的节点列表长度
3357
- _createClass(DomUtils, [{
3065
+ return _createClass(DomUtils, [{
3358
3066
  key: "length",
3359
3067
  get: function get() {
3360
3068
  return this._els.length;
@@ -3376,7 +3084,7 @@ var DomUtils = /*#__PURE__*/function () {
3376
3084
  if (this._els.length) {
3377
3085
  // 有节点
3378
3086
  res = this._els;
3379
- _global__WEBPACK_IMPORTED_MODULE_1__["sdk"].isDarkmode && (this._els = []);
3087
+ _global__WEBPACK_IMPORTED_MODULE_1__.sdk.isDarkmode && (this._els = []);
3380
3088
  } else {
3381
3089
  // 如果没有节点
3382
3090
  if (this._delayEls.length) {
@@ -3434,27 +3142,27 @@ var DomUtils = /*#__PURE__*/function () {
3434
3142
  this._firstPageEls = [];
3435
3143
  }
3436
3144
  }]);
3437
- return DomUtils;
3438
3145
  }();
3439
3146
  ;
3440
3147
 
3441
- /***/ }),
3148
+ /***/ },
3442
3149
 
3443
- /***/ "./src/modules/global.js":
3150
+ /***/ "./src/modules/global.js"
3444
3151
  /*!*******************************!*\
3445
3152
  !*** ./src/modules/global.js ***!
3446
3153
  \*******************************/
3447
- /*! exports provided: plugins, tnQueue, bgStack, cssUtils, domUtils, sdk */
3448
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
3154
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
3449
3155
 
3450
3156
  "use strict";
3451
3157
  __webpack_require__.r(__webpack_exports__);
3452
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "plugins", function() { return plugins; });
3453
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tnQueue", function() { return tnQueue; });
3454
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bgStack", function() { return bgStack; });
3455
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cssUtils", function() { return cssUtils; });
3456
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "domUtils", function() { return domUtils; });
3457
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sdk", function() { return sdk; });
3158
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3159
+ /* harmony export */ bgStack: () => (/* binding */ bgStack),
3160
+ /* harmony export */ cssUtils: () => (/* binding */ cssUtils),
3161
+ /* harmony export */ domUtils: () => (/* binding */ domUtils),
3162
+ /* harmony export */ plugins: () => (/* binding */ plugins),
3163
+ /* harmony export */ sdk: () => (/* binding */ sdk),
3164
+ /* harmony export */ tnQueue: () => (/* binding */ tnQueue)
3165
+ /* harmony export */ });
3458
3166
  /* harmony import */ var _constant__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constant */ "./src/modules/constant.js");
3459
3167
  /* harmony import */ var _plugins__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./plugins */ "./src/modules/plugins.js");
3460
3168
  /* harmony import */ var _textNodeQueue__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textNodeQueue */ "./src/modules/textNodeQueue.js");
@@ -3476,11 +3184,11 @@ var plugins = new _plugins__WEBPACK_IMPORTED_MODULE_1__["default"]();
3476
3184
 
3477
3185
  // 文本节点队列
3478
3186
 
3479
- var tnQueue = new _textNodeQueue__WEBPACK_IMPORTED_MODULE_2__["default"]("".concat(_constant__WEBPACK_IMPORTED_MODULE_0__["CLASS_PREFIX"], "text__"));
3187
+ var tnQueue = new _textNodeQueue__WEBPACK_IMPORTED_MODULE_2__["default"]("".concat(_constant__WEBPACK_IMPORTED_MODULE_0__.CLASS_PREFIX, "text__"));
3480
3188
 
3481
3189
  // 需要判断位置的背景节点堆栈
3482
3190
 
3483
- var bgStack = new _bgNodeStack__WEBPACK_IMPORTED_MODULE_3__["default"]("".concat(_constant__WEBPACK_IMPORTED_MODULE_0__["CLASS_PREFIX"], "bg__"));
3191
+ var bgStack = new _bgNodeStack__WEBPACK_IMPORTED_MODULE_3__["default"]("".concat(_constant__WEBPACK_IMPORTED_MODULE_0__.CLASS_PREFIX, "bg__"));
3484
3192
 
3485
3193
  // 样式相关操作工具对象
3486
3194
 
@@ -3488,29 +3196,33 @@ var cssUtils = new _cssUtils__WEBPACK_IMPORTED_MODULE_4__["default"]();
3488
3196
 
3489
3197
  // 节点相关操作工具对象
3490
3198
 
3491
- var domUtils = new _domUtils__WEBPACK_IMPORTED_MODULE_5__["DomUtils"]();
3199
+ var domUtils = new _domUtils__WEBPACK_IMPORTED_MODULE_5__.DomUtils();
3492
3200
 
3493
3201
  // sdk
3494
3202
 
3495
3203
  var sdk = new _sdk__WEBPACK_IMPORTED_MODULE_6__["default"]();
3496
3204
 
3497
- /***/ }),
3205
+ /***/ },
3498
3206
 
3499
- /***/ "./src/modules/plugins.js":
3207
+ /***/ "./src/modules/plugins.js"
3500
3208
  /*!********************************!*\
3501
3209
  !*** ./src/modules/plugins.js ***!
3502
3210
  \********************************/
3503
- /*! exports provided: default */
3504
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
3211
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
3505
3212
 
3506
3213
  "use strict";
3507
3214
  __webpack_require__.r(__webpack_exports__);
3508
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Plugins; });
3215
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3216
+ /* harmony export */ "default": () => (/* binding */ Plugins)
3217
+ /* harmony export */ });
3509
3218
  /* harmony import */ var _global__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./global */ "./src/modules/global.js");
3510
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3511
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3512
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
3513
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
3219
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
3220
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3221
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
3222
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
3223
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
3224
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
3225
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
3514
3226
  /**
3515
3227
  * @name 插件基类
3516
3228
  *
@@ -3537,17 +3249,17 @@ var Plugin = /*#__PURE__*/function () {
3537
3249
  }
3538
3250
 
3539
3251
  // 遍历次数(全部节点遍历结束算一次)
3540
- _createClass(Plugin, [{
3252
+ return _createClass(Plugin, [{
3541
3253
  key: "loopTimes",
3542
3254
  get: function get() {
3543
- return _global__WEBPACK_IMPORTED_MODULE_0__["plugins"].loopTimes;
3255
+ return _global__WEBPACK_IMPORTED_MODULE_0__.plugins.loopTimes;
3544
3256
  }
3545
3257
 
3546
3258
  // 是否为Dark Mode
3547
3259
  }, {
3548
3260
  key: "isDarkmode",
3549
3261
  get: function get() {
3550
- return _global__WEBPACK_IMPORTED_MODULE_0__["sdk"].isDarkmode;
3262
+ return _global__WEBPACK_IMPORTED_MODULE_0__.sdk.isDarkmode;
3551
3263
  }
3552
3264
 
3553
3265
  // 添加样式
@@ -3555,14 +3267,13 @@ var Plugin = /*#__PURE__*/function () {
3555
3267
  key: "addCss",
3556
3268
  value: function addCss(className, kvList) {
3557
3269
  var needMediaQuery = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
3558
- (needMediaQuery ? cssNeedMQ : cssNoMQ).push(_global__WEBPACK_IMPORTED_MODULE_0__["cssUtils"].genCss(className, kvList.map(function (_ref) {
3270
+ (needMediaQuery ? cssNeedMQ : cssNoMQ).push(_global__WEBPACK_IMPORTED_MODULE_0__.cssUtils.genCss(className, kvList.map(function (_ref) {
3559
3271
  var key = _ref.key,
3560
3272
  value = _ref.value;
3561
- return _global__WEBPACK_IMPORTED_MODULE_0__["cssUtils"].genCssKV(key, value);
3273
+ return _global__WEBPACK_IMPORTED_MODULE_0__.cssUtils.genCssKV(key, value);
3562
3274
  }).join('')));
3563
3275
  }
3564
3276
  }]);
3565
- return Plugin;
3566
3277
  }();
3567
3278
  /**
3568
3279
  * @name 插件系统
@@ -3594,28 +3305,27 @@ var Plugin = /*#__PURE__*/function () {
3594
3305
  *
3595
3306
  */
3596
3307
  var Plugins = /*#__PURE__*/function () {
3597
- // 已挂载的插件列表
3598
-
3599
- // 已挂载的插件数量
3600
- // 已遍历次数(全部节点遍历结束算一次)
3601
- // 首屏样式
3602
- // 非首屏样式
3603
- // 首屏样式(不需要加媒体查询)
3604
3308
  // 非首屏样式(不需要加媒体查询)
3605
3309
 
3606
3310
  function Plugins() {
3607
3311
  _classCallCheck(this, Plugins);
3608
3312
  _defineProperty(this, "_plugins", []);
3313
+ // 已挂载的插件列表
3609
3314
  _defineProperty(this, "length", 0);
3315
+ // 已挂载的插件数量
3610
3316
  _defineProperty(this, "loopTimes", 0);
3317
+ // 已遍历次数(全部节点遍历结束算一次)
3611
3318
  _defineProperty(this, "firstPageStyle", '');
3319
+ // 首屏样式
3612
3320
  _defineProperty(this, "otherPageStyle", '');
3321
+ // 非首屏样式
3613
3322
  _defineProperty(this, "firstPageStyleNoMQ", '');
3323
+ // 首屏样式(不需要加媒体查询)
3614
3324
  _defineProperty(this, "otherPageStyleNoMQ", '');
3615
3325
  }
3616
3326
 
3617
3327
  // 挂载插件
3618
- _createClass(Plugins, [{
3328
+ return _createClass(Plugins, [{
3619
3329
  key: "extend",
3620
3330
  value: function extend(plugin) {
3621
3331
  this._plugins.push(new (plugin(Plugin))());
@@ -3655,23 +3365,23 @@ var Plugins = /*#__PURE__*/function () {
3655
3365
  cssNoMQ = [];
3656
3366
  }
3657
3367
  }]);
3658
- return Plugins;
3659
3368
  }();
3660
3369
 
3661
3370
  ;
3662
3371
 
3663
- /***/ }),
3372
+ /***/ },
3664
3373
 
3665
- /***/ "./src/modules/sdk.js":
3374
+ /***/ "./src/modules/sdk.js"
3666
3375
  /*!****************************!*\
3667
3376
  !*** ./src/modules/sdk.js ***!
3668
3377
  \****************************/
3669
- /*! exports provided: default */
3670
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
3378
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
3671
3379
 
3672
3380
  "use strict";
3673
3381
  __webpack_require__.r(__webpack_exports__);
3674
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return SDK; });
3382
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3383
+ /* harmony export */ "default": () => (/* binding */ SDK)
3384
+ /* harmony export */ });
3675
3385
  /* harmony import */ var color__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! color */ "./node_modules/color/index.js");
3676
3386
  /* harmony import */ var color__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(color__WEBPACK_IMPORTED_MODULE_0__);
3677
3387
  /* harmony import */ var _color__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./color */ "./src/modules/color.js");
@@ -3679,20 +3389,23 @@ __webpack_require__.r(__webpack_exports__);
3679
3389
  /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./config */ "./src/modules/config.js");
3680
3390
  /* harmony import */ var _global__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./global */ "./src/modules/global.js");
3681
3391
  /* harmony import */ var _domUtils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./domUtils */ "./src/modules/domUtils.js");
3682
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3392
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3393
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
3683
3394
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3684
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
3685
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
3686
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3395
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
3396
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
3397
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
3687
3398
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3688
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3689
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
3690
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
3691
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
3692
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3693
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
3694
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
3695
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3399
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
3400
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
3401
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
3402
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
3403
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
3404
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
3405
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
3406
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
3407
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
3408
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
3696
3409
  /**
3697
3410
  * @name 算法SDK
3698
3411
  *
@@ -3728,13 +3441,12 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
3728
3441
  // 节点相关操作工具API
3729
3442
 
3730
3443
  var SDK = /*#__PURE__*/function () {
3731
- // 索引值
3732
-
3733
3444
  // 当前是否需要运行Darkmode处理
3734
3445
 
3735
3446
  function SDK() {
3736
3447
  _classCallCheck(this, SDK);
3737
3448
  _defineProperty(this, "_idx", 0);
3449
+ // 索引值
3738
3450
  _defineProperty(this, "_defaultDarkTextColorRgb", null);
3739
3451
  _defineProperty(this, "_defaultDarkBgColorRgb", null);
3740
3452
  _defineProperty(this, "_defaultDarkBgColorHSL", null);
@@ -3746,9 +3458,9 @@ var SDK = /*#__PURE__*/function () {
3746
3458
  }
3747
3459
 
3748
3460
  // 调整明度
3749
- _createClass(SDK, [{
3461
+ return _createClass(SDK, [{
3750
3462
  key: "_adjustBrightness",
3751
- value: function _adjustBrightness(color, el, options, isUpdate) {
3463
+ value: function _adjustBrightness(color, el, options, isUpdate, needReset) {
3752
3464
  // 背景:
3753
3465
  // 处理原则:白背景改黑,其他高感知亮度背景调暗,低亮度适当提高亮度(感知亮度:https://www.w3.org/TR/AERT/#color-contrast)
3754
3466
  // 处理方法:
@@ -3768,52 +3480,60 @@ var SDK = /*#__PURE__*/function () {
3768
3480
  var extStyle = '';
3769
3481
  if (options.isBgColor) {
3770
3482
  // 背景色
3771
- if (alpha >= _constant__WEBPACK_IMPORTED_MODULE_2__["IGNORE_ALPHA"]) {
3483
+ if (alpha >= _constant__WEBPACK_IMPORTED_MODULE_2__.IGNORE_ALPHA) {
3772
3484
  // 如果设置背景颜色,取消背景图片的影响
3773
- if (el[_constant__WEBPACK_IMPORTED_MODULE_2__["BGIMAGEATTR"]]) delete el[_constant__WEBPACK_IMPORTED_MODULE_2__["BGIMAGEATTR"]];
3485
+ if (el[_constant__WEBPACK_IMPORTED_MODULE_2__.BGIMAGEATTR]) delete el[_constant__WEBPACK_IMPORTED_MODULE_2__.BGIMAGEATTR];
3774
3486
 
3775
3487
  // 如果有背景图片补色
3776
- if (el[_constant__WEBPACK_IMPORTED_MODULE_2__["COMPLEMENTARY_BGIMAGECOLORATTR"]]) {
3488
+ if (el[_constant__WEBPACK_IMPORTED_MODULE_2__.COMPLEMENTARY_BGIMAGECOLORATTR]) {
3777
3489
  // 背景图片补色和当前背景色一致,则无需处理
3778
3490
  // 根据最小可觉差Just-noticeable difference(即JND,表示人类或动物对于某一特定的感官刺激所能察觉的最小改变)和韦伯-费希纳定律,在特定条件下,人类能感知小至 0.5% - 2% 的变化,0.5%换算成对比度为1.1
3779
3491
  // https://zh.wikipedia.org/wiki/%E6%9C%80%E5%B0%8F%E5%8F%AF%E8%A6%BA%E5%B7%AE 最小可觉差wiki
3780
3492
  // https://zh.wikipedia.org/wiki/%E9%9F%8B%E4%BC%AF-%E8%B2%BB%E5%B8%8C%E7%B4%8D%E5%AE%9A%E7%90%86 韦伯-费希纳定理wiki
3781
- if (el[_constant__WEBPACK_IMPORTED_MODULE_2__["COMPLEMENTARY_BGIMAGECOLORATTR"]] === color.toString() || this.getContrast(el[_constant__WEBPACK_IMPORTED_MODULE_2__["COMPLEMENTARY_BGIMAGECOLORATTR"]], color.toString()) < 1.1) return {
3782
- newColor: '',
3783
- extStyle: extStyle
3784
- };
3493
+ if (el[_constant__WEBPACK_IMPORTED_MODULE_2__.COMPLEMENTARY_BGIMAGECOLORATTR] === color.toString() || this.getContrast(el[_constant__WEBPACK_IMPORTED_MODULE_2__.COMPLEMENTARY_BGIMAGECOLORATTR], color.toString()) < 1.1) {
3494
+ return {
3495
+ newColor: needReset ? color.toString() : '',
3496
+ extStyle: extStyle
3497
+ };
3498
+ }
3785
3499
 
3786
3500
  // 否则取消背景图片补色的影响
3787
- Object(_domUtils__WEBPACK_IMPORTED_MODULE_5__["getChildrenAndIt"])(el).forEach(function (dom) {
3788
- delete dom[_constant__WEBPACK_IMPORTED_MODULE_2__["COMPLEMENTARY_BGIMAGECOLORATTR"]];
3501
+ (0,_domUtils__WEBPACK_IMPORTED_MODULE_5__.getChildrenAndIt)(el).forEach(function (dom) {
3502
+ delete dom[_constant__WEBPACK_IMPORTED_MODULE_2__.COMPLEMENTARY_BGIMAGECOLORATTR];
3789
3503
  });
3790
3504
  }
3791
3505
  }
3792
3506
  newColor = this._adjustBackgroundBrightness(color);
3793
3507
  if (!options.hasInlineColor) {
3794
- var parentTextColorStr = el[_constant__WEBPACK_IMPORTED_MODULE_2__["ORIGINAL_COLORATTR"]] || _config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultLightTextColor;
3795
- var parentTextColor = Object(_color__WEBPACK_IMPORTED_MODULE_1__["ColorParser"])(parentTextColorStr);
3508
+ var parentTextColorStr = el[_constant__WEBPACK_IMPORTED_MODULE_2__.ORIGINAL_COLORATTR] || _config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultLightTextColor;
3509
+ var parentTextColor = (0,_color__WEBPACK_IMPORTED_MODULE_1__.ColorParser)(parentTextColorStr);
3796
3510
  if (parentTextColor) {
3797
3511
  var ret = this._adjustBrightness(parentTextColor, el, {
3798
3512
  isTextColor: true,
3799
3513
  parentElementBgColorStr: newColor || color
3800
- }, isUpdate);
3514
+ }, isUpdate, needReset);
3801
3515
  if (ret.newColor) {
3802
- extStyle += _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCssKV('color', ret.newColor);
3516
+ extStyle += _global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.genCssKV('color', ret.newColor);
3803
3517
  } else {
3804
- extStyle += _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCssKV('color', parentTextColor);
3518
+ extStyle += _global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.genCssKV('color', parentTextColor);
3805
3519
  }
3806
3520
  }
3807
3521
  }
3808
3522
  } else if (options.isTextColor || options.isBorderColor) {
3809
3523
  // 字体色、边框色
3810
- var parentElementBgColorStr = options.parentElementBgColorStr || options.isTextColor && el[_constant__WEBPACK_IMPORTED_MODULE_2__["BGCOLORATTR"]] || _config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultDarkBgColor;
3811
- var parentElementBgColor = Object(_color__WEBPACK_IMPORTED_MODULE_1__["ColorParser"])(parentElementBgColorStr);
3524
+ var parentElementBgColorStr = options.parentElementBgColorStr || options.isTextColor && el[_constant__WEBPACK_IMPORTED_MODULE_2__.BGCOLORATTR] || _config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultDarkBgColor;
3525
+ var parentElementBgColor = (0,_color__WEBPACK_IMPORTED_MODULE_1__.ColorParser)(parentElementBgColorStr);
3812
3526
 
3813
3527
  // 无背景图片
3814
- if (parentElementBgColor && !el[_constant__WEBPACK_IMPORTED_MODULE_2__["BGIMAGEATTR"]]) {
3528
+ if (parentElementBgColor && !el[_constant__WEBPACK_IMPORTED_MODULE_2__.BGIMAGEATTR]) {
3815
3529
  newColor = this._adjustTextBrightness(color, parentElementBgColor);
3816
- _global__WEBPACK_IMPORTED_MODULE_4__["plugins"].emit("afterConvertTextColor".concat(isUpdate ? 'ByUpdateStyle' : ''), el, {
3530
+ var emitNameSuffix = '';
3531
+ if (isUpdate) {
3532
+ emitNameSuffix = 'ByUpdateStyle';
3533
+ } else if (needReset) {
3534
+ emitNameSuffix = 'ByReset';
3535
+ }
3536
+ _global__WEBPACK_IMPORTED_MODULE_4__.plugins.emit("afterConvertTextColor".concat(emitNameSuffix), el, {
3817
3537
  // fontColor: color,
3818
3538
  fontColor: newColor,
3819
3539
  bgColor: parentElementBgColor
@@ -3822,11 +3542,10 @@ var SDK = /*#__PURE__*/function () {
3822
3542
  } else if (options.isTextShadow) {
3823
3543
  // 字体阴影
3824
3544
  // 无背景图片
3825
- if (!el[_constant__WEBPACK_IMPORTED_MODULE_2__["BGIMAGEATTR"]]) {
3545
+ if (!el[_constant__WEBPACK_IMPORTED_MODULE_2__.BGIMAGEATTR]) {
3826
3546
  newColor = this._adjustBackgroundBrightness(color); // 按照背景色的方法来处理
3827
3547
  }
3828
3548
  }
3829
-
3830
3549
  return {
3831
3550
  newColor: newColor && color.toString() !== newColor.toString() && newColor.alpha(alpha).rgb(),
3832
3551
  extStyle: extStyle
@@ -3839,40 +3558,40 @@ var SDK = /*#__PURE__*/function () {
3839
3558
  value: function _adjustTextBrightness(textColor, bgColor) {
3840
3559
  var bgColorRgb = bgColor.rgb().array();
3841
3560
  var bgColorAlpha = bgColor.alpha();
3842
- var bgColorPerceivedBrightness = Object(_color__WEBPACK_IMPORTED_MODULE_1__["getColorPerceivedBrightness"])(bgColorRgb);
3561
+ var bgColorPerceivedBrightness = (0,_color__WEBPACK_IMPORTED_MODULE_1__.getColorPerceivedBrightness)(bgColorRgb);
3843
3562
  var bgColorWithOpacityPerceivedBrightness = bgColorPerceivedBrightness * bgColorAlpha + this._defaultDarkBgColorBrightness * (1 - bgColorAlpha);
3844
3563
  var textColorRgb = textColor.rgb().array();
3845
3564
  var textColorHSL = textColor.hsl().array();
3846
3565
  var textColorAlpha = textColor.alpha();
3847
- var textPerceivedBrightness = Object(_color__WEBPACK_IMPORTED_MODULE_1__["getColorPerceivedBrightness"])(textColorRgb);
3566
+ var textPerceivedBrightness = (0,_color__WEBPACK_IMPORTED_MODULE_1__.getColorPerceivedBrightness)(textColorRgb);
3848
3567
  var offsetPerceivedBrightness = Math.abs(bgColorWithOpacityPerceivedBrightness - textPerceivedBrightness);
3849
3568
 
3850
3569
  // 用户设置为高亮字体颜色(接近白色亮度),不处理,保持高亮
3851
- if (textPerceivedBrightness >= _constant__WEBPACK_IMPORTED_MODULE_2__["WHITE_LIKE_COLOR_BRIGHTNESS"]) return textColor;
3570
+ if (textPerceivedBrightness >= _constant__WEBPACK_IMPORTED_MODULE_2__.WHITE_LIKE_COLOR_BRIGHTNESS) return textColor;
3852
3571
  if (offsetPerceivedBrightness > this._maxLimitOffsetBrightness && bgColorWithOpacityPerceivedBrightness <= this._defaultDarkBgColorBrightness + 2) {
3853
- return Object(_color__WEBPACK_IMPORTED_MODULE_1__["adjustBrightnessTo"])(this._maxLimitOffsetBrightness + bgColorWithOpacityPerceivedBrightness, textColorRgb).alpha(textColorAlpha);
3572
+ return (0,_color__WEBPACK_IMPORTED_MODULE_1__.adjustBrightnessTo)(this._maxLimitOffsetBrightness + bgColorWithOpacityPerceivedBrightness, textColorRgb).alpha(textColorAlpha);
3854
3573
  }
3855
3574
 
3856
3575
  // 如果感知亮度差大于阈值,无需调整
3857
- if (offsetPerceivedBrightness >= _constant__WEBPACK_IMPORTED_MODULE_2__["MIN_LIMIT_OFFSET_BRIGHTNESS"]) return textColor;
3858
- if (bgColorWithOpacityPerceivedBrightness >= _constant__WEBPACK_IMPORTED_MODULE_2__["HIGH_BGCOLOR_BRIGHTNESS"]) {
3576
+ if (offsetPerceivedBrightness >= _constant__WEBPACK_IMPORTED_MODULE_2__.MIN_LIMIT_OFFSET_BRIGHTNESS) return textColor;
3577
+ if (bgColorWithOpacityPerceivedBrightness >= _constant__WEBPACK_IMPORTED_MODULE_2__.HIGH_BGCOLOR_BRIGHTNESS) {
3859
3578
  // 亮背景,调暗字体
3860
- if (textColorHSL[2] > 90 - _constant__WEBPACK_IMPORTED_MODULE_2__["HIGH_BLACKWHITE_HSL_BRIGHTNESS"]) {
3579
+ if (textColorHSL[2] > 90 - _constant__WEBPACK_IMPORTED_MODULE_2__.HIGH_BLACKWHITE_HSL_BRIGHTNESS) {
3861
3580
  // 优先调字体的亮度已带到降低感知亮度的目的
3862
3581
  textColorHSL[2] = 90 - textColorHSL[2];
3863
- var tmpTextColor = color__WEBPACK_IMPORTED_MODULE_0___default.a.hsl.apply(color__WEBPACK_IMPORTED_MODULE_0___default.a, _toConsumableArray(textColorHSL)).alpha(textColorAlpha);
3582
+ var tmpTextColor = color__WEBPACK_IMPORTED_MODULE_0___default().hsl.apply((color__WEBPACK_IMPORTED_MODULE_0___default()), _toConsumableArray(textColorHSL)).alpha(textColorAlpha);
3864
3583
  return this._adjustTextBrightness(tmpTextColor, bgColor);
3865
3584
  }
3866
- return Object(_color__WEBPACK_IMPORTED_MODULE_1__["adjustBrightnessTo"])(Math.min(this._maxLimitOffsetBrightness, bgColorWithOpacityPerceivedBrightness - _constant__WEBPACK_IMPORTED_MODULE_2__["MIN_LIMIT_OFFSET_BRIGHTNESS"]), textColorRgb).alpha(textColorAlpha);
3585
+ return (0,_color__WEBPACK_IMPORTED_MODULE_1__.adjustBrightnessTo)(Math.min(this._maxLimitOffsetBrightness, bgColorWithOpacityPerceivedBrightness - _constant__WEBPACK_IMPORTED_MODULE_2__.MIN_LIMIT_OFFSET_BRIGHTNESS), textColorRgb).alpha(textColorAlpha);
3867
3586
  } else {
3868
3587
  // 暗背景,调亮字体
3869
- if (textColorHSL[2] <= _constant__WEBPACK_IMPORTED_MODULE_2__["HIGH_BLACKWHITE_HSL_BRIGHTNESS"]) {
3588
+ if (textColorHSL[2] <= _constant__WEBPACK_IMPORTED_MODULE_2__.HIGH_BLACKWHITE_HSL_BRIGHTNESS) {
3870
3589
  // 优先调字体的亮度已带到提高感知亮度的目的
3871
3590
  textColorHSL[2] = 90 - textColorHSL[2];
3872
- var _tmpTextColor = color__WEBPACK_IMPORTED_MODULE_0___default.a.hsl.apply(color__WEBPACK_IMPORTED_MODULE_0___default.a, _toConsumableArray(textColorHSL)).alpha(textColorAlpha);
3591
+ var _tmpTextColor = color__WEBPACK_IMPORTED_MODULE_0___default().hsl.apply((color__WEBPACK_IMPORTED_MODULE_0___default()), _toConsumableArray(textColorHSL)).alpha(textColorAlpha);
3873
3592
  return this._adjustTextBrightness(_tmpTextColor, bgColor);
3874
3593
  }
3875
- return Object(_color__WEBPACK_IMPORTED_MODULE_1__["adjustBrightnessTo"])(Math.min(this._maxLimitOffsetBrightness, bgColorWithOpacityPerceivedBrightness + _constant__WEBPACK_IMPORTED_MODULE_2__["MIN_LIMIT_OFFSET_BRIGHTNESS"]), textColorRgb).alpha(textColorAlpha);
3594
+ return (0,_color__WEBPACK_IMPORTED_MODULE_1__.adjustBrightnessTo)(Math.min(this._maxLimitOffsetBrightness, bgColorWithOpacityPerceivedBrightness + _constant__WEBPACK_IMPORTED_MODULE_2__.MIN_LIMIT_OFFSET_BRIGHTNESS), textColorRgb).alpha(textColorAlpha);
3876
3595
  }
3877
3596
  }
3878
3597
 
@@ -3883,21 +3602,21 @@ var SDK = /*#__PURE__*/function () {
3883
3602
  var bgColorRgb = bgColor.rgb().array();
3884
3603
  var bgColorHsl = bgColor.hsl().array();
3885
3604
  var bgColorAlpha = bgColor.alpha();
3886
- var bgColorPerceivedBrightness = Object(_color__WEBPACK_IMPORTED_MODULE_1__["getColorPerceivedBrightness"])(bgColorRgb);
3605
+ var bgColorPerceivedBrightness = (0,_color__WEBPACK_IMPORTED_MODULE_1__.getColorPerceivedBrightness)(bgColorRgb);
3887
3606
  var newColor = bgColor;
3888
- if (bgColorHsl[1] === 0 && bgColorHsl[2] > _constant__WEBPACK_IMPORTED_MODULE_2__["HIGH_BLACKWHITE_HSL_BRIGHTNESS"] || bgColorPerceivedBrightness > _constant__WEBPACK_IMPORTED_MODULE_2__["WHITE_LIKE_COLOR_BRIGHTNESS"]) {
3607
+ if (bgColorHsl[1] === 0 && bgColorHsl[2] > _constant__WEBPACK_IMPORTED_MODULE_2__.HIGH_BLACKWHITE_HSL_BRIGHTNESS || bgColorPerceivedBrightness > _constant__WEBPACK_IMPORTED_MODULE_2__.WHITE_LIKE_COLOR_BRIGHTNESS) {
3889
3608
  // 饱和度为0(黑白灰色),亮度大于HIGH_BLACKWHITE_HSL_BRIGHTNESS或感知亮度大于WHITE_LIKE_COLOR_BRIGHTNESS(白色)时,做亮度取反处理
3890
- newColor = color__WEBPACK_IMPORTED_MODULE_0___default.a.hsl(0, 0, Math.min(100, 100 + this._defaultDarkBgColorHslBrightness - bgColorHsl[2]));
3891
- } else if (bgColorPerceivedBrightness > _constant__WEBPACK_IMPORTED_MODULE_2__["MAX_LIMIT_BGCOLOR_BRIGHTNESS"]) {
3609
+ newColor = color__WEBPACK_IMPORTED_MODULE_0___default().hsl(0, 0, Math.min(100, 100 + this._defaultDarkBgColorHslBrightness - bgColorHsl[2]));
3610
+ } else if (bgColorPerceivedBrightness > _constant__WEBPACK_IMPORTED_MODULE_2__.MAX_LIMIT_BGCOLOR_BRIGHTNESS) {
3892
3611
  // 感知亮度大于MAX_LIMIT_BGCOLOR_BRIGHTNESS,将感知亮度设为MAX_LIMIT_BGCOLOR_BRIGHTNESS
3893
- newColor = Object(_color__WEBPACK_IMPORTED_MODULE_1__["adjustBrightnessTo"])(_constant__WEBPACK_IMPORTED_MODULE_2__["MAX_LIMIT_BGCOLOR_BRIGHTNESS"], bgColorRgb).alpha(bgColorAlpha);
3612
+ newColor = (0,_color__WEBPACK_IMPORTED_MODULE_1__.adjustBrightnessTo)(_constant__WEBPACK_IMPORTED_MODULE_2__.MAX_LIMIT_BGCOLOR_BRIGHTNESS, bgColorRgb).alpha(bgColorAlpha);
3894
3613
  // const ratio = (MAX_LIMIT_BGCOLOR_BRIGHTNESS * 1000)
3895
3614
  // / (bgColorRgb[0] * 299 + bgColorRgb[1] * 587 + bgColorRgb[2] * 114);
3896
3615
  // newColor = Color.rgb(bgColorRgb[0] * ratio, bgColorRgb[1] * ratio, bgColorRgb[2] * ratio);
3897
- } else if (bgColorHsl[2] < _constant__WEBPACK_IMPORTED_MODULE_2__["LOW_BLACKWHITE_HSL_BRIGHTNESS"]) {
3616
+ } else if (bgColorHsl[2] < _constant__WEBPACK_IMPORTED_MODULE_2__.LOW_BLACKWHITE_HSL_BRIGHTNESS) {
3898
3617
  // 亮度小于LOW_BLACKWHITE_HSL_BRIGHTNESS,将亮度设为LOW_BLACKWHITE_HSL_BRIGHTNESS,适当提高亮度
3899
- bgColorHsl[2] = _constant__WEBPACK_IMPORTED_MODULE_2__["LOW_BLACKWHITE_HSL_BRIGHTNESS"];
3900
- newColor = color__WEBPACK_IMPORTED_MODULE_0___default.a.hsl.apply(color__WEBPACK_IMPORTED_MODULE_0___default.a, _toConsumableArray(bgColorHsl));
3618
+ bgColorHsl[2] = _constant__WEBPACK_IMPORTED_MODULE_2__.LOW_BLACKWHITE_HSL_BRIGHTNESS;
3619
+ newColor = color__WEBPACK_IMPORTED_MODULE_0___default().hsl.apply((color__WEBPACK_IMPORTED_MODULE_0___default()), _toConsumableArray(bgColorHsl));
3901
3620
  }
3902
3621
  return newColor.alpha(bgColorAlpha).rgb();
3903
3622
  }
@@ -3905,23 +3624,23 @@ var SDK = /*#__PURE__*/function () {
3905
3624
  // 叠加渐变色到背景色中,并更新背景色相关属性值以及文本颜色
3906
3625
  }, {
3907
3626
  key: "_updateBgWithGradient",
3908
- value: function _updateBgWithGradient(gradientColor, el, className, cssKVList, hasInlineColor, isUpdate) {
3909
- var newBgColor = Object(_color__WEBPACK_IMPORTED_MODULE_1__["mixColors"])([el[_constant__WEBPACK_IMPORTED_MODULE_2__["BGCOLORATTR"]] || _config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultDarkBgColor, gradientColor], 'normal');
3910
- var newOriginalBgColor = (el[_constant__WEBPACK_IMPORTED_MODULE_2__["ORIGINAL_BGCOLORATTR"]] || _config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultLightBgColor).split(_constant__WEBPACK_IMPORTED_MODULE_2__["BG_COLOR_DELIMITER"]).concat(gradientColor.toString()).join(_constant__WEBPACK_IMPORTED_MODULE_2__["BG_COLOR_DELIMITER"]);
3911
- Object(_domUtils__WEBPACK_IMPORTED_MODULE_5__["getChildrenAndIt"])(el).forEach(function (dom) {
3912
- dom[_constant__WEBPACK_IMPORTED_MODULE_2__["BGCOLORATTR"]] = newBgColor;
3913
- dom[_constant__WEBPACK_IMPORTED_MODULE_2__["ORIGINAL_BGCOLORATTR"]] = newOriginalBgColor;
3627
+ value: function _updateBgWithGradient(gradientColor, el, className, cssKVList, hasInlineColor, isUpdate, needReset) {
3628
+ var newBgColor = (0,_color__WEBPACK_IMPORTED_MODULE_1__.mixColors)([el[_constant__WEBPACK_IMPORTED_MODULE_2__.BGCOLORATTR] || _config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultDarkBgColor, gradientColor], 'normal');
3629
+ var newOriginalBgColor = (el[_constant__WEBPACK_IMPORTED_MODULE_2__.ORIGINAL_BGCOLORATTR] || _config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultLightBgColor).split(_constant__WEBPACK_IMPORTED_MODULE_2__.BG_COLOR_DELIMITER).concat(gradientColor.toString()).join(_constant__WEBPACK_IMPORTED_MODULE_2__.BG_COLOR_DELIMITER);
3630
+ (0,_domUtils__WEBPACK_IMPORTED_MODULE_5__.getChildrenAndIt)(el).forEach(function (dom) {
3631
+ dom[_constant__WEBPACK_IMPORTED_MODULE_2__.BGCOLORATTR] = newBgColor;
3632
+ dom[_constant__WEBPACK_IMPORTED_MODULE_2__.ORIGINAL_BGCOLORATTR] = newOriginalBgColor;
3914
3633
  });
3915
3634
  var lastKV = cssKVList.slice(-1)[0];
3916
3635
  if (lastKV[0] === 'color') {
3917
- var ret = this._adjustBrightness(Object(_color__WEBPACK_IMPORTED_MODULE_1__["ColorParser"])(Object(_color__WEBPACK_IMPORTED_MODULE_1__["parseColorName"])(lastKV[1])), el, {
3636
+ var ret = this._adjustBrightness((0,_color__WEBPACK_IMPORTED_MODULE_1__.ColorParser)((0,_color__WEBPACK_IMPORTED_MODULE_1__.parseColorName)(lastKV[1])), el, {
3918
3637
  isBgColor: false,
3919
3638
  isTextShadow: false,
3920
3639
  isTextColor: true,
3921
3640
  isBorderColor: false,
3922
3641
  hasInlineColor: hasInlineColor
3923
- }, isUpdate);
3924
- if (ret.newColor) return _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCss(className, _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCssKV('color', ret.newColor));
3642
+ }, isUpdate, needReset);
3643
+ if (ret.newColor) return _global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.genCss(className, _global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.genCssKV('color', ret.newColor));
3925
3644
  }
3926
3645
  return '';
3927
3646
  }
@@ -3940,11 +3659,11 @@ var SDK = /*#__PURE__*/function () {
3940
3659
  }, {
3941
3660
  key: "init",
3942
3661
  value: function init() {
3943
- this._defaultDarkTextColorRgb = Object(_color__WEBPACK_IMPORTED_MODULE_1__["ColorParser"])(_config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultDarkTextColor).rgb().array();
3944
- this._defaultDarkBgColorRgb = Object(_color__WEBPACK_IMPORTED_MODULE_1__["ColorParser"])(_config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultDarkBgColor).rgb().array();
3945
- this._defaultDarkBgColorHSL = Object(_color__WEBPACK_IMPORTED_MODULE_1__["ColorParser"])(_config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultDarkBgColor).hsl().array();
3946
- this._defaultDarkTextColorBrightness = Object(_color__WEBPACK_IMPORTED_MODULE_1__["getColorPerceivedBrightness"])(this._defaultDarkTextColorRgb);
3947
- this._defaultDarkBgColorBrightness = Object(_color__WEBPACK_IMPORTED_MODULE_1__["getColorPerceivedBrightness"])(this._defaultDarkBgColorRgb);
3662
+ this._defaultDarkTextColorRgb = (0,_color__WEBPACK_IMPORTED_MODULE_1__.ColorParser)(_config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultDarkTextColor).rgb().array();
3663
+ this._defaultDarkBgColorRgb = (0,_color__WEBPACK_IMPORTED_MODULE_1__.ColorParser)(_config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultDarkBgColor).rgb().array();
3664
+ this._defaultDarkBgColorHSL = (0,_color__WEBPACK_IMPORTED_MODULE_1__.ColorParser)(_config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultDarkBgColor).hsl().array();
3665
+ this._defaultDarkTextColorBrightness = (0,_color__WEBPACK_IMPORTED_MODULE_1__.getColorPerceivedBrightness)(this._defaultDarkTextColorRgb);
3666
+ this._defaultDarkBgColorBrightness = (0,_color__WEBPACK_IMPORTED_MODULE_1__.getColorPerceivedBrightness)(this._defaultDarkBgColorRgb);
3948
3667
  this._defaultDarkBgColorHslBrightness = this._defaultDarkBgColorHSL[2];
3949
3668
  this._maxLimitOffsetBrightness = this._defaultDarkTextColorBrightness - this._defaultDarkBgColorBrightness;
3950
3669
  }
@@ -3952,14 +3671,20 @@ var SDK = /*#__PURE__*/function () {
3952
3671
  // 处理节点
3953
3672
  }, {
3954
3673
  key: "convert",
3955
- value: function convert(el, cssKVList, isUpdate) {
3674
+ value: function convert(el, cssKVList, isUpdate, needReset) {
3956
3675
  var _this = this;
3957
- _global__WEBPACK_IMPORTED_MODULE_4__["plugins"].resetCss();
3958
- _global__WEBPACK_IMPORTED_MODULE_4__["plugins"].emit("beforeConvertNode".concat(isUpdate ? 'ByUpdateStyle' : ''), el);
3676
+ _global__WEBPACK_IMPORTED_MODULE_4__.plugins.resetCss();
3677
+ var emitNameSuffix = '';
3678
+ if (isUpdate) {
3679
+ emitNameSuffix = 'ByUpdateStyle';
3680
+ } else if (needReset) {
3681
+ emitNameSuffix = 'ByReset';
3682
+ }
3683
+ _global__WEBPACK_IMPORTED_MODULE_4__.plugins.emit("beforeConvertNode".concat(emitNameSuffix), el);
3959
3684
  var css = ''; // css
3960
3685
  var bgCss = ''; // 文字底图css
3961
3686
 
3962
- if (this.isDarkmode || isUpdate) {
3687
+ if (this.isDarkmode || isUpdate || needReset) {
3963
3688
  var nodeName = el.nodeName;
3964
3689
  if (_config__WEBPACK_IMPORTED_MODULE_3__["default"].whitelist.tagName.indexOf(nodeName) > -1) return '';
3965
3690
  if (_config__WEBPACK_IMPORTED_MODULE_3__["default"].whitelist.attribute.some(function (attribute) {
@@ -3969,10 +3694,10 @@ var SDK = /*#__PURE__*/function () {
3969
3694
  if (!cssKVList) {
3970
3695
  // 没有传入cssKVList就从内联样式中提取
3971
3696
  // styles.cssText 读出来的颜色统一是rgba格式,除了用英文定义颜色(如:black、white)
3972
- cssKVList = (styles.cssText && styles.cssText.replace(/("[^;]*);([^;]*")|('[^;]*);([^;]*')/g, "$1$3".concat(_constant__WEBPACK_IMPORTED_MODULE_2__["SEMICOLON_PLACEHOLDER"], "$2$4")).split(';') || []).map(function (cssStr) {
3697
+ cssKVList = (styles.cssText && styles.cssText.replace(/("[^;]*);([^;]*")|('[^;]*);([^;]*')/g, "$1$3".concat(_constant__WEBPACK_IMPORTED_MODULE_2__.SEMICOLON_PLACEHOLDER, "$2$4")).split(';') || []).map(function (cssStr) {
3973
3698
  // 将cssStr转换为[key, value],并清除各个元素的前后空白字符
3974
3699
  var splitIdx = cssStr.indexOf(':');
3975
- return [cssStr.slice(0, splitIdx).toLowerCase(), cssStr.slice(splitIdx + 1).replace(_constant__WEBPACK_IMPORTED_MODULE_2__["SEMICOLON_PLACEHOLDER_REGEXP"], ';')].map(function (item) {
3700
+ return [cssStr.slice(0, splitIdx).toLowerCase(), cssStr.slice(splitIdx + 1).replace(_constant__WEBPACK_IMPORTED_MODULE_2__.SEMICOLON_PLACEHOLDER_REGEXP, ';')].map(function (item) {
3976
3701
  return (item || '').replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
3977
3702
  });
3978
3703
  });
@@ -4001,7 +3726,7 @@ var SDK = /*#__PURE__*/function () {
4001
3726
  }
4002
3727
 
4003
3728
  // 过滤掉一些key
4004
- return _constant__WEBPACK_IMPORTED_MODULE_2__["CSS_PROP_LIST"].indexOf(key) > -1;
3729
+ return _constant__WEBPACK_IMPORTED_MODULE_2__.CSS_PROP_LIST.indexOf(key) > -1;
4005
3730
  }).sort(function (_ref3, _ref4) {
4006
3731
  var _ref5 = _slicedToArray(_ref3, 1),
4007
3732
  key1 = _ref5[0];
@@ -4019,14 +3744,14 @@ var SDK = /*#__PURE__*/function () {
4019
3744
  }
4020
3745
  return -1;
4021
3746
  });
4022
- if (_constant__WEBPACK_IMPORTED_MODULE_2__["TABLE_NAME"].indexOf(nodeName) > -1 && !hasInlineBackground) {
3747
+ if (_constant__WEBPACK_IMPORTED_MODULE_2__.TABLE_NAME.indexOf(nodeName) > -1 && !hasInlineBackground) {
4023
3748
  // 如果table没有内联样式
4024
3749
  this._try(function () {
4025
- var colorStr = Object(_domUtils__WEBPACK_IMPORTED_MODULE_5__["hasTableClass"])(el); // 获取class对应的lm色值
3750
+ var colorStr = (0,_domUtils__WEBPACK_IMPORTED_MODULE_5__.hasTableClass)(el); // 获取class对应的lm色值
4026
3751
  if (!colorStr) colorStr = el.getAttribute('bgcolor'); // 如果没有class则获取bgcolor的色值
4027
3752
  if (colorStr) {
4028
3753
  // 有色值(class对应的lm色值或者是bgcolor色值),则当做内联样式来处理
4029
- var color = Object(_color__WEBPACK_IMPORTED_MODULE_1__["ColorParser"])(colorStr);
3754
+ var color = (0,_color__WEBPACK_IMPORTED_MODULE_1__.ColorParser)(colorStr);
4030
3755
  if (color) {
4031
3756
  cssKVList.unshift(['background-color', color.toString()]);
4032
3757
  hasInlineBackground = true;
@@ -4040,7 +3765,7 @@ var SDK = /*#__PURE__*/function () {
4040
3765
  var colorStr = el.getAttribute('color'); // 获取color的色值
4041
3766
  if (colorStr) {
4042
3767
  // 有色值,则当做内联样式来处理
4043
- var color = Object(_color__WEBPACK_IMPORTED_MODULE_1__["ColorParser"])(colorStr);
3768
+ var color = (0,_color__WEBPACK_IMPORTED_MODULE_1__.ColorParser)(colorStr);
4044
3769
  if (color) {
4045
3770
  cssKVList.push(['color', color.toString()]);
4046
3771
  hasInlineColor = true;
@@ -4063,27 +3788,25 @@ var SDK = /*#__PURE__*/function () {
4063
3788
  webkitTextLen = idx; // 记录-webkit-text相关样式的长度
4064
3789
  return true; // 结束遍历
4065
3790
  }
4066
-
4067
3791
  switch (key) {
4068
3792
  case '-webkit-text-fill-color':
4069
- webkitFillColor = Object(_color__WEBPACK_IMPORTED_MODULE_1__["parseWebkitFillColorAndStrokeColor"])(value);
3793
+ webkitFillColor = (0,_color__WEBPACK_IMPORTED_MODULE_1__.parseWebkitFillColorAndStrokeColor)(value);
4070
3794
  break;
4071
3795
  case '-webkit-text-stroke':
4072
3796
  {
4073
3797
  // 有-webkit-text-stroke时就不会有-webkit-text-stroke-color
4074
3798
  var newValue = value.split(' ');
4075
- newValue.length === 2 && (webkitStrokeColor = Object(_color__WEBPACK_IMPORTED_MODULE_1__["parseWebkitFillColorAndStrokeColor"])(newValue[1]));
3799
+ newValue.length === 2 && (webkitStrokeColor = (0,_color__WEBPACK_IMPORTED_MODULE_1__.parseWebkitFillColorAndStrokeColor)(newValue[1]));
4076
3800
  break;
4077
3801
  }
4078
3802
  case '-webkit-text-stroke-color':
4079
3803
  // 有-webkit-text-stroke-color时就不会有-webkit-text-stroke
4080
- webkitStrokeColor = Object(_color__WEBPACK_IMPORTED_MODULE_1__["parseWebkitFillColorAndStrokeColor"])(value);
3804
+ webkitStrokeColor = (0,_color__WEBPACK_IMPORTED_MODULE_1__.parseWebkitFillColorAndStrokeColor)(value);
4081
3805
  break;
4082
3806
  }
4083
3807
  return false; // 继续遍历
4084
3808
  });
4085
3809
  });
4086
-
4087
3810
  if (webkitFillColor) {
4088
3811
  // 有-webkit-text-fill-color,当做color对待
4089
3812
  if (hasInlineColor) {
@@ -4099,65 +3822,69 @@ var SDK = /*#__PURE__*/function () {
4099
3822
  cssKVList.splice(0, webkitTextLen); // 删掉-webkit-text相关样式
4100
3823
  webkitStrokeColor && cssKVList.unshift(['-webkit-text-stroke-color', webkitStrokeColor]); // 如果有-webkit-text-stroke-color,则插入到最前面
4101
3824
  }
4102
-
4103
3825
  var dmClassName = '';
4104
3826
  var dmBgClassName = '';
4105
- if (isUpdate && el.className && typeof el.className === 'string') {
3827
+ if ((isUpdate || needReset) && el.className && typeof el.className === 'string') {
4106
3828
  // 先提取dm className
4107
- var matches = el.className.match(_constant__WEBPACK_IMPORTED_MODULE_2__["DM_CLASSNAME_REGEXP"]);
3829
+ var matches = el.className.match(_constant__WEBPACK_IMPORTED_MODULE_2__.DM_CLASSNAME_REGEXP);
4108
3830
  if (matches) {
4109
3831
  dmClassName = matches[0];
4110
3832
  }
4111
3833
 
4112
3834
  // 再提取dm bg className
4113
- matches = el.className.match(_global__WEBPACK_IMPORTED_MODULE_4__["bgStack"].classNameReg);
3835
+ matches = el.className.match(_global__WEBPACK_IMPORTED_MODULE_4__.bgStack.classNameReg);
4114
3836
  if (matches) {
4115
3837
  dmBgClassName = matches[0];
4116
3838
  }
4117
3839
  }
4118
3840
  var cssKV = ''; // css键值对
3841
+ var noColor = needReset;
3842
+ noColor && _global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.watch('color', function () {
3843
+ noColor = false;
3844
+ _global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.unwatch('color');
3845
+ });
4119
3846
  cssKVList.forEach(function (_ref9) {
4120
- var _ref10 = _slicedToArray(_ref9, 2),
4121
- key = _ref10[0],
4122
- value = _ref10[1];
3847
+ var _ref0 = _slicedToArray(_ref9, 2),
3848
+ key = _ref0[0],
3849
+ value = _ref0[1];
4123
3850
  return _this._try(function () {
4124
3851
  var oldValue = value;
4125
3852
  var cssChange = false;
4126
3853
 
4127
3854
  // 找出色值来处理
4128
- var isBgColor = _constant__WEBPACK_IMPORTED_MODULE_2__["CSS_PROP_SERIES"].BG_COLOR.indexOf(key) > -1;
4129
- var isTextShadow = _constant__WEBPACK_IMPORTED_MODULE_2__["CSS_PROP_SERIES"].TEXT_SHADOW.indexOf(key) > -1;
4130
- var textColorIdx = _constant__WEBPACK_IMPORTED_MODULE_2__["CSS_PROP_SERIES"].TEXT_COLOR.indexOf(key);
4131
- var isBorderColor = _constant__WEBPACK_IMPORTED_MODULE_2__["CSS_PROP_SERIES"].BORDER_COLOR.indexOf(key) > -1;
3855
+ var isBgColor = _constant__WEBPACK_IMPORTED_MODULE_2__.CSS_PROP_SERIES.BG_COLOR.indexOf(key) > -1;
3856
+ var isTextShadow = _constant__WEBPACK_IMPORTED_MODULE_2__.CSS_PROP_SERIES.TEXT_SHADOW.indexOf(key) > -1;
3857
+ var textColorIdx = _constant__WEBPACK_IMPORTED_MODULE_2__.CSS_PROP_SERIES.TEXT_COLOR.indexOf(key);
3858
+ var isBorderColor = _constant__WEBPACK_IMPORTED_MODULE_2__.CSS_PROP_SERIES.BORDER_COLOR.indexOf(key) > -1;
4132
3859
  var isGradient = /gradient/.test(value);
4133
3860
  var gradientColors = [];
4134
3861
  var extStyle = '';
4135
3862
  var gradientMixColor;
4136
3863
 
4137
3864
  // 将英文定义颜色转换为rgb格式
4138
- value = Object(_color__WEBPACK_IMPORTED_MODULE_1__["parseColorName"])(value, isGradient); // 渐变需要处理透明
3865
+ value = (0,_color__WEBPACK_IMPORTED_MODULE_1__.parseColorName)(value, isGradient); // 渐变需要处理透明
4139
3866
 
4140
- if (_constant__WEBPACK_IMPORTED_MODULE_2__["COLOR_REGEXP"].test(value)) {
3867
+ if (_constant__WEBPACK_IMPORTED_MODULE_2__.COLOR_REGEXP.test(value)) {
4141
3868
  if (isGradient) {
4142
3869
  // 把原渐变色取出来
4143
- var _matches = _constant__WEBPACK_IMPORTED_MODULE_2__["COLOR_REGEXP_GLOBAL"].exec(value);
3870
+ var _matches = _constant__WEBPACK_IMPORTED_MODULE_2__.COLOR_REGEXP_GLOBAL.exec(value);
4144
3871
  while (_matches) {
4145
3872
  gradientColors.push(_matches[0]);
4146
- _matches = _constant__WEBPACK_IMPORTED_MODULE_2__["COLOR_REGEXP_GLOBAL"].exec(value);
3873
+ _matches = _constant__WEBPACK_IMPORTED_MODULE_2__.COLOR_REGEXP_GLOBAL.exec(value);
4147
3874
  }
4148
3875
 
4149
3876
  // 计算出一个mix颜色
4150
- gradientMixColor = Object(_color__WEBPACK_IMPORTED_MODULE_1__["mixColors"])(gradientColors);
3877
+ gradientMixColor = (0,_color__WEBPACK_IMPORTED_MODULE_1__.mixColors)(gradientColors);
4151
3878
  }
4152
3879
  var replaceIndex = 0;
4153
- value = value.replace(_constant__WEBPACK_IMPORTED_MODULE_2__["COLOR_REGEXP_GLOBAL"], function (match) {
3880
+ value = value.replace(_constant__WEBPACK_IMPORTED_MODULE_2__.COLOR_REGEXP_GLOBAL, function (match) {
4154
3881
  // 渐变色统一改成mix纯色
4155
3882
  if (isGradient) {
4156
3883
  match = gradientMixColor;
4157
3884
  cssChange = true;
4158
3885
  }
4159
- var matchColor = Object(_color__WEBPACK_IMPORTED_MODULE_1__["ColorParser"])(match);
4160
- if ((matchColor === null || matchColor === void 0 ? void 0 : matchColor.alpha()) >= _constant__WEBPACK_IMPORTED_MODULE_2__["IGNORE_ALPHA"]) {
3886
+ var matchColor = (0,_color__WEBPACK_IMPORTED_MODULE_1__.ColorParser)(match);
3887
+ if ((matchColor === null || matchColor === void 0 ? void 0 : matchColor.alpha()) >= _constant__WEBPACK_IMPORTED_MODULE_2__.IGNORE_ALPHA) {
4161
3888
  // 忽略透明度低的色值
4162
3889
  // 使用颜色处理算法
4163
3890
  var ret = _this._adjustBrightness(matchColor, el, {
@@ -4166,7 +3893,7 @@ var SDK = /*#__PURE__*/function () {
4166
3893
  isTextColor: textColorIdx > -1,
4167
3894
  isBorderColor: isBorderColor,
4168
3895
  hasInlineColor: hasInlineColor
4169
- }, isUpdate);
3896
+ }, isUpdate, needReset);
4170
3897
  var retColor = !hasInlineBackgroundImage && ret.newColor;
4171
3898
  extStyle += ret.extStyle;
4172
3899
 
@@ -4174,19 +3901,19 @@ var SDK = /*#__PURE__*/function () {
4174
3901
  if (isBgColor || textColorIdx >= 5) {
4175
3902
  // 只处理color及之后的属性
4176
3903
  var retColorStr = retColor ? retColor.toString() : match;
4177
- replaceIndex === 0 && Object(_domUtils__WEBPACK_IMPORTED_MODULE_5__["getChildrenAndIt"])(el).forEach(function (dom) {
3904
+ replaceIndex === 0 && (0,_domUtils__WEBPACK_IMPORTED_MODULE_5__.getChildrenAndIt)(el).forEach(function (dom) {
4178
3905
  if (isBgColor) {
4179
- dom[_constant__WEBPACK_IMPORTED_MODULE_2__["BGCOLORATTR"]] = retColorStr;
4180
- dom[_constant__WEBPACK_IMPORTED_MODULE_2__["ORIGINAL_BGCOLORATTR"]] = (dom[_constant__WEBPACK_IMPORTED_MODULE_2__["ORIGINAL_BGCOLORATTR"]] || _config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultLightBgColor).split(_constant__WEBPACK_IMPORTED_MODULE_2__["BG_COLOR_DELIMITER"]).concat(match).join(_constant__WEBPACK_IMPORTED_MODULE_2__["BG_COLOR_DELIMITER"]);
3906
+ dom[_constant__WEBPACK_IMPORTED_MODULE_2__.BGCOLORATTR] = retColorStr;
3907
+ dom[_constant__WEBPACK_IMPORTED_MODULE_2__.ORIGINAL_BGCOLORATTR] = (dom[_constant__WEBPACK_IMPORTED_MODULE_2__.ORIGINAL_BGCOLORATTR] || _config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultLightBgColor).split(_constant__WEBPACK_IMPORTED_MODULE_2__.BG_COLOR_DELIMITER).concat(match).join(_constant__WEBPACK_IMPORTED_MODULE_2__.BG_COLOR_DELIMITER);
4181
3908
  } else {
4182
- dom[_constant__WEBPACK_IMPORTED_MODULE_2__["COLORATTR"]] = retColorStr;
4183
- dom[_constant__WEBPACK_IMPORTED_MODULE_2__["ORIGINAL_COLORATTR"]] = match;
3909
+ dom[_constant__WEBPACK_IMPORTED_MODULE_2__.COLORATTR] = retColorStr;
3910
+ dom[_constant__WEBPACK_IMPORTED_MODULE_2__.ORIGINAL_COLORATTR] = match;
4184
3911
  }
4185
3912
 
4186
3913
  // 如果设置背景颜色,取消背景图片的影响
4187
- var retColor = Object(_color__WEBPACK_IMPORTED_MODULE_1__["ColorParser"])(retColorStr);
4188
- if (isBgColor && (retColor === null || retColor === void 0 ? void 0 : retColor.alpha()) >= _constant__WEBPACK_IMPORTED_MODULE_2__["IGNORE_ALPHA"] && dom[_constant__WEBPACK_IMPORTED_MODULE_2__["BGIMAGEATTR"]]) {
4189
- delete dom[_constant__WEBPACK_IMPORTED_MODULE_2__["BGIMAGEATTR"]];
3914
+ var retColor = (0,_color__WEBPACK_IMPORTED_MODULE_1__.ColorParser)(retColorStr);
3915
+ if (isBgColor && (retColor === null || retColor === void 0 ? void 0 : retColor.alpha()) >= _constant__WEBPACK_IMPORTED_MODULE_2__.IGNORE_ALPHA && dom[_constant__WEBPACK_IMPORTED_MODULE_2__.BGIMAGEATTR]) {
3916
+ delete dom[_constant__WEBPACK_IMPORTED_MODULE_2__.BGIMAGEATTR];
4190
3917
  }
4191
3918
  });
4192
3919
  }
@@ -4205,7 +3932,7 @@ var SDK = /*#__PURE__*/function () {
4205
3932
  var isBorderImageAttr = /^(-webkit-)?border-image/.test(key);
4206
3933
  if ((isBackgroundAttr || isBorderImageAttr) && /url\([^)]*\)/i.test(value)) {
4207
3934
  cssChange = true;
4208
- var imgBgColor = Object(_color__WEBPACK_IMPORTED_MODULE_1__["mixColors"])((el[_constant__WEBPACK_IMPORTED_MODULE_2__["ORIGINAL_BGCOLORATTR"]] || _config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultLightBgColor).split(_constant__WEBPACK_IMPORTED_MODULE_2__["BG_COLOR_DELIMITER"]), 'normal').toString();
3935
+ var imgBgColor = (0,_color__WEBPACK_IMPORTED_MODULE_1__.mixColors)((el[_constant__WEBPACK_IMPORTED_MODULE_2__.ORIGINAL_BGCOLORATTR] || _config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultLightBgColor).split(_constant__WEBPACK_IMPORTED_MODULE_2__.BG_COLOR_DELIMITER), 'normal').toString();
4209
3936
  // const imgBgColor = el[BGCOLORATTR] || config.defaultLightBgColor;
4210
3937
 
4211
3938
  // 在背景图片下加一层原背景颜色:
@@ -4214,115 +3941,126 @@ var SDK = /*#__PURE__*/function () {
4214
3941
  value = value.replace(/^(.*?)url\(([^)]*)\)(.*)$/i, function (matches) {
4215
3942
  var newValue = matches;
4216
3943
  var tmpCssKvStr = '';
4217
- if (!el[_constant__WEBPACK_IMPORTED_MODULE_2__["BGIMAGEATTR"]]) {
3944
+ if (!el[_constant__WEBPACK_IMPORTED_MODULE_2__.BGIMAGEATTR]) {
4218
3945
  // 避免重复set
4219
- Object(_domUtils__WEBPACK_IMPORTED_MODULE_5__["getChildrenAndIt"])(el).forEach(function (dom) {
4220
- dom[_constant__WEBPACK_IMPORTED_MODULE_2__["BGIMAGEATTR"]] = true;
3946
+ (0,_domUtils__WEBPACK_IMPORTED_MODULE_5__.getChildrenAndIt)(el).forEach(function (dom) {
3947
+ dom[_constant__WEBPACK_IMPORTED_MODULE_2__.BGIMAGEATTR] = true;
4221
3948
  });
4222
3949
  }
4223
3950
 
4224
3951
  // background-image
4225
3952
  if (isBackgroundAttr) {
4226
- tmpCssKvStr = _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCssKV(key, imgBgColor ? "".concat(newValue, ",linear-gradient(").concat(imgBgColor, ", ").concat(imgBgColor, ")") : newValue);
3953
+ tmpCssKvStr = _global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.genCssKV(key, imgBgColor ? "".concat(newValue, ",linear-gradient(").concat(imgBgColor, ", ").concat(imgBgColor, ")") : newValue);
4227
3954
  if (elBackgroundPositionAttr) {
4228
- cssKV += _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCssKV('background-position', elBackgroundPositionAttr);
4229
- tmpCssKvStr += _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCssKV('background-position', imgBgColor ? "".concat(elBackgroundPositionAttr, ",top left") : elBackgroundPositionAttr);
3955
+ cssKV += _global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.genCssKV('background-position', elBackgroundPositionAttr);
3956
+ tmpCssKvStr += _global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.genCssKV('background-position', imgBgColor ? "".concat(elBackgroundPositionAttr, ",top left") : elBackgroundPositionAttr);
4230
3957
  }
4231
3958
  if (elBackgroundSizeAttr) {
4232
- cssKV += _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCssKV('background-size', elBackgroundSizeAttr);
4233
- tmpCssKvStr += _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCssKV('background-size', imgBgColor ? "".concat(elBackgroundSizeAttr, ",100%") : elBackgroundSizeAttr);
3959
+ cssKV += _global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.genCssKV('background-size', elBackgroundSizeAttr);
3960
+ tmpCssKvStr += _global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.genCssKV('background-size', imgBgColor ? "".concat(elBackgroundSizeAttr, ",100%") : elBackgroundSizeAttr);
4234
3961
  }
4235
- if (dmBgClassName) {
4236
- // 如果是文字底图,则直接加样式
4237
- bgCss += _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCss(dmBgClassName, tmpCssKvStr);
4238
- Object(_domUtils__WEBPACK_IMPORTED_MODULE_5__["getChildrenAndIt"])(el).forEach(function (dom) {
4239
- dom[_constant__WEBPACK_IMPORTED_MODULE_2__["COMPLEMENTARY_BGIMAGECOLORATTR"]] = imgBgColor || newValue;
4240
- });
4241
- } else {
4242
- // 否则背景图入栈
4243
- _global__WEBPACK_IMPORTED_MODULE_4__["bgStack"].push(el, tmpCssKvStr, function () {
4244
- Object(_domUtils__WEBPACK_IMPORTED_MODULE_5__["getChildrenAndIt"])(el).forEach(function (dom) {
4245
- dom[_constant__WEBPACK_IMPORTED_MODULE_2__["COMPLEMENTARY_BGIMAGECOLORATTR"]] = imgBgColor || newValue;
3962
+ if (!needReset) {
3963
+ if (dmBgClassName) {
3964
+ // 如果是文字底图,则直接加样式
3965
+ bgCss += _global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.genCss(dmBgClassName, tmpCssKvStr);
3966
+ (0,_domUtils__WEBPACK_IMPORTED_MODULE_5__.getChildrenAndIt)(el).forEach(function (dom) {
3967
+ dom[_constant__WEBPACK_IMPORTED_MODULE_2__.COMPLEMENTARY_BGIMAGECOLORATTR] = imgBgColor || newValue;
3968
+ });
3969
+ } else {
3970
+ // 否则背景图入栈
3971
+ _global__WEBPACK_IMPORTED_MODULE_4__.bgStack.push(el, tmpCssKvStr, function () {
3972
+ (0,_domUtils__WEBPACK_IMPORTED_MODULE_5__.getChildrenAndIt)(el).forEach(function (dom) {
3973
+ dom[_constant__WEBPACK_IMPORTED_MODULE_2__.COMPLEMENTARY_BGIMAGECOLORATTR] = imgBgColor || newValue;
3974
+ });
4246
3975
  });
4247
- });
3976
+ }
4248
3977
  }
4249
3978
  } else {
4250
3979
  // border-image元素,如果当前元素没有背景颜色,补背景颜色
4251
- if (imgBgColor && !hasInlineBackground) {
4252
- tmpCssKvStr = _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCssKV('background-image', "linear-gradient(".concat(imgBgColor, ", ").concat(imgBgColor, ")"));
3980
+ if (imgBgColor && !hasInlineBackground && !needReset) {
3981
+ tmpCssKvStr = _global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.genCssKV('background-image', "linear-gradient(".concat(imgBgColor, ", ").concat(imgBgColor, ")"));
4253
3982
  if (dmBgClassName) {
4254
3983
  // 如果是文字底图,则直接加样式
4255
- bgCss += _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCss(dmBgClassName, tmpCssKvStr);
3984
+ bgCss += _global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.genCss(dmBgClassName, tmpCssKvStr);
4256
3985
  } else {
4257
3986
  // 否则背景图入栈
4258
- _global__WEBPACK_IMPORTED_MODULE_4__["bgStack"].push(el, tmpCssKvStr); // 背景图入栈
3987
+ _global__WEBPACK_IMPORTED_MODULE_4__.bgStack.push(el, tmpCssKvStr); // 背景图入栈
4259
3988
  }
4260
3989
  }
4261
3990
  }
4262
-
4263
3991
  return newValue;
4264
3992
  });
4265
3993
 
4266
3994
  // 没有设置自定义字体颜色,则使用非 Dark Mode 下默认字体颜色
4267
3995
  if (!hasInlineColor) {
4268
- var textColor = el[_constant__WEBPACK_IMPORTED_MODULE_2__["ORIGINAL_COLORATTR"]] || _config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultLightTextColor;
4269
- cssKV += _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCssKV('color', textColor);
4270
- Object(_domUtils__WEBPACK_IMPORTED_MODULE_5__["getChildrenAndIt"])(el).forEach(function (dom) {
4271
- dom[_constant__WEBPACK_IMPORTED_MODULE_2__["COLORATTR"]] = textColor;
3996
+ var textColor = el[_constant__WEBPACK_IMPORTED_MODULE_2__.ORIGINAL_COLORATTR] || _config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultLightTextColor;
3997
+ cssKV += _global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.genCssKV('color', textColor);
3998
+ (0,_domUtils__WEBPACK_IMPORTED_MODULE_5__.getChildrenAndIt)(el).forEach(function (dom) {
3999
+ dom[_constant__WEBPACK_IMPORTED_MODULE_2__.COLORATTR] = textColor;
4272
4000
  });
4273
4001
  }
4274
4002
  }
4275
4003
  }
4276
- if (cssChange) {
4277
- !isUpdate && _constant__WEBPACK_IMPORTED_MODULE_2__["IMPORTANT_REGEXP"].test(oldValue) && (styles[key] = oldValue.replace(_constant__WEBPACK_IMPORTED_MODULE_2__["IMPORTANT_REGEXP"], '')); // 清除inline style的!important
4004
+ if (cssChange || needReset) {
4005
+ !isUpdate && !needReset && _constant__WEBPACK_IMPORTED_MODULE_2__.IMPORTANT_REGEXP.test(oldValue) && (styles[key] = oldValue.replace(_constant__WEBPACK_IMPORTED_MODULE_2__.IMPORTANT_REGEXP, '')); // 清除inline style的!important
4278
4006
  if (isGradient) {
4279
- if (dmBgClassName) {
4280
- // 如果是文字底图,则直接加样式(其实理论上不会走到这里)
4281
- bgCss += _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCss(dmBgClassName, _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCssKV(key, value));
4282
- if (/^background/.test(key) && !/url\([^)]*\)/i.test(value)) {
4283
- // 是无背景图的渐变,需要重新计算背景色
4284
- css += _this._updateBgWithGradient(gradientMixColor, el, dmBgClassName, cssKVList, hasInlineColor, isUpdate);
4285
- }
4286
- } else {
4287
- // 否则渐变入栈
4288
- _global__WEBPACK_IMPORTED_MODULE_4__["bgStack"].push(el, _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCssKV(key, value), function (item) {
4289
- // 渐变入栈
4007
+ if (!needReset) {
4008
+ if (dmBgClassName) {
4009
+ // 如果是文字底图,则直接加样式
4010
+ bgCss += _global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.genCss(dmBgClassName, _global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.genCssKV(key, value));
4290
4011
  if (/^background/.test(key) && !/url\([^)]*\)/i.test(value)) {
4291
4012
  // 是无背景图的渐变,需要重新计算背景色
4292
- css += _this._updateBgWithGradient(gradientMixColor, el, item.className, cssKVList, hasInlineColor, isUpdate);
4013
+ css += _this._updateBgWithGradient(gradientMixColor, el, dmBgClassName, cssKVList, hasInlineColor, isUpdate, needReset);
4293
4014
  }
4294
- });
4015
+ } else {
4016
+ // 否则渐变入栈
4017
+ _global__WEBPACK_IMPORTED_MODULE_4__.bgStack.push(el, _global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.genCssKV(key, value), function (item) {
4018
+ // 渐变入栈
4019
+ if (/^background/.test(key) && !/url\([^)]*\)/i.test(value)) {
4020
+ // 是无背景图的渐变,需要重新计算背景色
4021
+ css += _this._updateBgWithGradient(gradientMixColor, el, item.className, cssKVList, hasInlineColor, isUpdate, needReset);
4022
+ }
4023
+ });
4024
+ }
4295
4025
  }
4296
4026
  } else {
4297
- cssKV += _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCssKV(key, value);
4027
+ if (key === 'color') {
4028
+ noColor = false;
4029
+ _global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.unwatch('color');
4030
+ }
4031
+ cssKV += _global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.genCssKV(key, !cssChange && needReset ? el.style[key] : value);
4298
4032
  }
4299
4033
  }
4300
4034
  });
4301
4035
  });
4036
+ if (noColor) {
4037
+ cssKV += _global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.genCssKV('color', el.style.color || el[_constant__WEBPACK_IMPORTED_MODULE_2__.COLORATTR] || _config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultDarkTextColor);
4038
+ _global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.unwatch('color');
4039
+ }
4302
4040
  if (cssKV) {
4303
4041
  // 有处理过或者是背景图片就加class以及css
4304
4042
  if (!dmClassName) {
4305
- dmClassName = "".concat(_constant__WEBPACK_IMPORTED_MODULE_2__["CLASS_PREFIX"]).concat(this._idx++);
4043
+ dmClassName = "".concat(_constant__WEBPACK_IMPORTED_MODULE_2__.CLASS_PREFIX).concat(this._idx++);
4306
4044
  el.classList.add(dmClassName);
4307
4045
  }
4308
- css += cssKV ? _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCss(dmClassName, cssKV) : '';
4046
+ css += cssKV ? _global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.genCss(dmClassName, cssKV) : '';
4309
4047
  }
4310
4048
  css += bgCss; // 追加文字底图样式,要在添加cssKV之后添加,避免被覆盖
4311
4049
 
4312
- if (!isUpdate && Object(_domUtils__WEBPACK_IMPORTED_MODULE_5__["hasTextNode"])(el)) {
4050
+ if (!isUpdate && (0,_domUtils__WEBPACK_IMPORTED_MODULE_5__.hasTextNode)(el) && !needReset) {
4313
4051
  // 如果节点里有文本,要判断是否在背景图里
4314
4052
  if (_config__WEBPACK_IMPORTED_MODULE_3__["default"].delayBgJudge) {
4315
4053
  // 延迟背景判断
4316
- _global__WEBPACK_IMPORTED_MODULE_4__["tnQueue"].push(el); // 文字入队
4054
+ _global__WEBPACK_IMPORTED_MODULE_4__.tnQueue.push(el); // 文字入队
4317
4055
  } else {
4318
- _global__WEBPACK_IMPORTED_MODULE_4__["bgStack"].contains(el, function (item) {
4319
- css += _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCss(item.className, item.cssKV);
4056
+ _global__WEBPACK_IMPORTED_MODULE_4__.bgStack.contains(el, function (item) {
4057
+ css += _global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.genCss(item.className, item.cssKV);
4320
4058
  typeof item.cb === 'function' && item.cb(item);
4321
4059
  });
4322
4060
  }
4323
4061
  }
4324
4062
  }
4325
- _global__WEBPACK_IMPORTED_MODULE_4__["plugins"].emit("afterConvertNode".concat(isUpdate ? 'ByUpdateStyle' : ''), el);
4063
+ _global__WEBPACK_IMPORTED_MODULE_4__.plugins.emit("afterConvertNode".concat(emitNameSuffix), el);
4326
4064
  return css;
4327
4065
  }
4328
4066
 
@@ -4330,34 +4068,36 @@ var SDK = /*#__PURE__*/function () {
4330
4068
  }, {
4331
4069
  key: "getContrast",
4332
4070
  value: function getContrast(colorStr1, colorStr2) {
4333
- var color1 = Object(_color__WEBPACK_IMPORTED_MODULE_1__["ColorParser"])(colorStr1);
4334
- var color2 = Object(_color__WEBPACK_IMPORTED_MODULE_1__["ColorParser"])(colorStr2);
4071
+ var color1 = (0,_color__WEBPACK_IMPORTED_MODULE_1__.ColorParser)(colorStr1);
4072
+ var color2 = (0,_color__WEBPACK_IMPORTED_MODULE_1__.ColorParser)(colorStr2);
4335
4073
  return color1 && color2 ? color1.contrast(color2) : 0;
4336
4074
  }
4337
4075
  }]);
4338
- return SDK;
4339
4076
  }();
4340
4077
 
4341
4078
  ;
4342
4079
 
4343
- /***/ }),
4080
+ /***/ },
4344
4081
 
4345
- /***/ "./src/modules/textNodeQueue.js":
4082
+ /***/ "./src/modules/textNodeQueue.js"
4346
4083
  /*!**************************************!*\
4347
4084
  !*** ./src/modules/textNodeQueue.js ***!
4348
4085
  \**************************************/
4349
- /*! exports provided: default */
4350
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
4086
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
4351
4087
 
4352
4088
  "use strict";
4353
4089
  __webpack_require__.r(__webpack_exports__);
4354
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return TextNodeQueue; });
4090
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4091
+ /* harmony export */ "default": () => (/* binding */ TextNodeQueue)
4092
+ /* harmony export */ });
4355
4093
  /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./config */ "./src/modules/config.js");
4356
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4357
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4358
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
4359
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4360
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4094
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4095
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
4096
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
4097
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
4098
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
4099
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
4100
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
4361
4101
  /**
4362
4102
  * @name 文本节点队列
4363
4103
  *
@@ -4366,6 +4106,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
4366
4106
  * @constructor
4367
4107
  * @param {string} prefix 类名前缀
4368
4108
  *
4109
+ * @attr {number} length 队列长度
4110
+ *
4369
4111
  * @method push 文本节点入队
4370
4112
  * @param {DOM Object} el 文本节点对象
4371
4113
  * @return void
@@ -4383,18 +4125,25 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
4383
4125
  // Darkmode配置
4384
4126
 
4385
4127
  var TextNodeQueue = /*#__PURE__*/function () {
4386
- // 文本节点队列,{ el, className, updated }
4387
4128
  // 索引值
4388
4129
 
4389
4130
  function TextNodeQueue(prefix) {
4390
4131
  _classCallCheck(this, TextNodeQueue);
4391
4132
  _defineProperty(this, "_queue", []);
4133
+ // 文本节点队列,{ el, className, updated }
4392
4134
  _defineProperty(this, "_idx", 0);
4393
4135
  this._prefix = prefix;
4394
4136
  }
4395
4137
 
4396
- // 文本节点入队
4397
- _createClass(TextNodeQueue, [{
4138
+ // 队列长度
4139
+ return _createClass(TextNodeQueue, [{
4140
+ key: "length",
4141
+ get: function get() {
4142
+ return this._queue.length;
4143
+ }
4144
+
4145
+ // 文本节点入队
4146
+ }, {
4398
4147
  key: "push",
4399
4148
  value: function push(el) {
4400
4149
  var className = "".concat(this._prefix).concat(this._idx++);
@@ -4441,13 +4190,372 @@ var TextNodeQueue = /*#__PURE__*/function () {
4441
4190
  });
4442
4191
  }
4443
4192
  }]);
4444
- return TextNodeQueue;
4445
4193
  }();
4446
4194
 
4447
4195
  ;
4448
4196
 
4449
- /***/ })
4197
+ /***/ }
4198
+
4199
+ /******/ });
4200
+ /************************************************************************/
4201
+ /******/ // The module cache
4202
+ /******/ var __webpack_module_cache__ = {};
4203
+ /******/
4204
+ /******/ // The require function
4205
+ /******/ function __webpack_require__(moduleId) {
4206
+ /******/ // Check if module is in cache
4207
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
4208
+ /******/ if (cachedModule !== undefined) {
4209
+ /******/ return cachedModule.exports;
4210
+ /******/ }
4211
+ /******/ // Check if module exists (development only)
4212
+ /******/ if (__webpack_modules__[moduleId] === undefined) {
4213
+ /******/ var e = new Error("Cannot find module '" + moduleId + "'");
4214
+ /******/ e.code = 'MODULE_NOT_FOUND';
4215
+ /******/ throw e;
4216
+ /******/ }
4217
+ /******/ // Create a new module (and put it into the cache)
4218
+ /******/ var module = __webpack_module_cache__[moduleId] = {
4219
+ /******/ // no module.id needed
4220
+ /******/ // no module.loaded needed
4221
+ /******/ exports: {}
4222
+ /******/ };
4223
+ /******/
4224
+ /******/ // Execute the module function
4225
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
4226
+ /******/
4227
+ /******/ // Return the exports of the module
4228
+ /******/ return module.exports;
4229
+ /******/ }
4230
+ /******/
4231
+ /************************************************************************/
4232
+ /******/ /* webpack/runtime/compat get default export */
4233
+ /******/ (() => {
4234
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
4235
+ /******/ __webpack_require__.n = (module) => {
4236
+ /******/ var getter = module && module.__esModule ?
4237
+ /******/ () => (module['default']) :
4238
+ /******/ () => (module);
4239
+ /******/ __webpack_require__.d(getter, { a: getter });
4240
+ /******/ return getter;
4241
+ /******/ };
4242
+ /******/ })();
4243
+ /******/
4244
+ /******/ /* webpack/runtime/define property getters */
4245
+ /******/ (() => {
4246
+ /******/ // define getter functions for harmony exports
4247
+ /******/ __webpack_require__.d = (exports, definition) => {
4248
+ /******/ for(var key in definition) {
4249
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
4250
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
4251
+ /******/ }
4252
+ /******/ }
4253
+ /******/ };
4254
+ /******/ })();
4255
+ /******/
4256
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
4257
+ /******/ (() => {
4258
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
4259
+ /******/ })();
4260
+ /******/
4261
+ /******/ /* webpack/runtime/make namespace object */
4262
+ /******/ (() => {
4263
+ /******/ // define __esModule on exports
4264
+ /******/ __webpack_require__.r = (exports) => {
4265
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
4266
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4267
+ /******/ }
4268
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
4269
+ /******/ };
4270
+ /******/ })();
4271
+ /******/
4272
+ /************************************************************************/
4273
+ var __webpack_exports__ = {};
4274
+ // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
4275
+ (() => {
4276
+ "use strict";
4277
+ /*!*************************!*\
4278
+ !*** ./src/darkmode.js ***!
4279
+ \*************************/
4280
+ __webpack_require__.r(__webpack_exports__);
4281
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4282
+ /* harmony export */ convertBg: () => (/* binding */ convertBg),
4283
+ /* harmony export */ extend: () => (/* binding */ extend),
4284
+ /* harmony export */ getContrast: () => (/* binding */ getContrast),
4285
+ /* harmony export */ init: () => (/* binding */ init),
4286
+ /* harmony export */ run: () => (/* binding */ run),
4287
+ /* harmony export */ updateStyle: () => (/* binding */ updateStyle)
4288
+ /* harmony export */ });
4289
+ /* harmony import */ var _modules_constant__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./modules/constant */ "./src/modules/constant.js");
4290
+ /* harmony import */ var _modules_config__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./modules/config */ "./src/modules/config.js");
4291
+ /* harmony import */ var _modules_global__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./modules/global */ "./src/modules/global.js");
4292
+ /* harmony import */ var _modules_domUtils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./modules/domUtils */ "./src/modules/domUtils.js");
4293
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
4294
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4295
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
4296
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
4297
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
4298
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
4299
+ /**
4300
+ * @name Darkmode主入口
4301
+ *
4302
+ * @function run 初始化Dark Mode配置并运行Dark Mode处理
4303
+ * @param {DOM Object Array} nodes 要处理的节点列表
4304
+ * @param {Object} opt Dark Mode配置,详见init配置说明
4305
+ * @return void
4306
+ *
4307
+ * @function init 初始化Dark Mode配置
4308
+ * @param {Function} opt.begin 开始处理时触发的回调
4309
+ * @param {Function} opt.showFirstPage 首屏处理完成时触发的回调
4310
+ * @param {Function} opt.error 发生error时触发的回调
4311
+ * @param {string} opt.mode 强制指定的颜色模式(dark|light), 指定了就不监听系统颜色
4312
+ * @param {Object} opt.whitelist 节点白名单
4313
+ * @param {Array} opt.whitelist.tagName 标签名列表
4314
+ * @param {Array} opt.whitelist.attribute 属性列表
4315
+ * @param {boolean} opt.needJudgeFirstPage 是否需要判断首屏
4316
+ * @param {boolean} opt.delayBgJudge 是否延迟背景判断
4317
+ * @param {DOM Object} opt.container 延迟运行js时使用的容器
4318
+ * @param {string} opt.cssSelectorsPrefix css选择器前缀
4319
+ * @param {string} opt.defaultLightTextColor 非Dark Mode下字体颜色
4320
+ * @param {string} opt.defaultLightBgColor 非Dark Mode下背景颜色
4321
+ * @param {string} opt.defaultDarkTextColor Dark Mode下字体颜色
4322
+ * @param {string} opt.defaultDarkBgColor Dark Mode下背景颜色
4323
+ * @return void
4324
+ *
4325
+ * @function convertBg 处理背景
4326
+ * @param {DOM Object Array} nodes 要处理的节点列表
4327
+ * @return void
4328
+ *
4329
+ * @function updateStyle 更新节点Dark Mode样式
4330
+ * @param {DOM Object} node 要更新的节点
4331
+ * @param {Object} styles 更新的样式键值对对象,如:{ color: '#ddd' }
4332
+ * @return void
4333
+ *
4334
+ * @function getContrast 获取两个颜色的对比度
4335
+ * @param {string} color1 要计算颜色对比度的颜色1,支持css颜色格式
4336
+ * @param {string} color2 要计算颜色对比度的颜色2,支持css颜色格式
4337
+ * @return {number} 颜色对比度,取值范围为`[1, 21]`
4338
+ *
4339
+ * @function extend 挂载插件
4340
+ * @param {Array} pluginList 插件列表
4341
+ * @return void
4342
+ *
4343
+ */
4344
+
4345
+ // 常量
4346
+
4347
+ var classReg = new RegExp("".concat(_modules_constant__WEBPACK_IMPORTED_MODULE_0__.CLASS_PREFIX, "[^ ]+"), 'g');
4348
+
4349
+ // Darkmode配置
4350
+
4351
+
4450
4352
 
4451
- /******/ });
4353
+
4354
+ // Dark Mode切换
4355
+ var mql = null;
4356
+ var switchToDarkmode = function switchToDarkmode(mqlObj) {
4357
+ var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
4358
+ type: 'dom'
4359
+ };
4360
+ opt.force && (_modules_global__WEBPACK_IMPORTED_MODULE_2__.cssUtils.isFinish = false); // 如果是强制运行Dark Mode处理逻辑,则重置为未运行
4361
+
4362
+ if (_modules_global__WEBPACK_IMPORTED_MODULE_2__.cssUtils.isFinish) return; // 已运行过Dark Mode处理逻辑则不再运行
4363
+
4364
+ try {
4365
+ _modules_global__WEBPACK_IMPORTED_MODULE_2__.sdk.isDarkmode = _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].mode ? _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].mode === 'dark' : mqlObj.matches;
4366
+ if (opt.type === 'dom') {
4367
+ // 处理节点
4368
+ _modules_global__WEBPACK_IMPORTED_MODULE_2__.sdk.isDarkmode && typeof _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].begin === 'function' && _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].begin(_modules_global__WEBPACK_IMPORTED_MODULE_2__.domUtils.hasDelay());
4369
+ Array.prototype.forEach.call(_modules_global__WEBPACK_IMPORTED_MODULE_2__.domUtils.get(), function (node) {
4370
+ if (_modules_global__WEBPACK_IMPORTED_MODULE_2__.sdk.isDarkmode && node.className && typeof node.className === 'string') {
4371
+ node.className = node.className.replace(classReg, ''); // 过滤掉原有的Dark Mode class,避免外部复制文章时把文章内的Dark Mode class也复制过去导致新文章在Dark Mode下样式错乱
4372
+ }
4373
+ if (_modules_global__WEBPACK_IMPORTED_MODULE_2__.sdk.isDarkmode || _modules_global__WEBPACK_IMPORTED_MODULE_2__.plugins.length) {
4374
+ if (!_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].needJudgeFirstPage) {
4375
+ // 不需要判断首屏
4376
+ _modules_global__WEBPACK_IMPORTED_MODULE_2__.cssUtils.addCss(_modules_global__WEBPACK_IMPORTED_MODULE_2__.sdk.convert(node)); // 写入非首屏样式
4377
+ } else {
4378
+ // 判断首屏
4379
+ var rect = node.getBoundingClientRect();
4380
+ var top = rect.top;
4381
+ var bottom = rect.bottom;
4382
+ if (top <= 0 && bottom <= 0) {
4383
+ // 首屏前面
4384
+ _modules_global__WEBPACK_IMPORTED_MODULE_2__.cssUtils.addCss(_modules_global__WEBPACK_IMPORTED_MODULE_2__.sdk.convert(node)); // 写入非首屏样式
4385
+ } else if (top > 0 && top < _modules_constant__WEBPACK_IMPORTED_MODULE_0__.PAGE_HEIGHT || bottom > 0 && bottom < _modules_constant__WEBPACK_IMPORTED_MODULE_0__.PAGE_HEIGHT) {
4386
+ // 首屏
4387
+ _modules_global__WEBPACK_IMPORTED_MODULE_2__.domUtils.addFirstPageNode(node); // 记录首屏节点
4388
+ _modules_global__WEBPACK_IMPORTED_MODULE_2__.cssUtils.addCss(_modules_global__WEBPACK_IMPORTED_MODULE_2__.sdk.convert(node), true); // 写入首屏样式
4389
+ } else {
4390
+ // 首屏后面,理论上,这里最多只会进来一次
4391
+ _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].needJudgeFirstPage = false; // 至此,不需要再判断首屏了
4392
+
4393
+ // 显示首屏
4394
+ _modules_global__WEBPACK_IMPORTED_MODULE_2__.cssUtils.writeStyle(true); // 写入首屏样式表
4395
+ _modules_global__WEBPACK_IMPORTED_MODULE_2__.domUtils.showFirstPageNodes(); // 显示首屏节点
4396
+ typeof _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].showFirstPage === 'function' && _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].showFirstPage(); // 执行首屏回调
4397
+
4398
+ _modules_global__WEBPACK_IMPORTED_MODULE_2__.cssUtils.addCss(_modules_global__WEBPACK_IMPORTED_MODULE_2__.sdk.convert(node)); // 写入非首屏样式
4399
+ }
4400
+ }
4401
+ }
4402
+ });
4403
+ _modules_global__WEBPACK_IMPORTED_MODULE_2__.plugins.loopTimes++;
4404
+ } else if (opt.type === 'bg') {
4405
+ // 处理背景
4406
+ _modules_global__WEBPACK_IMPORTED_MODULE_2__.sdk.isDarkmode && _modules_global__WEBPACK_IMPORTED_MODULE_2__.tnQueue.forEach(function (text) {
4407
+ return _modules_global__WEBPACK_IMPORTED_MODULE_2__.bgStack.contains(text, function (bg) {
4408
+ var _el$COLORATTR, _el$BGCOLORATTR, _el$ORIGINAL_COLORATT, _el$ORIGINAL_BGCOLORA, _el$BGIMAGEATTR, _el$COMPLEMENTARY_BGI;
4409
+ _modules_global__WEBPACK_IMPORTED_MODULE_2__.cssUtils.addCss(_modules_global__WEBPACK_IMPORTED_MODULE_2__.cssUtils.genCss(bg.className, bg.cssKV)); // 写入非首屏样式
4410
+ typeof bg.cb === 'function' && bg.cb(bg);
4411
+
4412
+ // 还得处理该背景下的所有节点
4413
+ var el = bg.el;
4414
+ var inheritAttrs = [[_modules_constant__WEBPACK_IMPORTED_MODULE_0__.COLORATTR, (_el$COLORATTR = el[_modules_constant__WEBPACK_IMPORTED_MODULE_0__.COLORATTR]) !== null && _el$COLORATTR !== void 0 ? _el$COLORATTR : null], [_modules_constant__WEBPACK_IMPORTED_MODULE_0__.BGCOLORATTR, (_el$BGCOLORATTR = el[_modules_constant__WEBPACK_IMPORTED_MODULE_0__.BGCOLORATTR]) !== null && _el$BGCOLORATTR !== void 0 ? _el$BGCOLORATTR : null], [_modules_constant__WEBPACK_IMPORTED_MODULE_0__.ORIGINAL_COLORATTR, (_el$ORIGINAL_COLORATT = el[_modules_constant__WEBPACK_IMPORTED_MODULE_0__.ORIGINAL_COLORATTR]) !== null && _el$ORIGINAL_COLORATT !== void 0 ? _el$ORIGINAL_COLORATT : null], [_modules_constant__WEBPACK_IMPORTED_MODULE_0__.ORIGINAL_BGCOLORATTR, (_el$ORIGINAL_BGCOLORA = el[_modules_constant__WEBPACK_IMPORTED_MODULE_0__.ORIGINAL_BGCOLORATTR]) !== null && _el$ORIGINAL_BGCOLORA !== void 0 ? _el$ORIGINAL_BGCOLORA : null], [_modules_constant__WEBPACK_IMPORTED_MODULE_0__.BGIMAGEATTR, (_el$BGIMAGEATTR = el[_modules_constant__WEBPACK_IMPORTED_MODULE_0__.BGIMAGEATTR]) !== null && _el$BGIMAGEATTR !== void 0 ? _el$BGIMAGEATTR : null], [_modules_constant__WEBPACK_IMPORTED_MODULE_0__.COMPLEMENTARY_BGIMAGECOLORATTR, (_el$COMPLEMENTARY_BGI = el[_modules_constant__WEBPACK_IMPORTED_MODULE_0__.COMPLEMENTARY_BGIMAGECOLORATTR]) !== null && _el$COMPLEMENTARY_BGI !== void 0 ? _el$COMPLEMENTARY_BGI : null]];
4415
+ var children = (0,_modules_domUtils__WEBPACK_IMPORTED_MODULE_3__.getChildrenAndIt)(el, true);
4416
+ children.forEach(function (child) {
4417
+ // 重置继承属性
4418
+ inheritAttrs.forEach(function (_ref) {
4419
+ var _ref2 = _slicedToArray(_ref, 2),
4420
+ attr = _ref2[0],
4421
+ value = _ref2[1];
4422
+ if (value === null) {
4423
+ delete child[attr];
4424
+ } else {
4425
+ child[attr] = value;
4426
+ }
4427
+ });
4428
+ });
4429
+ children.forEach(function (child) {
4430
+ // 重新运行Dark Mode处理逻辑
4431
+ _modules_global__WEBPACK_IMPORTED_MODULE_2__.cssUtils.addCss(_modules_global__WEBPACK_IMPORTED_MODULE_2__.sdk.convert(child, undefined, false, true));
4432
+ });
4433
+ });
4434
+ });
4435
+ }
4436
+ if (_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].needJudgeFirstPage || !_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].needJudgeFirstPage && !_modules_global__WEBPACK_IMPORTED_MODULE_2__.domUtils.showFirstPage) {
4437
+ // config.needJudgeFirstPage === ture,表示需要判断首屏但是正文长度没超过一屏
4438
+ // config.needJudgeFirstPage === false && domUtils.showFirstPage === false,表示不需要判断首屏且没有做首屏优化
4439
+ typeof _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].showFirstPage === 'function' && _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].showFirstPage(); // 执行首屏回调
4440
+ }
4441
+ _modules_global__WEBPACK_IMPORTED_MODULE_2__.cssUtils.writeStyle(); // 写入非首屏样式表
4442
+ _modules_global__WEBPACK_IMPORTED_MODULE_2__.domUtils.emptyFirstPageNodes(); // 清空记录的首屏节点
4443
+
4444
+ if (!_modules_global__WEBPACK_IMPORTED_MODULE_2__.sdk.isDarkmode) {
4445
+ // 非Dark Mode
4446
+ // 首次加载页面时为非Dark Mode,标记为不需要判断首屏
4447
+ _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].needJudgeFirstPage = false;
4448
+
4449
+ // 首次加载页面时为非Dark Mode,标记为不延迟判断背景
4450
+ _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].delayBgJudge = false;
4451
+ if (_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].container === null && opt.type === 'dom' && _modules_global__WEBPACK_IMPORTED_MODULE_2__.domUtils.length) {
4452
+ _modules_global__WEBPACK_IMPORTED_MODULE_2__.domUtils.delay(); // 将节点转移到延迟处理队列里
4453
+ }
4454
+ }
4455
+ } catch (e) {
4456
+ console.log('An error occurred when running the dark mode conversion algorithm\n', e);
4457
+ typeof _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].error === 'function' && _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].error(e);
4458
+ }
4459
+ };
4460
+
4461
+ // 初始化Dark Mode配置并运行Dark Mode处理
4462
+ function run(nodes, opt) {
4463
+ init(opt); // 初始化配置
4464
+
4465
+ _modules_global__WEBPACK_IMPORTED_MODULE_2__.domUtils.set(nodes);
4466
+ switchToDarkmode(mql, {
4467
+ force: true,
4468
+ type: 'dom'
4469
+ });
4470
+ }
4471
+ ;
4472
+
4473
+ // 初始化Dark Mode配置
4474
+ function init() {
4475
+ var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4476
+ if (_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].hasInit) return; // 只可设置一次配置
4477
+
4478
+ _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].hasInit = true; // 记录为配置已设置
4479
+
4480
+ var tagName = _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].whitelist.tagName;
4481
+ var attribute = _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].whitelist.attribute;
4482
+ if (opt.whitelist) {
4483
+ opt.whitelist.tagName instanceof Array && opt.whitelist.tagName.forEach(function (item) {
4484
+ item = item.toUpperCase();
4485
+ tagName.indexOf(item) === -1 && tagName.push(item);
4486
+ });
4487
+ opt.whitelist.attribute instanceof Array && opt.whitelist.attribute.forEach(function (item) {
4488
+ attribute.indexOf(item) === -1 && attribute.push(item);
4489
+ });
4490
+ }
4491
+ if (['dark', 'light'].indexOf(opt.mode) > -1) {
4492
+ _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('string', opt, 'mode');
4493
+ opt.mode === 'dark' && document.getElementsByTagName('html')[0].classList.add(_modules_constant__WEBPACK_IMPORTED_MODULE_0__.HTML_CLASS);
4494
+ }
4495
+ _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('function', opt, 'begin');
4496
+ _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('function', opt, 'showFirstPage');
4497
+ _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('function', opt, 'error');
4498
+ _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('boolean', opt, 'needJudgeFirstPage');
4499
+ _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('boolean', opt, 'delayBgJudge');
4500
+ _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('dom', opt, 'container');
4501
+ _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('string', opt, 'cssSelectorsPrefix');
4502
+ _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('string', opt, 'defaultLightTextColor');
4503
+ _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('string', opt, 'defaultLightBgColor');
4504
+ _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('string', opt, 'defaultDarkTextColor');
4505
+ _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('string', opt, 'defaultDarkBgColor');
4506
+ _modules_global__WEBPACK_IMPORTED_MODULE_2__.sdk.init();
4507
+ if (!_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].mode && mql === null && window.matchMedia) {
4508
+ // 匹配媒体查询
4509
+ mql = window.matchMedia(_modules_constant__WEBPACK_IMPORTED_MODULE_0__.MEDIA_QUERY);
4510
+ mql.addListener(switchToDarkmode); // 监听
4511
+ }
4512
+ }
4513
+ ;
4514
+
4515
+ // 处理背景
4516
+ function convertBg(nodes) {
4517
+ _modules_global__WEBPACK_IMPORTED_MODULE_2__.domUtils.set(nodes);
4518
+ if (_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].container !== null) {
4519
+ _modules_global__WEBPACK_IMPORTED_MODULE_2__.bgStack.update(nodes); // 更新背景堆栈
4520
+ _modules_global__WEBPACK_IMPORTED_MODULE_2__.tnQueue.update(nodes); // 更新文字队列
4521
+ }
4522
+ switchToDarkmode(mql, {
4523
+ force: true,
4524
+ type: 'bg'
4525
+ });
4526
+
4527
+ // 如果延迟背景判断且文字队列为空,则清空背景堆栈
4528
+ _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].delayBgJudge && _modules_global__WEBPACK_IMPORTED_MODULE_2__.tnQueue.length === 0 && _modules_global__WEBPACK_IMPORTED_MODULE_2__.bgStack.clear();
4529
+ }
4530
+ ;
4531
+
4532
+ // 更新节点Dark Mode样式
4533
+ function updateStyle(node, styles) {
4534
+ if (!_modules_global__WEBPACK_IMPORTED_MODULE_2__.cssUtils.isFinish) return; // 没有运行过Dark Mode处理逻辑则无需运行
4535
+ _modules_global__WEBPACK_IMPORTED_MODULE_2__.cssUtils.addCss(_modules_global__WEBPACK_IMPORTED_MODULE_2__.sdk.convert(node, styles ? Object.keys(styles).map(function (key) {
4536
+ return [key, styles[key]];
4537
+ }) : undefined, true), false);
4538
+ _modules_global__WEBPACK_IMPORTED_MODULE_2__.cssUtils.writeStyle();
4539
+ }
4540
+ ;
4541
+
4542
+ // 获取两个颜色的对比度
4543
+ function getContrast(color1, color2) {
4544
+ return _modules_global__WEBPACK_IMPORTED_MODULE_2__.sdk.getContrast(color1, color2);
4545
+ }
4546
+ ;
4547
+
4548
+ // 挂载插件
4549
+ function extend(pluginList) {
4550
+ pluginList.forEach(function (plugin) {
4551
+ return _modules_global__WEBPACK_IMPORTED_MODULE_2__.plugins.extend(plugin);
4552
+ });
4553
+ }
4554
+ ;
4555
+ })();
4556
+
4557
+ /******/ return __webpack_exports__;
4558
+ /******/ })()
4559
+ ;
4452
4560
  });
4453
4561
  //# sourceMappingURL=darkmode.js.map