fix(core): Ensure correct ArrayBuffer return, fix fetch body typing, reorganize node-only tests, and bump tsbuild devDependency
This commit is contained in:
@@ -1,5 +1,13 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2025-11-16 - 4.3.8 - fix(core)
|
||||||
|
Ensure correct ArrayBuffer return, fix fetch body typing, reorganize node-only tests, and bump tsbuild devDependency
|
||||||
|
|
||||||
|
- core_node: Fix arrayBuffer() to ensure an ArrayBuffer is returned (avoid returning SharedArrayBuffer) to improve interoperability when consuming binary responses.
|
||||||
|
- core_fetch: Cast request body to BodyInit when assigning to fetch options and preserve duplex = 'half' for ReadableStream bodies to satisfy typings and streaming behavior.
|
||||||
|
- tests: Reorganize tests into Node-only variants (rename/remove multi-platform test files to test.*.node.ts) to separate platform-specific test coverage.
|
||||||
|
- chore: Bump devDependency @git.zone/tsbuild from ^2.6.8 to ^2.7.1.
|
||||||
|
|
||||||
## 2025-11-01 - 4.3.7 - fix(ci)
|
## 2025-11-01 - 4.3.7 - fix(ci)
|
||||||
Update dependencies, add deno.lock, and reorganize tests for browser and Node environments
|
Update dependencies, add deno.lock, and reorganize tests for browser and Node environments
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
"form-data": "^4.0.4"
|
"form-data": "^4.0.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@git.zone/tsbuild": "^2.6.8",
|
"@git.zone/tsbuild": "^2.7.1",
|
||||||
"@git.zone/tsrun": "^1.6.2",
|
"@git.zone/tsrun": "^1.6.2",
|
||||||
"@git.zone/tstest": "^2.7.0",
|
"@git.zone/tstest": "^2.7.0",
|
||||||
"@types/node": "^22.9.0"
|
"@types/node": "^22.9.0"
|
||||||
|
|||||||
680
pnpm-lock.yaml
generated
680
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartrequest',
|
name: '@push.rocks/smartrequest',
|
||||||
version: '4.3.7',
|
version: '4.3.8',
|
||||||
description: 'A module for modern HTTP/HTTPS requests with support for form data, file uploads, JSON, binary data, streams, and more.'
|
description: 'A module for modern HTTP/HTTPS requests with support for form data, file uploads, JSON, binary data, streams, and more.'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ export class CoreRequest extends AbstractCoreRequest<
|
|||||||
// Check for Buffer (Node.js polyfills in browser may provide this)
|
// Check for Buffer (Node.js polyfills in browser may provide this)
|
||||||
(typeof Buffer !== 'undefined' && this.options.requestBody instanceof Buffer)
|
(typeof Buffer !== 'undefined' && this.options.requestBody instanceof Buffer)
|
||||||
) {
|
) {
|
||||||
fetchOptions.body = this.options.requestBody;
|
fetchOptions.body = this.options.requestBody as BodyInit;
|
||||||
|
|
||||||
// If streaming, we need to set duplex mode
|
// If streaming, we need to set duplex mode
|
||||||
if (this.options.requestBody instanceof ReadableStream) {
|
if (this.options.requestBody instanceof ReadableStream) {
|
||||||
|
|||||||
@@ -115,10 +115,12 @@ export class CoreResponse<T = any>
|
|||||||
*/
|
*/
|
||||||
async arrayBuffer(): Promise<ArrayBuffer> {
|
async arrayBuffer(): Promise<ArrayBuffer> {
|
||||||
const buffer = await this.collectBody();
|
const buffer = await this.collectBody();
|
||||||
return buffer.buffer.slice(
|
const sliced = buffer.buffer.slice(
|
||||||
buffer.byteOffset,
|
buffer.byteOffset,
|
||||||
buffer.byteOffset + buffer.byteLength,
|
buffer.byteOffset + buffer.byteLength,
|
||||||
);
|
);
|
||||||
|
// Ensure we return ArrayBuffer, not SharedArrayBuffer
|
||||||
|
return sliced instanceof ArrayBuffer ? sliced : new ArrayBuffer(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user