@typespec/ts-http-runtime 0.3.5-alpha.20260311.2 → 0.3.5
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/browser/client/multipart.js.map +1 -1
- package/dist/browser/client/sendRequest.js +12 -4
- package/dist/browser/client/sendRequest.js.map +1 -1
- package/dist/browser/client/urlHelpers.js +9 -3
- package/dist/browser/client/urlHelpers.js.map +1 -1
- package/dist/browser/fetchHttpClient.d.ts +5 -0
- package/dist/browser/fetchHttpClient.js.map +1 -1
- package/dist/browser/logger/logger.js.map +1 -1
- package/dist/browser/policies/retryPolicy.js +4 -3
- package/dist/browser/policies/retryPolicy.js.map +1 -1
- package/dist/browser/util/concat.d.ts +16 -1
- package/dist/browser/util/concat.js +55 -1
- package/dist/browser/util/concat.js.map +1 -1
- package/dist/browser/util/sanitizer.js +3 -3
- package/dist/browser/util/sanitizer.js.map +1 -1
- package/dist/browser/util/typeGuards.js +2 -2
- package/dist/browser/util/typeGuards.js.map +1 -1
- package/dist/browser/util/userAgentPlatform.d.ts +28 -0
- package/dist/browser/util/userAgentPlatform.js +9 -10
- package/dist/browser/util/userAgentPlatform.js.map +1 -1
- package/dist/browser/util/uuidUtils.common.js +1 -1
- package/dist/browser/util/uuidUtils.common.js.map +1 -1
- package/dist/commonjs/abort-controller/AbortError.js +1 -0
- package/dist/commonjs/abort-controller/AbortError.js.map +1 -1
- package/dist/commonjs/auth/credentials.js +1 -0
- package/dist/commonjs/auth/credentials.js.map +1 -1
- package/dist/commonjs/auth/oauth2Flows.js +1 -0
- package/dist/commonjs/auth/oauth2Flows.js.map +1 -1
- package/dist/commonjs/auth/schemes.js +1 -0
- package/dist/commonjs/auth/schemes.js.map +1 -1
- package/dist/commonjs/client/apiVersionPolicy.js +1 -0
- package/dist/commonjs/client/apiVersionPolicy.js.map +1 -1
- package/dist/commonjs/client/clientHelpers.js +1 -0
- package/dist/commonjs/client/clientHelpers.js.map +1 -1
- package/dist/commonjs/client/common.js +1 -0
- package/dist/commonjs/client/common.js.map +1 -1
- package/dist/commonjs/client/getClient.js +1 -0
- package/dist/commonjs/client/getClient.js.map +1 -1
- package/dist/commonjs/client/multipart.js +1 -0
- package/dist/commonjs/client/multipart.js.map +3 -3
- package/dist/commonjs/client/operationOptionHelpers.js +1 -0
- package/dist/commonjs/client/operationOptionHelpers.js.map +1 -1
- package/dist/commonjs/client/restError.js +1 -0
- package/dist/commonjs/client/restError.js.map +1 -1
- package/dist/commonjs/client/sendRequest.js +13 -2
- package/dist/commonjs/client/sendRequest.js.map +3 -3
- package/dist/commonjs/client/urlHelpers.js +7 -3
- package/dist/commonjs/client/urlHelpers.js.map +3 -3
- package/dist/commonjs/constants.js +1 -0
- package/dist/commonjs/constants.js.map +1 -1
- package/dist/commonjs/createPipelineFromOptions.js +1 -0
- package/dist/commonjs/createPipelineFromOptions.js.map +1 -1
- package/dist/commonjs/defaultHttpClient.js +1 -0
- package/dist/commonjs/defaultHttpClient.js.map +1 -1
- package/dist/commonjs/fetchHttpClient.d.ts +5 -0
- package/dist/commonjs/fetchHttpClient.js +1 -0
- package/dist/commonjs/fetchHttpClient.js.map +3 -3
- package/dist/commonjs/httpHeaders.js +1 -0
- package/dist/commonjs/httpHeaders.js.map +1 -1
- package/dist/commonjs/index.js +1 -0
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/interfaces.js +1 -0
- package/dist/commonjs/interfaces.js.map +1 -1
- package/dist/commonjs/log.js +1 -0
- package/dist/commonjs/log.js.map +1 -1
- package/dist/commonjs/logger/debug.js +1 -0
- package/dist/commonjs/logger/debug.js.map +1 -1
- package/dist/commonjs/logger/internal.js +1 -0
- package/dist/commonjs/logger/internal.js.map +1 -1
- package/dist/commonjs/logger/log.common.js +1 -0
- package/dist/commonjs/logger/log.common.js.map +1 -1
- package/dist/commonjs/logger/log.js +1 -0
- package/dist/commonjs/logger/log.js.map +1 -1
- package/dist/commonjs/logger/logger.js +1 -0
- package/dist/commonjs/logger/logger.js.map +3 -3
- package/dist/commonjs/nodeHttpClient.js +1 -0
- package/dist/commonjs/nodeHttpClient.js.map +1 -1
- package/dist/commonjs/pipeline.js +1 -0
- package/dist/commonjs/pipeline.js.map +1 -1
- package/dist/commonjs/pipelineRequest.js +1 -0
- package/dist/commonjs/pipelineRequest.js.map +1 -1
- package/dist/commonjs/policies/agentPolicy.js +1 -0
- package/dist/commonjs/policies/agentPolicy.js.map +1 -1
- package/dist/commonjs/policies/auth/apiKeyAuthenticationPolicy.js +1 -0
- package/dist/commonjs/policies/auth/apiKeyAuthenticationPolicy.js.map +1 -1
- package/dist/commonjs/policies/auth/basicAuthenticationPolicy.js +1 -0
- package/dist/commonjs/policies/auth/basicAuthenticationPolicy.js.map +1 -1
- package/dist/commonjs/policies/auth/bearerAuthenticationPolicy.js +1 -0
- package/dist/commonjs/policies/auth/bearerAuthenticationPolicy.js.map +1 -1
- package/dist/commonjs/policies/auth/checkInsecureConnection.js +1 -0
- package/dist/commonjs/policies/auth/checkInsecureConnection.js.map +1 -1
- package/dist/commonjs/policies/auth/oauth2AuthenticationPolicy.js +1 -0
- package/dist/commonjs/policies/auth/oauth2AuthenticationPolicy.js.map +1 -1
- package/dist/commonjs/policies/decompressResponsePolicy.js +1 -0
- package/dist/commonjs/policies/decompressResponsePolicy.js.map +1 -1
- package/dist/commonjs/policies/defaultRetryPolicy.js +1 -0
- package/dist/commonjs/policies/defaultRetryPolicy.js.map +1 -1
- package/dist/commonjs/policies/exponentialRetryPolicy.js +1 -0
- package/dist/commonjs/policies/exponentialRetryPolicy.js.map +1 -1
- package/dist/commonjs/policies/formDataPolicy.js +1 -0
- package/dist/commonjs/policies/formDataPolicy.js.map +1 -1
- package/dist/commonjs/policies/internal.js +1 -0
- package/dist/commonjs/policies/internal.js.map +1 -1
- package/dist/commonjs/policies/logPolicy.js +1 -0
- package/dist/commonjs/policies/logPolicy.js.map +1 -1
- package/dist/commonjs/policies/multipartPolicy.js +1 -0
- package/dist/commonjs/policies/multipartPolicy.js.map +1 -1
- package/dist/commonjs/policies/proxyPolicy.common.js +1 -0
- package/dist/commonjs/policies/proxyPolicy.common.js.map +1 -1
- package/dist/commonjs/policies/proxyPolicy.js +3 -3
- package/dist/commonjs/policies/proxyPolicy.js.map +3 -3
- package/dist/commonjs/policies/redirectPolicy.js +1 -0
- package/dist/commonjs/policies/redirectPolicy.js.map +1 -1
- package/dist/commonjs/policies/retryPolicy.js +5 -3
- package/dist/commonjs/policies/retryPolicy.js.map +3 -3
- package/dist/commonjs/policies/systemErrorRetryPolicy.js +1 -0
- package/dist/commonjs/policies/systemErrorRetryPolicy.js.map +1 -1
- package/dist/commonjs/policies/throttlingRetryPolicy.js +1 -0
- package/dist/commonjs/policies/throttlingRetryPolicy.js.map +1 -1
- package/dist/commonjs/policies/tlsPolicy.js +1 -0
- package/dist/commonjs/policies/tlsPolicy.js.map +1 -1
- package/dist/commonjs/policies/userAgentPolicy.js +1 -0
- package/dist/commonjs/policies/userAgentPolicy.js.map +1 -1
- package/dist/commonjs/restError.js +1 -0
- package/dist/commonjs/restError.js.map +1 -1
- package/dist/commonjs/retryStrategies/exponentialRetryStrategy.js +1 -0
- package/dist/commonjs/retryStrategies/exponentialRetryStrategy.js.map +1 -1
- package/dist/commonjs/retryStrategies/retryStrategy.js +1 -0
- package/dist/commonjs/retryStrategies/retryStrategy.js.map +1 -1
- package/dist/commonjs/retryStrategies/throttlingRetryStrategy.js +1 -0
- package/dist/commonjs/retryStrategies/throttlingRetryStrategy.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +1 -1
- package/dist/commonjs/util/arrayBuffer.js +1 -0
- package/dist/commonjs/util/arrayBuffer.js.map +1 -1
- package/dist/commonjs/util/bytesEncoding.common.js +1 -0
- package/dist/commonjs/util/bytesEncoding.common.js.map +1 -1
- package/dist/commonjs/util/bytesEncoding.js +1 -0
- package/dist/commonjs/util/bytesEncoding.js.map +1 -1
- package/dist/commonjs/util/checkEnvironment.js +1 -0
- package/dist/commonjs/util/checkEnvironment.js.map +1 -1
- package/dist/commonjs/util/concat.js +1 -0
- package/dist/commonjs/util/concat.js.map +1 -1
- package/dist/commonjs/util/delay.js +1 -0
- package/dist/commonjs/util/delay.js.map +1 -1
- package/dist/commonjs/util/error.js +1 -0
- package/dist/commonjs/util/error.js.map +1 -1
- package/dist/commonjs/util/helpers.js +1 -0
- package/dist/commonjs/util/helpers.js.map +1 -1
- package/dist/commonjs/util/inspect.common.js +1 -0
- package/dist/commonjs/util/inspect.common.js.map +1 -1
- package/dist/commonjs/util/inspect.js +1 -0
- package/dist/commonjs/util/inspect.js.map +1 -1
- package/dist/commonjs/util/internal.js +1 -0
- package/dist/commonjs/util/internal.js.map +1 -1
- package/dist/commonjs/util/object.js +1 -0
- package/dist/commonjs/util/object.js.map +1 -1
- package/dist/commonjs/util/random.js +1 -0
- package/dist/commonjs/util/random.js.map +1 -1
- package/dist/commonjs/util/sanitizer.js +4 -3
- package/dist/commonjs/util/sanitizer.js.map +3 -3
- package/dist/commonjs/util/sha256.common.js +1 -0
- package/dist/commonjs/util/sha256.common.js.map +1 -1
- package/dist/commonjs/util/sha256.js +1 -0
- package/dist/commonjs/util/sha256.js.map +1 -1
- package/dist/commonjs/util/typeGuards.js +3 -2
- package/dist/commonjs/util/typeGuards.js.map +3 -3
- package/dist/commonjs/util/userAgent.js +1 -0
- package/dist/commonjs/util/userAgent.js.map +1 -1
- package/dist/commonjs/util/userAgentPlatform.d.ts +8 -0
- package/dist/commonjs/util/userAgentPlatform.js +7 -7
- package/dist/commonjs/util/userAgentPlatform.js.map +3 -3
- package/dist/commonjs/util/uuidUtils.common.js +2 -1
- package/dist/commonjs/util/uuidUtils.common.js.map +3 -3
- package/dist/commonjs/util/uuidUtils.js +1 -0
- package/dist/commonjs/util/uuidUtils.js.map +1 -1
- package/dist/commonjs/xhrHttpClient.js +1 -0
- package/dist/commonjs/xhrHttpClient.js.map +1 -1
- package/dist/esm/client/multipart.js.map +1 -1
- package/dist/esm/client/sendRequest.js +12 -4
- package/dist/esm/client/sendRequest.js.map +1 -1
- package/dist/esm/client/urlHelpers.js +9 -3
- package/dist/esm/client/urlHelpers.js.map +1 -1
- package/dist/esm/fetchHttpClient.d.ts +5 -0
- package/dist/esm/fetchHttpClient.js.map +1 -1
- package/dist/esm/logger/logger.js.map +1 -1
- package/dist/esm/policies/proxyPolicy.js +2 -3
- package/dist/esm/policies/proxyPolicy.js.map +1 -1
- package/dist/esm/policies/retryPolicy.js +4 -3
- package/dist/esm/policies/retryPolicy.js.map +1 -1
- package/dist/esm/util/sanitizer.js +3 -3
- package/dist/esm/util/sanitizer.js.map +1 -1
- package/dist/esm/util/typeGuards.js +2 -2
- package/dist/esm/util/typeGuards.js.map +1 -1
- package/dist/esm/util/userAgentPlatform.d.ts +8 -0
- package/dist/esm/util/userAgentPlatform.js +6 -7
- package/dist/esm/util/userAgentPlatform.js.map +1 -1
- package/dist/esm/util/uuidUtils.common.js +1 -1
- package/dist/esm/util/uuidUtils.common.js.map +1 -1
- package/dist/react-native/client/multipart.js.map +1 -1
- package/dist/react-native/client/sendRequest.js +12 -4
- package/dist/react-native/client/sendRequest.js.map +1 -1
- package/dist/react-native/client/urlHelpers.js +9 -3
- package/dist/react-native/client/urlHelpers.js.map +1 -1
- package/dist/react-native/fetchHttpClient.d.ts +5 -0
- package/dist/react-native/fetchHttpClient.js.map +1 -1
- package/dist/react-native/logger/logger.js.map +1 -1
- package/dist/react-native/policies/retryPolicy.js +4 -3
- package/dist/react-native/policies/retryPolicy.js.map +1 -1
- package/dist/react-native/util/concat.d.ts +34 -1
- package/dist/react-native/util/concat.js +48 -1
- package/dist/react-native/util/concat.js.map +1 -1
- package/dist/react-native/util/sanitizer.js +3 -3
- package/dist/react-native/util/sanitizer.js.map +1 -1
- package/dist/react-native/util/typeGuards.js +2 -2
- package/dist/react-native/util/typeGuards.js.map +1 -1
- package/dist/react-native/util/uuidUtils.common.js +1 -1
- package/dist/react-native/util/uuidUtils.common.js.map +1 -1
- package/package.json +10 -8
- package/dist/browser/util/concat.common.d.ts +0 -17
- package/dist/browser/util/concat.common.js +0 -58
- package/dist/browser/util/concat.common.js.map +0 -1
- package/dist/commonjs/util/concat.common.d.ts +0 -17
- package/dist/commonjs/util/concat.common.js +0 -60
- package/dist/commonjs/util/concat.common.js.map +0 -7
- package/dist/esm/util/concat.common.d.ts +0 -17
- package/dist/esm/util/concat.common.js +0 -58
- package/dist/esm/util/concat.common.js.map +0 -1
- package/dist/react-native/util/concat.common.d.ts +0 -17
- package/dist/react-native/util/concat.common.js +0 -58
- package/dist/react-native/util/concat.common.js.map +0 -1
|
@@ -1,4 +1,51 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
-
|
|
3
|
+
import { isWebReadableStream } from "./typeGuards.js";
|
|
4
|
+
/**
|
|
5
|
+
* Utility function that concatenates a set of binary inputs into one combined output.
|
|
6
|
+
*
|
|
7
|
+
* React Native runs on the Hermes engine, which implements a subset of web
|
|
8
|
+
* APIs with narrower type contracts than full browsers:
|
|
9
|
+
*
|
|
10
|
+
* - **Blob**: natively supported, but its constructor only accepts
|
|
11
|
+
* `(Blob | string)[]` — NOT the full `BlobPart[]` union. Passing a
|
|
12
|
+
* `Uint8Array` to `new Blob([uint8])` throws at runtime.
|
|
13
|
+
* See https://github.com/facebook/react-native/issues/44125
|
|
14
|
+
*
|
|
15
|
+
* - **Uint8Array**: works as a data type, but cannot be passed to the Blob
|
|
16
|
+
* constructor without a polyfill (e.g. react-native-blob-jsi-helper).
|
|
17
|
+
* See https://github.com/facebook/react-native/issues/41079
|
|
18
|
+
*
|
|
19
|
+
* - **ReadableStream / Response**: not available by default. Apps can polyfill
|
|
20
|
+
* these (e.g. web-streams-polyfill + react-native-fetch-api).
|
|
21
|
+
*
|
|
22
|
+
* This implementation handles all source types and defers to the runtime,
|
|
23
|
+
* so apps with the appropriate polyfills get correct behavior while apps
|
|
24
|
+
* without them get the engine's native error.
|
|
25
|
+
*
|
|
26
|
+
* @param sources - array of sources for the concatenation
|
|
27
|
+
* @returns a `Blob` representing all the concatenated inputs.
|
|
28
|
+
*
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
export async function concat(sources) {
|
|
32
|
+
const parts = [];
|
|
33
|
+
for (const source of sources) {
|
|
34
|
+
const resolved = typeof source === "function" ? source() : source;
|
|
35
|
+
if (resolved instanceof Blob || resolved instanceof Uint8Array) {
|
|
36
|
+
parts.push(resolved);
|
|
37
|
+
}
|
|
38
|
+
else if (isWebReadableStream(resolved)) {
|
|
39
|
+
// Requires ReadableStream + Response polyfills in RN
|
|
40
|
+
parts.push(await new Response(resolved).blob());
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
throw new Error(`Unsupported source type: ${typeof resolved}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Hermes's Blob constructor natively accepts only (Blob | string)[].
|
|
47
|
+
// Uint8Array requires a polyfill — the cast lets it through at compile
|
|
48
|
+
// time and defers the check to the runtime.
|
|
49
|
+
return new Blob(parts);
|
|
50
|
+
}
|
|
4
51
|
//# sourceMappingURL=concat.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"concat.js","sourceRoot":"","sources":["../../../src/util/concat.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,
|
|
1
|
+
{"version":3,"file":"concat.js","sourceRoot":"","sources":["../../../src/util/concat.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAStD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,OAAgD;IAEhD,MAAM,KAAK,GAA0B,EAAE,CAAC;IACxC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,QAAQ,GAAG,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;QAClE,IAAI,QAAQ,YAAY,IAAI,IAAI,QAAQ,YAAY,UAAU,EAAE,CAAC;YAC/D,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvB,CAAC;aAAM,IAAI,mBAAmB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACzC,qDAAqD;YACrD,KAAK,CAAC,IAAI,CAAC,MAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QAClD,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,4BAA4B,OAAO,QAAQ,EAAE,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;IAED,qEAAqE;IACrE,uEAAuE;IACvE,4CAA4C;IAC5C,OAAO,IAAI,IAAI,CAAC,KAA0B,CAAC,CAAC;AAC9C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { isWebReadableStream } from \"./typeGuards.js\";\n\n/**\n * Accepted binary data types for concat\n *\n * @internal\n */\nexport type ConcatSource = ReadableStream<Uint8Array> | NodeJS.ReadableStream | Uint8Array | Blob;\n\n/**\n * Utility function that concatenates a set of binary inputs into one combined output.\n *\n * React Native runs on the Hermes engine, which implements a subset of web\n * APIs with narrower type contracts than full browsers:\n *\n * - **Blob**: natively supported, but its constructor only accepts\n * `(Blob | string)[]` — NOT the full `BlobPart[]` union. Passing a\n * `Uint8Array` to `new Blob([uint8])` throws at runtime.\n * See https://github.com/facebook/react-native/issues/44125\n *\n * - **Uint8Array**: works as a data type, but cannot be passed to the Blob\n * constructor without a polyfill (e.g. react-native-blob-jsi-helper).\n * See https://github.com/facebook/react-native/issues/41079\n *\n * - **ReadableStream / Response**: not available by default. Apps can polyfill\n * these (e.g. web-streams-polyfill + react-native-fetch-api).\n *\n * This implementation handles all source types and defers to the runtime,\n * so apps with the appropriate polyfills get correct behavior while apps\n * without them get the engine's native error.\n *\n * @param sources - array of sources for the concatenation\n * @returns a `Blob` representing all the concatenated inputs.\n *\n * @internal\n */\nexport async function concat(\n sources: (ConcatSource | (() => ConcatSource))[],\n): Promise<(() => NodeJS.ReadableStream) | Blob> {\n const parts: (Blob | Uint8Array)[] = [];\n for (const source of sources) {\n const resolved = typeof source === \"function\" ? source() : source;\n if (resolved instanceof Blob || resolved instanceof Uint8Array) {\n parts.push(resolved);\n } else if (isWebReadableStream(resolved)) {\n // Requires ReadableStream + Response polyfills in RN\n parts.push(await new Response(resolved).blob());\n } else {\n throw new Error(`Unsupported source type: ${typeof resolved}`);\n }\n }\n\n // Hermes's Blob constructor natively accepts only (Blob | string)[].\n // Uint8Array requires a polyfill — the cast lets it through at compile\n // time and defers the check to the runtime.\n return new Blob(parts as (Blob | string)[]);\n}\n"]}
|
|
@@ -73,13 +73,13 @@ export class Sanitizer {
|
|
|
73
73
|
message: value.message,
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
|
-
if (key === "headers") {
|
|
76
|
+
if (key === "headers" && isObject(value)) {
|
|
77
77
|
return this.sanitizeHeaders(value);
|
|
78
78
|
}
|
|
79
|
-
else if (key === "url") {
|
|
79
|
+
else if (key === "url" && typeof value === "string") {
|
|
80
80
|
return this.sanitizeUrl(value);
|
|
81
81
|
}
|
|
82
|
-
else if (key === "query") {
|
|
82
|
+
else if (key === "query" && isObject(value)) {
|
|
83
83
|
return this.sanitizeQuery(value);
|
|
84
84
|
}
|
|
85
85
|
else if (key === "body") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitizer.js","sourceRoot":"","sources":["../../../src/util/sanitizer.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAsB,QAAQ,EAAE,MAAM,aAAa,CAAC;AAqB3D,MAAM,cAAc,GAAG,UAAU,CAAC;AAElC,sFAAsF;AACtF,MAAM,yBAAyB,GAAG;IAChC,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ject } from \"./object.js\";\n\n/**\n * Sanitizer options\n */\nexport interface SanitizerOptions {\n /**\n * Header names whose values will be logged when logging is enabled.\n * Defaults include a list of well-known safe headers. Any headers\n * specified in this field will be added to that list. Any other values will\n * be written to logs as \"REDACTED\".\n */\n additionalAllowedHeaderNames?: string[];\n\n /**\n * Query string names whose values will be logged when logging is enabled. By default no\n * query string values are logged.\n */\n additionalAllowedQueryParameters?: string[];\n}\n\nconst RedactedString = \"REDACTED\";\n\n// Make sure this list is up-to-date with the one under core/logger/Readme#Keyconcepts\nconst defaultAllowedHeaderNames = [\n \"x-ms-client-request-id\",\n \"x-ms-return-client-request-id\",\n \"x-ms-useragent\",\n \"x-ms-correlation-request-id\",\n \"x-ms-request-id\",\n \"client-request-id\",\n \"ms-cv\",\n \"return-client-request-id\",\n \"traceparent\",\n\n \"Access-Control-Allow-Credentials\",\n \"Access-Control-Allow-Headers\",\n \"Access-Control-Allow-Methods\",\n \"Access-Control-Allow-Origin\",\n \"Access-Control-Expose-Headers\",\n \"Access-Control-Max-Age\",\n \"Access-Control-Request-Headers\",\n \"Access-Control-Request-Method\",\n \"Origin\",\n\n \"Accept\",\n \"Accept-Encoding\",\n \"Cache-Control\",\n \"Connection\",\n \"Content-Length\",\n \"Content-Type\",\n \"Date\",\n \"ETag\",\n \"Expires\",\n \"If-Match\",\n \"If-Modified-Since\",\n \"If-None-Match\",\n \"If-Unmodified-Since\",\n \"Last-Modified\",\n \"Pragma\",\n \"Request-Id\",\n \"Retry-After\",\n \"Server\",\n \"Transfer-Encoding\",\n \"User-Agent\",\n \"WWW-Authenticate\",\n];\n\nconst defaultAllowedQueryParameters: string[] = [\"api-version\"];\n\n/**\n * A utility class to sanitize objects for logging.\n */\nexport class Sanitizer {\n private allowedHeaderNames: Set<string>;\n private allowedQueryParameters: Set<string>;\n\n constructor({\n additionalAllowedHeaderNames: allowedHeaderNames = [],\n additionalAllowedQueryParameters: allowedQueryParameters = [],\n }: SanitizerOptions = {}) {\n allowedHeaderNames = defaultAllowedHeaderNames.concat(allowedHeaderNames);\n allowedQueryParameters = defaultAllowedQueryParameters.concat(allowedQueryParameters);\n\n this.allowedHeaderNames = new Set(allowedHeaderNames.map((n) => n.toLowerCase()));\n this.allowedQueryParameters = new Set(allowedQueryParameters.map((p) => p.toLowerCase()));\n }\n\n /**\n * Sanitizes an object for logging.\n * @param obj - The object to sanitize\n * @returns - The sanitized object as a string\n */\n public sanitize(obj: unknown): string {\n const seen = new Set<unknown>();\n return JSON.stringify(\n obj,\n (key: string, value: unknown) => {\n // Ensure Errors include their interesting non-enumerable members\n if (value instanceof Error) {\n return {\n ...value,\n name: value.name,\n message: value.message,\n };\n }\n\n if (key === \"headers\" && isObject(value)) {\n return this.sanitizeHeaders(value);\n } else if (key === \"url\" && typeof value === \"string\") {\n return this.sanitizeUrl(value);\n } else if (key === \"query\" && isObject(value)) {\n return this.sanitizeQuery(value);\n } else if (key === \"body\") {\n // Don't log the request body\n return undefined;\n } else if (key === \"response\") {\n // Don't log response again\n return undefined;\n } else if (key === \"operationSpec\") {\n // When using sendOperationRequest, the request carries a massive\n // field with the autorest spec. No need to log it.\n return undefined;\n } else if (Array.isArray(value) || isObject(value)) {\n if (seen.has(value)) {\n return \"[Circular]\";\n }\n seen.add(value);\n }\n\n return value;\n },\n 2,\n );\n }\n\n /**\n * Sanitizes a URL for logging.\n * @param value - The URL to sanitize\n * @returns - The sanitized URL as a string\n */\n public sanitizeUrl(value: string): string {\n if (typeof value !== \"string\" || value === null || value === \"\") {\n return value;\n }\n\n const url = new URL(value);\n\n if (!url.search) {\n return value;\n }\n\n for (const [key] of url.searchParams) {\n if (!this.allowedQueryParameters.has(key.toLowerCase())) {\n url.searchParams.set(key, RedactedString);\n }\n }\n\n return url.toString();\n }\n\n private sanitizeHeaders(obj: UnknownObject): UnknownObject {\n const sanitized: UnknownObject = {};\n for (const key of Object.keys(obj)) {\n if (this.allowedHeaderNames.has(key.toLowerCase())) {\n sanitized[key] = obj[key];\n } else {\n sanitized[key] = RedactedString;\n }\n }\n return sanitized;\n }\n\n private sanitizeQuery(value: UnknownObject): UnknownObject {\n if (typeof value !== \"object\" || value === null) {\n return value;\n }\n\n const sanitized: UnknownObject = {};\n\n for (const k of Object.keys(value)) {\n if (this.allowedQueryParameters.has(k.toLowerCase())) {\n sanitized[k] = value[k];\n } else {\n sanitized[k] = RedactedString;\n }\n }\n\n return sanitized;\n }\n}\n"]}
|
|
@@ -13,12 +13,12 @@ export function isBinaryBody(body) {
|
|
|
13
13
|
(body instanceof Uint8Array ||
|
|
14
14
|
isReadableStream(body) ||
|
|
15
15
|
typeof body === "function" ||
|
|
16
|
-
body instanceof Blob));
|
|
16
|
+
(typeof Blob !== "undefined" && body instanceof Blob)));
|
|
17
17
|
}
|
|
18
18
|
export function isReadableStream(x) {
|
|
19
19
|
return isNodeReadableStream(x) || isWebReadableStream(x);
|
|
20
20
|
}
|
|
21
21
|
export function isBlob(x) {
|
|
22
|
-
return typeof
|
|
22
|
+
return typeof Blob !== "undefined" && x instanceof Blob;
|
|
23
23
|
}
|
|
24
24
|
//# sourceMappingURL=typeGuards.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeGuards.js","sourceRoot":"","sources":["../../../src/util/typeGuards.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,MAAM,UAAU,oBAAoB,CAAC,CAAU;IAC7C,OAAO,OAAO,CAAC,CAAC,IAAI,OAAQ,CAA2B,CAAC,MAAM,CAAC,KAAK,UAAU,CAAC,CAAC;AAClF,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,CAAU;IAC5C,OAAO,OAAO,CACZ,CAAC;QACD,OAAQ,CAAoB,CAAC,SAAS,KAAK,UAAU;QACrD,OAAQ,CAAoB,CAAC,GAAG,KAAK,UAAU,CAChD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,IAAa;IAQb,OAAO,CACL,IAAI,KAAK,SAAS;QAClB,CAAC,IAAI,YAAY,UAAU;YACzB,gBAAgB,CAAC,IAAI,CAAC;YACtB,OAAO,IAAI,KAAK,UAAU;YAC1B,IAAI,YAAY,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"typeGuards.js","sourceRoot":"","sources":["../../../src/util/typeGuards.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,MAAM,UAAU,oBAAoB,CAAC,CAAU;IAC7C,OAAO,OAAO,CAAC,CAAC,IAAI,OAAQ,CAA2B,CAAC,MAAM,CAAC,KAAK,UAAU,CAAC,CAAC;AAClF,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,CAAU;IAC5C,OAAO,OAAO,CACZ,CAAC;QACD,OAAQ,CAAoB,CAAC,SAAS,KAAK,UAAU;QACrD,OAAQ,CAAoB,CAAC,GAAG,KAAK,UAAU,CAChD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,IAAa;IAQb,OAAO,CACL,IAAI,KAAK,SAAS;QAClB,CAAC,IAAI,YAAY,UAAU;YACzB,gBAAgB,CAAC,IAAI,CAAC;YACtB,OAAO,IAAI,KAAK,UAAU;YAC1B,CAAC,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,YAAY,IAAI,CAAC,CAAC,CACzD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,CAAU;IACzC,OAAO,oBAAoB,CAAC,CAAC,CAAC,IAAI,mBAAmB,CAAC,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,CAAU;IAC/B,OAAO,OAAO,IAAI,KAAK,WAAW,IAAI,CAAC,YAAY,IAAI,CAAC;AAC1D,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport function isNodeReadableStream(x: unknown): x is NodeJS.ReadableStream {\n return Boolean(x && typeof (x as NodeJS.ReadableStream)[\"pipe\"] === \"function\");\n}\n\nexport function isWebReadableStream(x: unknown): x is ReadableStream {\n return Boolean(\n x &&\n typeof (x as ReadableStream).getReader === \"function\" &&\n typeof (x as ReadableStream).tee === \"function\",\n );\n}\n\nexport function isBinaryBody(\n body: unknown,\n): body is\n | Uint8Array\n | NodeJS.ReadableStream\n | ReadableStream<Uint8Array>\n | (() => NodeJS.ReadableStream)\n | (() => ReadableStream<Uint8Array>)\n | Blob {\n return (\n body !== undefined &&\n (body instanceof Uint8Array ||\n isReadableStream(body) ||\n typeof body === \"function\" ||\n (typeof Blob !== \"undefined\" && body instanceof Blob))\n );\n}\n\nexport function isReadableStream(x: unknown): x is ReadableStream | NodeJS.ReadableStream {\n return isNodeReadableStream(x) || isWebReadableStream(x);\n}\n\nexport function isBlob(x: unknown): x is Blob {\n return typeof Blob !== \"undefined\" && x instanceof Blob;\n}\n"]}
|
|
@@ -16,7 +16,7 @@ export function generateUUID() {
|
|
|
16
16
|
}
|
|
17
17
|
else if (i === 16) {
|
|
18
18
|
// Set the UUID variant to "10" in the 17th position
|
|
19
|
-
uuid += (randomNumber & 0x3) | 0x8;
|
|
19
|
+
uuid += ((randomNumber & 0x3) | 0x8).toString(16);
|
|
20
20
|
}
|
|
21
21
|
else {
|
|
22
22
|
// Add a random hexadecimal digit to the UUID string
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uuidUtils.common.js","sourceRoot":"","sources":["../../../src/util/uuidUtils.common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;;GAIG;AACH,MAAM,UAAU,YAAY;IAC1B,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5B,4CAA4C;QAC5C,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACpD,iDAAiD;QACjD,IAAI,CAAC,KAAK,EAAE,E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CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Generated Universally Unique Identifier\n *\n * @returns RFC4122 v4 UUID.\n */\nexport function generateUUID(): string {\n let uuid = \"\";\n for (let i = 0; i < 32; i++) {\n // Generate a random number between 0 and 15\n const randomNumber = Math.floor(Math.random() * 16);\n // Set the UUID version to 4 in the 13th position\n if (i === 12) {\n uuid += \"4\";\n } else if (i === 16) {\n // Set the UUID variant to \"10\" in the 17th position\n uuid += ((randomNumber & 0x3) | 0x8).toString(16);\n } else {\n // Add a random hexadecimal digit to the UUID string\n uuid += randomNumber.toString(16);\n }\n // Add hyphens to the UUID string at the appropriate positions\n if (i === 7 || i === 11 || i === 15 || i === 19) {\n uuid += \"-\";\n }\n }\n return uuid;\n}\n\n/**\n * Generated Universally Unique Identifier\n *\n * @returns RFC4122 v4 UUID.\n */\nexport function randomUUID(): string {\n return generateUUID();\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/ts-http-runtime",
|
|
3
|
-
"version": "0.3.5
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "Isomorphic client library for making HTTP requests in node.js and browser.",
|
|
5
5
|
"sdk-type": "client",
|
|
6
6
|
"type": "module",
|
|
@@ -129,19 +129,21 @@
|
|
|
129
129
|
},
|
|
130
130
|
"devDependencies": {
|
|
131
131
|
"@types/node": "^20.19.25",
|
|
132
|
-
"@
|
|
133
|
-
"@vitest/
|
|
132
|
+
"@types/react": "^19.2.14",
|
|
133
|
+
"@vitest/browser-playwright": "^4.1.2",
|
|
134
|
+
"@vitest/coverage-istanbul": "^4.1.2",
|
|
134
135
|
"cross-env": "^10.1.0",
|
|
135
136
|
"eslint": "^9.39.1",
|
|
136
|
-
"playwright": "^1.
|
|
137
|
+
"playwright": "^1.58.2",
|
|
137
138
|
"prettier": "^3.6.2",
|
|
139
|
+
"react-native": "^0.84.1",
|
|
138
140
|
"rimraf": "^6.1.0",
|
|
139
141
|
"tsx": "^4.20.4",
|
|
140
|
-
"typescript": "~
|
|
141
|
-
"vitest": "^4.
|
|
142
|
+
"typescript": "~6.0.2",
|
|
143
|
+
"vitest": "^4.1.2",
|
|
142
144
|
"@azure-tools/vite-plugin-browser-test-map": "^1.0.0",
|
|
143
|
-
"@azure/
|
|
144
|
-
"@azure/
|
|
145
|
+
"@azure/dev-tool": "^1.0.0",
|
|
146
|
+
"@azure/eslint-plugin-azure-sdk": "^3.0.0"
|
|
145
147
|
},
|
|
146
148
|
"module": "./dist/esm/index.js",
|
|
147
149
|
"scripts": {
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Accepted binary data types for concat
|
|
3
|
-
*
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
6
|
-
export type ConcatSource = ReadableStream<Uint8Array> | NodeJS.ReadableStream | Uint8Array | Blob;
|
|
7
|
-
/**
|
|
8
|
-
* Utility function that concatenates a set of binary inputs into one combined output.
|
|
9
|
-
*
|
|
10
|
-
* @param sources - array of sources for the concatenation
|
|
11
|
-
* @returns - in Node, a (() =\> NodeJS.ReadableStream) which, when read, produces a concatenation of all the inputs.
|
|
12
|
-
* In browser, returns a `Blob` representing all the concatenated inputs.
|
|
13
|
-
*
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
export declare function concat(sources: (ConcatSource | (() => ConcatSource))[]): Promise<(() => NodeJS.ReadableStream) | Blob>;
|
|
17
|
-
//# sourceMappingURL=concat.common.d.ts.map
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
import { isWebReadableStream } from "./typeGuards.js";
|
|
4
|
-
/**
|
|
5
|
-
* Drain the content of the given ReadableStream into a Blob.
|
|
6
|
-
* The blob's content may end up in memory or on disk dependent on size.
|
|
7
|
-
*/
|
|
8
|
-
function drain(stream) {
|
|
9
|
-
return new Response(stream).blob();
|
|
10
|
-
}
|
|
11
|
-
async function toBlobPart(source) {
|
|
12
|
-
if (source instanceof Blob || source instanceof Uint8Array) {
|
|
13
|
-
return source;
|
|
14
|
-
}
|
|
15
|
-
if (isWebReadableStream(source)) {
|
|
16
|
-
return drain(source);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
throw new Error("Unsupported source type. Only Blob, Uint8Array, and ReadableStream are supported in browser.");
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Converts a Uint8Array to a Uint8Array<ArrayBuffer>.
|
|
24
|
-
* @param source - The source Uint8Array.
|
|
25
|
-
* @returns
|
|
26
|
-
*/
|
|
27
|
-
function arrayToArrayBuffer(source) {
|
|
28
|
-
if ("resize" in source.buffer) {
|
|
29
|
-
// ArrayBuffer
|
|
30
|
-
return source;
|
|
31
|
-
}
|
|
32
|
-
// SharedArrayBuffer
|
|
33
|
-
return source.map((x) => x);
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Utility function that concatenates a set of binary inputs into one combined output.
|
|
37
|
-
*
|
|
38
|
-
* @param sources - array of sources for the concatenation
|
|
39
|
-
* @returns - in Node, a (() =\> NodeJS.ReadableStream) which, when read, produces a concatenation of all the inputs.
|
|
40
|
-
* In browser, returns a `Blob` representing all the concatenated inputs.
|
|
41
|
-
*
|
|
42
|
-
* @internal
|
|
43
|
-
*/
|
|
44
|
-
export async function concat(sources) {
|
|
45
|
-
const parts = [];
|
|
46
|
-
for (const source of sources) {
|
|
47
|
-
const blobPart = await toBlobPart(typeof source === "function" ? source() : source);
|
|
48
|
-
if (blobPart instanceof Blob) {
|
|
49
|
-
parts.push(blobPart);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
// Uint8Array
|
|
53
|
-
parts.push(new Blob([arrayToArrayBuffer(blobPart)]));
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return new Blob(parts);
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=concat.common.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"concat.common.js","sourceRoot":"","sources":["../../../src/util/concat.common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;;GAGG;AACH,SAAS,KAAK,CAAC,MAAkC;IAC/C,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;AACrC,CAAC;AAED,KAAK,UAAU,UAAU,CAAC,MAAoB;IAC5C,IAAI,MAAM,YAAY,IAAI,IAAI,MAAM,YAAY,UAAU,EAAE,CAAC;QAC3D,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CACb,8FAA8F,CAC/F,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,kBAAkB,CAAC,MAAkB;IAC5C,IAAI,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAC9B,cAAc;QACd,OAAO,MAAiC,CAAC;IAC3C,CAAC;IACD,oBAAoB;IACpB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;AAC9B,CAAC;AASD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,OAAgD;IAEhD,MAAM,KAAK,GAAG,EAAE,CAAC;IACjB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACpF,IAAI,QAAQ,YAAY,IAAI,EAAE,CAAC;YAC7B,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,aAAa;YACb,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAED,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { isWebReadableStream } from \"./typeGuards.js\";\n\n/**\n * Drain the content of the given ReadableStream into a Blob.\n * The blob's content may end up in memory or on disk dependent on size.\n */\nfunction drain(stream: ReadableStream<Uint8Array>): Promise<Blob> {\n return new Response(stream).blob();\n}\n\nasync function toBlobPart(source: ConcatSource): Promise<Blob | Uint8Array> {\n if (source instanceof Blob || source instanceof Uint8Array) {\n return source;\n }\n\n if (isWebReadableStream(source)) {\n return drain(source);\n } else {\n throw new Error(\n \"Unsupported source type. Only Blob, Uint8Array, and ReadableStream are supported in browser.\",\n );\n }\n}\n\n/**\n * Converts a Uint8Array to a Uint8Array<ArrayBuffer>.\n * @param source - The source Uint8Array.\n * @returns\n */\nfunction arrayToArrayBuffer(source: Uint8Array): Uint8Array<ArrayBuffer> {\n if (\"resize\" in source.buffer) {\n // ArrayBuffer\n return source as Uint8Array<ArrayBuffer>;\n }\n // SharedArrayBuffer\n return source.map((x) => x);\n}\n\n/**\n * Accepted binary data types for concat\n *\n * @internal\n */\nexport type ConcatSource = ReadableStream<Uint8Array> | NodeJS.ReadableStream | Uint8Array | Blob;\n\n/**\n * Utility function that concatenates a set of binary inputs into one combined output.\n *\n * @param sources - array of sources for the concatenation\n * @returns - in Node, a (() =\\> NodeJS.ReadableStream) which, when read, produces a concatenation of all the inputs.\n * In browser, returns a `Blob` representing all the concatenated inputs.\n *\n * @internal\n */\nexport async function concat(\n sources: (ConcatSource | (() => ConcatSource))[],\n): Promise<(() => NodeJS.ReadableStream) | Blob> {\n const parts = [];\n for (const source of sources) {\n const blobPart = await toBlobPart(typeof source === \"function\" ? source() : source);\n if (blobPart instanceof Blob) {\n parts.push(blobPart);\n } else {\n // Uint8Array\n parts.push(new Blob([arrayToArrayBuffer(blobPart)]));\n }\n }\n\n return new Blob(parts);\n}\n"]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Accepted binary data types for concat
|
|
3
|
-
*
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
6
|
-
export type ConcatSource = ReadableStream<Uint8Array> | NodeJS.ReadableStream | Uint8Array | Blob;
|
|
7
|
-
/**
|
|
8
|
-
* Utility function that concatenates a set of binary inputs into one combined output.
|
|
9
|
-
*
|
|
10
|
-
* @param sources - array of sources for the concatenation
|
|
11
|
-
* @returns - in Node, a (() =\> NodeJS.ReadableStream) which, when read, produces a concatenation of all the inputs.
|
|
12
|
-
* In browser, returns a `Blob` representing all the concatenated inputs.
|
|
13
|
-
*
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
export declare function concat(sources: (ConcatSource | (() => ConcatSource))[]): Promise<(() => NodeJS.ReadableStream) | Blob>;
|
|
17
|
-
//# sourceMappingURL=concat.common.d.ts.map
|
|
@@ -1,60 +0,0 @@
|
|
|
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
|
-
var concat_common_exports = {};
|
|
19
|
-
__export(concat_common_exports, {
|
|
20
|
-
concat: () => concat
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(concat_common_exports);
|
|
23
|
-
var import_typeGuards = require("./typeGuards.js");
|
|
24
|
-
function drain(stream) {
|
|
25
|
-
return new Response(stream).blob();
|
|
26
|
-
}
|
|
27
|
-
async function toBlobPart(source) {
|
|
28
|
-
if (source instanceof Blob || source instanceof Uint8Array) {
|
|
29
|
-
return source;
|
|
30
|
-
}
|
|
31
|
-
if ((0, import_typeGuards.isWebReadableStream)(source)) {
|
|
32
|
-
return drain(source);
|
|
33
|
-
} else {
|
|
34
|
-
throw new Error(
|
|
35
|
-
"Unsupported source type. Only Blob, Uint8Array, and ReadableStream are supported in browser."
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
function arrayToArrayBuffer(source) {
|
|
40
|
-
if ("resize" in source.buffer) {
|
|
41
|
-
return source;
|
|
42
|
-
}
|
|
43
|
-
return source.map((x) => x);
|
|
44
|
-
}
|
|
45
|
-
async function concat(sources) {
|
|
46
|
-
const parts = [];
|
|
47
|
-
for (const source of sources) {
|
|
48
|
-
const blobPart = await toBlobPart(typeof source === "function" ? source() : source);
|
|
49
|
-
if (blobPart instanceof Blob) {
|
|
50
|
-
parts.push(blobPart);
|
|
51
|
-
} else {
|
|
52
|
-
parts.push(new Blob([arrayToArrayBuffer(blobPart)]));
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return new Blob(parts);
|
|
56
|
-
}
|
|
57
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
-
0 && (module.exports = {
|
|
59
|
-
concat
|
|
60
|
-
});
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["/mnt/vss/_work/1/s/sdk/core/ts-http-runtime/src/util/concat.common.ts"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { isWebReadableStream } from \"./typeGuards.js\";\n\n/**\n * Drain the content of the given ReadableStream into a Blob.\n * The blob's content may end up in memory or on disk dependent on size.\n */\nfunction drain(stream: ReadableStream<Uint8Array>): Promise<Blob> {\n return new Response(stream).blob();\n}\n\nasync function toBlobPart(source: ConcatSource): Promise<Blob | Uint8Array> {\n if (source instanceof Blob || source instanceof Uint8Array) {\n return source;\n }\n\n if (isWebReadableStream(source)) {\n return drain(source);\n } else {\n throw new Error(\n \"Unsupported source type. Only Blob, Uint8Array, and ReadableStream are supported in browser.\",\n );\n }\n}\n\n/**\n * Converts a Uint8Array to a Uint8Array<ArrayBuffer>.\n * @param source - The source Uint8Array.\n * @returns\n */\nfunction arrayToArrayBuffer(source: Uint8Array): Uint8Array<ArrayBuffer> {\n if (\"resize\" in source.buffer) {\n // ArrayBuffer\n return source as Uint8Array<ArrayBuffer>;\n }\n // SharedArrayBuffer\n return source.map((x) => x);\n}\n\n/**\n * Accepted binary data types for concat\n *\n * @internal\n */\nexport type ConcatSource = ReadableStream<Uint8Array> | NodeJS.ReadableStream | Uint8Array | Blob;\n\n/**\n * Utility function that concatenates a set of binary inputs into one combined output.\n *\n * @param sources - array of sources for the concatenation\n * @returns - in Node, a (() =\\> NodeJS.ReadableStream) which, when read, produces a concatenation of all the inputs.\n * In browser, returns a `Blob` representing all the concatenated inputs.\n *\n * @internal\n */\nexport async function concat(\n sources: (ConcatSource | (() => ConcatSource))[],\n): Promise<(() => NodeJS.ReadableStream) | Blob> {\n const parts = [];\n for (const source of sources) {\n const blobPart = await toBlobPart(typeof source === \"function\" ? source() : source);\n if (blobPart instanceof Blob) {\n parts.push(blobPart);\n } else {\n // Uint8Array\n parts.push(new Blob([arrayToArrayBuffer(blobPart)]));\n }\n }\n\n return new Blob(parts);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAAoC;AAMpC,SAAS,MAAM,QAAmD;AAChE,SAAO,IAAI,SAAS,MAAM,EAAE,KAAK;AACnC;AAEA,eAAe,WAAW,QAAkD;AAC1E,MAAI,kBAAkB,QAAQ,kBAAkB,YAAY;AAC1D,WAAO;AAAA,EACT;AAEA,UAAI,uCAAoB,MAAM,GAAG;AAC/B,WAAO,MAAM,MAAM;AAAA,EACrB,OAAO;AACL,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACF;AAOA,SAAS,mBAAmB,QAA6C;AACvE,MAAI,YAAY,OAAO,QAAQ;AAE7B,WAAO;AAAA,EACT;AAEA,SAAO,OAAO,IAAI,CAAC,MAAM,CAAC;AAC5B;AAkBA,eAAsB,OACpB,SAC+C;AAC/C,QAAM,QAAQ,CAAC;AACf,aAAW,UAAU,SAAS;AAC5B,UAAM,WAAW,MAAM,WAAW,OAAO,WAAW,aAAa,OAAO,IAAI,MAAM;AAClF,QAAI,oBAAoB,MAAM;AAC5B,YAAM,KAAK,QAAQ;AAAA,IACrB,OAAO;AAEL,YAAM,KAAK,IAAI,KAAK,CAAC,mBAAmB,QAAQ,CAAC,CAAC,CAAC;AAAA,IACrD;AAAA,EACF;AAEA,SAAO,IAAI,KAAK,KAAK;AACvB;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Accepted binary data types for concat
|
|
3
|
-
*
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
6
|
-
export type ConcatSource = ReadableStream<Uint8Array> | NodeJS.ReadableStream | Uint8Array | Blob;
|
|
7
|
-
/**
|
|
8
|
-
* Utility function that concatenates a set of binary inputs into one combined output.
|
|
9
|
-
*
|
|
10
|
-
* @param sources - array of sources for the concatenation
|
|
11
|
-
* @returns - in Node, a (() =\> NodeJS.ReadableStream) which, when read, produces a concatenation of all the inputs.
|
|
12
|
-
* In browser, returns a `Blob` representing all the concatenated inputs.
|
|
13
|
-
*
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
export declare function concat(sources: (ConcatSource | (() => ConcatSource))[]): Promise<(() => NodeJS.ReadableStream) | Blob>;
|
|
17
|
-
//# sourceMappingURL=concat.common.d.ts.map
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
import { isWebReadableStream } from "./typeGuards.js";
|
|
4
|
-
/**
|
|
5
|
-
* Drain the content of the given ReadableStream into a Blob.
|
|
6
|
-
* The blob's content may end up in memory or on disk dependent on size.
|
|
7
|
-
*/
|
|
8
|
-
function drain(stream) {
|
|
9
|
-
return new Response(stream).blob();
|
|
10
|
-
}
|
|
11
|
-
async function toBlobPart(source) {
|
|
12
|
-
if (source instanceof Blob || source instanceof Uint8Array) {
|
|
13
|
-
return source;
|
|
14
|
-
}
|
|
15
|
-
if (isWebReadableStream(source)) {
|
|
16
|
-
return drain(source);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
throw new Error("Unsupported source type. Only Blob, Uint8Array, and ReadableStream are supported in browser.");
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Converts a Uint8Array to a Uint8Array<ArrayBuffer>.
|
|
24
|
-
* @param source - The source Uint8Array.
|
|
25
|
-
* @returns
|
|
26
|
-
*/
|
|
27
|
-
function arrayToArrayBuffer(source) {
|
|
28
|
-
if ("resize" in source.buffer) {
|
|
29
|
-
// ArrayBuffer
|
|
30
|
-
return source;
|
|
31
|
-
}
|
|
32
|
-
// SharedArrayBuffer
|
|
33
|
-
return source.map((x) => x);
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Utility function that concatenates a set of binary inputs into one combined output.
|
|
37
|
-
*
|
|
38
|
-
* @param sources - array of sources for the concatenation
|
|
39
|
-
* @returns - in Node, a (() =\> NodeJS.ReadableStream) which, when read, produces a concatenation of all the inputs.
|
|
40
|
-
* In browser, returns a `Blob` representing all the concatenated inputs.
|
|
41
|
-
*
|
|
42
|
-
* @internal
|
|
43
|
-
*/
|
|
44
|
-
export async function concat(sources) {
|
|
45
|
-
const parts = [];
|
|
46
|
-
for (const source of sources) {
|
|
47
|
-
const blobPart = await toBlobPart(typeof source === "function" ? source() : source);
|
|
48
|
-
if (blobPart instanceof Blob) {
|
|
49
|
-
parts.push(blobPart);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
// Uint8Array
|
|
53
|
-
parts.push(new Blob([arrayToArrayBuffer(blobPart)]));
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return new Blob(parts);
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=concat.common.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"concat.common.js","sourceRoot":"","sources":["../../../src/util/concat.common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;;GAGG;AACH,SAAS,KAAK,CAAC,MAAkC;IAC/C,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;AACrC,CAAC;AAED,KAAK,UAAU,UAAU,CAAC,MAAoB;IAC5C,IAAI,MAAM,YAAY,IAAI,IAAI,MAAM,YAAY,UAAU,EAAE,CAAC;QAC3D,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CACb,8FAA8F,CAC/F,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,kBAAkB,CAAC,MAAkB;IAC5C,IAAI,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAC9B,cAAc;QACd,OAAO,MAAiC,CAAC;IAC3C,CAAC;IACD,oBAAoB;IACpB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;AAC9B,CAAC;AASD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,OAAgD;IAEhD,MAAM,KAAK,GAAG,EAAE,CAAC;IACjB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACpF,IAAI,QAAQ,YAAY,IAAI,EAAE,CAAC;YAC7B,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,aAAa;YACb,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAED,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { isWebReadableStream } from \"./typeGuards.js\";\n\n/**\n * Drain the content of the given ReadableStream into a Blob.\n * The blob's content may end up in memory or on disk dependent on size.\n */\nfunction drain(stream: ReadableStream<Uint8Array>): Promise<Blob> {\n return new Response(stream).blob();\n}\n\nasync function toBlobPart(source: ConcatSource): Promise<Blob | Uint8Array> {\n if (source instanceof Blob || source instanceof Uint8Array) {\n return source;\n }\n\n if (isWebReadableStream(source)) {\n return drain(source);\n } else {\n throw new Error(\n \"Unsupported source type. Only Blob, Uint8Array, and ReadableStream are supported in browser.\",\n );\n }\n}\n\n/**\n * Converts a Uint8Array to a Uint8Array<ArrayBuffer>.\n * @param source - The source Uint8Array.\n * @returns\n */\nfunction arrayToArrayBuffer(source: Uint8Array): Uint8Array<ArrayBuffer> {\n if (\"resize\" in source.buffer) {\n // ArrayBuffer\n return source as Uint8Array<ArrayBuffer>;\n }\n // SharedArrayBuffer\n return source.map((x) => x);\n}\n\n/**\n * Accepted binary data types for concat\n *\n * @internal\n */\nexport type ConcatSource = ReadableStream<Uint8Array> | NodeJS.ReadableStream | Uint8Array | Blob;\n\n/**\n * Utility function that concatenates a set of binary inputs into one combined output.\n *\n * @param sources - array of sources for the concatenation\n * @returns - in Node, a (() =\\> NodeJS.ReadableStream) which, when read, produces a concatenation of all the inputs.\n * In browser, returns a `Blob` representing all the concatenated inputs.\n *\n * @internal\n */\nexport async function concat(\n sources: (ConcatSource | (() => ConcatSource))[],\n): Promise<(() => NodeJS.ReadableStream) | Blob> {\n const parts = [];\n for (const source of sources) {\n const blobPart = await toBlobPart(typeof source === \"function\" ? source() : source);\n if (blobPart instanceof Blob) {\n parts.push(blobPart);\n } else {\n // Uint8Array\n parts.push(new Blob([arrayToArrayBuffer(blobPart)]));\n }\n }\n\n return new Blob(parts);\n}\n"]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Accepted binary data types for concat
|
|
3
|
-
*
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
6
|
-
export type ConcatSource = ReadableStream<Uint8Array> | NodeJS.ReadableStream | Uint8Array | Blob;
|
|
7
|
-
/**
|
|
8
|
-
* Utility function that concatenates a set of binary inputs into one combined output.
|
|
9
|
-
*
|
|
10
|
-
* @param sources - array of sources for the concatenation
|
|
11
|
-
* @returns - in Node, a (() =\> NodeJS.ReadableStream) which, when read, produces a concatenation of all the inputs.
|
|
12
|
-
* In browser, returns a `Blob` representing all the concatenated inputs.
|
|
13
|
-
*
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
export declare function concat(sources: (ConcatSource | (() => ConcatSource))[]): Promise<(() => NodeJS.ReadableStream) | Blob>;
|
|
17
|
-
//# sourceMappingURL=concat.common.d.ts.map
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
import { isWebReadableStream } from "./typeGuards.js";
|
|
4
|
-
/**
|
|
5
|
-
* Drain the content of the given ReadableStream into a Blob.
|
|
6
|
-
* The blob's content may end up in memory or on disk dependent on size.
|
|
7
|
-
*/
|
|
8
|
-
function drain(stream) {
|
|
9
|
-
return new Response(stream).blob();
|
|
10
|
-
}
|
|
11
|
-
async function toBlobPart(source) {
|
|
12
|
-
if (source instanceof Blob || source instanceof Uint8Array) {
|
|
13
|
-
return source;
|
|
14
|
-
}
|
|
15
|
-
if (isWebReadableStream(source)) {
|
|
16
|
-
return drain(source);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
throw new Error("Unsupported source type. Only Blob, Uint8Array, and ReadableStream are supported in browser.");
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Converts a Uint8Array to a Uint8Array<ArrayBuffer>.
|
|
24
|
-
* @param source - The source Uint8Array.
|
|
25
|
-
* @returns
|
|
26
|
-
*/
|
|
27
|
-
function arrayToArrayBuffer(source) {
|
|
28
|
-
if ("resize" in source.buffer) {
|
|
29
|
-
// ArrayBuffer
|
|
30
|
-
return source;
|
|
31
|
-
}
|
|
32
|
-
// SharedArrayBuffer
|
|
33
|
-
return source.map((x) => x);
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Utility function that concatenates a set of binary inputs into one combined output.
|
|
37
|
-
*
|
|
38
|
-
* @param sources - array of sources for the concatenation
|
|
39
|
-
* @returns - in Node, a (() =\> NodeJS.ReadableStream) which, when read, produces a concatenation of all the inputs.
|
|
40
|
-
* In browser, returns a `Blob` representing all the concatenated inputs.
|
|
41
|
-
*
|
|
42
|
-
* @internal
|
|
43
|
-
*/
|
|
44
|
-
export async function concat(sources) {
|
|
45
|
-
const parts = [];
|
|
46
|
-
for (const source of sources) {
|
|
47
|
-
const blobPart = await toBlobPart(typeof source === "function" ? source() : source);
|
|
48
|
-
if (blobPart instanceof Blob) {
|
|
49
|
-
parts.push(blobPart);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
// Uint8Array
|
|
53
|
-
parts.push(new Blob([arrayToArrayBuffer(blobPart)]));
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return new Blob(parts);
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=concat.common.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"concat.common.js","sourceRoot":"","sources":["../../../src/util/concat.common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;;GAGG;AACH,SAAS,KAAK,CAAC,MAAkC;IAC/C,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;AACrC,CAAC;AAED,KAAK,UAAU,UAAU,CAAC,MAAoB;IAC5C,IAAI,MAAM,YAAY,IAAI,IAAI,MAAM,YAAY,UAAU,EAAE,CAAC;QAC3D,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CACb,8FAA8F,CAC/F,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,kBAAkB,CAAC,MAAkB;IAC5C,IAAI,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAC9B,cAAc;QACd,OAAO,MAAiC,CAAC;IAC3C,CAAC;IACD,oBAAoB;IACpB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;AAC9B,CAAC;AASD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,OAAgD;IAEhD,MAAM,KAAK,GAAG,EAAE,CAAC;IACjB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACpF,IAAI,QAAQ,YAAY,IAAI,EAAE,CAAC;YAC7B,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,aAAa;YACb,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAED,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { isWebReadableStream } from \"./typeGuards.js\";\n\n/**\n * Drain the content of the given ReadableStream into a Blob.\n * The blob's content may end up in memory or on disk dependent on size.\n */\nfunction drain(stream: ReadableStream<Uint8Array>): Promise<Blob> {\n return new Response(stream).blob();\n}\n\nasync function toBlobPart(source: ConcatSource): Promise<Blob | Uint8Array> {\n if (source instanceof Blob || source instanceof Uint8Array) {\n return source;\n }\n\n if (isWebReadableStream(source)) {\n return drain(source);\n } else {\n throw new Error(\n \"Unsupported source type. Only Blob, Uint8Array, and ReadableStream are supported in browser.\",\n );\n }\n}\n\n/**\n * Converts a Uint8Array to a Uint8Array<ArrayBuffer>.\n * @param source - The source Uint8Array.\n * @returns\n */\nfunction arrayToArrayBuffer(source: Uint8Array): Uint8Array<ArrayBuffer> {\n if (\"resize\" in source.buffer) {\n // ArrayBuffer\n return source as Uint8Array<ArrayBuffer>;\n }\n // SharedArrayBuffer\n return source.map((x) => x);\n}\n\n/**\n * Accepted binary data types for concat\n *\n * @internal\n */\nexport type ConcatSource = ReadableStream<Uint8Array> | NodeJS.ReadableStream | Uint8Array | Blob;\n\n/**\n * Utility function that concatenates a set of binary inputs into one combined output.\n *\n * @param sources - array of sources for the concatenation\n * @returns - in Node, a (() =\\> NodeJS.ReadableStream) which, when read, produces a concatenation of all the inputs.\n * In browser, returns a `Blob` representing all the concatenated inputs.\n *\n * @internal\n */\nexport async function concat(\n sources: (ConcatSource | (() => ConcatSource))[],\n): Promise<(() => NodeJS.ReadableStream) | Blob> {\n const parts = [];\n for (const source of sources) {\n const blobPart = await toBlobPart(typeof source === \"function\" ? source() : source);\n if (blobPart instanceof Blob) {\n parts.push(blobPart);\n } else {\n // Uint8Array\n parts.push(new Blob([arrayToArrayBuffer(blobPart)]));\n }\n }\n\n return new Blob(parts);\n}\n"]}
|