@tiny-codes/react-easy 1.4.5 → 1.4.7

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 (142) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/es/assets/request-camera-en.js +2 -0
  3. package/es/assets/request-camera-en.js.d.ts +2 -0
  4. package/es/assets/request-camera-en.js.map +1 -0
  5. package/es/assets/request-camera-en.png +0 -0
  6. package/es/assets/request-camera-zh.js +2 -0
  7. package/es/assets/request-camera-zh.js.d.ts +2 -0
  8. package/es/assets/request-camera-zh.js.map +1 -0
  9. package/es/assets/request-camera-zh.png +0 -0
  10. package/es/assets/request-microphone-en.js +2 -0
  11. package/es/assets/request-microphone-en.js.d.ts +2 -0
  12. package/es/assets/request-microphone-en.js.map +1 -0
  13. package/es/assets/request-microphone-en.png +0 -0
  14. package/es/assets/request-microphone-zh.js +2 -0
  15. package/es/assets/request-microphone-zh.js.d.ts +2 -0
  16. package/es/assets/request-microphone-zh.js.map +1 -0
  17. package/es/assets/request-microphone-zh.png +0 -0
  18. package/es/assets/reset-camera-en.js +2 -0
  19. package/es/assets/reset-camera-en.js.d.ts +2 -0
  20. package/es/assets/reset-camera-en.js.map +1 -0
  21. package/es/assets/reset-camera-en.png +0 -0
  22. package/es/assets/reset-camera-zh.js +2 -0
  23. package/es/assets/reset-camera-zh.js.d.ts +2 -0
  24. package/es/assets/reset-camera-zh.js.map +1 -0
  25. package/es/assets/reset-camera-zh.png +0 -0
  26. package/es/assets/reset-microphone-en.js +2 -0
  27. package/es/assets/reset-microphone-en.js.d.ts +2 -0
  28. package/es/assets/reset-microphone-en.js.map +1 -0
  29. package/es/assets/reset-microphone-en.png +0 -0
  30. package/es/assets/reset-microphone-zh.js +2 -0
  31. package/es/assets/reset-microphone-zh.js.d.ts +2 -0
  32. package/es/assets/reset-microphone-zh.js.map +1 -0
  33. package/es/assets/reset-microphone-zh.png +0 -0
  34. package/es/assets/save-default-audio1-en.js +2 -0
  35. package/es/assets/save-default-audio1-en.js.d.ts +2 -0
  36. package/es/assets/save-default-audio1-en.js.map +1 -0
  37. package/es/assets/save-default-audio1-en.png +0 -0
  38. package/es/assets/save-default-audio1-zh.js +2 -0
  39. package/es/assets/save-default-audio1-zh.js.d.ts +2 -0
  40. package/es/assets/save-default-audio1-zh.js.map +1 -0
  41. package/es/assets/save-default-audio1-zh.png +0 -0
  42. package/es/assets/save-default-audio2-en.js +2 -0
  43. package/es/assets/save-default-audio2-en.js.d.ts +2 -0
  44. package/es/assets/save-default-audio2-en.js.map +1 -0
  45. package/es/assets/save-default-audio2-en.png +0 -0
  46. package/es/assets/save-default-audio2-zh.js +2 -0
  47. package/es/assets/save-default-audio2-zh.js.d.ts +2 -0
  48. package/es/assets/save-default-audio2-zh.js.map +1 -0
  49. package/es/assets/save-default-audio2-zh.png +0 -0
  50. package/es/components/ConfigProvider/index.js +1 -0
  51. package/es/components/ConfigProvider/index.js.map +1 -1
  52. package/es/hooks/index.d.ts +1 -0
  53. package/es/hooks/index.js +1 -0
  54. package/es/hooks/index.js.map +1 -1
  55. package/es/hooks/useRefValue.d.ts +2 -2
  56. package/es/hooks/useRefValue.js.map +1 -1
  57. package/es/hooks/useUserMedia.d.ts +104 -0
  58. package/es/hooks/useUserMedia.js +799 -0
  59. package/es/hooks/useUserMedia.js.map +1 -0
  60. package/es/locales/index.d.ts +51 -0
  61. package/es/locales/langs/en-US.d.ts +17 -0
  62. package/es/locales/langs/en-US.js +18 -1
  63. package/es/locales/langs/en-US.js.map +1 -1
  64. package/es/locales/langs/zh-CN.d.ts +17 -0
  65. package/es/locales/langs/zh-CN.js +18 -1
  66. package/es/locales/langs/zh-CN.js.map +1 -1
  67. package/es/utils/math.js +52 -4
  68. package/es/utils/math.js.map +1 -1
  69. package/es/utils/stream.d.ts +68 -0
  70. package/es/utils/stream.js +122 -0
  71. package/es/utils/stream.js.map +1 -0
  72. package/lib/assets/request-camera-en.js +26 -0
  73. package/lib/assets/request-camera-en.js.d.ts +2 -0
  74. package/lib/assets/request-camera-en.js.map +7 -0
  75. package/lib/assets/request-camera-en.png +0 -0
  76. package/lib/assets/request-camera-zh.js +26 -0
  77. package/lib/assets/request-camera-zh.js.d.ts +2 -0
  78. package/lib/assets/request-camera-zh.js.map +7 -0
  79. package/lib/assets/request-camera-zh.png +0 -0
  80. package/lib/assets/request-microphone-en.js +26 -0
  81. package/lib/assets/request-microphone-en.js.d.ts +2 -0
  82. package/lib/assets/request-microphone-en.js.map +7 -0
  83. package/lib/assets/request-microphone-en.png +0 -0
  84. package/lib/assets/request-microphone-zh.js +26 -0
  85. package/lib/assets/request-microphone-zh.js.d.ts +2 -0
  86. package/lib/assets/request-microphone-zh.js.map +7 -0
  87. package/lib/assets/request-microphone-zh.png +0 -0
  88. package/lib/assets/reset-camera-en.js +26 -0
  89. package/lib/assets/reset-camera-en.js.d.ts +2 -0
  90. package/lib/assets/reset-camera-en.js.map +7 -0
  91. package/lib/assets/reset-camera-en.png +0 -0
  92. package/lib/assets/reset-camera-zh.js +26 -0
  93. package/lib/assets/reset-camera-zh.js.d.ts +2 -0
  94. package/lib/assets/reset-camera-zh.js.map +7 -0
  95. package/lib/assets/reset-camera-zh.png +0 -0
  96. package/lib/assets/reset-microphone-en.js +26 -0
  97. package/lib/assets/reset-microphone-en.js.d.ts +2 -0
  98. package/lib/assets/reset-microphone-en.js.map +7 -0
  99. package/lib/assets/reset-microphone-en.png +0 -0
  100. package/lib/assets/reset-microphone-zh.js +26 -0
  101. package/lib/assets/reset-microphone-zh.js.d.ts +2 -0
  102. package/lib/assets/reset-microphone-zh.js.map +7 -0
  103. package/lib/assets/reset-microphone-zh.png +0 -0
  104. package/lib/assets/save-default-audio1-en.js +26 -0
  105. package/lib/assets/save-default-audio1-en.js.d.ts +2 -0
  106. package/lib/assets/save-default-audio1-en.js.map +7 -0
  107. package/lib/assets/save-default-audio1-en.png +0 -0
  108. package/lib/assets/save-default-audio1-zh.js +26 -0
  109. package/lib/assets/save-default-audio1-zh.js.d.ts +2 -0
  110. package/lib/assets/save-default-audio1-zh.js.map +7 -0
  111. package/lib/assets/save-default-audio1-zh.png +0 -0
  112. package/lib/assets/save-default-audio2-en.js +26 -0
  113. package/lib/assets/save-default-audio2-en.js.d.ts +2 -0
  114. package/lib/assets/save-default-audio2-en.js.map +7 -0
  115. package/lib/assets/save-default-audio2-en.png +0 -0
  116. package/lib/assets/save-default-audio2-zh.js +26 -0
  117. package/lib/assets/save-default-audio2-zh.js.d.ts +2 -0
  118. package/lib/assets/save-default-audio2-zh.js.map +7 -0
  119. package/lib/assets/save-default-audio2-zh.png +0 -0
  120. package/lib/components/ConfigProvider/index.js +1 -0
  121. package/lib/components/ConfigProvider/index.js.map +2 -2
  122. package/lib/hooks/index.d.ts +1 -0
  123. package/lib/hooks/index.js +3 -0
  124. package/lib/hooks/index.js.map +2 -2
  125. package/lib/hooks/useRefValue.d.ts +2 -2
  126. package/lib/hooks/useRefValue.js.map +2 -2
  127. package/lib/hooks/useUserMedia.d.ts +104 -0
  128. package/lib/hooks/useUserMedia.js +553 -0
  129. package/lib/hooks/useUserMedia.js.map +7 -0
  130. package/lib/locales/index.d.ts +51 -0
  131. package/lib/locales/langs/en-US.d.ts +17 -0
  132. package/lib/locales/langs/en-US.js +18 -1
  133. package/lib/locales/langs/en-US.js.map +2 -2
  134. package/lib/locales/langs/zh-CN.d.ts +17 -0
  135. package/lib/locales/langs/zh-CN.js +18 -1
  136. package/lib/locales/langs/zh-CN.js.map +2 -2
  137. package/lib/utils/math.js +37 -4
  138. package/lib/utils/math.js.map +2 -2
  139. package/lib/utils/stream.d.ts +68 -0
  140. package/lib/utils/stream.js +101 -0
  141. package/lib/utils/stream.js.map +7 -0
  142. package/package.json +1 -1
@@ -28,6 +28,23 @@ export declare const resources: {
28
28
  readonly 'validation.rule.buildRule.token.lowerLetter': "lowercase letter";
29
29
  readonly 'validation.rule.buildRule.token.upperLetter': "uppercase letter";
30
30
  readonly 'validation.rule.buildRule.token.number': "number";
31
+ readonly 'hooks.useUserMedia.microphone': "Microphone";
32
+ readonly 'hooks.useUserMedia.camera': "Camera";
33
+ readonly 'hooks.featureName.microphone': "Speech";
34
+ readonly 'hooks.featureName.camera': "Video";
35
+ readonly 'hooks.useUserMedia.disabledWarning': "User media is disabled";
36
+ readonly 'hooks.useUserMedia.isRecordingNow': "User media is currently recording and cannot be operated on";
37
+ readonly 'hooks.useUserMedia.devicePermission': "{{deviceType}} Permission";
38
+ readonly 'hooks.useUserMedia.requestTip1': "The browser is requesting {{deviceType}} permission. Please click the \"Allow\" button in the pop-up window that appears later.";
39
+ readonly 'hooks.useUserMedia.requestTip2': "Please do not click the \"Deny\" button, otherwise you will not be able to use the {{featureName}} related feature.";
40
+ readonly 'hooks.useUserMedia.deniedPermission': "You have denied the {{deviceType}} permission, which will prevent you from using the {{featureName}} related feature!";
41
+ readonly 'hooks.useUserMedia.reopenPermissionGuide': "Please click the site settings icon in the address bar, and then follow these steps to reopen {{deviceType}} permission.";
42
+ readonly 'hooks.useUserMedia.notSupport': "Current browser does not support audio recording";
43
+ readonly 'hooks.useUserMedia.soundDetectTitle': "Sound Issue Detected";
44
+ readonly 'hooks.useUserMedia.soundDetectDescription': "No sound seems to be detected. Please check if the microphone is working properly or if the correct audio input device is selected.";
45
+ readonly 'hooks.useUserMedia.chooseMicrophoneDevice': "Please reselect the audio device";
46
+ readonly 'hooks.useUserMedia.rememberDefaultAudioDevice': "Remember default device?";
47
+ readonly 'hooks.useUserMedia.rememberDefaultAudioDeviceTip': "Please follow these steps to save the default audio device for automatic selection next time.";
31
48
  };
32
49
  };
33
50
  readonly 'en-US': {
@@ -56,6 +73,23 @@ export declare const resources: {
56
73
  readonly 'validation.rule.buildRule.token.lowerLetter': "lowercase letter";
57
74
  readonly 'validation.rule.buildRule.token.upperLetter': "uppercase letter";
58
75
  readonly 'validation.rule.buildRule.token.number': "number";
76
+ readonly 'hooks.useUserMedia.microphone': "Microphone";
77
+ readonly 'hooks.useUserMedia.camera': "Camera";
78
+ readonly 'hooks.featureName.microphone': "Speech";
79
+ readonly 'hooks.featureName.camera': "Video";
80
+ readonly 'hooks.useUserMedia.disabledWarning': "User media is disabled";
81
+ readonly 'hooks.useUserMedia.isRecordingNow': "User media is currently recording and cannot be operated on";
82
+ readonly 'hooks.useUserMedia.devicePermission': "{{deviceType}} Permission";
83
+ readonly 'hooks.useUserMedia.requestTip1': "The browser is requesting {{deviceType}} permission. Please click the \"Allow\" button in the pop-up window that appears later.";
84
+ readonly 'hooks.useUserMedia.requestTip2': "Please do not click the \"Deny\" button, otherwise you will not be able to use the {{featureName}} related feature.";
85
+ readonly 'hooks.useUserMedia.deniedPermission': "You have denied the {{deviceType}} permission, which will prevent you from using the {{featureName}} related feature!";
86
+ readonly 'hooks.useUserMedia.reopenPermissionGuide': "Please click the site settings icon in the address bar, and then follow these steps to reopen {{deviceType}} permission.";
87
+ readonly 'hooks.useUserMedia.notSupport': "Current browser does not support audio recording";
88
+ readonly 'hooks.useUserMedia.soundDetectTitle': "Sound Issue Detected";
89
+ readonly 'hooks.useUserMedia.soundDetectDescription': "No sound seems to be detected. Please check if the microphone is working properly or if the correct audio input device is selected.";
90
+ readonly 'hooks.useUserMedia.chooseMicrophoneDevice': "Please reselect the audio device";
91
+ readonly 'hooks.useUserMedia.rememberDefaultAudioDevice': "Remember default device?";
92
+ readonly 'hooks.useUserMedia.rememberDefaultAudioDeviceTip': "Please follow these steps to save the default audio device for automatic selection next time.";
59
93
  };
60
94
  };
61
95
  readonly 'zh-CN': {
@@ -84,6 +118,23 @@ export declare const resources: {
84
118
  readonly 'validation.rule.buildRule.token.lowerLetter': "小写字母";
85
119
  readonly 'validation.rule.buildRule.token.upperLetter': "大写字母";
86
120
  readonly 'validation.rule.buildRule.token.number': "数字";
121
+ readonly 'hooks.useUserMedia.microphone': "麦克风";
122
+ readonly 'hooks.useUserMedia.camera': "摄像头";
123
+ readonly 'hooks.featureName.microphone': "语音";
124
+ readonly 'hooks.featureName.camera': "视频";
125
+ readonly 'hooks.useUserMedia.disabledWarning': "用户媒体已禁用";
126
+ readonly 'hooks.useUserMedia.isRecordingNow': "用户媒体正在录制,不可操作";
127
+ readonly 'hooks.useUserMedia.devicePermission': "{{deviceType}}权限";
128
+ readonly 'hooks.useUserMedia.requestTip1': "浏览器正在申请{{deviceType}}权限,请在稍后弹出的弹窗中点击“访问该网站时允许”按钮。";
129
+ readonly 'hooks.useUserMedia.requestTip2': "请不要点击“不允许”按钮,否则将无法使用{{featureName}}相关功能。";
130
+ readonly 'hooks.useUserMedia.deniedPermission': "您已经拒绝了{{deviceType}}权限,将无法使用{{featureName}}相关功能!";
131
+ readonly 'hooks.useUserMedia.reopenPermissionGuide': "请点击地址栏的站点设置图标,然后按照以下步骤重新打开{{deviceType}}权限。";
132
+ readonly 'hooks.useUserMedia.notSupport': "当前浏览器不支持录制语音";
133
+ readonly 'hooks.useUserMedia.soundDetectTitle': "声音检测到问题";
134
+ readonly 'hooks.useUserMedia.soundDetectDescription': "似乎没有检测到声音,请检查麦克风是否正常工作,或者可能没有选择正确的音频输入设备。";
135
+ readonly 'hooks.useUserMedia.chooseMicrophoneDevice': "请重新选择音频设备";
136
+ readonly 'hooks.useUserMedia.rememberDefaultAudioDevice': "记住默认设备?";
137
+ readonly 'hooks.useUserMedia.rememberDefaultAudioDeviceTip': "请按照以下步骤保存默认音频设备,以便下次使用时自动选择。";
87
138
  };
88
139
  };
89
140
  };
@@ -23,5 +23,22 @@ declare const enUS: {
23
23
  readonly 'validation.rule.buildRule.token.lowerLetter': "lowercase letter";
24
24
  readonly 'validation.rule.buildRule.token.upperLetter': "uppercase letter";
25
25
  readonly 'validation.rule.buildRule.token.number': "number";
26
+ readonly 'hooks.useUserMedia.microphone': "Microphone";
27
+ readonly 'hooks.useUserMedia.camera': "Camera";
28
+ readonly 'hooks.featureName.microphone': "Speech";
29
+ readonly 'hooks.featureName.camera': "Video";
30
+ readonly 'hooks.useUserMedia.disabledWarning': "User media is disabled";
31
+ readonly 'hooks.useUserMedia.isRecordingNow': "User media is currently recording and cannot be operated on";
32
+ readonly 'hooks.useUserMedia.devicePermission': "{{deviceType}} Permission";
33
+ readonly 'hooks.useUserMedia.requestTip1': "The browser is requesting {{deviceType}} permission. Please click the \"Allow\" button in the pop-up window that appears later.";
34
+ readonly 'hooks.useUserMedia.requestTip2': "Please do not click the \"Deny\" button, otherwise you will not be able to use the {{featureName}} related feature.";
35
+ readonly 'hooks.useUserMedia.deniedPermission': "You have denied the {{deviceType}} permission, which will prevent you from using the {{featureName}} related feature!";
36
+ readonly 'hooks.useUserMedia.reopenPermissionGuide': "Please click the site settings icon in the address bar, and then follow these steps to reopen {{deviceType}} permission.";
37
+ readonly 'hooks.useUserMedia.notSupport': "Current browser does not support audio recording";
38
+ readonly 'hooks.useUserMedia.soundDetectTitle': "Sound Issue Detected";
39
+ readonly 'hooks.useUserMedia.soundDetectDescription': "No sound seems to be detected. Please check if the microphone is working properly or if the correct audio input device is selected.";
40
+ readonly 'hooks.useUserMedia.chooseMicrophoneDevice': "Please reselect the audio device";
41
+ readonly 'hooks.useUserMedia.rememberDefaultAudioDevice': "Remember default device?";
42
+ readonly 'hooks.useUserMedia.rememberDefaultAudioDeviceTip': "Please follow these steps to save the default audio device for automatic selection next time.";
26
43
  };
27
44
  export default enUS;
@@ -46,7 +46,24 @@ var enUS = {
46
46
  "validation.rule.buildRule.token.letter": "letter",
47
47
  "validation.rule.buildRule.token.lowerLetter": "lowercase letter",
48
48
  "validation.rule.buildRule.token.upperLetter": "uppercase letter",
49
- "validation.rule.buildRule.token.number": "number"
49
+ "validation.rule.buildRule.token.number": "number",
50
+ "hooks.useUserMedia.microphone": "Microphone",
51
+ "hooks.useUserMedia.camera": "Camera",
52
+ "hooks.featureName.microphone": "Speech",
53
+ "hooks.featureName.camera": "Video",
54
+ "hooks.useUserMedia.disabledWarning": "User media is disabled",
55
+ "hooks.useUserMedia.isRecordingNow": "User media is currently recording and cannot be operated on",
56
+ "hooks.useUserMedia.devicePermission": "{{deviceType}} Permission",
57
+ "hooks.useUserMedia.requestTip1": 'The browser is requesting {{deviceType}} permission. Please click the "Allow" button in the pop-up window that appears later.',
58
+ "hooks.useUserMedia.requestTip2": 'Please do not click the "Deny" button, otherwise you will not be able to use the {{featureName}} related feature.',
59
+ "hooks.useUserMedia.deniedPermission": "You have denied the {{deviceType}} permission, which will prevent you from using the {{featureName}} related feature!",
60
+ "hooks.useUserMedia.reopenPermissionGuide": "Please click the site settings icon in the address bar, and then follow these steps to reopen {{deviceType}} permission.",
61
+ "hooks.useUserMedia.notSupport": "Current browser does not support audio recording",
62
+ "hooks.useUserMedia.soundDetectTitle": "Sound Issue Detected",
63
+ "hooks.useUserMedia.soundDetectDescription": "No sound seems to be detected. Please check if the microphone is working properly or if the correct audio input device is selected.",
64
+ "hooks.useUserMedia.chooseMicrophoneDevice": "Please reselect the audio device",
65
+ "hooks.useUserMedia.rememberDefaultAudioDevice": "Remember default device?",
66
+ "hooks.useUserMedia.rememberDefaultAudioDeviceTip": "Please follow these steps to save the default audio device for automatic selection next time."
50
67
  };
51
68
  var en_US_default = enUS;
52
69
  //# sourceMappingURL=en-US.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/locales/langs/en-US.ts"],
4
- "sourcesContent": ["const enUS = {\n 'components.EditableText.requiredMsg': 'Please enter text content',\n 'components.EditableText.placeholder': 'Please input text content, press Enter or click the OK button',\n 'components.EditableText.edit': 'Edit',\n 'components.EditableText.save': 'Save',\n 'components.EditableText.cancel': 'Cancel',\n 'validation.rule.number.message': 'Please enter a number',\n 'validation.rule.floatNumber.message': 'Please enter a number',\n 'validation.rule.email.message': 'Please enter the correct email address',\n 'validation.rule.ip.message': 'Please enter the correct ip address',\n 'validation.rule.chineseMobile.message': 'Please enter the correct mobile number',\n 'validation.rule.password.message': '8-16 digit password, at least two of numbers, letters, and symbols',\n 'validation.rule.buildRule.includeMandatory': 'At least one field in the include option is true',\n 'validation.rule.buildRule.messageFormat': 'Allow {{content}}',\n 'validation.rule.buildRule.startsWithFormat': `, start with {{prefix}}`,\n 'validation.rule.buildRule.minLength': `, at least {{min}} characters`,\n 'validation.rule.buildRule.maxLength': `, up to {{max}} characters`,\n 'validation.rule.buildRule.rangeLength': `, {{min}}~{{max}} characters`,\n 'validation.rule.buildRule.token.separator': ', ',\n 'validation.rule.buildRule.token.chinese': 'Chinese characters',\n 'validation.rule.buildRule.token.chinesePunctuation': 'Chinese punctuation',\n 'validation.rule.buildRule.token.letter': 'letter',\n 'validation.rule.buildRule.token.lowerLetter': 'lowercase letter',\n 'validation.rule.buildRule.token.upperLetter': 'uppercase letter',\n 'validation.rule.buildRule.token.number': 'number',\n} as const;\nexport default enUS;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAM,OAAO;AAAA,EACX,uCAAuC;AAAA,EACvC,uCAAuC;AAAA,EACvC,gCAAgC;AAAA,EAChC,gCAAgC;AAAA,EAChC,kCAAkC;AAAA,EAClC,kCAAkC;AAAA,EAClC,uCAAuC;AAAA,EACvC,iCAAiC;AAAA,EACjC,8BAA8B;AAAA,EAC9B,yCAAyC;AAAA,EACzC,oCAAoC;AAAA,EACpC,8CAA8C;AAAA,EAC9C,2CAA2C;AAAA,EAC3C,8CAA8C;AAAA,EAC9C,uCAAuC;AAAA,EACvC,uCAAuC;AAAA,EACvC,yCAAyC;AAAA,EACzC,6CAA6C;AAAA,EAC7C,2CAA2C;AAAA,EAC3C,sDAAsD;AAAA,EACtD,0CAA0C;AAAA,EAC1C,+CAA+C;AAAA,EAC/C,+CAA+C;AAAA,EAC/C,0CAA0C;AAC5C;AACA,IAAO,gBAAQ;",
4
+ "sourcesContent": ["const enUS = {\n 'components.EditableText.requiredMsg': 'Please enter text content',\n 'components.EditableText.placeholder': 'Please input text content, press Enter or click the OK button',\n 'components.EditableText.edit': 'Edit',\n 'components.EditableText.save': 'Save',\n 'components.EditableText.cancel': 'Cancel',\n 'validation.rule.number.message': 'Please enter a number',\n 'validation.rule.floatNumber.message': 'Please enter a number',\n 'validation.rule.email.message': 'Please enter the correct email address',\n 'validation.rule.ip.message': 'Please enter the correct ip address',\n 'validation.rule.chineseMobile.message': 'Please enter the correct mobile number',\n 'validation.rule.password.message': '8-16 digit password, at least two of numbers, letters, and symbols',\n 'validation.rule.buildRule.includeMandatory': 'At least one field in the include option is true',\n 'validation.rule.buildRule.messageFormat': 'Allow {{content}}',\n 'validation.rule.buildRule.startsWithFormat': `, start with {{prefix}}`,\n 'validation.rule.buildRule.minLength': `, at least {{min}} characters`,\n 'validation.rule.buildRule.maxLength': `, up to {{max}} characters`,\n 'validation.rule.buildRule.rangeLength': `, {{min}}~{{max}} characters`,\n 'validation.rule.buildRule.token.separator': ', ',\n 'validation.rule.buildRule.token.chinese': 'Chinese characters',\n 'validation.rule.buildRule.token.chinesePunctuation': 'Chinese punctuation',\n 'validation.rule.buildRule.token.letter': 'letter',\n 'validation.rule.buildRule.token.lowerLetter': 'lowercase letter',\n 'validation.rule.buildRule.token.upperLetter': 'uppercase letter',\n 'validation.rule.buildRule.token.number': 'number',\n 'hooks.useUserMedia.microphone': 'Microphone',\n 'hooks.useUserMedia.camera': 'Camera',\n 'hooks.featureName.microphone': 'Speech',\n 'hooks.featureName.camera': 'Video',\n 'hooks.useUserMedia.disabledWarning': 'User media is disabled',\n 'hooks.useUserMedia.isRecordingNow': 'User media is currently recording and cannot be operated on',\n 'hooks.useUserMedia.devicePermission': '{{deviceType}} Permission',\n 'hooks.useUserMedia.requestTip1':\n 'The browser is requesting {{deviceType}} permission. Please click the \"Allow\" button in the pop-up window that appears later.',\n 'hooks.useUserMedia.requestTip2':\n 'Please do not click the \"Deny\" button, otherwise you will not be able to use the {{featureName}} related feature.',\n 'hooks.useUserMedia.deniedPermission':\n 'You have denied the {{deviceType}} permission, which will prevent you from using the {{featureName}} related feature!',\n 'hooks.useUserMedia.reopenPermissionGuide':\n 'Please click the site settings icon in the address bar, and then follow these steps to reopen {{deviceType}} permission.',\n 'hooks.useUserMedia.notSupport': 'Current browser does not support audio recording',\n 'hooks.useUserMedia.soundDetectTitle': 'Sound Issue Detected',\n 'hooks.useUserMedia.soundDetectDescription':\n 'No sound seems to be detected. Please check if the microphone is working properly or if the correct audio input device is selected.',\n 'hooks.useUserMedia.chooseMicrophoneDevice': 'Please reselect the audio device',\n 'hooks.useUserMedia.rememberDefaultAudioDevice': 'Remember default device?',\n 'hooks.useUserMedia.rememberDefaultAudioDeviceTip':\n 'Please follow these steps to save the default audio device for automatic selection next time.',\n} as const;\nexport default enUS;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAM,OAAO;AAAA,EACX,uCAAuC;AAAA,EACvC,uCAAuC;AAAA,EACvC,gCAAgC;AAAA,EAChC,gCAAgC;AAAA,EAChC,kCAAkC;AAAA,EAClC,kCAAkC;AAAA,EAClC,uCAAuC;AAAA,EACvC,iCAAiC;AAAA,EACjC,8BAA8B;AAAA,EAC9B,yCAAyC;AAAA,EACzC,oCAAoC;AAAA,EACpC,8CAA8C;AAAA,EAC9C,2CAA2C;AAAA,EAC3C,8CAA8C;AAAA,EAC9C,uCAAuC;AAAA,EACvC,uCAAuC;AAAA,EACvC,yCAAyC;AAAA,EACzC,6CAA6C;AAAA,EAC7C,2CAA2C;AAAA,EAC3C,sDAAsD;AAAA,EACtD,0CAA0C;AAAA,EAC1C,+CAA+C;AAAA,EAC/C,+CAA+C;AAAA,EAC/C,0CAA0C;AAAA,EAC1C,iCAAiC;AAAA,EACjC,6BAA6B;AAAA,EAC7B,gCAAgC;AAAA,EAChC,4BAA4B;AAAA,EAC5B,sCAAsC;AAAA,EACtC,qCAAqC;AAAA,EACrC,uCAAuC;AAAA,EACvC,kCACE;AAAA,EACF,kCACE;AAAA,EACF,uCACE;AAAA,EACF,4CACE;AAAA,EACF,iCAAiC;AAAA,EACjC,uCAAuC;AAAA,EACvC,6CACE;AAAA,EACF,6CAA6C;AAAA,EAC7C,iDAAiD;AAAA,EACjD,oDACE;AACJ;AACA,IAAO,gBAAQ;",
6
6
  "names": []
7
7
  }
@@ -23,5 +23,22 @@ declare const zhCN: {
23
23
  readonly 'validation.rule.buildRule.token.lowerLetter': "小写字母";
24
24
  readonly 'validation.rule.buildRule.token.upperLetter': "大写字母";
25
25
  readonly 'validation.rule.buildRule.token.number': "数字";
26
+ readonly 'hooks.useUserMedia.microphone': "麦克风";
27
+ readonly 'hooks.useUserMedia.camera': "摄像头";
28
+ readonly 'hooks.featureName.microphone': "语音";
29
+ readonly 'hooks.featureName.camera': "视频";
30
+ readonly 'hooks.useUserMedia.disabledWarning': "用户媒体已禁用";
31
+ readonly 'hooks.useUserMedia.isRecordingNow': "用户媒体正在录制,不可操作";
32
+ readonly 'hooks.useUserMedia.devicePermission': "{{deviceType}}权限";
33
+ readonly 'hooks.useUserMedia.requestTip1': "浏览器正在申请{{deviceType}}权限,请在稍后弹出的弹窗中点击“访问该网站时允许”按钮。";
34
+ readonly 'hooks.useUserMedia.requestTip2': "请不要点击“不允许”按钮,否则将无法使用{{featureName}}相关功能。";
35
+ readonly 'hooks.useUserMedia.deniedPermission': "您已经拒绝了{{deviceType}}权限,将无法使用{{featureName}}相关功能!";
36
+ readonly 'hooks.useUserMedia.reopenPermissionGuide': "请点击地址栏的站点设置图标,然后按照以下步骤重新打开{{deviceType}}权限。";
37
+ readonly 'hooks.useUserMedia.notSupport': "当前浏览器不支持录制语音";
38
+ readonly 'hooks.useUserMedia.soundDetectTitle': "声音检测到问题";
39
+ readonly 'hooks.useUserMedia.soundDetectDescription': "似乎没有检测到声音,请检查麦克风是否正常工作,或者可能没有选择正确的音频输入设备。";
40
+ readonly 'hooks.useUserMedia.chooseMicrophoneDevice': "请重新选择音频设备";
41
+ readonly 'hooks.useUserMedia.rememberDefaultAudioDevice': "记住默认设备?";
42
+ readonly 'hooks.useUserMedia.rememberDefaultAudioDeviceTip': "请按照以下步骤保存默认音频设备,以便下次使用时自动选择。";
26
43
  };
27
44
  export default zhCN;
@@ -46,7 +46,24 @@ var zhCN = {
46
46
  "validation.rule.buildRule.token.letter": "字母",
47
47
  "validation.rule.buildRule.token.lowerLetter": "小写字母",
48
48
  "validation.rule.buildRule.token.upperLetter": "大写字母",
49
- "validation.rule.buildRule.token.number": "数字"
49
+ "validation.rule.buildRule.token.number": "数字",
50
+ "hooks.useUserMedia.microphone": "麦克风",
51
+ "hooks.useUserMedia.camera": "摄像头",
52
+ "hooks.featureName.microphone": "语音",
53
+ "hooks.featureName.camera": "视频",
54
+ "hooks.useUserMedia.disabledWarning": "用户媒体已禁用",
55
+ "hooks.useUserMedia.isRecordingNow": "用户媒体正在录制,不可操作",
56
+ "hooks.useUserMedia.devicePermission": "{{deviceType}}权限",
57
+ "hooks.useUserMedia.requestTip1": "浏览器正在申请{{deviceType}}权限,请在稍后弹出的弹窗中点击“访问该网站时允许”按钮。",
58
+ "hooks.useUserMedia.requestTip2": "请不要点击“不允许”按钮,否则将无法使用{{featureName}}相关功能。",
59
+ "hooks.useUserMedia.deniedPermission": "您已经拒绝了{{deviceType}}权限,将无法使用{{featureName}}相关功能!",
60
+ "hooks.useUserMedia.reopenPermissionGuide": "请点击地址栏的站点设置图标,然后按照以下步骤重新打开{{deviceType}}权限。",
61
+ "hooks.useUserMedia.notSupport": "当前浏览器不支持录制语音",
62
+ "hooks.useUserMedia.soundDetectTitle": "声音检测到问题",
63
+ "hooks.useUserMedia.soundDetectDescription": "似乎没有检测到声音,请检查麦克风是否正常工作,或者可能没有选择正确的音频输入设备。",
64
+ "hooks.useUserMedia.chooseMicrophoneDevice": "请重新选择音频设备",
65
+ "hooks.useUserMedia.rememberDefaultAudioDevice": "记住默认设备?",
66
+ "hooks.useUserMedia.rememberDefaultAudioDeviceTip": "请按照以下步骤保存默认音频设备,以便下次使用时自动选择。"
50
67
  };
51
68
  var zh_CN_default = zhCN;
52
69
  //# sourceMappingURL=zh-CN.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/locales/langs/zh-CN.ts"],
4
- "sourcesContent": ["const zhCN = {\n 'components.EditableText.requiredMsg': '请输入文本内容',\n 'components.EditableText.placeholder': '输入文本内容,按回车或点击确定按钮',\n 'components.EditableText.edit': '编辑',\n 'components.EditableText.save': '保存',\n 'components.EditableText.cancel': '取消',\n 'validation.rule.number.message': '请输入数字',\n 'validation.rule.floatNumber.message': '请输入数字',\n 'validation.rule.email.message': '请输入正确的邮箱地址',\n 'validation.rule.ip.message': '请输入正确的ip地址',\n 'validation.rule.chineseMobile.message': '请输入正确的手机号',\n 'validation.rule.password.message': '8-16位密码,数字、字母、符号至少包含两种',\n 'validation.rule.buildRule.includeMandatory': 'include选项中至少有一个字段为true',\n 'validation.rule.buildRule.messageFormat': '支持{{content}}',\n 'validation.rule.buildRule.startsWithFormat': `,以{{prefix}}开头`,\n 'validation.rule.buildRule.minLength': `,至少{{min}}字符`,\n 'validation.rule.buildRule.maxLength': `,{{max}}字符以内`,\n 'validation.rule.buildRule.rangeLength': `,{{min}}~{{max}}个字符`,\n 'validation.rule.buildRule.token.separator': '、',\n 'validation.rule.buildRule.token.chinese': '汉字',\n 'validation.rule.buildRule.token.chinesePunctuation': '中文标点',\n 'validation.rule.buildRule.token.letter': '字母',\n 'validation.rule.buildRule.token.lowerLetter': '小写字母',\n 'validation.rule.buildRule.token.upperLetter': '大写字母',\n 'validation.rule.buildRule.token.number': '数字',\n} as const;\nexport default zhCN;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAM,OAAO;AAAA,EACX,uCAAuC;AAAA,EACvC,uCAAuC;AAAA,EACvC,gCAAgC;AAAA,EAChC,gCAAgC;AAAA,EAChC,kCAAkC;AAAA,EAClC,kCAAkC;AAAA,EAClC,uCAAuC;AAAA,EACvC,iCAAiC;AAAA,EACjC,8BAA8B;AAAA,EAC9B,yCAAyC;AAAA,EACzC,oCAAoC;AAAA,EACpC,8CAA8C;AAAA,EAC9C,2CAA2C;AAAA,EAC3C,8CAA8C;AAAA,EAC9C,uCAAuC;AAAA,EACvC,uCAAuC;AAAA,EACvC,yCAAyC;AAAA,EACzC,6CAA6C;AAAA,EAC7C,2CAA2C;AAAA,EAC3C,sDAAsD;AAAA,EACtD,0CAA0C;AAAA,EAC1C,+CAA+C;AAAA,EAC/C,+CAA+C;AAAA,EAC/C,0CAA0C;AAC5C;AACA,IAAO,gBAAQ;",
4
+ "sourcesContent": ["const zhCN = {\n 'components.EditableText.requiredMsg': '请输入文本内容',\n 'components.EditableText.placeholder': '输入文本内容,按回车或点击确定按钮',\n 'components.EditableText.edit': '编辑',\n 'components.EditableText.save': '保存',\n 'components.EditableText.cancel': '取消',\n 'validation.rule.number.message': '请输入数字',\n 'validation.rule.floatNumber.message': '请输入数字',\n 'validation.rule.email.message': '请输入正确的邮箱地址',\n 'validation.rule.ip.message': '请输入正确的ip地址',\n 'validation.rule.chineseMobile.message': '请输入正确的手机号',\n 'validation.rule.password.message': '8-16位密码,数字、字母、符号至少包含两种',\n 'validation.rule.buildRule.includeMandatory': 'include选项中至少有一个字段为true',\n 'validation.rule.buildRule.messageFormat': '支持{{content}}',\n 'validation.rule.buildRule.startsWithFormat': `,以{{prefix}}开头`,\n 'validation.rule.buildRule.minLength': `,至少{{min}}字符`,\n 'validation.rule.buildRule.maxLength': `,{{max}}字符以内`,\n 'validation.rule.buildRule.rangeLength': `,{{min}}~{{max}}个字符`,\n 'validation.rule.buildRule.token.separator': '、',\n 'validation.rule.buildRule.token.chinese': '汉字',\n 'validation.rule.buildRule.token.chinesePunctuation': '中文标点',\n 'validation.rule.buildRule.token.letter': '字母',\n 'validation.rule.buildRule.token.lowerLetter': '小写字母',\n 'validation.rule.buildRule.token.upperLetter': '大写字母',\n 'validation.rule.buildRule.token.number': '数字',\n 'hooks.useUserMedia.microphone': '麦克风',\n 'hooks.useUserMedia.camera': '摄像头',\n 'hooks.featureName.microphone': '语音',\n 'hooks.featureName.camera': '视频',\n 'hooks.useUserMedia.disabledWarning': '用户媒体已禁用',\n 'hooks.useUserMedia.isRecordingNow': '用户媒体正在录制,不可操作',\n 'hooks.useUserMedia.devicePermission': '{{deviceType}}权限',\n 'hooks.useUserMedia.requestTip1':\n '浏览器正在申请{{deviceType}}权限,请在稍后弹出的弹窗中点击“访问该网站时允许”按钮。',\n 'hooks.useUserMedia.requestTip2': '请不要点击“不允许”按钮,否则将无法使用{{featureName}}相关功能。',\n 'hooks.useUserMedia.deniedPermission': '您已经拒绝了{{deviceType}}权限,将无法使用{{featureName}}相关功能!',\n 'hooks.useUserMedia.reopenPermissionGuide':\n '请点击地址栏的站点设置图标,然后按照以下步骤重新打开{{deviceType}}权限。',\n 'hooks.useUserMedia.notSupport': '当前浏览器不支持录制语音',\n 'hooks.useUserMedia.soundDetectTitle': '声音检测到问题',\n 'hooks.useUserMedia.soundDetectDescription':\n '似乎没有检测到声音,请检查麦克风是否正常工作,或者可能没有选择正确的音频输入设备。',\n 'hooks.useUserMedia.chooseMicrophoneDevice': '请重新选择音频设备',\n 'hooks.useUserMedia.rememberDefaultAudioDevice': '记住默认设备?',\n 'hooks.useUserMedia.rememberDefaultAudioDeviceTip': '请按照以下步骤保存默认音频设备,以便下次使用时自动选择。',\n} as const;\nexport default zhCN;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAM,OAAO;AAAA,EACX,uCAAuC;AAAA,EACvC,uCAAuC;AAAA,EACvC,gCAAgC;AAAA,EAChC,gCAAgC;AAAA,EAChC,kCAAkC;AAAA,EAClC,kCAAkC;AAAA,EAClC,uCAAuC;AAAA,EACvC,iCAAiC;AAAA,EACjC,8BAA8B;AAAA,EAC9B,yCAAyC;AAAA,EACzC,oCAAoC;AAAA,EACpC,8CAA8C;AAAA,EAC9C,2CAA2C;AAAA,EAC3C,8CAA8C;AAAA,EAC9C,uCAAuC;AAAA,EACvC,uCAAuC;AAAA,EACvC,yCAAyC;AAAA,EACzC,6CAA6C;AAAA,EAC7C,2CAA2C;AAAA,EAC3C,sDAAsD;AAAA,EACtD,0CAA0C;AAAA,EAC1C,+CAA+C;AAAA,EAC/C,+CAA+C;AAAA,EAC/C,0CAA0C;AAAA,EAC1C,iCAAiC;AAAA,EACjC,6BAA6B;AAAA,EAC7B,gCAAgC;AAAA,EAChC,4BAA4B;AAAA,EAC5B,sCAAsC;AAAA,EACtC,qCAAqC;AAAA,EACrC,uCAAuC;AAAA,EACvC,kCACE;AAAA,EACF,kCAAkC;AAAA,EAClC,uCAAuC;AAAA,EACvC,4CACE;AAAA,EACF,iCAAiC;AAAA,EACjC,uCAAuC;AAAA,EACvC,6CACE;AAAA,EACF,6CAA6C;AAAA,EAC7C,iDAAiD;AAAA,EACjD,oDAAoD;AACtD;AACA,IAAO,gBAAQ;",
6
6
  "names": []
7
7
  }
package/lib/utils/math.js CHANGED
@@ -23,10 +23,43 @@ __export(math_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(math_exports);
25
25
  function random(min, max) {
26
- const array = new Uint32Array(1);
27
- globalThis.crypto.getRandomValues(array);
28
- const randomValue = array[0] / (4294967295 + 1);
29
- return Math.floor(randomValue * (max - min + 1)) + min;
26
+ var _a;
27
+ if (!Number.isFinite(min) || !Number.isFinite(max)) {
28
+ throw new TypeError("min and max must be finite numbers");
29
+ }
30
+ if (Math.floor(min) !== min || Math.floor(max) !== max) {
31
+ throw new TypeError("min and max must be integers");
32
+ }
33
+ if (min > max) {
34
+ [min, max] = [max, min];
35
+ }
36
+ let nodeCrypto;
37
+ if (typeof process !== "undefined" && ((_a = process.versions) == null ? void 0 : _a.node)) {
38
+ try {
39
+ nodeCrypto = require("crypto");
40
+ } catch {
41
+ }
42
+ }
43
+ if (nodeCrypto == null ? void 0 : nodeCrypto.randomInt) {
44
+ return nodeCrypto.randomInt(min, max + 1);
45
+ }
46
+ const webCrypto = globalThis.crypto || (nodeCrypto == null ? void 0 : nodeCrypto.webcrypto);
47
+ if (webCrypto == null ? void 0 : webCrypto.getRandomValues) {
48
+ const range = max - min + 1;
49
+ if (range <= 0)
50
+ return min;
51
+ const maxUint32 = 4294967295;
52
+ const limit = Math.floor((maxUint32 + 1) / range) * range;
53
+ const arr = new Uint32Array(1);
54
+ let v;
55
+ do {
56
+ webCrypto.getRandomValues(arr);
57
+ v = arr[0];
58
+ } while (v >= limit);
59
+ return min + v % range;
60
+ }
61
+ const _math = Math;
62
+ return Math.floor(_math.random() * (max - min + 1)) + min;
30
63
  }
31
64
  // Annotate the CommonJS export names for ESM import in node:
32
65
  0 && (module.exports = {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/math.ts"],
4
- "sourcesContent": ["/**\n * **EN**: Generate a random number within a specified range (inclusive on both ends)\n *\n * **CN**: 生成指定范围(两端包含)内的随机数\n *\n * @param min The minimum value (inclusive) | 最小值(包含)\n * @param max The maximum value (inclusive) | 最大值(包含)\n *\n * @returns The generated random number | 生成的随机数\n */\nexport function random(min: number, max: number): number {\n const array = new Uint32Array(1);\n globalThis.crypto.getRandomValues(array);\n const randomValue = array[0] / (0xffffffff + 1);\n return Math.floor(randomValue * (max - min + 1)) + min;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUO,SAAS,OAAO,KAAa,KAAqB;AACvD,QAAM,QAAQ,IAAI,YAAY,CAAC;AAC/B,aAAW,OAAO,gBAAgB,KAAK;AACvC,QAAM,cAAc,MAAM,CAAC,KAAK,aAAa;AAC7C,SAAO,KAAK,MAAM,eAAe,MAAM,MAAM,EAAE,IAAI;AACrD;",
4
+ "sourcesContent": ["/**\n * **EN**: Generate a random number within a specified range (inclusive on both ends)\n *\n * **CN**: 生成指定范围(两端包含)内的随机数\n *\n * @param min The minimum value (inclusive) | 最小值(包含)\n * @param max The maximum value (inclusive) | 最大值(包含)\n *\n * @returns The generated random number | 生成的随机数\n */\nexport function random(min: number, max: number): number {\n if (!Number.isFinite(min) || !Number.isFinite(max)) {\n throw new TypeError('min and max must be finite numbers');\n }\n if (Math.floor(min) !== min || Math.floor(max) !== max) {\n throw new TypeError('min and max must be integers');\n }\n if (min > max) {\n [min, max] = [max, min];\n }\n\n // Try to require Node.js crypto\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let nodeCrypto: any;\n if (typeof process !== 'undefined' && process.versions?.node) {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n nodeCrypto = require('crypto');\n } catch {\n // ignore\n }\n }\n\n // 1. Node.js crypto.randomInt\n if (nodeCrypto?.randomInt) {\n return nodeCrypto.randomInt(min, max + 1);\n }\n\n // 2. Web Crypto (Browsers or Node 19+ webcrypto)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const webCrypto: Crypto | undefined = (globalThis as any).crypto || nodeCrypto?.webcrypto;\n\n if (webCrypto?.getRandomValues) {\n const range = max - min + 1;\n if (range <= 0) return min;\n\n // 使用拒绝采样避免 (2^32 % range) 造成的微小偏差\n const maxUint32 = 0xffffffff;\n const limit = Math.floor((maxUint32 + 1) / range) * range;\n const arr = new Uint32Array(1);\n let v: number;\n do {\n webCrypto.getRandomValues(arr);\n v = arr[0];\n } while (v >= limit);\n return min + (v % range);\n }\n\n // 3. Fallback, should not be used for cryptographic purposes\n const _math = Math;\n return Math.floor(_math.random() * (max - min + 1)) + min;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUO,SAAS,OAAO,KAAa,KAAqB;AAVzD;AAWE,MAAI,CAAC,OAAO,SAAS,GAAG,KAAK,CAAC,OAAO,SAAS,GAAG,GAAG;AAClD,UAAM,IAAI,UAAU,oCAAoC;AAAA,EAC1D;AACA,MAAI,KAAK,MAAM,GAAG,MAAM,OAAO,KAAK,MAAM,GAAG,MAAM,KAAK;AACtD,UAAM,IAAI,UAAU,8BAA8B;AAAA,EACpD;AACA,MAAI,MAAM,KAAK;AACb,KAAC,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG;AAAA,EACxB;AAIA,MAAI;AACJ,MAAI,OAAO,YAAY,iBAAe,aAAQ,aAAR,mBAAkB,OAAM;AAC5D,QAAI;AAEF,mBAAa,QAAQ,QAAQ;AAAA,IAC/B,QAAE;AAAA,IAEF;AAAA,EACF;AAGA,MAAI,yCAAY,WAAW;AACzB,WAAO,WAAW,UAAU,KAAK,MAAM,CAAC;AAAA,EAC1C;AAIA,QAAM,YAAiC,WAAmB,WAAU,yCAAY;AAEhF,MAAI,uCAAW,iBAAiB;AAC9B,UAAM,QAAQ,MAAM,MAAM;AAC1B,QAAI,SAAS;AAAG,aAAO;AAGvB,UAAM,YAAY;AAClB,UAAM,QAAQ,KAAK,OAAO,YAAY,KAAK,KAAK,IAAI;AACpD,UAAM,MAAM,IAAI,YAAY,CAAC;AAC7B,QAAI;AACJ,OAAG;AACD,gBAAU,gBAAgB,GAAG;AAC7B,UAAI,IAAI,CAAC;AAAA,IACX,SAAS,KAAK;AACd,WAAO,MAAO,IAAI;AAAA,EACpB;AAGA,QAAM,QAAQ;AACd,SAAO,KAAK,MAAM,MAAM,OAAO,KAAK,MAAM,MAAM,EAAE,IAAI;AACxD;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,68 @@
1
+ /**
2
+ * - **EN:** A stream time slicer for splitting audio streams into fixed time segments
3
+ * - **CN:** 一个数据流时间切片器,用于将音频流分成固定时间段
4
+ */
5
+ export declare class StreamTimeSlicerClass implements StreamTimeSlicer {
6
+ timeSlice: number;
7
+ private readonly onSlice;
8
+ private channelChunks;
9
+ private startTs;
10
+ constructor(options: StreamTimeSlicerOptions);
11
+ private now;
12
+ private shouldEmit;
13
+ private emit;
14
+ push(channels: Float32Array[]): void;
15
+ flush(): void;
16
+ reset(): void;
17
+ duration(): number;
18
+ }
19
+ export interface StreamTimeSlicerOptions {
20
+ /**
21
+ * - **EN:** Duration of each slice (ms)
22
+ * - **CN:** 分片时长(ms)
23
+ */
24
+ timeSlice: number;
25
+ /**
26
+ * - **EN:** Callback when a slice is reached
27
+ * - **CN:** 达到分片时回调
28
+ *
29
+ * @param channels - Multi-channel data, each channel is a Float32Array | 多通道数据,每个通道是一个
30
+ * Float32Array
31
+ * @param sliceDuration - Duration of the slice (ms) | 分片时长(ms)
32
+ */
33
+ onSlice: (channels: Float32Array[], sliceDuration: number) => void;
34
+ }
35
+ /**
36
+ * - **EN:** stream time slicer
37
+ * - **CN:** 数据流时间切片器
38
+ */
39
+ export interface StreamTimeSlicer {
40
+ /**
41
+ * - **EN:** Duration of each slice (ms)
42
+ * - **CN:** 每个分片的时长(毫秒)
43
+ */
44
+ timeSlice: number;
45
+ /**
46
+ * - **EN:** Push a frame (multi-channel data obtained from the same callback)
47
+ * - **CN:** 推入一帧(同一次回调得到的多通道)
48
+ *
49
+ * @param channels - Multi-channel data, each channel is a Float32Array | 多通道数据,每个通道是一个
50
+ * Float32Array
51
+ */
52
+ push: (channels: Float32Array[]) => void;
53
+ /**
54
+ * - **EN:** Force output the current accumulation (output even if not enough timeSlice)
55
+ * - **CN:** 强制输出当前累积(不足 timeSlice 也输出)
56
+ */
57
+ flush: () => void;
58
+ /**
59
+ * - **EN:** Clear the cache (do not output)
60
+ * - **CN:** 清空缓存(不输出)
61
+ */
62
+ reset: () => void;
63
+ /**
64
+ * - **EN:** Get the accumulated duration from start to current (ms)
65
+ * - **CN:** 获取从开始到当前已累计的时长(ms)
66
+ */
67
+ duration: () => number;
68
+ }
@@ -0,0 +1,101 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/utils/stream.ts
20
+ var stream_exports = {};
21
+ __export(stream_exports, {
22
+ StreamTimeSlicerClass: () => StreamTimeSlicerClass
23
+ });
24
+ module.exports = __toCommonJS(stream_exports);
25
+ var StreamTimeSlicerClass = class {
26
+ constructor(options) {
27
+ this.channelChunks = [];
28
+ this.startTs = null;
29
+ this.timeSlice = options.timeSlice;
30
+ this.onSlice = options.onSlice;
31
+ }
32
+ now() {
33
+ return typeof performance !== "undefined" ? performance.now() : Date.now();
34
+ }
35
+ shouldEmit(currentTs) {
36
+ if (this.startTs == null)
37
+ return false;
38
+ if (this.timeSlice <= 0)
39
+ return true;
40
+ return currentTs - this.startTs >= this.timeSlice;
41
+ }
42
+ emit(force = false) {
43
+ if (this.startTs == null)
44
+ return;
45
+ const currentTs = this.now();
46
+ if (!force && !this.shouldEmit(currentTs))
47
+ return;
48
+ if (this.channelChunks.length === 0 || this.channelChunks.every((arr) => arr.length === 0)) {
49
+ this.startTs = null;
50
+ for (let i = 0; i < this.channelChunks.length; i++)
51
+ this.channelChunks[i] = [];
52
+ return;
53
+ }
54
+ const merged = this.channelChunks.map((chArr) => {
55
+ const total = chArr.reduce((s, a) => s + a.length, 0);
56
+ const out = new Float32Array(total);
57
+ let offset = 0;
58
+ for (const seg of chArr) {
59
+ out.set(seg, offset);
60
+ offset += seg.length;
61
+ }
62
+ return out;
63
+ });
64
+ const sliceDur = this.startTs != null ? currentTs - this.startTs : 0;
65
+ this.onSlice(merged, sliceDur);
66
+ for (let i = 0; i < this.channelChunks.length; i++)
67
+ this.channelChunks[i] = [];
68
+ this.startTs = null;
69
+ }
70
+ push(channels) {
71
+ if (!channels || channels.length === 0)
72
+ return;
73
+ if (this.startTs == null)
74
+ this.startTs = this.now();
75
+ while (this.channelChunks.length < channels.length) {
76
+ this.channelChunks.push([]);
77
+ }
78
+ channels.forEach((ch, i) => {
79
+ this.channelChunks[i].push(ch);
80
+ });
81
+ this.emit(false);
82
+ if (this.timeSlice <= 0)
83
+ this.emit(true);
84
+ }
85
+ flush() {
86
+ this.emit(true);
87
+ }
88
+ reset() {
89
+ for (let i = 0; i < this.channelChunks.length; i++)
90
+ this.channelChunks[i] = [];
91
+ this.startTs = null;
92
+ }
93
+ duration() {
94
+ return this.startTs == null ? 0 : this.now() - this.startTs;
95
+ }
96
+ };
97
+ // Annotate the CommonJS export names for ESM import in node:
98
+ 0 && (module.exports = {
99
+ StreamTimeSlicerClass
100
+ });
101
+ //# sourceMappingURL=stream.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/stream.ts"],
4
+ "sourcesContent": ["/**\n * - **EN:** A stream time slicer for splitting audio streams into fixed time segments\n * - **CN:** 一个数据流时间切片器,用于将音频流分成固定时间段\n */\nexport class StreamTimeSlicerClass implements StreamTimeSlicer {\n timeSlice: number;\n private readonly onSlice: (channels: Float32Array[], sliceDurationMs: number) => void;\n private channelChunks: Float32Array[][] = [];\n private startTs: number | null = null;\n\n constructor(options: StreamTimeSlicerOptions) {\n this.timeSlice = options.timeSlice;\n this.onSlice = options.onSlice;\n }\n\n private now() {\n return typeof performance !== 'undefined' ? performance.now() : Date.now();\n }\n\n private shouldEmit(currentTs: number) {\n if (this.startTs == null) return false;\n if (this.timeSlice <= 0) return true;\n return currentTs - this.startTs >= this.timeSlice;\n }\n\n private emit(force = false) {\n if (this.startTs == null) return;\n const currentTs = this.now();\n if (!force && !this.shouldEmit(currentTs)) return;\n\n // reset start time\n if (this.channelChunks.length === 0 || this.channelChunks.every((arr) => arr.length === 0)) {\n this.startTs = null;\n for (let i = 0; i < this.channelChunks.length; i++) this.channelChunks[i] = [];\n return;\n }\n\n // Merge each channel\n const merged: Float32Array[] = this.channelChunks.map((chArr) => {\n const total = chArr.reduce((s, a) => s + a.length, 0);\n const out = new Float32Array(total);\n let offset = 0;\n for (const seg of chArr) {\n out.set(seg, offset);\n offset += seg.length;\n }\n return out;\n });\n\n const sliceDur = this.startTs != null ? currentTs - this.startTs : 0;\n this.onSlice(merged, sliceDur);\n\n // Reset start time\n for (let i = 0; i < this.channelChunks.length; i++) this.channelChunks[i] = [];\n this.startTs = null;\n }\n\n push(channels: Float32Array[]) {\n if (!channels || channels.length === 0) return;\n if (this.startTs == null) this.startTs = this.now();\n\n while (this.channelChunks.length < channels.length) {\n this.channelChunks.push([]);\n }\n channels.forEach((ch, i) => {\n this.channelChunks[i].push(ch);\n });\n\n this.emit(false);\n if (this.timeSlice <= 0) this.emit(true); // immediate output mode\n }\n\n flush() {\n this.emit(true);\n }\n\n reset() {\n for (let i = 0; i < this.channelChunks.length; i++) this.channelChunks[i] = [];\n this.startTs = null;\n }\n\n duration() {\n return this.startTs == null ? 0 : this.now() - this.startTs;\n }\n}\nexport interface StreamTimeSlicerOptions {\n /**\n * - **EN:** Duration of each slice (ms)\n * - **CN:** 分片时长(ms)\n */\n timeSlice: number;\n /**\n * - **EN:** Callback when a slice is reached\n * - **CN:** 达到分片时回调\n *\n * @param channels - Multi-channel data, each channel is a Float32Array | 多通道数据,每个通道是一个\n * Float32Array\n * @param sliceDuration - Duration of the slice (ms) | 分片时长(ms)\n */\n onSlice: (channels: Float32Array[], sliceDuration: number) => void;\n}\n\n/**\n * - **EN:** stream time slicer\n * - **CN:** 数据流时间切片器\n */\nexport interface StreamTimeSlicer {\n /**\n * - **EN:** Duration of each slice (ms)\n * - **CN:** 每个分片的时长(毫秒)\n */\n timeSlice: number;\n /**\n * - **EN:** Push a frame (multi-channel data obtained from the same callback)\n * - **CN:** 推入一帧(同一次回调得到的多通道)\n *\n * @param channels - Multi-channel data, each channel is a Float32Array | 多通道数据,每个通道是一个\n * Float32Array\n */\n push: (channels: Float32Array[]) => void;\n /**\n * - **EN:** Force output the current accumulation (output even if not enough timeSlice)\n * - **CN:** 强制输出当前累积(不足 timeSlice 也输出)\n */\n flush: () => void;\n /**\n * - **EN:** Clear the cache (do not output)\n * - **CN:** 清空缓存(不输出)\n */\n reset: () => void;\n /**\n * - **EN:** Get the accumulated duration from start to current (ms)\n * - **CN:** 获取从开始到当前已累计的时长(ms)\n */\n duration: () => number;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIO,IAAM,wBAAN,MAAwD;AAAA,EAM7D,YAAY,SAAkC;AAH9C,SAAQ,gBAAkC,CAAC;AAC3C,SAAQ,UAAyB;AAG/B,SAAK,YAAY,QAAQ;AACzB,SAAK,UAAU,QAAQ;AAAA,EACzB;AAAA,EAEQ,MAAM;AACZ,WAAO,OAAO,gBAAgB,cAAc,YAAY,IAAI,IAAI,KAAK,IAAI;AAAA,EAC3E;AAAA,EAEQ,WAAW,WAAmB;AACpC,QAAI,KAAK,WAAW;AAAM,aAAO;AACjC,QAAI,KAAK,aAAa;AAAG,aAAO;AAChC,WAAO,YAAY,KAAK,WAAW,KAAK;AAAA,EAC1C;AAAA,EAEQ,KAAK,QAAQ,OAAO;AAC1B,QAAI,KAAK,WAAW;AAAM;AAC1B,UAAM,YAAY,KAAK,IAAI;AAC3B,QAAI,CAAC,SAAS,CAAC,KAAK,WAAW,SAAS;AAAG;AAG3C,QAAI,KAAK,cAAc,WAAW,KAAK,KAAK,cAAc,MAAM,CAAC,QAAQ,IAAI,WAAW,CAAC,GAAG;AAC1F,WAAK,UAAU;AACf,eAAS,IAAI,GAAG,IAAI,KAAK,cAAc,QAAQ;AAAK,aAAK,cAAc,CAAC,IAAI,CAAC;AAC7E;AAAA,IACF;AAGA,UAAM,SAAyB,KAAK,cAAc,IAAI,CAAC,UAAU;AAC/D,YAAM,QAAQ,MAAM,OAAO,CAAC,GAAG,MAAM,IAAI,EAAE,QAAQ,CAAC;AACpD,YAAM,MAAM,IAAI,aAAa,KAAK;AAClC,UAAI,SAAS;AACb,iBAAW,OAAO,OAAO;AACvB,YAAI,IAAI,KAAK,MAAM;AACnB,kBAAU,IAAI;AAAA,MAChB;AACA,aAAO;AAAA,IACT,CAAC;AAED,UAAM,WAAW,KAAK,WAAW,OAAO,YAAY,KAAK,UAAU;AACnE,SAAK,QAAQ,QAAQ,QAAQ;AAG7B,aAAS,IAAI,GAAG,IAAI,KAAK,cAAc,QAAQ;AAAK,WAAK,cAAc,CAAC,IAAI,CAAC;AAC7E,SAAK,UAAU;AAAA,EACjB;AAAA,EAEA,KAAK,UAA0B;AAC7B,QAAI,CAAC,YAAY,SAAS,WAAW;AAAG;AACxC,QAAI,KAAK,WAAW;AAAM,WAAK,UAAU,KAAK,IAAI;AAElD,WAAO,KAAK,cAAc,SAAS,SAAS,QAAQ;AAClD,WAAK,cAAc,KAAK,CAAC,CAAC;AAAA,IAC5B;AACA,aAAS,QAAQ,CAAC,IAAI,MAAM;AAC1B,WAAK,cAAc,CAAC,EAAE,KAAK,EAAE;AAAA,IAC/B,CAAC;AAED,SAAK,KAAK,KAAK;AACf,QAAI,KAAK,aAAa;AAAG,WAAK,KAAK,IAAI;AAAA,EACzC;AAAA,EAEA,QAAQ;AACN,SAAK,KAAK,IAAI;AAAA,EAChB;AAAA,EAEA,QAAQ;AACN,aAAS,IAAI,GAAG,IAAI,KAAK,cAAc,QAAQ;AAAK,WAAK,cAAc,CAAC,IAAI,CAAC;AAC7E,SAAK,UAAU;AAAA,EACjB;AAAA,EAEA,WAAW;AACT,WAAO,KAAK,WAAW,OAAO,IAAI,KAAK,IAAI,IAAI,KAAK;AAAA,EACtD;AACF;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiny-codes/react-easy",
3
- "version": "1.4.5",
3
+ "version": "1.4.7",
4
4
  "description": "Simplify React and AntDesign development with practical components and hooks",
5
5
  "keywords": [
6
6
  "react",