posipaki 0.48.0 → 0.48.1

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.48.0";
23
+ declare const LIB_VERSION = "0.48.1";
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-BsegZXH2.js";
5
+ import { t as LIB_VERSION } from "./version-CjO8pCPA.js";
6
6
  //#region src/process.ts
7
7
  /** @deprecated Use {@link spawnAsync} instead. */
8
8
  function spawn(fn, pname, tp) {
@@ -1 +1 @@
1
- {"version":3,"file":"process-eCAv2tIS.d.ts","names":[],"sources":["../src/process.d.ts"],"mappings":";;;iBAKwB,MAAM,GAAG,GAAG,WAAW,UAAU,SAAS,WAAW,UAAU,aAAa,IAAI,UAAU,GAAG,GAAG,IAAI,KAAK,eAAe,MAAM,GAAG,IAAI,MAAM,uBAAuB,GAAG,MAAM,QAAQ,GAAG,GAAG,IAAI;;;cAGvM,QAAQ,GAAG,GAAG,WAAW,SAAS,WAAW,iBAAiB,aAAa,GAAG,GAAG,IAAI;EAC/F,YAAY,IAAI,UAAU,GAAG,GAAG,IAAI,KAAK,eAAe,MAAM,GAAG,IAAI,MAAM;EAC3E,MAAM,GAAG;EACT,QAAQ"}
1
+ {"version":3,"file":"process-eCAv2tIS.d.ts","names":[],"sources":["../src/process.ts"],"mappings":";;;iBAQgB,MAAM,GAAG,GAAG,WAAW,UAAU,SAAS,WAAW,UAAU,aAC7E,IAAI,UAAU,GAAG,GAAG,IAAI,KACxB,eACA,MAAM,GAAG,IAAI,MAAM,uBACjB,GAAG,MAAM,QAAQ,GAAG,GAAG,IAAI;;;cAMzB,QAAQ,GAAG,GAAG,WAAW,SAAS,WAAW,iBAAiB,aAAa,GAAG,GAAG,IAAI;EACzF,YAAY,IAAI,UAAU,GAAG,GAAG,IAAI,KAAK,eAAe,MAAM,GAAG,IAAI,MAAM;EAI3E,MAAM,GAAG;EAIT,QAAQ"}
@@ -99,9 +99,18 @@ function announcedOctets(frame) {
99
99
  function json1Channel(transport) {
100
100
  const frameReaders = /* @__PURE__ */ new Set();
101
101
  const segmentReaders = /* @__PURE__ */ new Set();
102
+ /** What arrived with nobody reading it. A connection is live from the moment it is made, and a
103
+ * first stage that relays it has nowhere to hand a frame until the payload it relays to exists. */
104
+ const heldFrames = [];
105
+ const heldSegments = [];
102
106
  /** The head whose octets are on their way: set between the line and the run it announced. */
103
107
  let expecting = null;
104
108
  const deliver = (frame) => {
109
+ if (frameReaders.size === 0) {
110
+ heldFrames.push(frame);
111
+ return;
112
+ }
113
+ heldFrames.length = 0;
105
114
  for (const reader of [...frameReaders]) reader(frame);
106
115
  };
107
116
  transport.onMessage((str) => {
@@ -121,6 +130,11 @@ function json1Channel(transport) {
121
130
  deliver(badFrame(`${bytes.length} octets arrived that no frame announced`, ""));
122
131
  return;
123
132
  }
133
+ if (segmentReaders.size === 0) {
134
+ heldSegments.push([frame, bytes]);
135
+ return;
136
+ }
137
+ heldSegments.length = 0;
124
138
  for (const reader of [...segmentReaders]) reader(frame, bytes);
125
139
  });
126
140
  return {
@@ -129,6 +143,7 @@ function json1Channel(transport) {
129
143
  },
130
144
  onMessage(handler) {
131
145
  frameReaders.add(handler);
146
+ for (const frame of heldFrames) handler(frame);
132
147
  return () => {
133
148
  frameReaders.delete(handler);
134
149
  };
@@ -139,6 +154,7 @@ function json1Channel(transport) {
139
154
  },
140
155
  onSegment(handler) {
141
156
  segmentReaders.add(handler);
157
+ for (const [frame, bytes] of heldSegments) handler(frame, bytes);
142
158
  return () => {
143
159
  segmentReaders.delete(handler);
144
160
  };
@@ -193,6 +209,9 @@ function channelThrough(base, onFrame) {
193
209
  if (base.onSegment) wrapped.onSegment = (handler) => base.onSegment?.(handler) ?? (() => {});
194
210
  return wrapped;
195
211
  }
212
+ function isProto(msg) {
213
+ return "$proto" in msg;
214
+ }
196
215
  const ERROR_KEY = "$error";
197
216
  /** The frame that says the wire is over: the reason, and the connection ends with it. */
198
217
  function errorFrame$1(reason) {
@@ -1595,7 +1614,7 @@ async function runGateway(argv = process.argv.slice(2)) {
1595
1614
  };
1596
1615
  let offered = false;
1597
1616
  fromClient.onMessage((frame) => {
1598
- if (!offered) {
1617
+ if (!offered && !isProto(frame)) {
1599
1618
  offered = true;
1600
1619
  offerOutput();
1601
1620
  }