keq 5.0.0-alpha.25 → 5.0.0-alpha.26
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/CHANGELOG.md +10 -0
- package/dist/context/utils/fork.d.ts.map +1 -1
- package/dist/index.js +25 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -12
- package/dist/index.mjs.map +1 -1
- package/dist/middlewares/flow-control-middleware/serial-flow-control-middleware.d.ts.map +1 -1
- package/dist/middlewares/flow-control-middleware/types/keq-flow-control.d.ts +2 -1
- package/dist/middlewares/flow-control-middleware/types/keq-flow-control.d.ts.map +1 -1
- package/dist/request/keq.d.ts +4 -2
- package/dist/request/keq.d.ts.map +1 -1
- package/dist/request/request.d.ts.map +1 -1
- package/package.json +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
## 5.0.0-alpha.6 (2025-09-17)
|
|
2
2
|
|
|
3
|
+
## 5.0.0-alpha.26
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 63161c4: **Feat:** the .flowControl() support concurrency.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 22ce01a: **Fix:** JSON.stringify ctx.response always get empty object.
|
|
12
|
+
|
|
3
13
|
## 5.0.0-alpha.25
|
|
4
14
|
|
|
5
15
|
### Major Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fork.d.ts","sourceRoot":"","sources":["../../../src/context/utils/fork.ts"],"names":[],"mappings":"AAuBA;;GAEG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"fork.d.ts","sourceRoot":"","sources":["../../../src/context/utils/fork.ts"],"names":[],"mappings":"AAuBA;;GAEG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CA4EtC;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAErC"}
|
package/dist/index.js
CHANGED
|
@@ -790,15 +790,16 @@ function fork(original) {
|
|
|
790
790
|
return current;
|
|
791
791
|
};
|
|
792
792
|
const createProxy = (path = []) => {
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
793
|
+
const getTarget = () => objectPath(current, path);
|
|
794
|
+
return new Proxy(getTarget(), {
|
|
795
|
+
get(target, prop) {
|
|
796
|
+
const realTarget = getTarget();
|
|
797
|
+
if (prop === UnWrapPropertyKey) return realTarget;
|
|
798
|
+
const value = realTarget[prop];
|
|
798
799
|
if (current !== original) {
|
|
799
800
|
return value;
|
|
800
801
|
}
|
|
801
|
-
if (Array.isArray(
|
|
802
|
+
if (Array.isArray(realTarget) && ARRAY_MUTATORS.has(prop)) {
|
|
802
803
|
return new Proxy(value, {
|
|
803
804
|
apply(fn, thisArg, args) {
|
|
804
805
|
ensureCopy();
|
|
@@ -812,15 +813,23 @@ function fork(original) {
|
|
|
812
813
|
}
|
|
813
814
|
return value;
|
|
814
815
|
},
|
|
815
|
-
set(
|
|
816
|
+
set(target, prop, value) {
|
|
816
817
|
ensureCopy();
|
|
817
818
|
objectPath(current, path)[prop] = value;
|
|
818
819
|
return true;
|
|
819
820
|
},
|
|
820
|
-
deleteProperty(
|
|
821
|
+
deleteProperty(target, prop) {
|
|
821
822
|
ensureCopy();
|
|
822
823
|
delete objectPath(current, path)[prop];
|
|
823
824
|
return true;
|
|
825
|
+
},
|
|
826
|
+
ownKeys(target) {
|
|
827
|
+
const realTarget = getTarget();
|
|
828
|
+
return Reflect.ownKeys(realTarget);
|
|
829
|
+
},
|
|
830
|
+
getOwnPropertyDescriptor(target, prop) {
|
|
831
|
+
const realTarget = getTarget();
|
|
832
|
+
return Reflect.getOwnPropertyDescriptor(realTarget, prop);
|
|
824
833
|
}
|
|
825
834
|
});
|
|
826
835
|
};
|
|
@@ -1599,13 +1608,15 @@ var Keq = class extends Core {
|
|
|
1599
1608
|
this.requestInit.mode = mod;
|
|
1600
1609
|
return this;
|
|
1601
1610
|
}
|
|
1602
|
-
flowControl(mode,
|
|
1603
|
-
const
|
|
1611
|
+
flowControl(mode, arg2, arg3) {
|
|
1612
|
+
const concurrencyLimit = typeof arg2 === "number" ? arg2 : void 0;
|
|
1613
|
+
const sig = typeof arg2 === "function" || typeof arg2 === "string" ? arg2 : arg3 && (typeof arg3 === "function" || typeof arg3 === "string") ? arg3 : this.__locationId__;
|
|
1604
1614
|
if (!sig) {
|
|
1605
1615
|
throw new Exception("please set signal to .flowControl()");
|
|
1606
1616
|
}
|
|
1607
1617
|
const flowControl = {
|
|
1608
1618
|
mode,
|
|
1619
|
+
concurrencyLimit,
|
|
1609
1620
|
signal: sig
|
|
1610
1621
|
};
|
|
1611
1622
|
this.option("flowControl", flowControl);
|
|
@@ -1776,17 +1787,18 @@ function keqTimeoutMiddleware() {
|
|
|
1776
1787
|
var fastq = __toESM(require("fastq"));
|
|
1777
1788
|
function keqSerialFlowControlMiddleware() {
|
|
1778
1789
|
return async function serialFlowControlMiddleware(ctx, next) {
|
|
1779
|
-
if (!ctx.options.flowControl || ctx.options.flowControl.mode
|
|
1790
|
+
if (!ctx.options.flowControl || !["serial", "concurrent"].includes(ctx.options.flowControl.mode)) {
|
|
1780
1791
|
await next();
|
|
1781
1792
|
return;
|
|
1782
1793
|
}
|
|
1783
1794
|
const { signal } = ctx.options.flowControl;
|
|
1795
|
+
const concurrent = ctx.options.flowControl.mode === "serial" ? 1 : !ctx.options.flowControl.concurrencyLimit ? 1 : ctx.options.flowControl.concurrencyLimit < 1 ? 1 : parseInt(ctx.options.flowControl.concurrencyLimit, 10);
|
|
1784
1796
|
const key = typeof signal === "string" ? signal : signal(ctx);
|
|
1785
1797
|
if (!ctx.global.serialFlowControl) ctx.global.serialFlowControl = {};
|
|
1786
1798
|
if (!ctx.global.serialFlowControl[key]) {
|
|
1787
1799
|
ctx.global.serialFlowControl[key] = fastq.promise(async (next2) => {
|
|
1788
1800
|
await next2();
|
|
1789
|
-
},
|
|
1801
|
+
}, concurrent);
|
|
1790
1802
|
}
|
|
1791
1803
|
const queue = ctx.global.serialFlowControl[key];
|
|
1792
1804
|
await queue.push(next);
|
|
@@ -1954,6 +1966,7 @@ var KeqRequest = class {
|
|
|
1954
1966
|
context.emitter.on(event, listener);
|
|
1955
1967
|
await next();
|
|
1956
1968
|
};
|
|
1969
|
+
middleware.__keqMiddlewareName__ = "listen(".concat(event, ", ").concat(listener.name || "anonymous", ")");
|
|
1957
1970
|
this.use(middleware);
|
|
1958
1971
|
return this;
|
|
1959
1972
|
}
|