Skip to content

Commit 00897e0

Browse files
authored
build: update distribution (#3221)
1 parent 4cfc1fc commit 00897e0

File tree

1 file changed

+57
-31
lines changed

1 file changed

+57
-31
lines changed

dist/index.js

+57-31
Original file line numberDiff line numberDiff line change
@@ -15930,9 +15930,23 @@ const kWeight = Symbol('kWeight')
1593015930
const kMaxWeightPerServer = Symbol('kMaxWeightPerServer')
1593115931
const kErrorPenalty = Symbol('kErrorPenalty')
1593215932

15933+
/**
15934+
* Calculate the greatest common divisor of two numbers by
15935+
* using the Euclidean algorithm.
15936+
*
15937+
* @param {number} a
15938+
* @param {number} b
15939+
* @returns {number}
15940+
*/
1593315941
function getGreatestCommonDivisor (a, b) {
15934-
if (b === 0) return a
15935-
return getGreatestCommonDivisor(b, a % b)
15942+
if (a === 0) return b
15943+
15944+
while (b !== 0) {
15945+
const t = b
15946+
b = a % b
15947+
a = t
15948+
}
15949+
return a
1593615950
}
1593715951

1593815952
function defaultFactory (origin, opts) {
@@ -16010,7 +16024,12 @@ class BalancedPool extends PoolBase {
1601016024
}
1601116025

1601216026
_updateBalancedPoolStats () {
16013-
this[kGreatestCommonDivisor] = this[kClients].map(p => p[kWeight]).reduce(getGreatestCommonDivisor, 0)
16027+
let result = 0
16028+
for (let i = 0; i < this[kClients].length; i++) {
16029+
result = getGreatestCommonDivisor(this[kClients][i][kWeight], result)
16030+
}
16031+
16032+
this[kGreatestCommonDivisor] = result
1601416033
}
1601516034

1601616035
removeUpstream (upstream) {
@@ -25197,12 +25216,25 @@ const { kState } = __nccwpck_require__(749)
2519725216
const { webidl } = __nccwpck_require__(4890)
2519825217
const { Blob } = __nccwpck_require__(2254)
2519925218
const assert = __nccwpck_require__(8061)
25200-
const { isErrored } = __nccwpck_require__(3983)
25219+
const { isErrored, isDisturbed } = __nccwpck_require__(4492)
2520125220
const { isArrayBuffer } = __nccwpck_require__(3746)
2520225221
const { serializeAMimeType } = __nccwpck_require__(7704)
2520325222
const { multipartFormDataParser } = __nccwpck_require__(7991)
2520425223

2520525224
const textEncoder = new TextEncoder()
25225+
function noop () {}
25226+
25227+
const hasFinalizationRegistry = globalThis.FinalizationRegistry && process.version.indexOf('v18') !== 0
25228+
let streamRegistry
25229+
25230+
if (hasFinalizationRegistry) {
25231+
streamRegistry = new FinalizationRegistry((weakRef) => {
25232+
const stream = weakRef.deref()
25233+
if (stream && !stream.locked && !isDisturbed(stream) && !isErrored(stream)) {
25234+
stream.cancel('Response object has been garbage collected').catch(noop)
25235+
}
25236+
})
25237+
}
2520625238

2520725239
// https://fetch.spec.whatwg.org/#concept-bodyinit-extract
2520825240
function extractBody (object, keepalive = false) {
@@ -25445,14 +25477,18 @@ function safelyExtractBody (object, keepalive = false) {
2544525477
return extractBody(object, keepalive)
2544625478
}
2544725479

25448-
function cloneBody (body) {
25480+
function cloneBody (instance, body) {
2544925481
// To clone a body body, run these steps:
2545025482

2545125483
// https://fetch.spec.whatwg.org/#concept-body-clone
2545225484

2545325485
// 1. Let « out1, out2 » be the result of teeing body’s stream.
2545425486
const [out1, out2] = body.stream.tee()
2545525487

25488+
if (hasFinalizationRegistry) {
25489+
streamRegistry.register(instance, new WeakRef(out1))
25490+
}
25491+
2545625492
// 2. Set body’s stream to out1.
2545725493
body.stream = out1
2545825494

@@ -25595,7 +25631,7 @@ async function consumeBody (object, convertBytesToJSValue, instance) {
2559525631

2559625632
// 1. If object is unusable, then return a promise rejected
2559725633
// with a TypeError.
25598-
if (bodyUnusable(object[kState].body)) {
25634+
if (bodyUnusable(object)) {
2559925635
throw new TypeError('Body is unusable: Body has already been read')
2560025636
}
2560125637

@@ -25635,7 +25671,9 @@ async function consumeBody (object, convertBytesToJSValue, instance) {
2563525671
}
2563625672

2563725673
// https://fetch.spec.whatwg.org/#body-unusable
25638-
function bodyUnusable (body) {
25674+
function bodyUnusable (object) {
25675+
const body = object[kState].body
25676+
2563925677
// An object including the Body interface mixin is
2564025678
// said to be unusable if its body is non-null and
2564125679
// its body’s stream is disturbed or locked.
@@ -25677,7 +25715,10 @@ module.exports = {
2567725715
extractBody,
2567825716
safelyExtractBody,
2567925717
cloneBody,
25680-
mixinBody
25718+
mixinBody,
25719+
streamRegistry,
25720+
hasFinalizationRegistry,
25721+
bodyUnusable
2568125722
}
2568225723

2568325724

@@ -30487,7 +30528,7 @@ module.exports = {
3048730528

3048830529

3048930530

30490-
const { extractBody, mixinBody, cloneBody } = __nccwpck_require__(6682)
30531+
const { extractBody, mixinBody, cloneBody, bodyUnusable } = __nccwpck_require__(6682)
3049130532
const { Headers, fill: fillHeaders, HeadersList, setHeadersGuard, getHeadersGuard, setHeadersList, getHeadersList } = __nccwpck_require__(2991)
3049230533
const { FinalizationRegistry } = __nccwpck_require__(1922)()
3049330534
const util = __nccwpck_require__(3983)
@@ -31042,7 +31083,7 @@ class Request {
3104231083
// 40. If initBody is null and inputBody is non-null, then:
3104331084
if (initBody == null && inputBody != null) {
3104431085
// 1. If input is unusable, then throw a TypeError.
31045-
if (util.isDisturbed(inputBody.stream) || inputBody.stream.locked) {
31086+
if (bodyUnusable(input)) {
3104631087
throw new TypeError(
3104731088
'Cannot construct a Request with a Request object that has already been used.'
3104831089
)
@@ -31244,7 +31285,7 @@ class Request {
3124431285
webidl.brandCheck(this, Request)
3124531286

3124631287
// 1. If this is unusable, then throw a TypeError.
31247-
if (this.bodyUsed || this.body?.locked) {
31288+
if (bodyUnusable(this)) {
3124831289
throw new TypeError('unusable')
3124931290
}
3125031291

@@ -31362,7 +31403,7 @@ function cloneRequest (request) {
3136231403
// 2. If request’s body is non-null, set newRequest’s body to the
3136331404
// result of cloning request’s body.
3136431405
if (request.body != null) {
31365-
newRequest.body = cloneBody(request.body)
31406+
newRequest.body = cloneBody(newRequest, request.body)
3136631407
}
3136731408

3136831409
// 3. Return newRequest.
@@ -31530,7 +31571,7 @@ module.exports = { Request, makeRequest, fromInnerRequest, cloneRequest }
3153031571

3153131572

3153231573
const { Headers, HeadersList, fill, getHeadersGuard, setHeadersGuard, setHeadersList } = __nccwpck_require__(2991)
31533-
const { extractBody, cloneBody, mixinBody } = __nccwpck_require__(6682)
31574+
const { extractBody, cloneBody, mixinBody, hasFinalizationRegistry, streamRegistry, bodyUnusable } = __nccwpck_require__(6682)
3153431575
const util = __nccwpck_require__(3983)
3153531576
const nodeUtil = __nccwpck_require__(7261)
3153631577
const { kEnumerableProperty } = util
@@ -31555,24 +31596,9 @@ const { URLSerializer } = __nccwpck_require__(7704)
3155531596
const { kConstruct } = __nccwpck_require__(2785)
3155631597
const assert = __nccwpck_require__(8061)
3155731598
const { types } = __nccwpck_require__(7261)
31558-
const { isDisturbed, isErrored } = __nccwpck_require__(4492)
3155931599

3156031600
const textEncoder = new TextEncoder('utf-8')
3156131601

31562-
const hasFinalizationRegistry = globalThis.FinalizationRegistry && process.version.indexOf('v18') !== 0
31563-
let registry
31564-
31565-
if (hasFinalizationRegistry) {
31566-
registry = new FinalizationRegistry((weakRef) => {
31567-
const stream = weakRef.deref()
31568-
if (stream && !stream.locked && !isDisturbed(stream) && !isErrored(stream)) {
31569-
stream.cancel('Response object has been garbage collected').catch(noop)
31570-
}
31571-
})
31572-
}
31573-
31574-
function noop () {}
31575-
3157631602
// https://fetch.spec.whatwg.org/#response-class
3157731603
class Response {
3157831604
// Creates network error Response.
@@ -31773,7 +31799,7 @@ class Response {
3177331799
webidl.brandCheck(this, Response)
3177431800

3177531801
// 1. If this is unusable, then throw a TypeError.
31776-
if (this.bodyUsed || this.body?.locked) {
31802+
if (bodyUnusable(this)) {
3177731803
throw webidl.errors.exception({
3177831804
header: 'Response.clone',
3177931805
message: 'Body has already been consumed.'
@@ -31856,7 +31882,7 @@ function cloneResponse (response) {
3185631882
// 3. If response’s body is non-null, then set newResponse’s body to the
3185731883
// result of cloning response’s body.
3185831884
if (response.body != null) {
31859-
newResponse.body = cloneBody(response.body)
31885+
newResponse.body = cloneBody(newResponse, response.body)
3186031886
}
3186131887

3186231888
// 4. Return newResponse.
@@ -32061,7 +32087,7 @@ function fromInnerResponse (innerResponse, guard) {
3206132087
// a primitive or an object, even undefined. If the held value is an object, the registry keeps
3206232088
// a strong reference to it (so it can pass it to the cleanup callback later). Reworded from
3206332089
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry
32064-
registry.register(response, new WeakRef(innerResponse.body.stream))
32090+
streamRegistry.register(response, new WeakRef(innerResponse.body.stream))
3206532091
}
3206632092

3206732093
return response

0 commit comments

Comments
 (0)