maka-agent 0.2.0-dev.64.20260929 → 0.2.0-dev.67.20261002
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/LICENSE +1 -1
- package/THIRD_PARTY_NOTICES.txt +3 -3
- package/dist/pi-tui-runner.js +26 -29
- package/dist/tui-copy-catalog.js +9 -9
- package/native/runtime-host-peer/prebuilds/darwin-arm64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/linux-arm64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/linux-x64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/win32-x64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
- package/node_modules/@maka/core/dist/settings.js +2 -2
- package/node_modules/@maka/core/dist/tool-ledger-scanner.js +53 -150
- package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +8 -1
- package/node_modules/@maka/runtime/dist/conversation-copy.js +6 -0
- package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +17 -0
- package/node_modules/@maka/runtime/dist/session-manager.js +25 -40
- package/node_modules/@maka/runtime/dist/stream-graph-coordinator.js +79 -13
- package/node_modules/@maka/runtime/dist/stream-graph-projection.js +64 -0
- package/node_modules/@maka/runtime/dist/stream-graph-read-model.js +138 -20
- package/node_modules/@maka/runtime/dist/tool-availability.js +10 -3
- package/node_modules/@maka/runtime-host/dist/candidate-entry.js +15 -0
- package/node_modules/@maka/runtime-host/dist/candidate-startup-failure.js +5 -0
- package/node_modules/@maka/runtime-host/dist/client/session-catalog-summary.js +1 -0
- package/node_modules/@maka/runtime-host/dist/client/startup-error.js +5 -0
- package/node_modules/@maka/runtime-host/dist/protocol/agent-graph.js +46 -1
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +14 -1
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +5 -1
- package/node_modules/@maka/runtime-host/dist/protocol/session-catalog.js +12 -0
- package/node_modules/@maka/runtime-host/dist/protocol/session-retirement.js +46 -10
- package/node_modules/@maka/runtime-host/dist/protocol/storage-usage.js +155 -0
- package/node_modules/@maka/runtime-host/dist/server/agent-graph-coordinator.js +23 -0
- package/node_modules/@maka/runtime-host/dist/server/canonical-turn-snapshot.js +5 -0
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +27 -6
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-tool-profile.js +2 -0
- package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +6 -0
- package/node_modules/@maka/runtime-host/dist/server/session-retirement-coordinator.js +112 -36
- package/node_modules/@maka/runtime-host/dist/server/session-revision-coordinator.js +27 -1
- package/node_modules/@maka/runtime-host/dist/server/storage-usage-coordinator.js +67 -0
- package/node_modules/@maka/runtime-host/dist/server/workhub-inspection-tool.js +208 -0
- package/node_modules/@maka/storage/dist/git-worktree-child-executor.js +3 -1
- package/node_modules/@maka/storage/dist/operational-state-store.js +0 -13
- package/node_modules/@maka/storage/dist/session-store.js +9 -6
- package/node_modules/@maka/storage/dist/sqlite-file-set.js +22 -0
- package/node_modules/@maka/storage/dist/sqlite-long-term-memory-store.js +1 -3
- package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +10 -260
- package/node_modules/@maka/storage/dist/sqlite-session-catalog-query.js +1 -0
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-schema.js +18 -6
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +28 -6
- package/node_modules/@maka/storage/dist/storage-footprint.js +239 -0
- package/node_modules/@maka/storage/dist/storage-writer-composition.js +10 -1
- package/node_modules/axios/CHANGELOG.md +62 -0
- package/node_modules/axios/README.md +297 -5
- package/node_modules/axios/dist/axios.js +728 -170
- package/node_modules/axios/dist/axios.min.js +3 -3
- package/node_modules/axios/dist/browser/axios.cjs +871 -188
- package/node_modules/axios/dist/esm/axios.js +871 -188
- package/node_modules/axios/dist/esm/axios.min.js +2 -2
- package/node_modules/axios/dist/node/axios.cjs +1037 -225
- package/node_modules/axios/lib/adapters/fetch.js +64 -11
- package/node_modules/axios/lib/adapters/http.js +140 -67
- package/node_modules/axios/lib/adapters/xhr.js +52 -3
- package/node_modules/axios/lib/core/Axios.js +43 -20
- package/node_modules/axios/lib/core/AxiosError.js +33 -2
- package/node_modules/axios/lib/core/AxiosHeaders.js +124 -1
- package/node_modules/axios/lib/core/InterceptorManager.js +107 -8
- package/node_modules/axios/lib/core/buildFullPath.js +41 -15
- package/node_modules/axios/lib/core/dispatchRequest.js +8 -2
- package/node_modules/axios/lib/core/mergeConfig.js +19 -4
- package/node_modules/axios/lib/core/methodList.js +17 -0
- package/node_modules/axios/lib/core/setFormDataHeaders.js +27 -0
- package/node_modules/axios/lib/defaults/index.js +2 -1
- package/node_modules/axios/lib/env/data.js +1 -1
- package/node_modules/axios/lib/helpers/Http2Sessions.js +2 -0
- package/node_modules/axios/lib/helpers/HttpStatusCode.js +12 -1
- package/node_modules/axios/lib/helpers/combineURLs.js +11 -3
- package/node_modules/axios/lib/helpers/composeSignals.js +12 -1
- package/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +115 -54
- package/node_modules/axios/lib/helpers/formDataToJSON.js +11 -5
- package/node_modules/axios/lib/helpers/fromDataURI.js +5 -4
- package/node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js +24 -0
- package/node_modules/axios/lib/helpers/parseHeaders.js +5 -3
- package/node_modules/axios/lib/helpers/progressEventReducer.js +4 -4
- package/node_modules/axios/lib/helpers/resolveConfig.js +5 -17
- package/node_modules/axios/lib/helpers/shouldBypassProxy.js +300 -5
- package/node_modules/axios/lib/helpers/throttle.js +3 -2
- package/node_modules/axios/lib/helpers/toFormData.js +17 -23
- package/node_modules/axios/lib/platform/node/classes/Buffer.js +11 -0
- package/node_modules/axios/lib/utils.js +151 -18
- package/node_modules/axios/package.json +21 -19
- package/node_modules/brace-expansion/dist/commonjs/index.js +69 -25
- package/node_modules/brace-expansion/dist/esm/index.js +68 -24
- package/node_modules/brace-expansion/package.json +2 -1
- package/node_modules/fast-uri/index.js +10 -6
- package/node_modules/fast-uri/package.json +1 -1
- package/package.json +1 -1
|
@@ -15,6 +15,7 @@ class Http2Sessions {
|
|
|
15
15
|
|
|
16
16
|
getSession(authority, options) {
|
|
17
17
|
options = Object.assign(
|
|
18
|
+
Object.create(null),
|
|
18
19
|
{
|
|
19
20
|
sessionTimeout: 1000,
|
|
20
21
|
},
|
|
@@ -105,6 +106,7 @@ class Http2Sessions {
|
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
session.once('close', removeSession);
|
|
109
|
+
session.once('error', removeSession);
|
|
108
110
|
|
|
109
111
|
let entry = [session, options];
|
|
110
112
|
|
|
@@ -35,14 +35,22 @@ const HttpStatusCode = {
|
|
|
35
35
|
Gone: 410,
|
|
36
36
|
LengthRequired: 411,
|
|
37
37
|
PreconditionFailed: 412,
|
|
38
|
+
/**
|
|
39
|
+
* @deprecated Use `ContentTooLarge` instead.
|
|
40
|
+
*/
|
|
38
41
|
PayloadTooLarge: 413,
|
|
42
|
+
ContentTooLarge: 413,
|
|
39
43
|
UriTooLong: 414,
|
|
40
44
|
UnsupportedMediaType: 415,
|
|
41
45
|
RangeNotSatisfiable: 416,
|
|
42
46
|
ExpectationFailed: 417,
|
|
43
47
|
ImATeapot: 418,
|
|
44
48
|
MisdirectedRequest: 421,
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated Use `UnprocessableContent` instead.
|
|
51
|
+
*/
|
|
45
52
|
UnprocessableEntity: 422,
|
|
53
|
+
UnprocessableContent: 422,
|
|
46
54
|
Locked: 423,
|
|
47
55
|
FailedDependency: 424,
|
|
48
56
|
TooEarly: 425,
|
|
@@ -62,6 +70,7 @@ const HttpStatusCode = {
|
|
|
62
70
|
LoopDetected: 508,
|
|
63
71
|
NotExtended: 510,
|
|
64
72
|
NetworkAuthenticationRequired: 511,
|
|
73
|
+
WebServerReturnsAnUnknownError: 520,
|
|
65
74
|
WebServerIsDown: 521,
|
|
66
75
|
ConnectionTimedOut: 522,
|
|
67
76
|
OriginIsUnreachable: 523,
|
|
@@ -71,7 +80,9 @@ const HttpStatusCode = {
|
|
|
71
80
|
};
|
|
72
81
|
|
|
73
82
|
Object.entries(HttpStatusCode).forEach(([key, value]) => {
|
|
74
|
-
HttpStatusCode[value]
|
|
83
|
+
if (HttpStatusCode[value] === undefined) {
|
|
84
|
+
HttpStatusCode[value] = key;
|
|
85
|
+
}
|
|
75
86
|
});
|
|
76
87
|
|
|
77
88
|
export default HttpStatusCode;
|
|
@@ -9,7 +9,15 @@
|
|
|
9
9
|
* @returns {string} The combined URL
|
|
10
10
|
*/
|
|
11
11
|
export default function combineURLs(baseURL, relativeURL) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
if (!relativeURL) {
|
|
13
|
+
return baseURL;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let end = baseURL.length;
|
|
17
|
+
|
|
18
|
+
while (end > 0 && baseURL.charCodeAt(end - 1) === 47) {
|
|
19
|
+
end--;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return baseURL.slice(0, end) + '/' + relativeURL.replace(/^\/+/, '');
|
|
15
23
|
}
|
|
@@ -45,7 +45,18 @@ const composeSignals = (signals, timeout) => {
|
|
|
45
45
|
signals = null;
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
signals.forEach((signal) =>
|
|
48
|
+
signals.forEach((signal) => {
|
|
49
|
+
if (aborted) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (signal.aborted) {
|
|
54
|
+
onabort.call(signal);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
signal.addEventListener('abort', onabort, { once: true });
|
|
59
|
+
});
|
|
49
60
|
|
|
50
61
|
const { signal } = controller;
|
|
51
62
|
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Estimate
|
|
3
|
-
* -
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @param {string} url
|
|
8
|
-
* @returns {number}
|
|
2
|
+
* Estimate data: URL byte lengths *without* allocating large buffers.
|
|
3
|
+
* - Fetch percent-decodes a base64 body before decoding it.
|
|
4
|
+
* - Node's Buffer.from(body, 'base64') sizes its backing allocation from the
|
|
5
|
+
* raw body, including ignored characters and content after padding.
|
|
6
|
+
* - Non-base64 data is percent-decoded and then encoded as UTF-8.
|
|
9
7
|
*/
|
|
10
8
|
const isHexDigit = (charCode) =>
|
|
11
9
|
(charCode >= 48 && charCode <= 57) ||
|
|
@@ -15,7 +13,89 @@ const isHexDigit = (charCode) =>
|
|
|
15
13
|
const isPercentEncodedByte = (str, i, len) =>
|
|
16
14
|
i + 2 < len && isHexDigit(str.charCodeAt(i + 1)) && isHexDigit(str.charCodeAt(i + 2));
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
const hexValue = (charCode) => (charCode <= 57 ? charCode - 48 : (charCode & 0xdf) - 55);
|
|
17
|
+
|
|
18
|
+
const isBase64Char = (charCode) =>
|
|
19
|
+
(charCode >= 65 && charCode <= 90) || // A-Z
|
|
20
|
+
(charCode >= 97 && charCode <= 122) || // a-z
|
|
21
|
+
(charCode >= 48 && charCode <= 57) || // 0-9
|
|
22
|
+
charCode === 43 || // +
|
|
23
|
+
charCode === 47 || // /
|
|
24
|
+
charCode === 45 || // - (base64url)
|
|
25
|
+
charCode === 95; // _ (base64url)
|
|
26
|
+
|
|
27
|
+
const isBase64Whitespace = (charCode) =>
|
|
28
|
+
charCode === 9 || charCode === 10 || charCode === 12 || charCode === 13 || charCode === 32;
|
|
29
|
+
|
|
30
|
+
const base64Bytes = (significant) => {
|
|
31
|
+
const groups = Math.floor(significant / 4);
|
|
32
|
+
const remainder = significant % 4;
|
|
33
|
+
return groups * 3 + (remainder === 2 ? 1 : remainder === 3 ? 2 : 0);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// Buffer.byteLength(body, 'base64') uses the raw string length as an allocation
|
|
37
|
+
// upper bound even when Buffer.from later ignores characters or stops at '='.
|
|
38
|
+
const estimateBase64BufferAllocation = (body) => {
|
|
39
|
+
const len = body.length;
|
|
40
|
+
let padding = 0;
|
|
41
|
+
|
|
42
|
+
if (len > 0 && body.charCodeAt(len - 1) === 61 /* '=' */) {
|
|
43
|
+
padding++;
|
|
44
|
+
|
|
45
|
+
if (len > 1 && body.charCodeAt(len - 2) === 61 /* '=' */) {
|
|
46
|
+
padding++;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return Math.floor(((len - padding) * 3) / 4);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const estimatePercentDecodedBase64Bytes = (body) => {
|
|
54
|
+
const len = body.length;
|
|
55
|
+
let significant = 0;
|
|
56
|
+
let padding = 0;
|
|
57
|
+
let invalid = false;
|
|
58
|
+
|
|
59
|
+
for (let i = 0; i < len; i++) {
|
|
60
|
+
let code = body.charCodeAt(i);
|
|
61
|
+
|
|
62
|
+
if (code === 37 /* '%' */ && isPercentEncodedByte(body, i, len)) {
|
|
63
|
+
code = hexValue(body.charCodeAt(i + 1)) * 16 + hexValue(body.charCodeAt(i + 2));
|
|
64
|
+
i += 2;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (isBase64Whitespace(code)) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (code === 61 /* '=' */) {
|
|
72
|
+
padding++;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (!isBase64Char(code) || padding > 0) {
|
|
77
|
+
invalid = true;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
significant++;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Fetch rejects malformed forgiving-base64 input. Returning the raw-size
|
|
85
|
+
// allocation bound keeps that invalid input from becoming a pre-check bypass.
|
|
86
|
+
if (
|
|
87
|
+
invalid ||
|
|
88
|
+
padding > 2 ||
|
|
89
|
+
(padding > 0 && (significant + padding) % 4 !== 0) ||
|
|
90
|
+
significant % 4 === 1
|
|
91
|
+
) {
|
|
92
|
+
return estimateBase64BufferAllocation(body);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return base64Bytes(significant);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const estimateDataURLBytes = (url, estimateBase64) => {
|
|
19
99
|
if (!url || typeof url !== 'string') return 0;
|
|
20
100
|
if (!url.startsWith('data:')) return 0;
|
|
21
101
|
|
|
@@ -27,52 +107,7 @@ export default function estimateDataURLDecodedBytes(url) {
|
|
|
27
107
|
const isBase64 = /;base64/i.test(meta);
|
|
28
108
|
|
|
29
109
|
if (isBase64) {
|
|
30
|
-
|
|
31
|
-
const len = body.length; // cache length
|
|
32
|
-
|
|
33
|
-
for (let i = 0; i < len; i++) {
|
|
34
|
-
if (body.charCodeAt(i) === 37 /* '%' */ && i + 2 < len) {
|
|
35
|
-
const a = body.charCodeAt(i + 1);
|
|
36
|
-
const b = body.charCodeAt(i + 2);
|
|
37
|
-
const isHex = isHexDigit(a) && isHexDigit(b);
|
|
38
|
-
|
|
39
|
-
if (isHex) {
|
|
40
|
-
effectiveLen -= 2;
|
|
41
|
-
i += 2;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
let pad = 0;
|
|
47
|
-
let idx = len - 1;
|
|
48
|
-
|
|
49
|
-
const tailIsPct3D = (j) =>
|
|
50
|
-
j >= 2 &&
|
|
51
|
-
body.charCodeAt(j - 2) === 37 && // '%'
|
|
52
|
-
body.charCodeAt(j - 1) === 51 && // '3'
|
|
53
|
-
(body.charCodeAt(j) === 68 || body.charCodeAt(j) === 100); // 'D' or 'd'
|
|
54
|
-
|
|
55
|
-
if (idx >= 0) {
|
|
56
|
-
if (body.charCodeAt(idx) === 61 /* '=' */) {
|
|
57
|
-
pad++;
|
|
58
|
-
idx--;
|
|
59
|
-
} else if (tailIsPct3D(idx)) {
|
|
60
|
-
pad++;
|
|
61
|
-
idx -= 3;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (pad === 1 && idx >= 0) {
|
|
66
|
-
if (body.charCodeAt(idx) === 61 /* '=' */) {
|
|
67
|
-
pad++;
|
|
68
|
-
} else if (tailIsPct3D(idx)) {
|
|
69
|
-
pad++;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const groups = Math.floor(effectiveLen / 4);
|
|
74
|
-
const bytes = groups * 3 - (pad || 0);
|
|
75
|
-
return bytes > 0 ? bytes : 0;
|
|
110
|
+
return estimateBase64(body);
|
|
76
111
|
}
|
|
77
112
|
|
|
78
113
|
// Compute UTF-8 byte length directly from UTF-16 code units without allocating
|
|
@@ -102,4 +137,30 @@ export default function estimateDataURLDecodedBytes(url) {
|
|
|
102
137
|
}
|
|
103
138
|
}
|
|
104
139
|
return bytes;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Estimate the percent-decoded payload size used by Fetch data: URLs.
|
|
144
|
+
*
|
|
145
|
+
* @param {string} url
|
|
146
|
+
* @returns {number}
|
|
147
|
+
*/
|
|
148
|
+
export default function estimateDataURLDecodedBytes(url) {
|
|
149
|
+
// Fetch removes URL fragments before processing a data: URL.
|
|
150
|
+
const fragmentIndex = typeof url === 'string' ? url.indexOf('#') : -1;
|
|
151
|
+
|
|
152
|
+
return estimateDataURLBytes(
|
|
153
|
+
fragmentIndex === -1 ? url : url.slice(0, fragmentIndex),
|
|
154
|
+
estimatePercentDecodedBase64Bytes
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Estimate the Buffer backing allocation used by Node's raw base64 decoder.
|
|
160
|
+
*
|
|
161
|
+
* @param {string} url
|
|
162
|
+
* @returns {number}
|
|
163
|
+
*/
|
|
164
|
+
export function estimateDataURLBufferAllocation(url) {
|
|
165
|
+
return estimateDataURLBytes(url, estimateBase64BufferAllocation);
|
|
105
166
|
}
|
|
@@ -23,12 +23,18 @@ function throwIfDepthExceeded(index) {
|
|
|
23
23
|
* @returns An array of strings.
|
|
24
24
|
*/
|
|
25
25
|
function parsePropPath(name) {
|
|
26
|
-
// foo[x][y][z]
|
|
27
|
-
// foo.x.y.z
|
|
28
|
-
//
|
|
29
|
-
//
|
|
26
|
+
// foo[x][y][z] -> ['foo', 'x', 'y', 'z']
|
|
27
|
+
// foo.x.y.z -> ['foo', 'x', 'y', 'z']
|
|
28
|
+
// A path is split on `.` and on `[...]` groups. A segment — whether written
|
|
29
|
+
// in dot notation or captured inside brackets — may contain any character
|
|
30
|
+
// except `.`, `[` and `]`, so a key like `user-name` or `user name` is kept
|
|
31
|
+
// literal instead of being split (#5402). `.`, `[` and `]` keep their existing
|
|
32
|
+
// meaning, e.g. `foo[bar.baz]` -> ['foo', 'bar', 'baz'] and `[]` is an array push.
|
|
33
|
+
// Excluding `[` from the bracket group also makes the match fail fast at the
|
|
34
|
+
// next `[`, so a malformed name cannot rescan to the end of the string from
|
|
35
|
+
// every unmatched `[` — parsing stays linear in the length of the name.
|
|
30
36
|
const path = [];
|
|
31
|
-
const pattern =
|
|
37
|
+
const pattern = /[^.[\]]+|\[([^.[\]]*)]/g;
|
|
32
38
|
let match;
|
|
33
39
|
|
|
34
40
|
while ((match = pattern.exec(name)) !== null) {
|
|
@@ -6,7 +6,7 @@ import platform from '../platform/index.js';
|
|
|
6
6
|
|
|
7
7
|
// RFC 2397: data:[<mediatype>][;base64],<data>
|
|
8
8
|
// mediatype = type/subtype followed by optional ;name=value parameters
|
|
9
|
-
const DATA_URL_PATTERN = /^([
|
|
9
|
+
const DATA_URL_PATTERN = /^([^,;/]+\/[^,;/]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Parse data uri to a Buffer or Blob
|
|
@@ -49,9 +49,10 @@ export default function fromDataURI(uri, asBlob, options) {
|
|
|
49
49
|
mime = 'text/plain' + params;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
const buffer =
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
const buffer =
|
|
53
|
+
encoding === 'base64'
|
|
54
|
+
? Buffer.from(body, 'base64')
|
|
55
|
+
: Buffer.from(decodeURIComponent(body), encoding);
|
|
55
56
|
|
|
56
57
|
if (asBlob) {
|
|
57
58
|
if (!_Blob) {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const urlParserControlCharacters = /[\t\n\r]/g;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Match WHATWG URL preprocessing before checking a URL's protocol.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} url
|
|
9
|
+
*
|
|
10
|
+
* @returns {string}
|
|
11
|
+
*/
|
|
12
|
+
export default function normalizeURLForProtocolCheck(url) {
|
|
13
|
+
if (typeof url !== 'string') {
|
|
14
|
+
return url;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let start = 0;
|
|
18
|
+
|
|
19
|
+
while (start < url.length && url.charCodeAt(start) <= 0x20) {
|
|
20
|
+
start++;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return url.slice(start).replace(urlParserControlCharacters, '');
|
|
24
|
+
}
|
|
@@ -50,18 +50,20 @@ export default (rawHeaders) => {
|
|
|
50
50
|
key = line.substring(0, i).trim().toLowerCase();
|
|
51
51
|
val = line.substring(i + 1).trim();
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
const hasKey = utils.hasOwnProp(parsed, key);
|
|
54
|
+
|
|
55
|
+
if (!key || (hasKey && utils.hasOwnProp(ignoreDuplicateOf, key))) {
|
|
54
56
|
return;
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
if (key === 'set-cookie') {
|
|
58
|
-
if (
|
|
60
|
+
if (hasKey) {
|
|
59
61
|
parsed[key].push(val);
|
|
60
62
|
} else {
|
|
61
63
|
parsed[key] = [val];
|
|
62
64
|
}
|
|
63
65
|
} else {
|
|
64
|
-
parsed[key] =
|
|
66
|
+
parsed[key] = hasKey ? parsed[key] + ', ' + val : val;
|
|
65
67
|
}
|
|
66
68
|
});
|
|
67
69
|
|
|
@@ -7,12 +7,12 @@ export const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
|
7
7
|
const _speedometer = speedometer(50, 250);
|
|
8
8
|
|
|
9
9
|
return throttle((e) => {
|
|
10
|
-
if (!e ||
|
|
10
|
+
if (!e || !utils.isNumber(e.loaded)) {
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
13
|
const rawLoaded = e.loaded;
|
|
14
14
|
const total = e.lengthComputable ? e.total : undefined;
|
|
15
|
-
const loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
|
|
15
|
+
const loaded = Math.max(0, total != null ? Math.min(rawLoaded, total) : rawLoaded);
|
|
16
16
|
const progressBytes = Math.max(0, loaded - bytesNotified);
|
|
17
17
|
const rate = _speedometer(progressBytes);
|
|
18
18
|
|
|
@@ -49,6 +49,6 @@ export const progressEventDecorator = (total, throttled) => {
|
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
export const asyncDecorator =
|
|
52
|
-
(fn) =>
|
|
52
|
+
(fn, scheduler = utils.asap) =>
|
|
53
53
|
(...args) =>
|
|
54
|
-
|
|
54
|
+
scheduler(() => fn(...args));
|
|
@@ -6,23 +6,9 @@ import cookies from './cookies.js';
|
|
|
6
6
|
import buildFullPath from '../core/buildFullPath.js';
|
|
7
7
|
import mergeConfig from '../core/mergeConfig.js';
|
|
8
8
|
import AxiosHeaders from '../core/AxiosHeaders.js';
|
|
9
|
+
import setFormDataHeaders from '../core/setFormDataHeaders.js';
|
|
9
10
|
import buildURL from './buildURL.js';
|
|
10
11
|
|
|
11
|
-
const FORM_DATA_CONTENT_HEADERS = ['content-type', 'content-length'];
|
|
12
|
-
|
|
13
|
-
function setFormDataHeaders(headers, formHeaders, policy) {
|
|
14
|
-
if (policy !== 'content-only') {
|
|
15
|
-
headers.set(formHeaders);
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
Object.entries(formHeaders || {}).forEach(([key, val]) => {
|
|
20
|
-
if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) {
|
|
21
|
-
headers.set(key, val);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
12
|
/**
|
|
27
13
|
* Encode a UTF-8 string to a Latin-1 byte string for use with btoa().
|
|
28
14
|
* This is a modern replacement for the deprecated unescape(encodeURIComponent(str)) pattern.
|
|
@@ -77,15 +63,17 @@ function resolveConfig(config) {
|
|
|
77
63
|
}
|
|
78
64
|
|
|
79
65
|
if (utils.isFormData(data)) {
|
|
66
|
+
const getHeaders = utils.getSafeProp(data, 'getHeaders');
|
|
67
|
+
|
|
80
68
|
if (
|
|
81
69
|
platform.hasStandardBrowserEnv ||
|
|
82
70
|
platform.hasStandardBrowserWebWorkerEnv ||
|
|
83
71
|
utils.isReactNative(data)
|
|
84
72
|
) {
|
|
85
73
|
headers.setContentType(undefined); // browser/web worker/RN handles it
|
|
86
|
-
} else if (utils.isFunction(
|
|
74
|
+
} else if (utils.isFunction(getHeaders)) {
|
|
87
75
|
// Node.js FormData (like form-data package)
|
|
88
|
-
setFormDataHeaders(headers,
|
|
76
|
+
setFormDataHeaders(headers, getHeaders.call(data), own('formDataHeaderPolicy'));
|
|
89
77
|
}
|
|
90
78
|
}
|
|
91
79
|
|