@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
|
@@ -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,59 +333,114 @@ __export(typography_exports, {
|
|
|
309
333
|
});
|
|
310
334
|
module.exports = __toCommonJS(typography_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 isString = (arg) => typeof arg === "string";
|
|
323
347
|
var isFunction = (arg) => typeof arg === "function";
|
|
324
348
|
var isNull = (arg) => arg === null;
|
|
325
349
|
var isArray = (arg) => Array.isArray(arg);
|
|
326
350
|
var isObjectLike = (arg) => {
|
|
327
|
-
if (arg === null)
|
|
328
|
-
return false;
|
|
351
|
+
if (arg === null) return false;
|
|
329
352
|
return typeof arg === "object";
|
|
330
353
|
};
|
|
331
354
|
var isUndefined = (arg) => {
|
|
332
355
|
return arg === void 0;
|
|
333
356
|
};
|
|
334
357
|
|
|
335
|
-
// ../../node_modules/@domql/utils/
|
|
336
|
-
var
|
|
337
|
-
return arr.reduce(
|
|
358
|
+
// ../../node_modules/@domql/utils/array.js
|
|
359
|
+
var unstackArrayOfObjects = (arr, exclude = []) => {
|
|
360
|
+
return arr.reduce(
|
|
361
|
+
(a, c) => deepMerge(a, deepClone(c, { exclude }), exclude),
|
|
362
|
+
{}
|
|
363
|
+
);
|
|
338
364
|
};
|
|
339
365
|
|
|
340
|
-
// ../../node_modules/@domql/utils/
|
|
341
|
-
var
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
366
|
+
// ../../node_modules/@domql/utils/keys.js
|
|
367
|
+
var STATE_METHODS = [
|
|
368
|
+
"update",
|
|
369
|
+
"parse",
|
|
370
|
+
"clean",
|
|
371
|
+
"create",
|
|
372
|
+
"destroy",
|
|
373
|
+
"add",
|
|
374
|
+
"toggle",
|
|
375
|
+
"remove",
|
|
376
|
+
"apply",
|
|
377
|
+
"set",
|
|
378
|
+
"reset",
|
|
379
|
+
"replace",
|
|
380
|
+
"quietReplace",
|
|
381
|
+
"quietUpdate",
|
|
382
|
+
"applyReplace",
|
|
383
|
+
"applyFunction",
|
|
384
|
+
"keys",
|
|
385
|
+
"values",
|
|
386
|
+
"ref",
|
|
387
|
+
"rootUpdate",
|
|
388
|
+
"parentUpdate",
|
|
389
|
+
"parent",
|
|
390
|
+
"__element",
|
|
391
|
+
"__depends",
|
|
392
|
+
"__ref",
|
|
393
|
+
"__children",
|
|
394
|
+
"root",
|
|
395
|
+
"setByPath",
|
|
396
|
+
"setPathCollection",
|
|
397
|
+
"removeByPath",
|
|
398
|
+
"removePathCollection",
|
|
399
|
+
"getByPath"
|
|
400
|
+
];
|
|
401
|
+
var PROPS_METHODS = ["update", "__element"];
|
|
402
|
+
var METHODS = [
|
|
403
|
+
"set",
|
|
404
|
+
"reset",
|
|
405
|
+
"update",
|
|
406
|
+
"remove",
|
|
407
|
+
"updateContent",
|
|
408
|
+
"removeContent",
|
|
409
|
+
"lookup",
|
|
410
|
+
"lookdown",
|
|
411
|
+
"lookdownAll",
|
|
412
|
+
"getRef",
|
|
413
|
+
"getPath",
|
|
414
|
+
"setNodeStyles",
|
|
415
|
+
"spotByPath",
|
|
416
|
+
"keys",
|
|
417
|
+
"parse",
|
|
418
|
+
"setProps",
|
|
419
|
+
"parseDeep",
|
|
420
|
+
"variables",
|
|
421
|
+
"if",
|
|
422
|
+
"log",
|
|
423
|
+
"verbose",
|
|
424
|
+
"warn",
|
|
425
|
+
"error",
|
|
426
|
+
"call",
|
|
427
|
+
"nextElement",
|
|
428
|
+
"previousElement"
|
|
429
|
+
];
|
|
430
|
+
var METHODS_EXL = [
|
|
431
|
+
...["node", "context", "extends", "__element", "__ref"],
|
|
432
|
+
...METHODS,
|
|
433
|
+
...STATE_METHODS,
|
|
434
|
+
...PROPS_METHODS
|
|
435
|
+
];
|
|
436
|
+
|
|
437
|
+
// ../../node_modules/@domql/utils/object.js
|
|
360
438
|
var merge = (element, obj, excludeFrom = []) => {
|
|
361
439
|
for (const e in obj) {
|
|
362
|
-
const
|
|
363
|
-
if (!
|
|
440
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, e);
|
|
441
|
+
if (!hasOwnProperty || excludeFrom.includes(e) || e.startsWith("__")) {
|
|
364
442
|
continue;
|
|
443
|
+
}
|
|
365
444
|
const elementProp = element[e];
|
|
366
445
|
const objProp = obj[e];
|
|
367
446
|
if (elementProp === void 0) {
|
|
@@ -370,11 +449,12 @@ var merge = (element, obj, excludeFrom = []) => {
|
|
|
370
449
|
}
|
|
371
450
|
return element;
|
|
372
451
|
};
|
|
373
|
-
var deepMerge = (element, extend, excludeFrom =
|
|
452
|
+
var deepMerge = (element, extend, excludeFrom = METHODS_EXL) => {
|
|
374
453
|
for (const e in extend) {
|
|
375
|
-
const
|
|
376
|
-
if (!
|
|
454
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty.call(extend, e);
|
|
455
|
+
if (!hasOwnProperty || excludeFrom.includes(e) || e.startsWith("__")) {
|
|
377
456
|
continue;
|
|
457
|
+
}
|
|
378
458
|
const elementProp = element[e];
|
|
379
459
|
const extendProp = extend[e];
|
|
380
460
|
if (isObjectLike(elementProp) && isObjectLike(extendProp)) {
|
|
@@ -392,7 +472,7 @@ var deepClone = (obj, options = {}) => {
|
|
|
392
472
|
cleanNull = false,
|
|
393
473
|
window: targetWindow,
|
|
394
474
|
visited = /* @__PURE__ */ new WeakMap(),
|
|
395
|
-
|
|
475
|
+
handleExtends = false
|
|
396
476
|
} = options;
|
|
397
477
|
if (!isObjectLike(obj) || isDOMNode(obj)) {
|
|
398
478
|
return obj;
|
|
@@ -400,40 +480,42 @@ var deepClone = (obj, options = {}) => {
|
|
|
400
480
|
if (visited.has(obj)) {
|
|
401
481
|
return visited.get(obj);
|
|
402
482
|
}
|
|
403
|
-
const
|
|
404
|
-
visited.set(obj,
|
|
483
|
+
const clone = targetWindow ? isArray(obj) ? new targetWindow.Array() : new targetWindow.Object() : isArray(obj) ? [] : {};
|
|
484
|
+
visited.set(obj, clone);
|
|
405
485
|
for (const key in obj) {
|
|
406
|
-
if (!Object.prototype.hasOwnProperty.call(obj, key))
|
|
407
|
-
|
|
408
|
-
if (exclude.includes(key) || key.startsWith("__") || key === "__proto__")
|
|
486
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
|
|
487
|
+
if (exclude.includes(key) || key.startsWith("__") || key === "__proto__") {
|
|
409
488
|
continue;
|
|
489
|
+
}
|
|
410
490
|
const value = obj[key];
|
|
411
|
-
if (cleanUndefined && isUndefined(value) || cleanNull && isNull(value))
|
|
491
|
+
if (cleanUndefined && isUndefined(value) || cleanNull && isNull(value)) {
|
|
412
492
|
continue;
|
|
493
|
+
}
|
|
413
494
|
if (isDOMNode(value)) {
|
|
414
|
-
|
|
495
|
+
clone[key] = value;
|
|
415
496
|
continue;
|
|
416
497
|
}
|
|
417
|
-
if (
|
|
418
|
-
|
|
498
|
+
if (handleExtends && key === "extends" && isArray(value)) {
|
|
499
|
+
clone[key] = unstackArrayOfObjects(value, exclude);
|
|
419
500
|
continue;
|
|
420
501
|
}
|
|
421
502
|
if (isFunction(value) && targetWindow) {
|
|
422
|
-
|
|
503
|
+
clone[key] = targetWindow.eval("(" + value.toString() + ")");
|
|
423
504
|
continue;
|
|
424
505
|
}
|
|
425
506
|
if (isObjectLike(value)) {
|
|
426
|
-
|
|
507
|
+
clone[key] = deepClone(value, {
|
|
508
|
+
...options,
|
|
427
509
|
visited
|
|
428
|
-
})
|
|
510
|
+
});
|
|
429
511
|
} else {
|
|
430
|
-
|
|
512
|
+
clone[key] = value;
|
|
431
513
|
}
|
|
432
514
|
}
|
|
433
|
-
return
|
|
515
|
+
return clone;
|
|
434
516
|
};
|
|
435
517
|
|
|
436
|
-
// ../../node_modules/@domql/utils/
|
|
518
|
+
// ../../node_modules/@domql/utils/cookie.js
|
|
437
519
|
var isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
|
|
438
520
|
|
|
439
521
|
// src/defaultConfig/index.js
|
|
@@ -662,11 +744,8 @@ var isScalingUnit = (unit) => {
|
|
|
662
744
|
return unit === "em" || unit === "rem" || unit === "vw" || unit === "vh" || unit === "vmax" || unit === "vmin";
|
|
663
745
|
};
|
|
664
746
|
|
|
665
|
-
// src/utils/color.js
|
|
666
|
-
var import_globals4 = __toESM(require_cjs(), 1);
|
|
667
|
-
|
|
668
747
|
// src/utils/sequence.js
|
|
669
|
-
var
|
|
748
|
+
var import_utils6 = __toESM(require_cjs(), 1);
|
|
670
749
|
var numToLetterMap = {
|
|
671
750
|
"-6": "U",
|
|
672
751
|
"-5": "V",
|
|
@@ -712,8 +791,7 @@ var setSequenceValue = (props, sequenceProps) => {
|
|
|
712
791
|
var setScalingVar = (key, sequenceProps) => {
|
|
713
792
|
const { base, type, unit } = sequenceProps;
|
|
714
793
|
const defaultVal = (isScalingUnit(unit) ? 1 : base) + unit;
|
|
715
|
-
if (key === 0)
|
|
716
|
-
return defaultVal;
|
|
794
|
+
if (key === 0) return defaultVal;
|
|
717
795
|
const prefix = "--" + (type && type.replace(".", "-"));
|
|
718
796
|
const ratioVar = `${prefix}-ratio`;
|
|
719
797
|
if (key > 0) {
|
|
@@ -750,10 +828,8 @@ var generateSubSequence = (props, sequenceProps) => {
|
|
|
750
828
|
const diffRounded = ~~next - ~~value;
|
|
751
829
|
let arr;
|
|
752
830
|
const [first, middle, second] = getSubratioDifference(value, ratio);
|
|
753
|
-
if (diffRounded > 16)
|
|
754
|
-
|
|
755
|
-
else
|
|
756
|
-
arr = [first, second];
|
|
831
|
+
if (diffRounded > 16) arr = [first, middle, second];
|
|
832
|
+
else arr = [first, second];
|
|
757
833
|
arr.forEach((v, k) => {
|
|
758
834
|
const scaling = ~~(v / base * 1e3) / 1e3;
|
|
759
835
|
const newVar = variable + (k + 1);
|
|
@@ -795,8 +871,7 @@ var generateSequence = (sequenceProps) => {
|
|
|
795
871
|
index: key
|
|
796
872
|
};
|
|
797
873
|
setSequenceValue(props, sequenceProps);
|
|
798
|
-
if (subSequence)
|
|
799
|
-
generateSubSequence(props, sequenceProps);
|
|
874
|
+
if (subSequence) generateSubSequence(props, sequenceProps);
|
|
800
875
|
}
|
|
801
876
|
return sequenceProps;
|
|
802
877
|
};
|
|
@@ -808,13 +883,11 @@ var getSequenceValue = (value = "A", sequenceProps) => {
|
|
|
808
883
|
unit = UNIT2.default,
|
|
809
884
|
useVariable
|
|
810
885
|
} = sequenceProps;
|
|
811
|
-
if (isString(value) && value.slice(0, 2) === "--")
|
|
812
|
-
|
|
813
|
-
const prefix = `--${(0, import_utils4.toDashCase)(sequenceProps.type.replace(".", "-"))}-`;
|
|
886
|
+
if (isString(value) && value.slice(0, 2) === "--") return `var(${value})`;
|
|
887
|
+
const prefix = `--${(0, import_utils6.toDashCase)(sequenceProps.type.replace(".", "-"))}-`;
|
|
814
888
|
const startsWithDashOrLetterRegex = /^-?[a-zA-Z]/i;
|
|
815
889
|
const startsWithDashOrLetter = startsWithDashOrLetterRegex.test(value);
|
|
816
|
-
if (value === "none" || value === "auto" || value === "unset" || value === "inherit" || value === "fit-content" || value === "min-content" || value === "max-content" || value.includes("calc") || value.includes("var") || !startsWithDashOrLetter)
|
|
817
|
-
return value;
|
|
890
|
+
if (value === "none" || value === "auto" || value === "unset" || value === "inherit" || value === "fit-content" || value === "min-content" || value === "max-content" || value.includes("calc") || value.includes("var") || !startsWithDashOrLetter) return value;
|
|
818
891
|
const letterVal = value.toUpperCase();
|
|
819
892
|
const isNegative = letterVal.slice(0, 1) === "-" ? "-" : "";
|
|
820
893
|
let absValue = isNegative ? letterVal.slice(1) : letterVal;
|
|
@@ -838,8 +911,7 @@ var getSequenceValue = (value = "A", sequenceProps) => {
|
|
|
838
911
|
return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
|
|
839
912
|
}
|
|
840
913
|
if (!sequence[absValue] && absValue.length === 2) {
|
|
841
|
-
if (CONFIG2.verbose)
|
|
842
|
-
console.warn(absValue, "- value is not found because `subSequence` is set to false");
|
|
914
|
+
if (CONFIG2.verbose) console.warn(absValue, "- value is not found because `subSequence` is set to false");
|
|
843
915
|
absValue = absValue.slice(0, 1);
|
|
844
916
|
}
|
|
845
917
|
if (useVariable || CONFIG2.useVariable) {
|
|
@@ -847,8 +919,7 @@ var getSequenceValue = (value = "A", sequenceProps) => {
|
|
|
847
919
|
return isNegative ? `calc(${varValue2} * -1)` : varValue2;
|
|
848
920
|
}
|
|
849
921
|
const sequenceItem = sequence ? sequence[absValue] : null;
|
|
850
|
-
if (!sequenceItem)
|
|
851
|
-
return console.warn("can't find", sequence, absValue);
|
|
922
|
+
if (!sequenceItem) return console.warn("can't find", sequence, absValue);
|
|
852
923
|
if (unit === "ms" || unit === "s") {
|
|
853
924
|
return isNegative + sequenceItem.val + unit;
|
|
854
925
|
}
|
|
@@ -857,12 +928,10 @@ var getSequenceValue = (value = "A", sequenceProps) => {
|
|
|
857
928
|
var getSequenceValuePropertyPair = (value, propertyName, sequenceProps) => {
|
|
858
929
|
if (typeof value !== "string") {
|
|
859
930
|
const CONFIG2 = getActiveConfig();
|
|
860
|
-
if (CONFIG2.verbose)
|
|
861
|
-
console.warn(propertyName, value, "is not a string");
|
|
931
|
+
if (CONFIG2.verbose) console.warn(propertyName, value, "is not a string");
|
|
862
932
|
return { [propertyName]: value };
|
|
863
933
|
}
|
|
864
|
-
if (value === "-" || value === "")
|
|
865
|
-
return {};
|
|
934
|
+
if (value === "-" || value === "") return {};
|
|
866
935
|
return { [propertyName]: getSequenceValue(value, sequenceProps) };
|
|
867
936
|
};
|
|
868
937
|
var findHeadingLetter = (h1Matches, index) => numToLetterMap[h1Matches - index];
|
|
@@ -922,23 +991,19 @@ var applyMediaSequenceVars = (FACTORY2, media, options = {}) => {
|
|
|
922
991
|
const { mediaRegenerate } = FACTORY2;
|
|
923
992
|
const { sequence, scales } = FACTORY2[media];
|
|
924
993
|
const query = MEDIA2[mediaName];
|
|
925
|
-
if (!query && CONFIG2.verbose)
|
|
926
|
-
console.warn("Can't find media query ", query);
|
|
994
|
+
if (!query && CONFIG2.verbose) console.warn("Can't find media query ", query);
|
|
927
995
|
if (!mediaRegenerate) {
|
|
928
996
|
let underMediaQuery = CSS_VARS2[`@media ${query}`];
|
|
929
|
-
if (!underMediaQuery)
|
|
930
|
-
underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
|
|
997
|
+
if (!underMediaQuery) underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
|
|
931
998
|
applySequenceGlobalVars(underMediaQuery, FACTORY2[media], options);
|
|
932
999
|
return;
|
|
933
1000
|
}
|
|
934
1001
|
for (const key in sequence) {
|
|
935
1002
|
const item = sequence[key];
|
|
936
1003
|
const value = (isScalingUnit(unit) ? scales[key] : sequence[key].val) + unit;
|
|
937
|
-
if (!query && CONFIG2.verbose)
|
|
938
|
-
console.warn("Can't find query ", query);
|
|
1004
|
+
if (!query && CONFIG2.verbose) console.warn("Can't find query ", query);
|
|
939
1005
|
let underMediaQuery = CSS_VARS2[`@media ${query}`];
|
|
940
|
-
if (!underMediaQuery)
|
|
941
|
-
underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
|
|
1006
|
+
if (!underMediaQuery) underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
|
|
942
1007
|
underMediaQuery[item.variable] = `var(${item.variable + "_" + mediaName})`;
|
|
943
1008
|
CSS_VARS2[item.variable + "_" + mediaName] = value;
|
|
944
1009
|
}
|
|
@@ -951,8 +1016,7 @@ var runThroughMedia = (FACTORY2) => {
|
|
|
951
1016
|
for (const prop in FACTORY2) {
|
|
952
1017
|
const isPropMedia = prop.slice(0, 1) === "@";
|
|
953
1018
|
const mediaValue = FACTORY2[prop];
|
|
954
|
-
if (!isPropMedia)
|
|
955
|
-
continue;
|
|
1019
|
+
if (!isPropMedia) continue;
|
|
956
1020
|
const { mediaRegenerate } = FACTORY2;
|
|
957
1021
|
const mediaName = prop.slice(1);
|
|
958
1022
|
const {
|