posipaki 0.46.0 → 0.47.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/dist/index.d.ts CHANGED
@@ -20,7 +20,7 @@ declare function defineActor<Args, InternalState, InMsg extends Message, OutMsg
20
20
  //#endregion
21
21
  //#region src/version.d.ts
22
22
  /** posipaki's release version. Must equal package.json's `version`. */
23
- declare const LIB_VERSION = "0.46.0";
23
+ declare const LIB_VERSION = "0.47.0";
24
24
  //#endregion
25
25
  export { type ActorConfig, type ActorContext, type ActorDecorated, type ActorDefinition, type ActorPlugin, type ActorReflection, type AnyProcess, AsyncProcess, type AsyncProcessFn, type ExitMessage, type HandlerFn, type HandlerOptions, type HookResult, LIB_VERSION, type Message, type MethodOptions, type PluginTransform, Process, type ProcessCtx, type ProcessFn, type SenderInfo, type SenderOrigin, type SpawnedFrom, type StopMessage, type WithSender, type WithoutSender, asyncify, callHook, chainHook, defineActor, defineMessages, mergeConfigs, propagateError, runDispatch, runDispatchAsync, spawn, spawnAsync, stopPropagation };
26
26
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { i as runDispatch } from "./util-Brtfgv68.js";
2
2
  import { a as spawnAsync, i as runDispatchAsync, o as asyncify, t as AsyncProcess } from "./process.async-B1FqZyD1.js";
3
3
  import { n as chainHook, o as propagateError, r as mergeConfigs, s as stopPropagation, t as callHook } from "./hooks-CgXhmY4r.js";
4
4
  import { n as defineMessages, t as defineActor } from "./define-actor-DR1P1PA5.js";
5
- import { t as LIB_VERSION } from "./version-DAQCfED6.js";
5
+ import { t as LIB_VERSION } from "./version-DRbb_jh2.js";
6
6
  //#region src/process.ts
7
7
  /** @deprecated Use {@link spawnAsync} instead. */
8
8
  function spawn(fn, pname, tp) {
@@ -146,14 +146,6 @@ function announcedOctets(frame) {
146
146
  function json1Channel(transport) {
147
147
  const frameReaders = /* @__PURE__ */ new Set();
148
148
  const segmentReaders = /* @__PURE__ */ new Set();
149
- const closeReaders = /* @__PURE__ */ new Set();
150
- /** The wire goes once, whoever ends it: the peer hanging up, or this side closing it. */
151
- let closed = false;
152
- const sayClosed = () => {
153
- if (closed) return;
154
- closed = true;
155
- for (const reader of [...closeReaders]) reader();
156
- };
157
149
  /** The head whose octets are on their way: set between the line and the run it announced. */
158
150
  let expecting = null;
159
151
  const deliver = (frame) => {
@@ -178,7 +170,6 @@ function json1Channel(transport) {
178
170
  }
179
171
  for (const reader of [...segmentReaders]) reader(frame, bytes);
180
172
  });
181
- transport.onClose(sayClosed);
182
173
  return {
183
174
  send(frame) {
184
175
  return transport.send(encode(frame));
@@ -200,11 +191,10 @@ function json1Channel(transport) {
200
191
  };
201
192
  },
202
193
  onClose(handler) {
203
- closeReaders.add(handler);
194
+ transport.onClose(handler);
204
195
  },
205
- async close() {
206
- sayClosed();
207
- await transport.close();
196
+ close() {
197
+ return transport.close();
208
198
  }
209
199
  };
210
200
  }
@@ -1177,13 +1167,14 @@ var LineTransport = class {
1177
1167
  this.pvtOnMessage = null;
1178
1168
  this.pvtOnBytes = null;
1179
1169
  this.pvtOnClose = null;
1170
+ this.pvtSaid = false;
1180
1171
  this.pvtClosed = false;
1181
1172
  this.pvtClosing = null;
1182
1173
  this.streams = streams;
1183
1174
  readParts(streams.read, (line) => this.pvtClosed ? void 0 : this.pvtOnMessage?.(line), (bytes) => {
1184
1175
  if (!this.pvtClosed) this.pvtOnBytes?.(bytes);
1185
1176
  }, () => {
1186
- this.pvtOnClose?.();
1177
+ this.pvtSayClosed();
1187
1178
  this.close();
1188
1179
  });
1189
1180
  streams.read.on("error", () => {
@@ -1242,6 +1233,12 @@ var LineTransport = class {
1242
1233
  this.pvtClosing ??= this.pvtClose();
1243
1234
  await this.pvtClosing;
1244
1235
  }
1236
+ /** Say the wire is over, once: the reader's end and a close here are one ending. */
1237
+ pvtSayClosed() {
1238
+ if (this.pvtSaid) return;
1239
+ this.pvtSaid = true;
1240
+ this.pvtOnClose?.();
1241
+ }
1245
1242
  async pvtClose() {
1246
1243
  await Promise.resolve();
1247
1244
  this.pvtClosed = true;
@@ -1251,6 +1248,7 @@ var LineTransport = class {
1251
1248
  try {
1252
1249
  if (!this.streams.write.writableEnded) this.streams.write.end();
1253
1250
  } catch {}
1251
+ this.pvtSayClosed();
1254
1252
  }
1255
1253
  };
1256
1254
  //#endregion
@@ -1263,6 +1261,7 @@ var FifoUtf8NlineTransport = class FifoUtf8NlineTransport {
1263
1261
  this.closed = false;
1264
1262
  this.closingPromise = null;
1265
1263
  this.pvtError = null;
1264
+ this.pvtSaid = false;
1266
1265
  this.readFd = opts.readFd ?? null;
1267
1266
  this.writeFd = opts.writeFd ?? null;
1268
1267
  if (this.readFd) {
@@ -1270,7 +1269,7 @@ var FifoUtf8NlineTransport = class FifoUtf8NlineTransport {
1270
1269
  this.reader = readParts(this.rs, (line) => this.closed ? void 0 : this.pvtOnMessage?.(line), (bytes) => {
1271
1270
  if (!this.closed) this.pvtOnBytes?.(bytes);
1272
1271
  }, () => {
1273
- this.pvtOnClose?.();
1272
+ this.pvtSayClosed();
1274
1273
  this.close();
1275
1274
  });
1276
1275
  this.rs.on("error", (err) => {
@@ -1378,6 +1377,12 @@ var FifoUtf8NlineTransport = class FifoUtf8NlineTransport {
1378
1377
  await this.closingPromise;
1379
1378
  this.closed = true;
1380
1379
  }
1380
+ /** Say the wire is over, once: the reader's end and a close here are one ending. */
1381
+ pvtSayClosed() {
1382
+ if (this.pvtSaid) return;
1383
+ this.pvtSaid = true;
1384
+ this.pvtOnClose?.();
1385
+ }
1381
1386
  async pvtClose() {
1382
1387
  await Promise.resolve();
1383
1388
  if (this.reader) {
@@ -1410,6 +1415,7 @@ var FifoUtf8NlineTransport = class FifoUtf8NlineTransport {
1410
1415
  } catch {}
1411
1416
  this.writeFd = null;
1412
1417
  }
1418
+ this.pvtSayClosed();
1413
1419
  }
1414
1420
  };
1415
1421
  //#endregion