@nice-code/action 0.24.0 → 0.25.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.
Files changed (36) hide show
  1. package/README.md +54 -6
  2. package/build/{AcceptorHandler-11-QMdx2.d.mts → AcceptorHandler-BizUtq4u.d.mts} +118 -15
  3. package/build/{AcceptorHandler-CxD0c1BE.d.cts → AcceptorHandler-CxPfZtIl.d.cts} +118 -15
  4. package/build/{ActionDevtoolsCore-37JP4bOG.d.cts → ActionDevtoolsCore-D9KBBI2V.d.cts} +2 -2
  5. package/build/{ActionDevtoolsCore-Cgq-go1R.d.mts → ActionDevtoolsCore-xZjAtB4H.d.mts} +2 -2
  6. package/build/advanced/index.cjs +1 -1
  7. package/build/advanced/index.d.cts +1 -96
  8. package/build/advanced/index.d.mts +1 -96
  9. package/build/advanced/index.mjs +1 -1
  10. package/build/{createHibernatableWsServerAdapter-C07RfUTH.mjs → createHibernatableWsServerAdapter-BkjESd01.mjs} +11 -9
  11. package/build/createHibernatableWsServerAdapter-BkjESd01.mjs.map +1 -0
  12. package/build/{createHibernatableWsServerAdapter-BNi4k9j3.cjs → createHibernatableWsServerAdapter-FSDWrxoF.cjs} +11 -9
  13. package/build/createHibernatableWsServerAdapter-FSDWrxoF.cjs.map +1 -0
  14. package/build/devtools/browser/index.d.cts +1 -1
  15. package/build/devtools/browser/index.d.mts +1 -1
  16. package/build/devtools/server/index.d.cts +1 -1
  17. package/build/devtools/server/index.d.mts +1 -1
  18. package/build/{httpAcceptorCarrier-C3S_bDkL.cjs → httpAcceptorCarrier-BQYaXI9j.cjs} +2 -2
  19. package/build/{httpAcceptorCarrier-C3S_bDkL.cjs.map → httpAcceptorCarrier-BQYaXI9j.cjs.map} +1 -1
  20. package/build/{httpAcceptorCarrier-DPBEuewS.mjs → httpAcceptorCarrier-DWqsCz3h.mjs} +2 -2
  21. package/build/{httpAcceptorCarrier-DPBEuewS.mjs.map → httpAcceptorCarrier-DWqsCz3h.mjs.map} +1 -1
  22. package/build/index.cjs +6 -2
  23. package/build/index.d.cts +2 -2
  24. package/build/index.d.mts +2 -2
  25. package/build/index.mjs +3 -3
  26. package/build/platform/cloudflare/index.cjs +45 -1
  27. package/build/platform/cloudflare/index.cjs.map +1 -1
  28. package/build/platform/cloudflare/index.d.cts +40 -2
  29. package/build/platform/cloudflare/index.d.mts +40 -2
  30. package/build/platform/cloudflare/index.mjs +45 -2
  31. package/build/platform/cloudflare/index.mjs.map +1 -1
  32. package/build/react-query/index.d.cts +1 -1
  33. package/build/react-query/index.d.mts +1 -1
  34. package/package.json +4 -4
  35. package/build/createHibernatableWsServerAdapter-BNi4k9j3.cjs.map +0 -1
  36. package/build/createHibernatableWsServerAdapter-C07RfUTH.mjs.map +0 -1
@@ -1405,11 +1405,13 @@ var ActionRuntime = class {
1405
1405
  * Used to locate the return-path channel for dispatching results back to the action origin.
1406
1406
  * Returns `undefined` if no handler matches (score > 0 required, i.e. at least id must match).
1407
1407
  *
1408
- * A handler that currently holds the origin's *live* connection always wins over a mere coordinate
1409
- * matchso with several duplex acceptors (e.g. WS + WebRTC) a result/push routes back over the carrier
1410
- * the client actually connected on, never a same-coordinate sibling that lacks the socket. Only when no
1411
- * handler owns a live connection do we fall back to the plain best-coordinate-score pick (the
1412
- * single-acceptor and connector-only cases, unchanged).
1408
+ * A handler that currently holds the origin's *live* connection always wins, regardless of its
1409
+ * coordinate score owning the live socket bound to the origin's exact coordinate (set from the
1410
+ * handshake) is a strictly more precise match than any env-level `peerClient` score. This lets one
1411
+ * server accept clients of *several* envs over a single acceptor (a multi-role Durable Object): the
1412
+ * result/push routes back over the carrier the client actually connected on even when the handler's
1413
+ * `clientEnv` is unset or names a different env. Only when no handler owns a live connection do we fall
1414
+ * back to the plain best-coordinate-score pick (the offline-return and connector-only cases).
1413
1415
  */
1414
1416
  getReturnHandlerForOrigin(originClient) {
1415
1417
  if (originClient.envId === "_unset_") return void 0;
@@ -1424,12 +1426,12 @@ var ActionRuntime = class {
1424
1426
  bestScore = score;
1425
1427
  bestHandler = handler;
1426
1428
  }
1427
- if (score > bestOwnedScore && handler.ownsLiveConnectionFor(originClient)) {
1429
+ if (handler.ownsLiveConnectionFor(originClient) && score > bestOwnedScore) {
1428
1430
  bestOwnedScore = score;
1429
1431
  bestOwnedHandler = handler;
1430
1432
  }
1431
1433
  }
1432
- if (bestOwnedHandler != null && bestOwnedScore > 0) return bestOwnedHandler;
1434
+ if (bestOwnedHandler != null) return bestOwnedHandler;
1433
1435
  return bestScore > 0 ? bestHandler : void 0;
1434
1436
  }
1435
1437
  resetRuntime() {
@@ -2172,7 +2174,7 @@ var AcceptorHandler = class extends PeerLinkHandler {
2172
2174
  _codecByConn = /* @__PURE__ */ new Map();
2173
2175
  _sessionByConn = /* @__PURE__ */ new Map();
2174
2176
  constructor(options) {
2175
- super(options.clientEnv);
2177
+ super(options.clientEnv ?? RuntimeCoordinate.unknown);
2176
2178
  this._formatMessage = options.formatMessage;
2177
2179
  this._createFormatMessage = options.createFormatMessage;
2178
2180
  this._send = options.send;
@@ -4076,4 +4078,4 @@ Object.defineProperty(exports, "runtimeLinkId", {
4076
4078
  }
4077
4079
  });
4078
4080
 
4079
- //# sourceMappingURL=createHibernatableWsServerAdapter-BNi4k9j3.cjs.map
4081
+ //# sourceMappingURL=createHibernatableWsServerAdapter-FSDWrxoF.cjs.map