sculp-js 1.13.0 → 1.13.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.
Files changed (127) hide show
  1. package/README.md +10 -11
  2. package/dist/cjs/_virtual/_commonjsHelpers.js +13 -0
  3. package/{lib → dist}/cjs/array.js +1 -1
  4. package/{lib → dist}/cjs/async.js +1 -1
  5. package/{lib/cjs/we-decode.js → dist/cjs/base64.js} +53 -44
  6. package/{lib → dist}/cjs/clipboard.js +1 -1
  7. package/{lib → dist}/cjs/cloneDeep.js +1 -1
  8. package/{lib → dist}/cjs/cookie.js +1 -1
  9. package/{lib → dist}/cjs/date.js +1 -1
  10. package/{lib → dist}/cjs/dom.js +1 -1
  11. package/{lib → dist}/cjs/download.js +1 -1
  12. package/dist/cjs/easing.js +75 -0
  13. package/{lib → dist}/cjs/file.js +1 -1
  14. package/{lib → dist}/cjs/func.js +1 -1
  15. package/{lib → dist}/cjs/index.js +10 -8
  16. package/{lib → dist}/cjs/math.js +1 -1
  17. package/dist/cjs/node_modules/bezier-easing/src/index.js +123 -0
  18. package/{lib → dist}/cjs/number.js +1 -1
  19. package/{lib → dist}/cjs/object.js +1 -1
  20. package/{lib → dist}/cjs/path.js +1 -1
  21. package/{lib → dist}/cjs/qs.js +1 -1
  22. package/{lib → dist}/cjs/random.js +1 -1
  23. package/{lib → dist}/cjs/string.js +1 -1
  24. package/{lib → dist}/cjs/tooltip.js +1 -1
  25. package/{lib → dist}/cjs/tree.js +36 -43
  26. package/{lib → dist}/cjs/type.js +1 -1
  27. package/{lib → dist}/cjs/unique.js +1 -1
  28. package/{lib → dist}/cjs/url.js +1 -1
  29. package/{lib → dist}/cjs/validator.js +1 -1
  30. package/{lib → dist}/cjs/variable.js +1 -1
  31. package/{lib → dist}/cjs/watermark.js +1 -1
  32. package/{lib/es → dist/esm}/array.js +1 -1
  33. package/{lib/es → dist/esm}/async.js +1 -1
  34. package/{lib/es/we-decode.js → dist/esm/base64.js} +52 -45
  35. package/{lib/es → dist/esm}/clipboard.js +1 -1
  36. package/{lib/es → dist/esm}/cloneDeep.js +1 -1
  37. package/{lib/es → dist/esm}/cookie.js +1 -1
  38. package/{lib/es → dist/esm}/date.js +1 -1
  39. package/{lib/es → dist/esm}/dom.js +1 -1
  40. package/{lib/es → dist/esm}/download.js +1 -1
  41. package/{lib/es → dist/esm}/easing.js +34 -2
  42. package/{lib/es → dist/esm}/file.js +1 -1
  43. package/{lib/es → dist/esm}/func.js +1 -1
  44. package/{lib/es → dist/esm}/index.js +3 -4
  45. package/{lib/es → dist/esm}/math.js +1 -1
  46. package/{lib/es → dist/esm}/number.js +1 -1
  47. package/{lib/es → dist/esm}/object.js +1 -1
  48. package/{lib/es → dist/esm}/path.js +1 -1
  49. package/{lib/es → dist/esm}/qs.js +1 -1
  50. package/{lib/es → dist/esm}/random.js +1 -1
  51. package/{lib/es → dist/esm}/string.js +1 -1
  52. package/{lib/es → dist/esm}/tooltip.js +1 -1
  53. package/{lib/es → dist/esm}/tree.js +36 -43
  54. package/{lib/es → dist/esm}/type.js +1 -1
  55. package/{lib/es → dist/esm}/unique.js +1 -1
  56. package/{lib/es → dist/esm}/url.js +1 -1
  57. package/{lib/es → dist/esm}/validator.js +1 -1
  58. package/{lib/es → dist/esm}/variable.js +1 -1
  59. package/{lib/es → dist/esm}/watermark.js +1 -1
  60. package/dist/types/array.d.ts +50 -0
  61. package/dist/types/array.d.ts.map +1 -0
  62. package/dist/types/async.d.ts +37 -0
  63. package/dist/types/async.d.ts.map +1 -0
  64. package/dist/types/base64.d.ts +25 -0
  65. package/dist/types/base64.d.ts.map +1 -0
  66. package/dist/types/clipboard.d.ts +20 -0
  67. package/dist/types/clipboard.d.ts.map +1 -0
  68. package/dist/types/cloneDeep.d.ts +12 -0
  69. package/dist/types/cloneDeep.d.ts.map +1 -0
  70. package/dist/types/cookie.d.ts +19 -0
  71. package/dist/types/cookie.d.ts.map +1 -0
  72. package/dist/types/core-index.d.ts +17 -0
  73. package/dist/types/core-index.d.ts.map +1 -0
  74. package/dist/types/date.d.ts +74 -0
  75. package/dist/types/date.d.ts.map +1 -0
  76. package/dist/types/dom.d.ts +74 -0
  77. package/dist/types/dom.d.ts.map +1 -0
  78. package/dist/types/download.d.ts +47 -0
  79. package/dist/types/download.d.ts.map +1 -0
  80. package/dist/types/easing.d.ts +32 -0
  81. package/dist/types/easing.d.ts.map +1 -0
  82. package/dist/types/file.d.ts +44 -0
  83. package/dist/types/file.d.ts.map +1 -0
  84. package/dist/types/func.d.ts +50 -0
  85. package/dist/types/func.d.ts.map +1 -0
  86. package/dist/types/index.d.ts +28 -0
  87. package/dist/types/index.d.ts.map +1 -0
  88. package/dist/types/index.js +3258 -0
  89. package/dist/types/math.d.ts +36 -0
  90. package/dist/types/math.d.ts.map +1 -0
  91. package/dist/types/number.d.ts +49 -0
  92. package/dist/types/number.d.ts.map +1 -0
  93. package/dist/types/object.d.ts +70 -0
  94. package/dist/types/object.d.ts.map +1 -0
  95. package/dist/types/path.d.ts +14 -0
  96. package/dist/types/path.d.ts.map +1 -0
  97. package/dist/types/qs.d.ts +22 -0
  98. package/dist/types/qs.d.ts.map +1 -0
  99. package/dist/types/random.d.ts +27 -0
  100. package/dist/types/random.d.ts.map +1 -0
  101. package/dist/types/string.d.ts +67 -0
  102. package/dist/types/string.d.ts.map +1 -0
  103. package/dist/types/tooltip.d.ts +36 -0
  104. package/dist/types/tooltip.d.ts.map +1 -0
  105. package/dist/types/tree.d.ts +98 -0
  106. package/dist/types/tree.d.ts.map +1 -0
  107. package/dist/types/type.d.ts +124 -0
  108. package/dist/types/type.d.ts.map +1 -0
  109. package/dist/types/unique.d.ts +21 -0
  110. package/dist/types/unique.d.ts.map +1 -0
  111. package/dist/types/url.d.ts +46 -0
  112. package/dist/types/url.d.ts.map +1 -0
  113. package/dist/types/validator.d.ts +67 -0
  114. package/dist/types/validator.d.ts.map +1 -0
  115. package/dist/types/variable.d.ts +71 -0
  116. package/dist/types/variable.d.ts.map +1 -0
  117. package/dist/types/watermark.d.ts +19 -0
  118. package/dist/types/watermark.d.ts.map +1 -0
  119. package/dist/umd/index.min.js +6 -0
  120. package/package.json +234 -17
  121. package/lib/cjs/base64.js +0 -62
  122. package/lib/cjs/easing.js +0 -40
  123. package/lib/cjs/isEqual.js +0 -133
  124. package/lib/es/base64.js +0 -59
  125. package/lib/es/isEqual.js +0 -131
  126. package/lib/index.d.ts +0 -1211
  127. package/lib/umd/index.js +0 -6
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -55,19 +55,15 @@ function forEachDeep(tree, iterator, options = {
55
55
  else if (re === true) {
56
56
  continue;
57
57
  }
58
- // @ts-ignore
59
58
  if (item && Array.isArray(item[childField])) {
60
- // @ts-ignore
61
59
  walk(item[childField], item, level + 1);
62
60
  }
63
61
  }
64
62
  }
65
63
  if (breadthFirst) {
66
64
  // Process queue
67
- while (!isBreak) {
65
+ while (queue.length > 0 && !isBreak) {
68
66
  const current = queue.shift();
69
- // iterate(info);
70
- // @ts-ignore
71
67
  const { item, index, array, tree, parent, level } = current;
72
68
  const re = iterator(item, index, array, tree, parent, level);
73
69
  if (re === false) {
@@ -77,9 +73,7 @@ function forEachDeep(tree, iterator, options = {
77
73
  else if (re === true) {
78
74
  continue;
79
75
  }
80
- // @ts-ignore
81
76
  if (item && Array.isArray(item[childField])) {
82
- // @ts-ignore
83
77
  walk(item[childField], item, level + 1);
84
78
  }
85
79
  }
@@ -105,19 +99,16 @@ function forEachDeep(tree, iterator, options = {
105
99
  else if (re === true) {
106
100
  continue;
107
101
  }
108
- // @ts-ignore
109
102
  if (item && Array.isArray(item[childField])) {
110
- // @ts-ignore
111
103
  walk(item[childField], item, level + 1);
112
104
  }
113
105
  }
114
106
  }
115
107
  if (breadthFirst) {
116
- while (!isBreak) {
108
+ while (queue.length > 0 && !isBreak) {
117
109
  const current = queue.shift();
118
110
  if (!current)
119
111
  break;
120
- // @ts-ignore
121
112
  const { item, index, array, tree, parent, level } = current;
122
113
  const re = iterator(item, index, array, tree, parent, level);
123
114
  if (re === false) {
@@ -127,9 +118,7 @@ function forEachDeep(tree, iterator, options = {
127
118
  else if (re === true) {
128
119
  continue;
129
120
  }
130
- // @ts-ignore
131
121
  if (item && Array.isArray(item[childField])) {
132
- // @ts-ignore
133
122
  walk(item[childField], item, level + 1);
134
123
  }
135
124
  }
@@ -146,20 +135,27 @@ function forEachDeep(tree, iterator, options = {
146
135
  * 可遍历任何带有 length 属性和数字键的类数组对象
147
136
  * @param {ArrayLike<V>} tree 树形数据
148
137
  * @param {Function} iterator 迭代函数, 返回值为true时continue, 返回值为false时break
149
- * @param {string} children 定制子元素的key
150
- * @param {boolean} isReverse 是否反向遍历
138
+ * @param {options} options 支持定制子元素名称、反向遍历,默认{
139
+ childField: 'children',
140
+ reverse: false,
141
+ }
151
142
  * @returns {any[]} 新的一棵树
152
143
  */
153
- function mapDeep(tree, iterator, children = 'children', isReverse = false) {
144
+ function mapDeep(tree, iterator, options = {
145
+ childField: 'children',
146
+ reverse: false
147
+ }) {
148
+ const { childField = 'children', reverse = false } = type.isObject(options) ? options : {};
154
149
  let isBreak = false;
155
150
  const newTree = [];
156
151
  const walk = (arr, parent, newTree, level = 0) => {
157
- if (isReverse) {
152
+ if (reverse) {
158
153
  for (let i = arr.length - 1; i >= 0; i--) {
159
154
  if (isBreak) {
160
155
  break;
161
156
  }
162
- const re = iterator(arr[i], i, arr, tree, parent, level);
157
+ const item = arr[i];
158
+ const re = iterator(item, i, arr, tree, parent, level);
163
159
  if (re === false) {
164
160
  isBreak = true;
165
161
  break;
@@ -167,16 +163,14 @@ function mapDeep(tree, iterator, children = 'children', isReverse = false) {
167
163
  else if (re === true) {
168
164
  continue;
169
165
  }
170
- newTree.push(object.objectOmit(re, [children]));
171
- // @ts-ignore
172
- if (arr[i] && Array.isArray(arr[i][children])) {
173
- newTree[newTree.length - 1][children] = [];
174
- // @ts-ignore
175
- walk(arr[i][children], arr[i], newTree[newTree.length - 1][children], level + 1);
166
+ newTree.push(object.objectOmit(re, [childField]));
167
+ if (item && Array.isArray(item[childField])) {
168
+ newTree[newTree.length - 1][childField] = [];
169
+ walk(item[childField], item, newTree[newTree.length - 1][childField], level + 1);
176
170
  }
177
171
  else {
178
172
  // children非有效数组时,移除该属性字段
179
- delete re[children];
173
+ delete re[childField];
180
174
  }
181
175
  }
182
176
  }
@@ -185,7 +179,8 @@ function mapDeep(tree, iterator, children = 'children', isReverse = false) {
185
179
  if (isBreak) {
186
180
  break;
187
181
  }
188
- const re = iterator(arr[i], i, arr, tree, parent, level);
182
+ const item = arr[i];
183
+ const re = iterator(item, i, arr, tree, parent, level);
189
184
  if (re === false) {
190
185
  isBreak = true;
191
186
  break;
@@ -193,16 +188,14 @@ function mapDeep(tree, iterator, children = 'children', isReverse = false) {
193
188
  else if (re === true) {
194
189
  continue;
195
190
  }
196
- newTree.push(object.objectOmit(re, [children]));
197
- // @ts-ignore
198
- if (arr[i] && Array.isArray(arr[i][children])) {
199
- newTree[newTree.length - 1][children] = [];
200
- // @ts-ignore
201
- walk(arr[i][children], arr[i], newTree[newTree.length - 1][children], level + 1);
191
+ newTree.push(object.objectOmit(re, [childField]));
192
+ if (item && Array.isArray(item[childField])) {
193
+ newTree[newTree.length - 1][childField] = [];
194
+ walk(item[childField], item, newTree[newTree.length - 1][childField], level + 1);
202
195
  }
203
196
  else {
204
197
  // children非有效数组时,移除该属性字段
205
- delete re[children];
198
+ delete re[childField];
206
199
  }
207
200
  }
208
201
  }
@@ -216,30 +209,30 @@ function mapDeep(tree, iterator, children = 'children', isReverse = false) {
216
209
  * 在树中找到 id 为某个值的节点,并返回上游的所有父级节点
217
210
  *
218
211
  * @param {ArrayLike<T>} tree - 树形数据
219
- * @param {IdLike} nodeId - 元素ID
220
- * @param {ITreeConf} config - 迭代配置项
221
- * @returns {[IdLike[], ITreeItem<V>[]]} - 由parentId...childId, parentObject-childObject组成的二维数组
212
+ * @param {number | string} nodeId - 目标元素ID
213
+ * @param {ITreeConf} options - 迭代配置项, 默认:{ children = 'children', id = 'id' }
214
+ * @returns {[(number | string)[], V[]]} - 由parentId...childId, parentObject-childObject组成的二维数组
222
215
  */
223
- function searchTreeById(tree, nodeId, config) {
224
- const { children = 'children', id = 'id' } = config || {};
216
+ function searchTreeById(tree, nodeId, options = { childField: 'children', keyField: 'id' }) {
217
+ const { childField = 'children', keyField = 'id' } = type.isObject(options) ? options : {};
225
218
  const toFlatArray = (tree, parentId, parent) => {
226
219
  return tree.reduce((t, _) => {
227
- const child = _[children];
220
+ const child = _[childField];
228
221
  return [
229
222
  ...t,
230
223
  parentId ? { ..._, parentId, parent } : _,
231
- ...(child && child.length ? toFlatArray(child, _[id], _) : [])
224
+ ...(child && child.length ? toFlatArray(child, _[keyField], _) : [])
232
225
  ];
233
226
  }, []);
234
227
  };
235
228
  const getIds = (flatArray) => {
236
- let child = flatArray.find(_ => _[id] === nodeId);
229
+ let child = flatArray.find(_ => _[keyField] === nodeId);
237
230
  const { parent, parentId, ...other } = child;
238
231
  let ids = [nodeId], nodes = [other];
239
232
  while (child && child.parentId) {
240
233
  ids = [child.parentId, ...ids];
241
234
  nodes = [child.parent, ...nodes];
242
- child = flatArray.find(_ => _[id] === child.parentId); // eslint-disable-line
235
+ child = flatArray.find(_ => _[keyField] === child.parentId); // eslint-disable-line
243
236
  }
244
237
  return [ids, nodes];
245
238
  };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,9 +1,12 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
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
- // function b64DecodeUnicode(str) {
61
- // return decodeURIComponent(
62
- // exports.weAtob(str).replace(/(.)/g, function (p) {
63
- // let code = p.charCodeAt(0).toString(16).toUpperCase();
64
- // if (code.length < 2) {
65
- // code = '0' + code;
66
- // }
67
- // return '%' + code;
68
- // })
69
- // );
70
- // }
71
- // function base64_url_decode(str) {
72
- // let output = str.replace(/-/g, '+').replace(/_/g, '/');
73
- // switch (output.length % 4) {
74
- // case 0:
75
- // break;
76
- // case 2:
77
- // output += '==';
78
- // break;
79
- // case 3:
80
- // output += '=';
81
- // break;
82
- // default:
83
- // throw new Error('Illegal base64url string!');
84
- // }
85
- // try {
86
- // return b64DecodeUnicode(output);
87
- // } catch (err) {
88
- // return exports.weAtob(output);
89
- // }
90
- // }
91
- // export function weAppJwtDecode(token, options) {
92
- // if (typeof token !== 'string') {
93
- // throw new Error('Invalid token specified');
94
- // }
95
- // options = options || {};
96
- // const pos = options.header === true ? 0 : 1;
97
- // try {
98
- // return JSON.parse(base64_url_decode(token.split('.')[pos]));
99
- // } catch (e) {
100
- // throw new Error('Invalid token specified: ' + (e as Error).message);
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.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
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.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -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 './we-decode.js';
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 { isEqual } from './isEqual.js';
33
+ export { easingFunctional, easingStringify, getEasing, setEasing } from './easing.js';
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.0
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */