@symbo.ls/scratch 2.11.523 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/factory.js +106 -51
- package/dist/cjs/index.js +366 -423
- package/dist/cjs/set.js +304 -321
- package/dist/cjs/system/color.js +231 -181
- package/dist/cjs/system/document.js +198 -121
- package/dist/cjs/system/font.js +199 -127
- package/dist/cjs/system/index.js +308 -325
- package/dist/cjs/system/reset.js +205 -135
- package/dist/cjs/system/shadow.js +247 -212
- package/dist/cjs/system/spacing.js +215 -153
- package/dist/cjs/system/svg.js +203 -132
- package/dist/cjs/system/theme.js +243 -206
- package/dist/cjs/system/timing.js +206 -138
- package/dist/cjs/system/typography.js +212 -148
- package/dist/cjs/transforms/index.js +285 -268
- package/dist/cjs/utils/color.js +93 -85
- package/dist/cjs/utils/font.js +3 -6
- package/dist/cjs/utils/index.js +236 -193
- package/dist/cjs/utils/sequence.js +206 -99
- package/dist/cjs/utils/sprite.js +106 -51
- package/dist/cjs/utils/theme.js +3 -6
- package/dist/cjs/utils/var.js +196 -83
- package/package.json +4 -4
- package/src/system/svg.js +1 -1
- package/src/transforms/index.js +9 -2
- package/src/utils/color.js +1 -2
- package/src/utils/sequence.js +1 -1
package/dist/cjs/system/color.js
CHANGED
|
@@ -30,65 +30,29 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
));
|
|
31
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
32
|
|
|
33
|
-
// ../../node_modules/@domql/globals/dist/cjs/index.js
|
|
34
|
-
var require_cjs = __commonJS({
|
|
35
|
-
"../../node_modules/@domql/globals/dist/cjs/index.js"(exports, module2) {
|
|
36
|
-
"use strict";
|
|
37
|
-
var __defProp3 = Object.defineProperty;
|
|
38
|
-
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
39
|
-
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
40
|
-
var __hasOwnProp3 = Object.prototype.hasOwnProperty;
|
|
41
|
-
var __export2 = (target, all) => {
|
|
42
|
-
for (var name in all)
|
|
43
|
-
__defProp3(target, name, { get: all[name], enumerable: true });
|
|
44
|
-
};
|
|
45
|
-
var __copyProps2 = (to, from, except, desc) => {
|
|
46
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
47
|
-
for (let key of __getOwnPropNames2(from))
|
|
48
|
-
if (!__hasOwnProp3.call(to, key) && key !== except)
|
|
49
|
-
__defProp3(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
50
|
-
}
|
|
51
|
-
return to;
|
|
52
|
-
};
|
|
53
|
-
var __toCommonJS2 = (mod) => __copyProps2(__defProp3({}, "__esModule", { value: true }), mod);
|
|
54
|
-
var globals_exports = {};
|
|
55
|
-
__export2(globals_exports, {
|
|
56
|
-
document: () => document4,
|
|
57
|
-
global: () => global,
|
|
58
|
-
self: () => self,
|
|
59
|
-
window: () => window4
|
|
60
|
-
});
|
|
61
|
-
module2.exports = __toCommonJS2(globals_exports);
|
|
62
|
-
var global = globalThis;
|
|
63
|
-
var self = globalThis;
|
|
64
|
-
var window4 = globalThis;
|
|
65
|
-
var document4 = window4.document;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
|
|
69
33
|
// ../utils/dist/cjs/index.js
|
|
70
|
-
var
|
|
34
|
+
var require_cjs = __commonJS({
|
|
71
35
|
"../utils/dist/cjs/index.js"(exports, module2) {
|
|
72
36
|
"use strict";
|
|
73
|
-
var
|
|
37
|
+
var __defProp2 = Object.defineProperty;
|
|
74
38
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
75
39
|
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
76
|
-
var
|
|
40
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
77
41
|
var __export2 = (target, all) => {
|
|
78
42
|
for (var name in all)
|
|
79
|
-
|
|
43
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
80
44
|
};
|
|
81
45
|
var __copyProps2 = (to, from, except, desc) => {
|
|
82
46
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
83
47
|
for (let key of __getOwnPropNames2(from))
|
|
84
|
-
if (!
|
|
85
|
-
|
|
48
|
+
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
49
|
+
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
86
50
|
}
|
|
87
51
|
return to;
|
|
88
52
|
};
|
|
89
|
-
var __toCommonJS2 = (mod) => __copyProps2(
|
|
90
|
-
var
|
|
91
|
-
__export2(
|
|
53
|
+
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
54
|
+
var index_exports = {};
|
|
55
|
+
__export2(index_exports, {
|
|
92
56
|
arrayzeValue: () => arrayzeValue,
|
|
93
57
|
copyJavaScriptToClipboard: () => copyJavaScriptToClipboard,
|
|
94
58
|
copyStringToClipboard: () => copyStringToClipboard,
|
|
@@ -109,17 +73,85 @@ var require_cjs2 = __commonJS({
|
|
|
109
73
|
toTitleCase: () => toTitleCase,
|
|
110
74
|
toggleFullscreen: () => toggleFullscreen
|
|
111
75
|
});
|
|
112
|
-
module2.exports = __toCommonJS2(
|
|
76
|
+
module2.exports = __toCommonJS2(index_exports);
|
|
113
77
|
var window22 = globalThis;
|
|
114
78
|
var document22 = window22.document;
|
|
115
79
|
var isObject2 = (arg) => {
|
|
116
|
-
if (arg === null)
|
|
117
|
-
return false;
|
|
80
|
+
if (arg === null) return false;
|
|
118
81
|
return typeof arg === "object" && arg.constructor === Object;
|
|
119
82
|
};
|
|
120
83
|
var isString2 = (arg) => typeof arg === "string";
|
|
121
84
|
var isNumber2 = (arg) => typeof arg === "number";
|
|
122
85
|
var isArray2 = (arg) => Array.isArray(arg);
|
|
86
|
+
var STATE_METHODS2 = [
|
|
87
|
+
"update",
|
|
88
|
+
"parse",
|
|
89
|
+
"clean",
|
|
90
|
+
"create",
|
|
91
|
+
"destroy",
|
|
92
|
+
"add",
|
|
93
|
+
"toggle",
|
|
94
|
+
"remove",
|
|
95
|
+
"apply",
|
|
96
|
+
"set",
|
|
97
|
+
"reset",
|
|
98
|
+
"replace",
|
|
99
|
+
"quietReplace",
|
|
100
|
+
"quietUpdate",
|
|
101
|
+
"applyReplace",
|
|
102
|
+
"applyFunction",
|
|
103
|
+
"keys",
|
|
104
|
+
"values",
|
|
105
|
+
"ref",
|
|
106
|
+
"rootUpdate",
|
|
107
|
+
"parentUpdate",
|
|
108
|
+
"parent",
|
|
109
|
+
"__element",
|
|
110
|
+
"__depends",
|
|
111
|
+
"__ref",
|
|
112
|
+
"__children",
|
|
113
|
+
"root",
|
|
114
|
+
"setByPath",
|
|
115
|
+
"setPathCollection",
|
|
116
|
+
"removeByPath",
|
|
117
|
+
"removePathCollection",
|
|
118
|
+
"getByPath"
|
|
119
|
+
];
|
|
120
|
+
var PROPS_METHODS2 = ["update", "__element"];
|
|
121
|
+
var METHODS2 = [
|
|
122
|
+
"set",
|
|
123
|
+
"reset",
|
|
124
|
+
"update",
|
|
125
|
+
"remove",
|
|
126
|
+
"updateContent",
|
|
127
|
+
"removeContent",
|
|
128
|
+
"lookup",
|
|
129
|
+
"lookdown",
|
|
130
|
+
"lookdownAll",
|
|
131
|
+
"getRef",
|
|
132
|
+
"getPath",
|
|
133
|
+
"setNodeStyles",
|
|
134
|
+
"spotByPath",
|
|
135
|
+
"keys",
|
|
136
|
+
"parse",
|
|
137
|
+
"setProps",
|
|
138
|
+
"parseDeep",
|
|
139
|
+
"variables",
|
|
140
|
+
"if",
|
|
141
|
+
"log",
|
|
142
|
+
"verbose",
|
|
143
|
+
"warn",
|
|
144
|
+
"error",
|
|
145
|
+
"call",
|
|
146
|
+
"nextElement",
|
|
147
|
+
"previousElement"
|
|
148
|
+
];
|
|
149
|
+
var METHODS_EXL2 = [
|
|
150
|
+
...["node", "context", "extends", "__element", "__ref"],
|
|
151
|
+
...METHODS2,
|
|
152
|
+
...STATE_METHODS2,
|
|
153
|
+
...PROPS_METHODS2
|
|
154
|
+
];
|
|
123
155
|
var isMobile2 = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
|
|
124
156
|
async function toggleFullscreen(opts) {
|
|
125
157
|
if (!document.fullscreenElement) {
|
|
@@ -139,13 +171,11 @@ var require_cjs2 = __commonJS({
|
|
|
139
171
|
};
|
|
140
172
|
var findClosestNumberInFactory = (val, factory) => {
|
|
141
173
|
val = parseFloat(val);
|
|
142
|
-
if (isObject2(factory))
|
|
143
|
-
factory = Object.values(factory);
|
|
174
|
+
if (isObject2(factory)) factory = Object.values(factory);
|
|
144
175
|
return findClosestNumber(val, factory);
|
|
145
176
|
};
|
|
146
177
|
var formatDate = (timestamp) => {
|
|
147
|
-
if (!timestamp)
|
|
148
|
-
return "";
|
|
178
|
+
if (!timestamp) return "";
|
|
149
179
|
const d = new Date(timestamp);
|
|
150
180
|
const ye = new Intl.DateTimeFormat("en", { year: "numeric" }).format(d);
|
|
151
181
|
const mo = new Intl.DateTimeFormat("en", { month: "short" }).format(d);
|
|
@@ -212,8 +242,7 @@ var require_cjs2 = __commonJS({
|
|
|
212
242
|
scriptEle.type = type;
|
|
213
243
|
scriptEle.text = xhr.responseText;
|
|
214
244
|
doc.body.appendChild(scriptEle);
|
|
215
|
-
if (typeof fallback === "function")
|
|
216
|
-
fallback();
|
|
245
|
+
if (typeof fallback === "function") fallback();
|
|
217
246
|
} else {
|
|
218
247
|
throw new Error(`Failed to load the script ${FILE_URL}`);
|
|
219
248
|
}
|
|
@@ -281,20 +310,15 @@ var require_cjs2 = __commonJS({
|
|
|
281
310
|
);
|
|
282
311
|
var toDashCase2 = (val) => val.replace(/[^a-zA-Z0-9]/g, " ").trim().toLowerCase().replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
283
312
|
var toDescriptionCase = (str = "") => {
|
|
284
|
-
if (typeof str !== "string")
|
|
285
|
-
return;
|
|
313
|
+
if (typeof str !== "string") return;
|
|
286
314
|
const result = str.replace(/([A-Z])/g, " $1");
|
|
287
315
|
return result.charAt(0).toUpperCase() + result.slice(1);
|
|
288
316
|
};
|
|
289
317
|
var arrayzeValue = (val) => {
|
|
290
|
-
if (isArray2(val))
|
|
291
|
-
|
|
292
|
-
if (
|
|
293
|
-
|
|
294
|
-
if (isObject2(val))
|
|
295
|
-
return Object.values(val);
|
|
296
|
-
if (isNumber2(val))
|
|
297
|
-
return [val];
|
|
318
|
+
if (isArray2(val)) return val;
|
|
319
|
+
if (isString2(val)) return val.split(" ");
|
|
320
|
+
if (isObject2(val)) return Object.values(val);
|
|
321
|
+
if (isNumber2(val)) return [val];
|
|
298
322
|
};
|
|
299
323
|
}
|
|
300
324
|
});
|
|
@@ -309,19 +333,18 @@ __export(color_exports, {
|
|
|
309
333
|
});
|
|
310
334
|
module.exports = __toCommonJS(color_exports);
|
|
311
335
|
|
|
312
|
-
// ../../node_modules/@domql/utils/
|
|
336
|
+
// ../../node_modules/@domql/utils/globals.js
|
|
313
337
|
var window2 = globalThis;
|
|
314
338
|
var document2 = window2.document;
|
|
315
339
|
|
|
316
|
-
// ../../node_modules/@domql/utils/
|
|
340
|
+
// ../../node_modules/@domql/utils/node.js
|
|
317
341
|
var isDOMNode = (obj) => {
|
|
318
342
|
return typeof window2 !== "undefined" && (obj instanceof window2.Node || obj instanceof window2.Window || obj === window2 || obj === document);
|
|
319
343
|
};
|
|
320
344
|
|
|
321
|
-
// ../../node_modules/@domql/utils/
|
|
345
|
+
// ../../node_modules/@domql/utils/types.js
|
|
322
346
|
var isObject = (arg) => {
|
|
323
|
-
if (arg === null)
|
|
324
|
-
return false;
|
|
347
|
+
if (arg === null) return false;
|
|
325
348
|
return typeof arg === "object" && arg.constructor === Object;
|
|
326
349
|
};
|
|
327
350
|
var isString = (arg) => typeof arg === "string";
|
|
@@ -330,44 +353,99 @@ var isFunction = (arg) => typeof arg === "function";
|
|
|
330
353
|
var isNull = (arg) => arg === null;
|
|
331
354
|
var isArray = (arg) => Array.isArray(arg);
|
|
332
355
|
var isObjectLike = (arg) => {
|
|
333
|
-
if (arg === null)
|
|
334
|
-
return false;
|
|
356
|
+
if (arg === null) return false;
|
|
335
357
|
return typeof arg === "object";
|
|
336
358
|
};
|
|
337
359
|
var isUndefined = (arg) => {
|
|
338
360
|
return arg === void 0;
|
|
339
361
|
};
|
|
340
362
|
|
|
341
|
-
// ../../node_modules/@domql/utils/
|
|
342
|
-
var
|
|
343
|
-
return arr.reduce(
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
var
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
363
|
+
// ../../node_modules/@domql/utils/array.js
|
|
364
|
+
var unstackArrayOfObjects = (arr, exclude = []) => {
|
|
365
|
+
return arr.reduce(
|
|
366
|
+
(a, c) => deepMerge(a, deepClone(c, { exclude }), exclude),
|
|
367
|
+
{}
|
|
368
|
+
);
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
// ../../node_modules/@domql/utils/keys.js
|
|
372
|
+
var STATE_METHODS = [
|
|
373
|
+
"update",
|
|
374
|
+
"parse",
|
|
375
|
+
"clean",
|
|
376
|
+
"create",
|
|
377
|
+
"destroy",
|
|
378
|
+
"add",
|
|
379
|
+
"toggle",
|
|
380
|
+
"remove",
|
|
381
|
+
"apply",
|
|
382
|
+
"set",
|
|
383
|
+
"reset",
|
|
384
|
+
"replace",
|
|
385
|
+
"quietReplace",
|
|
386
|
+
"quietUpdate",
|
|
387
|
+
"applyReplace",
|
|
388
|
+
"applyFunction",
|
|
389
|
+
"keys",
|
|
390
|
+
"values",
|
|
391
|
+
"ref",
|
|
392
|
+
"rootUpdate",
|
|
393
|
+
"parentUpdate",
|
|
394
|
+
"parent",
|
|
395
|
+
"__element",
|
|
396
|
+
"__depends",
|
|
397
|
+
"__ref",
|
|
398
|
+
"__children",
|
|
399
|
+
"root",
|
|
400
|
+
"setByPath",
|
|
401
|
+
"setPathCollection",
|
|
402
|
+
"removeByPath",
|
|
403
|
+
"removePathCollection",
|
|
404
|
+
"getByPath"
|
|
405
|
+
];
|
|
406
|
+
var PROPS_METHODS = ["update", "__element"];
|
|
407
|
+
var METHODS = [
|
|
408
|
+
"set",
|
|
409
|
+
"reset",
|
|
410
|
+
"update",
|
|
411
|
+
"remove",
|
|
412
|
+
"updateContent",
|
|
413
|
+
"removeContent",
|
|
414
|
+
"lookup",
|
|
415
|
+
"lookdown",
|
|
416
|
+
"lookdownAll",
|
|
417
|
+
"getRef",
|
|
418
|
+
"getPath",
|
|
419
|
+
"setNodeStyles",
|
|
420
|
+
"spotByPath",
|
|
421
|
+
"keys",
|
|
422
|
+
"parse",
|
|
423
|
+
"setProps",
|
|
424
|
+
"parseDeep",
|
|
425
|
+
"variables",
|
|
426
|
+
"if",
|
|
427
|
+
"log",
|
|
428
|
+
"verbose",
|
|
429
|
+
"warn",
|
|
430
|
+
"error",
|
|
431
|
+
"call",
|
|
432
|
+
"nextElement",
|
|
433
|
+
"previousElement"
|
|
434
|
+
];
|
|
435
|
+
var METHODS_EXL = [
|
|
436
|
+
...["node", "context", "extends", "__element", "__ref"],
|
|
437
|
+
...METHODS,
|
|
438
|
+
...STATE_METHODS,
|
|
439
|
+
...PROPS_METHODS
|
|
440
|
+
];
|
|
441
|
+
|
|
442
|
+
// ../../node_modules/@domql/utils/object.js
|
|
443
|
+
var deepMerge = (element, extend, excludeFrom = METHODS_EXL) => {
|
|
367
444
|
for (const e in extend) {
|
|
368
|
-
const
|
|
369
|
-
if (!
|
|
445
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty.call(extend, e);
|
|
446
|
+
if (!hasOwnProperty || excludeFrom.includes(e) || e.startsWith("__")) {
|
|
370
447
|
continue;
|
|
448
|
+
}
|
|
371
449
|
const elementProp = element[e];
|
|
372
450
|
const extendProp = extend[e];
|
|
373
451
|
if (isObjectLike(elementProp) && isObjectLike(extendProp)) {
|
|
@@ -385,7 +463,7 @@ var deepClone = (obj, options = {}) => {
|
|
|
385
463
|
cleanNull = false,
|
|
386
464
|
window: targetWindow,
|
|
387
465
|
visited = /* @__PURE__ */ new WeakMap(),
|
|
388
|
-
|
|
466
|
+
handleExtends = false
|
|
389
467
|
} = options;
|
|
390
468
|
if (!isObjectLike(obj) || isDOMNode(obj)) {
|
|
391
469
|
return obj;
|
|
@@ -393,40 +471,42 @@ var deepClone = (obj, options = {}) => {
|
|
|
393
471
|
if (visited.has(obj)) {
|
|
394
472
|
return visited.get(obj);
|
|
395
473
|
}
|
|
396
|
-
const
|
|
397
|
-
visited.set(obj,
|
|
474
|
+
const clone = targetWindow ? isArray(obj) ? new targetWindow.Array() : new targetWindow.Object() : isArray(obj) ? [] : {};
|
|
475
|
+
visited.set(obj, clone);
|
|
398
476
|
for (const key in obj) {
|
|
399
|
-
if (!Object.prototype.hasOwnProperty.call(obj, key))
|
|
400
|
-
|
|
401
|
-
if (exclude.includes(key) || key.startsWith("__") || key === "__proto__")
|
|
477
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
|
|
478
|
+
if (exclude.includes(key) || key.startsWith("__") || key === "__proto__") {
|
|
402
479
|
continue;
|
|
480
|
+
}
|
|
403
481
|
const value = obj[key];
|
|
404
|
-
if (cleanUndefined && isUndefined(value) || cleanNull && isNull(value))
|
|
482
|
+
if (cleanUndefined && isUndefined(value) || cleanNull && isNull(value)) {
|
|
405
483
|
continue;
|
|
484
|
+
}
|
|
406
485
|
if (isDOMNode(value)) {
|
|
407
|
-
|
|
486
|
+
clone[key] = value;
|
|
408
487
|
continue;
|
|
409
488
|
}
|
|
410
|
-
if (
|
|
411
|
-
|
|
489
|
+
if (handleExtends && key === "extends" && isArray(value)) {
|
|
490
|
+
clone[key] = unstackArrayOfObjects(value, exclude);
|
|
412
491
|
continue;
|
|
413
492
|
}
|
|
414
493
|
if (isFunction(value) && targetWindow) {
|
|
415
|
-
|
|
494
|
+
clone[key] = targetWindow.eval("(" + value.toString() + ")");
|
|
416
495
|
continue;
|
|
417
496
|
}
|
|
418
497
|
if (isObjectLike(value)) {
|
|
419
|
-
|
|
498
|
+
clone[key] = deepClone(value, {
|
|
499
|
+
...options,
|
|
420
500
|
visited
|
|
421
|
-
})
|
|
501
|
+
});
|
|
422
502
|
} else {
|
|
423
|
-
|
|
503
|
+
clone[key] = value;
|
|
424
504
|
}
|
|
425
505
|
}
|
|
426
|
-
return
|
|
506
|
+
return clone;
|
|
427
507
|
};
|
|
428
508
|
|
|
429
|
-
// ../../node_modules/@domql/utils/
|
|
509
|
+
// ../../node_modules/@domql/utils/cookie.js
|
|
430
510
|
var isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
|
|
431
511
|
|
|
432
512
|
// src/defaultConfig/index.js
|
|
@@ -651,12 +731,9 @@ var getActiveConfig = (def) => {
|
|
|
651
731
|
};
|
|
652
732
|
|
|
653
733
|
// src/utils/color.js
|
|
654
|
-
var import_globals4 = __toESM(require_cjs(), 1);
|
|
655
734
|
var colorStringToRgbaArray = (color) => {
|
|
656
|
-
if (color === "")
|
|
657
|
-
|
|
658
|
-
if (color.toLowerCase() === "transparent")
|
|
659
|
-
return [0, 0, 0, 0];
|
|
735
|
+
if (color === "") return [0, 0, 0, 0];
|
|
736
|
+
if (color.toLowerCase() === "transparent") return [0, 0, 0, 0];
|
|
660
737
|
if (color[0] === "#") {
|
|
661
738
|
if (color.length < 7) {
|
|
662
739
|
color = "#" + color[1] + color[1] + color[2] + color[2] + color[3] + color[3] + (color.length > 4 ? color[4] + color[4] : "");
|
|
@@ -669,26 +746,25 @@ var colorStringToRgbaArray = (color) => {
|
|
|
669
746
|
];
|
|
670
747
|
}
|
|
671
748
|
if (color.indexOf("rgb") === -1) {
|
|
672
|
-
if (
|
|
673
|
-
const elem =
|
|
749
|
+
if (document2 && window2) {
|
|
750
|
+
const elem = document2.body.appendChild(document2.createElement("fictum"));
|
|
674
751
|
const flag = "rgb(1, 2, 3)";
|
|
675
752
|
elem.style.color = flag;
|
|
676
753
|
if (elem.style.color !== flag) {
|
|
677
|
-
|
|
754
|
+
document2.body.removeChild(elem);
|
|
678
755
|
return;
|
|
679
756
|
}
|
|
680
757
|
elem.style.color = color;
|
|
681
758
|
if (elem.style.color === flag || elem.style.color === "") {
|
|
682
|
-
|
|
759
|
+
document2.body.removeChild(elem);
|
|
683
760
|
return [0, 0, 0, 0];
|
|
684
761
|
}
|
|
685
|
-
color =
|
|
686
|
-
|
|
762
|
+
color = window2.getComputedStyle(elem).color;
|
|
763
|
+
document2.body.removeChild(elem);
|
|
687
764
|
}
|
|
688
765
|
}
|
|
689
766
|
if (color.indexOf("rgb") === 0) {
|
|
690
|
-
if (color.indexOf("rgba") === -1)
|
|
691
|
-
color = `${color}, 1`;
|
|
767
|
+
if (color.indexOf("rgba") === -1) color = `${color}, 1`;
|
|
692
768
|
return color.match(/[\.\d]+/g).map((a) => +a);
|
|
693
769
|
}
|
|
694
770
|
return [0, 0, 0, 0];
|
|
@@ -714,29 +790,20 @@ var hslToRgb = (h, s, l, a = s * Math.min(l, 1 - l), f = (n, k = (n + h / 30) %
|
|
|
714
790
|
var getColorShade = (col, amt) => {
|
|
715
791
|
const num = parseInt(col, 16);
|
|
716
792
|
let r = (num >> 16) + amt;
|
|
717
|
-
if (r > 255)
|
|
718
|
-
|
|
719
|
-
else if (r < 0)
|
|
720
|
-
r = 0;
|
|
793
|
+
if (r > 255) r = 255;
|
|
794
|
+
else if (r < 0) r = 0;
|
|
721
795
|
let b = (num >> 8 & 255) + amt;
|
|
722
|
-
if (b > 255)
|
|
723
|
-
|
|
724
|
-
else if (b < 0)
|
|
725
|
-
b = 0;
|
|
796
|
+
if (b > 255) b = 255;
|
|
797
|
+
else if (b < 0) b = 0;
|
|
726
798
|
let g = (num & 255) + amt;
|
|
727
|
-
if (g > 255)
|
|
728
|
-
|
|
729
|
-
else if (g < 0)
|
|
730
|
-
g = 0;
|
|
799
|
+
if (g > 255) g = 255;
|
|
800
|
+
else if (g < 0) g = 0;
|
|
731
801
|
return ((g | b << 8 | r << 16) + 16777216).toString(16).slice(1);
|
|
732
802
|
};
|
|
733
803
|
var getRgbTone = (rgb, tone) => {
|
|
734
|
-
if (isString(rgb) && rgb.includes("rgb"))
|
|
735
|
-
|
|
736
|
-
if (
|
|
737
|
-
rgb = rgb.split(",").map((v) => parseFloat(v.trim()));
|
|
738
|
-
if (isNumber(tone))
|
|
739
|
-
tone += "";
|
|
804
|
+
if (isString(rgb) && rgb.includes("rgb")) rgb = colorStringToRgbaArray(rgb).join(", ");
|
|
805
|
+
if (isString(rgb)) rgb = rgb.split(",").map((v) => parseFloat(v.trim()));
|
|
806
|
+
if (isNumber(tone)) tone += "";
|
|
740
807
|
const toHex = rgbArrayToHex(rgb);
|
|
741
808
|
const abs = tone.slice(0, 1);
|
|
742
809
|
if (abs === "-" || abs === "+") {
|
|
@@ -752,33 +819,27 @@ var getRgbTone = (rgb, tone) => {
|
|
|
752
819
|
};
|
|
753
820
|
|
|
754
821
|
// src/utils/sequence.js
|
|
755
|
-
var
|
|
822
|
+
var import_utils6 = __toESM(require_cjs(), 1);
|
|
756
823
|
|
|
757
824
|
// src/system/color.js
|
|
758
825
|
var getColor = (value, key, config) => {
|
|
759
826
|
const CONFIG2 = config || getActiveConfig();
|
|
760
827
|
if (!isString(value)) {
|
|
761
|
-
if (CONFIG2.verbose)
|
|
762
|
-
console.warn(value, "- type for color is not valid");
|
|
828
|
+
if (CONFIG2.verbose) console.warn(value, "- type for color is not valid");
|
|
763
829
|
return;
|
|
764
830
|
}
|
|
765
|
-
if (value.slice(0, 2) === "--")
|
|
766
|
-
|
|
767
|
-
if (key && value[key])
|
|
768
|
-
value = value[key];
|
|
831
|
+
if (value.slice(0, 2) === "--") return `var(${value})`;
|
|
832
|
+
if (key && value[key]) value = value[key];
|
|
769
833
|
const [name, alpha, tone] = isArray(value) ? value : value.split(" ");
|
|
770
834
|
const { COLOR: COLOR2, GRADIENT: GRADIENT2 } = CONFIG2;
|
|
771
835
|
let val = COLOR2[name] || GRADIENT2[name];
|
|
772
836
|
if (!val) {
|
|
773
|
-
if (CONFIG2.verbose)
|
|
774
|
-
console.warn("Can't find color ", name);
|
|
837
|
+
if (CONFIG2.verbose) console.warn("Can't find color ", name);
|
|
775
838
|
return value;
|
|
776
839
|
}
|
|
777
840
|
if (key) {
|
|
778
|
-
if (val[key])
|
|
779
|
-
|
|
780
|
-
else if (CONFIG2.verbose)
|
|
781
|
-
console.warn(value, " - does not have ", key);
|
|
841
|
+
if (val[key]) val = val[key];
|
|
842
|
+
else if (CONFIG2.verbose) console.warn(value, " - does not have ", key);
|
|
782
843
|
}
|
|
783
844
|
let rgb = val.rgb;
|
|
784
845
|
if (!rgb) {
|
|
@@ -788,32 +849,25 @@ var getColor = (value, key, config) => {
|
|
|
788
849
|
rgb = getRgbTone(rgb, tone);
|
|
789
850
|
val[tone] = { rgb, var: `${val.var}-${tone}` };
|
|
790
851
|
}
|
|
791
|
-
if (val[tone])
|
|
792
|
-
|
|
793
|
-
if (alpha)
|
|
794
|
-
return `rgba(${rgb}, ${alpha})`;
|
|
852
|
+
if (val[tone]) rgb = val[tone].rgb;
|
|
853
|
+
if (alpha) return `rgba(${rgb}, ${alpha})`;
|
|
795
854
|
return CONFIG2.useVariable ? `var(${val.var})` : `rgb(${rgb})`;
|
|
796
855
|
};
|
|
797
856
|
var getMediaColor = (value, globalTheme, config) => {
|
|
798
857
|
const CONFIG2 = config || getActiveConfig();
|
|
799
|
-
if (!globalTheme)
|
|
800
|
-
globalTheme = CONFIG2.globalTheme;
|
|
858
|
+
if (!globalTheme) globalTheme = CONFIG2.globalTheme;
|
|
801
859
|
if (!isString(value)) {
|
|
802
|
-
if (CONFIG2.verbose)
|
|
803
|
-
console.warn(value, "- type for color is not valid");
|
|
860
|
+
if (CONFIG2.verbose) console.warn(value, "- type for color is not valid");
|
|
804
861
|
return;
|
|
805
862
|
}
|
|
806
|
-
if (value.slice(0, 2) === "--")
|
|
807
|
-
return `var(${value})`;
|
|
863
|
+
if (value.slice(0, 2) === "--") return `var(${value})`;
|
|
808
864
|
const [name] = isArray(value) ? value : value.split(" ");
|
|
809
865
|
const { COLOR: COLOR2, GRADIENT: GRADIENT2 } = CONFIG2;
|
|
810
866
|
const val = COLOR2[name] || GRADIENT2[name];
|
|
811
867
|
const isObj = isObject(val);
|
|
812
|
-
if (isObj && val.value)
|
|
813
|
-
return getColor(value, `@${globalTheme}`, config);
|
|
868
|
+
if (isObj && val.value) return getColor(value, `@${globalTheme}`, config);
|
|
814
869
|
else if (isObj) {
|
|
815
|
-
if (globalTheme)
|
|
816
|
-
return getColor(value, `@${globalTheme}`, config);
|
|
870
|
+
if (globalTheme) return getColor(value, `@${globalTheme}`, config);
|
|
817
871
|
else {
|
|
818
872
|
const obj = {};
|
|
819
873
|
for (const mediaName in val) {
|
|
@@ -824,8 +878,7 @@ var getMediaColor = (value, globalTheme, config) => {
|
|
|
824
878
|
return obj;
|
|
825
879
|
}
|
|
826
880
|
} else {
|
|
827
|
-
if (CONFIG2.verbose)
|
|
828
|
-
console.warn("Can't find color", value);
|
|
881
|
+
if (CONFIG2.verbose) console.warn("Can't find color", value);
|
|
829
882
|
return value;
|
|
830
883
|
}
|
|
831
884
|
};
|
|
@@ -834,8 +887,7 @@ var setColor = (val, key, suffix) => {
|
|
|
834
887
|
if (isString(val) && val.slice(0, 2) === "--") {
|
|
835
888
|
val = getColor(val.slice(2));
|
|
836
889
|
if (!(val.includes("rgb") || val.includes("var") || val.includes("#"))) {
|
|
837
|
-
if (CONFIG2.verbose)
|
|
838
|
-
console.warn(val, "- referred but does not exist");
|
|
890
|
+
if (CONFIG2.verbose) console.warn(val, "- referred but does not exist");
|
|
839
891
|
val = val.split(" ")[0];
|
|
840
892
|
}
|
|
841
893
|
}
|
|
@@ -874,8 +926,7 @@ var setColor = (val, key, suffix) => {
|
|
|
874
926
|
};
|
|
875
927
|
var setGradient = (val, key, suffix) => {
|
|
876
928
|
const CONFIG2 = getActiveConfig();
|
|
877
|
-
if (isString(val) && val.slice(0, 2) === "--")
|
|
878
|
-
val = getColor(val.slice(2));
|
|
929
|
+
if (isString(val) && val.slice(0, 2) === "--") val = getColor(val.slice(2));
|
|
879
930
|
if (isArray(val)) {
|
|
880
931
|
return {
|
|
881
932
|
"@light": setGradient(val[0], key, "light"),
|
|
@@ -884,8 +935,7 @@ var setGradient = (val, key, suffix) => {
|
|
|
884
935
|
}
|
|
885
936
|
if (isObject(val)) {
|
|
886
937
|
const obj = {};
|
|
887
|
-
for (const variant in val)
|
|
888
|
-
obj[variant] = setGradient(val[variant], key, variant.slice(0, 1) === "@" ? variant.slice(1) : variant);
|
|
938
|
+
for (const variant in val) obj[variant] = setGradient(val[variant], key, variant.slice(0, 1) === "@" ? variant.slice(1) : variant);
|
|
889
939
|
return obj;
|
|
890
940
|
}
|
|
891
941
|
const CSSVar = `--gradient-${key}` + (suffix ? `-${suffix}` : "");
|