sculp-js 1.13.1 → 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 +1 -16
  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 +1 -16
  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 -1214
  127. package/lib/umd/index.js +0 -6
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  [![Node.js CI](https://github.com/chandq/sculp-js/actions/workflows/node.js.yml/badge.svg)](https://github.com/chandq/sculp-js/actions/workflows/node.js.yml)
2
- [![sculp-js](https://img.shields.io/github/package-json/v/chandq/sculp-js?style=flat-square)](https://github.com/chandq/sculp-js)
3
- [![node](https://img.shields.io/badge/language-typescript-orange.svg)](https://nodejs.org/download/release/v12.0.0/)
2
+ [![sculp-js](https://img.shields.io/github/package-json/v/chandq/sculp-js?style=flat-square)](https://www.npmjs.com/package/sculp-js)
3
+
4
4
  [![license:MIT](https://img.shields.io/npm/l/vue.svg?sanitize=true)](https://github.com/chandq/sculp-js/blob/main/LICENSE.md)
5
5
  [![Downloads:?](https://img.shields.io/npm/dm/sculp-js.svg?sanitize=true)](https://npmcharts.com/compare/sculp-js?minimal=true)
6
6
  [![codecov](https://codecov.io/gh/chandq/sculp-js/graph/badge.svg?token=VZ6TERPGI9)](https://codecov.io/gh/chandq/sculp-js)
@@ -45,17 +45,17 @@
45
45
 
46
46
  - Array
47
47
 
48
- - arrayLike 判断类数组
49
- - arrayEachAsync 异步遍历数组,可中断,支持倒序
48
+ - arrayEach
49
+ - arrayEachAsync
50
50
 
51
51
  - Tree
52
52
 
53
- - forEachDeep 高性能的深度优先遍历函数, 支持continue、break,可定制id、children
54
- - mapDeep 高性能的深度优先遍历的Map函数, 支持continue、break,可定制id、children
55
- - searchTreeById 在树中找到 id 为某个值的节点,并返回上游的所有父级节点
56
- - formatTree 高性能的数组转树函数
57
- - flatTree 树转数组
58
- - fuzzySearchTree 模糊搜索函数,返回包含搜索字符的节点及其祖先节点的树
53
+ - forEachDeep
54
+ - mapDeep
55
+ - searchTreeById
56
+ - formatTree
57
+ - flatTree
58
+ - fuzzySearchTree
59
59
 
60
60
  - Object
61
61
 
@@ -66,7 +66,6 @@
66
66
  - objectEachAsync
67
67
  - objectGet
68
68
  - cloneDeep
69
- - isEqual
70
69
 
71
70
  - Number
72
71
 
@@ -0,0 +1,13 @@
1
+ /*!
2
+ * sculp-js v1.13.2
3
+ * (c) 2023-present chandq
4
+ * Released under the MIT License.
5
+ */
6
+
7
+ 'use strict';
8
+
9
+ function getDefaultExportFromCjs (x) {
10
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
11
+ }
12
+
13
+ exports.getDefaultExportFromCjs = getDefaultExportFromCjs;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.1
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.1
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,11 +1,14 @@
1
1
  /*!
2
- * sculp-js v1.13.1
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
7
7
  'use strict';
8
8
 
9
+ var func = require('./func.js');
10
+ var type = require('./type.js');
11
+
9
12
  const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
10
13
  // eslint-disable-next-line
11
14
  const b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
@@ -59,49 +62,55 @@ function weAtob(string) {
59
62
  }
60
63
  return result;
61
64
  }
62
- // function b64DecodeUnicode(str) {
63
- // return decodeURIComponent(
64
- // exports.weAtob(str).replace(/(.)/g, function (p) {
65
- // let code = p.charCodeAt(0).toString(16).toUpperCase();
66
- // if (code.length < 2) {
67
- // code = '0' + code;
68
- // }
69
- // return '%' + code;
70
- // })
71
- // );
72
- // }
73
- // function base64_url_decode(str) {
74
- // let output = str.replace(/-/g, '+').replace(/_/g, '/');
75
- // switch (output.length % 4) {
76
- // case 0:
77
- // break;
78
- // case 2:
79
- // output += '==';
80
- // break;
81
- // case 3:
82
- // output += '=';
83
- // break;
84
- // default:
85
- // throw new Error('Illegal base64url string!');
86
- // }
87
- // try {
88
- // return b64DecodeUnicode(output);
89
- // } catch (err) {
90
- // return exports.weAtob(output);
91
- // }
92
- // }
93
- // export function weAppJwtDecode(token, options) {
94
- // if (typeof token !== 'string') {
95
- // throw new Error('Invalid token specified');
96
- // }
97
- // options = options || {};
98
- // const pos = options.header === true ? 0 : 1;
99
- // try {
100
- // return JSON.parse(base64_url_decode(token.split('.')[pos]));
101
- // } catch (e) {
102
- // throw new Error('Invalid token specified: ' + (e as Error).message);
103
- // }
104
- // }
65
+ function stringToUint8Array(str) {
66
+ const utf8 = encodeURIComponent(str); // 将字符串转换为 UTF-8 编码
67
+ const uint8Array = new Uint8Array(utf8.length); // 创建 Uint8Array
68
+ for (let i = 0; i < utf8.length; i++) {
69
+ uint8Array[i] = utf8.charCodeAt(i); // 填充 Uint8Array
70
+ }
71
+ return uint8Array;
72
+ }
73
+ function uint8ArrayToString(uint8Array) {
74
+ const utf8 = String.fromCharCode.apply(null, uint8Array); // 将 Uint8Array 转为字符串
75
+ return decodeURIComponent(utf8); // 将 UTF-8 字符串解码回正常字符串
76
+ }
77
+ /**
78
+ * 将base64编码的字符串转换为原始字符串,包括对中文内容的处理(高性能,且支持Web、Node、小程序等任意平台)
79
+ * @param base64 base64编码的字符串
80
+ * @returns 原始字符串,包括中文内容
81
+ */
82
+ function b64decode(base64) {
83
+ const binaryString = !type.isNullOrUnDef(func.getGlobal('atob')) ? func.getGlobal('atob')(base64) : weAtob(base64);
84
+ const len = binaryString.length;
85
+ const bytes = new Uint8Array(len);
86
+ for (let i = 0; i < len; i++) {
87
+ bytes[i] = binaryString.charCodeAt(i);
88
+ }
89
+ // 使用TextDecoder将Uint8Array转换为原始字符串,包括中文内容
90
+ return !type.isNullOrUnDef(func.getGlobal('TextDecoder'))
91
+ ? new (func.getGlobal('TextDecoder'))('utf-8').decode(bytes)
92
+ : uint8ArrayToString(bytes);
93
+ }
94
+ /**
95
+ * 将原始字符串,包括中文内容,转换为base64编码的字符串(高性能,且支持Web、Node、小程序等任意平台)
96
+ * @param rawStr 原始字符串,包括中文内容
97
+ * @returns base64编码的字符串
98
+ */
99
+ function b64encode(rawStr) {
100
+ const utf8Array = !type.isNullOrUnDef(func.getGlobal('TextEncoder'))
101
+ ? new (func.getGlobal('TextEncoder'))().encode(rawStr)
102
+ : stringToUint8Array(rawStr);
103
+ // 将 Uint8Array 转换为二进制字符串
104
+ let binaryString = '';
105
+ const len = utf8Array.length;
106
+ for (let i = 0; i < len; i++) {
107
+ binaryString += String.fromCharCode(utf8Array[i]);
108
+ }
109
+ // 将二进制字符串转换为base64编码的字符串
110
+ return !type.isNullOrUnDef(func.getGlobal('btoa')) ? func.getGlobal('btoa')(binaryString) : weBtoa(binaryString);
111
+ }
105
112
 
113
+ exports.b64decode = b64decode;
114
+ exports.b64encode = b64encode;
106
115
  exports.weAtob = weAtob;
107
116
  exports.weBtoa = weBtoa;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.1
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.1
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.1
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.1
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.1
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.1
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -0,0 +1,75 @@
1
+ /*!
2
+ * sculp-js v1.13.2
3
+ * (c) 2023-present chandq
4
+ * Released under the MIT License.
5
+ */
6
+
7
+ 'use strict';
8
+
9
+ var index = require('./node_modules/bezier-easing/src/index.js');
10
+ var type = require('./type.js');
11
+
12
+ // @ref https://cubic-bezier.com/
13
+ const easingDefines = {
14
+ linear: [0, 0, 1, 1],
15
+ ease: [0.25, 0.1, 0.25, 1],
16
+ 'ease-in': [0.42, 0, 1, 1],
17
+ 'ease-out': [0, 0, 0.58, 1],
18
+ 'ease-in-out': [0.42, 0, 0.58, 1]
19
+ };
20
+ /**
21
+ * 设置缓存定义
22
+ * @param {string} name
23
+ * @param {EasingDefine} define
24
+ */
25
+ function setEasing(name, define) {
26
+ easingDefines[name] = define;
27
+ }
28
+ function getEasing(name) {
29
+ if (name)
30
+ return easingDefines[name];
31
+ return easingDefines;
32
+ }
33
+ /**
34
+ * 缓冲函数化,用于 js 计算缓冲进度
35
+ * @param {EasingNameOrDefine} [name=linear]
36
+ * @returns {EasingFunction}
37
+ */
38
+ function easingFunctional(name) {
39
+ let fn;
40
+ if (type.isArray(name)) {
41
+ fn = index.default(...name);
42
+ }
43
+ else {
44
+ const define = easingDefines[name];
45
+ if (!define) {
46
+ throw new Error(`${name} 缓冲函数未定义`);
47
+ }
48
+ fn = index.default(...define);
49
+ }
50
+ return (input) => fn(Math.max(0, Math.min(input, 1)));
51
+ }
52
+ /**
53
+ * 缓冲字符化,用于 css 设置缓冲属性
54
+ * @param {EasingNameOrDefine} name
55
+ * @returns {string}
56
+ */
57
+ function easingStringify(name) {
58
+ let bezierDefine;
59
+ if (type.isArray(name)) {
60
+ bezierDefine = name;
61
+ }
62
+ else {
63
+ const define = easingDefines[name];
64
+ if (!define) {
65
+ throw new Error(`${name} 缓冲函数未定义`);
66
+ }
67
+ bezierDefine = define;
68
+ }
69
+ return `cubic-bezier(${bezierDefine.join(',')})`;
70
+ }
71
+
72
+ exports.easingFunctional = easingFunctional;
73
+ exports.easingStringify = easingStringify;
74
+ exports.getEasing = getEasing;
75
+ exports.setEasing = setEasing;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.1
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.1
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.1
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -28,12 +28,11 @@ var unique = require('./unique.js');
28
28
  var tooltip = require('./tooltip.js');
29
29
  var tree = require('./tree.js');
30
30
  var math = require('./math.js');
31
- var weDecode = require('./we-decode.js');
32
31
  var base64 = require('./base64.js');
33
32
  var validator = require('./validator.js');
34
33
  var variable = require('./variable.js');
35
34
  var cloneDeep = require('./cloneDeep.js');
36
- var isEqual = require('./isEqual.js');
35
+ var easing = require('./easing.js');
37
36
 
38
37
 
39
38
 
@@ -154,10 +153,10 @@ exports.divide = math.divide;
154
153
  exports.multiply = math.multiply;
155
154
  exports.strip = math.strip;
156
155
  exports.subtract = math.subtract;
157
- exports.weAtob = weDecode.weAtob;
158
- exports.weBtoa = weDecode.weBtoa;
159
- exports.decodeFromBase64 = base64.decodeFromBase64;
160
- exports.encodeToBase64 = base64.encodeToBase64;
156
+ exports.b64decode = base64.b64decode;
157
+ exports.b64encode = base64.b64encode;
158
+ exports.weAtob = base64.weAtob;
159
+ exports.weBtoa = base64.weBtoa;
161
160
  exports.EMAIL_REGEX = validator.EMAIL_REGEX;
162
161
  exports.HTTP_URL_REGEX = validator.HTTP_URL_REGEX;
163
162
  exports.IPV4_REGEX = validator.IPV4_REGEX;
@@ -180,4 +179,7 @@ exports.parseVarFromString = variable.parseVarFromString;
180
179
  exports.replaceVarFromString = variable.replaceVarFromString;
181
180
  exports.uniqueSymbol = variable.uniqueSymbol;
182
181
  exports.cloneDeep = cloneDeep.cloneDeep;
183
- exports.isEqual = isEqual.isEqual;
182
+ exports.easingFunctional = easing.easingFunctional;
183
+ exports.easingStringify = easing.easingStringify;
184
+ exports.getEasing = easing.getEasing;
185
+ exports.setEasing = easing.setEasing;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.1
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -0,0 +1,123 @@
1
+ /*!
2
+ * sculp-js v1.13.2
3
+ * (c) 2023-present chandq
4
+ * Released under the MIT License.
5
+ */
6
+
7
+ 'use strict';
8
+
9
+ Object.defineProperty(exports, '__esModule', { value: true });
10
+
11
+ var _commonjsHelpers = require('../../../_virtual/_commonjsHelpers.js');
12
+
13
+ /**
14
+ * https://github.com/gre/bezier-easing
15
+ * BezierEasing - use bezier curve for transition easing function
16
+ * by Gaëtan Renaudeau 2014 - 2015 – MIT License
17
+ */
18
+
19
+ // These values are established by empiricism with tests (tradeoff: performance VS precision)
20
+ var NEWTON_ITERATIONS = 4;
21
+ var NEWTON_MIN_SLOPE = 0.001;
22
+ var SUBDIVISION_PRECISION = 0.0000001;
23
+ var SUBDIVISION_MAX_ITERATIONS = 10;
24
+
25
+ var kSplineTableSize = 11;
26
+ var kSampleStepSize = 1.0 / (kSplineTableSize - 1.0);
27
+
28
+ var float32ArraySupported = typeof Float32Array === 'function';
29
+
30
+ function A (aA1, aA2) { return 1.0 - 3.0 * aA2 + 3.0 * aA1; }
31
+ function B (aA1, aA2) { return 3.0 * aA2 - 6.0 * aA1; }
32
+ function C (aA1) { return 3.0 * aA1; }
33
+
34
+ // Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2.
35
+ function calcBezier (aT, aA1, aA2) { return ((A(aA1, aA2) * aT + B(aA1, aA2)) * aT + C(aA1)) * aT; }
36
+
37
+ // Returns dx/dt given t, x1, and x2, or dy/dt given t, y1, and y2.
38
+ function getSlope (aT, aA1, aA2) { return 3.0 * A(aA1, aA2) * aT * aT + 2.0 * B(aA1, aA2) * aT + C(aA1); }
39
+
40
+ function binarySubdivide (aX, aA, aB, mX1, mX2) {
41
+ var currentX, currentT, i = 0;
42
+ do {
43
+ currentT = aA + (aB - aA) / 2.0;
44
+ currentX = calcBezier(currentT, mX1, mX2) - aX;
45
+ if (currentX > 0.0) {
46
+ aB = currentT;
47
+ } else {
48
+ aA = currentT;
49
+ }
50
+ } while (Math.abs(currentX) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS);
51
+ return currentT;
52
+ }
53
+
54
+ function newtonRaphsonIterate (aX, aGuessT, mX1, mX2) {
55
+ for (var i = 0; i < NEWTON_ITERATIONS; ++i) {
56
+ var currentSlope = getSlope(aGuessT, mX1, mX2);
57
+ if (currentSlope === 0.0) {
58
+ return aGuessT;
59
+ }
60
+ var currentX = calcBezier(aGuessT, mX1, mX2) - aX;
61
+ aGuessT -= currentX / currentSlope;
62
+ }
63
+ return aGuessT;
64
+ }
65
+
66
+ function LinearEasing (x) {
67
+ return x;
68
+ }
69
+
70
+ var src = function bezier (mX1, mY1, mX2, mY2) {
71
+ if (!(0 <= mX1 && mX1 <= 1 && 0 <= mX2 && mX2 <= 1)) {
72
+ throw new Error('bezier x values must be in [0, 1] range');
73
+ }
74
+
75
+ if (mX1 === mY1 && mX2 === mY2) {
76
+ return LinearEasing;
77
+ }
78
+
79
+ // Precompute samples table
80
+ var sampleValues = float32ArraySupported ? new Float32Array(kSplineTableSize) : new Array(kSplineTableSize);
81
+ for (var i = 0; i < kSplineTableSize; ++i) {
82
+ sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);
83
+ }
84
+
85
+ function getTForX (aX) {
86
+ var intervalStart = 0.0;
87
+ var currentSample = 1;
88
+ var lastSample = kSplineTableSize - 1;
89
+
90
+ for (; currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample) {
91
+ intervalStart += kSampleStepSize;
92
+ }
93
+ --currentSample;
94
+
95
+ // Interpolate to provide an initial guess for t
96
+ var dist = (aX - sampleValues[currentSample]) / (sampleValues[currentSample + 1] - sampleValues[currentSample]);
97
+ var guessForT = intervalStart + dist * kSampleStepSize;
98
+
99
+ var initialSlope = getSlope(guessForT, mX1, mX2);
100
+ if (initialSlope >= NEWTON_MIN_SLOPE) {
101
+ return newtonRaphsonIterate(aX, guessForT, mX1, mX2);
102
+ } else if (initialSlope === 0.0) {
103
+ return guessForT;
104
+ } else {
105
+ return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, mX1, mX2);
106
+ }
107
+ }
108
+
109
+ return function BezierEasing (x) {
110
+ // Because JavaScript number are imprecise, we should guarantee the extremes are right.
111
+ if (x === 0) {
112
+ return 0;
113
+ }
114
+ if (x === 1) {
115
+ return 1;
116
+ }
117
+ return calcBezier(getTForX(x), mY1, mY2);
118
+ };
119
+ };
120
+
121
+ var bezier = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(src);
122
+
123
+ exports.default = bezier;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.1
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.1
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.1
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.1
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.1
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.1
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.1
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.1
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -55,9 +55,7 @@ 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
  }
@@ -66,8 +64,6 @@ function forEachDeep(tree, iterator, options = {
66
64
  // Process queue
67
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,9 +99,7 @@ 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
  }
@@ -117,7 +109,6 @@ function forEachDeep(tree, iterator, options = {
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
  }
@@ -175,10 +164,8 @@ function mapDeep(tree, iterator, options = {
175
164
  continue;
176
165
  }
177
166
  newTree.push(object.objectOmit(re, [childField]));
178
- // @ts-ignore
179
167
  if (item && Array.isArray(item[childField])) {
180
168
  newTree[newTree.length - 1][childField] = [];
181
- // @ts-ignore
182
169
  walk(item[childField], item, newTree[newTree.length - 1][childField], level + 1);
183
170
  }
184
171
  else {
@@ -202,10 +189,8 @@ function mapDeep(tree, iterator, options = {
202
189
  continue;
203
190
  }
204
191
  newTree.push(object.objectOmit(re, [childField]));
205
- // @ts-ignore
206
192
  if (item && Array.isArray(item[childField])) {
207
193
  newTree[newTree.length - 1][childField] = [];
208
- // @ts-ignore
209
194
  walk(item[childField], item, newTree[newTree.length - 1][childField], level + 1);
210
195
  }
211
196
  else {
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.1
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.1
2
+ * sculp-js v1.13.2
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */