enr 2.0.1 → 2.0.3

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 (34) hide show
  1. package/README.md +3 -3
  2. package/cjs/components/ripples/LazyRippleEle.js +1 -1
  3. package/cjs/components/ripples/RipplesEle.js +1 -1
  4. package/cjs/customHooks/useAnimationFrame.js +2 -2
  5. package/cjs/customHooks/useInputIsComposing.js +2 -2
  6. package/cjs/customHooks/useRipples/class-build-background.js +2 -3
  7. package/cjs/customHooks/useRipples/class-param.js +24 -1
  8. package/cjs/customHooks/useRipples/class-ripple.js +5 -1
  9. package/cjs/customHooks/useRipples/data-default.js +2 -1
  10. package/cjs/customHooks/useRipples/index.js +2 -2
  11. package/cjs/customHooks/useTimeId.js +2 -2
  12. package/es/components/ripples/LazyRippleEle.js +1 -1
  13. package/es/components/ripples/RipplesEle.js +1 -1
  14. package/es/customHooks/useAnimationFrame.js +2 -2
  15. package/es/customHooks/useInputIsComposing.js +2 -2
  16. package/es/customHooks/useRipples/class-build-background.js +2 -3
  17. package/es/customHooks/useRipples/class-param.js +25 -2
  18. package/es/customHooks/useRipples/class-ripple.js +5 -1
  19. package/es/customHooks/useRipples/data-default.js +2 -1
  20. package/es/customHooks/useRipples/index.js +2 -2
  21. package/es/customHooks/useTimeId.js +2 -2
  22. package/es/src/components/ripples/LazyRippleEle.d.ts +2 -2
  23. package/es/src/components/ripples/RipplesEle.d.ts +2 -2
  24. package/es/src/components/ripples/types.d.ts +8 -7
  25. package/es/src/customHooks/useAnimationFrame.d.ts +2 -2
  26. package/es/src/customHooks/useInputIsComposing.d.ts +2 -2
  27. package/es/src/customHooks/useRipples/class-build-background.d.ts +1 -1
  28. package/es/src/customHooks/useRipples/class-param.d.ts +8 -1
  29. package/es/src/customHooks/useRipples/class-ripple.d.ts +3 -2
  30. package/es/src/customHooks/useRipples/data-default.d.ts +1 -1
  31. package/es/src/customHooks/useRipples/index.d.ts +2 -2
  32. package/es/src/customHooks/useRipples/types.d.ts +97 -26
  33. package/es/src/customHooks/useTimeId.d.ts +2 -2
  34. package/package.json +1 -1
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # en React
1
+ # enr
2
2
 
3
3
  ## 一、安装
4
4
 
@@ -15,7 +15,7 @@ npm install --save earthnut
15
15
 
16
16
  - 尽管接受所有的 style 属性,但是 `position` 还是期待是非 'static' 值,否则将影响涟漪背景的渲染位置和显示状态;
17
17
  - 当前如果设置了 `background` 的话,有可能在恢复时使得其覆盖其他子属性;
18
- - 当前期待使用 `background-color` 设置背景色,而不是在上面的 `background` 中设置背景色。譬如:`background-color: #f0f6;`
18
+ - 当前期待使用 `background-color` 设置背景色,而不是在上面的 `background` 中设置背景色。譬如:<span style="background-color:#f0f6">`background-color: #f0f6;`</span>
19
19
  - 当前更期待使用配置参数 `option` 的 'imgUrl' 来配置目标背景图(请注意图源的跨域问题)。譬如:`imgUrl: 'background.png'`
20
20
  - 当然,也可以使用标准的 `background-image` 配置符合要求的背景图片(目前仅支持单张图配置)。譬如:`background-image: url(background.png);`
21
21
  - 当前可配置 `background-image` 为渐变色,但仅支持从上到下的线性渐变(仅支持单渐变)。譬如: `background-image: linear-gradient(black, transparent);`
@@ -139,4 +139,4 @@ export function Home() {
139
139
 
140
140
  ## 文档
141
141
 
142
- 更多参阅 [enr](https://earthnut.dev/quickUse/)
142
+ 更多参阅 [enr](https://lmssee.com/quickUse/)
@@ -20,7 +20,7 @@ var Content = require('./Content.js');
20
20
  * @param props 使用参数
21
21
  * @param props.option 初始化状态设定选项
22
22
  * @version 0.0.1
23
- * @see https://earthnut.dev/earthnut/lazy-background-ripple
23
+ * @see https://lmssee.com/lazy-background-ripple
24
24
  * @example
25
25
  * 使用:
26
26
  *
@@ -18,7 +18,7 @@ var Content = require('./Content.js');
18
18
  * @param props 使用参数
19
19
  * @param props.option 初始化 ripple 的原始数据
20
20
  * @version 0.0.1
21
- * @see https://earthnut.dev/earthnut/background-ripple
21
+ * @see https://lmssee.com/background-ripple
22
22
  * @example
23
23
  * 使用:
24
24
  *
@@ -13,7 +13,7 @@ var react = require('react');
13
13
  * @copyright 2026 ©️ MrMudBean
14
14
  * @since 2025-01-07 11:23
15
15
  * @version 2.0.0-alpha.0
16
- * @lastModified 2026-02-04 08:18
16
+ * @lastModified 2026-02-07 08:11
17
17
  */
18
18
  /**
19
19
  *
@@ -25,7 +25,7 @@ var react = require('react');
25
25
  * @param [option=false] 使用第二参数,可指定是否立即执行及是否仅执行一次
26
26
  * @returns 返回值包含执行状态
27
27
  * @version 0.2.0
28
- * @see https://earthnut.dev/custom-hooks/use-animation-frame
28
+ * @see https://lmssee.com/custom-hooks/use-animation-frame
29
29
  * @example
30
30
  * 使用:
31
31
  *
@@ -12,7 +12,7 @@ var react = require('react');
12
12
  * @copyright 2026 ©️ MrMudBean
13
13
  * @since 2025-01-07 11:23
14
14
  * @version 2.0.0-alpha.0
15
- * @lastModified 2026-02-04 08:19
15
+ * @lastModified 2026-02-07 08:11
16
16
  */
17
17
  /**
18
18
  *
@@ -23,7 +23,7 @@ var react = require('react');
23
23
  * @param inputRef [RefObject<HTMLInputElement | HTMLTextAreaElement>] 输入框的 ref
24
24
  * @returns RefObject<boolean>
25
25
  * @version 0.0.4
26
- * @see https://earthnut.dev/custom-hooks/use-input-is-composing
26
+ * @see https://lmssee.com/custom-hooks/use-input-is-composing
27
27
  * @example
28
28
  *
29
29
  * 使用:
@@ -14,7 +14,7 @@ var tools = require('./tools.js');
14
14
  * @copyright 2026 ©️ MrMudBean
15
15
  * @since 2026-01-22 14:17
16
16
  * @version 2.0.0-alpha.0
17
- * @lastModified 2026-02-04 07:49
17
+ * @lastModified 2026-02-05 17:41
18
18
  */
19
19
  /**
20
20
  * ## 构建背景
@@ -39,8 +39,7 @@ class BuildBackground {
39
39
  * ## 默认加载的首个背景色
40
40
  */
41
41
  get defaultColor() {
42
- return this.elementMeta.isDark ? '#000000' : '#ffffff';
43
- // return '#00000000';
42
+ return this.options.loadingBackgroundColor[Number(this.elementMeta.isDark)];
44
43
  }
45
44
  /**
46
45
  * ## 最后使用
@@ -13,7 +13,7 @@ var dataDefault = require('./data-default.js');
13
13
  * @copyright 2026 ©️ MrMudBean
14
14
  * @since 2026-01-22 02:40
15
15
  * @version 2.0.0-alpha.0
16
- * @lastModified 2026-02-03 14:08
16
+ * @lastModified 2026-02-05 19:20
17
17
  */
18
18
  /**
19
19
  * ## 传入参数
@@ -36,6 +36,8 @@ class RippleParam {
36
36
  firstDrawProgressStep = 12;
37
37
  /** canvas 的显隐 */
38
38
  visible = false;
39
+ /** 初始化设定值,该值由用户设置,但不可修改 */
40
+ loadingBackgroundColor;
39
41
  // ++++++++++++++++++++++ 配置数据 《〈《〈《〈《 ++++++++++++++++++++++
40
42
  // ++++++++++++++++++++++ 》〉》〉》〉》 用户控制变量 ++++++++++++++++++++++
41
43
  // 这些变量通过 Ripple 类的 set 方法设定
@@ -185,6 +187,7 @@ class RippleParam {
185
187
  this.running = Boolean(options.playingState ?? true);
186
188
  this.crossOrigin = options.crossOrigin;
187
189
  this.darkMode = options.darkMode;
190
+ this.loadingBackgroundColor = this.getLoadingBg(options.loadingBackgroundColor);
188
191
  }
189
192
  /**
190
193
  * ## 切换最后一次执行的状态
@@ -192,6 +195,26 @@ class RippleParam {
192
195
  toggleLastRunningState() {
193
196
  this._lastRunningState = !this._lastRunningState;
194
197
  }
198
+ /**
199
+ * ## 获取初始化背景值
200
+ * @param _v 初始化的值
201
+ */
202
+ getLoadingBg(_v) {
203
+ if (aTypeOfJs.isArray(_v)) {
204
+ const len = _v.length;
205
+ if (len === 1) {
206
+ const color = _v[0];
207
+ return [color, color];
208
+ }
209
+ else if (len === 2) {
210
+ return [..._v];
211
+ }
212
+ }
213
+ else if (aTypeOfJs.isString(_v)) {
214
+ return [_v, _v];
215
+ }
216
+ return ['#00000000', '#00000000'];
217
+ }
195
218
  }
196
219
 
197
220
  exports.RippleParam = RippleParam;
@@ -21,7 +21,7 @@ var dataDefault = require('./data-default.js');
21
21
  * @copyright 2026 ©️ MrMudBean
22
22
  * @since 2026-01-22 03:03
23
23
  * @version 2.0.0-alpha.0
24
- * @lastModified 2026-02-04 07:42
24
+ * @lastModified 2026-02-05 19:24
25
25
  *
26
26
  */
27
27
  /**
@@ -208,6 +208,10 @@ class Ripples {
208
208
  * @param value
209
209
  */
210
210
  set(property, value) {
211
+ // 该属性不允许被重新赋值
212
+ if (property === 'loadingBackgroundColor') {
213
+ return;
214
+ }
211
215
  this.options[property] = value;
212
216
  // 数仓更新
213
217
  this.state.dispatch({
@@ -10,7 +10,7 @@
10
10
  * @copyright 2026 ©️ MrMudBean
11
11
  * @since 2026-01-22 11:55
12
12
  * @version 2.0.0-alpha.0
13
- * @lastModified 2026-02-04 07:15
13
+ * @lastModified 2026-02-05 17:22
14
14
  */
15
15
  /**
16
16
  * ## 默认值
@@ -27,6 +27,7 @@ const defaultData = {
27
27
  raindropsTimeInterval: 3600,
28
28
  idleFluctuations: true,
29
29
  darkMode: undefined,
30
+ loadingBackgroundColor: ['#00000000', '#00000000'],
30
31
  };
31
32
  /** 冷冻执行 */
32
33
  Object.freeze(defaultData);
@@ -15,7 +15,7 @@ var classRipple = require('./class-ripple.js');
15
15
  * @copyright 2026 ©️ MrMudBean
16
16
  * @since 2025-06-20 01:37
17
17
  * @version 2.0.0-alpha.0
18
- * @lastModified 2026-02-04 08:19
18
+ * @lastModified 2026-02-07 08:12
19
19
  */
20
20
  /**
21
21
  *
@@ -25,7 +25,7 @@ var classRipple = require('./class-ripple.js');
25
25
  * @param canvas `usrRef` 包裹的 `HTMLCanvasElement`,用于绘制图像
26
26
  * @param option 初始化的
27
27
  * @version 0.0.3
28
- * @see https://earthnut.dev/custom-hooks/use-ripples
28
+ * @see https://lmssee.com/custom-hooks/use-ripples
29
29
  * @see JQuery https://github.com/sirxemic/jquery.ripples
30
30
  * @example
31
31
  *
@@ -12,7 +12,7 @@ var react = require('react');
12
12
  * @copyright 2026 ©️ MrMudBean
13
13
  * @since 2025-01-07 11:20
14
14
  * @version 2.0.0-alpha.0
15
- * @lastModified 2026-02-04 08:19
15
+ * @lastModified 2026-02-07 08:12
16
16
  */
17
17
  /**
18
18
  *
@@ -21,7 +21,7 @@ var react = require('react');
21
21
  * 该数值在组件卸载时会自动调用 `clearTimeout` 清理
22
22
  *
23
23
  * @version 0.0.3
24
- * @see https://earthnut.dev/custom-hooks/use-time-id
24
+ * @see https://lmssee.com/custom-hooks/use-time-id
25
25
  * @example
26
26
  *
27
27
  * 使用:
@@ -18,7 +18,7 @@ import { ComponentContent } from './Content.js';
18
18
  * @param props 使用参数
19
19
  * @param props.option 初始化状态设定选项
20
20
  * @version 0.0.1
21
- * @see https://earthnut.dev/earthnut/lazy-background-ripple
21
+ * @see https://lmssee.com/lazy-background-ripple
22
22
  * @example
23
23
  * 使用:
24
24
  *
@@ -16,7 +16,7 @@ import { ComponentContent } from './Content.js';
16
16
  * @param props 使用参数
17
17
  * @param props.option 初始化 ripple 的原始数据
18
18
  * @version 0.0.1
19
- * @see https://earthnut.dev/earthnut/background-ripple
19
+ * @see https://lmssee.com/background-ripple
20
20
  * @example
21
21
  * 使用:
22
22
  *
@@ -11,7 +11,7 @@ import { useRef, useCallback, useEffect } from 'react';
11
11
  * @copyright 2026 ©️ MrMudBean
12
12
  * @since 2025-01-07 11:23
13
13
  * @version 2.0.0-alpha.0
14
- * @lastModified 2026-02-04 08:18
14
+ * @lastModified 2026-02-07 08:11
15
15
  */
16
16
  /**
17
17
  *
@@ -23,7 +23,7 @@ import { useRef, useCallback, useEffect } from 'react';
23
23
  * @param [option=false] 使用第二参数,可指定是否立即执行及是否仅执行一次
24
24
  * @returns 返回值包含执行状态
25
25
  * @version 0.2.0
26
- * @see https://earthnut.dev/custom-hooks/use-animation-frame
26
+ * @see https://lmssee.com/custom-hooks/use-animation-frame
27
27
  * @example
28
28
  * 使用:
29
29
  *
@@ -10,7 +10,7 @@ import { useRef, useEffect } from 'react';
10
10
  * @copyright 2026 ©️ MrMudBean
11
11
  * @since 2025-01-07 11:23
12
12
  * @version 2.0.0-alpha.0
13
- * @lastModified 2026-02-04 08:19
13
+ * @lastModified 2026-02-07 08:11
14
14
  */
15
15
  /**
16
16
  *
@@ -21,7 +21,7 @@ import { useRef, useEffect } from 'react';
21
21
  * @param inputRef [RefObject<HTMLInputElement | HTMLTextAreaElement>] 输入框的 ref
22
22
  * @returns RefObject<boolean>
23
23
  * @version 0.0.4
24
- * @see https://earthnut.dev/custom-hooks/use-input-is-composing
24
+ * @see https://lmssee.com/custom-hooks/use-input-is-composing
25
25
  * @example
26
26
  *
27
27
  * 使用:
@@ -12,7 +12,7 @@ import { createImageBySrc, isNoneBackGroundColor, extractUrl } from './tools.js'
12
12
  * @copyright 2026 ©️ MrMudBean
13
13
  * @since 2026-01-22 14:17
14
14
  * @version 2.0.0-alpha.0
15
- * @lastModified 2026-02-04 07:49
15
+ * @lastModified 2026-02-05 17:41
16
16
  */
17
17
  /**
18
18
  * ## 构建背景
@@ -37,8 +37,7 @@ class BuildBackground {
37
37
  * ## 默认加载的首个背景色
38
38
  */
39
39
  get defaultColor() {
40
- return this.elementMeta.isDark ? '#000000' : '#ffffff';
41
- // return '#00000000';
40
+ return this.options.loadingBackgroundColor[Number(this.elementMeta.isDark)];
42
41
  }
43
42
  /**
44
43
  * ## 最后使用
@@ -1,4 +1,4 @@
1
- import { isBoolean, isUndefined } from 'a-type-of-js';
1
+ import { isBoolean, isUndefined, isArray, isString } from 'a-type-of-js';
2
2
  import { defaultData } from './data-default.js';
3
3
 
4
4
  /**
@@ -11,7 +11,7 @@ import { defaultData } from './data-default.js';
11
11
  * @copyright 2026 ©️ MrMudBean
12
12
  * @since 2026-01-22 02:40
13
13
  * @version 2.0.0-alpha.0
14
- * @lastModified 2026-02-03 14:08
14
+ * @lastModified 2026-02-05 19:20
15
15
  */
16
16
  /**
17
17
  * ## 传入参数
@@ -34,6 +34,8 @@ class RippleParam {
34
34
  firstDrawProgressStep = 12;
35
35
  /** canvas 的显隐 */
36
36
  visible = false;
37
+ /** 初始化设定值,该值由用户设置,但不可修改 */
38
+ loadingBackgroundColor;
37
39
  // ++++++++++++++++++++++ 配置数据 《〈《〈《〈《 ++++++++++++++++++++++
38
40
  // ++++++++++++++++++++++ 》〉》〉》〉》 用户控制变量 ++++++++++++++++++++++
39
41
  // 这些变量通过 Ripple 类的 set 方法设定
@@ -183,6 +185,7 @@ class RippleParam {
183
185
  this.running = Boolean(options.playingState ?? true);
184
186
  this.crossOrigin = options.crossOrigin;
185
187
  this.darkMode = options.darkMode;
188
+ this.loadingBackgroundColor = this.getLoadingBg(options.loadingBackgroundColor);
186
189
  }
187
190
  /**
188
191
  * ## 切换最后一次执行的状态
@@ -190,6 +193,26 @@ class RippleParam {
190
193
  toggleLastRunningState() {
191
194
  this._lastRunningState = !this._lastRunningState;
192
195
  }
196
+ /**
197
+ * ## 获取初始化背景值
198
+ * @param _v 初始化的值
199
+ */
200
+ getLoadingBg(_v) {
201
+ if (isArray(_v)) {
202
+ const len = _v.length;
203
+ if (len === 1) {
204
+ const color = _v[0];
205
+ return [color, color];
206
+ }
207
+ else if (len === 2) {
208
+ return [..._v];
209
+ }
210
+ }
211
+ else if (isString(_v)) {
212
+ return [_v, _v];
213
+ }
214
+ return ['#00000000', '#00000000'];
215
+ }
193
216
  }
194
217
 
195
218
  export { RippleParam };
@@ -19,7 +19,7 @@ import { defaultData } from './data-default.js';
19
19
  * @copyright 2026 ©️ MrMudBean
20
20
  * @since 2026-01-22 03:03
21
21
  * @version 2.0.0-alpha.0
22
- * @lastModified 2026-02-04 07:42
22
+ * @lastModified 2026-02-05 19:24
23
23
  *
24
24
  */
25
25
  /**
@@ -206,6 +206,10 @@ class Ripples {
206
206
  * @param value
207
207
  */
208
208
  set(property, value) {
209
+ // 该属性不允许被重新赋值
210
+ if (property === 'loadingBackgroundColor') {
211
+ return;
212
+ }
209
213
  this.options[property] = value;
210
214
  // 数仓更新
211
215
  this.state.dispatch({
@@ -8,7 +8,7 @@
8
8
  * @copyright 2026 ©️ MrMudBean
9
9
  * @since 2026-01-22 11:55
10
10
  * @version 2.0.0-alpha.0
11
- * @lastModified 2026-02-04 07:15
11
+ * @lastModified 2026-02-05 17:22
12
12
  */
13
13
  /**
14
14
  * ## 默认值
@@ -25,6 +25,7 @@ const defaultData = {
25
25
  raindropsTimeInterval: 3600,
26
26
  idleFluctuations: true,
27
27
  darkMode: undefined,
28
+ loadingBackgroundColor: ['#00000000', '#00000000'],
28
29
  };
29
30
  /** 冷冻执行 */
30
31
  Object.freeze(defaultData);
@@ -13,7 +13,7 @@ import { Ripples } from './class-ripple.js';
13
13
  * @copyright 2026 ©️ MrMudBean
14
14
  * @since 2025-06-20 01:37
15
15
  * @version 2.0.0-alpha.0
16
- * @lastModified 2026-02-04 08:19
16
+ * @lastModified 2026-02-07 08:12
17
17
  */
18
18
  /**
19
19
  *
@@ -23,7 +23,7 @@ import { Ripples } from './class-ripple.js';
23
23
  * @param canvas `usrRef` 包裹的 `HTMLCanvasElement`,用于绘制图像
24
24
  * @param option 初始化的
25
25
  * @version 0.0.3
26
- * @see https://earthnut.dev/custom-hooks/use-ripples
26
+ * @see https://lmssee.com/custom-hooks/use-ripples
27
27
  * @see JQuery https://github.com/sirxemic/jquery.ripples
28
28
  * @example
29
29
  *
@@ -10,7 +10,7 @@ import { useRef, useEffect } from 'react';
10
10
  * @copyright 2026 ©️ MrMudBean
11
11
  * @since 2025-01-07 11:20
12
12
  * @version 2.0.0-alpha.0
13
- * @lastModified 2026-02-04 08:19
13
+ * @lastModified 2026-02-07 08:12
14
14
  */
15
15
  /**
16
16
  *
@@ -19,7 +19,7 @@ import { useRef, useEffect } from 'react';
19
19
  * 该数值在组件卸载时会自动调用 `clearTimeout` 清理
20
20
  *
21
21
  * @version 0.0.3
22
- * @see https://earthnut.dev/custom-hooks/use-time-id
22
+ * @see https://lmssee.com/custom-hooks/use-time-id
23
23
  * @example
24
24
  *
25
25
  * 使用:
@@ -7,7 +7,7 @@
7
7
  * @copyright 2026 ©️ MrMudBean
8
8
  * @since 2024-12-12 12:11
9
9
  * @version 2.0.0-alpha.0
10
- * @lastModified 2026-02-04 08:18
10
+ * @lastModified 2026-02-07 08:11
11
11
  */
12
12
  import type { BackgroundRipplesProps } from './types';
13
13
  /**
@@ -24,7 +24,7 @@ import type { BackgroundRipplesProps } from './types';
24
24
  * @param props 使用参数
25
25
  * @param props.option 初始化状态设定选项
26
26
  * @version 0.0.1
27
- * @see https://earthnut.dev/earthnut/lazy-background-ripple
27
+ * @see https://lmssee.com/lazy-background-ripple
28
28
  * @example
29
29
  * 使用:
30
30
  *
@@ -7,7 +7,7 @@
7
7
  * @copyright 2026 ©️ MrMudBean
8
8
  * @since 2024-12-12 12:18
9
9
  * @version 2.0.0-alpha.0
10
- * @lastModified 2026-02-04 08:18
10
+ * @lastModified 2026-02-07 08:11
11
11
  */
12
12
  import type { BackgroundRipplesProps } from './types';
13
13
  /**
@@ -22,7 +22,7 @@ import type { BackgroundRipplesProps } from './types';
22
22
  * @param props 使用参数
23
23
  * @param props.option 初始化 ripple 的原始数据
24
24
  * @version 0.0.1
25
- * @see https://earthnut.dev/earthnut/background-ripple
25
+ * @see https://lmssee.com/background-ripple
26
26
  * @example
27
27
  * 使用:
28
28
  *
@@ -7,7 +7,7 @@
7
7
  * @copyright 2026 ©️ Mr.MudBean
8
8
  * @since 2026-02-02 16:55
9
9
  * @version 2.0.0-alpha.4
10
- * @lastModified 2026-02-04 06:42
10
+ * @lastModified 2026-02-07 08:08
11
11
  */
12
12
  import type { RipplesOptions } from '../../customHooks/useRipples/types';
13
13
  import type { PropsWithTagNameCustomRef } from '../type';
@@ -36,18 +36,19 @@ export type BackgroundRipplesProps = PropsWithTagNameCustomRef<{
36
36
  /**
37
37
  * ## 可设定涟漪的参数
38
38
  *
39
- * - resolution 波速,值越小,波动越快。缺省为 `360`
40
- * - dropRadius 波动强度,值越小,波动效果越大,缺省值为 `12`
41
- * - perturbation 扰动系数,值越大,对原背景造成干涉越强,缺省为 `0.01`
42
- * - interactive 光标交互,缺省为 `true` ,关闭须显示传入 `false` 值
43
39
  * - accelerating 加速光标移动触发,类似于扰动系数,及作用与鼠标或手指触发,缺省为 `1`
44
40
  * - crossOrigin 原始样式
41
+ * - darkMode 暗黑模式,仅用于在默认的背景图时更改默认背景图的背景色,如果使用了 `imgUrl` 配置,请执行处理色差异常
42
+ * - dropRadius 波动强度,值越小,波动效果越大,缺省值为 `12`
45
43
  * - imgUrl 原始背景图片地址
44
+ * - idleFluctuations 闲置波动,在光标交互不触发时,将触发模拟雨滴,缺省为 `true`
45
+ * - interactive 光标交互,缺省为 `true` ,关闭须显示传入 `false` 值
46
+ * - loadingBackgroundColor 初始化加载时背景色,可为单色值或双色值数组(**该值仅在初始化用到,后续更改该值直接舍弃**)
47
+ * - perturbation 扰动系数,值越大,对原背景造成干涉越强,缺省为 `0.01`
46
48
  * - playingState 当前的播放状态,缺省为 `true` ,设定为 `false` 时并不关闭,而是暂停
47
49
  * - raindropsTimeInterval 雨滴滴落的间隔,缺省为 `3650`,可设置区间为 `10 ~ 12000`,值越小,雨越大
50
+ * - resolution 分波速,值越小,波动越快。缺省为 `360`
48
51
  * 该值还将影响无背景设置时默认背景的切换频率,几乎每两个雨滴落下就会切换一次背景
49
- * - idleFluctuations 闲置波动,在光标交互不触发时,将触发模拟雨滴,缺省为 `true`
50
- * - darkMode 暗黑模式,仅用于在默认的背景图时更改默认背景图的背景色,如果使用了 `imgUrl` 配置,请执行处理色差异常
51
52
  */
52
53
  option?: RipplesOptions;
53
54
  }, 'div', RippleEle>;
@@ -7,7 +7,7 @@
7
7
  * @copyright 2026 ©️ MrMudBean
8
8
  * @since 2025-01-07 11:23
9
9
  * @version 2.0.0-alpha.0
10
- * @lastModified 2026-02-04 08:18
10
+ * @lastModified 2026-02-07 08:11
11
11
  */
12
12
  /** 使用动画结果 */
13
13
  export interface UseAnimationFrameResult {
@@ -51,7 +51,7 @@ export type AnimationFrameOption = boolean | {
51
51
  * @param [option=false] 使用第二参数,可指定是否立即执行及是否仅执行一次
52
52
  * @returns 返回值包含执行状态
53
53
  * @version 0.2.0
54
- * @see https://earthnut.dev/custom-hooks/use-animation-frame
54
+ * @see https://lmssee.com/custom-hooks/use-animation-frame
55
55
  * @example
56
56
  * 使用:
57
57
  *
@@ -7,7 +7,7 @@
7
7
  * @copyright 2026 ©️ MrMudBean
8
8
  * @since 2025-01-07 11:23
9
9
  * @version 2.0.0-alpha.0
10
- * @lastModified 2026-02-04 08:19
10
+ * @lastModified 2026-02-07 08:11
11
11
  */
12
12
  import type { RefObject } from 'react';
13
13
  /**
@@ -19,7 +19,7 @@ import type { RefObject } from 'react';
19
19
  * @param inputRef [RefObject<HTMLInputElement | HTMLTextAreaElement>] 输入框的 ref
20
20
  * @returns RefObject<boolean>
21
21
  * @version 0.0.4
22
- * @see https://earthnut.dev/custom-hooks/use-input-is-composing
22
+ * @see https://lmssee.com/custom-hooks/use-input-is-composing
23
23
  * @example
24
24
  *
25
25
  * 使用:
@@ -8,7 +8,7 @@
8
8
  * @copyright 2026 ©️ MrMudBean
9
9
  * @since 2026-01-22 14:17
10
10
  * @version 2.0.0-alpha.0
11
- * @lastModified 2026-02-04 07:49
11
+ * @lastModified 2026-02-05 17:41
12
12
  */
13
13
  import type { ElementMeta } from './class-html-element-meta';
14
14
  import type { RippleParam } from './class-param';
@@ -8,7 +8,7 @@
8
8
  * @copyright 2026 ©️ MrMudBean
9
9
  * @since 2026-01-22 02:40
10
10
  * @version 2.0.0-alpha.0
11
- * @lastModified 2026-02-03 14:08
11
+ * @lastModified 2026-02-05 19:20
12
12
  */
13
13
  import type { ImageCrossOrigin, RippleImgUrl, RipplesOptions } from './types';
14
14
  /**
@@ -28,6 +28,8 @@ export declare class RippleParam {
28
28
  readonly firstDrawProgressStep = 12;
29
29
  /** canvas 的显隐 */
30
30
  visible: boolean;
31
+ /** 初始化设定值,该值由用户设置,但不可修改 */
32
+ readonly loadingBackgroundColor: [string, string];
31
33
  /** 倍级触发光标事件(值) */
32
34
  private _accelerating;
33
35
  /** 倍级触发光标事件 */
@@ -112,4 +114,9 @@ export declare class RippleParam {
112
114
  * ## 切换最后一次执行的状态
113
115
  */
114
116
  toggleLastRunningState(): void;
117
+ /**
118
+ * ## 获取初始化背景值
119
+ * @param _v 初始化的值
120
+ */
121
+ private getLoadingBg;
115
122
  }
@@ -8,9 +8,10 @@
8
8
  * @copyright 2026 ©️ MrMudBean
9
9
  * @since 2026-01-22 03:03
10
10
  * @version 2.0.0-alpha.0
11
- * @lastModified 2026-02-04 07:42
11
+ * @lastModified 2026-02-05 19:24
12
12
  *
13
13
  */
14
+ import { RippleParam } from './class-param';
14
15
  import type { RipplesOptions } from './types';
15
16
  /**
16
17
  *
@@ -90,6 +91,6 @@ export declare class Ripples {
90
91
  * 获取某一个参数的当前值
91
92
  * @param property 要获取的键
92
93
  */
93
- get<T extends keyof RipplesOptions>(property: T): RipplesOptions[T];
94
+ get<T extends keyof RipplesOptions>(property: T): RippleParam[T];
94
95
  private readonly reducer;
95
96
  }
@@ -8,7 +8,7 @@
8
8
  * @copyright 2026 ©️ MrMudBean
9
9
  * @since 2026-01-22 11:55
10
10
  * @version 2.0.0-alpha.0
11
- * @lastModified 2026-02-04 07:15
11
+ * @lastModified 2026-02-05 17:22
12
12
  */
13
13
  import type { RipplesDefaultData } from './types';
14
14
  /**
@@ -8,7 +8,7 @@
8
8
  * @copyright 2026 ©️ MrMudBean
9
9
  * @since 2025-06-20 01:37
10
10
  * @version 2.0.0-alpha.0
11
- * @lastModified 2026-02-04 08:19
11
+ * @lastModified 2026-02-07 08:12
12
12
  */
13
13
  import type { RefObject } from 'react';
14
14
  import { Ripples } from './class-ripple';
@@ -21,7 +21,7 @@ import type { RippleImgUrl, RipplesOptions } from './types';
21
21
  * @param canvas `usrRef` 包裹的 `HTMLCanvasElement`,用于绘制图像
22
22
  * @param option 初始化的
23
23
  * @version 0.0.3
24
- * @see https://earthnut.dev/custom-hooks/use-ripples
24
+ * @see https://lmssee.com/custom-hooks/use-ripples
25
25
  * @see JQuery https://github.com/sirxemic/jquery.ripples
26
26
  * @example
27
27
  *
@@ -1,15 +1,18 @@
1
- /****************************************************************************
2
- * @Author earthnut
3
- * @Email earthnut.dev@outlook.com
4
- * @ProjectName react-ripples
5
- * @FileName interface.ts
6
- * @CreateDate 周二 12/17/2024
7
- * @Description BackgroundRipples 的类型声明文件
8
- ****************************************************************************/
1
+ /**
2
+ * @author Mr.MudBean <Mr.MudBean@outlook.com>
3
+ * @file types.ts
4
+ * @since 周二 12/17/2024
5
+ * @description BackgroundRipples 的类型声明文件
6
+ * @lastModified 2026-02-07 08:06
7
+ */
8
+ /**
9
+ * ## 图片源
10
+ *
11
+ */
9
12
  export type ImageCrossOrigin = 'anonymous' | 'use-credentials' | 'no-cors';
10
13
  /**
11
14
  *
12
- * WebGLProgram
15
+ * WebGL 程序
13
16
  *
14
17
  */
15
18
  export interface Program {
@@ -29,7 +32,7 @@ export interface Program {
29
32
  export type RippleImgUrl = string | string[] | null;
30
33
  export type RipplesUseOptions = {
31
34
  /**
32
- * 波速
35
+ * ## 波速
33
36
  *
34
37
  * 作用为波传播的速度,值越大,波传播的越慢
35
38
  *
@@ -37,7 +40,7 @@ export type RipplesUseOptions = {
37
40
  */
38
41
  resolution: number;
39
42
  /**
40
- * 波动强度
43
+ * ## 波动强度
41
44
  *
42
45
  * 值越小,波动越明显
43
46
  *
@@ -45,7 +48,7 @@ export type RipplesUseOptions = {
45
48
  */
46
49
  dropRadius: number;
47
50
  /**
48
- * 扰动系数
51
+ * ## 扰动系数
49
52
  *
50
53
  * 缺省 `0.01`
51
54
  *
@@ -72,25 +75,25 @@ export type RipplesUseOptions = {
72
75
  */
73
76
  accelerating: number;
74
77
  /**
75
- * 原设定的背景图片
78
+ * ## 原设定的背景图片
76
79
  *
77
- * 缺省为 `''`
80
+ * 图片源
78
81
  */
79
82
  crossOrigin: ImageCrossOrigin;
80
83
  /**
81
- * 设定的元素背景的 url 地址
84
+ * ## 设定的元素背景的 url 地址
82
85
  *
83
86
  * 缺省为 `null`
84
87
  */
85
88
  imgUrl: RippleImgUrl;
86
89
  /**
87
- * 当前涟漪的状态
90
+ * ## 当前涟漪的状态
88
91
  *
89
92
  * 缺省为 `true` , 即涟漪触发正在执行
90
93
  */
91
94
  playingState: boolean;
92
95
  /**
93
- * 雨滴滴落的时间间隔
96
+ * ## 雨滴滴落的时间间隔
94
97
  *
95
98
  * 单位为 ms
96
99
  *
@@ -103,7 +106,7 @@ export type RipplesUseOptions = {
103
106
  */
104
107
  raindropsTimeInterval: number;
105
108
  /**
106
- * 闲置波动
109
+ * ## 闲置波动
107
110
  *
108
111
  * 在光标交互不触发时,将触发模拟雨滴
109
112
  *
@@ -111,29 +114,42 @@ export type RipplesUseOptions = {
111
114
  */
112
115
  idleFluctuations: boolean;
113
116
  /**
114
- * 是否为暗黑模式
117
+ * ## 是否为暗黑模式
115
118
  *
116
119
  * 在使用默认的主题设置时,当页面使用暗黑模式时出现了文本看不清的现象
117
120
  *
118
121
  */
119
122
  darkMode: boolean | undefined;
123
+ /**
124
+ * ## 初始化时背景色
125
+ * 默认为透明,可传入一个色值,或双色值数组。
126
+ *
127
+ * 当传入的值为双色值数组时:
128
+ *
129
+ * - 第一个色值将被用作默认背景加载色(亮)
130
+ * - 第二个色值将被用作黑色主题背景加载色(暗)
131
+ *
132
+ * **该值仅在初始化用到,后续更改该值*直接*舍弃**
133
+ */
134
+ loadingBackgroundColor: string | [string] | [string, string];
120
135
  };
121
136
  /**
122
137
  *
123
138
  * 涟漪设定参数
124
139
  *
125
- * - resolution 分波速,值越小,波动越快。缺省为 `360`
126
- * - dropRadius 波动强度,值越小,波动效果越大,缺省值为 `12`
127
- * - perturbation 扰动系数,值越大,对原背景造成干涉越强,缺省为 `0.01`
128
- * - interactive 光标交互,缺省为 `true` ,关闭须显示传入 `false` 值
129
140
  * - accelerating 加速光标移动触发,类似于扰动系数,及作用与鼠标或手指触发,缺省为 `1`
130
141
  * - crossOrigin 原始样式
142
+ * - darkMode 暗黑模式,仅用于在默认的背景图时更改默认背景图的背景色,如果使用了 `imgUrl` 配置,请执行处理色差异常
143
+ * - dropRadius 波动强度,值越小,波动效果越大,缺省值为 `12`
131
144
  * - imgUrl 原始背景图片地址
145
+ * - idleFluctuations 闲置波动,在光标交互不触发时,将触发模拟雨滴,缺省为 `true`
146
+ * - interactive 光标交互,缺省为 `true` ,关闭须显示传入 `false` 值
147
+ * - loadingBackgroundColor 初始化加载时背景色,可为单色值或双色值数组(**该值仅在初始化用到,后续更改该值直接舍弃**)
148
+ * - perturbation 扰动系数,值越大,对原背景造成干涉越强,缺省为 `0.01`
132
149
  * - playingState 当前的播放状态,缺省为 `true` ,设定为 `false` 时并不关闭,而是暂停
133
150
  * - raindropsTimeInterval 雨滴滴落的间隔,缺省为 `3650`,可设置区间为 `10 ~ 12000`,值越小,雨越大
151
+ * - resolution 分波速,值越小,波动越快。缺省为 `360`
134
152
  * 该值还将影响无背景设置时默认背景的切换频率,几乎每两个雨滴落下就会切换一次背景
135
- * - idleFluctuations 闲置波动,在光标交互不触发时,将触发模拟雨滴,缺省为 `true`
136
- * - darkMode 暗黑模式,仅用于在默认的背景图时更改默认背景图的背景色,如果使用了 `imgUrl` 配置,请执行处理色差异常
137
153
  */
138
154
  export type RipplesOptions = Partial<RipplesUseOptions>;
139
155
  /**
@@ -142,17 +158,72 @@ export type RipplesOptions = Partial<RipplesUseOptions>;
142
158
  export interface RipplesDefaultData {
143
159
  /** 默认的图像地址 */
144
160
  imgUrl: null;
145
- /** */
161
+ /**
162
+ * ## 波速
163
+ *
164
+ * 作用为波传播的速度,值越大,波传播的越慢
165
+ */
146
166
  resolution: 360;
167
+ /**
168
+ * ## 波动强度
169
+ *
170
+ * 值越小,波动越明显
171
+ */
147
172
  dropRadius: 12;
173
+ /**
174
+ * ## 扰动系数
175
+ *
176
+ * 取之范围 `0.01 - 1`
177
+ *
178
+ * 值越大,扰动效果越明显
179
+ */
148
180
  perturbation: 0.01;
181
+ /** 是否开启光标滑动轨迹 */
149
182
  interactive: true;
183
+ /**
184
+ * ## 图片源
185
+ */
150
186
  crossOrigin: 'no-cors';
187
+ /**
188
+ * ## 当前涟漪的状态
189
+ *
190
+ * 缺省为 `true` , 即涟漪触发正在执行
191
+ */
151
192
  playingState: true;
193
+ /**
194
+ * ## 加速光标移动触发
195
+ *
196
+ * 所以以倍级触发会让波动更加明显
197
+ *
198
+ * 可设置区间为 `2 - 100`
199
+ */
152
200
  accelerating: 1;
201
+ /**
202
+ * ## 雨滴滴落的时间间隔
203
+ *
204
+ * 单位为 ms,可设置区间为 `10 ~ 12000`
205
+ *
206
+ * 该值**还将影响无背景设置时默认背景的*切换频率***,几乎每两个雨滴落下就会切换一次背景
207
+ */
153
208
  raindropsTimeInterval: 3600;
209
+ /**
210
+ * ## 闲置波动
211
+ *
212
+ * 在光标交互不触发时,将触发模拟雨滴
213
+ */
154
214
  idleFluctuations: true;
215
+ /**
216
+ * ## 暗黑模式
217
+ *
218
+ * 在使用默认的主题设置时,当页面使用暗黑模式时出现了文本看不清的现象
219
+ */
155
220
  darkMode: undefined;
221
+ /**
222
+ * ## 初始化时背景色
223
+ *
224
+ * 默认为透明,可传入一个色值,或双色值数组
225
+ */
226
+ loadingBackgroundColor: ['#00000000', '#00000000'];
156
227
  }
157
228
  /**
158
229
  * ## 绘制图像 (内部使用)
@@ -7,7 +7,7 @@
7
7
  * @copyright 2026 ©️ MrMudBean
8
8
  * @since 2025-01-07 11:20
9
9
  * @version 2.0.0-alpha.0
10
- * @lastModified 2026-02-04 08:19
10
+ * @lastModified 2026-02-07 08:12
11
11
  */
12
12
  /**
13
13
  *
@@ -16,7 +16,7 @@
16
16
  * 该数值在组件卸载时会自动调用 `clearTimeout` 清理
17
17
  *
18
18
  * @version 0.0.3
19
- * @see https://earthnut.dev/custom-hooks/use-time-id
19
+ * @see https://lmssee.com/custom-hooks/use-time-id
20
20
  * @example
21
21
  *
22
22
  * 使用:
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "enr",
4
- "version": "2.0.1",
4
+ "version": "2.0.3",
5
5
  "description": "一个 react ui",
6
6
  "peerDependencies": {
7
7
  "react": "^19.1.0",