sculp-js 1.13.1 → 1.13.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/README.md +10 -11
- package/dist/cjs/_virtual/_commonjsHelpers.js +13 -0
- package/{lib → dist}/cjs/array.js +1 -1
- package/{lib → dist}/cjs/async.js +1 -1
- package/{lib/cjs/we-decode.js → dist/cjs/base64.js} +53 -44
- package/{lib → dist}/cjs/clipboard.js +4 -2
- package/{lib → dist}/cjs/cloneDeep.js +1 -1
- package/{lib → dist}/cjs/cookie.js +1 -1
- package/{lib → dist}/cjs/date.js +1 -1
- package/{lib → dist}/cjs/dom.js +1 -1
- package/{lib → dist}/cjs/download.js +4 -2
- package/dist/cjs/easing.js +75 -0
- package/{lib → dist}/cjs/file.js +7 -3
- package/{lib → dist}/cjs/func.js +1 -1
- package/{lib → dist}/cjs/index.js +11 -8
- package/{lib → dist}/cjs/math.js +1 -1
- package/dist/cjs/node_modules/bezier-easing/src/index.js +123 -0
- package/{lib → dist}/cjs/number.js +1 -1
- package/{lib → dist}/cjs/object.js +1 -1
- package/{lib → dist}/cjs/path.js +1 -1
- package/{lib → dist}/cjs/qs.js +1 -1
- package/{lib → dist}/cjs/random.js +1 -1
- package/{lib → dist}/cjs/string.js +1 -1
- package/{lib → dist}/cjs/tooltip.js +5 -2
- package/{lib → dist}/cjs/tree.js +9 -23
- package/{lib → dist}/cjs/type.js +8 -1
- package/{lib → dist}/cjs/unique.js +1 -1
- package/{lib → dist}/cjs/url.js +1 -1
- package/{lib → dist}/cjs/validator.js +1 -1
- package/{lib → dist}/cjs/variable.js +1 -1
- package/{lib → dist}/cjs/watermark.js +4 -2
- package/{lib/es → dist/esm}/array.js +1 -1
- package/{lib/es → dist/esm}/async.js +1 -1
- package/{lib/es/we-decode.js → dist/esm/base64.js} +52 -45
- package/{lib/es → dist/esm}/clipboard.js +4 -2
- package/{lib/es → dist/esm}/cloneDeep.js +1 -1
- package/{lib/es → dist/esm}/cookie.js +1 -1
- package/{lib/es → dist/esm}/date.js +1 -1
- package/{lib/es → dist/esm}/dom.js +1 -1
- package/{lib/es → dist/esm}/download.js +4 -2
- package/{lib/es → dist/esm}/easing.js +34 -2
- package/{lib/es → dist/esm}/file.js +7 -3
- package/{lib/es → dist/esm}/func.js +1 -1
- package/{lib/es → dist/esm}/index.js +4 -5
- package/{lib/es → dist/esm}/math.js +1 -1
- package/{lib/es → dist/esm}/number.js +1 -1
- package/{lib/es → dist/esm}/object.js +1 -1
- package/{lib/es → dist/esm}/path.js +1 -1
- package/{lib/es → dist/esm}/qs.js +1 -1
- package/{lib/es → dist/esm}/random.js +1 -1
- package/{lib/es → dist/esm}/string.js +1 -1
- package/{lib/es → dist/esm}/tooltip.js +5 -2
- package/{lib/es → dist/esm}/tree.js +10 -24
- package/{lib/es → dist/esm}/type.js +8 -2
- package/{lib/es → dist/esm}/unique.js +1 -1
- package/{lib/es → dist/esm}/url.js +1 -1
- package/{lib/es → dist/esm}/validator.js +1 -1
- package/{lib/es → dist/esm}/variable.js +1 -1
- package/{lib/es → dist/esm}/watermark.js +4 -2
- package/dist/types/array.d.ts +50 -0
- package/dist/types/array.d.ts.map +1 -0
- package/dist/types/async.d.ts +37 -0
- package/dist/types/async.d.ts.map +1 -0
- package/dist/types/base64.d.ts +25 -0
- package/dist/types/base64.d.ts.map +1 -0
- package/dist/types/clipboard.d.ts +20 -0
- package/dist/types/clipboard.d.ts.map +1 -0
- package/dist/types/cloneDeep.d.ts +12 -0
- package/dist/types/cloneDeep.d.ts.map +1 -0
- package/dist/types/cookie.d.ts +19 -0
- package/dist/types/cookie.d.ts.map +1 -0
- package/dist/types/core-index.d.ts +17 -0
- package/dist/types/core-index.d.ts.map +1 -0
- package/dist/types/date.d.ts +74 -0
- package/dist/types/date.d.ts.map +1 -0
- package/dist/types/dom.d.ts +74 -0
- package/dist/types/dom.d.ts.map +1 -0
- package/dist/types/download.d.ts +47 -0
- package/dist/types/download.d.ts.map +1 -0
- package/dist/types/easing.d.ts +32 -0
- package/dist/types/easing.d.ts.map +1 -0
- package/dist/types/file.d.ts +44 -0
- package/dist/types/file.d.ts.map +1 -0
- package/dist/types/func.d.ts +50 -0
- package/dist/types/func.d.ts.map +1 -0
- package/dist/types/index.d.ts +28 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3278 -0
- package/dist/types/math.d.ts +36 -0
- package/dist/types/math.d.ts.map +1 -0
- package/dist/types/number.d.ts +49 -0
- package/dist/types/number.d.ts.map +1 -0
- package/dist/types/object.d.ts +70 -0
- package/dist/types/object.d.ts.map +1 -0
- package/dist/types/path.d.ts +14 -0
- package/dist/types/path.d.ts.map +1 -0
- package/dist/types/qs.d.ts +22 -0
- package/dist/types/qs.d.ts.map +1 -0
- package/dist/types/random.d.ts +27 -0
- package/dist/types/random.d.ts.map +1 -0
- package/dist/types/string.d.ts +67 -0
- package/dist/types/string.d.ts.map +1 -0
- package/dist/types/tooltip.d.ts +36 -0
- package/dist/types/tooltip.d.ts.map +1 -0
- package/dist/types/tree.d.ts +99 -0
- package/dist/types/tree.d.ts.map +1 -0
- package/dist/types/type.d.ts +128 -0
- package/dist/types/type.d.ts.map +1 -0
- package/dist/types/unique.d.ts +21 -0
- package/dist/types/unique.d.ts.map +1 -0
- package/dist/types/url.d.ts +46 -0
- package/dist/types/url.d.ts.map +1 -0
- package/dist/types/validator.d.ts +67 -0
- package/dist/types/validator.d.ts.map +1 -0
- package/dist/types/variable.d.ts +71 -0
- package/dist/types/variable.d.ts.map +1 -0
- package/dist/types/watermark.d.ts +19 -0
- package/dist/types/watermark.d.ts.map +1 -0
- package/dist/umd/index.min.js +6 -0
- package/package.json +234 -17
- package/lib/cjs/base64.js +0 -62
- package/lib/cjs/easing.js +0 -40
- package/lib/cjs/isEqual.js +0 -133
- package/lib/es/base64.js +0 -59
- package/lib/es/isEqual.js +0 -131
- package/lib/index.d.ts +0 -1214
- package/lib/umd/index.js +0 -6
package/{lib → dist}/cjs/tree.js
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* sculp-js v1.13.
|
|
2
|
+
* sculp-js v1.13.3-beta.0
|
|
3
3
|
* (c) 2023-present chandq
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -17,7 +17,7 @@ const defaultSearchTreeOptions = {
|
|
|
17
17
|
ignoreCase: true
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
|
-
* 树遍历函数(支持continue和break操作),
|
|
20
|
+
* 树遍历函数(支持continue和break操作), 可用于遍历Array和NodeList类型的数据
|
|
21
21
|
* @param {ArrayLike<V>} tree 树形数据
|
|
22
22
|
* @param {Function} iterator 迭代函数, 返回值为true时continue, 返回值为false时break
|
|
23
23
|
* @param {options} options 支持定制子元素名称、反向遍历、广度优先遍历,默认{
|
|
@@ -30,9 +30,10 @@ const defaultSearchTreeOptions = {
|
|
|
30
30
|
function forEachDeep(tree, iterator, options = {
|
|
31
31
|
childField: 'children',
|
|
32
32
|
reverse: false,
|
|
33
|
-
breadthFirst: false
|
|
33
|
+
breadthFirst: false,
|
|
34
|
+
isDomNode: false
|
|
34
35
|
}) {
|
|
35
|
-
const { childField = 'children', reverse = false, breadthFirst = false } = type.isObject(options) ? options : {};
|
|
36
|
+
const { childField = 'children', reverse = false, breadthFirst = false, isDomNode = false } = type.isObject(options) ? options : {};
|
|
36
37
|
let isBreak = false;
|
|
37
38
|
const queue = [];
|
|
38
39
|
const walk = (arr, parent, level = 0) => {
|
|
@@ -55,9 +56,7 @@ function forEachDeep(tree, iterator, options = {
|
|
|
55
56
|
else if (re === true) {
|
|
56
57
|
continue;
|
|
57
58
|
}
|
|
58
|
-
|
|
59
|
-
if (item && Array.isArray(item[childField])) {
|
|
60
|
-
// @ts-ignore
|
|
59
|
+
if (item && (isDomNode ? type.isNodeList(item[childField]) : Array.isArray(item[childField]))) {
|
|
61
60
|
walk(item[childField], item, level + 1);
|
|
62
61
|
}
|
|
63
62
|
}
|
|
@@ -66,8 +65,6 @@ function forEachDeep(tree, iterator, options = {
|
|
|
66
65
|
// Process queue
|
|
67
66
|
while (queue.length > 0 && !isBreak) {
|
|
68
67
|
const current = queue.shift();
|
|
69
|
-
// iterate(info);
|
|
70
|
-
// @ts-ignore
|
|
71
68
|
const { item, index, array, tree, parent, level } = current;
|
|
72
69
|
const re = iterator(item, index, array, tree, parent, level);
|
|
73
70
|
if (re === false) {
|
|
@@ -77,9 +74,7 @@ function forEachDeep(tree, iterator, options = {
|
|
|
77
74
|
else if (re === true) {
|
|
78
75
|
continue;
|
|
79
76
|
}
|
|
80
|
-
|
|
81
|
-
if (item && Array.isArray(item[childField])) {
|
|
82
|
-
// @ts-ignore
|
|
77
|
+
if (item && (isDomNode ? type.isNodeList(item[childField]) : Array.isArray(item[childField]))) {
|
|
83
78
|
walk(item[childField], item, level + 1);
|
|
84
79
|
}
|
|
85
80
|
}
|
|
@@ -105,9 +100,7 @@ function forEachDeep(tree, iterator, options = {
|
|
|
105
100
|
else if (re === true) {
|
|
106
101
|
continue;
|
|
107
102
|
}
|
|
108
|
-
|
|
109
|
-
if (item && Array.isArray(item[childField])) {
|
|
110
|
-
// @ts-ignore
|
|
103
|
+
if (item && (isDomNode ? type.isNodeList(item[childField]) : Array.isArray(item[childField]))) {
|
|
111
104
|
walk(item[childField], item, level + 1);
|
|
112
105
|
}
|
|
113
106
|
}
|
|
@@ -117,7 +110,6 @@ function forEachDeep(tree, iterator, options = {
|
|
|
117
110
|
const current = queue.shift();
|
|
118
111
|
if (!current)
|
|
119
112
|
break;
|
|
120
|
-
// @ts-ignore
|
|
121
113
|
const { item, index, array, tree, parent, level } = current;
|
|
122
114
|
const re = iterator(item, index, array, tree, parent, level);
|
|
123
115
|
if (re === false) {
|
|
@@ -127,9 +119,7 @@ function forEachDeep(tree, iterator, options = {
|
|
|
127
119
|
else if (re === true) {
|
|
128
120
|
continue;
|
|
129
121
|
}
|
|
130
|
-
|
|
131
|
-
if (item && Array.isArray(item[childField])) {
|
|
132
|
-
// @ts-ignore
|
|
122
|
+
if (item && (isDomNode ? type.isNodeList(item[childField]) : Array.isArray(item[childField]))) {
|
|
133
123
|
walk(item[childField], item, level + 1);
|
|
134
124
|
}
|
|
135
125
|
}
|
|
@@ -175,10 +165,8 @@ function mapDeep(tree, iterator, options = {
|
|
|
175
165
|
continue;
|
|
176
166
|
}
|
|
177
167
|
newTree.push(object.objectOmit(re, [childField]));
|
|
178
|
-
// @ts-ignore
|
|
179
168
|
if (item && Array.isArray(item[childField])) {
|
|
180
169
|
newTree[newTree.length - 1][childField] = [];
|
|
181
|
-
// @ts-ignore
|
|
182
170
|
walk(item[childField], item, newTree[newTree.length - 1][childField], level + 1);
|
|
183
171
|
}
|
|
184
172
|
else {
|
|
@@ -202,10 +190,8 @@ function mapDeep(tree, iterator, options = {
|
|
|
202
190
|
continue;
|
|
203
191
|
}
|
|
204
192
|
newTree.push(object.objectOmit(re, [childField]));
|
|
205
|
-
// @ts-ignore
|
|
206
193
|
if (item && Array.isArray(item[childField])) {
|
|
207
194
|
newTree[newTree.length - 1][childField] = [];
|
|
208
|
-
// @ts-ignore
|
|
209
195
|
walk(item[childField], item, newTree[newTree.length - 1][childField], level + 1);
|
|
210
196
|
}
|
|
211
197
|
else {
|
package/{lib → dist}/cjs/type.js
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* sculp-js v1.13.
|
|
2
|
+
* sculp-js v1.13.3-beta.0
|
|
3
3
|
* (c) 2023-present chandq
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -128,6 +128,12 @@ function isEmpty(value) {
|
|
|
128
128
|
}
|
|
129
129
|
return !Object.keys(value).length;
|
|
130
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Checks if `value` is an NodeList object
|
|
133
|
+
*/
|
|
134
|
+
function isNodeList(value) {
|
|
135
|
+
return isUndefined(NodeList) ? false : NodeList.prototype.isPrototypeOf(value);
|
|
136
|
+
}
|
|
131
137
|
|
|
132
138
|
exports.arrayLike = arrayLike;
|
|
133
139
|
exports.default = typeIs;
|
|
@@ -140,6 +146,7 @@ exports.isError = isError;
|
|
|
140
146
|
exports.isFunction = isFunction;
|
|
141
147
|
exports.isJsonString = isJsonString;
|
|
142
148
|
exports.isNaN = isNaN;
|
|
149
|
+
exports.isNodeList = isNodeList;
|
|
143
150
|
exports.isNull = isNull;
|
|
144
151
|
exports.isNullOrUnDef = isNullOrUnDef;
|
|
145
152
|
exports.isNullish = isNullOrUnDef;
|
package/{lib → dist}/cjs/url.js
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* sculp-js v1.13.
|
|
2
|
+
* sculp-js v1.13.3-beta.0
|
|
3
3
|
* (c) 2023-present chandq
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -62,7 +62,7 @@ function genCanvasWM(content = '请勿外传', canvasWM) {
|
|
|
62
62
|
const MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
|
|
63
63
|
if (MutationObserver) {
|
|
64
64
|
let mo = new MutationObserver(function () {
|
|
65
|
-
|
|
65
|
+
let __wm = document.querySelector(`#${watermarkId}`); // 只在__wm元素变动才重新调用 __canvasWM
|
|
66
66
|
if (!__wm) {
|
|
67
67
|
// 避免一直触发
|
|
68
68
|
// console.log('regenerate watermark by delete::')
|
|
@@ -80,6 +80,8 @@ function genCanvasWM(content = '请勿外传', canvasWM) {
|
|
|
80
80
|
mo.disconnect();
|
|
81
81
|
mo = null;
|
|
82
82
|
container.removeChild(__wm);
|
|
83
|
+
// @ts-ignore
|
|
84
|
+
__wm = null;
|
|
83
85
|
genCanvasWM(content, canvasWM);
|
|
84
86
|
}
|
|
85
87
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* sculp-js v1.13.
|
|
2
|
+
* sculp-js v1.13.3-beta.0
|
|
3
3
|
* (c) 2023-present chandq
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { getGlobal } from './func.js';
|
|
8
|
+
import { isNullOrUnDef } from './type.js';
|
|
9
|
+
|
|
7
10
|
const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
8
11
|
// eslint-disable-next-line
|
|
9
12
|
const b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
|
|
@@ -57,48 +60,52 @@ function weAtob(string) {
|
|
|
57
60
|
}
|
|
58
61
|
return result;
|
|
59
62
|
}
|
|
60
|
-
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
//
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
//
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
//
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
63
|
+
function stringToUint8Array(str) {
|
|
64
|
+
const utf8 = encodeURIComponent(str); // 将字符串转换为 UTF-8 编码
|
|
65
|
+
const uint8Array = new Uint8Array(utf8.length); // 创建 Uint8Array
|
|
66
|
+
for (let i = 0; i < utf8.length; i++) {
|
|
67
|
+
uint8Array[i] = utf8.charCodeAt(i); // 填充 Uint8Array
|
|
68
|
+
}
|
|
69
|
+
return uint8Array;
|
|
70
|
+
}
|
|
71
|
+
function uint8ArrayToString(uint8Array) {
|
|
72
|
+
const utf8 = String.fromCharCode.apply(null, uint8Array); // 将 Uint8Array 转为字符串
|
|
73
|
+
return decodeURIComponent(utf8); // 将 UTF-8 字符串解码回正常字符串
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* 将base64编码的字符串转换为原始字符串,包括对中文内容的处理(高性能,且支持Web、Node、小程序等任意平台)
|
|
77
|
+
* @param base64 base64编码的字符串
|
|
78
|
+
* @returns 原始字符串,包括中文内容
|
|
79
|
+
*/
|
|
80
|
+
function b64decode(base64) {
|
|
81
|
+
const binaryString = !isNullOrUnDef(getGlobal('atob')) ? getGlobal('atob')(base64) : weAtob(base64);
|
|
82
|
+
const len = binaryString.length;
|
|
83
|
+
const bytes = new Uint8Array(len);
|
|
84
|
+
for (let i = 0; i < len; i++) {
|
|
85
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
86
|
+
}
|
|
87
|
+
// 使用TextDecoder将Uint8Array转换为原始字符串,包括中文内容
|
|
88
|
+
return !isNullOrUnDef(getGlobal('TextDecoder'))
|
|
89
|
+
? new (getGlobal('TextDecoder'))('utf-8').decode(bytes)
|
|
90
|
+
: uint8ArrayToString(bytes);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* 将原始字符串,包括中文内容,转换为base64编码的字符串(高性能,且支持Web、Node、小程序等任意平台)
|
|
94
|
+
* @param rawStr 原始字符串,包括中文内容
|
|
95
|
+
* @returns base64编码的字符串
|
|
96
|
+
*/
|
|
97
|
+
function b64encode(rawStr) {
|
|
98
|
+
const utf8Array = !isNullOrUnDef(getGlobal('TextEncoder'))
|
|
99
|
+
? new (getGlobal('TextEncoder'))().encode(rawStr)
|
|
100
|
+
: stringToUint8Array(rawStr);
|
|
101
|
+
// 将 Uint8Array 转换为二进制字符串
|
|
102
|
+
let binaryString = '';
|
|
103
|
+
const len = utf8Array.length;
|
|
104
|
+
for (let i = 0; i < len; i++) {
|
|
105
|
+
binaryString += String.fromCharCode(utf8Array[i]);
|
|
106
|
+
}
|
|
107
|
+
// 将二进制字符串转换为base64编码的字符串
|
|
108
|
+
return !isNullOrUnDef(getGlobal('btoa')) ? getGlobal('btoa')(binaryString) : weBtoa(binaryString);
|
|
109
|
+
}
|
|
103
110
|
|
|
104
|
-
export { weAtob, weBtoa };
|
|
111
|
+
export { b64decode, b64encode, weAtob, weBtoa };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* sculp-js v1.13.
|
|
2
|
+
* sculp-js v1.13.3-beta.0
|
|
3
3
|
* (c) 2023-present chandq
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -40,7 +40,7 @@ function copyText(text, options) {
|
|
|
40
40
|
*/
|
|
41
41
|
function fallbackCopyText(text, options) {
|
|
42
42
|
const { successCallback = void 0, failCallback = void 0, container = document.body } = isNullOrUnDef(options) ? {} : options;
|
|
43
|
-
|
|
43
|
+
let textEl = createFakeElement(text);
|
|
44
44
|
container.appendChild(textEl);
|
|
45
45
|
select(textEl);
|
|
46
46
|
try {
|
|
@@ -56,6 +56,8 @@ function fallbackCopyText(text, options) {
|
|
|
56
56
|
}
|
|
57
57
|
finally {
|
|
58
58
|
container.removeChild(textEl);
|
|
59
|
+
// @ts-ignore
|
|
60
|
+
textEl = null;
|
|
59
61
|
window.getSelection()?.removeAllRanges(); // 清除选区
|
|
60
62
|
}
|
|
61
63
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* sculp-js v1.13.
|
|
2
|
+
* sculp-js v1.13.3-beta.0
|
|
3
3
|
* (c) 2023-present chandq
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -22,7 +22,7 @@ function downloadURL(url, params) {
|
|
|
22
22
|
* @param {Function} callback
|
|
23
23
|
*/
|
|
24
24
|
function downloadHref(href, filename, callback) {
|
|
25
|
-
|
|
25
|
+
let eleLink = document.createElement('a');
|
|
26
26
|
eleLink.download = filename;
|
|
27
27
|
eleLink.style.display = 'none';
|
|
28
28
|
eleLink.href = href;
|
|
@@ -30,6 +30,8 @@ function downloadHref(href, filename, callback) {
|
|
|
30
30
|
eleLink.click();
|
|
31
31
|
setTimeout(() => {
|
|
32
32
|
document.body.removeChild(eleLink);
|
|
33
|
+
// @ts-ignore
|
|
34
|
+
eleLink = null;
|
|
33
35
|
if (isFunction(callback)) {
|
|
34
36
|
callback();
|
|
35
37
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* sculp-js v1.13.
|
|
2
|
+
* sculp-js v1.13.3-beta.0
|
|
3
3
|
* (c) 2023-present chandq
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -15,6 +15,19 @@ const easingDefines = {
|
|
|
15
15
|
'ease-out': [0, 0, 0.58, 1],
|
|
16
16
|
'ease-in-out': [0.42, 0, 0.58, 1]
|
|
17
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* 设置缓存定义
|
|
20
|
+
* @param {string} name
|
|
21
|
+
* @param {EasingDefine} define
|
|
22
|
+
*/
|
|
23
|
+
function setEasing(name, define) {
|
|
24
|
+
easingDefines[name] = define;
|
|
25
|
+
}
|
|
26
|
+
function getEasing(name) {
|
|
27
|
+
if (name)
|
|
28
|
+
return easingDefines[name];
|
|
29
|
+
return easingDefines;
|
|
30
|
+
}
|
|
18
31
|
/**
|
|
19
32
|
* 缓冲函数化,用于 js 计算缓冲进度
|
|
20
33
|
* @param {EasingNameOrDefine} [name=linear]
|
|
@@ -34,5 +47,24 @@ function easingFunctional(name) {
|
|
|
34
47
|
}
|
|
35
48
|
return (input) => fn(Math.max(0, Math.min(input, 1)));
|
|
36
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* 缓冲字符化,用于 css 设置缓冲属性
|
|
52
|
+
* @param {EasingNameOrDefine} name
|
|
53
|
+
* @returns {string}
|
|
54
|
+
*/
|
|
55
|
+
function easingStringify(name) {
|
|
56
|
+
let bezierDefine;
|
|
57
|
+
if (isArray(name)) {
|
|
58
|
+
bezierDefine = name;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
const define = easingDefines[name];
|
|
62
|
+
if (!define) {
|
|
63
|
+
throw new Error(`${name} 缓冲函数未定义`);
|
|
64
|
+
}
|
|
65
|
+
bezierDefine = define;
|
|
66
|
+
}
|
|
67
|
+
return `cubic-bezier(${bezierDefine.join(',')})`;
|
|
68
|
+
}
|
|
37
69
|
|
|
38
|
-
export { easingFunctional };
|
|
70
|
+
export { easingFunctional, easingStringify, getEasing, setEasing };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* sculp-js v1.13.
|
|
2
|
+
* sculp-js v1.13.3-beta.0
|
|
3
3
|
* (c) 2023-present chandq
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -20,7 +20,7 @@ function supportCanvas() {
|
|
|
20
20
|
* @returns {HTMLInputElement}
|
|
21
21
|
*/
|
|
22
22
|
function chooseLocalFile(accept, changeCb) {
|
|
23
|
-
|
|
23
|
+
let inputObj = document.createElement('input');
|
|
24
24
|
inputObj.setAttribute('id', String(Date.now()));
|
|
25
25
|
inputObj.setAttribute('type', 'file');
|
|
26
26
|
inputObj.setAttribute('style', 'visibility:hidden');
|
|
@@ -30,7 +30,11 @@ function chooseLocalFile(accept, changeCb) {
|
|
|
30
30
|
// @ts-ignore
|
|
31
31
|
inputObj.onchange = (e) => {
|
|
32
32
|
changeCb(e.target.files);
|
|
33
|
-
setTimeout(() =>
|
|
33
|
+
setTimeout(() => {
|
|
34
|
+
document.body.removeChild(inputObj);
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
inputObj = null;
|
|
37
|
+
});
|
|
34
38
|
};
|
|
35
39
|
}
|
|
36
40
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* sculp-js v1.13.
|
|
2
|
+
* sculp-js v1.13.3-beta.0
|
|
3
3
|
* (c) 2023-present chandq
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -14,7 +14,7 @@ export { isPlainObject, objectAssign, objectEach, objectEachAsync, objectFill, o
|
|
|
14
14
|
export { pathJoin, pathNormalize } from './path.js';
|
|
15
15
|
export { qsParse, qsStringify } from './qs.js';
|
|
16
16
|
export { STRING_ARABIC_NUMERALS, STRING_LOWERCASE_ALPHA, STRING_UPPERCASE_ALPHA, parseQueryParams, stringAssign, stringCamelCase, stringEscapeHtml, stringFill, stringFormat, stringKebabCase } from './string.js';
|
|
17
|
-
export { arrayLike, isArray, isBigInt, isBoolean, isDate, isEmpty, isError, isFunction, isJsonString, isNaN, isNull, isNullOrUnDef, isNullOrUnDef as isNullish, isNumber, isObject, isPrimitive, isRegExp, isString, isSymbol, isUndefined, objectHas, typeIs } from './type.js';
|
|
17
|
+
export { arrayLike, isArray, isBigInt, isBoolean, isDate, isEmpty, isError, isFunction, isJsonString, isNaN, isNodeList, isNull, isNullOrUnDef, isNullOrUnDef as isNullish, isNumber, isObject, isPrimitive, isRegExp, isString, isSymbol, isUndefined, objectHas, typeIs } from './type.js';
|
|
18
18
|
export { urlDelParams, urlParse, urlSetParams, urlStringify } from './url.js';
|
|
19
19
|
export { asyncMap, safeAwait, wait } from './async.js';
|
|
20
20
|
export { chooseLocalFile, compressImg, supportCanvas } from './file.js';
|
|
@@ -26,9 +26,8 @@ export { UNIQUE_NUMBER_SAFE_LENGTH, uniqueNumber, uniqueString } from './unique.
|
|
|
26
26
|
export { tooltipEvent } from './tooltip.js';
|
|
27
27
|
export { flatTree, forEachDeep, formatTree, fuzzySearchTree, mapDeep, searchTreeById } from './tree.js';
|
|
28
28
|
export { add, divide, multiply, strip, subtract } from './math.js';
|
|
29
|
-
export { weAtob, weBtoa } from './
|
|
30
|
-
export { decodeFromBase64, encodeToBase64 } from './base64.js';
|
|
29
|
+
export { b64decode, b64encode, weAtob, weBtoa } from './base64.js';
|
|
31
30
|
export { EMAIL_REGEX, HTTP_URL_REGEX, IPV4_REGEX, IPV6_REGEX, PHONE_REGEX, URL_REGEX, isDigit, isEmail, isFloat, isIdNo, isInteger, isIpV4, isIpV6, isNumerical, isPhone, isUrl } from './validator.js';
|
|
32
31
|
export { escapeRegExp, executeInScope, parseVarFromString, replaceVarFromString, uniqueSymbol } from './variable.js';
|
|
33
32
|
export { cloneDeep } from './cloneDeep.js';
|
|
34
|
-
export {
|
|
33
|
+
export { easingFunctional, easingStringify, getEasing, setEasing } from './easing.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* sculp-js v1.13.
|
|
2
|
+
* sculp-js v1.13.3-beta.0
|
|
3
3
|
* (c) 2023-present chandq
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -113,9 +113,12 @@ function mouseenter($customTitle, title, e) {
|
|
|
113
113
|
* @returns {*}
|
|
114
114
|
*/
|
|
115
115
|
function handleMouseLeave(rootContainer = '#root') {
|
|
116
|
-
const rootEl = isString(rootContainer) ? document.querySelector(rootContainer) : rootContainer
|
|
116
|
+
const rootEl = isString(rootContainer) ? document.querySelector(rootContainer) : rootContainer;
|
|
117
|
+
let titleEl = document.querySelector('#customTitle1494304949567');
|
|
117
118
|
if (rootEl && titleEl) {
|
|
118
119
|
rootEl.removeChild(titleEl);
|
|
120
|
+
// @ts-ignore
|
|
121
|
+
titleEl = null;
|
|
119
122
|
}
|
|
120
123
|
}
|
|
121
124
|
const tooltipEvent = { handleMouseEnter, handleMouseLeave };
|