efront 3.7.7 → 3.8.4

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/apps/kugou/api.js CHANGED
@@ -12,7 +12,7 @@
12
12
  "singer-list": "get:[].singer-img-list>li singer/list/:id#href=a!href&=a!href\\singer-info&imgurl=img!_src&name=p|innerText",
13
13
  "singer-info": "mget:[].singer-songs-list>li singer/info/:id#hash=!id&singer=.singer-name|innerText&name=.song-name|innerText&data=em/innerText"
14
14
  },
15
- "https://mobilecdn.kugou.com/": {
15
+ "http://mobilecdn.kugou.com/": {
16
16
  "search?keyword": "get:data.info api/v3/search/song?format=json&page=1&pagesize=30&showtype=1"
17
17
  }
18
18
  })
@@ -17,6 +17,9 @@
17
17
  <script>
18
18
  cross_host = 'efront.cc';
19
19
  </script>
20
+ <script deleteoncompile>
21
+ cross_host = '';
22
+ </script>
20
23
  <style>
21
24
  *,
22
25
  ::before,
@@ -25,7 +25,7 @@ function encode(str) {
25
25
  }) + "\"";
26
26
  }
27
27
  function decode(s) {
28
- var r = /^(['"])([\s\S]*)\1$/.exec(s);
28
+ var r = /^(['"`])([\s\S]*)\1$/.exec(s);
29
29
  if (!r) return s;
30
30
  return r[2].replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\([\s\S])/ig, (a, b) => {
31
31
  if (!b) {
@@ -91,6 +91,7 @@ var skipAssignment = function (o) {
91
91
  }
92
92
  else if (o.text === "function") {
93
93
  o = o.next;
94
+ if (o && o.type === STAMP) o = o.next;
94
95
  if (o && o.type === EXPRESS) o = o.next;
95
96
  if (o) o = o.next;
96
97
  if (o) o = o.next;
@@ -118,6 +119,7 @@ var createScoped = function (parsed) {
118
119
  var isFunction = false;
119
120
  var isScope = false;
120
121
  var isArrow = false;
122
+ var isDeclare = false;
121
123
  switch (o.type) {
122
124
  case QUOTED:
123
125
  if (o.length) {
@@ -130,13 +132,18 @@ var createScoped = function (parsed) {
130
132
  if (o.next) {
131
133
  if (o.next.type !== STAMP || o.next.text !== ",") break;
132
134
  }
135
+ if (o.prev && o.prev.type === STRAP && o.prev.text === 'as') {
136
+ break;
137
+ }
133
138
  case VALUE:
134
139
  if (number_reg.test(o.text)) break;
135
140
  case EXPRESS:
136
141
  if (o.prev && o.prev.type === EXPRESS) {
137
142
  if (/\.$/.test(o.prev.text)) break;
138
143
  }
139
- var u = o.text.replace(/^([^\.\[]*)[\s\S]*$/, '$1');
144
+ var u = o.text;
145
+ if (/^\.\.\./.test(u)) u = u.slice(3);
146
+ var u = u.replace(/^([^\.\[]*)[\s\S]*$/, '$1');
140
147
  if (!u) break;
141
148
  if (o.next && o.next.type === STAMP && o.next.text === "=>") {
142
149
  isScope = true;
@@ -157,6 +164,9 @@ var createScoped = function (parsed) {
157
164
  case STRAP:
158
165
  var s = o.text;
159
166
  switch (s) {
167
+ case "as":
168
+ case "from":
169
+ break;
160
170
  case "var":
161
171
  case "import":
162
172
  var m = vars;
@@ -176,6 +186,7 @@ var createScoped = function (parsed) {
176
186
  continue loop;
177
187
  case "function":
178
188
  isFunction = true;
189
+ if (o.next.type === STAMP) o = o.next;
179
190
  case "catch":
180
191
  isCatch = true;
181
192
  case "class":
@@ -184,6 +195,7 @@ var createScoped = function (parsed) {
184
195
 
185
196
  if (o.type === EXPRESS) {
186
197
  vars[o.text] = true;
198
+ isDeclare = true;
187
199
  o.kind = isFunction ? 'function' : 'class';
188
200
  saveTo(used, o.text, o);
189
201
 
@@ -237,7 +249,7 @@ var createScoped = function (parsed) {
237
249
  scoped.used = used;
238
250
  }
239
251
  if (isArrow);
240
- else if (o.isExpress && o.type !== SCOPED) {
252
+ else if (o.isExpress && o.type !== SCOPED && !isDeclare) {
241
253
  o = o.next;
242
254
  if (o.type === EXPRESS) {
243
255
  vars[o.text] = true;
@@ -358,10 +370,19 @@ var getDeclared = function (o, kind) {
358
370
  }
359
371
  }
360
372
  switch (o.type) {
373
+ case STAMP:
374
+ if (o.text === "*" && o.next) {
375
+ if (o.next.type === STRAP && o.next.text === 'as') {
376
+ o = o.next.next;
377
+ continue;
378
+ }
379
+ }
361
380
  case PROPERTY:
362
- if (o.next && o.next.type === STAMP && o.next.text === ":") {
363
- o = o.next.next;
364
- continue;
381
+ if (o.next) {
382
+ if (o.next.type === STAMP && o.next.text === ":" || o.next.type === STRAP && o.next.text === "as") {
383
+ o = o.next.next;
384
+ continue;
385
+ }
365
386
  }
366
387
  case STRAP:
367
388
  case VALUE:
@@ -379,7 +400,6 @@ var getDeclared = function (o, kind) {
379
400
  Object.assign(declared, d);
380
401
  o = o.next;
381
402
  break;
382
-
383
403
  default:
384
404
  console.log(o);
385
405
  throw new Error("代码结构异常");
@@ -26,6 +26,7 @@ var needBreak = function (prev, next) {
26
26
  if (prev.type === EXPRESS && /\.$/.test(prev.text)) return;
27
27
  if (next.type === EXPRESS && /^\./.test(next.text)) return;
28
28
  if (next.type === PROPERTY) return ";";
29
+ if (next.type === STAMP && next.text === "*") return ";";
29
30
  if (
30
31
  [EXPRESS, VALUE, QUOTED].indexOf(prev.type) >= 0
31
32
  || prev.type === STAMP && /^(\+\+|\-\-)$/.test(prev.text)
@@ -95,8 +96,8 @@ var compress = function (scoped, maped) {
95
96
 
96
97
  var strings = require("../basic/strings");
97
98
 
98
- var insertAfter = function (o,) {
99
- var queue = o.queue;
99
+ var insertAfter = function (o) {
100
+ var queue = o.queue || this;
100
101
  var index = queue.indexOf(o) + 1;
101
102
  var os = [].slice.call(arguments, 1);
102
103
  queue.splice.apply(queue, [index, 0].concat(os));
@@ -104,6 +105,7 @@ var insertAfter = function (o,) {
104
105
  for (var o of os) {
105
106
  prev.next = o;
106
107
  o.prev = prev;
108
+ Object.defineProperty(o, 'queue', { value: queue });
107
109
  prev = o;
108
110
  }
109
111
  if (next) {
@@ -111,6 +113,20 @@ var insertAfter = function (o,) {
111
113
  next.prev = o;
112
114
  }
113
115
  };
116
+ var detourTemplate = function (raw, params) {
117
+ var spliter = { text: ",", type: STAMP };
118
+ var template = scan(`extend([],{["raw"]:[]})`);
119
+ var str0 = template[1].first;
120
+ var str1 = template[1][2][2];
121
+ for (var r of raw) {
122
+ str0.push({ text: strings.encode(strings.decode("`" + r.text + "`")), type: QUOTED }, spliter);
123
+ str1.push({ text: strings.encode(r.text), type: QUOTED }, spliter);
124
+ }
125
+ str0.pop();
126
+ str1.pop();
127
+ for (var p of params) template.push(spliter, p);
128
+ return template;
129
+ };
114
130
 
115
131
  var detour = function (o, ie) {
116
132
  while (o) {
@@ -121,31 +137,103 @@ var detour = function (o, ie) {
121
137
  case EXPRESS:
122
138
  if (!/^\.\.\.|\.\.\.$/.test(o.text)) {
123
139
  var ot = o.text;
124
- o.text = o.text.replace(/\.([^\.\[]+)/g, (_, a) => !ie || program.strap_reg.test(a) ? `[${strings.encode(strings.decode(a))}]` : _);
140
+ o.text = o.text.replace(/\.([^\.\[]+)/g, (_, a) => ie === undefined || program.strap_reg.test(a) ? `[${strings.encode(strings.decode(a))}]` : _);
125
141
  }
126
142
  break;
127
143
  case QUOTED:
128
144
  if (o.length) {
129
- detour(o.first, ie);
145
+ if (!o.prev || o.prev.type === STAMP || o.prev.type === STRAP) {
146
+ o.type = SCOPED;
147
+ o.entry = '[';
148
+ o.leave = `]["join"]('')`;
149
+ for (var cx = o.length - 1; cx >= 0; cx--) {
150
+ var c = o[cx];
151
+ if (c.type === PIECE) {
152
+ c.type = QUOTED;
153
+ c.text = strings.encode(strings.decode("`" + c.text + "`"));
154
+ }
155
+ else {
156
+ insertAfter.call(o, c.prev, { type: STAMP, text: ',' });
157
+ c.entry = "(";
158
+ c.leave = ")";
159
+ insertAfter.call(o, c, { type: STAMP, text: ',' });
160
+ detour(c.first, ie);
161
+ }
162
+ }
163
+ }
164
+ else {
165
+ var raw = [];
166
+ var params = [];
167
+
168
+ for (var c of o) {
169
+ if (c.type === PIECE) {
170
+ raw.push(c);
171
+ } else {
172
+ c.entry = '(';
173
+ c.leave = ")";
174
+ detour(c, ie);
175
+ params.push(c.length === 1 ? c[0] : c);
176
+ }
177
+ }
178
+ o.type = SCOPED;
179
+ o.entry = "(";
180
+ o.leave = ")";
181
+ var temp = detourTemplate(raw, params);
182
+ o.splice(0, o.length);
183
+ o.push.apply(o, temp);
184
+ }
130
185
  break;
131
186
  }
187
+ else if (!o.prev || o.prev.type === STAMP || o.prev.type === STRAP) {
188
+ if (/^[`]/.test(o.text)) {
189
+ o.text = strings.encode(strings.decode(o.text));
190
+ }
191
+ }
192
+ else {
193
+ if (/^`/.test(o.text)) {
194
+ o.text = o.text.replace(/^`|`$/g, '');
195
+ var template = detourTemplate([o], []);
196
+ o.type = SCOPED;
197
+ o.entry = "(";
198
+ o.leave = ")";
199
+ delete o.text;
200
+ o.push.apply(o, template);
201
+ }
202
+ }
132
203
  if (!o.isprop) break;
133
204
  case PROPERTY:
134
205
  if (/^(get|set|async|static)$/.test(o.text) && o.next && (o.next.type === PROPERTY || o.next.isprop)) break;
135
206
  if (o.text === 'static' && o.next && o.next.type === SCOPED && o.next.entry === '{') break;
136
- if (!ie || program.strap_reg.test(o.text)) {
207
+ if (ie === undefined || program.strap_reg.test(o.text)) {
137
208
  if (!/^\[/.test(o.text) && o.queue.isObject) {
138
209
  if (o.short) {
139
210
  insertAfter(o, { text: ':', type: STAMP }, { text: o.text, type: EXPRESS, isExpress: true });
140
211
  o.short = false;
141
212
  }
142
213
  var text = strings.encode(strings.decode(o.text));
143
- o.text = ie ? text : `[${text}]`;
214
+ o.text = ie !== undefined ? text : `[${text}]`;
215
+ }
216
+ if (!/^\[/.test(o.text) && o.queue.isClass) {
217
+ if (o.text === 'constructor') break;
218
+ var text = strings.encode(strings.decode(o.text));
219
+ if (o.prev) {
220
+ var prev = o.prev;
221
+ if (prev && prev.type === PROPERTY && /^(get|set|static|async)$/.test(prev.text)) {
222
+ prev = prev.prev;
223
+ }
224
+ if (prev && prev.type === STAMP && prev.isprop) prev = prev.prev;
225
+ if (prev && (prev.type !== STAMP || prev.text !== ';')) insertAfter(prev, { text: ';', type: STAMP });
226
+ }
227
+ o.text = `[${text}]`;
228
+ if (o.next && o.next.type === SCOPED && o.next.entry === "(") { }
229
+ else if (!o.next || o.next.type !== STAMP || o.next.text !== "=") {
230
+ insertAfter(o, { text: "=", type: STAMP }, { text: "undefined", type: VALUE, isExpress: true });
231
+ }
144
232
  }
145
233
  }
146
234
  break;
147
235
  }
148
- o = o.next;
236
+ if (o) o = o.next;
149
237
  }
150
238
  };
151
239
 
@@ -215,7 +303,7 @@ class Program extends Array {
215
303
  break;
216
304
  }
217
305
  case SCOPED:
218
- if (!this.pressed && (lasttype === STRAP || lasttype === SCOPED && o.entry === "{") && o.type !== QUOTED) result.push(" ");
306
+ if (!this.pressed && (lasttype === STRAP || lasttype === STAMP || lasttype === SCOPED && o.entry === "{") && o.type !== QUOTED) result.push(" ");
219
307
  result.push(o.entry);
220
308
  if (o.length > 0) {
221
309
  if (o.entry === "{" && result[0].type !== SPACE) {
@@ -229,7 +317,7 @@ class Program extends Array {
229
317
  if (!o.prev || o.prev.text !== 'for') result.pop();
230
318
  }
231
319
  if (o.leave === "}" && (!o.next || o.next.type !== PIECE) && o[o.length - 1].type !== SPACE) {
232
- result.push(" ");
320
+ if (!this.pressed) result.push(" ");
233
321
  }
234
322
  }
235
323
  result.push(o.leave);
@@ -253,7 +341,7 @@ class Program extends Array {
253
341
  ) result.push(";");
254
342
  }
255
343
  else if (!/^(\+\+|\-\-)$/.test(o.text)) {
256
- if (!this.pressed) result.push(" ");
344
+ if (!this.pressed && lasttype !== SPACE) result.push(" ");
257
345
  }
258
346
  }
259
347
  result.push(o.text);
@@ -290,8 +378,8 @@ class Program extends Array {
290
378
  return this;
291
379
  }
292
380
  // 绕开低版本ie的异常属性
293
- detour() {
294
- detour(this.first, true);
381
+ detour(ie) {
382
+ detour(this.first, !!ie);
295
383
  return this;
296
384
  }
297
385
  // 压缩
@@ -319,7 +407,7 @@ class Javascript {
319
407
  ["{", "}"],
320
408
  ]
321
409
  stamps = "/=+;|:?<>-!~@#%^&*,".split("")
322
- value_reg = /^(false|true|null|Infinity|NaN|undefined|arguments|this|eval)$/
410
+ value_reg = /^(false|true|null|Infinity|NaN|undefined|arguments|this|eval|super)$/
323
411
  number_reg = number_reg;
324
412
  transive = /^(new|var|let|const|yield|void|in|of|typeof|delete|case|return|await|export|default|instanceof|throw|extends|import|from)$/
325
413
  straps = `if,in,do,as,of
@@ -360,19 +448,24 @@ class Javascript {
360
448
  var origin = queue;
361
449
  var queue_push = function (scope) {
362
450
  var last = queue.lastUncomment;
363
- if (~[VALUE, QUOTED].indexOf(scope.type)) {
364
- scope.isprop = isProperty();
365
- }
366
- else if (scope.type === SCOPED && scope.entry === '[') {
367
- if (queue.isObject) {
368
- scope.isprop = !last || last.type === STAMP && last.text === ','
451
+ if (queue.isObject || queue.isClass) {
452
+ if (~[VALUE, QUOTED].indexOf(scope.type)) {
453
+ scope.isprop = isProperty();
454
+ }
455
+ else if (scope.type === SCOPED && scope.entry === '[') {
456
+ if (queue.isObject) scope.isprop = isProperty();
457
+ if (queue.isClass) scope.isprop = !last || last.isprop || last.type === STAMP && last.text === ';';
369
458
  }
370
- else if (queue.isClass) {
371
- scope.isprop = !last || last.type === STAMP && /^(\+\+|\-\-|;)$/.test(last.text)
459
+ else if (scope.type === STAMP) {
460
+ scope.isprop = scope.text === "*" && isProperty();
461
+ }
462
+ else if (scope.type === PROPERTY) {
463
+ scope.isprop = true;
372
464
  }
373
465
  }
374
466
  if (scope.type !== COMMENT && scope.type !== SPACE) {
375
- if (scope.type === PROPERTY || scope.isprop) scope.queue = queue;
467
+ Object.defineProperty(scope, 'queue', { value: queue });
468
+ if (scope.type === PROPERTY || scope.isprop);
376
469
  else if (scope.type === STRAP && /^(get|set|static)$/.test(scope.text)) {
377
470
  scope.type = EXPRESS;
378
471
  }
@@ -395,8 +488,11 @@ class Javascript {
395
488
  else {
396
489
  scope.prev = last;
397
490
  }
491
+ scope.row = row;
492
+ scope.col = scope.start - colstart;
398
493
  queue.push(scope);
399
494
  };
495
+ var row = 1, colstart = -1;
400
496
  var save = (type) => {
401
497
  if (lasttype === STAMP && type === STAMP && !/[,;\:\?]/.test(m)) {
402
498
  var scope = queue[queue.length - 1];
@@ -437,19 +533,26 @@ class Javascript {
437
533
  }
438
534
  else if (isProperty()) type = PROPERTY;
439
535
  else if (m === 'from') {
440
- if (!last || last.type === STRAP && last.text !== 'import') {
536
+ if (!last || last.type === STRAP && !/^(im|ex)port$/.test(last.text)) {
441
537
  type = EXPRESS;
442
538
  break;
443
539
  }
444
540
  var temp = last;
445
- while (temp.type === EXPRESS || temp.type === VALUE || temp.type === SCOPED) {
446
- var prev = last.prev;
541
+ while (temp.type === STAMP && temp.text === "*" || temp.type === EXPRESS || temp.type === VALUE || temp.type === SCOPED) {
542
+ var prev = temp.prev;
447
543
  if (!prev) break;
448
- if (prev.type !== STAMP || prev.text !== ',') break;
544
+ if (prev.type === STRAP && prev.text === "as") {
545
+ temp = prev.prev;
546
+ continue;
547
+ }
548
+ if (prev.type !== STAMP || prev.text !== ',' && (prev.text !== "*" || !prev.prev || !~[STRAP, STAMP].indexOf(prev.prev.type))) {
549
+ temp = prev;
550
+ break;
551
+ }
449
552
  temp = prev.prev;
450
553
  if (!temp) break;
451
554
  }
452
- if (temp.type !== STRAP || temp.text !== 'import') {
555
+ if (!temp || temp.type !== STRAP || !/^(im|ex)port$/.test(temp.text)) {
453
556
  type = EXPRESS;
454
557
  }
455
558
  }
@@ -458,9 +561,9 @@ class Javascript {
458
561
  type = EXPRESS;
459
562
  break;
460
563
  }
461
- if (~[EXPRESS, VALUE].indexOf(last.type)) {
462
- last.type = PROPERTY;
463
- last.queue = queue;
564
+ if (~[PROPERTY, EXPRESS, VALUE].indexOf(last.type)
565
+ || last.type === STAMP && last.text === "*" && last.prev && ~[STRAP, STAMP].indexOf(last.prev.type)) {
566
+ Object.defineProperty(last, 'queue', { value: queue });
464
567
  } else {
465
568
  type = EXPRESS;
466
569
  }
@@ -559,10 +662,14 @@ class Javascript {
559
662
  var prev = queue.lastUncomment;
560
663
  if (queue.isObject) {
561
664
  if (!prev || prev.type === STAMP && prev.text === ",") return true;
665
+ if (prev.type === STAMP && prev.isprop) return true;
562
666
  }
563
667
  if (queue.isClass) {
564
668
  if (!prev) return true;
565
- if (prev.type === STAMP) return /^(\+\+|\-\-|;)$/.test(prev.text);
669
+ if (prev.type === STAMP) {
670
+ if (prev.isprop) return true;
671
+ return /^(\+\+|\-\-|;)$/.test(prev.text);
672
+ }
566
673
  if (prev.type === EXPRESS && !/\.$/.test(prev.text)) return true;
567
674
  if (~[SCOPED, VALUE, QUOTED, PROPERTY].indexOf(prev.type)) return true;
568
675
  }
@@ -570,6 +677,9 @@ class Javascript {
570
677
  if (prev.type === PROPERTY && /^(get|set|async|static)$/.test(prev.text)) {
571
678
  return true;
572
679
  }
680
+ if (queue.prev && queue.prev.type === STRAP && queue.prev.text === 'export') {
681
+ if (prev.type === STRAP && prev.text === "as") return true;
682
+ }
573
683
  return false;
574
684
  };
575
685
 
@@ -671,7 +781,9 @@ class Javascript {
671
781
  }
672
782
  if (this.space_reg.test(m)) {
673
783
  if (/[\r\n\u2028\u2029]/.test(m)) {
674
- m = m.replace(/^[^\r\n\u2028\u2029]+/, '').replace(/\r\n|\r|\n/g, "\r\n");
784
+ colstart = match.index + 1;
785
+ m = m.replace(/^[^\r\n\u2028\u2029]+/, '').replace(/\r\n|\r|\n|\u2028|\u2029/g, "\r\n");
786
+ row += m.replace(/[^\r\n]+/, '').length >> 1;
675
787
  save(SPACE);
676
788
  }
677
789
  lasttype = SPACE;
@@ -689,7 +801,36 @@ class Javascript {
689
801
  queue.inExpress = false;
690
802
  }
691
803
  }
692
- save(STRAP);
804
+ if (m === 'yield') {
805
+ var temp = queue;
806
+ var type = STRAP;
807
+ while (temp) {
808
+ if (temp.entry != "{" || !temp.prev || temp.prev.type !== SCOPED || temp.prev.entry !== '(') {
809
+ temp = temp.queue;
810
+ continue;
811
+ }
812
+ var pp = temp.prev.prev;
813
+ var isprop = pp.isprop;
814
+ if (pp && pp.type === EXPRESS || pp.isprop) pp = pp.prev;
815
+ if (!pp || pp.type === STRAP && !/^function$/.test(pp.text)) {
816
+ temp = temp.queue;
817
+ continue;
818
+ }
819
+ if (pp.type === STAMP && pp.text === "*" && (pp.isprop || pp.prev && pp.prev.type === STRAP && pp.prev.text === "function")) {
820
+ type = STRAP;
821
+ break;
822
+ }
823
+ if (isprop || pp.type === STRAP && pp.text === "function") {
824
+ type = EXPRESS;
825
+ break;
826
+ }
827
+ temp = temp.queue;
828
+ }
829
+ save(type);
830
+ }
831
+ else {
832
+ save(STRAP);
833
+ }
693
834
  continue;
694
835
  }
695
836
  if (this.value_reg.test(m) || this.number_reg.test(m)) {
@@ -727,7 +868,8 @@ class Javascript {
727
868
  else scope.isObject = !/^(;|\+\+|\-\-|=>)$/.test(last.text);
728
869
  }
729
870
  else if (last.type === STRAP) {
730
- if (queue[queue.length - 1].type === SPACE && last.text === 'return');
871
+ if (queue[queue.length - 1].type === SPACE && /^(return|yield)$/.test(last.text));
872
+ else if (/^export$/.test(last.text));
731
873
  else scope.isObject = queue.inExpress;
732
874
  }
733
875
  }
@@ -7,6 +7,9 @@
7
7
  top: 0;
8
8
  height: auto;
9
9
  }
10
+ &+.titlebar>back{
11
+ height: 44px;
12
+ }
10
13
 
11
14
  >png {
12
15
  width: 100%;
@@ -0,0 +1,16 @@
1
+ .grid() {
2
+ @mask-color1 : rgba(255, 255, 255, .6);
3
+ @mask-color2 : rgba(0, 0, 0, 0);
4
+ @mask-color3 : rgba(0, 0, 0, .1);
5
+ background-image:
6
+ linear-gradient(45deg, @mask-color1, 25%, @mask-color1, 25%, @mask-color2, 75%, @mask-color1, 75%, @mask-color1),
7
+ linear-gradient(45deg, @mask-color1, 25%, @mask-color1, 25%, @mask-color2, 75%, @mask-color1, 75%, @mask-color1),
8
+ linear-gradient(45deg, @mask-color3, 25%, @mask-color3, 25%, @mask-color2, 75%, @mask-color3, 75%, @mask-color3),
9
+ linear-gradient(45deg, @mask-color3, 25%, @mask-color3, 25%, @mask-color2, 75%, @mask-color3, 75%, @mask-color3);
10
+ background-size: 20px 20px;
11
+ background-position: 0 0, 10px 10px, 10px 0, 0 10px;
12
+ background-repeat: repeat;
13
+ background-clip: border-box;
14
+ background-color: #fff;
15
+
16
+ }
@@ -215,14 +215,24 @@ function hsl2rgb([h, s, l]) {
215
215
  var b = h - 1 / 3;
216
216
  return [r, g, b].map(t => t2rgb(t, p, q));
217
217
  }
218
+ function percent(a) {
219
+ if (/%$/.test(a)) {
220
+ a = a.replace(/%$/, '') / 100;
221
+ }
222
+ return +a;
223
+ }
218
224
  function parse(color) {
219
225
  if (hslReg.test(color)) {
220
226
  var [_, H, S, L, a] = hslReg.exec(color);
227
+ H = parseFloat(H);
228
+ S = percent(S);
229
+ L = percent(L);
230
+ a = percent(a);
221
231
  [R, G, B] = hsl2rgb([H, S, L]);
222
232
  return [R, G, B, a || 1];
223
233
  } else if (rgbReg.test(color)) {
224
234
  var [_, R, G, B, a] = rgbReg.exec(color);
225
- return [R > 255 ? 255 : R, G > 255 ? 255 : G, B > 255 ? 255 : B, a || 1];
235
+ return [R > 255 ? 255 : +R, G > 255 ? 255 : +G, B > 255 ? 255 : +B, a ? +a : 1];
226
236
  } else if (rgbHex.test(color)) {
227
237
  var [_, R, G, B, A] = rgbHex.exec(color).map(a => parseInt(a + a, 16));
228
238
  return [R, G, B, A >= 0 ? A / 0xff : 1];
@@ -234,6 +244,10 @@ function parse(color) {
234
244
  function stringify(color) {
235
245
  var [R, G, B, a] = color;
236
246
  if (a >= 0 && a < 1) {
247
+ R = R.toFixed();
248
+ G = G.toFixed();
249
+ B = B.toFixed();
250
+ a = +a.toFixed(3);
237
251
  return `rgba(${R},${G},${B},${a})`;
238
252
  } else {
239
253
  return "#" + [R, G, B].map(hex256).join("");
@@ -291,12 +305,12 @@ function equal(c1, c2) {
291
305
  var [r2, g2, b2, a2] = parse(c2);
292
306
  return abs(r1 - r2) < 1 && abs(g1 - g2) < 1 && abs(b1 - b2) < 1 && abs(a1 - a2) < .01;
293
307
  }
294
- var hslReg = /^hsla?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:,\s*([\d\.]+))?\)$/i;
295
- var rgbReg = /^rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:,\s*([\d\.]+))?\)$/i;
308
+ var hslReg = /^hsla?\s*\(\s*([\d\.]+(?:deg)?)\s*[,\s]\s*([\d\.]+%?)\s*[,\s]\s*([\d\.]+%?)(?:[,\/\s]\s*([\d\.]+%?))?\)$/i;
309
+ var rgbReg = /^rgba?\s*\(\s*([\d\.]+)\s*[,\s]\s*([\d\.]+)\s*[,\s]\s*([\d\.]+)(?:[,\s]\s*([\d\.]+))?\)$/i;
296
310
  var rgbHex = /^#([\da-f])([\da-f])([\da-f])([\da-f])?$/i;
297
311
  var rgbHex2 = /^#([\da-f]{2})([\da-f]{2})([\da-f]{2})([\da-f]{2})?$/i;
298
312
  var rotated_base_color = "#d16969";
299
- var colorReg = /rgba?\s*\([\,\.\d]+\)|#[\da-f]{3,8}/ig;
313
+ var colorReg = /(?:rgb|hsl)a?\s*\([\,\.\d\s%]+\)|#[\da-f]{3,8}/ig;
300
314
  function isColor(text) {
301
315
  return rgbReg.test(text) || rgbHex.test(text) || rgbHex2.test(text) || hslReg.test(text);
302
316
  }
@@ -1,6 +1,7 @@
1
1
  function main(elem = div()) {
2
- care(elem, function (color) {
3
- css(this, 'background', color);
2
+ care(elem, function (c) {
3
+ css(this, 'background-color', c);
4
+ css(this, 'color', color.pair(c));
4
5
  });
5
6
  return elem;
6
7
  }
@@ -1,7 +1,28 @@
1
1
  & {
2
- width: 40px;
2
+ width: 180px;
3
3
  height: 20px;
4
- background: #ccc;
5
4
  display: inline-block;
5
+ text-align: center;
6
+ font-size: 10px;
7
+ line-height: 20px;
8
+ position: relative;
9
+ .grid();
10
+ background-color: transparent;
6
11
 
7
- }
12
+ >option {
13
+ position: relative;
14
+ }
15
+
16
+ &:before {
17
+ position: absolute;
18
+ left: 0;
19
+ top: 0;
20
+ right: 0;
21
+ bottom: 0;
22
+ content: "";
23
+ display: block;
24
+ background-color: inherit;
25
+ }
26
+ }
27
+
28
+ @import "./bggrid-func.less";
@@ -7,6 +7,10 @@
7
7
  <canvas></canvas>
8
8
  <pointer tabindex="-1"></pointer>
9
9
  </div>
10
+ <div class="opa">
11
+ <canvas></canvas>
12
+ <pointer tabindex="-1"></pointer>
13
+ </div>
10
14
  <div class="val">
11
15
  <input class="hex" />
12
16
  <input class="rgb" />