@dreamtree-org/twreact-ui 1.1.10 → 1.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +271 -179
- package/dist/index.js +271 -179
- package/package.json +25 -25
package/dist/index.esm.js
CHANGED
|
@@ -15953,9 +15953,19 @@ var SpeechToText = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
15953
15953
|
_ref$autoStart = _ref.autoStart,
|
|
15954
15954
|
autoStart = _ref$autoStart === void 0 ? false : _ref$autoStart,
|
|
15955
15955
|
_ref$disabled = _ref.disabled,
|
|
15956
|
-
disabled = _ref$disabled === void 0 ? false : _ref$disabled
|
|
15956
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
15957
|
+
_ref$maxAlternatives = _ref.maxAlternatives,
|
|
15958
|
+
maxAlternatives = _ref$maxAlternatives === void 0 ? 1 : _ref$maxAlternatives,
|
|
15959
|
+
_ref$grammars = _ref.grammars,
|
|
15960
|
+
grammars = _ref$grammars === void 0 ? null : _ref$grammars,
|
|
15961
|
+
_ref$timeout = _ref.timeout,
|
|
15962
|
+
timeout = _ref$timeout === void 0 ? null : _ref$timeout,
|
|
15963
|
+
_ref$clearOnStop = _ref.clearOnStop,
|
|
15964
|
+
clearOnStop = _ref$clearOnStop === void 0 ? false : _ref$clearOnStop;
|
|
15957
15965
|
var recognitionRef = useRef(null);
|
|
15958
15966
|
var finalTranscriptRef = useRef("");
|
|
15967
|
+
var timeoutRef = useRef(null);
|
|
15968
|
+
var isMountedRef = useRef(true);
|
|
15959
15969
|
var _useState = useState(false),
|
|
15960
15970
|
_useState2 = _slicedToArray(_useState, 2),
|
|
15961
15971
|
_isListening = _useState2[0],
|
|
@@ -15964,34 +15974,48 @@ var SpeechToText = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
15964
15974
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
15965
15975
|
_isSupported = _useState4[0],
|
|
15966
15976
|
setIsSupported = _useState4[1];
|
|
15977
|
+
var _useState5 = useState(null),
|
|
15978
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
15979
|
+
error = _useState6[0],
|
|
15980
|
+
setError = _useState6[1];
|
|
15981
|
+
|
|
15982
|
+
// Check browser support
|
|
15967
15983
|
useEffect(function () {
|
|
15968
|
-
|
|
15969
|
-
|
|
15970
|
-
|
|
15971
|
-
|
|
15984
|
+
var supported = "webkitSpeechRecognition" in window || "SpeechRecognition" in window;
|
|
15985
|
+
setIsSupported(supported);
|
|
15986
|
+
if (!supported) {
|
|
15987
|
+
var err = new Error("Speech recognition not supported in this browser");
|
|
15988
|
+
setError(err);
|
|
15989
|
+
onError(err);
|
|
15972
15990
|
}
|
|
15973
|
-
}, []);
|
|
15974
|
-
|
|
15975
|
-
|
|
15976
|
-
|
|
15991
|
+
}, [onError]);
|
|
15992
|
+
|
|
15993
|
+
// Clear timeout helper
|
|
15994
|
+
var clearInactivityTimeout = useCallback(function () {
|
|
15995
|
+
if (timeoutRef.current) {
|
|
15996
|
+
clearTimeout(timeoutRef.current);
|
|
15997
|
+
timeoutRef.current = null;
|
|
15977
15998
|
}
|
|
15978
|
-
|
|
15979
|
-
|
|
15980
|
-
|
|
15981
|
-
|
|
15982
|
-
|
|
15983
|
-
|
|
15984
|
-
|
|
15985
|
-
|
|
15986
|
-
|
|
15999
|
+
}, []);
|
|
16000
|
+
|
|
16001
|
+
// Reset inactivity timeout
|
|
16002
|
+
var resetInactivityTimeout = useCallback(function () {
|
|
16003
|
+
if (!timeout) return;
|
|
16004
|
+
clearInactivityTimeout();
|
|
16005
|
+
timeoutRef.current = setTimeout(function () {
|
|
16006
|
+
if (recognitionRef.current && _isListening) {
|
|
16007
|
+
stopListening();
|
|
15987
16008
|
}
|
|
15988
|
-
};
|
|
15989
|
-
}, [
|
|
15990
|
-
|
|
16009
|
+
}, timeout);
|
|
16010
|
+
}, [timeout, _isListening]);
|
|
16011
|
+
|
|
16012
|
+
// Initialize recognition
|
|
16013
|
+
var initializeRecognition = useCallback(function () {
|
|
15991
16014
|
if (recognitionRef.current) return recognitionRef.current;
|
|
15992
16015
|
var SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
|
|
15993
16016
|
if (!SpeechRecognition) {
|
|
15994
16017
|
var err = new Error("SpeechRecognition API not available");
|
|
16018
|
+
setError(err);
|
|
15995
16019
|
onError(err);
|
|
15996
16020
|
return null;
|
|
15997
16021
|
}
|
|
@@ -15999,12 +16023,21 @@ var SpeechToText = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
15999
16023
|
recognition.continuous = !!continuous;
|
|
16000
16024
|
recognition.interimResults = !!interimResults;
|
|
16001
16025
|
recognition.lang = lang;
|
|
16026
|
+
recognition.maxAlternatives = maxAlternatives;
|
|
16027
|
+
if (grammars) {
|
|
16028
|
+
recognition.grammars = grammars;
|
|
16029
|
+
}
|
|
16002
16030
|
recognition.onstart = function () {
|
|
16031
|
+
if (!isMountedRef.current) return;
|
|
16003
16032
|
finalTranscriptRef.current = finalTranscriptRef.current || "";
|
|
16004
16033
|
setIsListening(true);
|
|
16034
|
+
setError(null);
|
|
16035
|
+
resetInactivityTimeout();
|
|
16005
16036
|
onStart();
|
|
16006
16037
|
};
|
|
16007
16038
|
recognition.onresult = function (event) {
|
|
16039
|
+
if (!isMountedRef.current) return;
|
|
16040
|
+
resetInactivityTimeout();
|
|
16008
16041
|
var interim = "";
|
|
16009
16042
|
var finalPart = "";
|
|
16010
16043
|
for (var i = event.resultIndex; i < event.results.length; i++) {
|
|
@@ -16024,21 +16057,48 @@ var SpeechToText = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
16024
16057
|
}
|
|
16025
16058
|
};
|
|
16026
16059
|
recognition.onerror = function (event) {
|
|
16027
|
-
|
|
16028
|
-
|
|
16060
|
+
if (!isMountedRef.current) return;
|
|
16061
|
+
clearInactivityTimeout();
|
|
16062
|
+
var errorMessage = (event === null || event === void 0 ? void 0 : event.error) || "Speech recognition error";
|
|
16063
|
+
var err = new Error(errorMessage);
|
|
16064
|
+
setError(err);
|
|
16029
16065
|
setIsListening(false);
|
|
16066
|
+
onError(err);
|
|
16067
|
+
|
|
16068
|
+
// Handle specific errors
|
|
16069
|
+
if (errorMessage === "not-allowed" || errorMessage === "service-not-allowed") {
|
|
16070
|
+
console.warn("Microphone permission denied");
|
|
16071
|
+
} else if (errorMessage === "no-speech") {
|
|
16072
|
+
console.warn("No speech detected");
|
|
16073
|
+
} else if (errorMessage === "aborted") {
|
|
16074
|
+
console.warn("Speech recognition aborted");
|
|
16075
|
+
}
|
|
16030
16076
|
};
|
|
16031
16077
|
recognition.onend = function () {
|
|
16078
|
+
if (!isMountedRef.current) return;
|
|
16079
|
+
clearInactivityTimeout();
|
|
16032
16080
|
setIsListening(false);
|
|
16081
|
+
var finalText = (finalTranscriptRef.current || "").trim();
|
|
16082
|
+
onSpeechComplete(finalText);
|
|
16033
16083
|
onStop();
|
|
16034
|
-
|
|
16084
|
+
if (clearOnStop) {
|
|
16085
|
+
finalTranscriptRef.current = "";
|
|
16086
|
+
}
|
|
16035
16087
|
};
|
|
16036
16088
|
recognitionRef.current = recognition;
|
|
16037
16089
|
return recognition;
|
|
16038
|
-
}
|
|
16039
|
-
|
|
16090
|
+
}, [continuous, interimResults, lang, maxAlternatives, grammars, onStart, onSpeaking, onSpeechComplete, onError, onStop, clearOnStop, resetInactivityTimeout, clearInactivityTimeout]);
|
|
16091
|
+
|
|
16092
|
+
// Start listening
|
|
16093
|
+
var startListening = useCallback(function () {
|
|
16040
16094
|
if (!_isSupported) {
|
|
16041
|
-
|
|
16095
|
+
var err = new Error("Speech recognition not supported in this browser");
|
|
16096
|
+
setError(err);
|
|
16097
|
+
onError(err);
|
|
16098
|
+
return;
|
|
16099
|
+
}
|
|
16100
|
+
if (_isListening) {
|
|
16101
|
+
console.warn("Already listening");
|
|
16042
16102
|
return;
|
|
16043
16103
|
}
|
|
16044
16104
|
try {
|
|
@@ -16046,24 +16106,68 @@ var SpeechToText = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
16046
16106
|
if (!rec) return;
|
|
16047
16107
|
rec.start();
|
|
16048
16108
|
} catch (err) {
|
|
16109
|
+
var _err$message;
|
|
16110
|
+
// Handle "already started" error
|
|
16111
|
+
if ((_err$message = err.message) !== null && _err$message !== void 0 && _err$message.includes("already started")) {
|
|
16112
|
+
console.warn("Recognition already in progress");
|
|
16113
|
+
return;
|
|
16114
|
+
}
|
|
16115
|
+
setError(err);
|
|
16049
16116
|
onError(err);
|
|
16050
16117
|
}
|
|
16051
|
-
}
|
|
16052
|
-
|
|
16118
|
+
}, [_isSupported, _isListening, initializeRecognition, onError]);
|
|
16119
|
+
|
|
16120
|
+
// Stop listening
|
|
16121
|
+
var stopListening = useCallback(function () {
|
|
16053
16122
|
if (recognitionRef.current) {
|
|
16054
16123
|
try {
|
|
16124
|
+
clearInactivityTimeout();
|
|
16055
16125
|
recognitionRef.current.stop();
|
|
16056
|
-
} catch (
|
|
16126
|
+
} catch (err) {
|
|
16127
|
+
console.error("Error stopping recognition:", err);
|
|
16128
|
+
}
|
|
16057
16129
|
}
|
|
16058
|
-
}
|
|
16059
|
-
|
|
16130
|
+
}, [clearInactivityTimeout]);
|
|
16131
|
+
|
|
16132
|
+
// Toggle listening
|
|
16133
|
+
var toggleListening = useCallback(function () {
|
|
16060
16134
|
if (disabled) return;
|
|
16061
16135
|
if (_isListening) {
|
|
16062
16136
|
stopListening();
|
|
16063
16137
|
} else {
|
|
16064
16138
|
startListening();
|
|
16065
16139
|
}
|
|
16066
|
-
}
|
|
16140
|
+
}, [disabled, _isListening, startListening, stopListening]);
|
|
16141
|
+
|
|
16142
|
+
// Auto-start effect
|
|
16143
|
+
useEffect(function () {
|
|
16144
|
+
if (autoStart && _isSupported && !disabled) {
|
|
16145
|
+
startListening();
|
|
16146
|
+
}
|
|
16147
|
+
}, [autoStart, _isSupported, disabled, startListening]);
|
|
16148
|
+
|
|
16149
|
+
// Cleanup on unmount
|
|
16150
|
+
useEffect(function () {
|
|
16151
|
+
isMountedRef.current = true;
|
|
16152
|
+
return function () {
|
|
16153
|
+
isMountedRef.current = false;
|
|
16154
|
+
clearInactivityTimeout();
|
|
16155
|
+
if (recognitionRef.current) {
|
|
16156
|
+
try {
|
|
16157
|
+
recognitionRef.current.onresult = null;
|
|
16158
|
+
recognitionRef.current.onerror = null;
|
|
16159
|
+
recognitionRef.current.onend = null;
|
|
16160
|
+
recognitionRef.current.onstart = null;
|
|
16161
|
+
recognitionRef.current.stop();
|
|
16162
|
+
} catch (err) {
|
|
16163
|
+
console.error("Cleanup error:", err);
|
|
16164
|
+
}
|
|
16165
|
+
recognitionRef.current = null;
|
|
16166
|
+
}
|
|
16167
|
+
};
|
|
16168
|
+
}, [clearInactivityTimeout]);
|
|
16169
|
+
|
|
16170
|
+
// Imperative handle
|
|
16067
16171
|
useImperativeHandle(ref, function () {
|
|
16068
16172
|
return {
|
|
16069
16173
|
start: startListening,
|
|
@@ -16080,26 +16184,39 @@ var SpeechToText = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
16080
16184
|
},
|
|
16081
16185
|
clearTranscript: function clearTranscript() {
|
|
16082
16186
|
finalTranscriptRef.current = "";
|
|
16187
|
+
},
|
|
16188
|
+
getError: function getError() {
|
|
16189
|
+
return error;
|
|
16083
16190
|
}
|
|
16084
16191
|
};
|
|
16085
|
-
}, [_isListening, _isSupported]);
|
|
16192
|
+
}, [_isListening, _isSupported, error, startListening, stopListening, toggleListening]);
|
|
16193
|
+
|
|
16194
|
+
// Custom button renderer
|
|
16086
16195
|
if (renderButton && typeof renderButton === "function") {
|
|
16087
16196
|
return renderButton({
|
|
16088
16197
|
isListening: _isListening,
|
|
16089
16198
|
isSupported: _isSupported,
|
|
16199
|
+
error: error,
|
|
16090
16200
|
start: startListening,
|
|
16091
16201
|
stop: stopListening,
|
|
16092
16202
|
toggle: toggleListening,
|
|
16093
|
-
disabled: disabled
|
|
16203
|
+
disabled: disabled || !_isSupported
|
|
16094
16204
|
});
|
|
16095
16205
|
}
|
|
16206
|
+
|
|
16207
|
+
// Default button
|
|
16096
16208
|
return /*#__PURE__*/React__default.createElement("button", {
|
|
16097
16209
|
type: "button",
|
|
16098
16210
|
"aria-pressed": _isListening,
|
|
16211
|
+
"aria-label": _isListening ? "Stop listening" : "Start listening",
|
|
16099
16212
|
onClick: toggleListening,
|
|
16100
|
-
disabled: disabled || !_isSupported
|
|
16101
|
-
|
|
16213
|
+
disabled: disabled || !_isSupported,
|
|
16214
|
+
style: {
|
|
16215
|
+
cursor: disabled || !_isSupported ? "not-allowed" : "pointer"
|
|
16216
|
+
}
|
|
16217
|
+
}, _isListening ? "🎤 Stop" : "🎤 Start");
|
|
16102
16218
|
});
|
|
16219
|
+
SpeechToText.displayName = "SpeechToText";
|
|
16103
16220
|
|
|
16104
16221
|
var TextToSpeech = function TextToSpeech(_ref) {
|
|
16105
16222
|
var _ref$text = _ref.text,
|
|
@@ -22144,10 +22261,11 @@ const trim = (str) => str.trim ?
|
|
|
22144
22261
|
* If 'obj' is an Object callback will be called passing
|
|
22145
22262
|
* the value, key, and complete object for each property.
|
|
22146
22263
|
*
|
|
22147
|
-
* @param {Object|Array} obj The object to iterate
|
|
22264
|
+
* @param {Object|Array<unknown>} obj The object to iterate
|
|
22148
22265
|
* @param {Function} fn The callback to invoke for each item
|
|
22149
22266
|
*
|
|
22150
|
-
* @param {
|
|
22267
|
+
* @param {Object} [options]
|
|
22268
|
+
* @param {Boolean} [options.allOwnKeys = false]
|
|
22151
22269
|
* @returns {any}
|
|
22152
22270
|
*/
|
|
22153
22271
|
function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
@@ -22224,7 +22342,7 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
|
|
|
22224
22342
|
* Example:
|
|
22225
22343
|
*
|
|
22226
22344
|
* ```js
|
|
22227
|
-
*
|
|
22345
|
+
* const result = merge({foo: 123}, {foo: 456});
|
|
22228
22346
|
* console.log(result.foo); // outputs 456
|
|
22229
22347
|
* ```
|
|
22230
22348
|
*
|
|
@@ -22261,15 +22379,26 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
|
|
22261
22379
|
* @param {Object} b The object to copy properties from
|
|
22262
22380
|
* @param {Object} thisArg The object to bind function to
|
|
22263
22381
|
*
|
|
22264
|
-
* @param {
|
|
22382
|
+
* @param {Object} [options]
|
|
22383
|
+
* @param {Boolean} [options.allOwnKeys]
|
|
22265
22384
|
* @returns {Object} The resulting value of object a
|
|
22266
22385
|
*/
|
|
22267
22386
|
const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
|
|
22268
22387
|
forEach(b, (val, key) => {
|
|
22269
22388
|
if (thisArg && isFunction$1(val)) {
|
|
22270
|
-
a
|
|
22389
|
+
Object.defineProperty(a, key, {
|
|
22390
|
+
value: bind(val, thisArg),
|
|
22391
|
+
writable: true,
|
|
22392
|
+
enumerable: true,
|
|
22393
|
+
configurable: true
|
|
22394
|
+
});
|
|
22271
22395
|
} else {
|
|
22272
|
-
a
|
|
22396
|
+
Object.defineProperty(a, key, {
|
|
22397
|
+
value: val,
|
|
22398
|
+
writable: true,
|
|
22399
|
+
enumerable: true,
|
|
22400
|
+
configurable: true
|
|
22401
|
+
});
|
|
22273
22402
|
}
|
|
22274
22403
|
}, {allOwnKeys});
|
|
22275
22404
|
return a;
|
|
@@ -22300,7 +22429,12 @@ const stripBOM = (content) => {
|
|
|
22300
22429
|
*/
|
|
22301
22430
|
const inherits = (constructor, superConstructor, props, descriptors) => {
|
|
22302
22431
|
constructor.prototype = Object.create(superConstructor.prototype, descriptors);
|
|
22303
|
-
constructor.prototype
|
|
22432
|
+
Object.defineProperty(constructor.prototype, 'constructor', {
|
|
22433
|
+
value: constructor,
|
|
22434
|
+
writable: true,
|
|
22435
|
+
enumerable: false,
|
|
22436
|
+
configurable: true
|
|
22437
|
+
});
|
|
22304
22438
|
Object.defineProperty(constructor, 'super', {
|
|
22305
22439
|
value: superConstructor.prototype
|
|
22306
22440
|
});
|
|
@@ -22673,111 +22807,74 @@ var utils$1 = {
|
|
|
22673
22807
|
isIterable
|
|
22674
22808
|
};
|
|
22675
22809
|
|
|
22676
|
-
|
|
22677
|
-
|
|
22678
|
-
|
|
22679
|
-
|
|
22680
|
-
|
|
22681
|
-
|
|
22682
|
-
|
|
22683
|
-
|
|
22684
|
-
*
|
|
22685
|
-
* @returns {Error} The created error.
|
|
22686
|
-
*/
|
|
22687
|
-
function AxiosError$1(message, code, config, request, response) {
|
|
22688
|
-
Error.call(this);
|
|
22689
|
-
|
|
22690
|
-
if (Error.captureStackTrace) {
|
|
22691
|
-
Error.captureStackTrace(this, this.constructor);
|
|
22692
|
-
} else {
|
|
22693
|
-
this.stack = (new Error()).stack;
|
|
22694
|
-
}
|
|
22695
|
-
|
|
22696
|
-
this.message = message;
|
|
22697
|
-
this.name = 'AxiosError';
|
|
22698
|
-
code && (this.code = code);
|
|
22699
|
-
config && (this.config = config);
|
|
22700
|
-
request && (this.request = request);
|
|
22701
|
-
if (response) {
|
|
22702
|
-
this.response = response;
|
|
22703
|
-
this.status = response.status ? response.status : null;
|
|
22704
|
-
}
|
|
22705
|
-
}
|
|
22706
|
-
|
|
22707
|
-
utils$1.inherits(AxiosError$1, Error, {
|
|
22708
|
-
toJSON: function toJSON() {
|
|
22709
|
-
return {
|
|
22710
|
-
// Standard
|
|
22711
|
-
message: this.message,
|
|
22712
|
-
name: this.name,
|
|
22713
|
-
// Microsoft
|
|
22714
|
-
description: this.description,
|
|
22715
|
-
number: this.number,
|
|
22716
|
-
// Mozilla
|
|
22717
|
-
fileName: this.fileName,
|
|
22718
|
-
lineNumber: this.lineNumber,
|
|
22719
|
-
columnNumber: this.columnNumber,
|
|
22720
|
-
stack: this.stack,
|
|
22721
|
-
// Axios
|
|
22722
|
-
config: utils$1.toJSONObject(this.config),
|
|
22723
|
-
code: this.code,
|
|
22724
|
-
status: this.status
|
|
22725
|
-
};
|
|
22726
|
-
}
|
|
22727
|
-
});
|
|
22728
|
-
|
|
22729
|
-
const prototype$1 = AxiosError$1.prototype;
|
|
22730
|
-
const descriptors = {};
|
|
22731
|
-
|
|
22732
|
-
[
|
|
22733
|
-
'ERR_BAD_OPTION_VALUE',
|
|
22734
|
-
'ERR_BAD_OPTION',
|
|
22735
|
-
'ECONNABORTED',
|
|
22736
|
-
'ETIMEDOUT',
|
|
22737
|
-
'ERR_NETWORK',
|
|
22738
|
-
'ERR_FR_TOO_MANY_REDIRECTS',
|
|
22739
|
-
'ERR_DEPRECATED',
|
|
22740
|
-
'ERR_BAD_RESPONSE',
|
|
22741
|
-
'ERR_BAD_REQUEST',
|
|
22742
|
-
'ERR_CANCELED',
|
|
22743
|
-
'ERR_NOT_SUPPORT',
|
|
22744
|
-
'ERR_INVALID_URL'
|
|
22745
|
-
// eslint-disable-next-line func-names
|
|
22746
|
-
].forEach(code => {
|
|
22747
|
-
descriptors[code] = {value: code};
|
|
22748
|
-
});
|
|
22749
|
-
|
|
22750
|
-
Object.defineProperties(AxiosError$1, descriptors);
|
|
22751
|
-
Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
|
|
22752
|
-
|
|
22753
|
-
// eslint-disable-next-line func-names
|
|
22754
|
-
AxiosError$1.from = (error, code, config, request, response, customProps) => {
|
|
22755
|
-
const axiosError = Object.create(prototype$1);
|
|
22756
|
-
|
|
22757
|
-
utils$1.toFlatObject(error, axiosError, function filter(obj) {
|
|
22758
|
-
return obj !== Error.prototype;
|
|
22759
|
-
}, prop => {
|
|
22760
|
-
return prop !== 'isAxiosError';
|
|
22761
|
-
});
|
|
22762
|
-
|
|
22763
|
-
const msg = error && error.message ? error.message : 'Error';
|
|
22764
|
-
|
|
22765
|
-
// Prefer explicit code; otherwise copy the low-level error's code (e.g. ECONNREFUSED)
|
|
22766
|
-
const errCode = code == null && error ? error.code : code;
|
|
22767
|
-
AxiosError$1.call(axiosError, msg, errCode, config, request, response);
|
|
22768
|
-
|
|
22769
|
-
// Chain the original error on the standard field; non-enumerable to avoid JSON noise
|
|
22770
|
-
if (error && axiosError.cause == null) {
|
|
22771
|
-
Object.defineProperty(axiosError, 'cause', { value: error, configurable: true });
|
|
22772
|
-
}
|
|
22773
|
-
|
|
22774
|
-
axiosError.name = (error && error.name) || 'Error';
|
|
22810
|
+
let AxiosError$1 = class AxiosError extends Error {
|
|
22811
|
+
static from(error, code, config, request, response, customProps) {
|
|
22812
|
+
const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
|
|
22813
|
+
axiosError.cause = error;
|
|
22814
|
+
axiosError.name = error.name;
|
|
22815
|
+
customProps && Object.assign(axiosError, customProps);
|
|
22816
|
+
return axiosError;
|
|
22817
|
+
}
|
|
22775
22818
|
|
|
22776
|
-
|
|
22819
|
+
/**
|
|
22820
|
+
* Create an Error with the specified message, config, error code, request and response.
|
|
22821
|
+
*
|
|
22822
|
+
* @param {string} message The error message.
|
|
22823
|
+
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
22824
|
+
* @param {Object} [config] The config.
|
|
22825
|
+
* @param {Object} [request] The request.
|
|
22826
|
+
* @param {Object} [response] The response.
|
|
22827
|
+
*
|
|
22828
|
+
* @returns {Error} The created error.
|
|
22829
|
+
*/
|
|
22830
|
+
constructor(message, code, config, request, response) {
|
|
22831
|
+
super(message);
|
|
22832
|
+
this.name = 'AxiosError';
|
|
22833
|
+
this.isAxiosError = true;
|
|
22834
|
+
code && (this.code = code);
|
|
22835
|
+
config && (this.config = config);
|
|
22836
|
+
request && (this.request = request);
|
|
22837
|
+
if (response) {
|
|
22838
|
+
this.response = response;
|
|
22839
|
+
this.status = response.status;
|
|
22840
|
+
}
|
|
22841
|
+
}
|
|
22777
22842
|
|
|
22778
|
-
|
|
22843
|
+
toJSON() {
|
|
22844
|
+
return {
|
|
22845
|
+
// Standard
|
|
22846
|
+
message: this.message,
|
|
22847
|
+
name: this.name,
|
|
22848
|
+
// Microsoft
|
|
22849
|
+
description: this.description,
|
|
22850
|
+
number: this.number,
|
|
22851
|
+
// Mozilla
|
|
22852
|
+
fileName: this.fileName,
|
|
22853
|
+
lineNumber: this.lineNumber,
|
|
22854
|
+
columnNumber: this.columnNumber,
|
|
22855
|
+
stack: this.stack,
|
|
22856
|
+
// Axios
|
|
22857
|
+
config: utils$1.toJSONObject(this.config),
|
|
22858
|
+
code: this.code,
|
|
22859
|
+
status: this.status,
|
|
22860
|
+
};
|
|
22861
|
+
}
|
|
22779
22862
|
};
|
|
22780
22863
|
|
|
22864
|
+
// This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
|
|
22865
|
+
AxiosError$1.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
|
|
22866
|
+
AxiosError$1.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
|
|
22867
|
+
AxiosError$1.ECONNABORTED = 'ECONNABORTED';
|
|
22868
|
+
AxiosError$1.ETIMEDOUT = 'ETIMEDOUT';
|
|
22869
|
+
AxiosError$1.ERR_NETWORK = 'ERR_NETWORK';
|
|
22870
|
+
AxiosError$1.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
|
|
22871
|
+
AxiosError$1.ERR_DEPRECATED = 'ERR_DEPRECATED';
|
|
22872
|
+
AxiosError$1.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
|
|
22873
|
+
AxiosError$1.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
|
|
22874
|
+
AxiosError$1.ERR_CANCELED = 'ERR_CANCELED';
|
|
22875
|
+
AxiosError$1.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
|
|
22876
|
+
AxiosError$1.ERR_INVALID_URL = 'ERR_INVALID_URL';
|
|
22877
|
+
|
|
22781
22878
|
// eslint-disable-next-line strict
|
|
22782
22879
|
var httpAdapter = null;
|
|
22783
22880
|
|
|
@@ -23075,29 +23172,26 @@ function encode(val) {
|
|
|
23075
23172
|
* @returns {string} The formatted url
|
|
23076
23173
|
*/
|
|
23077
23174
|
function buildURL(url, params, options) {
|
|
23078
|
-
/*eslint no-param-reassign:0*/
|
|
23079
23175
|
if (!params) {
|
|
23080
23176
|
return url;
|
|
23081
23177
|
}
|
|
23082
|
-
|
|
23178
|
+
|
|
23083
23179
|
const _encode = options && options.encode || encode;
|
|
23084
23180
|
|
|
23085
|
-
|
|
23086
|
-
options
|
|
23087
|
-
|
|
23088
|
-
};
|
|
23089
|
-
}
|
|
23181
|
+
const _options = utils$1.isFunction(options) ? {
|
|
23182
|
+
serialize: options
|
|
23183
|
+
} : options;
|
|
23090
23184
|
|
|
23091
|
-
const serializeFn =
|
|
23185
|
+
const serializeFn = _options && _options.serialize;
|
|
23092
23186
|
|
|
23093
23187
|
let serializedParams;
|
|
23094
23188
|
|
|
23095
23189
|
if (serializeFn) {
|
|
23096
|
-
serializedParams = serializeFn(params,
|
|
23190
|
+
serializedParams = serializeFn(params, _options);
|
|
23097
23191
|
} else {
|
|
23098
23192
|
serializedParams = utils$1.isURLSearchParams(params) ?
|
|
23099
23193
|
params.toString() :
|
|
23100
|
-
new AxiosURLSearchParams(params,
|
|
23194
|
+
new AxiosURLSearchParams(params, _options).toString(_encode);
|
|
23101
23195
|
}
|
|
23102
23196
|
|
|
23103
23197
|
if (serializedParams) {
|
|
@@ -23122,6 +23216,7 @@ class InterceptorManager {
|
|
|
23122
23216
|
*
|
|
23123
23217
|
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|
23124
23218
|
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
|
23219
|
+
* @param {Object} options The options for the interceptor, synchronous and runWhen
|
|
23125
23220
|
*
|
|
23126
23221
|
* @return {Number} An ID used to remove interceptor later
|
|
23127
23222
|
*/
|
|
@@ -23899,24 +23994,22 @@ function isCancel$1(value) {
|
|
|
23899
23994
|
return !!(value && value.__CANCEL__);
|
|
23900
23995
|
}
|
|
23901
23996
|
|
|
23902
|
-
|
|
23903
|
-
|
|
23904
|
-
|
|
23905
|
-
|
|
23906
|
-
|
|
23907
|
-
|
|
23908
|
-
|
|
23909
|
-
|
|
23910
|
-
|
|
23911
|
-
|
|
23912
|
-
|
|
23913
|
-
|
|
23914
|
-
|
|
23915
|
-
|
|
23916
|
-
|
|
23917
|
-
|
|
23918
|
-
__CANCEL__: true
|
|
23919
|
-
});
|
|
23997
|
+
let CanceledError$1 = class CanceledError extends AxiosError$1 {
|
|
23998
|
+
/**
|
|
23999
|
+
* A `CanceledError` is an object that is thrown when an operation is canceled.
|
|
24000
|
+
*
|
|
24001
|
+
* @param {string=} message The message.
|
|
24002
|
+
* @param {Object=} config The config.
|
|
24003
|
+
* @param {Object=} request The request.
|
|
24004
|
+
*
|
|
24005
|
+
* @returns {CanceledError} The created error.
|
|
24006
|
+
*/
|
|
24007
|
+
constructor(message, config, request) {
|
|
24008
|
+
super(message == null ? 'canceled' : message, AxiosError$1.ERR_CANCELED, config, request);
|
|
24009
|
+
this.name = 'CanceledError';
|
|
24010
|
+
this.__CANCEL__ = true;
|
|
24011
|
+
}
|
|
24012
|
+
};
|
|
23920
24013
|
|
|
23921
24014
|
/**
|
|
23922
24015
|
* Resolve or reject a Promise based on response status.
|
|
@@ -24210,7 +24303,7 @@ function mergeConfig$1(config1, config2) {
|
|
|
24210
24303
|
|
|
24211
24304
|
function getMergedValue(target, source, prop, caseless) {
|
|
24212
24305
|
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
|
24213
|
-
return utils$1.merge.call({caseless}, target, source);
|
|
24306
|
+
return utils$1.merge.call({ caseless }, target, source);
|
|
24214
24307
|
} else if (utils$1.isPlainObject(source)) {
|
|
24215
24308
|
return utils$1.merge({}, source);
|
|
24216
24309
|
} else if (utils$1.isArray(source)) {
|
|
@@ -24219,7 +24312,6 @@ function mergeConfig$1(config1, config2) {
|
|
|
24219
24312
|
return source;
|
|
24220
24313
|
}
|
|
24221
24314
|
|
|
24222
|
-
// eslint-disable-next-line consistent-return
|
|
24223
24315
|
function mergeDeepProperties(a, b, prop, caseless) {
|
|
24224
24316
|
if (!utils$1.isUndefined(b)) {
|
|
24225
24317
|
return getMergedValue(a, b, prop, caseless);
|
|
@@ -24285,7 +24377,7 @@ function mergeConfig$1(config1, config2) {
|
|
|
24285
24377
|
headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
|
|
24286
24378
|
};
|
|
24287
24379
|
|
|
24288
|
-
utils$1.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) {
|
|
24380
|
+
utils$1.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
|
|
24289
24381
|
const merge = mergeMap[prop] || mergeDeepProperties;
|
|
24290
24382
|
const configValue = merge(config1[prop], config2[prop], prop);
|
|
24291
24383
|
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
@@ -24555,7 +24647,7 @@ const composeSignals = (signals, timeout) => {
|
|
|
24555
24647
|
|
|
24556
24648
|
let timer = timeout && setTimeout(() => {
|
|
24557
24649
|
timer = null;
|
|
24558
|
-
onabort(new AxiosError$1(`timeout ${timeout}
|
|
24650
|
+
onabort(new AxiosError$1(`timeout of ${timeout}ms exceeded`, AxiosError$1.ETIMEDOUT));
|
|
24559
24651
|
}, timeout);
|
|
24560
24652
|
|
|
24561
24653
|
const unsubscribe = () => {
|
|
@@ -25137,7 +25229,7 @@ function dispatchRequest(config) {
|
|
|
25137
25229
|
});
|
|
25138
25230
|
}
|
|
25139
25231
|
|
|
25140
|
-
const VERSION$1 = "1.13.
|
|
25232
|
+
const VERSION$1 = "1.13.4";
|
|
25141
25233
|
|
|
25142
25234
|
const validators$1 = {};
|
|
25143
25235
|
|
|
@@ -25597,7 +25689,7 @@ let CancelToken$1 = class CancelToken {
|
|
|
25597
25689
|
*
|
|
25598
25690
|
* ```js
|
|
25599
25691
|
* function f(x, y, z) {}
|
|
25600
|
-
*
|
|
25692
|
+
* const args = [1, 2, 3];
|
|
25601
25693
|
* f.apply(null, args);
|
|
25602
25694
|
* ```
|
|
25603
25695
|
*
|