@moq/net 0.4.0 → 0.4.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.
Files changed (121) hide show
  1. package/announced.d.ts +14 -0
  2. package/announced.d.ts.map +1 -1
  3. package/announced.js.map +1 -1
  4. package/broadcast.d.ts +6 -3
  5. package/broadcast.d.ts.map +1 -1
  6. package/broadcast.js +9 -5
  7. package/broadcast.js.map +1 -1
  8. package/connection/accept.js +9 -1
  9. package/connection/accept.js.map +1 -1
  10. package/connection/connect.d.ts.map +1 -1
  11. package/connection/connect.js +10 -1
  12. package/connection/connect.js.map +1 -1
  13. package/connection/established.d.ts +2 -1
  14. package/connection/established.d.ts.map +1 -1
  15. package/connection/established.js.map +1 -1
  16. package/connection/forward.js +9 -2
  17. package/connection/forward.js.map +1 -1
  18. package/connection/handshake.d.ts +1 -0
  19. package/connection/handshake.d.ts.map +1 -1
  20. package/connection/handshake.js +3 -0
  21. package/connection/handshake.js.map +1 -1
  22. package/connection/pool.d.ts +8 -10
  23. package/connection/pool.d.ts.map +1 -1
  24. package/connection/pool.js +18 -8
  25. package/connection/pool.js.map +1 -1
  26. package/connection/reload.js +6 -6
  27. package/connection/reload.js.map +1 -1
  28. package/error.d.ts.map +1 -1
  29. package/error.js +21 -0
  30. package/error.js.map +1 -1
  31. package/ietf/adapter.d.ts +5 -1
  32. package/ietf/adapter.d.ts.map +1 -1
  33. package/ietf/adapter.js +27 -9
  34. package/ietf/adapter.js.map +1 -1
  35. package/ietf/connection.d.ts +1 -1
  36. package/ietf/connection.d.ts.map +1 -1
  37. package/ietf/connection.js +9 -5
  38. package/ietf/connection.js.map +1 -1
  39. package/ietf/error.js +27 -2
  40. package/ietf/error.js.map +1 -1
  41. package/ietf/hidden.d.ts +2 -0
  42. package/ietf/hidden.d.ts.map +1 -0
  43. package/ietf/hidden.js +30 -0
  44. package/ietf/hidden.js.map +1 -0
  45. package/ietf/index.d.ts +1 -0
  46. package/ietf/index.d.ts.map +1 -1
  47. package/ietf/index.js +1 -0
  48. package/ietf/index.js.map +1 -1
  49. package/ietf/object.d.ts +8 -2
  50. package/ietf/object.d.ts.map +1 -1
  51. package/ietf/object.js +17 -3
  52. package/ietf/object.js.map +1 -1
  53. package/ietf/parameters.d.ts +5 -0
  54. package/ietf/parameters.d.ts.map +1 -1
  55. package/ietf/parameters.js +20 -0
  56. package/ietf/parameters.js.map +1 -1
  57. package/ietf/properties.d.ts +1 -0
  58. package/ietf/properties.d.ts.map +1 -1
  59. package/ietf/properties.js +14 -0
  60. package/ietf/properties.js.map +1 -1
  61. package/ietf/publish.d.ts +19 -2
  62. package/ietf/publish.d.ts.map +1 -1
  63. package/ietf/publish.js +40 -6
  64. package/ietf/publish.js.map +1 -1
  65. package/ietf/publisher.js +114 -60
  66. package/ietf/publisher.js.map +1 -1
  67. package/ietf/subscribe.d.ts.map +1 -1
  68. package/ietf/subscribe.js +3 -4
  69. package/ietf/subscribe.js.map +1 -1
  70. package/ietf/subscribe_namespace.d.ts +8 -2
  71. package/ietf/subscribe_namespace.d.ts.map +1 -1
  72. package/ietf/subscribe_namespace.js +18 -8
  73. package/ietf/subscribe_namespace.js.map +1 -1
  74. package/ietf/subscriber.js +189 -66
  75. package/ietf/subscriber.js.map +1 -1
  76. package/internal.d.ts +7 -0
  77. package/internal.d.ts.map +1 -1
  78. package/internal.js +11 -0
  79. package/internal.js.map +1 -1
  80. package/lite/announce.d.ts +46 -2
  81. package/lite/announce.d.ts.map +1 -1
  82. package/lite/announce.js +126 -11
  83. package/lite/announce.js.map +1 -1
  84. package/lite/connection.d.ts +1 -1
  85. package/lite/connection.d.ts.map +1 -1
  86. package/lite/connection.js +9 -3
  87. package/lite/connection.js.map +1 -1
  88. package/lite/publisher.js +168 -109
  89. package/lite/publisher.js.map +1 -1
  90. package/lite/subscribe.d.ts +10 -4
  91. package/lite/subscribe.d.ts.map +1 -1
  92. package/lite/subscribe.js +20 -10
  93. package/lite/subscribe.js.map +1 -1
  94. package/lite/subscriber.d.ts +10 -2
  95. package/lite/subscriber.d.ts.map +1 -1
  96. package/lite/subscriber.js +159 -93
  97. package/lite/subscriber.js.map +1 -1
  98. package/lite/version.d.ts +11 -0
  99. package/lite/version.d.ts.map +1 -1
  100. package/lite/version.js +56 -0
  101. package/lite/version.js.map +1 -1
  102. package/origin.d.ts +37 -18
  103. package/origin.d.ts.map +1 -1
  104. package/origin.js +248 -103
  105. package/origin.js.map +1 -1
  106. package/package.json +7 -3
  107. package/stream.d.ts +2 -2
  108. package/stream.d.ts.map +1 -1
  109. package/stream.js +16 -11
  110. package/stream.js.map +1 -1
  111. package/tail.d.ts +11 -0
  112. package/tail.d.ts.map +1 -0
  113. package/tail.js +121 -0
  114. package/tail.js.map +1 -0
  115. package/track.d.ts +33 -5
  116. package/track.d.ts.map +1 -1
  117. package/track.js +98 -30
  118. package/track.js.map +1 -1
  119. package/wire.d.ts +2 -0
  120. package/wire.d.ts.map +1 -1
  121. package/wire.js.map +1 -1
package/origin.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"origin.js","sourceRoot":"","sources":["../src/origin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,OAAO,EAA8C,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACzG,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAmB,YAAY,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGlE,OAAO,EAAE,WAAW,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CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;QACC,WAAW,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC1D,aAAa,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE;YAChC,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;YACrB,KAAK,GAAG,CAAC;QACV,CAAC,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,MAA+C;QACrD,IAAI,IAAI,CAAC,KAAK;YAAE,OAAO;QACvB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,MAAM,KAAK,GAAG,MAAM,YAAY,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;QAC/E,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAClC,CAAC;IAED,yEAAyE;IACzE,MAAM,CAAC,GAAU;QAChB,IAAI,IAAI,CAAC,KAAK;YAAE,OAAO;QACvB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAChC,CAAC;CACD","sourcesContent":["/**\n * A broadcast routing table, independent of any connection.\n *\n * Publish broadcasts into an origin and hand the origin to one or more connections to\n * serve them; the broadcasts outlive any single session. Hand the same (or another)\n * origin to a connection's `consume` option and the peer's announced routes appear\n * in the table too: each route covers a path prefix, and a request for a path under\n * it resolves through the session that announced it. Mirrors the `origin` module in\n * `rs/moq-net`.\n *\n * @module\n */\nimport { Derived, type Dispose, type GetPromise, type Getter, getter, Once, Signal } from \"@moq/signals\";\nimport * as announce from \"./announced.ts\";\nimport * as broadcast from \"./broadcast.ts\";\nimport { StreamCode, StreamError } from \"./error.ts\";\nimport { Route, routesEqual } from \"./hop.ts\";\nimport { hooks, scopeCaptures, scopeOverlaps } from \"./internal.ts\";\nimport * as Path from \"./path.ts\";\nimport { type Advertised, registerWire, wireOf } from \"./wire.ts\";\n\nexport type { Cost, Hop, Route } from \"./hop.ts\";\nexport { isAnonymous } from \"./hop.ts\";\n\n/**\n * One requested path: the notify node for everything watching it.\n *\n * `route` is the only reactive part, and the only thing a {@link Request} subscribes to, so\n * a publish or retraction anywhere else in the table cannot wake it. The origin's tables stay\n * the storage; this is a per-path view onto them, refreshed by whichever mutator touched the\n * path. The alternative, deriving each request over the whole `local`/`remote` maps, wakes\n * every open request on every unrelated change.\n *\n * `answer` outlives a session: the answering session clears it when it dies and the next one\n * answers again, which is what makes a request span reconnects.\n *\n * `refused` holds the route entries whose handler rejected the path. A refusal is\n * authoritative: the entry is never asked again while it stands (a reconnect is a fresh\n * entry), and the path resolves through the next-best route or to nothing. Without it a\n * rejection would refresh the path straight back onto the same queue, and a handler that\n * keeps saying no would be asked forever.\n *\n * @internal\n */\nexport interface RequestSlot {\n\tcount: number;\n\tblind: number;\n\tanswer?: broadcast.Consumer;\n\treadonly refused: Set<RouteEntry>;\n\treadonly route: Signal<broadcast.Consumer | undefined>;\n}\n\n/**\n * One advertised prefix: hops and cost, plus an optional server that answers\n * requests beneath it.\n *\n * Newest entry per prefix is the one requests resolve through. An originated\n * entry is forwarded by sessions; a received one is not, so a shared origin\n * cannot echo a peer's announcements back to it.\n *\n * @internal\n */\nexport interface RouteEntry {\n\treadonly identity: object;\n\treadonly route: Signal<Route>;\n\treadonly originated: boolean;\n\treadonly server?: ServeState;\n}\n\nfunction noCapacity(): StreamError {\n\treturn new StreamError(StreamCode.NoCapacity, { message: \"no capacity\" });\n}\n\n/** A served route from {@link Producer.dynamic}: the queue a handler drains. */\nclass ServeState {\n\tqueue = new Signal<Request[]>([]);\n\tpending = new Map<Path.Valid, Request>();\n\tserved = new Map<Path.Valid, broadcast.Consumer>();\n\trejected = new Map<Path.Valid, Error>();\n\t// demand() is the only reader of `rejected`. A Consumer.request refusal never\n\t// re-enqueues, so storing the error without a waiter would pin every unique\n\t// path until the route dies.\n\tdemanding = new Map<Path.Valid, number>();\n\tclosed = new Once<Error | null>();\n\tsettled = new Signal(0);\n\tonChange: (path: Path.Valid) => void = () => {};\n\tonReject: (path: Path.Valid) => void = () => {};\n\n\tenqueue(path: Path.Valid): void {\n\t\tif (this.closed.peek() !== undefined) return;\n\t\tthis.rejected.delete(path);\n\t\tif (this.pending.has(path)) return;\n\t\tconst live = this.served.get(path);\n\t\tif (live && live.closed.peek() === undefined) return;\n\t\tconst request = makeRequest(path, this);\n\t\tthis.pending.set(path, request);\n\t\tthis.queue.mutate((queue) => {\n\t\t\tqueue.push(request);\n\t\t});\n\t}\n\n\taccept(request: Request, front: broadcast.Consumer): void {\n\t\tif (this.closed.peek() !== undefined || this.pending.get(request.path) !== request) {\n\t\t\tfront.close();\n\t\t\treturn;\n\t\t}\n\t\tthis.pending.delete(request.path);\n\t\tconst existing = this.served.get(request.path);\n\t\tif (existing && existing.closed.peek() === undefined) {\n\t\t\tfront.close();\n\t\t\tthis.onChange(request.path);\n\t\t\tthis.settled.update((n) => n + 1);\n\t\t\treturn;\n\t\t}\n\t\tthis.served.set(request.path, front);\n\t\tvoid front.closed.then(() => {\n\t\t\tif (this.served.get(request.path) !== front) return;\n\t\t\tthis.served.delete(request.path);\n\t\t\tthis.onChange(request.path);\n\t\t});\n\t\tthis.onChange(request.path);\n\t\tthis.settled.update((n) => n + 1);\n\t}\n\n\treject(request: Request, err: Error): void {\n\t\tif (this.pending.get(request.path) !== request) return;\n\t\tthis.pending.delete(request.path);\n\t\tif (this.demanding.has(request.path)) this.rejected.set(request.path, err);\n\t\tthis.onReject(request.path);\n\t\tthis.settled.update((n) => n + 1);\n\t}\n\n\tclose(abort?: Error): void {\n\t\tif (this.closed.peek() !== undefined) return;\n\t\tconst err = abort ?? noCapacity();\n\t\tthis.closed.set(err);\n\t\tconst queued = [...this.pending.values()];\n\t\tthis.pending.clear();\n\t\tthis.queue.mutate((queue) => {\n\t\t\tqueue.length = 0;\n\t\t});\n\t\tfor (const request of queued) {\n\t\t\tfinishRequest(request, err);\n\t\t}\n\t\tfor (const [path, front] of this.served) {\n\t\t\tfront.close(abort);\n\t\t\tthis.onChange(path);\n\t\t}\n\t\tthis.served.clear();\n\t\tthis.rejected.clear();\n\t\tthis.demanding.clear();\n\t\tthis.settled.update((n) => n + 1);\n\t}\n}\n\ninterface Presented extends Advertised {\n\treadonly captures: Path.Pattern[] | undefined;\n}\n\n/** Reactive backing state shared by origin producers and consumers. */\nclass OriginState {\n\t// Both tables decouple the application producing into the origin from the\n\t// connections serving or feeding it. Undefined once the origin closes, so late\n\t// writes fail loudly.\n\t//\n\t// Local is what this endpoint creates, keyed by exact path: reachable for\n\t// subscribes whether or not it is advertised. Routes is the advertisement table:\n\t// prefixes a dynamic handle or a received session covers, newest first. They stay\n\t// separate so a session can never announce a received entry back to a peer, which\n\t// is what makes an origin shared by both directions echo-free.\n\tlocal = new Signal<Map<Path.Valid, broadcast.Consumer> | undefined>(new Map());\n\tadvertisedLocal = new Signal<Map<Path.Valid, Route> | undefined>(new Map());\n\troutes = new Signal<Map<Path.Valid, RouteEntry[]> | undefined>(new Map());\n\n\t// Originated advertisements sessions should forward: exact-path announces plus\n\t// originated dynamics. Identity is the local front or the route entry, so a\n\t// republish diffs as retract-then-announce and a re-price as another active.\n\toriginated = new Signal<Map<Path.Valid, Advertised> | undefined>(new Map());\n\n\t// Broadcasts materialized from a served route, keyed by exact path. Shared by every\n\t// request for the path so repeats reuse one accept; dropped (and closed) when the\n\t// providing route goes away or the last request releases it.\n\tmaterialized = new Map<Path.Valid, { entry: RouteEntry; front: broadcast.Consumer }>();\n\n\t// Paths consumers asked for without waiting for an announcement; attached sessions\n\t// answer them with blind subscriptions. Never announced: an answered request is assumed\n\t// present, not known live, so it must not read as an availability claim.\n\trequests = new Signal<Map<Path.Valid, RequestSlot> | undefined>(new Map());\n\n\t// How many sessions are attached, and how many of those support broadcast discovery.\n\t// What backs the public `discovery` getter.\n\tsessions = new Signal({ total: 0, discovery: 0 });\n\n\t// How many things are prepared to answer a request: attached sessions, plus reconnecting\n\t// connections that have no session right now but will. Zero means an unrouted path is\n\t// unroutable rather than merely unanswered, which is the whole difference between \"wait,\n\t// this is coming\" and \"nothing here can ever serve you\".\n\tanswerers = new Signal(0);\n\n\tclosed = new Once<Error | null>();\n\n\t/**\n\t * Recompute what `path` resolves to, waking only the requests watching that path.\n\t *\n\t * A no-op for a path nobody requested, so the common case (publishing into a table\n\t * nobody is asking about) costs a map lookup. Call after any write that could change\n\t * the answer for a single path.\n\t */\n\trefresh(path: Path.Valid): void {\n\t\tconst slot = this.requests.peek()?.get(path);\n\t\tif (!slot) return;\n\t\tslot.route.set(this.route(path, slot));\n\t}\n\n\t/** Record that `entry` refused `path` and re-route the requests watching it. */\n\trefuse(path: Path.Valid, entry: RouteEntry): void {\n\t\tconst slot = this.requests.peek()?.get(path);\n\t\tif (!slot) return;\n\t\tslot.refused.add(entry);\n\t\tslot.route.set(this.route(path, slot));\n\t}\n\n\t/**\n\t * Recompute every open request covered by `prefix`, after a route was inserted or\n\t * removed there: a route covers many paths, so a single-path refresh is not enough.\n\t * Materialized broadcasts whose provider changed are released here too, so a\n\t * retracted route's session subscription closes even when nothing reads it again.\n\t */\n\trefreshPrefix(prefix: Path.Valid): void {\n\t\tconst requests = this.requests.peek();\n\t\tfor (const [path, cached] of [...this.materialized]) {\n\t\t\tif (!Path.hasPrefix(prefix, path)) continue;\n\t\t\tif (cached.entry !== this.bestEntry(path, requests?.get(path)?.refused)) {\n\t\t\t\tthis.materialized.delete(path);\n\t\t\t\tcached.front.close();\n\t\t\t}\n\t\t}\n\t\tfor (const [path, slot] of requests ?? []) {\n\t\t\tif (Path.hasPrefix(prefix, path)) slot.route.set(this.route(path, slot));\n\t\t}\n\t}\n\n\t/** Rebuild the publisher-facing originated table after an advertisement write. */\n\trebuildOriginated(): void {\n\t\tconst local = this.local.peek();\n\t\tconst advertised = this.advertisedLocal.peek();\n\t\tconst routes = this.routes.peek();\n\t\tif (!local && !advertised && !routes) {\n\t\t\tthis.originated.set(undefined);\n\t\t\treturn;\n\t\t}\n\t\tconst next = new Map<Path.Valid, Advertised>();\n\t\tfor (const [path, route] of advertised ?? []) {\n\t\t\tconst front = local?.get(path);\n\t\t\tif (front) next.set(path, { identity: front, route });\n\t\t}\n\t\tfor (const [prefix, entries] of routes ?? []) {\n\t\t\tconst mine = entries.find((entry) => entry.originated);\n\t\t\tif (mine) next.set(prefix, { identity: mine.identity, route: mine.route.peek() });\n\t\t}\n\t\tthis.originated.set(next);\n\t}\n\n\t/**\n\t * Release the materialized broadcast for `path`, once its last request is gone: the\n\t * cache exists to share one session subscription between requests, not to outlive\n\t * them.\n\t */\n\treleaseMaterialized(path: Path.Valid): void {\n\t\tconst cached = this.materialized.get(path);\n\t\tif (!cached) return;\n\t\tthis.materialized.delete(path);\n\t\tcached.front.close();\n\t}\n\n\t/** The newest entry on the most specific route covering `path`, skipping `refused`, if any. */\n\tbestEntry(path: Path.Valid, refused?: ReadonlySet<RouteEntry>): RouteEntry | undefined {\n\t\tlet bestPrefix: Path.Valid | undefined;\n\t\tlet best: RouteEntry | undefined;\n\t\tfor (const [prefix, entries] of this.routes.peek() ?? []) {\n\t\t\tconst entry = entries.find((candidate) => !refused?.has(candidate));\n\t\t\tif (!entry) continue;\n\t\t\tif (!Path.hasPrefix(prefix, path)) continue;\n\t\t\tif (bestPrefix === undefined || prefix.length > bestPrefix.length) {\n\t\t\t\tbestPrefix = prefix;\n\t\t\t\tbest = entry;\n\t\t\t}\n\t\t}\n\t\treturn best;\n\t}\n\n\t/**\n\t * What `path` resolves to: a local publish, a broadcast materialized from the best\n\t * covering route, or the blind answer.\n\t *\n\t * Materialization is lazy and cached per path: the first request under a route opens\n\t * the providing session's subscription, repeats share it, and a provider change (the\n\t * route retracting, a better session taking over) swaps it out.\n\t */\n\troute(path: Path.Valid, slot: Pick<RequestSlot, \"answer\" | \"refused\">): broadcast.Consumer | undefined {\n\t\tconst local = this.local.peek()?.get(path);\n\t\tif (local) return local;\n\n\t\tconst entry = this.bestEntry(path, slot.refused);\n\t\tconst cached = this.materialized.get(path);\n\t\tif (cached && cached.entry === entry) {\n\t\t\tif (cached.front.closed.peek() === undefined) return cached.front;\n\t\t\tthis.materialized.delete(path);\n\t\t} else if (cached) {\n\t\t\tthis.materialized.delete(path);\n\t\t\tcached.front.close();\n\t\t}\n\t\tif (!entry?.server) return slot.answer;\n\n\t\tconst served = entry.server.served.get(path);\n\t\tif (served && served.closed.peek() === undefined) {\n\t\t\tthis.materialized.set(path, { entry, front: served });\n\t\t\treturn served;\n\t\t}\n\n\t\tentry.server.enqueue(path);\n\t\treturn undefined;\n\t}\n}\n\n/**\n * A non-owning handle on an origin: publish into it and read it, without its lifecycle.\n *\n * What a shared connection lends out. {@link Producer} implements it, so code that is\n * handed an origin rather than owning one should accept this type: closing the origin\n * stays the owner's alone, and a borrower cannot express it.\n *\n * @public\n */\nexport interface Table {\n\t/** Settles once the origin closes; see {@link Producer.closed}. */\n\treadonly closed: GetPromise<Error | null>;\n\n\t/** Whether every attached session announces into the table; see {@link Consumer.discovery}. */\n\treadonly discovery: Getter<boolean | undefined>;\n\n\t/** Create a locally announced broadcast at `path`; see {@link Producer.createBroadcast}. */\n\tcreateBroadcast(path: Path.Valid): broadcast.Producer;\n\n\t/** Resolve `path`, optionally waiting for an announcement; see {@link Consumer.request}. */\n\trequest(path: Path.Valid, options?: RequestOptions): Requesting;\n\n\t/** The available broadcasts under `scope`, as a live stream; see {@link Consumer.announced}. */\n\tannounced(scope?: Path.Pattern): announce.Consumer;\n}\n\n/** Options for resolving a broadcast path. */\nexport interface RequestOptions {\n\t/** Wait for a routed announcement when discovery is supported; otherwise subscribe blindly. */\n\tannounced?: boolean;\n}\n\n/**\n * The write side of an origin: create broadcasts by path and advertise them.\n *\n * Independent of any connection. A connection given this origin (via its `publish` option)\n * announces and serves the table's originated advertisements for as long as the session\n * lasts; the broadcasts themselves live until their producer closes or {@link close} tears\n * the origin down. A reconnecting session re-announces the table on each attach, so\n * advertisements made while offline surface on the next connection.\n *\n * Create, attach {@link dynamic} for tracks served on demand, populate, then\n * {@link broadcast.Producer.announce}: an exact-path subscribe before the tracks exist is\n * refused, and announcing advertises the path to peers.\n *\n * @public\n */\nexport class Producer implements Table {\n\t#state = new OriginState();\n\n\t// The reader backing the passthroughs, so holding a Producer never requires the\n\t// consume().x() stutter for everyday reads. One instance, so `discovery` keeps its\n\t// identity across reads.\n\t#reader = makeConsumer(this.#state);\n\n\tconstructor() {\n\t\tconst thisProducer = this;\n\t\tregisterWire(this, {\n\t\t\treceive: (prefix, route) => this.#receive(prefix, route),\n\t\t\tattach: (discovery) => this.#attach(discovery),\n\t\t\texpect: () => this.#expect(),\n\t\t\tget requests() {\n\t\t\t\treturn thisProducer.#state.requests;\n\t\t\t},\n\t\t\tchanged: () => this.#changed(),\n\t\t\tanswer: (path, front) => this.#answer(path, front),\n\t\t\troutes: (path) => wireOf(this.#reader).routes(path),\n\t\t});\n\t}\n\n\t/**\n\t * Settles once the origin closes: `null` on a clean close, or the abort {@link Error}.\n\t * Peek it synchronously (`undefined` while open), observe it reactively, or `await` it.\n\t */\n\tget closed(): GetPromise<Error | null> {\n\t\treturn this.#state.closed;\n\t}\n\n\t/**\n\t * Create a broadcast at `path`, returning its producer.\n\t *\n\t * The broadcast appears on this origin's local announce streams immediately.\n\t * Call {@link broadcast.Producer.announce} to advertise it to peers once its\n\t * tracks exist. Local consumers can discover and request it without that call.\n\t *\n\t * Close the producer to drop it. Creating a path again supersedes the previous\n\t * broadcast: the origin drops its handle on the old one, which closes it unless the\n\t * application still holds a consumer clone. A local broadcast also shadows any\n\t * remote broadcast at the same path.\n\t */\n\tcreateBroadcast(path: Path.Valid): broadcast.Producer {\n\t\tconst producer = new broadcast.Producer();\n\t\tconst front = producer.consume();\n\n\t\thooks.attachAnnouncer(producer, {\n\t\t\tannounce: (route) => this.#advertiseExact(path, front, route),\n\t\t\tunannounce: () => this.#retractExact(path, front),\n\t\t});\n\n\t\tthis.#state.local.mutate((broadcasts) => {\n\t\t\tif (!broadcasts) throw new Error(\"origin is closed\");\n\t\t\tbroadcasts.get(path)?.close();\n\t\t\tbroadcasts.set(path, front);\n\t\t});\n\t\tthis.#state.advertisedLocal.mutate((advertised) => {\n\t\t\tadvertised?.delete(path);\n\t\t});\n\t\tthis.#state.rebuildOriginated();\n\t\tthis.#state.refresh(path);\n\n\t\t// Drop it when the broadcast closes, unless a recreate already replaced it: a\n\t\t// stale broadcast closing must not unpublish the live one.\n\t\tvoid front.closed.then(() => {\n\t\t\tthis.#retractExact(path, front);\n\t\t\tthis.#state.local.mutate((broadcasts) => {\n\t\t\t\tif (broadcasts?.get(path) === front) broadcasts.delete(path);\n\t\t\t});\n\t\t\tthis.#state.refresh(path);\n\t\t});\n\n\t\treturn producer;\n\t}\n\n\t#advertiseExact(path: Path.Valid, front: broadcast.Consumer, route: Route): void {\n\t\tthis.#state.advertisedLocal.mutate((advertised) => {\n\t\t\tif (!advertised) throw new Error(\"origin is closed\");\n\t\t\tif (this.#state.local.peek()?.get(path) !== front) throw new Error(\"broadcast is closed\");\n\t\t\tadvertised.set(path, route);\n\t\t});\n\t\tthis.#state.rebuildOriginated();\n\t\tthis.#state.refresh(path);\n\t}\n\n\t#retractExact(path: Path.Valid, front: broadcast.Consumer): void {\n\t\tthis.#state.advertisedLocal.mutate((advertised) => {\n\t\t\tif (this.#state.local.peek()?.get(path) !== front) return;\n\t\t\tadvertised?.delete(path);\n\t\t});\n\t\tthis.#state.rebuildOriginated();\n\t\tthis.#state.refresh(path);\n\t}\n\n\t/**\n\t * Advertise `prefix` and serve the requests beneath it.\n\t *\n\t * A route is always a prefix: it claims `prefix` and every path beneath it (the\n\t * empty prefix claims every path). A service that only serves some of them\n\t * advertises the covering prefix and rejects the rest as they are requested;\n\t * consumers narrow with a {@link Path.Pattern} locally. The advertisement is\n\t * visible to {@link Consumer.announced} and forwarded by sessions for as long as\n\t * the returned {@link Dynamic} lives. A consumer resolving a path under it that\n\t * no local broadcast covers is handed to the handle as a {@link Request}.\n\t */\n\tdynamic(\n\t\tprefix: Path.Valid,\n\t\troute: Route | { hops?: Route[\"hops\"]; cost?: Route[\"cost\"] | bigint } = Route.default,\n\t): Dynamic {\n\t\treturn this.#insertRoute(prefix, Route.normalize(route), true);\n\t}\n\n\t/**\n\t * Land a route a peer announced, served through the returned handle. Same as\n\t * {@link dynamic} but not originated, so a session never announces it back.\n\t *\n\t * @internal\n\t */\n\t#receive(\n\t\tprefix: Path.Valid,\n\t\troute: Route | { hops?: Route[\"hops\"]; cost?: Route[\"cost\"] | bigint } = Route.default,\n\t): Dynamic {\n\t\treturn this.#insertRoute(prefix, Route.normalize(route), false);\n\t}\n\n\t#insertRoute(prefix: Path.Valid, route: Route, originated: boolean): Dynamic {\n\t\tconst server = new ServeState();\n\t\tserver.onChange = (path) => this.#state.refresh(path);\n\t\tconst entry: RouteEntry = {\n\t\t\tidentity: {},\n\t\t\troute: new Signal(route),\n\t\t\toriginated,\n\t\t\tserver,\n\t\t};\n\t\tserver.onReject = (path) => this.#state.refuse(path, entry);\n\n\t\tlet closed = false;\n\t\tthis.#state.routes.mutate((routes) => {\n\t\t\tif (!routes) {\n\t\t\t\tclosed = true;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst entries = routes.get(prefix);\n\t\t\tif (entries) entries.unshift(entry);\n\t\t\telse routes.set(prefix, [entry]);\n\t\t});\n\t\tif (closed) {\n\t\t\tserver.close();\n\t\t\treturn makeDynamic(prefix, entry, this.#state, () => {});\n\t\t}\n\t\tthis.#state.rebuildOriginated();\n\t\tthis.#state.refreshPrefix(prefix);\n\n\t\tconst retract = () => {\n\t\t\tthis.#state.routes.mutate((routes) => {\n\t\t\t\tconst entries = routes?.get(prefix);\n\t\t\t\tif (!entries) return;\n\t\t\t\tconst index = entries.indexOf(entry);\n\t\t\t\tif (index < 0) return;\n\t\t\t\tentries.splice(index, 1);\n\t\t\t\tif (entries.length === 0) routes?.delete(prefix);\n\t\t\t});\n\t\t\t// A retracted entry can never be picked again, so the refusals pinned to it are dead weight.\n\t\t\tfor (const slot of this.#state.requests.peek()?.values() ?? []) slot.refused.delete(entry);\n\t\t\tserver.close();\n\t\t\tthis.#state.rebuildOriginated();\n\t\t\tthis.#state.refreshPrefix(prefix);\n\t\t};\n\n\t\treturn makeDynamic(prefix, entry, this.#state, retract);\n\t}\n\n\t/**\n\t * Register an attached session, counting it toward the `discovery` state. Returns the\n\t * detach; call it exactly once when the session dies.\n\t *\n\t * @internal\n\t */\n\t#attach(discovery: boolean): Dispose {\n\t\tthis.#sessions(1, discovery);\n\t\tconst release = this.#expect();\n\t\tlet detached = false;\n\t\treturn () => {\n\t\t\tif (detached) return;\n\t\t\tdetached = true;\n\t\t\tthis.#sessions(-1, discovery);\n\t\t\trelease();\n\t\t};\n\t}\n\n\t#sessions(delta: number, discovery: boolean): void {\n\t\tthis.#state.sessions.update(({ total, discovery: d }) => ({\n\t\t\ttotal: total + delta,\n\t\t\tdiscovery: d + (discovery ? delta : 0),\n\t\t}));\n\t}\n\n\t/**\n\t * Declare that something will answer requests on this origin, even with no session\n\t * attached right now.\n\t *\n\t * A reconnecting connection holds one for its whole life, so a request made during a\n\t * reconnect (or before the first session establishes) stays pending instead of reading as\n\t * unroutable. Without it, {@link Request.unroutable} would fire on every page load, in the\n\t * window between wiring the origin up and the handshake completing. Call the returned\n\t * dispose when the connection is done for good.\n\t *\n\t * @internal\n\t */\n\t#expect(): Dispose {\n\t\tthis.#state.answerers.update((count) => count + 1);\n\t\tlet released = false;\n\t\treturn () => {\n\t\t\tif (released) return;\n\t\t\treleased = true;\n\t\t\t// Clamped because closing the origin zeroes the count, and the sessions attached at\n\t\t\t// the time still release afterwards.\n\t\t\tthis.#state.answerers.update((count) => Math.max(0, count - 1));\n\t\t};\n\t}\n\n\t/**\n\t * Resolves once anything a serving session scans changes: the open requests, or either\n\t * side of the routing table.\n\t *\n\t * @internal\n\t */\n\t#changed(): Promise<unknown> {\n\t\treturn Signal.race(this.#state.requests, this.#state.local, this.#state.routes, this.#state.advertisedLocal);\n\t}\n\n\t/**\n\t * Provide `front` as the answer for the open request on `path`, taking ownership of it.\n\t *\n\t * Returns undefined (releasing the front) when the request is gone or already answered;\n\t * first session in wins, and a loser must stay eligible to answer later. The returned\n\t * withdraw releases the front and, if it was the standing answer, vacates the slot and\n\t * wakes the other serving loops so a standby session answers immediately; call it when\n\t * the session dies.\n\t *\n\t * @internal\n\t */\n\t#answer(path: Path.Valid, front: broadcast.Consumer): Dispose | undefined {\n\t\tconst slot = this.#state.requests.peek()?.get(path);\n\t\tif (!slot || slot.answer !== undefined) {\n\t\t\tfront.close();\n\t\t\treturn undefined;\n\t\t}\n\t\tslot.answer = front;\n\t\tthis.#state.refresh(path);\n\n\t\treturn () => {\n\t\t\tif (slot.answer === front) {\n\t\t\t\tslot.answer = undefined;\n\t\t\t\tthis.#state.refresh(path);\n\t\t\t\t// The route signal only reaches this path's requesters; poke the map so every\n\t\t\t\t// serving loop re-scans and one of them re-answers.\n\t\t\t\tthis.#state.requests.mutate(() => {});\n\t\t\t}\n\t\t\tfront.close();\n\t\t};\n\t}\n\n\t/** A read handle for this origin, the side a connection's `publish` option borrows. */\n\tconsume(): Consumer {\n\t\treturn makeConsumer(this.#state);\n\t}\n\n\t/** Whether every attached session announces into the table; see {@link Consumer.discovery}. */\n\tget discovery(): Getter<boolean | undefined> {\n\t\treturn this.#reader.discovery;\n\t}\n\n\t/** Resolve `path`, optionally waiting for an announcement; see {@link Consumer.request}. */\n\trequest(path: Path.Valid, options?: RequestOptions): Requesting {\n\t\treturn this.#reader.request(path, options);\n\t}\n\n\t/** The available broadcasts under `scope`, as a live stream; see {@link Consumer.announced}. */\n\tannounced(scope?: Path.Pattern): announce.Consumer {\n\t\treturn this.#reader.announced(scope);\n\t}\n\n\t/** Close the origin, every broadcast it still routes, and its announcement streams. Idempotent. */\n\tclose(abort?: Error) {\n\t\tif (this.#state.closed.peek() !== undefined) return;\n\t\tthis.#state.closed.set(abort ?? null);\n\t\tthis.#state.local.update((broadcasts) => {\n\t\t\tfor (const front of broadcasts?.values() ?? []) {\n\t\t\t\tfront.close(abort);\n\t\t\t}\n\t\t\treturn undefined;\n\t\t});\n\t\tthis.#state.advertisedLocal.update(() => undefined);\n\t\tthis.#state.routes.update((routes) => {\n\t\t\tfor (const entries of routes?.values() ?? []) {\n\t\t\t\tfor (const entry of entries) entry.server?.close(abort);\n\t\t\t}\n\t\t\treturn undefined;\n\t\t});\n\t\tthis.#state.originated.update(() => undefined);\n\t\t// Materialized broadcasts are handles we opened; release them.\n\t\tfor (const cached of this.#state.materialized.values()) {\n\t\t\tcached.front.close();\n\t\t}\n\t\tthis.#state.materialized.clear();\n\t\t// Nothing will answer a request on a closed origin, whatever is still attached, so\n\t\t// existing requests report unroutable rather than waiting on a corpse.\n\t\tthis.#state.answerers.set(0);\n\t\tthis.#state.requests.update((requests) => {\n\t\t\tfor (const slot of requests?.values() ?? []) {\n\t\t\t\tslot.answer?.close();\n\t\t\t\tslot.answer = undefined;\n\t\t\t\tslot.route.set(undefined);\n\t\t\t}\n\t\t\treturn undefined;\n\t\t});\n\t}\n}\n\n// Constructs a Consumer from within this module without exposing a public constructor\n// that would leak the unexported OriginState. Assigned in the class's static block.\nlet makeConsumer: (state: OriginState) => Consumer;\n\n// Same for Requesting: a public constructor would let a caller forge a handle that no origin\n// ever registered, whose lifecycle guarantees are then false. `@internal` alone would not\n// stop it, since the declaration emit keeps the constructor.\nlet makeRequesting: (\n\tpath: Path.Valid,\n\tactive: Getter<broadcast.Consumer | undefined>,\n\tunroutable: Getter<boolean>,\n\tdispose: Dispose,\n) => Requesting;\n\nlet makeDynamic: (prefix: Path.Valid, entry: RouteEntry, state: OriginState, retract: Dispose) => Dynamic;\n\nlet makeRequest: (path: Path.Valid, server: ServeState) => Request;\nlet finishRequest: (request: Request, err: Error) => void;\n\n/**\n * An open request for a path nothing announced; see {@link Consumer.request}.\n *\n * @public\n */\nexport class Requesting {\n\t/** The requested path. */\n\treadonly path: Path.Valid;\n\n\t/**\n\t * The resolved broadcast, or undefined while nothing provides the path.\n\t *\n\t * The table's route when it has one: a local publish (no round trip) or an announced\n\t * broadcast, swapping when a republish takes the path. Otherwise a session's blind\n\t * answer, which is assumed present rather than known live: a missing broadcast\n\t * surfaces as a reset on the first track subscription, not here. Drops back to\n\t * undefined when the providing route dies and resolves again when another appears.\n\t *\n\t * Yours for as long as the request is open: it is a handle of this request's own, so\n\t * closing it ends your view of the path rather than the route everyone else reads.\n\t * {@link close} releases whatever is current.\n\t */\n\treadonly active: Getter<broadcast.Consumer | undefined>;\n\n\t/**\n\t * Whether nothing can serve this path, as opposed to not having served it yet.\n\t *\n\t * True when the origin routes nothing here and nothing is prepared to answer: no session\n\t * attached and no connection reconnecting toward one. False whenever {@link active} is\n\t * set, and false while a connection is still coming up, so the ordinary page-load window\n\t * before the first handshake reads as pending rather than as a missing broadcast. Waiting\n\t * on this is futile by definition; wait for an announcement instead, via the origin's\n\t * `announced`.\n\t */\n\treadonly unroutable: Getter<boolean>;\n\n\t#dispose: Dispose;\n\t#closed = false;\n\n\tprivate constructor(\n\t\tpath: Path.Valid,\n\t\tactive: Getter<broadcast.Consumer | undefined>,\n\t\tunroutable: Getter<boolean>,\n\t\tdispose: Dispose,\n\t) {\n\t\tthis.path = path;\n\t\tthis.active = active;\n\t\tthis.unroutable = unroutable;\n\t\tthis.#dispose = dispose;\n\t}\n\n\tstatic {\n\t\tmakeRequesting = (path, active, unroutable, dispose) => new Requesting(path, active, unroutable, dispose);\n\t}\n\n\t/** Withdraw the request. The path stays routed for any other open request. Idempotent. */\n\tclose(): void {\n\t\tif (this.#closed) return;\n\t\tthis.#closed = true;\n\t\tthis.#dispose();\n\t}\n}\n\n/**\n * The read side of an origin: resolve broadcasts by path and watch what is available.\n *\n * Obtain one from {@link Producer.consume}. Pass it to a connection's `publish` option to\n * serve the origin's local broadcasts to that peer; read it directly to consume anything\n * the origin routes, locally published or discovered by a session.\n *\n * @public\n */\nexport class Consumer {\n\t#state: OriginState;\n\n\tprivate constructor(state: OriginState) {\n\t\tthis.#state = state;\n\t\t// True only when every attached session announces. One session that cannot means the\n\t\t// table is an incomplete picture, so a consumer gated on it has to keep its blind\n\t\t// fallback: the paths only that session carries never reach the table at all.\n\t\tthis.#discovery = new Derived([state.sessions], ({ total, discovery }) =>\n\t\t\ttotal === 0 ? undefined : discovery === total,\n\t\t);\n\t\tregisterWire(this, {\n\t\t\troutes: (path) => this.#routes(path),\n\t\t\tget broadcasts() {\n\t\t\t\treturn state.local;\n\t\t\t},\n\t\t\tget advertised() {\n\t\t\t\treturn state.originated;\n\t\t\t},\n\t\t\tdemand: (path) => this.#demand(path),\n\t\t});\n\t}\n\n\tstatic {\n\t\tmakeConsumer = (state) => new Consumer(state);\n\t}\n\n\t/** Settles once the origin closes; see {@link Producer.closed}. */\n\tget closed(): GetPromise<Error | null> {\n\t\treturn this.#state.closed;\n\t}\n\n\t/**\n\t * Whether the announcement table sees everything the attached sessions can serve.\n\t *\n\t * Undefined while no session is attached (nothing is known yet), true when every attached\n\t * session announces into the table, and false as soon as one does not, where\n\t * {@link announced} cannot be complete and consumers should {@link request} paths instead\n\t * of waiting. One blind session among several is still false: the paths only it carries\n\t * never reach the table, so a consumer that trusted the gate would never see them.\n\t */\n\tget discovery(): Getter<boolean | undefined> {\n\t\treturn this.#discovery;\n\t}\n\n\t// Derived per access rather than cached: a lightweight mapped view over the session\n\t// counts, avoiding a Computed's lifecycle.\n\treadonly #discovery: Getter<boolean | undefined>;\n\n\t/**\n\t * Whether the table routes `path`, by a local publish or an announced route\n\t * covering it.\n\t *\n\t * Availability, not a handle: {@link request} is the only way to consume by path. A\n\t * request on a routed path resolves to that route and never to a blind answer, which is\n\t * why a serving session leaves it alone.\n\t *\n\t * @internal\n\t */\n\t#routes(path: Path.Valid): boolean {\n\t\tif (this.#state.local.peek()?.has(path)) return true;\n\t\treturn this.#state.bestEntry(path) !== undefined;\n\t}\n\n\t/**\n\t * Resolve `path`, optionally waiting for an announcement.\n\t *\n\t * The one way to consume by path. {@link Requesting.active} follows whatever the table\n\t * routes (a local publish, or any feeding session's announcement, swapping on a\n\t * republish); when nothing does, the request stands and whichever attached session\n\t * answers first provides a blind subscription instead, re-answered across reconnects.\n\t * With `announced: true`, an unrouted request waits while discovery is supported and\n\t * falls back to that blind behavior only when discovery is unavailable. Close the request\n\t * when done. On a closed origin it never resolves.\n\t *\n\t * With several sessions on one origin the first to answer wins, and it may be one that\n\t * does not carry the path. Nothing corrects that: a missing broadcast surfaces as a reset\n\t * on the first track and deliberately leaves the handle open, since the wire cannot tell\n\t * \"not here\" from \"not yet\" and a blind handle is expected to survive until a publisher\n\t * arrives. It matters only on an origin mixing sessions that announce with sessions that\n\t * cannot, where a path only the silent session carries may sit behind another session's\n\t * answer. Prefer {@link unroutable} and announcements over blind requests when the origin\n\t * feeds from more than one connection.\n\t */\n\trequest(path: Path.Valid, options: RequestOptions = {}): Requesting {\n\t\tconst requests = this.#state.requests.peek();\n\t\tif (!requests) {\n\t\t\t// Closed origin: a request that can never resolve, and says so.\n\t\t\treturn makeRequesting(path, new Signal<broadcast.Consumer | undefined>(undefined), getter(true), () => {});\n\t\t}\n\n\t\tlet slot = requests.get(path);\n\t\tif (!slot) {\n\t\t\t// Seeded through the constructor, so a path the table already routes resolves on the\n\t\t\t// first read. It must not go through a silent set: that still captures the pre-seed\n\t\t\t// value as the baseline the next change is compared against, and never flushes to\n\t\t\t// clear it, so a seeded route retracting to undefined would look like no change and\n\t\t\t// notify nobody.\n\t\t\tconst refused = new Set<RouteEntry>();\n\t\t\tconst created: RequestSlot = {\n\t\t\t\tcount: 0,\n\t\t\t\tblind: 0,\n\t\t\t\trefused,\n\t\t\t\troute: new Signal(this.#state.route(path, { refused })),\n\t\t\t};\n\t\t\tslot = created;\n\t\t\tthis.#state.requests.mutate((map) => {\n\t\t\t\tmap?.set(path, created);\n\t\t\t});\n\t\t}\n\t\tslot.count += 1;\n\t\tlet blind = !options.announced || this.#discovery.peek() === false;\n\t\tif (blind) slot.blind += 1;\n\t\tthis.#state.requests.mutate(() => {});\n\n\t\t// An announcement-gated request falls back to a blind subscription only while at\n\t\t// least one attached session cannot announce. It returns to the gate if discovery\n\t\t// becomes complete again, and remains gated with no session attached.\n\t\tconst unsubscribeDiscovery = options.announced\n\t\t\t? this.#discovery.subscribe((discovery) => {\n\t\t\t\t\tconst next = discovery === false;\n\t\t\t\t\tif (next === blind) return;\n\t\t\t\t\tblind = next;\n\t\t\t\t\tslot.blind += next ? 1 : -1;\n\t\t\t\t\tthis.#state.requests.mutate(() => {});\n\t\t\t\t})\n\t\t\t: () => {};\n\n\t\t// Hand out a handle of the request's own rather than the table's. Closing a consumer\n\t\t// closes the broadcast once it was the last one, and the table often holds the only\n\t\t// other handle, so lending its front out means an ordinary close() by one requester\n\t\t// can unpublish the path for everybody else.\n\t\tconst taken = slot;\n\n\t\t// Memoized on the route's identity: the same front resolving again returns the handle\n\t\t// we already made, and only a real swap clones a new one (cloning before closing the\n\t\t// old, so a broadcast that both routes share never briefly loses its last handle).\n\t\tlet released = false;\n\t\tlet source: broadcast.Consumer | undefined;\n\t\tlet handle: broadcast.Consumer | undefined;\n\t\tconst own = (front: broadcast.Consumer | undefined): broadcast.Consumer | undefined => {\n\t\t\tif (released) return undefined;\n\t\t\tif (front !== source) {\n\t\t\t\tconst previous = handle;\n\t\t\t\tsource = front;\n\t\t\t\thandle = front?.clone();\n\t\t\t\tprevious?.close();\n\t\t\t}\n\t\t\treturn handle;\n\t\t};\n\n\t\tconst route = taken.route;\n\t\tconst active = new Derived([route], own);\n\n\t\t// Swapping on the read is what keeps a routed path resolving synchronously, but a\n\t\t// holder that only ever peeked would then pin a route that has already been retracted\n\t\t// until it happened to read again. Following the route as well retires it promptly,\n\t\t// and the memo makes the two paths agree: whichever runs first does the swap.\n\t\tconst unsubscribe = route.subscribe(own);\n\n\t\t// Only meaningful while nothing is routed, so it reads the route rather than `active`:\n\t\t// the two cannot disagree, since a routed path always has an answerer-independent\n\t\t// answer.\n\t\tconst unroutable = new Derived([route, this.#state.answerers], (front, answerers) => !front && answerers === 0);\n\n\t\treturn makeRequesting(path, active, unroutable, () => {\n\t\t\t// Releases this request's handle; the route itself belongs to the table.\n\t\t\treleased = true;\n\t\t\tunsubscribeDiscovery();\n\t\t\tunsubscribe();\n\t\t\thandle?.close();\n\t\t\thandle = undefined;\n\t\t\tsource = undefined;\n\n\t\t\ttaken.count -= 1;\n\t\t\tif (blind) taken.blind -= 1;\n\t\t\tthis.#state.requests.mutate(() => {});\n\t\t\tif (taken.count > 0) return;\n\n\t\t\t// Defer the teardown a microtask: an effect whose rerun was triggered by the\n\t\t\t// answer resolving closes its old request and takes a new one in the same tick,\n\t\t\t// and tearing down in between would drop the answer it is about to read.\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tif (taken.count > 0) return;\n\t\t\t\tthis.#state.requests.mutate((map) => {\n\t\t\t\t\tif (map?.get(path) === taken) map.delete(path);\n\t\t\t\t});\n\t\t\t\ttaken.answer?.close();\n\t\t\t\ttaken.answer = undefined;\n\t\t\t\ttaken.route.set(undefined);\n\t\t\t\tthis.#state.releaseMaterialized(path);\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * The announced routes matching `scope`, as a live stream: every currently advertised\n\t * route arrives first as active, then additions and retractions as they happen.\n\t * Any pattern is accepted. A local broadcast appears when it is created;\n\t * {@link broadcast.Producer.announce} only forwards it to peers. A dynamic or\n\t * received route announces the prefix it covers when its subtree overlaps the scope. The\n\t * stream ends when the origin closes or the consumer is closed.\n\t */\n\tannounced(scope: Path.Pattern = Path.Pattern.all()): announce.Consumer {\n\t\tconst producer = new announce.Producer();\n\t\tvoid this.#runAnnounced(producer, scope);\n\t\treturn producer.consume();\n\t}\n\n\tasync #runAnnounced(producer: announce.Producer, scope: Path.Pattern): Promise<void> {\n\t\t// Keyed by the presented path (from the origin, not the scope), valued by identity\n\t\t// plus route. Diffing identity rather than mere presence means a republish emits a\n\t\t// retraction then a fresh announcement; a re-price of the same identity emits an\n\t\t// update.\n\t\tlet active = new Map<Path.Valid, Presented>();\n\n\t\ttry {\n\t\t\tfor (;;) {\n\t\t\t\tconst local = this.#state.local.peek();\n\t\t\t\tconst advertisedLocal = this.#state.advertisedLocal.peek();\n\t\t\t\tconst routes = this.#state.routes.peek();\n\t\t\t\tif (local === undefined && advertisedLocal === undefined && routes === undefined) break;\n\n\t\t\t\tconst next = new Map<Path.Valid, Presented>();\n\t\t\t\t// Routes first, so an advertised local at the same path overwrites it: the\n\t\t\t\t// announcement points at whatever request() would resolve. A route remains\n\t\t\t\t// the prefix it advertised; the pattern is a local filter, not a new claim.\n\t\t\t\tfor (const [covered, entries] of routes ?? []) {\n\t\t\t\t\tconst entry = entries[0];\n\t\t\t\t\tif (!entry) continue;\n\t\t\t\t\tif (!scopeOverlaps(scope, covered)) continue;\n\t\t\t\t\tconst snap: Presented = {\n\t\t\t\t\t\tidentity: entry.identity,\n\t\t\t\t\t\troute: entry.route.peek(),\n\t\t\t\t\t\tcaptures: scopeCaptures(scope, covered),\n\t\t\t\t\t};\n\t\t\t\t\tnext.set(covered, snap);\n\t\t\t\t}\n\t\t\t\tfor (const [path, front] of local ?? []) {\n\t\t\t\t\tconst route = advertisedLocal?.get(path) ?? Route.default;\n\t\t\t\t\tif (scope.matches(path))\n\t\t\t\t\t\tnext.set(path, { identity: front, route, captures: scopeCaptures(scope, path) });\n\t\t\t\t}\n\n\t\t\t\tfor (const [path, snap] of active) {\n\t\t\t\t\tconst cur = next.get(path);\n\t\t\t\t\tif (!cur || cur.identity !== snap.identity)\n\t\t\t\t\t\tproducer.append({\n\t\t\t\t\t\t\tprefix: path,\n\t\t\t\t\t\t\tcaptures: snap.captures,\n\t\t\t\t\t\t\tkind: \"retracted\",\n\t\t\t\t\t\t\troute: snap.route,\n\t\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tfor (const [path, snap] of next) {\n\t\t\t\t\tconst prev = active.get(path);\n\t\t\t\t\tif (!prev || prev.identity !== snap.identity) {\n\t\t\t\t\t\tproducer.append({\n\t\t\t\t\t\t\tprefix: path,\n\t\t\t\t\t\t\tcaptures: snap.captures,\n\t\t\t\t\t\t\tkind: \"announced\",\n\t\t\t\t\t\t\troute: snap.route,\n\t\t\t\t\t\t});\n\t\t\t\t\t} else if (!routesEqual(prev.route, snap.route)) {\n\t\t\t\t\t\tproducer.append({ prefix: path, captures: snap.captures, kind: \"updated\", route: snap.route });\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tactive = next;\n\n\t\t\t\tawait Signal.race(this.#state.local, this.#state.advertisedLocal, this.#state.routes, producer.closed);\n\t\t\t\tif (producer.closed.peek() !== undefined) return;\n\t\t\t}\n\t\t} catch {\n\t\t\t// The reader closed between the check and an append; nothing left to do.\n\t\t}\n\t\tproducer.close();\n\t}\n\n\t/**\n\t * The local table, borrowed by the wire publishers to answer subscribes.\n\t *\n\t * Deliberately excludes received routes: a session never re-announces what a peer\n\t * told it, so an origin wired to both directions of a connection cannot echo.\n\t * Borrowed, not owned: do not close the fronts. Undefined once the origin closes.\n\t *\n\t * @internal\n\t */\n\t/**\n\t * Originated advertisements a session should forward: exact-path announces plus\n\t * originated dynamics. Undefined once the origin closes.\n\t *\n\t * @internal\n\t */\n\t/**\n\t * Resolve `path` for serving: a local broadcast, or wait for an originated dynamic\n\t * to accept it. Undefined when nothing here can serve the path.\n\t *\n\t * @internal\n\t */\n\tasync #demand(path: Path.Valid): Promise<broadcast.Consumer | undefined> {\n\t\tconst local = this.#state.local.peek()?.get(path);\n\t\tif (local) return local;\n\n\t\tconst entry = this.#state.bestEntry(path);\n\t\tif (!entry?.originated || !entry.server) return undefined;\n\n\t\tconst server = entry.server;\n\t\tconst live = server.served.get(path);\n\t\tif (live && live.closed.peek() === undefined) return live;\n\n\t\tserver.enqueue(path);\n\t\tserver.demanding.set(path, (server.demanding.get(path) ?? 0) + 1);\n\t\ttry {\n\t\t\tfor (;;) {\n\t\t\t\tconst served = server.served.get(path);\n\t\t\t\tif (served && served.closed.peek() === undefined) return served;\n\t\t\t\tconst rejected = server.rejected.get(path);\n\t\t\t\tif (rejected) {\n\t\t\t\t\tserver.rejected.delete(path);\n\t\t\t\t\tthrow rejected;\n\t\t\t\t}\n\t\t\t\tconst closed = server.closed.peek();\n\t\t\t\tif (closed !== undefined) {\n\t\t\t\t\tif (closed) throw closed;\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\tif (!server.pending.has(path)) return undefined;\n\t\t\t\tawait Signal.race(server.settled, server.closed);\n\t\t\t}\n\t\t} finally {\n\t\t\tconst n = (server.demanding.get(path) ?? 1) - 1;\n\t\t\tif (n <= 0) server.demanding.delete(path);\n\t\t\telse server.demanding.set(path, n);\n\t\t}\n\t}\n}\n\n/**\n * A served route from {@link Producer.dynamic}: advertises a prefix and answers the\n * requests beneath it.\n *\n * Drop it (or {@link close}) to retract the route and reject anything still waiting\n * with {@link StreamCode.NoCapacity}. {@link update} re-prices it in place.\n *\n * @public\n */\nexport class Dynamic {\n\t/** The prefix this handle advertises. */\n\treadonly prefix: Path.Valid;\n\n\t#entry: RouteEntry;\n\t#state: OriginState;\n\t#retract: Dispose;\n\t#closed = false;\n\n\tprivate constructor(prefix: Path.Valid, entry: RouteEntry, state: OriginState, retract: Dispose) {\n\t\tthis.prefix = prefix;\n\t\tthis.#entry = entry;\n\t\tthis.#state = state;\n\t\tthis.#retract = retract;\n\t}\n\n\tstatic {\n\t\tmakeDynamic = (prefix, entry, state, retract) => new Dynamic(prefix, entry, state, retract);\n\t}\n\n\t/** Re-price the route in place. The prefix is fixed at announce time. */\n\tupdate(route: Route | { hops?: Route[\"hops\"]; cost?: Route[\"cost\"] | bigint }): void {\n\t\tif (this.#closed) throw new Error(\"dynamic is closed\");\n\t\tthis.#entry.route.set(Route.normalize(route));\n\t\tthis.#state.rebuildOriginated();\n\t\tthis.#state.refreshPrefix(this.prefix);\n\t\tthis.#state.routes.mutate(() => {});\n\t}\n\n\t/** Retract the route and reject anything still waiting. Idempotent. */\n\tclose(): void {\n\t\tif (this.#closed) return;\n\t\tthis.#closed = true;\n\t\tthis.#retract();\n\t}\n\n\t/** Requests under this prefix, as they arrive, each to {@link Request.accept} or reject. */\n\tasync *requested(): AsyncIterableIterator<Request> {\n\t\tconst server = this.#entry.server;\n\t\tif (!server) return;\n\t\tlet current: Request | undefined;\n\t\tconst drop = () => {\n\t\t\tcurrent?.reject(noCapacity());\n\t\t\tcurrent = undefined;\n\t\t};\n\t\ttry {\n\t\t\tfor (;;) {\n\t\t\t\tconst next = server.queue.peek()[0];\n\t\t\t\tif (next) {\n\t\t\t\t\tdrop();\n\t\t\t\t\tserver.queue.mutate((queue) => {\n\t\t\t\t\t\tqueue.shift();\n\t\t\t\t\t});\n\t\t\t\t\tcurrent = next;\n\t\t\t\t\tyield next;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (server.closed.peek() !== undefined) return;\n\t\t\t\tawait Signal.race(server.queue, server.closed);\n\t\t\t}\n\t\t} finally {\n\t\t\tdrop();\n\t\t}\n\t}\n}\n\n/**\n * A pending request for a broadcast to be served on demand.\n *\n * Yielded by {@link Dynamic.requested}. {@link accept} resolves it with a live\n * broadcast; {@link reject} resolves it with an error. Advancing the iterator or\n * closing it without either rejects the request.\n *\n * @public\n */\nexport class Request {\n\t/** The path that was requested. */\n\treadonly path: Path.Valid;\n\n\t#server: ServeState;\n\t#done = false;\n\n\tprivate constructor(path: Path.Valid, server: ServeState) {\n\t\tthis.path = path;\n\t\tthis.#server = server;\n\t}\n\n\tstatic {\n\t\tmakeRequest = (path, server) => new Request(path, server);\n\t\tfinishRequest = (request, err) => {\n\t\t\trequest.#done = true;\n\t\t\tvoid err;\n\t\t};\n\t}\n\n\t/**\n\t * Accept the request, resolving every awaiting requester with `broadcast`.\n\t *\n\t * The caller keeps producing into `broadcast`; repeat requests for the path share\n\t * it for as long as it stays live.\n\t */\n\taccept(source: broadcast.Producer | broadcast.Consumer): void {\n\t\tif (this.#done) return;\n\t\tthis.#done = true;\n\t\tconst front = source instanceof broadcast.Producer ? source.consume() : source;\n\t\tthis.#server.accept(this, front);\n\t}\n\n\t/** Reject the request, resolving every awaiting requester with `err`. */\n\treject(err: Error): void {\n\t\tif (this.#done) return;\n\t\tthis.#done = true;\n\t\tthis.#server.reject(this, err);\n\t}\n}\n"]}
1
+ {"version":3,"file":"origin.js","sourceRoot":"","sources":["../src/origin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,OAAO,EAA8C,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACzG,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC5F,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAmB,YAAY,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGlE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AA+CvC,gHAAgH;AAChH,SAAS,aAAa,CAAC,CAAQ,EAAE,CAAQ;IACxC,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAClE,IAAI,SAAS,KAAK,CAAC;Q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IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAChC,CAAC;CACD","sourcesContent":["/**\n * A broadcast routing table, independent of any connection.\n *\n * Publish broadcasts into an origin and hand the origin to one or more connections to\n * serve them; the broadcasts outlive any single session. Hand the same (or another)\n * origin to a connection's `consume` option and the peer's announced routes appear\n * in the table too: each route covers a path prefix, and a request for a path under\n * it resolves through the session that announced it. Mirrors the `origin` module in\n * `rs/moq-net`.\n *\n * @module\n */\nimport { Derived, type Dispose, type GetPromise, type Getter, getter, Once, Signal } from \"@moq/signals\";\nimport * as announce from \"./announced.ts\";\nimport * as broadcast from \"./broadcast.ts\";\nimport { StreamCode, StreamError } from \"./error.ts\";\nimport { isAnonymous, Route, routesEqual } from \"./hop.ts\";\nimport { hiddenBelow, hooks, scopeCaptures, scopeHead, scopeOverlaps } from \"./internal.ts\";\nimport * as Path from \"./path.ts\";\nimport { type Advertised, registerWire, wireOf } from \"./wire.ts\";\n\nexport type { Cost, Hop, Route } from \"./hop.ts\";\nexport { isAnonymous } from \"./hop.ts\";\n\n/**\n * One requested path: the notify node for everything watching it.\n *\n * `route` is the only reactive part, and the only thing a {@link Request} subscribes to, so\n * a publish or retraction anywhere else in the table cannot wake it. The origin's tables stay\n * the storage; this is a per-path view onto them, refreshed by whichever mutator touched the\n * path. The alternative, deriving each request over the whole `local`/`remote` maps, wakes\n * every open request on every unrelated change.\n *\n * `answer` outlives a session: the answering session clears it when it dies and the next one\n * answers again, which is what makes a request span reconnects.\n *\n * `refused` holds the route entries whose handler rejected the path. A refusal is\n * authoritative: the entry is never asked again while it stands (a reconnect is a fresh\n * entry), and the path resolves through the next-best route or to nothing. Without it a\n * rejection would refresh the path straight back onto the same queue, and a handler that\n * keeps saying no would be asked forever.\n *\n * @internal\n */\nexport interface RequestSlot {\n\tcount: number;\n\tblind: number;\n\tanswer?: broadcast.Consumer;\n\treadonly refused: Set<RouteEntry>;\n\treadonly route: Signal<broadcast.Consumer | undefined>;\n}\n\n/**\n * One advertised prefix: hops and cost, plus an optional server that answers\n * requests beneath it.\n *\n * The preferred entry per prefix is the one requests resolve through. An originated\n * entry is forwarded by sessions; a received one is not, so a shared origin\n * cannot echo a peer's announcements back to it.\n *\n * @internal\n */\nexport interface RouteEntry {\n\treadonly identity: object;\n\treadonly route: Signal<Route>;\n\treadonly originated: boolean;\n\treadonly server?: ServeState;\n}\n\n/** Orders two routes by preference: identified before anonymous, then lower warm cost, then lower cold cost. */\nfunction compareRoutes(a: Route, b: Route): number {\n\tconst anonymous = Number(isAnonymous(a)) - Number(isAnonymous(b));\n\tif (anonymous !== 0) return anonymous;\n\tif (a.cost.warm !== b.cost.warm) return a.cost.warm < b.cost.warm ? -1 : 1;\n\tif (a.cost.cold !== b.cost.cold) return a.cost.cold < b.cost.cold ? -1 : 1;\n\treturn 0;\n}\n\n/** The preferred of `entries` (newest first) not skipped: the best route, then fewest hops, then newest. */\nfunction preferredEntry(entries: readonly RouteEntry[], skip?: (entry: RouteEntry) => boolean): RouteEntry | undefined {\n\tlet best: RouteEntry | undefined;\n\tfor (const entry of entries) {\n\t\tif (skip?.(entry)) continue;\n\t\tif (!best) {\n\t\t\tbest = entry;\n\t\t\tcontinue;\n\t\t}\n\t\tconst a = entry.route.peek();\n\t\tconst b = best.route.peek();\n\t\tconst order = compareRoutes(a, b) || a.hops.length - b.hops.length;\n\t\tif (order < 0) best = entry;\n\t}\n\treturn best;\n}\n\n/** Whether a session received `entry`, so it is never forwarded to a peer. */\nfunction received(entry: RouteEntry): boolean {\n\treturn !entry.originated;\n}\n\nfunction noCapacity(): StreamError {\n\treturn new StreamError(StreamCode.NoCapacity, { message: \"no capacity\" });\n}\n\n/** A served route from {@link Producer.dynamic}: the queue a handler drains. */\nclass ServeState {\n\tqueue = new Signal<Request[]>([]);\n\tpending = new Map<Path.Valid, Request>();\n\tserved = new Map<Path.Valid, broadcast.Consumer>();\n\trejected = new Map<Path.Valid, Error>();\n\t// demand() is the only reader of `rejected`. A Consumer.request refusal never\n\t// re-enqueues, so storing the error without a waiter would pin every unique\n\t// path until the route dies.\n\tdemanding = new Map<Path.Valid, number>();\n\tclosed = new Once<Error | null>();\n\tsettled = new Signal(0);\n\tonChange: (path: Path.Valid) => void = () => {};\n\tonReject: (path: Path.Valid) => void = () => {};\n\n\tenqueue(path: Path.Valid): void {\n\t\tif (this.closed.peek() !== undefined) return;\n\t\tthis.rejected.delete(path);\n\t\tif (this.pending.has(path)) return;\n\t\tconst live = this.served.get(path);\n\t\tif (live && live.closed.peek() === undefined) return;\n\t\tconst request = makeRequest(path, this);\n\t\tthis.pending.set(path, request);\n\t\tthis.queue.mutate((queue) => {\n\t\t\tqueue.push(request);\n\t\t});\n\t}\n\n\taccept(request: Request, front: broadcast.Consumer): void {\n\t\tif (this.closed.peek() !== undefined || this.pending.get(request.path) !== request) {\n\t\t\tfront.close();\n\t\t\treturn;\n\t\t}\n\t\tthis.pending.delete(request.path);\n\t\tconst existing = this.served.get(request.path);\n\t\tif (existing && existing.closed.peek() === undefined) {\n\t\t\tfront.close();\n\t\t\tthis.onChange(request.path);\n\t\t\tthis.settled.update((n) => n + 1);\n\t\t\treturn;\n\t\t}\n\t\tthis.served.set(request.path, front);\n\t\tvoid front.closed.then(() => {\n\t\t\tif (this.served.get(request.path) !== front) return;\n\t\t\tthis.served.delete(request.path);\n\t\t\tthis.onChange(request.path);\n\t\t});\n\t\tthis.onChange(request.path);\n\t\tthis.settled.update((n) => n + 1);\n\t}\n\n\treject(request: Request, err: Error): void {\n\t\tif (this.pending.get(request.path) !== request) return;\n\t\tthis.pending.delete(request.path);\n\t\tif (this.demanding.has(request.path)) this.rejected.set(request.path, err);\n\t\tthis.onReject(request.path);\n\t\tthis.settled.update((n) => n + 1);\n\t}\n\n\tclose(abort?: Error): void {\n\t\tif (this.closed.peek() !== undefined) return;\n\t\tconst err = abort ?? noCapacity();\n\t\tthis.closed.set(err);\n\t\tconst queued = [...this.pending.values()];\n\t\tthis.pending.clear();\n\t\tthis.queue.mutate((queue) => {\n\t\t\tqueue.length = 0;\n\t\t});\n\t\tfor (const request of queued) {\n\t\t\tfinishRequest(request, err);\n\t\t}\n\t\tfor (const [path, front] of this.served) {\n\t\t\tfront.close(abort);\n\t\t\tthis.onChange(path);\n\t\t}\n\t\tthis.served.clear();\n\t\tthis.rejected.clear();\n\t\tthis.demanding.clear();\n\t\tthis.settled.update((n) => n + 1);\n\t}\n}\n\ninterface Presented extends Advertised {\n\treadonly captures: Path.Pattern[] | undefined;\n}\n\n/** A table mutation invalidates the shared route snapshot before its async notification. */\nclass VersionedSignal<T> extends Signal<T> {\n\tversion = 0;\n\n\toverride set(value: T, notify?: boolean): void {\n\t\tthis.version++;\n\t\tsuper.set(value, notify);\n\t}\n}\n\n/** Reactive backing state shared by origin producers and consumers. */\nclass OriginState {\n\t// Both tables decouple the application producing into the origin from the\n\t// connections serving or feeding it. Undefined once the origin closes, so late\n\t// writes fail loudly.\n\t//\n\t// Created is what this endpoint publishes, keyed by exact path, announced or not.\n\t// Local is the announced subset, with its route in advertisedLocal: a broadcast\n\t// exists for nobody, here or at a peer, until it announces. Routes is the\n\t// advertisement table: prefixes a dynamic handle or a received session covers,\n\t// newest first. Local and routes stay separate so a session can never announce a\n\t// received entry back to a peer, which is what makes an origin shared by both\n\t// directions echo-free.\n\tcreated: Map<Path.Valid, broadcast.Consumer> | undefined = new Map();\n\tlocal = new VersionedSignal<Map<Path.Valid, broadcast.Consumer> | undefined>(new Map());\n\tadvertisedLocal = new VersionedSignal<Map<Path.Valid, Route> | undefined>(new Map());\n\troutes = new VersionedSignal<Map<Path.Valid, RouteEntry[]> | undefined>(new Map());\n\n\t#snapshotVersion = \"\";\n\t#snapshot = {\n\t\tremote: new Map<Path.Valid, Advertised>(),\n\t\tlocal: new Map<Path.Valid, Advertised>(),\n\t\troutes: new Map<Path.Valid, Route>(),\n\t\tvisible: new Map<Path.Valid, Route>(),\n\t};\n\n\t/** The full route table is built once per mutation, regardless of observer count. */\n\tavailable = new Derived([this.local, this.advertisedLocal, this.routes], () => this.snapshot().routes);\n\t/** {@link available} without hidden routes, for unscoped readers that did not opt in. */\n\tvisible = new Derived([this.local, this.advertisedLocal, this.routes], () => this.snapshot().visible);\n\n\tsnapshot(): {\n\t\tremote: ReadonlyMap<Path.Valid, Advertised>;\n\t\tlocal: ReadonlyMap<Path.Valid, Advertised>;\n\t\troutes: ReadonlyMap<Path.Valid, Route>;\n\t\tvisible: ReadonlyMap<Path.Valid, Route>;\n\t} {\n\t\tconst version = `${this.local.version}/${this.advertisedLocal.version}/${this.routes.version}`;\n\t\tif (version === this.#snapshotVersion) return this.#snapshot;\n\t\tconst remote = new Map<Path.Valid, Advertised>();\n\t\tconst local = new Map<Path.Valid, Advertised>();\n\t\tconst available = new Map<Path.Valid, Route>();\n\t\tfor (const [path, routes] of this.routes.peek() ?? []) {\n\t\t\tconst entry = preferredEntry(routes);\n\t\t\tif (!entry) continue;\n\t\t\tconst value = { identity: entry.identity, route: entry.route.peek() };\n\t\t\tremote.set(path, value);\n\t\t\tavailable.set(path, value.route);\n\t\t}\n\t\tfor (const [path, front] of this.local.peek() ?? []) {\n\t\t\tconst routes = this.routes.peek()?.get(path);\n\t\t\tif (!this.localWins(path, routes && preferredEntry(routes))) continue;\n\t\t\tconst value = { identity: front, route: this.advertisedLocal.peek()?.get(path) ?? Route.default };\n\t\t\tlocal.set(path, value);\n\t\t\tavailable.set(path, value.route);\n\t\t}\n\t\tconst visible = new Map<Path.Valid, Route>();\n\t\tfor (const [path, route] of available) {\n\t\t\tif (!hiddenBelow(Path.empty(), path)) visible.set(path, route);\n\t\t}\n\t\tthis.#snapshot = { remote, local, routes: available, visible };\n\t\tthis.#snapshotVersion = version;\n\t\treturn this.#snapshot;\n\t}\n\n\t// Originated advertisements sessions should forward: exact-path announces plus\n\t// originated dynamics. Identity is the local front or the route entry, so a\n\t// republish diffs as retract-then-announce and a re-price as another active.\n\toriginated = new Signal<Map<Path.Valid, Advertised> | undefined>(new Map());\n\n\t// Broadcasts materialized from a served route, keyed by exact path. Shared by every\n\t// request for the path so repeats reuse one accept; dropped (and closed) when the\n\t// providing route goes away or the last request releases it.\n\tmaterialized = new Map<Path.Valid, { entry: RouteEntry; front: broadcast.Consumer }>();\n\n\t// Paths consumers asked for without waiting for an announcement; attached sessions\n\t// answer them with blind subscriptions. Never announced: an answered request is assumed\n\t// present, not known live, so it must not read as an availability claim.\n\trequests = new Signal<Map<Path.Valid, RequestSlot> | undefined>(new Map());\n\n\t// How many sessions are attached, and how many of those support broadcast discovery.\n\t// What backs the public `discovery` getter.\n\tsessions = new Signal({ total: 0, discovery: 0 });\n\n\t// How many things are prepared to answer a request: attached sessions, plus reconnecting\n\t// connections that have no session right now but will. Zero means an unrouted path is\n\t// unroutable rather than merely unanswered, which is the whole difference between \"wait,\n\t// this is coming\" and \"nothing here can ever serve you\".\n\tanswerers = new Signal(0);\n\n\tclosed = new Once<Error | null>();\n\n\t/**\n\t * Recompute what `path` resolves to, waking only the requests watching that path.\n\t *\n\t * A no-op for a path nobody requested, so the common case (publishing into a table\n\t * nobody is asking about) costs a map lookup. Call after any write that could change\n\t * the answer for a single path.\n\t */\n\trefresh(path: Path.Valid): void {\n\t\tconst slot = this.requests.peek()?.get(path);\n\t\tif (!slot) return;\n\t\tslot.route.set(this.route(path, slot));\n\t}\n\n\t/** Record that `entry` refused `path` and re-route the requests watching it. */\n\trefuse(path: Path.Valid, entry: RouteEntry): void {\n\t\tconst slot = this.requests.peek()?.get(path);\n\t\tif (!slot) return;\n\t\tslot.refused.add(entry);\n\t\tslot.route.set(this.route(path, slot));\n\t}\n\n\t/**\n\t * Recompute every open request covered by `prefix`, after a route was inserted or\n\t * removed there: a route covers many paths, so a single-path refresh is not enough.\n\t * Materialized broadcasts whose provider changed are released here too, so a\n\t * retracted route's session subscription closes even when nothing reads it again.\n\t */\n\trefreshPrefix(prefix: Path.Valid): void {\n\t\tconst requests = this.requests.peek();\n\t\tfor (const [path, cached] of [...this.materialized]) {\n\t\t\tif (!Path.hasPrefix(prefix, path)) continue;\n\t\t\tconst refused = requests?.get(path)?.refused;\n\t\t\tif (cached.entry !== this.bestEntry(path, (entry) => refused?.has(entry) ?? false)) {\n\t\t\t\tthis.materialized.delete(path);\n\t\t\t\tcached.front.close();\n\t\t\t}\n\t\t}\n\t\tfor (const [path, slot] of requests ?? []) {\n\t\t\tif (Path.hasPrefix(prefix, path)) slot.route.set(this.route(path, slot));\n\t\t}\n\t}\n\n\t/** Rebuild the publisher-facing originated table after an advertisement write. */\n\trebuildOriginated(): void {\n\t\tconst local = this.local.peek();\n\t\tconst advertised = this.advertisedLocal.peek();\n\t\tconst routes = this.routes.peek();\n\t\tif (!local && !advertised && !routes) {\n\t\t\tthis.originated.set(undefined);\n\t\t\treturn;\n\t\t}\n\t\tconst next = new Map<Path.Valid, Advertised>();\n\t\tfor (const [prefix, entries] of routes ?? []) {\n\t\t\tconst mine = preferredEntry(entries, received);\n\t\t\tif (mine) next.set(prefix, { identity: mine.identity, route: mine.route.peek() });\n\t\t}\n\t\t// A local broadcast and an originated dynamic at one path compete on cost, as they do for requests.\n\t\tfor (const [path, route] of advertised ?? []) {\n\t\t\tconst front = local?.get(path);\n\t\t\tconst entries = routes?.get(path);\n\t\t\tif (front && this.localWins(path, entries && preferredEntry(entries, received))) {\n\t\t\t\tnext.set(path, { identity: front, route });\n\t\t\t}\n\t\t}\n\t\tthis.originated.set(next);\n\t}\n\n\t/**\n\t * Release the materialized broadcast for `path`, once its last request is gone: the\n\t * cache exists to share one session subscription between requests, not to outlive\n\t * them.\n\t */\n\treleaseMaterialized(path: Path.Valid): void {\n\t\tconst cached = this.materialized.get(path);\n\t\tif (!cached) return;\n\t\tthis.materialized.delete(path);\n\t\tcached.front.close();\n\t}\n\n\t/** The preferred entry on the most specific route covering `path`, ignoring skipped entries, if any. */\n\tbestEntry(path: Path.Valid, skip?: (entry: RouteEntry) => boolean): RouteEntry | undefined {\n\t\tlet bestPrefix: Path.Valid | undefined;\n\t\tlet best: RouteEntry | undefined;\n\t\tfor (const [prefix, entries] of this.routes.peek() ?? []) {\n\t\t\tif (!Path.hasPrefix(prefix, path)) continue;\n\t\t\tconst entry = preferredEntry(entries, skip);\n\t\t\tif (!entry) continue;\n\t\t\tif (bestPrefix === undefined || prefix.length > bestPrefix.length) {\n\t\t\t\tbestPrefix = prefix;\n\t\t\t\tbest = entry;\n\t\t\t}\n\t\t}\n\t\treturn best;\n\t}\n\n\t/**\n\t * Whether the announced local broadcast at `path` wins over `entry`, the best route a\n\t * session or dynamic handle announced there. Cost decides, as for any two routes: an\n\t * identified route strictly cheaper than the local one wins, and the local broadcast\n\t * wins a tie. A route at a shorter prefix never competes, since the most specific\n\t * prefix wins outright. False when nothing is announced locally at `path`.\n\t */\n\tlocalWins(path: Path.Valid, entry: RouteEntry | undefined): boolean {\n\t\tconst local = this.advertisedLocal.peek()?.get(path);\n\t\tif (!local || !this.local.peek()?.has(path)) return false;\n\t\tif (!entry || !this.routes.peek()?.get(path)?.includes(entry)) return true;\n\t\treturn compareRoutes(local, entry.route.peek()) <= 0;\n\t}\n\n\t/**\n\t * What `path` resolves to: an announced local publish, a broadcast materialized from\n\t * the best covering route, or the blind answer.\n\t *\n\t * Materialization is lazy and cached per path: the first request under a route opens\n\t * the providing session's subscription, repeats share it, and a provider change (the\n\t * route retracting, a better session taking over) swaps it out.\n\t */\n\troute(path: Path.Valid, slot: Pick<RequestSlot, \"answer\" | \"refused\">): broadcast.Consumer | undefined {\n\t\tconst entry = this.bestEntry(path, (candidate) => slot.refused.has(candidate));\n\t\tconst local = this.local.peek()?.get(path);\n\t\tif (local && this.localWins(path, entry)) {\n\t\t\t// Nothing reads a remote front the local broadcast replaced, so close its session subscription.\n\t\t\tthis.releaseMaterialized(path);\n\t\t\treturn local;\n\t\t}\n\n\t\tconst cached = this.materialized.get(path);\n\t\tif (cached && cached.entry === entry) {\n\t\t\tif (cached.front.closed.peek() === undefined) return cached.front;\n\t\t\tthis.materialized.delete(path);\n\t\t} else if (cached) {\n\t\t\tthis.materialized.delete(path);\n\t\t\tcached.front.close();\n\t\t}\n\t\tif (!entry?.server) return slot.answer;\n\n\t\tconst served = entry.server.served.get(path);\n\t\tif (served && served.closed.peek() === undefined) {\n\t\t\tthis.materialized.set(path, { entry, front: served });\n\t\t\treturn served;\n\t\t}\n\n\t\tentry.server.enqueue(path);\n\t\treturn undefined;\n\t}\n}\n\n/**\n * A non-owning handle on an origin: publish into it and read it, without its lifecycle.\n *\n * What a shared connection lends out. {@link Producer} implements it, so code that is\n * handed an origin rather than owning one should accept this type: closing the origin\n * stays the owner's alone, and a borrower cannot express it.\n *\n * @public\n */\nexport interface Table {\n\t/** Settles once the origin closes; see {@link Producer.closed}. */\n\treadonly closed: GetPromise<Error | null>;\n\n\t/** Whether every attached session announces into the table; see {@link Consumer.discovery}. */\n\treadonly discovery: Getter<boolean | undefined>;\n\n\t/** Create an unannounced broadcast at `path`; see {@link Producer.createBroadcast}. */\n\tcreateBroadcast(path: Path.Valid): broadcast.Producer;\n\n\t/** Resolve `path`, optionally waiting for an announcement; see {@link Consumer.request}. */\n\trequest(path: Path.Valid, options?: RequestOptions): Requesting;\n\n\t/** The available announcements under `scope`, as a live map; see {@link Consumer.broadcasts}. */\n\tbroadcasts(scope?: Path.Pattern, options?: announce.Options): Getter<ReadonlyMap<Path.Valid, Route>>;\n\n\t/** The available broadcasts under `scope`, as a live stream; see {@link Consumer.announced}. */\n\tannounced(scope?: Path.Pattern, options?: announce.Options): announce.Consumer;\n\n\t/** Advertise a prefix and serve requests under it; see {@link Producer.dynamic}. */\n\tdynamic(prefix: Path.Valid, route?: Route | { hops?: Route[\"hops\"]; cost?: Route[\"cost\"] | bigint }): Dynamic;\n}\n\n/** Options for resolving a broadcast path. */\nexport interface RequestOptions {\n\t/** Wait for a routed announcement when discovery is supported; otherwise subscribe blindly. */\n\tannounced?: boolean;\n}\n\n/**\n * The write side of an origin: create broadcasts by path and advertise them.\n *\n * Independent of any connection. A connection given this origin (via its `publish` option)\n * announces and serves the table's originated advertisements for as long as the session\n * lasts; the broadcasts themselves live until their producer closes or {@link close} tears\n * the origin down. A reconnecting session re-announces the table on each attach, so\n * advertisements made while offline surface on the next connection.\n *\n * Create, attach {@link dynamic} for tracks served on demand, populate, then\n * {@link broadcast.Producer.announce}: an exact-path subscribe before the tracks exist is\n * refused, and nobody can see or reach a broadcast until it announces.\n *\n * @public\n */\nexport class Producer implements Table {\n\t#state = new OriginState();\n\n\t// The reader backing the passthroughs, so holding a Producer never requires the\n\t// consume().x() stutter for everyday reads. One instance, so `discovery` keeps its\n\t// identity across reads.\n\t#reader = makeConsumer(this.#state);\n\n\tconstructor() {\n\t\tconst thisProducer = this;\n\t\tregisterWire(this, {\n\t\t\treceive: (prefix, route) => this.#receive(prefix, route),\n\t\t\tattach: (discovery) => this.#attach(discovery),\n\t\t\texpect: () => this.#expect(),\n\t\t\tget requests() {\n\t\t\t\treturn thisProducer.#state.requests;\n\t\t\t},\n\t\t\tchanged: () => this.#changed(),\n\t\t\tanswer: (path, front) => this.#answer(path, front),\n\t\t\troutes: (path) => wireOf(this.#reader).routes(path),\n\t\t});\n\t}\n\n\t/**\n\t * Settles once the origin closes: `null` on a clean close, or the abort {@link Error}.\n\t * Peek it synchronously (`undefined` while open), observe it reactively, or `await` it.\n\t */\n\tget closed(): GetPromise<Error | null> {\n\t\treturn this.#state.closed;\n\t}\n\n\t/**\n\t * Create a broadcast at `path`, returning its producer.\n\t *\n\t * The broadcast exists for nobody until {@link broadcast.Producer.announce}: announce\n\t * streams skip it and requests for its path find nothing, on this origin exactly as at\n\t * a peer. Announce once its tracks exist; {@link broadcast.Producer.unannounce}\n\t * withdraws it from everyone again.\n\t *\n\t * Close the producer to drop it. Creating a path again supersedes the previous\n\t * broadcast: the origin drops its handle on the old one, which closes it unless the\n\t * application still holds a consumer clone. An announced local broadcast competes with\n\t * a remote route at the same path on cost, winning ties.\n\t */\n\tcreateBroadcast(path: Path.Valid): broadcast.Producer {\n\t\tconst created = this.#state.created;\n\t\tif (!created) throw new Error(\"origin is closed\");\n\n\t\tconst producer = new broadcast.Producer();\n\t\tconst front = producer.consume();\n\n\t\thooks.attachAnnouncer(producer, {\n\t\t\tannounce: (route) => this.#advertiseExact(path, front, route),\n\t\t\tunannounce: () => this.#retractExact(path, front),\n\t\t});\n\n\t\tconst previous = created.get(path);\n\t\tcreated.set(path, front);\n\t\tif (previous) {\n\t\t\tthis.#retractExact(path, previous);\n\t\t\tprevious.close();\n\t\t}\n\n\t\t// Drop it when the broadcast closes, unless a recreate already replaced it: a\n\t\t// stale broadcast closing must not unpublish the live one.\n\t\tvoid front.closed.then(() => {\n\t\t\tthis.#retractExact(path, front);\n\t\t\tif (this.#state.created?.get(path) === front) this.#state.created.delete(path);\n\t\t});\n\n\t\treturn producer;\n\t}\n\n\t#advertiseExact(path: Path.Valid, front: broadcast.Consumer, route: Route): void {\n\t\tif (!this.#state.local.peek()) throw new Error(\"origin is closed\");\n\t\tif (this.#state.created?.get(path) !== front) throw new Error(\"broadcast is closed\");\n\t\t// Both maps move together, so every reader sees the broadcast and its route at once.\n\t\tthis.#state.local.mutate((broadcasts) => {\n\t\t\tbroadcasts?.set(path, front);\n\t\t});\n\t\tthis.#state.advertisedLocal.mutate((advertised) => {\n\t\t\tadvertised?.set(path, route);\n\t\t});\n\t\tthis.#state.rebuildOriginated();\n\t\tthis.#state.refresh(path);\n\t}\n\n\t#retractExact(path: Path.Valid, front: broadcast.Consumer): void {\n\t\tif (this.#state.local.peek()?.get(path) !== front) return;\n\t\tthis.#state.local.mutate((broadcasts) => {\n\t\t\tbroadcasts?.delete(path);\n\t\t});\n\t\tthis.#state.advertisedLocal.mutate((advertised) => {\n\t\t\tadvertised?.delete(path);\n\t\t});\n\t\tthis.#state.rebuildOriginated();\n\t\tthis.#state.refresh(path);\n\t}\n\n\t/**\n\t * Advertise `prefix` and serve the requests beneath it.\n\t *\n\t * A route is always a prefix: it claims `prefix` and every path beneath it (the\n\t * empty prefix claims every path). A service that only serves some of them\n\t * advertises the covering prefix and rejects the rest as they are requested;\n\t * consumers narrow with a {@link Path.Pattern} locally. The advertisement is\n\t * visible to {@link Consumer.announced} and forwarded by sessions for as long as\n\t * the returned {@link Dynamic} lives. A consumer resolving a path under it that\n\t * no announced local broadcast wins is handed to the handle as a {@link Request}.\n\t */\n\tdynamic(\n\t\tprefix: Path.Valid,\n\t\troute: Route | { hops?: Route[\"hops\"]; cost?: Route[\"cost\"] | bigint } = Route.default,\n\t): Dynamic {\n\t\treturn this.#insertRoute(prefix, Route.normalize(route), true);\n\t}\n\n\t/**\n\t * Land a route a peer announced, served through the returned handle. Same as\n\t * {@link dynamic} but not originated, so a session never announces it back.\n\t *\n\t * @internal\n\t */\n\t#receive(\n\t\tprefix: Path.Valid,\n\t\troute: Route | { hops?: Route[\"hops\"]; cost?: Route[\"cost\"] | bigint } = Route.default,\n\t): Dynamic {\n\t\treturn this.#insertRoute(prefix, Route.normalize(route), false);\n\t}\n\n\t#insertRoute(prefix: Path.Valid, route: Route, originated: boolean): Dynamic {\n\t\tconst server = new ServeState();\n\t\tserver.onChange = (path) => this.#state.refresh(path);\n\t\tconst entry: RouteEntry = {\n\t\t\tidentity: {},\n\t\t\troute: new Signal(route),\n\t\t\toriginated,\n\t\t\tserver,\n\t\t};\n\t\tserver.onReject = (path) => this.#state.refuse(path, entry);\n\n\t\tlet closed = false;\n\t\tthis.#state.routes.mutate((routes) => {\n\t\t\tif (!routes) {\n\t\t\t\tclosed = true;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst entries = routes.get(prefix);\n\t\t\tif (entries) entries.unshift(entry);\n\t\t\telse routes.set(prefix, [entry]);\n\t\t});\n\t\tif (closed) {\n\t\t\tserver.close();\n\t\t\treturn makeDynamic(prefix, entry, this.#state, () => {});\n\t\t}\n\t\tthis.#state.rebuildOriginated();\n\t\tthis.#state.refreshPrefix(prefix);\n\n\t\tconst retract = () => {\n\t\t\tthis.#state.routes.mutate((routes) => {\n\t\t\t\tconst entries = routes?.get(prefix);\n\t\t\t\tif (!entries) return;\n\t\t\t\tconst index = entries.indexOf(entry);\n\t\t\t\tif (index < 0) return;\n\t\t\t\tentries.splice(index, 1);\n\t\t\t\tif (entries.length === 0) routes?.delete(prefix);\n\t\t\t});\n\t\t\t// A retracted entry can never be picked again, so the refusals pinned to it are dead weight.\n\t\t\tfor (const slot of this.#state.requests.peek()?.values() ?? []) slot.refused.delete(entry);\n\t\t\tserver.close();\n\t\t\tthis.#state.rebuildOriginated();\n\t\t\tthis.#state.refreshPrefix(prefix);\n\t\t};\n\n\t\treturn makeDynamic(prefix, entry, this.#state, retract);\n\t}\n\n\t/**\n\t * Register an attached session, counting it toward the `discovery` state. Returns the\n\t * detach; call it exactly once when the session dies.\n\t *\n\t * @internal\n\t */\n\t#attach(discovery: boolean): Dispose {\n\t\tthis.#sessions(1, discovery);\n\t\tconst release = this.#expect();\n\t\tlet detached = false;\n\t\treturn () => {\n\t\t\tif (detached) return;\n\t\t\tdetached = true;\n\t\t\tthis.#sessions(-1, discovery);\n\t\t\trelease();\n\t\t};\n\t}\n\n\t#sessions(delta: number, discovery: boolean): void {\n\t\tthis.#state.sessions.update(({ total, discovery: d }) => ({\n\t\t\ttotal: total + delta,\n\t\t\tdiscovery: d + (discovery ? delta : 0),\n\t\t}));\n\t}\n\n\t/**\n\t * Declare that something will answer requests on this origin, even with no session\n\t * attached right now.\n\t *\n\t * A reconnecting connection holds one for its whole life, so a request made during a\n\t * reconnect (or before the first session establishes) stays pending instead of reading as\n\t * unroutable. Without it, {@link Request.unroutable} would fire on every page load, in the\n\t * window between wiring the origin up and the handshake completing. Call the returned\n\t * dispose when the connection is done for good.\n\t *\n\t * @internal\n\t */\n\t#expect(): Dispose {\n\t\tthis.#state.answerers.update((count) => count + 1);\n\t\tlet released = false;\n\t\treturn () => {\n\t\t\tif (released) return;\n\t\t\treleased = true;\n\t\t\t// Clamped because closing the origin zeroes the count, and the sessions attached at\n\t\t\t// the time still release afterwards.\n\t\t\tthis.#state.answerers.update((count) => Math.max(0, count - 1));\n\t\t};\n\t}\n\n\t/**\n\t * Resolves once anything a serving session scans changes: the open requests, or either\n\t * side of the routing table.\n\t *\n\t * @internal\n\t */\n\t#changed(): Promise<unknown> {\n\t\treturn Signal.race(this.#state.requests, this.#state.local, this.#state.routes, this.#state.advertisedLocal);\n\t}\n\n\t/**\n\t * Provide `front` as the answer for the open request on `path`, taking ownership of it.\n\t *\n\t * Returns undefined (releasing the front) when the request is gone or already answered;\n\t * first session in wins, and a loser must stay eligible to answer later. The returned\n\t * withdraw releases the front and, if it was the standing answer, vacates the slot and\n\t * wakes the other serving loops so a standby session answers immediately; call it when\n\t * the session dies.\n\t *\n\t * @internal\n\t */\n\t#answer(path: Path.Valid, front: broadcast.Consumer): Dispose | undefined {\n\t\tconst slot = this.#state.requests.peek()?.get(path);\n\t\tif (!slot || slot.answer !== undefined) {\n\t\t\tfront.close();\n\t\t\treturn undefined;\n\t\t}\n\t\tslot.answer = front;\n\t\tthis.#state.refresh(path);\n\n\t\treturn () => {\n\t\t\tif (slot.answer === front) {\n\t\t\t\tslot.answer = undefined;\n\t\t\t\tthis.#state.refresh(path);\n\t\t\t\t// The route signal only reaches this path's requesters; poke the map so every\n\t\t\t\t// serving loop re-scans and one of them re-answers.\n\t\t\t\tthis.#state.requests.mutate(() => {});\n\t\t\t}\n\t\t\tfront.close();\n\t\t};\n\t}\n\n\t/** A read handle for this origin, the side a connection's `publish` option borrows. */\n\tconsume(): Consumer {\n\t\treturn makeConsumer(this.#state);\n\t}\n\n\t/** Whether every attached session announces into the table; see {@link Consumer.discovery}. */\n\tget discovery(): Getter<boolean | undefined> {\n\t\treturn this.#reader.discovery;\n\t}\n\n\t/** Resolve `path`, optionally waiting for an announcement; see {@link Consumer.request}. */\n\trequest(path: Path.Valid, options?: RequestOptions): Requesting {\n\t\treturn this.#reader.request(path, options);\n\t}\n\n\t/** The available announcements under `scope`, as a live map; see {@link Consumer.broadcasts}. */\n\tbroadcasts(scope?: Path.Pattern, options?: announce.Options): Getter<ReadonlyMap<Path.Valid, Route>> {\n\t\treturn this.#reader.broadcasts(scope, options);\n\t}\n\n\t/** The available broadcasts under `scope`, as a live stream; see {@link Consumer.announced}. */\n\tannounced(scope?: Path.Pattern, options?: announce.Options): announce.Consumer {\n\t\treturn this.#reader.announced(scope, options);\n\t}\n\n\t/** Close the origin, every broadcast it still routes, and its announcement streams. Idempotent. */\n\tclose(abort?: Error) {\n\t\tif (this.#state.closed.peek() !== undefined) return;\n\t\tthis.#state.closed.set(abort ?? null);\n\t\tfor (const front of this.#state.created?.values() ?? []) {\n\t\t\tfront.close(abort);\n\t\t}\n\t\tthis.#state.created = undefined;\n\t\tthis.#state.local.update(() => undefined);\n\t\tthis.#state.advertisedLocal.update(() => undefined);\n\t\tthis.#state.routes.update((routes) => {\n\t\t\tfor (const entries of routes?.values() ?? []) {\n\t\t\t\tfor (const entry of entries) entry.server?.close(abort);\n\t\t\t}\n\t\t\treturn undefined;\n\t\t});\n\t\tthis.#state.originated.update(() => undefined);\n\t\t// Materialized broadcasts are handles we opened; release them.\n\t\tfor (const cached of this.#state.materialized.values()) {\n\t\t\tcached.front.close();\n\t\t}\n\t\tthis.#state.materialized.clear();\n\t\t// Nothing will answer a request on a closed origin, whatever is still attached, so\n\t\t// existing requests report unroutable rather than waiting on a corpse.\n\t\tthis.#state.answerers.set(0);\n\t\tthis.#state.requests.update((requests) => {\n\t\t\tfor (const slot of requests?.values() ?? []) {\n\t\t\t\tslot.answer?.close();\n\t\t\t\tslot.answer = undefined;\n\t\t\t\tslot.route.set(undefined);\n\t\t\t}\n\t\t\treturn undefined;\n\t\t});\n\t}\n}\n\n// Constructs a Consumer from within this module without exposing a public constructor\n// that would leak the unexported OriginState. Assigned in the class's static block.\nlet makeConsumer: (state: OriginState) => Consumer;\n\n// Same for Requesting: a public constructor would let a caller forge a handle that no origin\n// ever registered, whose lifecycle guarantees are then false. `@internal` alone would not\n// stop it, since the declaration emit keeps the constructor.\nlet makeRequesting: (\n\tpath: Path.Valid,\n\tactive: Getter<broadcast.Consumer | undefined>,\n\tunroutable: Getter<boolean>,\n\tdispose: Dispose,\n) => Requesting;\n\nlet makeDynamic: (prefix: Path.Valid, entry: RouteEntry, state: OriginState, retract: Dispose) => Dynamic;\n\nlet makeRequest: (path: Path.Valid, server: ServeState) => Request;\nlet finishRequest: (request: Request, err: Error) => void;\n\n/**\n * An open request for a path nothing announced; see {@link Consumer.request}.\n *\n * @public\n */\nexport class Requesting {\n\t/** The requested path. */\n\treadonly path: Path.Valid;\n\n\t/**\n\t * The resolved broadcast, or undefined while nothing provides the path.\n\t *\n\t * The table's route when it has one: a local publish (no round trip) or an announced\n\t * broadcast, swapping when a republish takes the path. Otherwise a session's blind\n\t * answer, which is assumed present rather than known live: a missing broadcast\n\t * surfaces as a reset on the first track subscription, not here. Drops back to\n\t * undefined when the providing route dies and resolves again when another appears.\n\t *\n\t * Yours for as long as the request is open: it is a handle of this request's own, so\n\t * closing it ends your view of the path rather than the route everyone else reads.\n\t * {@link close} releases whatever is current.\n\t */\n\treadonly active: Getter<broadcast.Consumer | undefined>;\n\n\t/**\n\t * Whether nothing can serve this path, as opposed to not having served it yet.\n\t *\n\t * True when the origin routes nothing here and nothing is prepared to answer: no session\n\t * attached and no connection reconnecting toward one. False whenever {@link active} is\n\t * set, and false while a connection is still coming up, so the ordinary page-load window\n\t * before the first handshake reads as pending rather than as a missing broadcast. Waiting\n\t * on this is futile by definition; wait for an announcement instead, via the origin's\n\t * `announced`.\n\t */\n\treadonly unroutable: Getter<boolean>;\n\n\t#dispose: Dispose;\n\t#closed = false;\n\n\tprivate constructor(\n\t\tpath: Path.Valid,\n\t\tactive: Getter<broadcast.Consumer | undefined>,\n\t\tunroutable: Getter<boolean>,\n\t\tdispose: Dispose,\n\t) {\n\t\tthis.path = path;\n\t\tthis.active = active;\n\t\tthis.unroutable = unroutable;\n\t\tthis.#dispose = dispose;\n\t}\n\n\tstatic {\n\t\tmakeRequesting = (path, active, unroutable, dispose) => new Requesting(path, active, unroutable, dispose);\n\t}\n\n\t/** Withdraw the request. The path stays routed for any other open request. Idempotent. */\n\tclose(): void {\n\t\tif (this.#closed) return;\n\t\tthis.#closed = true;\n\t\tthis.#dispose();\n\t}\n}\n\n/**\n * The read side of an origin: resolve broadcasts by path and watch what is available.\n *\n * Obtain one from {@link Producer.consume}. Pass it to a connection's `publish` option to\n * serve the origin's local broadcasts to that peer; read it directly to consume anything\n * the origin routes, locally published or discovered by a session.\n *\n * @public\n */\nexport class Consumer {\n\t#state: OriginState;\n\n\tprivate constructor(state: OriginState) {\n\t\tthis.#state = state;\n\t\t// True only when every attached session announces. One session that cannot means the\n\t\t// table is an incomplete picture, so a consumer gated on it has to keep its blind\n\t\t// fallback: the paths only that session carries never reach the table at all.\n\t\tthis.#discovery = new Derived([state.sessions], ({ total, discovery }) =>\n\t\t\ttotal === 0 ? undefined : discovery === total,\n\t\t);\n\t\tregisterWire(this, {\n\t\t\troutes: (path) => this.#routes(path),\n\t\t\tget broadcasts() {\n\t\t\t\treturn state.local;\n\t\t\t},\n\t\t\tget advertised() {\n\t\t\t\treturn state.originated;\n\t\t\t},\n\t\t\tlocal: (path) => this.#local(path),\n\t\t\tdemand: (path) => this.#demand(path),\n\t\t});\n\t}\n\n\tstatic {\n\t\tmakeConsumer = (state) => new Consumer(state);\n\t}\n\n\t/** Settles once the origin closes; see {@link Producer.closed}. */\n\tget closed(): GetPromise<Error | null> {\n\t\treturn this.#state.closed;\n\t}\n\n\t/**\n\t * Whether the announcement table sees everything the attached sessions can serve.\n\t *\n\t * Undefined while no session is attached (nothing is known yet), true when every attached\n\t * session announces into the table, and false as soon as one does not, where\n\t * {@link announced} cannot be complete and consumers should {@link request} paths instead\n\t * of waiting. One blind session among several is still false: the paths only it carries\n\t * never reach the table, so a consumer that trusted the gate would never see them.\n\t */\n\tget discovery(): Getter<boolean | undefined> {\n\t\treturn this.#discovery;\n\t}\n\n\t// Derived per access rather than cached: a lightweight mapped view over the session\n\t// counts, avoiding a Computed's lifecycle.\n\treadonly #discovery: Getter<boolean | undefined>;\n\n\t/**\n\t * Whether the table routes `path`, by an announced local publish or an announced\n\t * route covering it.\n\t *\n\t * Availability, not a handle: {@link request} is the only way to consume by path. A\n\t * request on a routed path resolves to that route and never to a blind answer, which is\n\t * why a serving session leaves it alone.\n\t *\n\t * @internal\n\t */\n\t#routes(path: Path.Valid): boolean {\n\t\tif (this.#state.local.peek()?.has(path)) return true;\n\t\treturn this.#state.bestEntry(path) !== undefined;\n\t}\n\n\t/**\n\t * Resolve `path`, optionally waiting for an announcement.\n\t *\n\t * The one way to consume by path. {@link Requesting.active} follows whatever the table\n\t * routes (an announced local publish, or any feeding session's announcement, swapping\n\t * on a republish or a retraction); when nothing does, the request stands and whichever\n\t * attached session answers first provides a blind subscription instead, re-answered\n\t * across reconnects.\n\t * With `announced: true`, an unrouted request waits while discovery is supported and\n\t * falls back to that blind behavior only when discovery is unavailable. Close the request\n\t * when done. On a closed origin it never resolves.\n\t *\n\t * With several sessions on one origin the first to answer wins, and it may be one that\n\t * does not carry the path. Nothing corrects that: a missing broadcast surfaces as a reset\n\t * on the first track and deliberately leaves the handle open, since the wire cannot tell\n\t * \"not here\" from \"not yet\" and a blind handle is expected to survive until a publisher\n\t * arrives. It matters only on an origin mixing sessions that announce with sessions that\n\t * cannot, where a path only the silent session carries may sit behind another session's\n\t * answer. Prefer {@link unroutable} and announcements over blind requests when the origin\n\t * feeds from more than one connection.\n\t */\n\trequest(path: Path.Valid, options: RequestOptions = {}): Requesting {\n\t\tconst requests = this.#state.requests.peek();\n\t\tif (!requests) {\n\t\t\t// Closed origin: a request that can never resolve, and says so.\n\t\t\treturn makeRequesting(path, new Signal<broadcast.Consumer | undefined>(undefined), getter(true), () => {});\n\t\t}\n\n\t\tlet slot = requests.get(path);\n\t\tif (!slot) {\n\t\t\t// Seeded through the constructor, so a path the table already routes resolves on the\n\t\t\t// first read. It must not go through a silent set: that still captures the pre-seed\n\t\t\t// value as the baseline the next change is compared against, and never flushes to\n\t\t\t// clear it, so a seeded route retracting to undefined would look like no change and\n\t\t\t// notify nobody.\n\t\t\tconst refused = new Set<RouteEntry>();\n\t\t\tconst created: RequestSlot = {\n\t\t\t\tcount: 0,\n\t\t\t\tblind: 0,\n\t\t\t\trefused,\n\t\t\t\troute: new Signal(this.#state.route(path, { refused })),\n\t\t\t};\n\t\t\tslot = created;\n\t\t\tthis.#state.requests.mutate((map) => {\n\t\t\t\tmap?.set(path, created);\n\t\t\t});\n\t\t}\n\t\tslot.count += 1;\n\t\tlet blind = !options.announced || this.#discovery.peek() === false;\n\t\tif (blind) slot.blind += 1;\n\t\tthis.#state.requests.mutate(() => {});\n\n\t\t// An announcement-gated request falls back to a blind subscription only while at\n\t\t// least one attached session cannot announce. It returns to the gate if discovery\n\t\t// becomes complete again, and remains gated with no session attached.\n\t\tconst unsubscribeDiscovery = options.announced\n\t\t\t? this.#discovery.subscribe((discovery) => {\n\t\t\t\t\tconst next = discovery === false;\n\t\t\t\t\tif (next === blind) return;\n\t\t\t\t\tblind = next;\n\t\t\t\t\tslot.blind += next ? 1 : -1;\n\t\t\t\t\tthis.#state.requests.mutate(() => {});\n\t\t\t\t})\n\t\t\t: () => {};\n\n\t\t// Hand out a handle of the request's own rather than the table's. Closing a consumer\n\t\t// closes the broadcast once it was the last one, and the table often holds the only\n\t\t// other handle, so lending its front out means an ordinary close() by one requester\n\t\t// can unpublish the path for everybody else.\n\t\tconst taken = slot;\n\n\t\t// Memoized on the route's identity: the same front resolving again returns the handle\n\t\t// we already made, and only a real swap clones a new one (cloning before closing the\n\t\t// old, so a broadcast that both routes share never briefly loses its last handle).\n\t\tlet released = false;\n\t\tlet source: broadcast.Consumer | undefined;\n\t\tlet handle: broadcast.Consumer | undefined;\n\t\tconst own = (front: broadcast.Consumer | undefined): broadcast.Consumer | undefined => {\n\t\t\tif (released) return undefined;\n\t\t\tif (front !== source) {\n\t\t\t\tconst previous = handle;\n\t\t\t\tsource = front;\n\t\t\t\thandle = front?.clone();\n\t\t\t\tprevious?.close();\n\t\t\t}\n\t\t\treturn handle;\n\t\t};\n\n\t\tconst route = taken.route;\n\t\tconst active = new Derived([route], own);\n\n\t\t// Swapping on the read is what keeps a routed path resolving synchronously, but a\n\t\t// holder that only ever peeked would then pin a route that has already been retracted\n\t\t// until it happened to read again. Following the route as well retires it promptly,\n\t\t// and the memo makes the two paths agree: whichever runs first does the swap.\n\t\tconst unsubscribe = route.subscribe(own);\n\n\t\t// Only meaningful while nothing is routed, so it reads the route rather than `active`:\n\t\t// the two cannot disagree, since a routed path always has an answerer-independent\n\t\t// answer.\n\t\tconst unroutable = new Derived([route, this.#state.answerers], (front, answerers) => !front && answerers === 0);\n\n\t\treturn makeRequesting(path, active, unroutable, () => {\n\t\t\t// Releases this request's handle; the route itself belongs to the table.\n\t\t\treleased = true;\n\t\t\tunsubscribeDiscovery();\n\t\t\tunsubscribe();\n\t\t\thandle?.close();\n\t\t\thandle = undefined;\n\t\t\tsource = undefined;\n\n\t\t\ttaken.count -= 1;\n\t\t\tif (blind) taken.blind -= 1;\n\t\t\tthis.#state.requests.mutate(() => {});\n\t\t\tif (taken.count > 0) return;\n\n\t\t\t// Defer the teardown a microtask: an effect whose rerun was triggered by the\n\t\t\t// answer resolving closes its old request and takes a new one in the same tick,\n\t\t\t// and tearing down in between would drop the answer it is about to read.\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tif (taken.count > 0) return;\n\t\t\t\tthis.#state.requests.mutate((map) => {\n\t\t\t\t\tif (map?.get(path) === taken) map.delete(path);\n\t\t\t\t});\n\t\t\t\ttaken.answer?.close();\n\t\t\t\ttaken.answer = undefined;\n\t\t\t\ttaken.route.set(undefined);\n\t\t\t\tthis.#state.releaseMaterialized(path);\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * The announced routes matching `scope`, as a live map from covered prefix to route.\n\t * Local broadcasts appear once announced; received and dynamic routes retain their\n\t * advertised prefixes. Reads are synchronous, and the getter needs no teardown.\n\t * Hidden routes are left out unless `options.hidden` opts in (see {@link announce.Options}).\n\t * Unscoped readers share one snapshot; each distinct scope filters the table on changes.\n\t */\n\tbroadcasts(scope?: Path.Pattern, options?: announce.Options): Getter<ReadonlyMap<Path.Valid, Route>> {\n\t\tconst hidden = options?.hidden ?? false;\n\t\tif (!scope) return hidden ? this.#state.available : this.#state.visible;\n\t\treturn new Derived([this.#state.available], () => {\n\t\t\tconst routes = new Map<Path.Valid, Route>();\n\t\t\tfor (const [path, entry] of this.#listed(scope, hidden)) routes.set(path, entry.route);\n\t\t\treturn routes;\n\t\t});\n\t}\n\n\t/**\n\t * The announced routes matching `scope`, as a live stream: every currently advertised\n\t * route arrives first as active, then additions and retractions as they happen.\n\t * Any pattern is accepted. A local broadcast appears once it announces, exactly as a\n\t * peer sees it. A dynamic or received route announces the prefix it covers when its\n\t * subtree overlaps the scope. The stream ends when the origin closes or the consumer is\n\t * closed. Hidden routes are left out unless `options.hidden` opts in (see {@link announce.Options}).\n\t */\n\tannounced(scope: Path.Pattern = Path.Pattern.all(), options?: announce.Options): announce.Consumer {\n\t\tconst producer = new announce.Producer();\n\t\tvoid this.#runAnnounced(producer, scope, options?.hidden ?? false);\n\t\treturn producer.consume();\n\t}\n\n\t/** One snapshot shared by map readers and announcement-stream diffing. */\n\t#listed(scope: Path.Pattern, hidden: boolean): Map<Path.Valid, Presented> {\n\t\tconst next = new Map<Path.Valid, Presented>();\n\t\tconst { remote, local } = this.#state.snapshot();\n\t\tconst head = scopeHead(scope);\n\t\tfor (const [path, entry] of remote) {\n\t\t\tif (!scopeOverlaps(scope, path)) continue;\n\t\t\tif (!hidden && hiddenBelow(head, path)) continue;\n\t\t\tnext.set(path, { identity: entry.identity, route: entry.route, captures: scopeCaptures(scope, path) });\n\t\t}\n\t\tfor (const [path, entry] of local) {\n\t\t\tif (!scope.matches(path)) continue;\n\t\t\tif (!hidden && hiddenBelow(head, path)) continue;\n\t\t\tnext.set(path, { identity: entry.identity, route: entry.route, captures: scopeCaptures(scope, path) });\n\t\t}\n\t\treturn next;\n\t}\n\n\tasync #runAnnounced(producer: announce.Producer, scope: Path.Pattern, hidden: boolean): Promise<void> {\n\t\t// Keyed by the presented path (from the origin, not the scope), valued by identity\n\t\t// plus route. Diffing identity rather than mere presence means a republish emits a\n\t\t// retraction then a fresh announcement; a re-price of the same identity emits an\n\t\t// update.\n\t\tlet active = new Map<Path.Valid, Presented>();\n\n\t\ttry {\n\t\t\tfor (;;) {\n\t\t\t\tconst local = this.#state.local.peek();\n\t\t\t\tconst advertisedLocal = this.#state.advertisedLocal.peek();\n\t\t\t\tconst routes = this.#state.routes.peek();\n\t\t\t\tif (local === undefined && advertisedLocal === undefined && routes === undefined) break;\n\n\t\t\t\tconst next = this.#listed(scope, hidden);\n\n\t\t\t\tfor (const [path, snap] of active) {\n\t\t\t\t\tconst cur = next.get(path);\n\t\t\t\t\tif (!cur || cur.identity !== snap.identity)\n\t\t\t\t\t\tproducer.append({\n\t\t\t\t\t\t\tprefix: path,\n\t\t\t\t\t\t\tcaptures: snap.captures,\n\t\t\t\t\t\t\tkind: \"retracted\",\n\t\t\t\t\t\t\troute: snap.route,\n\t\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tfor (const [path, snap] of next) {\n\t\t\t\t\tconst prev = active.get(path);\n\t\t\t\t\tif (!prev || prev.identity !== snap.identity) {\n\t\t\t\t\t\tproducer.append({\n\t\t\t\t\t\t\tprefix: path,\n\t\t\t\t\t\t\tcaptures: snap.captures,\n\t\t\t\t\t\t\tkind: \"announced\",\n\t\t\t\t\t\t\troute: snap.route,\n\t\t\t\t\t\t});\n\t\t\t\t\t} else if (!routesEqual(prev.route, snap.route)) {\n\t\t\t\t\t\tproducer.append({ prefix: path, captures: snap.captures, kind: \"updated\", route: snap.route });\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tactive = next;\n\n\t\t\t\tawait Signal.race(this.#state.local, this.#state.advertisedLocal, this.#state.routes, producer.closed);\n\t\t\t\tif (producer.closed.peek() !== undefined) return;\n\t\t\t}\n\t\t} catch {\n\t\t\t// The reader closed between the check and an append; nothing left to do.\n\t\t}\n\t\tproducer.close();\n\t}\n\n\t/**\n\t * The local table, borrowed by the wire publishers to answer subscribes.\n\t *\n\t * Deliberately excludes received routes: a session never re-announces what a peer\n\t * told it, so an origin wired to both directions of a connection cannot echo.\n\t * Borrowed, not owned: do not close the fronts. Undefined once the origin closes.\n\t *\n\t * @internal\n\t */\n\t/**\n\t * Originated advertisements a session should forward: exact-path announces plus\n\t * originated dynamics. Undefined once the origin closes.\n\t *\n\t * @internal\n\t */\n\t/**\n\t * The announced local broadcast at `path`, when it beats the originated routes there.\n\t * Resolves through what rebuildOriginated advertised: a peer never sees received routes.\n\t */\n\t#local(path: Path.Valid): broadcast.Consumer | undefined {\n\t\tconst local = this.#state.local.peek()?.get(path);\n\t\tif (local && this.#state.localWins(path, this.#state.bestEntry(path, received))) return local;\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Resolve `path` for serving: an announced local broadcast, or wait for an originated\n\t * dynamic to accept it. Undefined when nothing here can serve the path.\n\t *\n\t * @internal\n\t */\n\tasync #demand(path: Path.Valid): Promise<broadcast.Consumer | undefined> {\n\t\tconst local = this.#local(path);\n\t\tif (local) return local;\n\t\tconst entry = this.#state.bestEntry(path, received);\n\t\tif (!entry?.server) return undefined;\n\n\t\tconst server = entry.server;\n\t\tconst live = server.served.get(path);\n\t\tif (live && live.closed.peek() === undefined) return live;\n\n\t\tserver.enqueue(path);\n\t\tserver.demanding.set(path, (server.demanding.get(path) ?? 0) + 1);\n\t\ttry {\n\t\t\tfor (;;) {\n\t\t\t\tconst served = server.served.get(path);\n\t\t\t\tif (served && served.closed.peek() === undefined) return served;\n\t\t\t\tconst rejected = server.rejected.get(path);\n\t\t\t\tif (rejected) {\n\t\t\t\t\tserver.rejected.delete(path);\n\t\t\t\t\tthrow rejected;\n\t\t\t\t}\n\t\t\t\tconst closed = server.closed.peek();\n\t\t\t\tif (closed !== undefined) {\n\t\t\t\t\tif (closed) throw closed;\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\tif (!server.pending.has(path)) return undefined;\n\t\t\t\tawait Signal.race(server.settled, server.closed);\n\t\t\t}\n\t\t} finally {\n\t\t\tconst n = (server.demanding.get(path) ?? 1) - 1;\n\t\t\tif (n <= 0) server.demanding.delete(path);\n\t\t\telse server.demanding.set(path, n);\n\t\t}\n\t}\n}\n\n/**\n * A served route from {@link Producer.dynamic}: advertises a prefix and answers the\n * requests beneath it.\n *\n * Drop it (or {@link close}) to retract the route and reject anything still waiting\n * with {@link StreamCode.NoCapacity}. {@link update} re-prices it in place.\n *\n * @public\n */\nexport class Dynamic {\n\t/** The prefix this handle advertises. */\n\treadonly prefix: Path.Valid;\n\n\t#entry: RouteEntry;\n\t#state: OriginState;\n\t#retract: Dispose;\n\t#closed = false;\n\n\tprivate constructor(prefix: Path.Valid, entry: RouteEntry, state: OriginState, retract: Dispose) {\n\t\tthis.prefix = prefix;\n\t\tthis.#entry = entry;\n\t\tthis.#state = state;\n\t\tthis.#retract = retract;\n\t}\n\n\tstatic {\n\t\tmakeDynamic = (prefix, entry, state, retract) => new Dynamic(prefix, entry, state, retract);\n\t}\n\n\t/** Re-price the route in place. The prefix is fixed at announce time. */\n\tupdate(route: Route | { hops?: Route[\"hops\"]; cost?: Route[\"cost\"] | bigint }): void {\n\t\tif (this.#closed) throw new Error(\"dynamic is closed\");\n\t\tthis.#entry.route.set(Route.normalize(route));\n\t\tthis.#state.rebuildOriginated();\n\t\tthis.#state.refreshPrefix(this.prefix);\n\t\tthis.#state.routes.mutate(() => {});\n\t}\n\n\t/** Retract the route and reject anything still waiting. Idempotent. */\n\tclose(): void {\n\t\tif (this.#closed) return;\n\t\tthis.#closed = true;\n\t\tthis.#retract();\n\t}\n\n\t/** Requests under this prefix, as they arrive, each to {@link Request.accept} or reject. */\n\tasync *requested(): AsyncIterableIterator<Request> {\n\t\tconst server = this.#entry.server;\n\t\tif (!server) return;\n\t\tlet current: Request | undefined;\n\t\tconst drop = () => {\n\t\t\tcurrent?.reject(noCapacity());\n\t\t\tcurrent = undefined;\n\t\t};\n\t\ttry {\n\t\t\tfor (;;) {\n\t\t\t\tconst next = server.queue.peek()[0];\n\t\t\t\tif (next) {\n\t\t\t\t\tdrop();\n\t\t\t\t\tserver.queue.mutate((queue) => {\n\t\t\t\t\t\tqueue.shift();\n\t\t\t\t\t});\n\t\t\t\t\tcurrent = next;\n\t\t\t\t\tyield next;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (server.closed.peek() !== undefined) return;\n\t\t\t\tawait Signal.race(server.queue, server.closed);\n\t\t\t}\n\t\t} finally {\n\t\t\tdrop();\n\t\t}\n\t}\n}\n\n/**\n * A pending request for a broadcast to be served on demand.\n *\n * Yielded by {@link Dynamic.requested}. {@link accept} resolves it with a live\n * broadcast; {@link reject} resolves it with an error. Advancing the iterator or\n * closing it without either rejects the request.\n *\n * @public\n */\nexport class Request {\n\t/** The path that was requested. */\n\treadonly path: Path.Valid;\n\n\t#server: ServeState;\n\t#done = false;\n\n\tprivate constructor(path: Path.Valid, server: ServeState) {\n\t\tthis.path = path;\n\t\tthis.#server = server;\n\t}\n\n\tstatic {\n\t\tmakeRequest = (path, server) => new Request(path, server);\n\t\tfinishRequest = (request, err) => {\n\t\t\trequest.#done = true;\n\t\t\tvoid err;\n\t\t};\n\t}\n\n\t/**\n\t * Accept the request, resolving every awaiting requester with `broadcast`.\n\t *\n\t * The caller keeps producing into `broadcast`; repeat requests for the path share\n\t * it for as long as it stays live.\n\t */\n\taccept(source: broadcast.Producer | broadcast.Consumer): void {\n\t\tif (this.#done) return;\n\t\tthis.#done = true;\n\t\tconst front = source instanceof broadcast.Producer ? source.consume() : source;\n\t\tthis.#server.accept(this, front);\n\t}\n\n\t/** Reject the request, resolving every awaiting requester with `err`. */\n\treject(err: Error): void {\n\t\tif (this.#done) return;\n\t\tthis.#done = true;\n\t\tthis.#server.reject(this, err);\n\t}\n}\n"]}
package/package.json CHANGED
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "name": "@moq/net",
3
3
  "type": "module",
4
- "version": "0.4.0",
4
+ "version": "0.4.1",
5
5
  "description": "The networking layer for Media over QUIC: real-time pub/sub with built-in caching, fan-out, and prioritization.",
6
6
  "license": "(MIT OR Apache-2.0)",
7
- "repository": "github:moq-dev/moq",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/moq-dev/moq.git",
10
+ "directory": "js/net"
11
+ },
8
12
  "sideEffects": false,
9
13
  "exports": {
10
14
  ".": {
@@ -19,7 +23,7 @@
19
23
  "dependencies": {
20
24
  "@moq/pattern": "^0.2.0",
21
25
  "@moq/qmux": "^0.3.3",
22
- "@moq/signals": "^0.2.4",
26
+ "@moq/signals": "^0.2.5",
23
27
  "async-mutex": "^0.5.0",
24
28
  "bowser": "^2.14.1"
25
29
  },
package/stream.d.ts CHANGED
@@ -50,8 +50,8 @@ export interface OpenOptions {
50
50
  }
51
51
  /** Options for {@link Writer.tryOpen}. */
52
52
  export interface TryOpenOptions extends OpenOptions {
53
- /** Give up once this settles, however it settles. */
54
- cancel: Promise<unknown>;
53
+ /** Give up once this resolves. */
54
+ cancel: Promise<void>;
55
55
  }
56
56
  export declare class Stream {
57
57
  reader: Reader;
package/stream.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAiBrD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,6BAA6B,GAAG;IAAE,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAAE,CAEnH;AA+BD;;;;;;;;;GASG;AACH,MAAM,MAAM,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC,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5E;IAED;;;;;;;OAOG;IACH,OAAa,OAAO,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAyB7F;CACD;AAqBD,qBAAa,OAAO;;IAInB,YAAY,IAAI,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,WAAW,EAKpD;IAEK,IAAI,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAIxC;IAED,KAAK,SAEJ;CACD"}
package/stream.js CHANGED
@@ -1,4 +1,5 @@
1
1
  /* @ts-self-types="./stream.d.ts" */
2
+ import { race } from "@moq/signals";
2
3
  import { fromTransport, StreamCode, StreamError, toStreamCode, toTransport } from "./error.js";
3
4
  import { Version } from "./ietf/version.js";
4
5
  import { TimeoutError, withTimeout } from "./util/timeout.js";
@@ -388,25 +389,29 @@ export class Writer {
388
389
  * an over-limit open instead of rejecting it.
389
390
  */
390
391
  static async tryOpen(quic, options) {
391
- // A rejected `cancel` (STOP_SENDING) means the peer is gone too, so both settle
392
- // paths mean "give up" and neither is left unhandled. Built before the open, and
393
- // raced ahead of it, so an already-cancelled caller wins even against a slot that
394
- // is free right now.
395
- const cancelled = options.cancel.then(() => undefined, () => undefined);
392
+ // Raced ahead of the open, so an already-cancelled caller wins even against a slot
393
+ // that is free right now. `race` rather than `Promise.race`: the caller shares one
394
+ // `cancel` across every group of a subscription, which must not gain a reaction per call.
396
395
  const open = Writer.open(quic, options);
396
+ // Resets a stream that opens after we gave up; a no-op if the open itself failed.
397
+ const abandon = () => {
398
+ const abandoned = new Error("abandoned waiting for a stream slot");
399
+ open.then((w) => w.reset(abandoned)).catch(() => void 0);
400
+ };
397
401
  try {
398
- const stream = await Promise.race([cancelled, open]);
402
+ const stream = await race([options.cancel, open]);
399
403
  if (stream)
400
404
  return stream;
401
405
  }
402
406
  catch (err) {
403
407
  // open already discarded the late stream on its way out.
404
- if (!(err instanceof TimeoutError))
405
- throw err;
406
- return undefined;
408
+ if (err instanceof TimeoutError)
409
+ return undefined;
410
+ // A rejected `cancel` still leaves the open pending.
411
+ abandon();
412
+ throw err;
407
413
  }
408
- const abandoned = new Error("abandoned waiting for a stream slot");
409
- open.then((w) => w.reset(abandoned)).catch(() => void 0);
414
+ abandon();
410
415
  return undefined;
411
416
  }
412
417
  }