milkio 1.3.74 → 1.4.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "milkio",
3
- "version": "1.3.74",
3
+ "version": "1.4.0",
4
4
  "type": "module",
5
5
  "exports": "./index.js",
6
6
  "types": "./index.d.ts",
package/world/index.d.ts CHANGED
@@ -22,6 +22,11 @@ export interface MilkioInit {
22
22
  onLoggerInserting?: LoggerInsertingHandler;
23
23
  /** called only for fault-level failures (unexpected/internal); never for fail (business rejections) */
24
24
  onError?: (report: MilkioFaultReport) => void;
25
+ /**
26
+ * 全局内存水位(字节)。运行时能读到可信的堆占用(Node 进程 / Node worker)时,
27
+ * 缓存在超过该水位后渐进逐出;不传则不检查水位。
28
+ */
29
+ memoryLimitBytes?: number;
25
30
  bootstraps?: Array<(world: any) => Promise<void> | void>;
26
31
  }
27
32
  export type MilkioRuntimeInit<T extends MilkioInit> = Mixin<T, {
@@ -57,4 +62,12 @@ export interface MilkioWorld<Generated extends GeneratedInit, MilkioOptions exte
57
62
  listener: Awaited<ReturnType<typeof __initListener>>;
58
63
  config: Readonly<Awaited<ReturnType<$types["configSchema"]["get"]>>>;
59
64
  isTestMode: boolean;
65
+ memory: {
66
+ /** 全局内存水位(字节);未配置为 undefined */
67
+ limitBytes: number | undefined;
68
+ /** 当前 isolate 的堆占用;运行时不可读时为 null */
69
+ usedBytes: () => number | null;
70
+ /** 是否超过水位;未配置或运行时不可读时恒为 false */
71
+ exceeded: () => boolean;
72
+ };
60
73
  }