mp-darkmode 1.2.2 → 1.2.3-beta.0
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 +763 -768
- package/dist/darkmode.js.map +1 -1
- package/dist/darkmode.min.js +1 -1
- package/package.json +1 -1
package/dist/darkmode.js
CHANGED
|
@@ -7,47 +7,132 @@
|
|
|
7
7
|
exports["Darkmode"] = factory();
|
|
8
8
|
else
|
|
9
9
|
root["Darkmode"] = factory();
|
|
10
|
-
})(
|
|
11
|
-
return /******/ (()
|
|
12
|
-
/******/
|
|
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
|
+
/******/ ({
|
|
13
98
|
|
|
14
|
-
/***/ "./node_modules/color-blend/dist/index.modern.js"
|
|
99
|
+
/***/ "./node_modules/color-blend/dist/index.modern.js":
|
|
15
100
|
/*!*******************************************************!*\
|
|
16
101
|
!*** ./node_modules/color-blend/dist/index.modern.js ***!
|
|
17
102
|
\*******************************************************/
|
|
18
|
-
|
|
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__) {
|
|
19
105
|
|
|
20
106
|
"use strict";
|
|
21
107
|
__webpack_require__.r(__webpack_exports__);
|
|
22
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
23
|
-
/* harmony export */
|
|
24
|
-
/* harmony export */
|
|
25
|
-
/* harmony export */
|
|
26
|
-
/* harmony export */
|
|
27
|
-
/* harmony export */
|
|
28
|
-
/* harmony export */
|
|
29
|
-
/* harmony export */
|
|
30
|
-
/* harmony export */
|
|
31
|
-
/* harmony export */
|
|
32
|
-
/* harmony export */
|
|
33
|
-
/* harmony export */
|
|
34
|
-
/* harmony export */
|
|
35
|
-
/* harmony export */
|
|
36
|
-
/* harmony export */
|
|
37
|
-
/* harmony export */
|
|
38
|
-
/* harmony export */ softLight: () => (/* binding */ K)
|
|
39
|
-
/* harmony export */ });
|
|
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; });
|
|
40
124
|
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)}
|
|
41
125
|
//# sourceMappingURL=index.modern.js.map
|
|
42
126
|
|
|
43
127
|
|
|
44
|
-
/***/ },
|
|
128
|
+
/***/ }),
|
|
45
129
|
|
|
46
|
-
/***/ "./node_modules/color-convert/conversions.js"
|
|
130
|
+
/***/ "./node_modules/color-convert/conversions.js":
|
|
47
131
|
/*!***************************************************!*\
|
|
48
132
|
!*** ./node_modules/color-convert/conversions.js ***!
|
|
49
133
|
\***************************************************/
|
|
50
|
-
|
|
134
|
+
/*! no static exports found */
|
|
135
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
51
136
|
|
|
52
137
|
/* MIT license */
|
|
53
138
|
var cssKeywords = __webpack_require__(/*! color-name */ "./node_modules/color-convert/node_modules/color-name/index.js");
|
|
@@ -919,13 +1004,14 @@ convert.rgb.gray = function (rgb) {
|
|
|
919
1004
|
};
|
|
920
1005
|
|
|
921
1006
|
|
|
922
|
-
/***/ },
|
|
1007
|
+
/***/ }),
|
|
923
1008
|
|
|
924
|
-
/***/ "./node_modules/color-convert/index.js"
|
|
1009
|
+
/***/ "./node_modules/color-convert/index.js":
|
|
925
1010
|
/*!*********************************************!*\
|
|
926
1011
|
!*** ./node_modules/color-convert/index.js ***!
|
|
927
1012
|
\*********************************************/
|
|
928
|
-
|
|
1013
|
+
/*! no static exports found */
|
|
1014
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
929
1015
|
|
|
930
1016
|
var conversions = __webpack_require__(/*! ./conversions */ "./node_modules/color-convert/conversions.js");
|
|
931
1017
|
var route = __webpack_require__(/*! ./route */ "./node_modules/color-convert/route.js");
|
|
@@ -1007,13 +1093,14 @@ models.forEach(function (fromModel) {
|
|
|
1007
1093
|
module.exports = convert;
|
|
1008
1094
|
|
|
1009
1095
|
|
|
1010
|
-
/***/ },
|
|
1096
|
+
/***/ }),
|
|
1011
1097
|
|
|
1012
|
-
/***/ "./node_modules/color-convert/node_modules/color-name/index.js"
|
|
1098
|
+
/***/ "./node_modules/color-convert/node_modules/color-name/index.js":
|
|
1013
1099
|
/*!*********************************************************************!*\
|
|
1014
1100
|
!*** ./node_modules/color-convert/node_modules/color-name/index.js ***!
|
|
1015
1101
|
\*********************************************************************/
|
|
1016
|
-
|
|
1102
|
+
/*! no static exports found */
|
|
1103
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
1017
1104
|
|
|
1018
1105
|
"use strict";
|
|
1019
1106
|
|
|
@@ -1170,13 +1257,14 @@ module.exports = {
|
|
|
1170
1257
|
};
|
|
1171
1258
|
|
|
1172
1259
|
|
|
1173
|
-
/***/ },
|
|
1260
|
+
/***/ }),
|
|
1174
1261
|
|
|
1175
|
-
/***/ "./node_modules/color-convert/route.js"
|
|
1262
|
+
/***/ "./node_modules/color-convert/route.js":
|
|
1176
1263
|
/*!*********************************************!*\
|
|
1177
1264
|
!*** ./node_modules/color-convert/route.js ***!
|
|
1178
1265
|
\*********************************************/
|
|
1179
|
-
|
|
1266
|
+
/*! no static exports found */
|
|
1267
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
1180
1268
|
|
|
1181
1269
|
var conversions = __webpack_require__(/*! ./conversions */ "./node_modules/color-convert/conversions.js");
|
|
1182
1270
|
|
|
@@ -1277,13 +1365,14 @@ module.exports = function (fromModel) {
|
|
|
1277
1365
|
|
|
1278
1366
|
|
|
1279
1367
|
|
|
1280
|
-
/***/ },
|
|
1368
|
+
/***/ }),
|
|
1281
1369
|
|
|
1282
|
-
/***/ "./node_modules/color-name/index.js"
|
|
1370
|
+
/***/ "./node_modules/color-name/index.js":
|
|
1283
1371
|
/*!******************************************!*\
|
|
1284
1372
|
!*** ./node_modules/color-name/index.js ***!
|
|
1285
1373
|
\******************************************/
|
|
1286
|
-
|
|
1374
|
+
/*! no static exports found */
|
|
1375
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
1287
1376
|
|
|
1288
1377
|
"use strict";
|
|
1289
1378
|
|
|
@@ -1440,20 +1529,21 @@ module.exports = {
|
|
|
1440
1529
|
};
|
|
1441
1530
|
|
|
1442
1531
|
|
|
1443
|
-
/***/ },
|
|
1532
|
+
/***/ }),
|
|
1444
1533
|
|
|
1445
|
-
/***/ "./node_modules/color-string/index.js"
|
|
1534
|
+
/***/ "./node_modules/color-string/index.js":
|
|
1446
1535
|
/*!********************************************!*\
|
|
1447
1536
|
!*** ./node_modules/color-string/index.js ***!
|
|
1448
1537
|
\********************************************/
|
|
1449
|
-
|
|
1538
|
+
/*! no static exports found */
|
|
1539
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
1450
1540
|
|
|
1451
1541
|
/* MIT license */
|
|
1452
1542
|
var colorNames = __webpack_require__(/*! color-name */ "./node_modules/color-name/index.js");
|
|
1453
1543
|
var swizzle = __webpack_require__(/*! simple-swizzle */ "./node_modules/simple-swizzle/index.js");
|
|
1454
1544
|
var hasOwnProperty = Object.hasOwnProperty;
|
|
1455
1545
|
|
|
1456
|
-
var reverseNames =
|
|
1546
|
+
var reverseNames = {};
|
|
1457
1547
|
|
|
1458
1548
|
// create a list of reverse color names
|
|
1459
1549
|
for (var name in colorNames) {
|
|
@@ -1692,13 +1782,14 @@ function hexDouble(num) {
|
|
|
1692
1782
|
}
|
|
1693
1783
|
|
|
1694
1784
|
|
|
1695
|
-
/***/ },
|
|
1785
|
+
/***/ }),
|
|
1696
1786
|
|
|
1697
|
-
/***/ "./node_modules/color/index.js"
|
|
1787
|
+
/***/ "./node_modules/color/index.js":
|
|
1698
1788
|
/*!*************************************!*\
|
|
1699
1789
|
!*** ./node_modules/color/index.js ***!
|
|
1700
1790
|
\*************************************/
|
|
1701
|
-
|
|
1791
|
+
/*! no static exports found */
|
|
1792
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
1702
1793
|
|
|
1703
1794
|
"use strict";
|
|
1704
1795
|
|
|
@@ -2185,13 +2276,14 @@ function zeroArray(arr, length) {
|
|
|
2185
2276
|
module.exports = Color;
|
|
2186
2277
|
|
|
2187
2278
|
|
|
2188
|
-
/***/ },
|
|
2279
|
+
/***/ }),
|
|
2189
2280
|
|
|
2190
|
-
/***/ "./node_modules/is-arrayish/index.js"
|
|
2281
|
+
/***/ "./node_modules/is-arrayish/index.js":
|
|
2191
2282
|
/*!*******************************************!*\
|
|
2192
2283
|
!*** ./node_modules/is-arrayish/index.js ***!
|
|
2193
2284
|
\*******************************************/
|
|
2194
|
-
|
|
2285
|
+
/*! no static exports found */
|
|
2286
|
+
/***/ (function(module, exports) {
|
|
2195
2287
|
|
|
2196
2288
|
module.exports = function isArrayish(obj) {
|
|
2197
2289
|
if (!obj || typeof obj === 'string') {
|
|
@@ -2204,13 +2296,14 @@ module.exports = function isArrayish(obj) {
|
|
|
2204
2296
|
};
|
|
2205
2297
|
|
|
2206
2298
|
|
|
2207
|
-
/***/ },
|
|
2299
|
+
/***/ }),
|
|
2208
2300
|
|
|
2209
|
-
/***/ "./node_modules/simple-swizzle/index.js"
|
|
2301
|
+
/***/ "./node_modules/simple-swizzle/index.js":
|
|
2210
2302
|
/*!**********************************************!*\
|
|
2211
2303
|
!*** ./node_modules/simple-swizzle/index.js ***!
|
|
2212
2304
|
\**********************************************/
|
|
2213
|
-
|
|
2305
|
+
/*! no static exports found */
|
|
2306
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
2214
2307
|
|
|
2215
2308
|
"use strict";
|
|
2216
2309
|
|
|
@@ -2244,27 +2337,310 @@ swizzle.wrap = function (fn) {
|
|
|
2244
2337
|
};
|
|
2245
2338
|
|
|
2246
2339
|
|
|
2247
|
-
/***/ },
|
|
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
|
+
/* harmony import */ var _modules_domUtils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./modules/domUtils */ "./src/modules/domUtils.js");
|
|
2361
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2362
|
+
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."); }
|
|
2363
|
+
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); }
|
|
2364
|
+
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; }
|
|
2365
|
+
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; }
|
|
2366
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
2367
|
+
/**
|
|
2368
|
+
* @name Darkmode主入口
|
|
2369
|
+
*
|
|
2370
|
+
* @function run 初始化Dark Mode配置并运行Dark Mode处理
|
|
2371
|
+
* @param {DOM Object Array} nodes 要处理的节点列表
|
|
2372
|
+
* @param {Object} opt Dark Mode配置,详见init配置说明
|
|
2373
|
+
* @return void
|
|
2374
|
+
*
|
|
2375
|
+
* @function init 初始化Dark Mode配置
|
|
2376
|
+
* @param {Function} opt.begin 开始处理时触发的回调
|
|
2377
|
+
* @param {Function} opt.showFirstPage 首屏处理完成时触发的回调
|
|
2378
|
+
* @param {Function} opt.error 发生error时触发的回调
|
|
2379
|
+
* @param {string} opt.mode 强制指定的颜色模式(dark|light), 指定了就不监听系统颜色
|
|
2380
|
+
* @param {Object} opt.whitelist 节点白名单
|
|
2381
|
+
* @param {Array} opt.whitelist.tagName 标签名列表
|
|
2382
|
+
* @param {Array} opt.whitelist.attribute 属性列表
|
|
2383
|
+
* @param {boolean} opt.needJudgeFirstPage 是否需要判断首屏
|
|
2384
|
+
* @param {boolean} opt.delayBgJudge 是否延迟背景判断
|
|
2385
|
+
* @param {DOM Object} opt.container 延迟运行js时使用的容器
|
|
2386
|
+
* @param {string} opt.cssSelectorsPrefix css选择器前缀
|
|
2387
|
+
* @param {string} opt.defaultLightTextColor 非Dark Mode下字体颜色
|
|
2388
|
+
* @param {string} opt.defaultLightBgColor 非Dark Mode下背景颜色
|
|
2389
|
+
* @param {string} opt.defaultDarkTextColor Dark Mode下字体颜色
|
|
2390
|
+
* @param {string} opt.defaultDarkBgColor Dark Mode下背景颜色
|
|
2391
|
+
* @return void
|
|
2392
|
+
*
|
|
2393
|
+
* @function convertBg 处理背景
|
|
2394
|
+
* @param {DOM Object Array} nodes 要处理的节点列表
|
|
2395
|
+
* @return void
|
|
2396
|
+
*
|
|
2397
|
+
* @function updateStyle 更新节点Dark Mode样式
|
|
2398
|
+
* @param {DOM Object} node 要更新的节点
|
|
2399
|
+
* @param {Object} styles 更新的样式键值对对象,如:{ color: '#ddd' }
|
|
2400
|
+
* @return void
|
|
2401
|
+
*
|
|
2402
|
+
* @function getContrast 获取两个颜色的对比度
|
|
2403
|
+
* @param {string} color1 要计算颜色对比度的颜色1,支持css颜色格式
|
|
2404
|
+
* @param {string} color2 要计算颜色对比度的颜色2,支持css颜色格式
|
|
2405
|
+
* @return {number} 颜色对比度,取值范围为`[1, 21]`
|
|
2406
|
+
*
|
|
2407
|
+
* @function extend 挂载插件
|
|
2408
|
+
* @param {Array} pluginList 插件列表
|
|
2409
|
+
* @return void
|
|
2410
|
+
*
|
|
2411
|
+
*/
|
|
2412
|
+
|
|
2413
|
+
// 常量
|
|
2414
|
+
|
|
2415
|
+
var classReg = new RegExp("".concat(_modules_constant__WEBPACK_IMPORTED_MODULE_0__["CLASS_PREFIX"], "[^ ]+"), 'g');
|
|
2416
|
+
|
|
2417
|
+
// Darkmode配置
|
|
2418
|
+
|
|
2419
|
+
|
|
2420
|
+
|
|
2421
|
+
|
|
2422
|
+
// Dark Mode切换
|
|
2423
|
+
var mql = null;
|
|
2424
|
+
var switchToDarkmode = function switchToDarkmode(mqlObj) {
|
|
2425
|
+
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
2426
|
+
type: 'dom'
|
|
2427
|
+
};
|
|
2428
|
+
opt.force && (_modules_global__WEBPACK_IMPORTED_MODULE_2__["cssUtils"].isFinish = false); // 如果是强制运行Dark Mode处理逻辑,则重置为未运行
|
|
2429
|
+
|
|
2430
|
+
if (_modules_global__WEBPACK_IMPORTED_MODULE_2__["cssUtils"].isFinish) return; // 已运行过Dark Mode处理逻辑则不再运行
|
|
2431
|
+
|
|
2432
|
+
try {
|
|
2433
|
+
_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;
|
|
2434
|
+
if (opt.type === 'dom') {
|
|
2435
|
+
// 处理节点
|
|
2436
|
+
_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());
|
|
2437
|
+
Array.prototype.forEach.call(_modules_global__WEBPACK_IMPORTED_MODULE_2__["domUtils"].get(), function (node) {
|
|
2438
|
+
if (_modules_global__WEBPACK_IMPORTED_MODULE_2__["sdk"].isDarkmode && node.className && typeof node.className === 'string') {
|
|
2439
|
+
node.className = node.className.replace(classReg, ''); // 过滤掉原有的Dark Mode class,避免外部复制文章时把文章内的Dark Mode class也复制过去导致新文章在Dark Mode下样式错乱
|
|
2440
|
+
}
|
|
2441
|
+
|
|
2442
|
+
if (_modules_global__WEBPACK_IMPORTED_MODULE_2__["sdk"].isDarkmode || _modules_global__WEBPACK_IMPORTED_MODULE_2__["plugins"].length) {
|
|
2443
|
+
if (!_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].needJudgeFirstPage) {
|
|
2444
|
+
// 不需要判断首屏
|
|
2445
|
+
_modules_global__WEBPACK_IMPORTED_MODULE_2__["cssUtils"].addCss(_modules_global__WEBPACK_IMPORTED_MODULE_2__["sdk"].convert(node)); // 写入非首屏样式
|
|
2446
|
+
} else {
|
|
2447
|
+
// 判断首屏
|
|
2448
|
+
var rect = node.getBoundingClientRect();
|
|
2449
|
+
var top = rect.top;
|
|
2450
|
+
var bottom = rect.bottom;
|
|
2451
|
+
if (top <= 0 && bottom <= 0) {
|
|
2452
|
+
// 首屏前面
|
|
2453
|
+
_modules_global__WEBPACK_IMPORTED_MODULE_2__["cssUtils"].addCss(_modules_global__WEBPACK_IMPORTED_MODULE_2__["sdk"].convert(node)); // 写入非首屏样式
|
|
2454
|
+
} else if (top > 0 && top < _modules_constant__WEBPACK_IMPORTED_MODULE_0__["PAGE_HEIGHT"] || bottom > 0 && bottom < _modules_constant__WEBPACK_IMPORTED_MODULE_0__["PAGE_HEIGHT"]) {
|
|
2455
|
+
// 首屏
|
|
2456
|
+
_modules_global__WEBPACK_IMPORTED_MODULE_2__["domUtils"].addFirstPageNode(node); // 记录首屏节点
|
|
2457
|
+
_modules_global__WEBPACK_IMPORTED_MODULE_2__["cssUtils"].addCss(_modules_global__WEBPACK_IMPORTED_MODULE_2__["sdk"].convert(node), true); // 写入首屏样式
|
|
2458
|
+
} else {
|
|
2459
|
+
// 首屏后面,理论上,这里最多只会进来一次
|
|
2460
|
+
_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].needJudgeFirstPage = false; // 至此,不需要再判断首屏了
|
|
2461
|
+
|
|
2462
|
+
// 显示首屏
|
|
2463
|
+
_modules_global__WEBPACK_IMPORTED_MODULE_2__["cssUtils"].writeStyle(true); // 写入首屏样式表
|
|
2464
|
+
_modules_global__WEBPACK_IMPORTED_MODULE_2__["domUtils"].showFirstPageNodes(); // 显示首屏节点
|
|
2465
|
+
typeof _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].showFirstPage === 'function' && _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].showFirstPage(); // 执行首屏回调
|
|
2466
|
+
|
|
2467
|
+
_modules_global__WEBPACK_IMPORTED_MODULE_2__["cssUtils"].addCss(_modules_global__WEBPACK_IMPORTED_MODULE_2__["sdk"].convert(node)); // 写入非首屏样式
|
|
2468
|
+
}
|
|
2469
|
+
}
|
|
2470
|
+
}
|
|
2471
|
+
});
|
|
2472
|
+
|
|
2473
|
+
_modules_global__WEBPACK_IMPORTED_MODULE_2__["plugins"].loopTimes++;
|
|
2474
|
+
} else if (opt.type === 'bg') {
|
|
2475
|
+
// 处理背景
|
|
2476
|
+
_modules_global__WEBPACK_IMPORTED_MODULE_2__["sdk"].isDarkmode && _modules_global__WEBPACK_IMPORTED_MODULE_2__["tnQueue"].forEach(function (text) {
|
|
2477
|
+
return _modules_global__WEBPACK_IMPORTED_MODULE_2__["bgStack"].contains(text, function (bg) {
|
|
2478
|
+
_modules_global__WEBPACK_IMPORTED_MODULE_2__["cssUtils"].addCss(_modules_global__WEBPACK_IMPORTED_MODULE_2__["cssUtils"].genCss(bg.className, bg.cssKV)); // 写入非首屏样式
|
|
2479
|
+
typeof bg.cb === 'function' && bg.cb(bg);
|
|
2480
|
+
|
|
2481
|
+
// 还得处理该背景下的所有新老节点
|
|
2482
|
+
[bg.elOld, bg.el].forEach(function (el) {
|
|
2483
|
+
var _el$COLORATTR, _el$BGCOLORATTR, _el$ORIGINAL_COLORATT, _el$ORIGINAL_BGCOLORA, _el$BGIMAGEATTR, _el$COMPLEMENTARY_BGI;
|
|
2484
|
+
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]];
|
|
2485
|
+
var children = Object(_modules_domUtils__WEBPACK_IMPORTED_MODULE_3__["getChildrenAndIt"])(el, true);
|
|
2486
|
+
children.forEach(function (child) {
|
|
2487
|
+
// 重置继承属性
|
|
2488
|
+
inheritAttrs.forEach(function (_ref) {
|
|
2489
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
2490
|
+
attr = _ref2[0],
|
|
2491
|
+
value = _ref2[1];
|
|
2492
|
+
if (value === null) {
|
|
2493
|
+
delete child[attr];
|
|
2494
|
+
} else {
|
|
2495
|
+
child[attr] = value;
|
|
2496
|
+
}
|
|
2497
|
+
});
|
|
2498
|
+
});
|
|
2499
|
+
children.forEach(function (child) {
|
|
2500
|
+
// 重新运行Dark Mode处理逻辑
|
|
2501
|
+
_modules_global__WEBPACK_IMPORTED_MODULE_2__["cssUtils"].addCss(_modules_global__WEBPACK_IMPORTED_MODULE_2__["sdk"].convert(child, undefined, false, true));
|
|
2502
|
+
});
|
|
2503
|
+
});
|
|
2504
|
+
});
|
|
2505
|
+
});
|
|
2506
|
+
}
|
|
2507
|
+
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) {
|
|
2508
|
+
// config.needJudgeFirstPage === ture,表示需要判断首屏但是正文长度没超过一屏
|
|
2509
|
+
// config.needJudgeFirstPage === false && domUtils.showFirstPage === false,表示不需要判断首屏且没有做首屏优化
|
|
2510
|
+
typeof _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].showFirstPage === 'function' && _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].showFirstPage(); // 执行首屏回调
|
|
2511
|
+
}
|
|
2512
|
+
|
|
2513
|
+
_modules_global__WEBPACK_IMPORTED_MODULE_2__["cssUtils"].writeStyle(); // 写入非首屏样式表
|
|
2514
|
+
_modules_global__WEBPACK_IMPORTED_MODULE_2__["domUtils"].emptyFirstPageNodes(); // 清空记录的首屏节点
|
|
2515
|
+
|
|
2516
|
+
if (!_modules_global__WEBPACK_IMPORTED_MODULE_2__["sdk"].isDarkmode) {
|
|
2517
|
+
// 非Dark Mode
|
|
2518
|
+
// 首次加载页面时为非Dark Mode,标记为不需要判断首屏
|
|
2519
|
+
_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].needJudgeFirstPage = false;
|
|
2520
|
+
|
|
2521
|
+
// 首次加载页面时为非Dark Mode,标记为不延迟判断背景
|
|
2522
|
+
_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].delayBgJudge = false;
|
|
2523
|
+
if (_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].container === null && opt.type === 'dom' && _modules_global__WEBPACK_IMPORTED_MODULE_2__["domUtils"].length) {
|
|
2524
|
+
_modules_global__WEBPACK_IMPORTED_MODULE_2__["domUtils"].delay(); // 将节点转移到延迟处理队列里
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2527
|
+
} catch (e) {
|
|
2528
|
+
console.log('An error occurred when running the dark mode conversion algorithm\n', e);
|
|
2529
|
+
typeof _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].error === 'function' && _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].error(e);
|
|
2530
|
+
}
|
|
2531
|
+
};
|
|
2532
|
+
|
|
2533
|
+
// 初始化Dark Mode配置并运行Dark Mode处理
|
|
2534
|
+
function run(nodes, opt) {
|
|
2535
|
+
init(opt); // 初始化配置
|
|
2536
|
+
|
|
2537
|
+
_modules_global__WEBPACK_IMPORTED_MODULE_2__["domUtils"].set(nodes);
|
|
2538
|
+
switchToDarkmode(mql, {
|
|
2539
|
+
force: true,
|
|
2540
|
+
type: 'dom'
|
|
2541
|
+
});
|
|
2542
|
+
}
|
|
2543
|
+
;
|
|
2544
|
+
|
|
2545
|
+
// 初始化Dark Mode配置
|
|
2546
|
+
function init() {
|
|
2547
|
+
var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2548
|
+
if (_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].hasInit) return; // 只可设置一次配置
|
|
2549
|
+
|
|
2550
|
+
_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].hasInit = true; // 记录为配置已设置
|
|
2551
|
+
|
|
2552
|
+
var tagName = _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].whitelist.tagName;
|
|
2553
|
+
var attribute = _modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].whitelist.attribute;
|
|
2554
|
+
if (opt.whitelist) {
|
|
2555
|
+
opt.whitelist.tagName instanceof Array && opt.whitelist.tagName.forEach(function (item) {
|
|
2556
|
+
item = item.toUpperCase();
|
|
2557
|
+
tagName.indexOf(item) === -1 && tagName.push(item);
|
|
2558
|
+
});
|
|
2559
|
+
opt.whitelist.attribute instanceof Array && opt.whitelist.attribute.forEach(function (item) {
|
|
2560
|
+
attribute.indexOf(item) === -1 && attribute.push(item);
|
|
2561
|
+
});
|
|
2562
|
+
}
|
|
2563
|
+
if (['dark', 'light'].indexOf(opt.mode) > -1) {
|
|
2564
|
+
_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('string', opt, 'mode');
|
|
2565
|
+
opt.mode === 'dark' && document.getElementsByTagName('html')[0].classList.add(_modules_constant__WEBPACK_IMPORTED_MODULE_0__["HTML_CLASS"]);
|
|
2566
|
+
}
|
|
2567
|
+
_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('function', opt, 'begin');
|
|
2568
|
+
_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('function', opt, 'showFirstPage');
|
|
2569
|
+
_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('function', opt, 'error');
|
|
2570
|
+
_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('boolean', opt, 'needJudgeFirstPage');
|
|
2571
|
+
_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('boolean', opt, 'delayBgJudge');
|
|
2572
|
+
_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('dom', opt, 'container');
|
|
2573
|
+
_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('string', opt, 'cssSelectorsPrefix');
|
|
2574
|
+
_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('string', opt, 'defaultLightTextColor');
|
|
2575
|
+
_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('string', opt, 'defaultLightBgColor');
|
|
2576
|
+
_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('string', opt, 'defaultDarkTextColor');
|
|
2577
|
+
_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].set('string', opt, 'defaultDarkBgColor');
|
|
2578
|
+
_modules_global__WEBPACK_IMPORTED_MODULE_2__["sdk"].init();
|
|
2579
|
+
if (!_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].mode && mql === null && window.matchMedia) {
|
|
2580
|
+
// 匹配媒体查询
|
|
2581
|
+
mql = window.matchMedia(_modules_constant__WEBPACK_IMPORTED_MODULE_0__["MEDIA_QUERY"]);
|
|
2582
|
+
mql.addListener(switchToDarkmode); // 监听
|
|
2583
|
+
}
|
|
2584
|
+
}
|
|
2585
|
+
|
|
2586
|
+
;
|
|
2587
|
+
|
|
2588
|
+
// 处理背景
|
|
2589
|
+
function convertBg(nodes) {
|
|
2590
|
+
_modules_global__WEBPACK_IMPORTED_MODULE_2__["domUtils"].set(nodes);
|
|
2591
|
+
if (_modules_config__WEBPACK_IMPORTED_MODULE_1__["default"].container !== null) {
|
|
2592
|
+
_modules_global__WEBPACK_IMPORTED_MODULE_2__["bgStack"].update(nodes); // 更新背景堆栈
|
|
2593
|
+
_modules_global__WEBPACK_IMPORTED_MODULE_2__["tnQueue"].update(nodes); // 更新文字队列
|
|
2594
|
+
}
|
|
2595
|
+
|
|
2596
|
+
switchToDarkmode(mql, {
|
|
2597
|
+
force: true,
|
|
2598
|
+
type: 'bg'
|
|
2599
|
+
});
|
|
2600
|
+
}
|
|
2601
|
+
;
|
|
2602
|
+
|
|
2603
|
+
// 更新节点Dark Mode样式
|
|
2604
|
+
function updateStyle(node, styles) {
|
|
2605
|
+
if (!_modules_global__WEBPACK_IMPORTED_MODULE_2__["cssUtils"].isFinish) return; // 没有运行过Dark Mode处理逻辑则无需运行
|
|
2606
|
+
_modules_global__WEBPACK_IMPORTED_MODULE_2__["cssUtils"].addCss(_modules_global__WEBPACK_IMPORTED_MODULE_2__["sdk"].convert(node, styles ? Object.keys(styles).map(function (key) {
|
|
2607
|
+
return [key, styles[key]];
|
|
2608
|
+
}) : undefined, true), false);
|
|
2609
|
+
_modules_global__WEBPACK_IMPORTED_MODULE_2__["cssUtils"].writeStyle();
|
|
2610
|
+
}
|
|
2611
|
+
;
|
|
2612
|
+
|
|
2613
|
+
// 获取两个颜色的对比度
|
|
2614
|
+
function getContrast(color1, color2) {
|
|
2615
|
+
return _modules_global__WEBPACK_IMPORTED_MODULE_2__["sdk"].getContrast(color1, color2);
|
|
2616
|
+
}
|
|
2617
|
+
;
|
|
2618
|
+
|
|
2619
|
+
// 挂载插件
|
|
2620
|
+
function extend(pluginList) {
|
|
2621
|
+
pluginList.forEach(function (plugin) {
|
|
2622
|
+
return _modules_global__WEBPACK_IMPORTED_MODULE_2__["plugins"].extend(plugin);
|
|
2623
|
+
});
|
|
2624
|
+
}
|
|
2625
|
+
;
|
|
2626
|
+
|
|
2627
|
+
/***/ }),
|
|
2248
2628
|
|
|
2249
|
-
/***/ "./src/modules/bgNodeStack.js"
|
|
2629
|
+
/***/ "./src/modules/bgNodeStack.js":
|
|
2250
2630
|
/*!************************************!*\
|
|
2251
2631
|
!*** ./src/modules/bgNodeStack.js ***!
|
|
2252
2632
|
\************************************/
|
|
2253
|
-
|
|
2633
|
+
/*! exports provided: default */
|
|
2634
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
2254
2635
|
|
|
2255
2636
|
"use strict";
|
|
2256
2637
|
__webpack_require__.r(__webpack_exports__);
|
|
2257
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2258
|
-
/* harmony export */ "default": () => (/* binding */ BgNodeStack)
|
|
2259
|
-
/* harmony export */ });
|
|
2638
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return BgNodeStack; });
|
|
2260
2639
|
/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./config */ "./src/modules/config.js");
|
|
2261
|
-
function
|
|
2262
|
-
function
|
|
2263
|
-
function
|
|
2264
|
-
function
|
|
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); }
|
|
2640
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2641
|
+
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); } }
|
|
2642
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
2643
|
+
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; }
|
|
2268
2644
|
/**
|
|
2269
2645
|
* @name 需要判断位置的背景节点堆栈
|
|
2270
2646
|
*
|
|
@@ -2287,32 +2663,30 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
2287
2663
|
* @param {DOM Object Array} els 要更新的节点对象列表
|
|
2288
2664
|
* @return void
|
|
2289
2665
|
*
|
|
2290
|
-
* @method clear 清空堆栈
|
|
2291
|
-
* @return void
|
|
2292
|
-
*
|
|
2293
2666
|
*/
|
|
2294
2667
|
|
|
2295
2668
|
// Darkmode配置
|
|
2296
2669
|
|
|
2297
2670
|
var BgNodeStack = /*#__PURE__*/function () {
|
|
2671
|
+
// 需要判断位置的背景堆栈,{ elOld, el, className, cssKV, updated, rect }
|
|
2298
2672
|
// 索引值
|
|
2299
2673
|
|
|
2300
2674
|
function BgNodeStack(prefix) {
|
|
2301
2675
|
_classCallCheck(this, BgNodeStack);
|
|
2302
2676
|
_defineProperty(this, "_stack", []);
|
|
2303
|
-
// 需要判断位置的背景堆栈,{ el, className, cssKV, updated, rect }
|
|
2304
2677
|
_defineProperty(this, "_idx", 0);
|
|
2305
2678
|
this._prefix = prefix;
|
|
2306
2679
|
this.classNameReg = new RegExp("".concat(this._prefix, "\\d+"));
|
|
2307
2680
|
}
|
|
2308
2681
|
|
|
2309
2682
|
// 背景节点入栈
|
|
2310
|
-
|
|
2683
|
+
_createClass(BgNodeStack, [{
|
|
2311
2684
|
key: "push",
|
|
2312
2685
|
value: function push(el, cssKV, cb) {
|
|
2313
2686
|
var className = "".concat(this._prefix).concat(this._idx++);
|
|
2314
2687
|
el.classList.add(className);
|
|
2315
2688
|
this._stack.unshift({
|
|
2689
|
+
elOld: el,
|
|
2316
2690
|
el: el,
|
|
2317
2691
|
className: className,
|
|
2318
2692
|
cssKV: cssKV,
|
|
@@ -2339,13 +2713,7 @@ var BgNodeStack = /*#__PURE__*/function () {
|
|
|
2339
2713
|
});
|
|
2340
2714
|
while (idxStack.length) {
|
|
2341
2715
|
var idx = idxStack.shift();
|
|
2342
|
-
var item =
|
|
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
|
-
}
|
|
2716
|
+
var item = this._stack.splice(idx, 1)[0];
|
|
2349
2717
|
typeof callback === 'function' && callback(item);
|
|
2350
2718
|
}
|
|
2351
2719
|
}
|
|
@@ -2367,36 +2735,29 @@ var BgNodeStack = /*#__PURE__*/function () {
|
|
|
2367
2735
|
}
|
|
2368
2736
|
});
|
|
2369
2737
|
}
|
|
2370
|
-
|
|
2371
|
-
// 清空堆栈
|
|
2372
|
-
}, {
|
|
2373
|
-
key: "clear",
|
|
2374
|
-
value: function clear() {
|
|
2375
|
-
this._stack = [];
|
|
2376
|
-
}
|
|
2377
2738
|
}]);
|
|
2739
|
+
return BgNodeStack;
|
|
2378
2740
|
}();
|
|
2379
2741
|
|
|
2380
2742
|
;
|
|
2381
2743
|
|
|
2382
|
-
/***/ },
|
|
2744
|
+
/***/ }),
|
|
2383
2745
|
|
|
2384
|
-
/***/ "./src/modules/color.js"
|
|
2746
|
+
/***/ "./src/modules/color.js":
|
|
2385
2747
|
/*!******************************!*\
|
|
2386
2748
|
!*** ./src/modules/color.js ***!
|
|
2387
2749
|
\******************************/
|
|
2388
|
-
|
|
2750
|
+
/*! exports provided: ColorParser, parseColorName, parseWebkitFillColorAndStrokeColor, mixColors, getColorPerceivedBrightness, adjustBrightnessTo */
|
|
2751
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
2389
2752
|
|
|
2390
2753
|
"use strict";
|
|
2391
2754
|
__webpack_require__.r(__webpack_exports__);
|
|
2392
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2393
|
-
/* harmony export */
|
|
2394
|
-
/* harmony export */
|
|
2395
|
-
/* harmony export */
|
|
2396
|
-
/* harmony export */
|
|
2397
|
-
/* harmony export */
|
|
2398
|
-
/* harmony export */ parseWebkitFillColorAndStrokeColor: () => (/* binding */ parseWebkitFillColorAndStrokeColor)
|
|
2399
|
-
/* harmony export */ });
|
|
2755
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorParser", function() { return ColorParser; });
|
|
2756
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseColorName", function() { return parseColorName; });
|
|
2757
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseWebkitFillColorAndStrokeColor", function() { return parseWebkitFillColorAndStrokeColor; });
|
|
2758
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mixColors", function() { return mixColors; });
|
|
2759
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getColorPerceivedBrightness", function() { return getColorPerceivedBrightness; });
|
|
2760
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "adjustBrightnessTo", function() { return adjustBrightnessTo; });
|
|
2400
2761
|
/* harmony import */ var color__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! color */ "./node_modules/color/index.js");
|
|
2401
2762
|
/* harmony import */ var color__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(color__WEBPACK_IMPORTED_MODULE_0__);
|
|
2402
2763
|
/* harmony import */ var color_name__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! color-name */ "./node_modules/color-name/index.js");
|
|
@@ -2437,13 +2798,13 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2437
2798
|
|
|
2438
2799
|
|
|
2439
2800
|
|
|
2440
|
-
|
|
2441
|
-
|
|
2801
|
+
color_name__WEBPACK_IMPORTED_MODULE_1___default.a.windowtext = [0, 0, 0]; // 补上这个colorName
|
|
2802
|
+
color_name__WEBPACK_IMPORTED_MODULE_1___default.a.transparent = [255, 255, 255, 0]; // 支持透明,暂定用白色透明度0来表示
|
|
2442
2803
|
|
|
2443
2804
|
|
|
2444
2805
|
// 常量
|
|
2445
2806
|
|
|
2446
|
-
var COLOR_NAME_REG = new RegExp(Object.keys(
|
|
2807
|
+
var COLOR_NAME_REG = new RegExp(Object.keys(color_name__WEBPACK_IMPORTED_MODULE_1___default.a).map(function (colorName) {
|
|
2447
2808
|
return "\\b".concat(colorName, "\\b");
|
|
2448
2809
|
}).join('|'), 'ig'); // 生成正则表达式来匹配这些colorName
|
|
2449
2810
|
|
|
@@ -2466,7 +2827,7 @@ var colorBlend2Color = function colorBlend2Color(colorBlend) {
|
|
|
2466
2827
|
var ColorParser = function ColorParser(color) {
|
|
2467
2828
|
var res = null;
|
|
2468
2829
|
try {
|
|
2469
|
-
res = color instanceof
|
|
2830
|
+
res = color instanceof color__WEBPACK_IMPORTED_MODULE_0___default.a ? color : color__WEBPACK_IMPORTED_MODULE_0___default()(color);
|
|
2470
2831
|
} catch (e) {
|
|
2471
2832
|
console.log("ignore the invalid color: `".concat(color, "`"));
|
|
2472
2833
|
}
|
|
@@ -2475,10 +2836,10 @@ var ColorParser = function ColorParser(color) {
|
|
|
2475
2836
|
|
|
2476
2837
|
// 处理颜色,包括清除!important和转换英文定义颜色
|
|
2477
2838
|
var parseColorName = function parseColorName(color, supportTransparent) {
|
|
2478
|
-
return color.replace(_constant__WEBPACK_IMPORTED_MODULE_3__
|
|
2839
|
+
return color.replace(_constant__WEBPACK_IMPORTED_MODULE_3__["IMPORTANT_REGEXP"], '').replace(COLOR_NAME_REG, function (match) {
|
|
2479
2840
|
if (!supportTransparent && match === 'transparent') return match; // 如果不支持转换transparent,直接返回transparent
|
|
2480
2841
|
|
|
2481
|
-
var color =
|
|
2842
|
+
var color = color_name__WEBPACK_IMPORTED_MODULE_1___default.a[match.toLowerCase()];
|
|
2482
2843
|
return "".concat(color.length > 3 ? 'rgba' : 'rgb', "(").concat(color.toString(), ")");
|
|
2483
2844
|
});
|
|
2484
2845
|
};
|
|
@@ -2486,7 +2847,7 @@ var parseColorName = function parseColorName(color, supportTransparent) {
|
|
|
2486
2847
|
// 处理-webkit-fill-color和-webkit-text-stroke-color,返回处理后的色值,无则返回空字符串
|
|
2487
2848
|
var parseWebkitFillColorAndStrokeColor = function parseWebkitFillColorAndStrokeColor(color) {
|
|
2488
2849
|
var newValue = parseColorName(color);
|
|
2489
|
-
return _constant__WEBPACK_IMPORTED_MODULE_3__
|
|
2850
|
+
return _constant__WEBPACK_IMPORTED_MODULE_3__["COLOR_REGEXP"].test(newValue) ? newValue : '';
|
|
2490
2851
|
};
|
|
2491
2852
|
|
|
2492
2853
|
// 计算混合颜色
|
|
@@ -2533,22 +2894,20 @@ var adjustBrightnessTo = function adjustBrightnessTo(target, rgb) {
|
|
|
2533
2894
|
} else if (newTextB === 0 || newTextG === 255) {
|
|
2534
2895
|
newTextB = (target * 1000 - newTextR * 299 - newTextG * 587) / 114;
|
|
2535
2896
|
}
|
|
2536
|
-
return color__WEBPACK_IMPORTED_MODULE_0___default
|
|
2897
|
+
return color__WEBPACK_IMPORTED_MODULE_0___default.a.rgb(newTextR, newTextG, newTextB);
|
|
2537
2898
|
};
|
|
2538
2899
|
|
|
2539
|
-
/***/ },
|
|
2900
|
+
/***/ }),
|
|
2540
2901
|
|
|
2541
|
-
/***/ "./src/modules/config.js"
|
|
2902
|
+
/***/ "./src/modules/config.js":
|
|
2542
2903
|
/*!*******************************!*\
|
|
2543
2904
|
!*** ./src/modules/config.js ***!
|
|
2544
2905
|
\*******************************/
|
|
2545
|
-
|
|
2906
|
+
/*! exports provided: default */
|
|
2907
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
2546
2908
|
|
|
2547
2909
|
"use strict";
|
|
2548
2910
|
__webpack_require__.r(__webpack_exports__);
|
|
2549
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2550
|
-
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
2551
|
-
/* harmony export */ });
|
|
2552
2911
|
/* harmony import */ var _constant__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constant */ "./src/modules/constant.js");
|
|
2553
2912
|
/**
|
|
2554
2913
|
* @name Darkmode配置
|
|
@@ -2600,6 +2959,7 @@ var config = {
|
|
|
2600
2959
|
// 标签名列表
|
|
2601
2960
|
attribute: [] // 属性列表
|
|
2602
2961
|
},
|
|
2962
|
+
|
|
2603
2963
|
needJudgeFirstPage: true,
|
|
2604
2964
|
// 是否需要判断首屏
|
|
2605
2965
|
delayBgJudge: false,
|
|
@@ -2608,13 +2968,13 @@ var config = {
|
|
|
2608
2968
|
// 延迟运行js时使用的容器
|
|
2609
2969
|
cssSelectorsPrefix: '',
|
|
2610
2970
|
// css选择器前缀
|
|
2611
|
-
defaultLightTextColor: _constant__WEBPACK_IMPORTED_MODULE_0__
|
|
2971
|
+
defaultLightTextColor: _constant__WEBPACK_IMPORTED_MODULE_0__["DEFAULT_LIGHT_TEXTCOLOR"],
|
|
2612
2972
|
// 非Dark Mode下字体颜色
|
|
2613
|
-
defaultLightBgColor: _constant__WEBPACK_IMPORTED_MODULE_0__
|
|
2973
|
+
defaultLightBgColor: _constant__WEBPACK_IMPORTED_MODULE_0__["DEFAULT_LIGHT_BGCOLOR"],
|
|
2614
2974
|
// 非Dark Mode下背景颜色
|
|
2615
|
-
defaultDarkTextColor: _constant__WEBPACK_IMPORTED_MODULE_0__
|
|
2975
|
+
defaultDarkTextColor: _constant__WEBPACK_IMPORTED_MODULE_0__["DEFAULT_DARK_TEXTCOLOR"],
|
|
2616
2976
|
// Dark Mode下字体颜色
|
|
2617
|
-
defaultDarkBgColor: _constant__WEBPACK_IMPORTED_MODULE_0__
|
|
2977
|
+
defaultDarkBgColor: _constant__WEBPACK_IMPORTED_MODULE_0__["DEFAULT_DARK_BGCOLOR"],
|
|
2618
2978
|
// Dark Mode下背景颜色
|
|
2619
2979
|
// 设置配置
|
|
2620
2980
|
set: function set(type, opt, key) {
|
|
@@ -2636,51 +2996,50 @@ var config = {
|
|
|
2636
2996
|
}
|
|
2637
2997
|
}
|
|
2638
2998
|
};
|
|
2639
|
-
/* harmony default export */
|
|
2999
|
+
/* harmony default export */ __webpack_exports__["default"] = (config);
|
|
2640
3000
|
|
|
2641
|
-
/***/ },
|
|
3001
|
+
/***/ }),
|
|
2642
3002
|
|
|
2643
|
-
/***/ "./src/modules/constant.js"
|
|
3003
|
+
/***/ "./src/modules/constant.js":
|
|
2644
3004
|
/*!*********************************!*\
|
|
2645
3005
|
!*** ./src/modules/constant.js ***!
|
|
2646
3006
|
\*********************************/
|
|
2647
|
-
|
|
3007
|
+
/*! 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 */
|
|
3008
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
2648
3009
|
|
|
2649
3010
|
"use strict";
|
|
2650
3011
|
__webpack_require__.r(__webpack_exports__);
|
|
2651
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2652
|
-
/* harmony export */
|
|
2653
|
-
/* harmony export */
|
|
2654
|
-
/* harmony export */
|
|
2655
|
-
/* harmony export */
|
|
2656
|
-
/* harmony export */
|
|
2657
|
-
/* harmony export */
|
|
2658
|
-
/* harmony export */
|
|
2659
|
-
/* harmony export */
|
|
2660
|
-
/* harmony export */
|
|
2661
|
-
/* harmony export */
|
|
2662
|
-
/* harmony export */
|
|
2663
|
-
/* harmony export */
|
|
2664
|
-
/* harmony export */
|
|
2665
|
-
/* harmony export */
|
|
2666
|
-
/* harmony export */
|
|
2667
|
-
/* harmony export */
|
|
2668
|
-
/* harmony export */
|
|
2669
|
-
/* harmony export */
|
|
2670
|
-
/* harmony export */
|
|
2671
|
-
/* harmony export */
|
|
2672
|
-
/* harmony export */
|
|
2673
|
-
/* harmony export */
|
|
2674
|
-
/* harmony export */
|
|
2675
|
-
/* harmony export */
|
|
2676
|
-
/* harmony export */
|
|
2677
|
-
/* harmony export */
|
|
2678
|
-
/* harmony export */
|
|
2679
|
-
/* harmony export */
|
|
2680
|
-
/* harmony export */
|
|
2681
|
-
/* harmony export */
|
|
2682
|
-
/* harmony export */ WHITE_LIKE_COLOR_BRIGHTNESS: () => (/* binding */ WHITE_LIKE_COLOR_BRIGHTNESS)
|
|
2683
|
-
/* harmony export */ });
|
|
3012
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MEDIA_QUERY", function() { return MEDIA_QUERY; });
|
|
3013
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CLASS_PREFIX", function() { return CLASS_PREFIX; });
|
|
3014
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DM_CLASSNAME_REGEXP", function() { return DM_CLASSNAME_REGEXP; });
|
|
3015
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HTML_CLASS", function() { return HTML_CLASS; });
|
|
3016
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "COLORATTR", function() { return COLORATTR; });
|
|
3017
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BGCOLORATTR", function() { return BGCOLORATTR; });
|
|
3018
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ORIGINAL_COLORATTR", function() { return ORIGINAL_COLORATTR; });
|
|
3019
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ORIGINAL_BGCOLORATTR", function() { return ORIGINAL_BGCOLORATTR; });
|
|
3020
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BGIMAGEATTR", function() { return BGIMAGEATTR; });
|
|
3021
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "COMPLEMENTARY_BGIMAGECOLORATTR", function() { return COMPLEMENTARY_BGIMAGECOLORATTR; });
|
|
3022
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BG_COLOR_DELIMITER", function() { return BG_COLOR_DELIMITER; });
|
|
3023
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_LIGHT_TEXTCOLOR", function() { return DEFAULT_LIGHT_TEXTCOLOR; });
|
|
3024
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_LIGHT_BGCOLOR", function() { return DEFAULT_LIGHT_BGCOLOR; });
|
|
3025
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_DARK_TEXTCOLOR", function() { return DEFAULT_DARK_TEXTCOLOR; });
|
|
3026
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_DARK_BGCOLOR", function() { return DEFAULT_DARK_BGCOLOR; });
|
|
3027
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WHITE_LIKE_COLOR_BRIGHTNESS", function() { return WHITE_LIKE_COLOR_BRIGHTNESS; });
|
|
3028
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MAX_LIMIT_BGCOLOR_BRIGHTNESS", function() { return MAX_LIMIT_BGCOLOR_BRIGHTNESS; });
|
|
3029
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MIN_LIMIT_OFFSET_BRIGHTNESS", function() { return MIN_LIMIT_OFFSET_BRIGHTNESS; });
|
|
3030
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HIGH_BGCOLOR_BRIGHTNESS", function() { return HIGH_BGCOLOR_BRIGHTNESS; });
|
|
3031
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HIGH_BLACKWHITE_HSL_BRIGHTNESS", function() { return HIGH_BLACKWHITE_HSL_BRIGHTNESS; });
|
|
3032
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LOW_BLACKWHITE_HSL_BRIGHTNESS", function() { return LOW_BLACKWHITE_HSL_BRIGHTNESS; });
|
|
3033
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IGNORE_ALPHA", function() { return IGNORE_ALPHA; });
|
|
3034
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PAGE_HEIGHT", function() { return PAGE_HEIGHT; });
|
|
3035
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CSS_PROP_SERIES", function() { return CSS_PROP_SERIES; });
|
|
3036
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CSS_PROP_LIST", function() { return CSS_PROP_LIST; });
|
|
3037
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TABLE_NAME", function() { return TABLE_NAME; });
|
|
3038
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IMPORTANT_REGEXP", function() { return IMPORTANT_REGEXP; });
|
|
3039
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SEMICOLON_PLACEHOLDER", function() { return SEMICOLON_PLACEHOLDER; });
|
|
3040
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SEMICOLON_PLACEHOLDER_REGEXP", function() { return SEMICOLON_PLACEHOLDER_REGEXP; });
|
|
3041
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "COLOR_REGEXP", function() { return COLOR_REGEXP; });
|
|
3042
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "COLOR_REGEXP_GLOBAL", function() { return COLOR_REGEXP_GLOBAL; });
|
|
2684
3043
|
/**
|
|
2685
3044
|
* @name 常量
|
|
2686
3045
|
*
|
|
@@ -2733,6 +3092,7 @@ var CSS_PROP_SERIES = {
|
|
|
2733
3092
|
// 'filter'
|
|
2734
3093
|
// ],
|
|
2735
3094
|
};
|
|
3095
|
+
|
|
2736
3096
|
var CSS_PROP_LIST = Object.keys(CSS_PROP_SERIES).map(function (key) {
|
|
2737
3097
|
return CSS_PROP_SERIES[key].join('|');
|
|
2738
3098
|
}).join('|').split('|'); // 支持的css属性平铺列表
|
|
@@ -2745,35 +3105,31 @@ var SEMICOLON_PLACEHOLDER_REGEXP = /<\$#_SEMICOLON_#\$>/g;
|
|
|
2745
3105
|
var COLOR_REGEXP = /\brgba?\([^)]+\)/i;
|
|
2746
3106
|
var COLOR_REGEXP_GLOBAL = /\brgba?\([^)]+\)/ig;
|
|
2747
3107
|
|
|
2748
|
-
/***/ },
|
|
3108
|
+
/***/ }),
|
|
2749
3109
|
|
|
2750
|
-
/***/ "./src/modules/cssUtils.js"
|
|
3110
|
+
/***/ "./src/modules/cssUtils.js":
|
|
2751
3111
|
/*!*********************************!*\
|
|
2752
3112
|
!*** ./src/modules/cssUtils.js ***!
|
|
2753
3113
|
\*********************************/
|
|
2754
|
-
|
|
3114
|
+
/*! exports provided: default */
|
|
3115
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
2755
3116
|
|
|
2756
3117
|
"use strict";
|
|
2757
3118
|
__webpack_require__.r(__webpack_exports__);
|
|
2758
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2759
|
-
/* harmony export */ "default": () => (/* binding */ CssUtils)
|
|
2760
|
-
/* harmony export */ });
|
|
3119
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return CssUtils; });
|
|
2761
3120
|
/* harmony import */ var _constant__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constant */ "./src/modules/constant.js");
|
|
2762
3121
|
/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./config */ "./src/modules/config.js");
|
|
2763
3122
|
/* harmony import */ var _global__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./global */ "./src/modules/global.js");
|
|
2764
|
-
function
|
|
2765
|
-
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
3123
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2766
3124
|
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."); }
|
|
2767
|
-
function _unsupportedIterableToArray(
|
|
2768
|
-
function _arrayLikeToArray(
|
|
2769
|
-
function _iterableToArrayLimit(
|
|
2770
|
-
function _arrayWithHoles(
|
|
2771
|
-
function _classCallCheck(
|
|
2772
|
-
function _defineProperties(
|
|
2773
|
-
function _createClass(
|
|
2774
|
-
function _defineProperty(
|
|
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); }
|
|
3125
|
+
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); }
|
|
3126
|
+
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; }
|
|
3127
|
+
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; }
|
|
3128
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
3129
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3130
|
+
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); } }
|
|
3131
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
3132
|
+
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; }
|
|
2777
3133
|
/**
|
|
2778
3134
|
* @name 样式相关操作工具对象
|
|
2779
3135
|
*
|
|
@@ -2818,25 +3174,26 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
2818
3174
|
|
|
2819
3175
|
|
|
2820
3176
|
var CssUtils = /*#__PURE__*/function () {
|
|
3177
|
+
// 首屏样式
|
|
3178
|
+
// 非首屏样式
|
|
3179
|
+
// 监听器,用于监听生成css键值对
|
|
3180
|
+
|
|
2821
3181
|
// 是否运行过Dark Mode处理逻辑(写入过非首屏样式表则表示已运行过)
|
|
2822
3182
|
|
|
2823
3183
|
function CssUtils() {
|
|
2824
3184
|
_classCallCheck(this, CssUtils);
|
|
2825
3185
|
_defineProperty(this, "_firstPageStyle", '');
|
|
2826
|
-
// 首屏样式
|
|
2827
3186
|
_defineProperty(this, "_otherPageStyle", '');
|
|
2828
|
-
// 非首屏样式
|
|
2829
3187
|
_defineProperty(this, "_watcher", {});
|
|
2830
|
-
// 监听器,用于监听生成css键值对
|
|
2831
3188
|
_defineProperty(this, "isFinish", false);
|
|
2832
3189
|
}
|
|
2833
3190
|
|
|
2834
3191
|
// 生成css键值对
|
|
2835
|
-
|
|
3192
|
+
_createClass(CssUtils, [{
|
|
2836
3193
|
key: "genCssKV",
|
|
2837
3194
|
value: function genCssKV(key, val) {
|
|
2838
3195
|
var _this$_watcher$key, _this$_watcher;
|
|
2839
|
-
(_this$_watcher$key = (_this$_watcher = this._watcher)[key]) === null || _this$_watcher$key === void 0
|
|
3196
|
+
(_this$_watcher$key = (_this$_watcher = this._watcher)[key]) === null || _this$_watcher$key === void 0 ? void 0 : _this$_watcher$key.call(_this$_watcher);
|
|
2840
3197
|
return "".concat(key, ": ").concat(val, " !important;");
|
|
2841
3198
|
}
|
|
2842
3199
|
|
|
@@ -2844,7 +3201,7 @@ var CssUtils = /*#__PURE__*/function () {
|
|
|
2844
3201
|
}, {
|
|
2845
3202
|
key: "genCss",
|
|
2846
3203
|
value: function genCss(className, cssKV) {
|
|
2847
|
-
return "".concat(_config__WEBPACK_IMPORTED_MODULE_1__["default"].mode === 'dark' ? "html.".concat(_constant__WEBPACK_IMPORTED_MODULE_0__
|
|
3204
|
+
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, "}");
|
|
2848
3205
|
}
|
|
2849
3206
|
|
|
2850
3207
|
// 加入css
|
|
@@ -2853,7 +3210,7 @@ var CssUtils = /*#__PURE__*/function () {
|
|
|
2853
3210
|
value: function addCss(css) {
|
|
2854
3211
|
var isFirstPageStyle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
2855
3212
|
this[isFirstPageStyle ? '_firstPageStyle' : '_otherPageStyle'] += css;
|
|
2856
|
-
_global__WEBPACK_IMPORTED_MODULE_2__
|
|
3213
|
+
_global__WEBPACK_IMPORTED_MODULE_2__["plugins"].addCss(isFirstPageStyle);
|
|
2857
3214
|
}
|
|
2858
3215
|
|
|
2859
3216
|
// 写入样式表
|
|
@@ -2861,19 +3218,19 @@ var CssUtils = /*#__PURE__*/function () {
|
|
|
2861
3218
|
key: "writeStyle",
|
|
2862
3219
|
value: function writeStyle() {
|
|
2863
3220
|
var isFirstPageStyle = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
2864
|
-
!isFirstPageStyle && _global__WEBPACK_IMPORTED_MODULE_2__
|
|
3221
|
+
!isFirstPageStyle && _global__WEBPACK_IMPORTED_MODULE_2__["sdk"].isDarkmode && (this.isFinish = true); // 在Dark Mode下一旦写入了非首屏样式表,则认为已经运行过Dark Mode处理逻辑
|
|
2865
3222
|
|
|
2866
3223
|
// 获取样式表内容
|
|
2867
|
-
var styles = (_global__WEBPACK_IMPORTED_MODULE_2__
|
|
3224
|
+
var styles = (_global__WEBPACK_IMPORTED_MODULE_2__["sdk"].isDarkmode ? [{
|
|
2868
3225
|
target: this,
|
|
2869
3226
|
key: ['_firstPageStyle', '_otherPageStyle'],
|
|
2870
3227
|
needMediaQuery: true
|
|
2871
3228
|
}] : []).concat([{
|
|
2872
|
-
target: _global__WEBPACK_IMPORTED_MODULE_2__
|
|
3229
|
+
target: _global__WEBPACK_IMPORTED_MODULE_2__["plugins"],
|
|
2873
3230
|
key: ['firstPageStyle', 'otherPageStyle'],
|
|
2874
3231
|
needMediaQuery: true
|
|
2875
3232
|
}, {
|
|
2876
|
-
target: _global__WEBPACK_IMPORTED_MODULE_2__
|
|
3233
|
+
target: _global__WEBPACK_IMPORTED_MODULE_2__["plugins"],
|
|
2877
3234
|
key: ['firstPageStyleNoMQ', 'otherPageStyleNoMQ'],
|
|
2878
3235
|
needMediaQuery: false
|
|
2879
3236
|
}]).map(function (_ref) {
|
|
@@ -2894,7 +3251,7 @@ var CssUtils = /*#__PURE__*/function () {
|
|
|
2894
3251
|
var style = target[styleKey];
|
|
2895
3252
|
if (style) {
|
|
2896
3253
|
target[styleKey] = ''; // 写入样式表后清空内存中的数据
|
|
2897
|
-
return _config__WEBPACK_IMPORTED_MODULE_1__["default"].mode === 'dark' || !needMediaQuery ? style : "@media ".concat(_constant__WEBPACK_IMPORTED_MODULE_0__
|
|
3254
|
+
return _config__WEBPACK_IMPORTED_MODULE_1__["default"].mode === 'dark' || !needMediaQuery ? style : "@media ".concat(_constant__WEBPACK_IMPORTED_MODULE_0__["MEDIA_QUERY"], " {").concat(style, "}");
|
|
2898
3255
|
}
|
|
2899
3256
|
return '';
|
|
2900
3257
|
}).join('');
|
|
@@ -2917,41 +3274,38 @@ var CssUtils = /*#__PURE__*/function () {
|
|
|
2917
3274
|
delete this._watcher[key];
|
|
2918
3275
|
}
|
|
2919
3276
|
}]);
|
|
3277
|
+
return CssUtils;
|
|
2920
3278
|
}();
|
|
2921
3279
|
|
|
2922
3280
|
;
|
|
2923
3281
|
|
|
2924
|
-
/***/ },
|
|
3282
|
+
/***/ }),
|
|
2925
3283
|
|
|
2926
|
-
/***/ "./src/modules/domUtils.js"
|
|
3284
|
+
/***/ "./src/modules/domUtils.js":
|
|
2927
3285
|
/*!*********************************!*\
|
|
2928
3286
|
!*** ./src/modules/domUtils.js ***!
|
|
2929
3287
|
\*********************************/
|
|
2930
|
-
|
|
3288
|
+
/*! exports provided: getChildrenAndIt, hasTextNode, hasTableClass, DomUtils */
|
|
3289
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
2931
3290
|
|
|
2932
3291
|
"use strict";
|
|
2933
3292
|
__webpack_require__.r(__webpack_exports__);
|
|
2934
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2935
|
-
/* harmony export */
|
|
2936
|
-
/* harmony export */
|
|
2937
|
-
/* harmony export */
|
|
2938
|
-
/* harmony export */ hasTextNode: () => (/* binding */ hasTextNode)
|
|
2939
|
-
/* harmony export */ });
|
|
3293
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getChildrenAndIt", function() { return getChildrenAndIt; });
|
|
3294
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasTextNode", function() { return hasTextNode; });
|
|
3295
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasTableClass", function() { return hasTableClass; });
|
|
3296
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DomUtils", function() { return DomUtils; });
|
|
2940
3297
|
/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./config */ "./src/modules/config.js");
|
|
2941
3298
|
/* harmony import */ var _global__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./global */ "./src/modules/global.js");
|
|
2942
|
-
function
|
|
2943
|
-
function
|
|
2944
|
-
function
|
|
2945
|
-
function
|
|
2946
|
-
function
|
|
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(); }
|
|
3299
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3300
|
+
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); } }
|
|
3301
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
3302
|
+
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; }
|
|
3303
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2950
3304
|
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."); }
|
|
2951
|
-
function _unsupportedIterableToArray(
|
|
2952
|
-
function _iterableToArray(
|
|
2953
|
-
function _arrayWithoutHoles(
|
|
2954
|
-
function _arrayLikeToArray(
|
|
3305
|
+
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); }
|
|
3306
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
3307
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
3308
|
+
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; }
|
|
2955
3309
|
/**
|
|
2956
3310
|
* @name 节点相关操作工具API
|
|
2957
3311
|
*
|
|
@@ -3048,21 +3402,22 @@ function hasTableClass(el) {
|
|
|
3048
3402
|
*/
|
|
3049
3403
|
|
|
3050
3404
|
var DomUtils = /*#__PURE__*/function () {
|
|
3405
|
+
// 要处理的节点列表
|
|
3406
|
+
// 首屏节点列表
|
|
3407
|
+
// 延迟处理的节点列表
|
|
3408
|
+
|
|
3051
3409
|
// 是否已显示首屏
|
|
3052
3410
|
|
|
3053
3411
|
function DomUtils() {
|
|
3054
3412
|
_classCallCheck(this, DomUtils);
|
|
3055
3413
|
_defineProperty(this, "_els", []);
|
|
3056
|
-
// 要处理的节点列表
|
|
3057
3414
|
_defineProperty(this, "_firstPageEls", []);
|
|
3058
|
-
// 首屏节点列表
|
|
3059
3415
|
_defineProperty(this, "_delayEls", []);
|
|
3060
|
-
// 延迟处理的节点列表
|
|
3061
3416
|
_defineProperty(this, "showFirstPage", false);
|
|
3062
3417
|
}
|
|
3063
3418
|
|
|
3064
3419
|
// 要处理的节点列表长度
|
|
3065
|
-
|
|
3420
|
+
_createClass(DomUtils, [{
|
|
3066
3421
|
key: "length",
|
|
3067
3422
|
get: function get() {
|
|
3068
3423
|
return this._els.length;
|
|
@@ -3084,7 +3439,7 @@ var DomUtils = /*#__PURE__*/function () {
|
|
|
3084
3439
|
if (this._els.length) {
|
|
3085
3440
|
// 有节点
|
|
3086
3441
|
res = this._els;
|
|
3087
|
-
_global__WEBPACK_IMPORTED_MODULE_1__
|
|
3442
|
+
_global__WEBPACK_IMPORTED_MODULE_1__["sdk"].isDarkmode && (this._els = []);
|
|
3088
3443
|
} else {
|
|
3089
3444
|
// 如果没有节点
|
|
3090
3445
|
if (this._delayEls.length) {
|
|
@@ -3142,27 +3497,27 @@ var DomUtils = /*#__PURE__*/function () {
|
|
|
3142
3497
|
this._firstPageEls = [];
|
|
3143
3498
|
}
|
|
3144
3499
|
}]);
|
|
3500
|
+
return DomUtils;
|
|
3145
3501
|
}();
|
|
3146
3502
|
;
|
|
3147
3503
|
|
|
3148
|
-
/***/ },
|
|
3504
|
+
/***/ }),
|
|
3149
3505
|
|
|
3150
|
-
/***/ "./src/modules/global.js"
|
|
3506
|
+
/***/ "./src/modules/global.js":
|
|
3151
3507
|
/*!*******************************!*\
|
|
3152
3508
|
!*** ./src/modules/global.js ***!
|
|
3153
3509
|
\*******************************/
|
|
3154
|
-
|
|
3510
|
+
/*! exports provided: plugins, tnQueue, bgStack, cssUtils, domUtils, sdk */
|
|
3511
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
3155
3512
|
|
|
3156
3513
|
"use strict";
|
|
3157
3514
|
__webpack_require__.r(__webpack_exports__);
|
|
3158
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3159
|
-
/* harmony export */
|
|
3160
|
-
/* harmony export */
|
|
3161
|
-
/* harmony export */
|
|
3162
|
-
/* harmony export */
|
|
3163
|
-
/* harmony export */
|
|
3164
|
-
/* harmony export */ tnQueue: () => (/* binding */ tnQueue)
|
|
3165
|
-
/* harmony export */ });
|
|
3515
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "plugins", function() { return plugins; });
|
|
3516
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tnQueue", function() { return tnQueue; });
|
|
3517
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bgStack", function() { return bgStack; });
|
|
3518
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cssUtils", function() { return cssUtils; });
|
|
3519
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "domUtils", function() { return domUtils; });
|
|
3520
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sdk", function() { return sdk; });
|
|
3166
3521
|
/* harmony import */ var _constant__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constant */ "./src/modules/constant.js");
|
|
3167
3522
|
/* harmony import */ var _plugins__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./plugins */ "./src/modules/plugins.js");
|
|
3168
3523
|
/* harmony import */ var _textNodeQueue__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textNodeQueue */ "./src/modules/textNodeQueue.js");
|
|
@@ -3184,11 +3539,11 @@ var plugins = new _plugins__WEBPACK_IMPORTED_MODULE_1__["default"]();
|
|
|
3184
3539
|
|
|
3185
3540
|
// 文本节点队列
|
|
3186
3541
|
|
|
3187
|
-
var tnQueue = new _textNodeQueue__WEBPACK_IMPORTED_MODULE_2__["default"]("".concat(_constant__WEBPACK_IMPORTED_MODULE_0__
|
|
3542
|
+
var tnQueue = new _textNodeQueue__WEBPACK_IMPORTED_MODULE_2__["default"]("".concat(_constant__WEBPACK_IMPORTED_MODULE_0__["CLASS_PREFIX"], "text__"));
|
|
3188
3543
|
|
|
3189
3544
|
// 需要判断位置的背景节点堆栈
|
|
3190
3545
|
|
|
3191
|
-
var bgStack = new _bgNodeStack__WEBPACK_IMPORTED_MODULE_3__["default"]("".concat(_constant__WEBPACK_IMPORTED_MODULE_0__
|
|
3546
|
+
var bgStack = new _bgNodeStack__WEBPACK_IMPORTED_MODULE_3__["default"]("".concat(_constant__WEBPACK_IMPORTED_MODULE_0__["CLASS_PREFIX"], "bg__"));
|
|
3192
3547
|
|
|
3193
3548
|
// 样式相关操作工具对象
|
|
3194
3549
|
|
|
@@ -3196,33 +3551,29 @@ var cssUtils = new _cssUtils__WEBPACK_IMPORTED_MODULE_4__["default"]();
|
|
|
3196
3551
|
|
|
3197
3552
|
// 节点相关操作工具对象
|
|
3198
3553
|
|
|
3199
|
-
var domUtils = new _domUtils__WEBPACK_IMPORTED_MODULE_5__
|
|
3554
|
+
var domUtils = new _domUtils__WEBPACK_IMPORTED_MODULE_5__["DomUtils"]();
|
|
3200
3555
|
|
|
3201
3556
|
// sdk
|
|
3202
3557
|
|
|
3203
3558
|
var sdk = new _sdk__WEBPACK_IMPORTED_MODULE_6__["default"]();
|
|
3204
3559
|
|
|
3205
|
-
/***/ },
|
|
3560
|
+
/***/ }),
|
|
3206
3561
|
|
|
3207
|
-
/***/ "./src/modules/plugins.js"
|
|
3562
|
+
/***/ "./src/modules/plugins.js":
|
|
3208
3563
|
/*!********************************!*\
|
|
3209
3564
|
!*** ./src/modules/plugins.js ***!
|
|
3210
3565
|
\********************************/
|
|
3211
|
-
|
|
3566
|
+
/*! exports provided: default */
|
|
3567
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
3212
3568
|
|
|
3213
3569
|
"use strict";
|
|
3214
3570
|
__webpack_require__.r(__webpack_exports__);
|
|
3215
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3216
|
-
/* harmony export */ "default": () => (/* binding */ Plugins)
|
|
3217
|
-
/* harmony export */ });
|
|
3571
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Plugins; });
|
|
3218
3572
|
/* harmony import */ var _global__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./global */ "./src/modules/global.js");
|
|
3219
|
-
function _defineProperty(
|
|
3220
|
-
function
|
|
3221
|
-
function
|
|
3222
|
-
function
|
|
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); }
|
|
3573
|
+
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; }
|
|
3574
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3575
|
+
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); } }
|
|
3576
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
3226
3577
|
/**
|
|
3227
3578
|
* @name 插件基类
|
|
3228
3579
|
*
|
|
@@ -3249,17 +3600,17 @@ var Plugin = /*#__PURE__*/function () {
|
|
|
3249
3600
|
}
|
|
3250
3601
|
|
|
3251
3602
|
// 遍历次数(全部节点遍历结束算一次)
|
|
3252
|
-
|
|
3603
|
+
_createClass(Plugin, [{
|
|
3253
3604
|
key: "loopTimes",
|
|
3254
3605
|
get: function get() {
|
|
3255
|
-
return _global__WEBPACK_IMPORTED_MODULE_0__
|
|
3606
|
+
return _global__WEBPACK_IMPORTED_MODULE_0__["plugins"].loopTimes;
|
|
3256
3607
|
}
|
|
3257
3608
|
|
|
3258
3609
|
// 是否为Dark Mode
|
|
3259
3610
|
}, {
|
|
3260
3611
|
key: "isDarkmode",
|
|
3261
3612
|
get: function get() {
|
|
3262
|
-
return _global__WEBPACK_IMPORTED_MODULE_0__
|
|
3613
|
+
return _global__WEBPACK_IMPORTED_MODULE_0__["sdk"].isDarkmode;
|
|
3263
3614
|
}
|
|
3264
3615
|
|
|
3265
3616
|
// 添加样式
|
|
@@ -3267,13 +3618,14 @@ var Plugin = /*#__PURE__*/function () {
|
|
|
3267
3618
|
key: "addCss",
|
|
3268
3619
|
value: function addCss(className, kvList) {
|
|
3269
3620
|
var needMediaQuery = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
3270
|
-
(needMediaQuery ? cssNeedMQ : cssNoMQ).push(_global__WEBPACK_IMPORTED_MODULE_0__
|
|
3621
|
+
(needMediaQuery ? cssNeedMQ : cssNoMQ).push(_global__WEBPACK_IMPORTED_MODULE_0__["cssUtils"].genCss(className, kvList.map(function (_ref) {
|
|
3271
3622
|
var key = _ref.key,
|
|
3272
3623
|
value = _ref.value;
|
|
3273
|
-
return _global__WEBPACK_IMPORTED_MODULE_0__
|
|
3624
|
+
return _global__WEBPACK_IMPORTED_MODULE_0__["cssUtils"].genCssKV(key, value);
|
|
3274
3625
|
}).join('')));
|
|
3275
3626
|
}
|
|
3276
3627
|
}]);
|
|
3628
|
+
return Plugin;
|
|
3277
3629
|
}();
|
|
3278
3630
|
/**
|
|
3279
3631
|
* @name 插件系统
|
|
@@ -3305,27 +3657,28 @@ var Plugin = /*#__PURE__*/function () {
|
|
|
3305
3657
|
*
|
|
3306
3658
|
*/
|
|
3307
3659
|
var Plugins = /*#__PURE__*/function () {
|
|
3660
|
+
// 已挂载的插件列表
|
|
3661
|
+
|
|
3662
|
+
// 已挂载的插件数量
|
|
3663
|
+
// 已遍历次数(全部节点遍历结束算一次)
|
|
3664
|
+
// 首屏样式
|
|
3665
|
+
// 非首屏样式
|
|
3666
|
+
// 首屏样式(不需要加媒体查询)
|
|
3308
3667
|
// 非首屏样式(不需要加媒体查询)
|
|
3309
3668
|
|
|
3310
3669
|
function Plugins() {
|
|
3311
3670
|
_classCallCheck(this, Plugins);
|
|
3312
3671
|
_defineProperty(this, "_plugins", []);
|
|
3313
|
-
// 已挂载的插件列表
|
|
3314
3672
|
_defineProperty(this, "length", 0);
|
|
3315
|
-
// 已挂载的插件数量
|
|
3316
3673
|
_defineProperty(this, "loopTimes", 0);
|
|
3317
|
-
// 已遍历次数(全部节点遍历结束算一次)
|
|
3318
3674
|
_defineProperty(this, "firstPageStyle", '');
|
|
3319
|
-
// 首屏样式
|
|
3320
3675
|
_defineProperty(this, "otherPageStyle", '');
|
|
3321
|
-
// 非首屏样式
|
|
3322
3676
|
_defineProperty(this, "firstPageStyleNoMQ", '');
|
|
3323
|
-
// 首屏样式(不需要加媒体查询)
|
|
3324
3677
|
_defineProperty(this, "otherPageStyleNoMQ", '');
|
|
3325
3678
|
}
|
|
3326
3679
|
|
|
3327
3680
|
// 挂载插件
|
|
3328
|
-
|
|
3681
|
+
_createClass(Plugins, [{
|
|
3329
3682
|
key: "extend",
|
|
3330
3683
|
value: function extend(plugin) {
|
|
3331
3684
|
this._plugins.push(new (plugin(Plugin))());
|
|
@@ -3365,23 +3718,23 @@ var Plugins = /*#__PURE__*/function () {
|
|
|
3365
3718
|
cssNoMQ = [];
|
|
3366
3719
|
}
|
|
3367
3720
|
}]);
|
|
3721
|
+
return Plugins;
|
|
3368
3722
|
}();
|
|
3369
3723
|
|
|
3370
3724
|
;
|
|
3371
3725
|
|
|
3372
|
-
/***/ },
|
|
3726
|
+
/***/ }),
|
|
3373
3727
|
|
|
3374
|
-
/***/ "./src/modules/sdk.js"
|
|
3728
|
+
/***/ "./src/modules/sdk.js":
|
|
3375
3729
|
/*!****************************!*\
|
|
3376
3730
|
!*** ./src/modules/sdk.js ***!
|
|
3377
3731
|
\****************************/
|
|
3378
|
-
|
|
3732
|
+
/*! exports provided: default */
|
|
3733
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
3379
3734
|
|
|
3380
3735
|
"use strict";
|
|
3381
3736
|
__webpack_require__.r(__webpack_exports__);
|
|
3382
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3383
|
-
/* harmony export */ "default": () => (/* binding */ SDK)
|
|
3384
|
-
/* harmony export */ });
|
|
3737
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return SDK; });
|
|
3385
3738
|
/* harmony import */ var color__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! color */ "./node_modules/color/index.js");
|
|
3386
3739
|
/* harmony import */ var color__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(color__WEBPACK_IMPORTED_MODULE_0__);
|
|
3387
3740
|
/* harmony import */ var _color__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./color */ "./src/modules/color.js");
|
|
@@ -3389,23 +3742,20 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3389
3742
|
/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./config */ "./src/modules/config.js");
|
|
3390
3743
|
/* harmony import */ var _global__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./global */ "./src/modules/global.js");
|
|
3391
3744
|
/* harmony import */ var _domUtils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./domUtils */ "./src/modules/domUtils.js");
|
|
3392
|
-
function
|
|
3393
|
-
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
3745
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3394
3746
|
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."); }
|
|
3395
|
-
function _iterableToArrayLimit(
|
|
3396
|
-
function _arrayWithHoles(
|
|
3397
|
-
function _toConsumableArray(
|
|
3747
|
+
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; }
|
|
3748
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
3749
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3398
3750
|
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."); }
|
|
3399
|
-
function _unsupportedIterableToArray(
|
|
3400
|
-
function _iterableToArray(
|
|
3401
|
-
function _arrayWithoutHoles(
|
|
3402
|
-
function _arrayLikeToArray(
|
|
3403
|
-
function _classCallCheck(
|
|
3404
|
-
function _defineProperties(
|
|
3405
|
-
function _createClass(
|
|
3406
|
-
function _defineProperty(
|
|
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); }
|
|
3751
|
+
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); }
|
|
3752
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
3753
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
3754
|
+
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; }
|
|
3755
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3756
|
+
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); } }
|
|
3757
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
3758
|
+
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; }
|
|
3409
3759
|
/**
|
|
3410
3760
|
* @name 算法SDK
|
|
3411
3761
|
*
|
|
@@ -3441,12 +3791,13 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
3441
3791
|
// 节点相关操作工具API
|
|
3442
3792
|
|
|
3443
3793
|
var SDK = /*#__PURE__*/function () {
|
|
3794
|
+
// 索引值
|
|
3795
|
+
|
|
3444
3796
|
// 当前是否需要运行Darkmode处理
|
|
3445
3797
|
|
|
3446
3798
|
function SDK() {
|
|
3447
3799
|
_classCallCheck(this, SDK);
|
|
3448
3800
|
_defineProperty(this, "_idx", 0);
|
|
3449
|
-
// 索引值
|
|
3450
3801
|
_defineProperty(this, "_defaultDarkTextColorRgb", null);
|
|
3451
3802
|
_defineProperty(this, "_defaultDarkBgColorRgb", null);
|
|
3452
3803
|
_defineProperty(this, "_defaultDarkBgColorHSL", null);
|
|
@@ -3458,7 +3809,7 @@ var SDK = /*#__PURE__*/function () {
|
|
|
3458
3809
|
}
|
|
3459
3810
|
|
|
3460
3811
|
// 调整明度
|
|
3461
|
-
|
|
3812
|
+
_createClass(SDK, [{
|
|
3462
3813
|
key: "_adjustBrightness",
|
|
3463
3814
|
value: function _adjustBrightness(color, el, options, isUpdate, needReset) {
|
|
3464
3815
|
// 背景:
|
|
@@ -3480,17 +3831,17 @@ var SDK = /*#__PURE__*/function () {
|
|
|
3480
3831
|
var extStyle = '';
|
|
3481
3832
|
if (options.isBgColor) {
|
|
3482
3833
|
// 背景色
|
|
3483
|
-
if (alpha >= _constant__WEBPACK_IMPORTED_MODULE_2__
|
|
3834
|
+
if (alpha >= _constant__WEBPACK_IMPORTED_MODULE_2__["IGNORE_ALPHA"]) {
|
|
3484
3835
|
// 如果设置背景颜色,取消背景图片的影响
|
|
3485
|
-
if (el[_constant__WEBPACK_IMPORTED_MODULE_2__
|
|
3836
|
+
if (el[_constant__WEBPACK_IMPORTED_MODULE_2__["BGIMAGEATTR"]]) delete el[_constant__WEBPACK_IMPORTED_MODULE_2__["BGIMAGEATTR"]];
|
|
3486
3837
|
|
|
3487
3838
|
// 如果有背景图片补色
|
|
3488
|
-
if (el[_constant__WEBPACK_IMPORTED_MODULE_2__
|
|
3839
|
+
if (el[_constant__WEBPACK_IMPORTED_MODULE_2__["COMPLEMENTARY_BGIMAGECOLORATTR"]]) {
|
|
3489
3840
|
// 背景图片补色和当前背景色一致,则无需处理
|
|
3490
3841
|
// 根据最小可觉差Just-noticeable difference(即JND,表示人类或动物对于某一特定的感官刺激所能察觉的最小改变)和韦伯-费希纳定律,在特定条件下,人类能感知小至 0.5% - 2% 的变化,0.5%换算成对比度为1.1
|
|
3491
3842
|
// https://zh.wikipedia.org/wiki/%E6%9C%80%E5%B0%8F%E5%8F%AF%E8%A6%BA%E5%B7%AE 最小可觉差wiki
|
|
3492
3843
|
// 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
|
|
3493
|
-
if (el[_constant__WEBPACK_IMPORTED_MODULE_2__
|
|
3844
|
+
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
3845
|
return {
|
|
3495
3846
|
newColor: needReset ? color.toString() : '',
|
|
3496
3847
|
extStyle: extStyle
|
|
@@ -3498,34 +3849,34 @@ var SDK = /*#__PURE__*/function () {
|
|
|
3498
3849
|
}
|
|
3499
3850
|
|
|
3500
3851
|
// 否则取消背景图片补色的影响
|
|
3501
|
-
(
|
|
3502
|
-
delete dom[_constant__WEBPACK_IMPORTED_MODULE_2__
|
|
3852
|
+
Object(_domUtils__WEBPACK_IMPORTED_MODULE_5__["getChildrenAndIt"])(el).forEach(function (dom) {
|
|
3853
|
+
delete dom[_constant__WEBPACK_IMPORTED_MODULE_2__["COMPLEMENTARY_BGIMAGECOLORATTR"]];
|
|
3503
3854
|
});
|
|
3504
3855
|
}
|
|
3505
3856
|
}
|
|
3506
3857
|
newColor = this._adjustBackgroundBrightness(color);
|
|
3507
3858
|
if (!options.hasInlineColor) {
|
|
3508
|
-
var parentTextColorStr = el[_constant__WEBPACK_IMPORTED_MODULE_2__
|
|
3509
|
-
var parentTextColor = (
|
|
3859
|
+
var parentTextColorStr = el[_constant__WEBPACK_IMPORTED_MODULE_2__["ORIGINAL_COLORATTR"]] || _config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultLightTextColor;
|
|
3860
|
+
var parentTextColor = Object(_color__WEBPACK_IMPORTED_MODULE_1__["ColorParser"])(parentTextColorStr);
|
|
3510
3861
|
if (parentTextColor) {
|
|
3511
3862
|
var ret = this._adjustBrightness(parentTextColor, el, {
|
|
3512
3863
|
isTextColor: true,
|
|
3513
3864
|
parentElementBgColorStr: newColor || color
|
|
3514
3865
|
}, isUpdate, needReset);
|
|
3515
3866
|
if (ret.newColor) {
|
|
3516
|
-
extStyle += _global__WEBPACK_IMPORTED_MODULE_4__
|
|
3867
|
+
extStyle += _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCssKV('color', ret.newColor);
|
|
3517
3868
|
} else {
|
|
3518
|
-
extStyle += _global__WEBPACK_IMPORTED_MODULE_4__
|
|
3869
|
+
extStyle += _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCssKV('color', parentTextColor);
|
|
3519
3870
|
}
|
|
3520
3871
|
}
|
|
3521
3872
|
}
|
|
3522
3873
|
} else if (options.isTextColor || options.isBorderColor) {
|
|
3523
3874
|
// 字体色、边框色
|
|
3524
|
-
var parentElementBgColorStr = options.parentElementBgColorStr || options.isTextColor && el[_constant__WEBPACK_IMPORTED_MODULE_2__
|
|
3525
|
-
var parentElementBgColor = (
|
|
3875
|
+
var parentElementBgColorStr = options.parentElementBgColorStr || options.isTextColor && el[_constant__WEBPACK_IMPORTED_MODULE_2__["BGCOLORATTR"]] || _config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultDarkBgColor;
|
|
3876
|
+
var parentElementBgColor = Object(_color__WEBPACK_IMPORTED_MODULE_1__["ColorParser"])(parentElementBgColorStr);
|
|
3526
3877
|
|
|
3527
3878
|
// 无背景图片
|
|
3528
|
-
if (parentElementBgColor && !el[_constant__WEBPACK_IMPORTED_MODULE_2__
|
|
3879
|
+
if (parentElementBgColor && !el[_constant__WEBPACK_IMPORTED_MODULE_2__["BGIMAGEATTR"]]) {
|
|
3529
3880
|
newColor = this._adjustTextBrightness(color, parentElementBgColor);
|
|
3530
3881
|
var emitNameSuffix = '';
|
|
3531
3882
|
if (isUpdate) {
|
|
@@ -3533,7 +3884,7 @@ var SDK = /*#__PURE__*/function () {
|
|
|
3533
3884
|
} else if (needReset) {
|
|
3534
3885
|
emitNameSuffix = 'ByReset';
|
|
3535
3886
|
}
|
|
3536
|
-
_global__WEBPACK_IMPORTED_MODULE_4__
|
|
3887
|
+
_global__WEBPACK_IMPORTED_MODULE_4__["plugins"].emit("afterConvertTextColor".concat(emitNameSuffix), el, {
|
|
3537
3888
|
// fontColor: color,
|
|
3538
3889
|
fontColor: newColor,
|
|
3539
3890
|
bgColor: parentElementBgColor
|
|
@@ -3542,10 +3893,11 @@ var SDK = /*#__PURE__*/function () {
|
|
|
3542
3893
|
} else if (options.isTextShadow) {
|
|
3543
3894
|
// 字体阴影
|
|
3544
3895
|
// 无背景图片
|
|
3545
|
-
if (!el[_constant__WEBPACK_IMPORTED_MODULE_2__
|
|
3896
|
+
if (!el[_constant__WEBPACK_IMPORTED_MODULE_2__["BGIMAGEATTR"]]) {
|
|
3546
3897
|
newColor = this._adjustBackgroundBrightness(color); // 按照背景色的方法来处理
|
|
3547
3898
|
}
|
|
3548
3899
|
}
|
|
3900
|
+
|
|
3549
3901
|
return {
|
|
3550
3902
|
newColor: newColor && color.toString() !== newColor.toString() && newColor.alpha(alpha).rgb(),
|
|
3551
3903
|
extStyle: extStyle
|
|
@@ -3558,40 +3910,40 @@ var SDK = /*#__PURE__*/function () {
|
|
|
3558
3910
|
value: function _adjustTextBrightness(textColor, bgColor) {
|
|
3559
3911
|
var bgColorRgb = bgColor.rgb().array();
|
|
3560
3912
|
var bgColorAlpha = bgColor.alpha();
|
|
3561
|
-
var bgColorPerceivedBrightness = (
|
|
3913
|
+
var bgColorPerceivedBrightness = Object(_color__WEBPACK_IMPORTED_MODULE_1__["getColorPerceivedBrightness"])(bgColorRgb);
|
|
3562
3914
|
var bgColorWithOpacityPerceivedBrightness = bgColorPerceivedBrightness * bgColorAlpha + this._defaultDarkBgColorBrightness * (1 - bgColorAlpha);
|
|
3563
3915
|
var textColorRgb = textColor.rgb().array();
|
|
3564
3916
|
var textColorHSL = textColor.hsl().array();
|
|
3565
3917
|
var textColorAlpha = textColor.alpha();
|
|
3566
|
-
var textPerceivedBrightness = (
|
|
3918
|
+
var textPerceivedBrightness = Object(_color__WEBPACK_IMPORTED_MODULE_1__["getColorPerceivedBrightness"])(textColorRgb);
|
|
3567
3919
|
var offsetPerceivedBrightness = Math.abs(bgColorWithOpacityPerceivedBrightness - textPerceivedBrightness);
|
|
3568
3920
|
|
|
3569
3921
|
// 用户设置为高亮字体颜色(接近白色亮度),不处理,保持高亮
|
|
3570
|
-
if (textPerceivedBrightness >= _constant__WEBPACK_IMPORTED_MODULE_2__
|
|
3922
|
+
if (textPerceivedBrightness >= _constant__WEBPACK_IMPORTED_MODULE_2__["WHITE_LIKE_COLOR_BRIGHTNESS"]) return textColor;
|
|
3571
3923
|
if (offsetPerceivedBrightness > this._maxLimitOffsetBrightness && bgColorWithOpacityPerceivedBrightness <= this._defaultDarkBgColorBrightness + 2) {
|
|
3572
|
-
return (
|
|
3924
|
+
return Object(_color__WEBPACK_IMPORTED_MODULE_1__["adjustBrightnessTo"])(this._maxLimitOffsetBrightness + bgColorWithOpacityPerceivedBrightness, textColorRgb).alpha(textColorAlpha);
|
|
3573
3925
|
}
|
|
3574
3926
|
|
|
3575
3927
|
// 如果感知亮度差大于阈值,无需调整
|
|
3576
|
-
if (offsetPerceivedBrightness >= _constant__WEBPACK_IMPORTED_MODULE_2__
|
|
3577
|
-
if (bgColorWithOpacityPerceivedBrightness >= _constant__WEBPACK_IMPORTED_MODULE_2__
|
|
3928
|
+
if (offsetPerceivedBrightness >= _constant__WEBPACK_IMPORTED_MODULE_2__["MIN_LIMIT_OFFSET_BRIGHTNESS"]) return textColor;
|
|
3929
|
+
if (bgColorWithOpacityPerceivedBrightness >= _constant__WEBPACK_IMPORTED_MODULE_2__["HIGH_BGCOLOR_BRIGHTNESS"]) {
|
|
3578
3930
|
// 亮背景,调暗字体
|
|
3579
|
-
if (textColorHSL[2] > 90 - _constant__WEBPACK_IMPORTED_MODULE_2__
|
|
3931
|
+
if (textColorHSL[2] > 90 - _constant__WEBPACK_IMPORTED_MODULE_2__["HIGH_BLACKWHITE_HSL_BRIGHTNESS"]) {
|
|
3580
3932
|
// 优先调字体的亮度已带到降低感知亮度的目的
|
|
3581
3933
|
textColorHSL[2] = 90 - textColorHSL[2];
|
|
3582
|
-
var tmpTextColor = color__WEBPACK_IMPORTED_MODULE_0___default
|
|
3934
|
+
var tmpTextColor = color__WEBPACK_IMPORTED_MODULE_0___default.a.hsl.apply(color__WEBPACK_IMPORTED_MODULE_0___default.a, _toConsumableArray(textColorHSL)).alpha(textColorAlpha);
|
|
3583
3935
|
return this._adjustTextBrightness(tmpTextColor, bgColor);
|
|
3584
3936
|
}
|
|
3585
|
-
return (
|
|
3937
|
+
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);
|
|
3586
3938
|
} else {
|
|
3587
3939
|
// 暗背景,调亮字体
|
|
3588
|
-
if (textColorHSL[2] <= _constant__WEBPACK_IMPORTED_MODULE_2__
|
|
3940
|
+
if (textColorHSL[2] <= _constant__WEBPACK_IMPORTED_MODULE_2__["HIGH_BLACKWHITE_HSL_BRIGHTNESS"]) {
|
|
3589
3941
|
// 优先调字体的亮度已带到提高感知亮度的目的
|
|
3590
3942
|
textColorHSL[2] = 90 - textColorHSL[2];
|
|
3591
|
-
var _tmpTextColor = color__WEBPACK_IMPORTED_MODULE_0___default
|
|
3943
|
+
var _tmpTextColor = color__WEBPACK_IMPORTED_MODULE_0___default.a.hsl.apply(color__WEBPACK_IMPORTED_MODULE_0___default.a, _toConsumableArray(textColorHSL)).alpha(textColorAlpha);
|
|
3592
3944
|
return this._adjustTextBrightness(_tmpTextColor, bgColor);
|
|
3593
3945
|
}
|
|
3594
|
-
return (
|
|
3946
|
+
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);
|
|
3595
3947
|
}
|
|
3596
3948
|
}
|
|
3597
3949
|
|
|
@@ -3602,21 +3954,21 @@ var SDK = /*#__PURE__*/function () {
|
|
|
3602
3954
|
var bgColorRgb = bgColor.rgb().array();
|
|
3603
3955
|
var bgColorHsl = bgColor.hsl().array();
|
|
3604
3956
|
var bgColorAlpha = bgColor.alpha();
|
|
3605
|
-
var bgColorPerceivedBrightness = (
|
|
3957
|
+
var bgColorPerceivedBrightness = Object(_color__WEBPACK_IMPORTED_MODULE_1__["getColorPerceivedBrightness"])(bgColorRgb);
|
|
3606
3958
|
var newColor = bgColor;
|
|
3607
|
-
if (bgColorHsl[1] === 0 && bgColorHsl[2] > _constant__WEBPACK_IMPORTED_MODULE_2__
|
|
3959
|
+
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"]) {
|
|
3608
3960
|
// 饱和度为0(黑白灰色),亮度大于HIGH_BLACKWHITE_HSL_BRIGHTNESS或感知亮度大于WHITE_LIKE_COLOR_BRIGHTNESS(白色)时,做亮度取反处理
|
|
3609
|
-
newColor = color__WEBPACK_IMPORTED_MODULE_0___default
|
|
3610
|
-
} else if (bgColorPerceivedBrightness > _constant__WEBPACK_IMPORTED_MODULE_2__
|
|
3961
|
+
newColor = color__WEBPACK_IMPORTED_MODULE_0___default.a.hsl(0, 0, Math.min(100, 100 + this._defaultDarkBgColorHslBrightness - bgColorHsl[2]));
|
|
3962
|
+
} else if (bgColorPerceivedBrightness > _constant__WEBPACK_IMPORTED_MODULE_2__["MAX_LIMIT_BGCOLOR_BRIGHTNESS"]) {
|
|
3611
3963
|
// 感知亮度大于MAX_LIMIT_BGCOLOR_BRIGHTNESS,将感知亮度设为MAX_LIMIT_BGCOLOR_BRIGHTNESS
|
|
3612
|
-
newColor = (
|
|
3964
|
+
newColor = Object(_color__WEBPACK_IMPORTED_MODULE_1__["adjustBrightnessTo"])(_constant__WEBPACK_IMPORTED_MODULE_2__["MAX_LIMIT_BGCOLOR_BRIGHTNESS"], bgColorRgb).alpha(bgColorAlpha);
|
|
3613
3965
|
// const ratio = (MAX_LIMIT_BGCOLOR_BRIGHTNESS * 1000)
|
|
3614
3966
|
// / (bgColorRgb[0] * 299 + bgColorRgb[1] * 587 + bgColorRgb[2] * 114);
|
|
3615
3967
|
// newColor = Color.rgb(bgColorRgb[0] * ratio, bgColorRgb[1] * ratio, bgColorRgb[2] * ratio);
|
|
3616
|
-
} else if (bgColorHsl[2] < _constant__WEBPACK_IMPORTED_MODULE_2__
|
|
3968
|
+
} else if (bgColorHsl[2] < _constant__WEBPACK_IMPORTED_MODULE_2__["LOW_BLACKWHITE_HSL_BRIGHTNESS"]) {
|
|
3617
3969
|
// 亮度小于LOW_BLACKWHITE_HSL_BRIGHTNESS,将亮度设为LOW_BLACKWHITE_HSL_BRIGHTNESS,适当提高亮度
|
|
3618
|
-
bgColorHsl[2] = _constant__WEBPACK_IMPORTED_MODULE_2__
|
|
3619
|
-
newColor = color__WEBPACK_IMPORTED_MODULE_0___default
|
|
3970
|
+
bgColorHsl[2] = _constant__WEBPACK_IMPORTED_MODULE_2__["LOW_BLACKWHITE_HSL_BRIGHTNESS"];
|
|
3971
|
+
newColor = color__WEBPACK_IMPORTED_MODULE_0___default.a.hsl.apply(color__WEBPACK_IMPORTED_MODULE_0___default.a, _toConsumableArray(bgColorHsl));
|
|
3620
3972
|
}
|
|
3621
3973
|
return newColor.alpha(bgColorAlpha).rgb();
|
|
3622
3974
|
}
|
|
@@ -3625,22 +3977,22 @@ var SDK = /*#__PURE__*/function () {
|
|
|
3625
3977
|
}, {
|
|
3626
3978
|
key: "_updateBgWithGradient",
|
|
3627
3979
|
value: function _updateBgWithGradient(gradientColor, el, className, cssKVList, hasInlineColor, isUpdate, needReset) {
|
|
3628
|
-
var newBgColor = (
|
|
3629
|
-
var newOriginalBgColor = (el[_constant__WEBPACK_IMPORTED_MODULE_2__
|
|
3630
|
-
(
|
|
3631
|
-
dom[_constant__WEBPACK_IMPORTED_MODULE_2__
|
|
3632
|
-
dom[_constant__WEBPACK_IMPORTED_MODULE_2__
|
|
3980
|
+
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');
|
|
3981
|
+
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"]);
|
|
3982
|
+
Object(_domUtils__WEBPACK_IMPORTED_MODULE_5__["getChildrenAndIt"])(el).forEach(function (dom) {
|
|
3983
|
+
dom[_constant__WEBPACK_IMPORTED_MODULE_2__["BGCOLORATTR"]] = newBgColor;
|
|
3984
|
+
dom[_constant__WEBPACK_IMPORTED_MODULE_2__["ORIGINAL_BGCOLORATTR"]] = newOriginalBgColor;
|
|
3633
3985
|
});
|
|
3634
3986
|
var lastKV = cssKVList.slice(-1)[0];
|
|
3635
3987
|
if (lastKV[0] === 'color') {
|
|
3636
|
-
var ret = this._adjustBrightness((
|
|
3988
|
+
var ret = this._adjustBrightness(Object(_color__WEBPACK_IMPORTED_MODULE_1__["ColorParser"])(Object(_color__WEBPACK_IMPORTED_MODULE_1__["parseColorName"])(lastKV[1])), el, {
|
|
3637
3989
|
isBgColor: false,
|
|
3638
3990
|
isTextShadow: false,
|
|
3639
3991
|
isTextColor: true,
|
|
3640
3992
|
isBorderColor: false,
|
|
3641
3993
|
hasInlineColor: hasInlineColor
|
|
3642
3994
|
}, isUpdate, needReset);
|
|
3643
|
-
if (ret.newColor) return _global__WEBPACK_IMPORTED_MODULE_4__
|
|
3995
|
+
if (ret.newColor) return _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCss(className, _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCssKV('color', ret.newColor));
|
|
3644
3996
|
}
|
|
3645
3997
|
return '';
|
|
3646
3998
|
}
|
|
@@ -3659,11 +4011,11 @@ var SDK = /*#__PURE__*/function () {
|
|
|
3659
4011
|
}, {
|
|
3660
4012
|
key: "init",
|
|
3661
4013
|
value: function init() {
|
|
3662
|
-
this._defaultDarkTextColorRgb = (
|
|
3663
|
-
this._defaultDarkBgColorRgb = (
|
|
3664
|
-
this._defaultDarkBgColorHSL = (
|
|
3665
|
-
this._defaultDarkTextColorBrightness = (
|
|
3666
|
-
this._defaultDarkBgColorBrightness = (
|
|
4014
|
+
this._defaultDarkTextColorRgb = Object(_color__WEBPACK_IMPORTED_MODULE_1__["ColorParser"])(_config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultDarkTextColor).rgb().array();
|
|
4015
|
+
this._defaultDarkBgColorRgb = Object(_color__WEBPACK_IMPORTED_MODULE_1__["ColorParser"])(_config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultDarkBgColor).rgb().array();
|
|
4016
|
+
this._defaultDarkBgColorHSL = Object(_color__WEBPACK_IMPORTED_MODULE_1__["ColorParser"])(_config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultDarkBgColor).hsl().array();
|
|
4017
|
+
this._defaultDarkTextColorBrightness = Object(_color__WEBPACK_IMPORTED_MODULE_1__["getColorPerceivedBrightness"])(this._defaultDarkTextColorRgb);
|
|
4018
|
+
this._defaultDarkBgColorBrightness = Object(_color__WEBPACK_IMPORTED_MODULE_1__["getColorPerceivedBrightness"])(this._defaultDarkBgColorRgb);
|
|
3667
4019
|
this._defaultDarkBgColorHslBrightness = this._defaultDarkBgColorHSL[2];
|
|
3668
4020
|
this._maxLimitOffsetBrightness = this._defaultDarkTextColorBrightness - this._defaultDarkBgColorBrightness;
|
|
3669
4021
|
}
|
|
@@ -3673,14 +4025,14 @@ var SDK = /*#__PURE__*/function () {
|
|
|
3673
4025
|
key: "convert",
|
|
3674
4026
|
value: function convert(el, cssKVList, isUpdate, needReset) {
|
|
3675
4027
|
var _this = this;
|
|
3676
|
-
_global__WEBPACK_IMPORTED_MODULE_4__
|
|
4028
|
+
_global__WEBPACK_IMPORTED_MODULE_4__["plugins"].resetCss();
|
|
3677
4029
|
var emitNameSuffix = '';
|
|
3678
4030
|
if (isUpdate) {
|
|
3679
4031
|
emitNameSuffix = 'ByUpdateStyle';
|
|
3680
4032
|
} else if (needReset) {
|
|
3681
4033
|
emitNameSuffix = 'ByReset';
|
|
3682
4034
|
}
|
|
3683
|
-
_global__WEBPACK_IMPORTED_MODULE_4__
|
|
4035
|
+
_global__WEBPACK_IMPORTED_MODULE_4__["plugins"].emit("beforeConvertNode".concat(emitNameSuffix), el);
|
|
3684
4036
|
var css = ''; // css
|
|
3685
4037
|
var bgCss = ''; // 文字底图css
|
|
3686
4038
|
|
|
@@ -3694,10 +4046,10 @@ var SDK = /*#__PURE__*/function () {
|
|
|
3694
4046
|
if (!cssKVList) {
|
|
3695
4047
|
// 没有传入cssKVList就从内联样式中提取
|
|
3696
4048
|
// styles.cssText 读出来的颜色统一是rgba格式,除了用英文定义颜色(如:black、white)
|
|
3697
|
-
cssKVList = (styles.cssText && styles.cssText.replace(/("[^;]*);([^;]*")|('[^;]*);([^;]*')/g, "$1$3".concat(_constant__WEBPACK_IMPORTED_MODULE_2__
|
|
4049
|
+
cssKVList = (styles.cssText && styles.cssText.replace(/("[^;]*);([^;]*")|('[^;]*);([^;]*')/g, "$1$3".concat(_constant__WEBPACK_IMPORTED_MODULE_2__["SEMICOLON_PLACEHOLDER"], "$2$4")).split(';') || []).map(function (cssStr) {
|
|
3698
4050
|
// 将cssStr转换为[key, value],并清除各个元素的前后空白字符
|
|
3699
4051
|
var splitIdx = cssStr.indexOf(':');
|
|
3700
|
-
return [cssStr.slice(0, splitIdx).toLowerCase(), cssStr.slice(splitIdx + 1).replace(_constant__WEBPACK_IMPORTED_MODULE_2__
|
|
4052
|
+
return [cssStr.slice(0, splitIdx).toLowerCase(), cssStr.slice(splitIdx + 1).replace(_constant__WEBPACK_IMPORTED_MODULE_2__["SEMICOLON_PLACEHOLDER_REGEXP"], ';')].map(function (item) {
|
|
3701
4053
|
return (item || '').replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
|
3702
4054
|
});
|
|
3703
4055
|
});
|
|
@@ -3726,7 +4078,7 @@ var SDK = /*#__PURE__*/function () {
|
|
|
3726
4078
|
}
|
|
3727
4079
|
|
|
3728
4080
|
// 过滤掉一些key
|
|
3729
|
-
return _constant__WEBPACK_IMPORTED_MODULE_2__
|
|
4081
|
+
return _constant__WEBPACK_IMPORTED_MODULE_2__["CSS_PROP_LIST"].indexOf(key) > -1;
|
|
3730
4082
|
}).sort(function (_ref3, _ref4) {
|
|
3731
4083
|
var _ref5 = _slicedToArray(_ref3, 1),
|
|
3732
4084
|
key1 = _ref5[0];
|
|
@@ -3744,14 +4096,14 @@ var SDK = /*#__PURE__*/function () {
|
|
|
3744
4096
|
}
|
|
3745
4097
|
return -1;
|
|
3746
4098
|
});
|
|
3747
|
-
if (_constant__WEBPACK_IMPORTED_MODULE_2__
|
|
4099
|
+
if (_constant__WEBPACK_IMPORTED_MODULE_2__["TABLE_NAME"].indexOf(nodeName) > -1 && !hasInlineBackground) {
|
|
3748
4100
|
// 如果table没有内联样式
|
|
3749
4101
|
this._try(function () {
|
|
3750
|
-
var colorStr = (
|
|
4102
|
+
var colorStr = Object(_domUtils__WEBPACK_IMPORTED_MODULE_5__["hasTableClass"])(el); // 获取class对应的lm色值
|
|
3751
4103
|
if (!colorStr) colorStr = el.getAttribute('bgcolor'); // 如果没有class则获取bgcolor的色值
|
|
3752
4104
|
if (colorStr) {
|
|
3753
4105
|
// 有色值(class对应的lm色值或者是bgcolor色值),则当做内联样式来处理
|
|
3754
|
-
var color = (
|
|
4106
|
+
var color = Object(_color__WEBPACK_IMPORTED_MODULE_1__["ColorParser"])(colorStr);
|
|
3755
4107
|
if (color) {
|
|
3756
4108
|
cssKVList.unshift(['background-color', color.toString()]);
|
|
3757
4109
|
hasInlineBackground = true;
|
|
@@ -3765,7 +4117,7 @@ var SDK = /*#__PURE__*/function () {
|
|
|
3765
4117
|
var colorStr = el.getAttribute('color'); // 获取color的色值
|
|
3766
4118
|
if (colorStr) {
|
|
3767
4119
|
// 有色值,则当做内联样式来处理
|
|
3768
|
-
var color = (
|
|
4120
|
+
var color = Object(_color__WEBPACK_IMPORTED_MODULE_1__["ColorParser"])(colorStr);
|
|
3769
4121
|
if (color) {
|
|
3770
4122
|
cssKVList.push(['color', color.toString()]);
|
|
3771
4123
|
hasInlineColor = true;
|
|
@@ -3788,25 +4140,27 @@ var SDK = /*#__PURE__*/function () {
|
|
|
3788
4140
|
webkitTextLen = idx; // 记录-webkit-text相关样式的长度
|
|
3789
4141
|
return true; // 结束遍历
|
|
3790
4142
|
}
|
|
4143
|
+
|
|
3791
4144
|
switch (key) {
|
|
3792
4145
|
case '-webkit-text-fill-color':
|
|
3793
|
-
webkitFillColor = (
|
|
4146
|
+
webkitFillColor = Object(_color__WEBPACK_IMPORTED_MODULE_1__["parseWebkitFillColorAndStrokeColor"])(value);
|
|
3794
4147
|
break;
|
|
3795
4148
|
case '-webkit-text-stroke':
|
|
3796
4149
|
{
|
|
3797
4150
|
// 有-webkit-text-stroke时就不会有-webkit-text-stroke-color
|
|
3798
4151
|
var newValue = value.split(' ');
|
|
3799
|
-
newValue.length === 2 && (webkitStrokeColor = (
|
|
4152
|
+
newValue.length === 2 && (webkitStrokeColor = Object(_color__WEBPACK_IMPORTED_MODULE_1__["parseWebkitFillColorAndStrokeColor"])(newValue[1]));
|
|
3800
4153
|
break;
|
|
3801
4154
|
}
|
|
3802
4155
|
case '-webkit-text-stroke-color':
|
|
3803
4156
|
// 有-webkit-text-stroke-color时就不会有-webkit-text-stroke
|
|
3804
|
-
webkitStrokeColor = (
|
|
4157
|
+
webkitStrokeColor = Object(_color__WEBPACK_IMPORTED_MODULE_1__["parseWebkitFillColorAndStrokeColor"])(value);
|
|
3805
4158
|
break;
|
|
3806
4159
|
}
|
|
3807
4160
|
return false; // 继续遍历
|
|
3808
4161
|
});
|
|
3809
4162
|
});
|
|
4163
|
+
|
|
3810
4164
|
if (webkitFillColor) {
|
|
3811
4165
|
// 有-webkit-text-fill-color,当做color对待
|
|
3812
4166
|
if (hasInlineColor) {
|
|
@@ -3822,69 +4176,70 @@ var SDK = /*#__PURE__*/function () {
|
|
|
3822
4176
|
cssKVList.splice(0, webkitTextLen); // 删掉-webkit-text相关样式
|
|
3823
4177
|
webkitStrokeColor && cssKVList.unshift(['-webkit-text-stroke-color', webkitStrokeColor]); // 如果有-webkit-text-stroke-color,则插入到最前面
|
|
3824
4178
|
}
|
|
4179
|
+
|
|
3825
4180
|
var dmClassName = '';
|
|
3826
4181
|
var dmBgClassName = '';
|
|
3827
4182
|
if ((isUpdate || needReset) && el.className && typeof el.className === 'string') {
|
|
3828
4183
|
// 先提取dm className
|
|
3829
|
-
var matches = el.className.match(_constant__WEBPACK_IMPORTED_MODULE_2__
|
|
4184
|
+
var matches = el.className.match(_constant__WEBPACK_IMPORTED_MODULE_2__["DM_CLASSNAME_REGEXP"]);
|
|
3830
4185
|
if (matches) {
|
|
3831
4186
|
dmClassName = matches[0];
|
|
3832
4187
|
}
|
|
3833
4188
|
|
|
3834
4189
|
// 再提取dm bg className
|
|
3835
|
-
matches = el.className.match(_global__WEBPACK_IMPORTED_MODULE_4__
|
|
4190
|
+
matches = el.className.match(_global__WEBPACK_IMPORTED_MODULE_4__["bgStack"].classNameReg);
|
|
3836
4191
|
if (matches) {
|
|
3837
4192
|
dmBgClassName = matches[0];
|
|
3838
4193
|
}
|
|
3839
4194
|
}
|
|
3840
4195
|
var cssKV = ''; // css键值对
|
|
3841
4196
|
var noColor = needReset;
|
|
3842
|
-
noColor && _global__WEBPACK_IMPORTED_MODULE_4__
|
|
4197
|
+
noColor && _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].watch('color', function () {
|
|
3843
4198
|
noColor = false;
|
|
3844
|
-
_global__WEBPACK_IMPORTED_MODULE_4__
|
|
4199
|
+
_global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].unwatch('color');
|
|
3845
4200
|
});
|
|
3846
4201
|
cssKVList.forEach(function (_ref9) {
|
|
3847
|
-
var
|
|
3848
|
-
key =
|
|
3849
|
-
value =
|
|
4202
|
+
var _ref10 = _slicedToArray(_ref9, 2),
|
|
4203
|
+
key = _ref10[0],
|
|
4204
|
+
value = _ref10[1];
|
|
3850
4205
|
return _this._try(function () {
|
|
3851
4206
|
var oldValue = value;
|
|
3852
4207
|
var cssChange = false;
|
|
3853
4208
|
|
|
3854
4209
|
// 找出色值来处理
|
|
3855
|
-
var isBgColor = _constant__WEBPACK_IMPORTED_MODULE_2__
|
|
3856
|
-
var isTextShadow = _constant__WEBPACK_IMPORTED_MODULE_2__
|
|
3857
|
-
var textColorIdx = _constant__WEBPACK_IMPORTED_MODULE_2__
|
|
3858
|
-
var isBorderColor = _constant__WEBPACK_IMPORTED_MODULE_2__
|
|
4210
|
+
var isBgColor = _constant__WEBPACK_IMPORTED_MODULE_2__["CSS_PROP_SERIES"].BG_COLOR.indexOf(key) > -1;
|
|
4211
|
+
var isTextShadow = _constant__WEBPACK_IMPORTED_MODULE_2__["CSS_PROP_SERIES"].TEXT_SHADOW.indexOf(key) > -1;
|
|
4212
|
+
var textColorIdx = _constant__WEBPACK_IMPORTED_MODULE_2__["CSS_PROP_SERIES"].TEXT_COLOR.indexOf(key);
|
|
4213
|
+
var isBorderColor = _constant__WEBPACK_IMPORTED_MODULE_2__["CSS_PROP_SERIES"].BORDER_COLOR.indexOf(key) > -1;
|
|
3859
4214
|
var isGradient = /gradient/.test(value);
|
|
3860
4215
|
var gradientColors = [];
|
|
3861
4216
|
var extStyle = '';
|
|
3862
4217
|
var gradientMixColor;
|
|
3863
4218
|
|
|
3864
4219
|
// 将英文定义颜色转换为rgb格式
|
|
3865
|
-
value = (
|
|
4220
|
+
value = Object(_color__WEBPACK_IMPORTED_MODULE_1__["parseColorName"])(value, isGradient); // 渐变需要处理透明
|
|
3866
4221
|
|
|
3867
|
-
if (_constant__WEBPACK_IMPORTED_MODULE_2__
|
|
4222
|
+
if (_constant__WEBPACK_IMPORTED_MODULE_2__["COLOR_REGEXP"].test(value)) {
|
|
3868
4223
|
if (isGradient) {
|
|
3869
4224
|
// 把原渐变色取出来
|
|
3870
|
-
var _matches = _constant__WEBPACK_IMPORTED_MODULE_2__
|
|
4225
|
+
var _matches = _constant__WEBPACK_IMPORTED_MODULE_2__["COLOR_REGEXP_GLOBAL"].exec(value);
|
|
3871
4226
|
while (_matches) {
|
|
3872
4227
|
gradientColors.push(_matches[0]);
|
|
3873
|
-
_matches = _constant__WEBPACK_IMPORTED_MODULE_2__
|
|
4228
|
+
_matches = _constant__WEBPACK_IMPORTED_MODULE_2__["COLOR_REGEXP_GLOBAL"].exec(value);
|
|
3874
4229
|
}
|
|
3875
4230
|
|
|
3876
4231
|
// 计算出一个mix颜色
|
|
3877
|
-
gradientMixColor = (
|
|
4232
|
+
gradientMixColor = Object(_color__WEBPACK_IMPORTED_MODULE_1__["mixColors"])(gradientColors);
|
|
3878
4233
|
}
|
|
3879
4234
|
var replaceIndex = 0;
|
|
3880
|
-
value = value.replace(_constant__WEBPACK_IMPORTED_MODULE_2__
|
|
4235
|
+
value = value.replace(_constant__WEBPACK_IMPORTED_MODULE_2__["COLOR_REGEXP_GLOBAL"], function (match) {
|
|
3881
4236
|
// 渐变色统一改成mix纯色
|
|
3882
4237
|
if (isGradient) {
|
|
3883
4238
|
match = gradientMixColor;
|
|
3884
4239
|
cssChange = true;
|
|
3885
4240
|
}
|
|
3886
|
-
var matchColor = (
|
|
3887
|
-
if ((matchColor === null || matchColor === void 0 ? void 0 : matchColor.alpha()) >= _constant__WEBPACK_IMPORTED_MODULE_2__
|
|
4241
|
+
var matchColor = Object(_color__WEBPACK_IMPORTED_MODULE_1__["ColorParser"])(match);
|
|
4242
|
+
if ((matchColor === null || matchColor === void 0 ? void 0 : matchColor.alpha()) >= _constant__WEBPACK_IMPORTED_MODULE_2__["IGNORE_ALPHA"]) {
|
|
3888
4243
|
// 忽略透明度低的色值
|
|
3889
4244
|
// 使用颜色处理算法
|
|
3890
4245
|
var ret = _this._adjustBrightness(matchColor, el, {
|
|
@@ -3901,19 +4256,19 @@ var SDK = /*#__PURE__*/function () {
|
|
|
3901
4256
|
if (isBgColor || textColorIdx >= 5) {
|
|
3902
4257
|
// 只处理color及之后的属性
|
|
3903
4258
|
var retColorStr = retColor ? retColor.toString() : match;
|
|
3904
|
-
replaceIndex === 0 && (
|
|
4259
|
+
replaceIndex === 0 && Object(_domUtils__WEBPACK_IMPORTED_MODULE_5__["getChildrenAndIt"])(el).forEach(function (dom) {
|
|
3905
4260
|
if (isBgColor) {
|
|
3906
|
-
dom[_constant__WEBPACK_IMPORTED_MODULE_2__
|
|
3907
|
-
dom[_constant__WEBPACK_IMPORTED_MODULE_2__
|
|
4261
|
+
dom[_constant__WEBPACK_IMPORTED_MODULE_2__["BGCOLORATTR"]] = retColorStr;
|
|
4262
|
+
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"]);
|
|
3908
4263
|
} else {
|
|
3909
|
-
dom[_constant__WEBPACK_IMPORTED_MODULE_2__
|
|
3910
|
-
dom[_constant__WEBPACK_IMPORTED_MODULE_2__
|
|
4264
|
+
dom[_constant__WEBPACK_IMPORTED_MODULE_2__["COLORATTR"]] = retColorStr;
|
|
4265
|
+
dom[_constant__WEBPACK_IMPORTED_MODULE_2__["ORIGINAL_COLORATTR"]] = match;
|
|
3911
4266
|
}
|
|
3912
4267
|
|
|
3913
4268
|
// 如果设置背景颜色,取消背景图片的影响
|
|
3914
|
-
var retColor = (
|
|
3915
|
-
if (isBgColor && (retColor === null || retColor === void 0 ? void 0 : retColor.alpha()) >= _constant__WEBPACK_IMPORTED_MODULE_2__
|
|
3916
|
-
delete dom[_constant__WEBPACK_IMPORTED_MODULE_2__
|
|
4269
|
+
var retColor = Object(_color__WEBPACK_IMPORTED_MODULE_1__["ColorParser"])(retColorStr);
|
|
4270
|
+
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"]]) {
|
|
4271
|
+
delete dom[_constant__WEBPACK_IMPORTED_MODULE_2__["BGIMAGEATTR"]];
|
|
3917
4272
|
}
|
|
3918
4273
|
});
|
|
3919
4274
|
}
|
|
@@ -3932,7 +4287,7 @@ var SDK = /*#__PURE__*/function () {
|
|
|
3932
4287
|
var isBorderImageAttr = /^(-webkit-)?border-image/.test(key);
|
|
3933
4288
|
if ((isBackgroundAttr || isBorderImageAttr) && /url\([^)]*\)/i.test(value)) {
|
|
3934
4289
|
cssChange = true;
|
|
3935
|
-
var imgBgColor = (
|
|
4290
|
+
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();
|
|
3936
4291
|
// const imgBgColor = el[BGCOLORATTR] || config.defaultLightBgColor;
|
|
3937
4292
|
|
|
3938
4293
|
// 在背景图片下加一层原背景颜色:
|
|
@@ -3941,36 +4296,36 @@ var SDK = /*#__PURE__*/function () {
|
|
|
3941
4296
|
value = value.replace(/^(.*?)url\(([^)]*)\)(.*)$/i, function (matches) {
|
|
3942
4297
|
var newValue = matches;
|
|
3943
4298
|
var tmpCssKvStr = '';
|
|
3944
|
-
if (!el[_constant__WEBPACK_IMPORTED_MODULE_2__
|
|
4299
|
+
if (!el[_constant__WEBPACK_IMPORTED_MODULE_2__["BGIMAGEATTR"]]) {
|
|
3945
4300
|
// 避免重复set
|
|
3946
|
-
(
|
|
3947
|
-
dom[_constant__WEBPACK_IMPORTED_MODULE_2__
|
|
4301
|
+
Object(_domUtils__WEBPACK_IMPORTED_MODULE_5__["getChildrenAndIt"])(el).forEach(function (dom) {
|
|
4302
|
+
dom[_constant__WEBPACK_IMPORTED_MODULE_2__["BGIMAGEATTR"]] = true;
|
|
3948
4303
|
});
|
|
3949
4304
|
}
|
|
3950
4305
|
|
|
3951
4306
|
// background-image
|
|
3952
4307
|
if (isBackgroundAttr) {
|
|
3953
|
-
tmpCssKvStr = _global__WEBPACK_IMPORTED_MODULE_4__
|
|
4308
|
+
tmpCssKvStr = _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCssKV(key, imgBgColor ? "".concat(newValue, ",linear-gradient(").concat(imgBgColor, ", ").concat(imgBgColor, ")") : newValue);
|
|
3954
4309
|
if (elBackgroundPositionAttr) {
|
|
3955
|
-
cssKV += _global__WEBPACK_IMPORTED_MODULE_4__
|
|
3956
|
-
tmpCssKvStr += _global__WEBPACK_IMPORTED_MODULE_4__
|
|
4310
|
+
cssKV += _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCssKV('background-position', elBackgroundPositionAttr);
|
|
4311
|
+
tmpCssKvStr += _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCssKV('background-position', imgBgColor ? "".concat(elBackgroundPositionAttr, ",top left") : elBackgroundPositionAttr);
|
|
3957
4312
|
}
|
|
3958
4313
|
if (elBackgroundSizeAttr) {
|
|
3959
|
-
cssKV += _global__WEBPACK_IMPORTED_MODULE_4__
|
|
3960
|
-
tmpCssKvStr += _global__WEBPACK_IMPORTED_MODULE_4__
|
|
4314
|
+
cssKV += _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCssKV('background-size', elBackgroundSizeAttr);
|
|
4315
|
+
tmpCssKvStr += _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCssKV('background-size', imgBgColor ? "".concat(elBackgroundSizeAttr, ",100%") : elBackgroundSizeAttr);
|
|
3961
4316
|
}
|
|
3962
4317
|
if (!needReset) {
|
|
3963
4318
|
if (dmBgClassName) {
|
|
3964
4319
|
// 如果是文字底图,则直接加样式
|
|
3965
|
-
bgCss += _global__WEBPACK_IMPORTED_MODULE_4__
|
|
3966
|
-
(
|
|
3967
|
-
dom[_constant__WEBPACK_IMPORTED_MODULE_2__
|
|
4320
|
+
bgCss += _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCss(dmBgClassName, tmpCssKvStr);
|
|
4321
|
+
Object(_domUtils__WEBPACK_IMPORTED_MODULE_5__["getChildrenAndIt"])(el).forEach(function (dom) {
|
|
4322
|
+
dom[_constant__WEBPACK_IMPORTED_MODULE_2__["COMPLEMENTARY_BGIMAGECOLORATTR"]] = imgBgColor || newValue;
|
|
3968
4323
|
});
|
|
3969
4324
|
} else {
|
|
3970
4325
|
// 否则背景图入栈
|
|
3971
|
-
_global__WEBPACK_IMPORTED_MODULE_4__
|
|
3972
|
-
(
|
|
3973
|
-
dom[_constant__WEBPACK_IMPORTED_MODULE_2__
|
|
4326
|
+
_global__WEBPACK_IMPORTED_MODULE_4__["bgStack"].push(el, tmpCssKvStr, function () {
|
|
4327
|
+
Object(_domUtils__WEBPACK_IMPORTED_MODULE_5__["getChildrenAndIt"])(el).forEach(function (dom) {
|
|
4328
|
+
dom[_constant__WEBPACK_IMPORTED_MODULE_2__["COMPLEMENTARY_BGIMAGECOLORATTR"]] = imgBgColor || newValue;
|
|
3974
4329
|
});
|
|
3975
4330
|
});
|
|
3976
4331
|
}
|
|
@@ -3978,43 +4333,44 @@ var SDK = /*#__PURE__*/function () {
|
|
|
3978
4333
|
} else {
|
|
3979
4334
|
// border-image元素,如果当前元素没有背景颜色,补背景颜色
|
|
3980
4335
|
if (imgBgColor && !hasInlineBackground && !needReset) {
|
|
3981
|
-
tmpCssKvStr = _global__WEBPACK_IMPORTED_MODULE_4__
|
|
4336
|
+
tmpCssKvStr = _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCssKV('background-image', "linear-gradient(".concat(imgBgColor, ", ").concat(imgBgColor, ")"));
|
|
3982
4337
|
if (dmBgClassName) {
|
|
3983
4338
|
// 如果是文字底图,则直接加样式
|
|
3984
|
-
bgCss += _global__WEBPACK_IMPORTED_MODULE_4__
|
|
4339
|
+
bgCss += _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCss(dmBgClassName, tmpCssKvStr);
|
|
3985
4340
|
} else {
|
|
3986
4341
|
// 否则背景图入栈
|
|
3987
|
-
_global__WEBPACK_IMPORTED_MODULE_4__
|
|
4342
|
+
_global__WEBPACK_IMPORTED_MODULE_4__["bgStack"].push(el, tmpCssKvStr); // 背景图入栈
|
|
3988
4343
|
}
|
|
3989
4344
|
}
|
|
3990
4345
|
}
|
|
4346
|
+
|
|
3991
4347
|
return newValue;
|
|
3992
4348
|
});
|
|
3993
4349
|
|
|
3994
4350
|
// 没有设置自定义字体颜色,则使用非 Dark Mode 下默认字体颜色
|
|
3995
4351
|
if (!hasInlineColor) {
|
|
3996
|
-
var textColor = el[_constant__WEBPACK_IMPORTED_MODULE_2__
|
|
3997
|
-
cssKV += _global__WEBPACK_IMPORTED_MODULE_4__
|
|
3998
|
-
(
|
|
3999
|
-
dom[_constant__WEBPACK_IMPORTED_MODULE_2__
|
|
4352
|
+
var textColor = el[_constant__WEBPACK_IMPORTED_MODULE_2__["ORIGINAL_COLORATTR"]] || _config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultLightTextColor;
|
|
4353
|
+
cssKV += _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCssKV('color', textColor);
|
|
4354
|
+
Object(_domUtils__WEBPACK_IMPORTED_MODULE_5__["getChildrenAndIt"])(el).forEach(function (dom) {
|
|
4355
|
+
dom[_constant__WEBPACK_IMPORTED_MODULE_2__["COLORATTR"]] = textColor;
|
|
4000
4356
|
});
|
|
4001
4357
|
}
|
|
4002
4358
|
}
|
|
4003
4359
|
}
|
|
4004
4360
|
if (cssChange || needReset) {
|
|
4005
|
-
!isUpdate && !needReset && _constant__WEBPACK_IMPORTED_MODULE_2__
|
|
4361
|
+
!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
|
|
4006
4362
|
if (isGradient) {
|
|
4007
4363
|
if (!needReset) {
|
|
4008
4364
|
if (dmBgClassName) {
|
|
4009
4365
|
// 如果是文字底图,则直接加样式
|
|
4010
|
-
bgCss += _global__WEBPACK_IMPORTED_MODULE_4__
|
|
4366
|
+
bgCss += _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCss(dmBgClassName, _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCssKV(key, value));
|
|
4011
4367
|
if (/^background/.test(key) && !/url\([^)]*\)/i.test(value)) {
|
|
4012
4368
|
// 是无背景图的渐变,需要重新计算背景色
|
|
4013
4369
|
css += _this._updateBgWithGradient(gradientMixColor, el, dmBgClassName, cssKVList, hasInlineColor, isUpdate, needReset);
|
|
4014
4370
|
}
|
|
4015
4371
|
} else {
|
|
4016
4372
|
// 否则渐变入栈
|
|
4017
|
-
_global__WEBPACK_IMPORTED_MODULE_4__
|
|
4373
|
+
_global__WEBPACK_IMPORTED_MODULE_4__["bgStack"].push(el, _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCssKV(key, value), function (item) {
|
|
4018
4374
|
// 渐变入栈
|
|
4019
4375
|
if (/^background/.test(key) && !/url\([^)]*\)/i.test(value)) {
|
|
4020
4376
|
// 是无背景图的渐变,需要重新计算背景色
|
|
@@ -4026,41 +4382,41 @@ var SDK = /*#__PURE__*/function () {
|
|
|
4026
4382
|
} else {
|
|
4027
4383
|
if (key === 'color') {
|
|
4028
4384
|
noColor = false;
|
|
4029
|
-
_global__WEBPACK_IMPORTED_MODULE_4__
|
|
4385
|
+
_global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].unwatch('color');
|
|
4030
4386
|
}
|
|
4031
|
-
cssKV += _global__WEBPACK_IMPORTED_MODULE_4__
|
|
4387
|
+
cssKV += _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCssKV(key, !cssChange && needReset ? el.style[key] : value);
|
|
4032
4388
|
}
|
|
4033
4389
|
}
|
|
4034
4390
|
});
|
|
4035
4391
|
});
|
|
4036
4392
|
if (noColor) {
|
|
4037
|
-
cssKV += _global__WEBPACK_IMPORTED_MODULE_4__
|
|
4038
|
-
_global__WEBPACK_IMPORTED_MODULE_4__
|
|
4393
|
+
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);
|
|
4394
|
+
_global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].unwatch('color');
|
|
4039
4395
|
}
|
|
4040
4396
|
if (cssKV) {
|
|
4041
4397
|
// 有处理过或者是背景图片就加class以及css
|
|
4042
4398
|
if (!dmClassName) {
|
|
4043
|
-
dmClassName = "".concat(_constant__WEBPACK_IMPORTED_MODULE_2__
|
|
4399
|
+
dmClassName = "".concat(_constant__WEBPACK_IMPORTED_MODULE_2__["CLASS_PREFIX"]).concat(this._idx++);
|
|
4044
4400
|
el.classList.add(dmClassName);
|
|
4045
4401
|
}
|
|
4046
|
-
css += cssKV ? _global__WEBPACK_IMPORTED_MODULE_4__
|
|
4402
|
+
css += cssKV ? _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCss(dmClassName, cssKV) : '';
|
|
4047
4403
|
}
|
|
4048
4404
|
css += bgCss; // 追加文字底图样式,要在添加cssKV之后添加,避免被覆盖
|
|
4049
4405
|
|
|
4050
|
-
if (!isUpdate && (
|
|
4406
|
+
if (!isUpdate && Object(_domUtils__WEBPACK_IMPORTED_MODULE_5__["hasTextNode"])(el) && !needReset) {
|
|
4051
4407
|
// 如果节点里有文本,要判断是否在背景图里
|
|
4052
4408
|
if (_config__WEBPACK_IMPORTED_MODULE_3__["default"].delayBgJudge) {
|
|
4053
4409
|
// 延迟背景判断
|
|
4054
|
-
_global__WEBPACK_IMPORTED_MODULE_4__
|
|
4410
|
+
_global__WEBPACK_IMPORTED_MODULE_4__["tnQueue"].push(el); // 文字入队
|
|
4055
4411
|
} else {
|
|
4056
|
-
_global__WEBPACK_IMPORTED_MODULE_4__
|
|
4057
|
-
css += _global__WEBPACK_IMPORTED_MODULE_4__
|
|
4412
|
+
_global__WEBPACK_IMPORTED_MODULE_4__["bgStack"].contains(el, function (item) {
|
|
4413
|
+
css += _global__WEBPACK_IMPORTED_MODULE_4__["cssUtils"].genCss(item.className, item.cssKV);
|
|
4058
4414
|
typeof item.cb === 'function' && item.cb(item);
|
|
4059
4415
|
});
|
|
4060
4416
|
}
|
|
4061
4417
|
}
|
|
4062
4418
|
}
|
|
4063
|
-
_global__WEBPACK_IMPORTED_MODULE_4__
|
|
4419
|
+
_global__WEBPACK_IMPORTED_MODULE_4__["plugins"].emit("afterConvertNode".concat(emitNameSuffix), el);
|
|
4064
4420
|
return css;
|
|
4065
4421
|
}
|
|
4066
4422
|
|
|
@@ -4068,36 +4424,34 @@ var SDK = /*#__PURE__*/function () {
|
|
|
4068
4424
|
}, {
|
|
4069
4425
|
key: "getContrast",
|
|
4070
4426
|
value: function getContrast(colorStr1, colorStr2) {
|
|
4071
|
-
var color1 = (
|
|
4072
|
-
var color2 = (
|
|
4427
|
+
var color1 = Object(_color__WEBPACK_IMPORTED_MODULE_1__["ColorParser"])(colorStr1);
|
|
4428
|
+
var color2 = Object(_color__WEBPACK_IMPORTED_MODULE_1__["ColorParser"])(colorStr2);
|
|
4073
4429
|
return color1 && color2 ? color1.contrast(color2) : 0;
|
|
4074
4430
|
}
|
|
4075
4431
|
}]);
|
|
4432
|
+
return SDK;
|
|
4076
4433
|
}();
|
|
4077
4434
|
|
|
4078
4435
|
;
|
|
4079
4436
|
|
|
4080
|
-
/***/ },
|
|
4437
|
+
/***/ }),
|
|
4081
4438
|
|
|
4082
|
-
/***/ "./src/modules/textNodeQueue.js"
|
|
4439
|
+
/***/ "./src/modules/textNodeQueue.js":
|
|
4083
4440
|
/*!**************************************!*\
|
|
4084
4441
|
!*** ./src/modules/textNodeQueue.js ***!
|
|
4085
4442
|
\**************************************/
|
|
4086
|
-
|
|
4443
|
+
/*! exports provided: default */
|
|
4444
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
4087
4445
|
|
|
4088
4446
|
"use strict";
|
|
4089
4447
|
__webpack_require__.r(__webpack_exports__);
|
|
4090
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
4091
|
-
/* harmony export */ "default": () => (/* binding */ TextNodeQueue)
|
|
4092
|
-
/* harmony export */ });
|
|
4448
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return TextNodeQueue; });
|
|
4093
4449
|
/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./config */ "./src/modules/config.js");
|
|
4094
|
-
function _typeof(
|
|
4095
|
-
function _classCallCheck(
|
|
4096
|
-
function _defineProperties(
|
|
4097
|
-
function _createClass(
|
|
4098
|
-
function _defineProperty(
|
|
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); }
|
|
4450
|
+
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); }
|
|
4451
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4452
|
+
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); } }
|
|
4453
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
4454
|
+
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; }
|
|
4101
4455
|
/**
|
|
4102
4456
|
* @name 文本节点队列
|
|
4103
4457
|
*
|
|
@@ -4125,18 +4479,18 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
4125
4479
|
// Darkmode配置
|
|
4126
4480
|
|
|
4127
4481
|
var TextNodeQueue = /*#__PURE__*/function () {
|
|
4482
|
+
// 文本节点队列,{ el, className, updated }
|
|
4128
4483
|
// 索引值
|
|
4129
4484
|
|
|
4130
4485
|
function TextNodeQueue(prefix) {
|
|
4131
4486
|
_classCallCheck(this, TextNodeQueue);
|
|
4132
4487
|
_defineProperty(this, "_queue", []);
|
|
4133
|
-
// 文本节点队列,{ el, className, updated }
|
|
4134
4488
|
_defineProperty(this, "_idx", 0);
|
|
4135
4489
|
this._prefix = prefix;
|
|
4136
4490
|
}
|
|
4137
4491
|
|
|
4138
4492
|
// 队列长度
|
|
4139
|
-
|
|
4493
|
+
_createClass(TextNodeQueue, [{
|
|
4140
4494
|
key: "length",
|
|
4141
4495
|
get: function get() {
|
|
4142
4496
|
return this._queue.length;
|
|
@@ -4190,372 +4544,13 @@ var TextNodeQueue = /*#__PURE__*/function () {
|
|
|
4190
4544
|
});
|
|
4191
4545
|
}
|
|
4192
4546
|
}]);
|
|
4547
|
+
return TextNodeQueue;
|
|
4193
4548
|
}();
|
|
4194
4549
|
|
|
4195
4550
|
;
|
|
4196
4551
|
|
|
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
|
-
|
|
4552
|
+
/***/ })
|
|
4351
4553
|
|
|
4352
|
-
|
|
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
|
-
;
|
|
4554
|
+
/******/ });
|
|
4560
4555
|
});
|
|
4561
4556
|
//# sourceMappingURL=darkmode.js.map
|