@voltro/plugin-broadcast 0.85.0 → 0.87.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
1
  # Third-Party Notices — @voltro/plugin-broadcast
2
2
 
3
- This package depends on the open-source software listed below. Each is the
3
+ This package uses the open-source software listed below. Each is the
4
4
  property of its respective copyright holders and is used under the terms of
5
5
  its license. This file is provided for attribution; it grants no rights in
6
6
  @voltro/plugin-broadcast itself, which is proprietary (see LICENSE).
7
7
 
8
- Generated from the resolved runtime dependency closure (19 packages).
8
+ Generated from the resolved runtime dependency closure (18 packages).
9
9
 
10
10
  ---
11
11
 
@@ -870,6 +870,34 @@ Apache License
870
870
  limitations under the License.
871
871
  ```
872
872
 
873
+ ## @upstash/redis@1.38.4
874
+
875
+ License: MIT
876
+
877
+ ```
878
+ The MIT License (MIT)
879
+
880
+ Copyright (c) 2021 Upstash, Inc.
881
+
882
+ Permission is hereby granted, free of charge, to any person obtaining a copy
883
+ of this software and associated documentation files (the "Software"), to deal
884
+ in the Software without restriction, including without limitation the rights
885
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
886
+ copies of the Software, and to permit persons to whom the Software is
887
+ furnished to do so, subject to the following conditions:
888
+
889
+ The above copyright notice and this permission notice shall be included in all
890
+ copies or substantial portions of the Software.
891
+
892
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
893
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
894
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
895
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
896
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
897
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
898
+ SOFTWARE.
899
+ ```
900
+
873
901
  ## cluster-key-slot@1.1.1
874
902
 
875
903
  License: Apache-2.0
@@ -1180,34 +1208,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1180
1208
  SOFTWARE.
1181
1209
  ```
1182
1210
 
1183
- ## layerr@3.0.0
1184
-
1185
- License: MIT
1186
-
1187
- ```
1188
- MIT License
1189
-
1190
- Copyright (c) 2020 Perry Mitchell
1191
-
1192
- Permission is hereby granted, free of charge, to any person obtaining a copy
1193
- of this software and associated documentation files (the "Software"), to deal
1194
- in the Software without restriction, including without limitation the rights
1195
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1196
- copies of the Software, and to permit persons to whom the Software is
1197
- furnished to do so, subject to the following conditions:
1198
-
1199
- The above copyright notice and this permission notice shall be included in all
1200
- copies or substantial portions of the Software.
1201
-
1202
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1203
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1204
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1205
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1206
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1207
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1208
- SOFTWARE.
1209
- ```
1210
-
1211
1211
  ## ms@2.1.3
1212
1212
 
1213
1213
  License: MIT
@@ -1352,222 +1352,14 @@ OTHER DEALINGS IN THE SOFTWARE.
1352
1352
  For more information, please refer to <http://unlicense.org>
1353
1353
  ```
1354
1354
 
1355
- ## typeid-js@1.2.0
1356
-
1357
- License: Apache-2.0
1358
-
1359
- ```
1360
- Apache License
1361
- Version 2.0, January 2004
1362
- http://www.apache.org/licenses/
1363
-
1364
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1365
-
1366
- 1. Definitions.
1367
-
1368
- "License" shall mean the terms and conditions for use, reproduction,
1369
- and distribution as defined by Sections 1 through 9 of this document.
1370
-
1371
- "Licensor" shall mean the copyright owner or entity authorized by
1372
- the copyright owner that is granting the License.
1373
-
1374
- "Legal Entity" shall mean the union of the acting entity and all
1375
- other entities that control, are controlled by, or are under common
1376
- control with that entity. For the purposes of this definition,
1377
- "control" means (i) the power, direct or indirect, to cause the
1378
- direction or management of such entity, whether by contract or
1379
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
1380
- outstanding shares, or (iii) beneficial ownership of such entity.
1381
-
1382
- "You" (or "Your") shall mean an individual or Legal Entity
1383
- exercising permissions granted by this License.
1384
-
1385
- "Source" form shall mean the preferred form for making modifications,
1386
- including but not limited to software source code, documentation
1387
- source, and configuration files.
1388
-
1389
- "Object" form shall mean any form resulting from mechanical
1390
- transformation or translation of a Source form, including but
1391
- not limited to compiled object code, generated documentation,
1392
- and conversions to other media types.
1393
-
1394
- "Work" shall mean the work of authorship, whether in Source or
1395
- Object form, made available under the License, as indicated by a
1396
- copyright notice that is included in or attached to the work
1397
- (an example is provided in the Appendix below).
1398
-
1399
- "Derivative Works" shall mean any work, whether in Source or Object
1400
- form, that is based on (or derived from) the Work and for which the
1401
- editorial revisions, annotations, elaborations, or other modifications
1402
- represent, as a whole, an original work of authorship. For the purposes
1403
- of this License, Derivative Works shall not include works that remain
1404
- separable from, or merely link (or bind by name) to the interfaces of,
1405
- the Work and Derivative Works thereof.
1406
-
1407
- "Contribution" shall mean any work of authorship, including
1408
- the original version of the Work and any modifications or additions
1409
- to that Work or Derivative Works thereof, that is intentionally
1410
- submitted to Licensor for inclusion in the Work by the copyright owner
1411
- or by an individual or Legal Entity authorized to submit on behalf of
1412
- the copyright owner. For the purposes of this definition, "submitted"
1413
- means any form of electronic, verbal, or written communication sent
1414
- to the Licensor or its representatives, including but not limited to
1415
- communication on electronic mailing lists, source code control systems,
1416
- and issue tracking systems that are managed by, or on behalf of, the
1417
- Licensor for the purpose of discussing and improving the Work, but
1418
- excluding communication that is conspicuously marked or otherwise
1419
- designated in writing by the copyright owner as "Not a Contribution."
1420
-
1421
- "Contributor" shall mean Licensor and any individual or Legal Entity
1422
- on behalf of whom a Contribution has been received by Licensor and
1423
- subsequently incorporated within the Work.
1424
-
1425
- 2. Grant of Copyright License. Subject to the terms and conditions of
1426
- this License, each Contributor hereby grants to You a perpetual,
1427
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
1428
- copyright license to reproduce, prepare Derivative Works of,
1429
- publicly display, publicly perform, sublicense, and distribute the
1430
- Work and such Derivative Works in Source or Object form.
1431
-
1432
- 3. Grant of Patent License. Subject to the terms and conditions of
1433
- this License, each Contributor hereby grants to You a perpetual,
1434
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
1435
- (except as stated in this section) patent license to make, have made,
1436
- use, offer to sell, sell, import, and otherwise transfer the Work,
1437
- where such license applies only to those patent claims licensable
1438
- by such Contributor that are necessarily infringed by their
1439
- Contribution(s) alone or by combination of their Contribution(s)
1440
- with the Work to which such Contribution(s) was submitted. If You
1441
- institute patent litigation against any entity (including a
1442
- cross-claim or counterclaim in a lawsuit) alleging that the Work
1443
- or a Contribution incorporated within the Work constitutes direct
1444
- or contributory patent infringement, then any patent licenses
1445
- granted to You under this License for that Work shall terminate
1446
- as of the date such litigation is filed.
1447
-
1448
- 4. Redistribution. You may reproduce and distribute copies of the
1449
- Work or Derivative Works thereof in any medium, with or without
1450
- modifications, and in Source or Object form, provided that You
1451
- meet the following conditions:
1452
-
1453
- (a) You must give any other recipients of the Work or
1454
- Derivative Works a copy of this License; and
1455
-
1456
- (b) You must cause any modified files to carry prominent notices
1457
- stating that You changed the files; and
1458
-
1459
- (c) You must retain, in the Source form of any Derivative Works
1460
- that You distribute, all copyright, patent, trademark, and
1461
- attribution notices from the Source form of the Work,
1462
- excluding those notices that do not pertain to any part of
1463
- the Derivative Works; and
1464
-
1465
- (d) If the Work includes a "NOTICE" text file as part of its
1466
- distribution, then any Derivative Works that You distribute must
1467
- include a readable copy of the attribution notices contained
1468
- within such NOTICE file, excluding those notices that do not
1469
- pertain to any part of the Derivative Works, in at least one
1470
- of the following places: within a NOTICE text file distributed
1471
- as part of the Derivative Works; within the Source form or
1472
- documentation, if provided along with the Derivative Works; or,
1473
- within a display generated by the Derivative Works, if and
1474
- wherever such third-party notices normally appear. The contents
1475
- of the NOTICE file are for informational purposes only and
1476
- do not modify the License. You may add Your own attribution
1477
- notices within Derivative Works that You distribute, alongside
1478
- or as an addendum to the NOTICE text from the Work, provided
1479
- that such additional attribution notices cannot be construed
1480
- as modifying the License.
1481
-
1482
- You may add Your own copyright statement to Your modifications and
1483
- may provide additional or different license terms and conditions
1484
- for use, reproduction, or distribution of Your modifications, or
1485
- for any such Derivative Works as a whole, provided Your use,
1486
- reproduction, and distribution of the Work otherwise complies with
1487
- the conditions stated in this License.
1488
-
1489
- 5. Submission of Contributions. Unless You explicitly state otherwise,
1490
- any Contribution intentionally submitted for inclusion in the Work
1491
- by You to the Licensor shall be under the terms and conditions of
1492
- this License, without any additional terms or conditions.
1493
- Notwithstanding the above, nothing herein shall supersede or modify
1494
- the terms of any separate license agreement you may have executed
1495
- with Licensor regarding such Contributions.
1496
-
1497
- 6. Trademarks. This License does not grant permission to use the trade
1498
- names, trademarks, service marks, or product names of the Licensor,
1499
- except as required for reasonable and customary use in describing the
1500
- origin of the Work and reproducing the content of the NOTICE file.
1501
-
1502
- 7. Disclaimer of Warranty. Unless required by applicable law or
1503
- agreed to in writing, Licensor provides the Work (and each
1504
- Contributor provides its Contributions) on an "AS IS" BASIS,
1505
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
1506
- implied, including, without limitation, any warranties or conditions
1507
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
1508
- PARTICULAR PURPOSE. You are solely responsible for determining the
1509
- appropriateness of using or redistributing the Work and assume any
1510
- risks associated with Your exercise of permissions under this License.
1511
-
1512
- 8. Limitation of Liability. In no event and under no legal theory,
1513
- whether in tort (including negligence), contract, or otherwise,
1514
- unless required by applicable law (such as deliberate and grossly
1515
- negligent acts) or agreed to in writing, shall any Contributor be
1516
- liable to You for damages, including any direct, indirect, special,
1517
- incidental, or consequential damages of any character arising as a
1518
- result of this License or out of the use or inability to use the
1519
- Work (including but not limited to damages for loss of goodwill,
1520
- work stoppage, computer failure or malfunction, or any and all
1521
- other commercial damages or losses), even if such Contributor
1522
- has been advised of the possibility of such damages.
1523
-
1524
- 9. Accepting Warranty or Additional Liability. While redistributing
1525
- the Work or Derivative Works thereof, You may choose to offer,
1526
- and charge a fee for, acceptance of support, warranty, indemnity,
1527
- or other liability obligations and/or rights consistent with this
1528
- License. However, in accepting such obligations, You may act only
1529
- on Your own behalf and on Your sole responsibility, not on behalf
1530
- of any other Contributor, and only if You agree to indemnify,
1531
- defend, and hold each Contributor harmless for any liability
1532
- incurred by, or claims asserted against, such Contributor by reason
1533
- of your accepting any such warranty or additional liability.
1534
-
1535
- END OF TERMS AND CONDITIONS
1536
-
1537
- APPENDIX: How to apply the Apache License to your work.
1538
-
1539
- To apply the Apache License to your work, attach the following
1540
- boilerplate notice, with the fields enclosed by brackets "[]"
1541
- replaced with your own identifying information. (Don't include
1542
- the brackets!) The text should be enclosed in the appropriate
1543
- comment syntax for the file format. We also recommend that a
1544
- file or class name and description of purpose be included on the
1545
- same "printed page" as the copyright notice for easier
1546
- identification within third-party archives.
1547
-
1548
- Copyright [yyyy] [name of copyright owner]
1549
-
1550
- Licensed under the Apache License, Version 2.0 (the "License");
1551
- you may not use this file except in compliance with the License.
1552
- You may obtain a copy of the License at
1553
-
1554
- http://www.apache.org/licenses/LICENSE-2.0
1555
-
1556
- Unless required by applicable law or agreed to in writing, software
1557
- distributed under the License is distributed on an "AS IS" BASIS,
1558
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1559
- See the License for the specific language governing permissions and
1560
- limitations under the License.
1561
- ```
1562
-
1563
- ## ulidx@2.4.1
1355
+ ## ulid@3.0.2
1564
1356
 
1565
1357
  License: MIT
1566
1358
 
1567
1359
  ```
1568
- MIT License
1360
+ The MIT License (MIT)
1569
1361
 
1570
- Copyright (c) 2021 Perry Mitchell
1362
+ Copyright (c) 2017 Alizain Feerasta
1571
1363
 
1572
1364
  Permission is hereby granted, free of charge, to any person obtaining a copy
1573
1365
  of this software and associated documentation files (the "Software"), to deal
@@ -1588,19 +1380,31 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1588
1380
  SOFTWARE.
1589
1381
  ```
1590
1382
 
1591
- ## uuid@11.1.1
1383
+ ## uncrypto@0.1.3
1592
1384
 
1593
1385
  License: MIT
1594
1386
 
1595
1387
  ```
1596
- The MIT License (MIT)
1388
+ MIT License
1597
1389
 
1598
- Copyright (c) 2010-2020 Robert Kieffer and other contributors
1390
+ Copyright (c) Pooya Parsa <pooya@pi0.io>
1599
1391
 
1600
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
1392
+ Permission is hereby granted, free of charge, to any person obtaining a copy
1393
+ of this software and associated documentation files (the "Software"), to deal
1394
+ in the Software without restriction, including without limitation the rights
1395
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1396
+ copies of the Software, and to permit persons to whom the Software is
1397
+ furnished to do so, subject to the following conditions:
1601
1398
 
1602
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
1399
+ The above copyright notice and this permission notice shall be included in all
1400
+ copies or substantial portions of the Software.
1603
1401
 
1604
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1402
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1403
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1404
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1405
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1406
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1407
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1408
+ SOFTWARE.
1605
1409
  ```
1606
1410
 
package/dist/bus.js ADDED
@@ -0,0 +1,181 @@
1
+ import { BROADCAST_CHANNEL as e } from "./types.js";
2
+ import { createPublishQueue as t } from "./publishQueue.js";
3
+ import { Effect as n, Metric as r } from "effect";
4
+ //#region src/bus.ts
5
+ var i = ({ origin: e, ...t }) => t, a = (e) => Math.min(500 * 2 ** Math.min(Math.max(e, 1) - 1, 5), 1e4), o = {
6
+ info: () => {},
7
+ warn: () => {},
8
+ debug: () => {}
9
+ }, s = async (s) => {
10
+ let { store: c, provider: l, replicaId: u } = s, d = s.logger ?? o, f = s.channel ?? e, p = !1, m, h = 0, g = /* @__PURE__ */ new Map(), _ = `${Date.now().toString(36)}.${Math.random().toString(36).slice(2, 10)}`, v = r.gauge("voltro_broadcast_connected").pipe(r.withAttributes({ provider: l.name })), y = r.counter("voltro_broadcast_gaps_total").pipe(r.withAttributes({ provider: l.name })), b = r.counter("voltro_broadcast_missed_total").pipe(r.withAttributes({ provider: l.name })), x = r.counter("voltro_broadcast_reconnects_total").pipe(r.withAttributes({ provider: l.name })), S = {
11
+ connected: !1,
12
+ lastReceivedAt: null,
13
+ lastPublishedAt: null,
14
+ reconnects: 0,
15
+ gaps: 0,
16
+ missed: 0
17
+ }, C = (e) => {
18
+ S.connected = e, n.runSync(r.update(v, +!!e));
19
+ };
20
+ C(!1);
21
+ let w = (e) => {
22
+ S.gaps += 1, n.runSync(r.update(y, 1)), e.missed !== void 0 && e.missed > 0 && (S.missed += e.missed, n.runSync(r.update(b, e.missed))), d.warn(`broadcast: ${e.reason} — refreshing live queries, which is safe because a query is idempotent`, {
23
+ ...e.origin === void 0 ? {} : { origin: e.origin },
24
+ ...e.missed === void 0 ? {} : { missed: e.missed }
25
+ });
26
+ try {
27
+ s.onGap?.(e);
28
+ } catch (e) {
29
+ d.warn("broadcast: gap recovery threw", { err: e });
30
+ }
31
+ }, T = (e) => {
32
+ if (O) return;
33
+ S.lastReceivedAt = Date.now();
34
+ let t;
35
+ try {
36
+ t = JSON.parse(e);
37
+ } catch {
38
+ d.warn("broadcast: bad payload (not JSON)", { channel: f });
39
+ return;
40
+ }
41
+ if (t.origin === u || !t.event || typeof t.event != "object") return;
42
+ let n = !1;
43
+ if (typeof t.n == "number" && Number.isFinite(t.n)) {
44
+ let e = t.epoch ?? "", r = g.get(t.origin);
45
+ if (r === void 0) g.set(t.origin, {
46
+ epoch: e,
47
+ n: t.n
48
+ });
49
+ else if (r.epoch !== e) g.set(t.origin, {
50
+ epoch: e,
51
+ n: t.n
52
+ });
53
+ else {
54
+ let i = t.n - r.n - (t.resync === !0 ? 0 : 1);
55
+ i > 0 && (n = !0, w({
56
+ reason: `missed ${i} change(s) from ${t.origin}`,
57
+ origin: t.origin,
58
+ missed: i
59
+ })), t.n > r.n && g.set(t.origin, {
60
+ epoch: e,
61
+ n: t.n
62
+ });
63
+ }
64
+ }
65
+ if (t.resync === !0) {
66
+ n || w({
67
+ reason: `the ${t.origin} publisher lost changes and requested a resync`,
68
+ origin: t.origin
69
+ });
70
+ return;
71
+ }
72
+ let r = i(t.event);
73
+ p = !0, m = r;
74
+ try {
75
+ c.injectExternalChange(r);
76
+ } catch (e) {
77
+ d.warn("broadcast: inject failed", { err: e });
78
+ } finally {
79
+ p = !1, m = void 0;
80
+ }
81
+ }, E = t(l, f, (e) => JSON.stringify({
82
+ origin: u,
83
+ epoch: _,
84
+ n: e,
85
+ resync: !0,
86
+ event: {
87
+ table: "",
88
+ op: "update",
89
+ old: null,
90
+ new: null
91
+ }
92
+ }), (e) => {
93
+ d.warn(`broadcast: ${e}`, {
94
+ provider: l.name,
95
+ channel: f
96
+ });
97
+ }, s.publishQueue, () => {
98
+ S.lastPublishedAt = Date.now();
99
+ }), D, O = !1, k = 0, A = async () => {
100
+ try {
101
+ return D = await n.runPromise(l.subscribe(f, T)), O ? (D(), D = void 0, !1) : (C(!0), !0);
102
+ } catch (e) {
103
+ return k += 1, k === 1 && d.warn("broadcast: could not subscribe — this replica will not receive other replicas' changes yet. Retrying in the background; local reactivity is unaffected.", {
104
+ provider: l.name,
105
+ channel: f,
106
+ err: e
107
+ }), !1;
108
+ }
109
+ };
110
+ await A() || (async () => {
111
+ let e = Date.now();
112
+ for (; !O && D === void 0;) {
113
+ if (await new Promise((e) => setTimeout(e, a(k))), O) return;
114
+ if (await A()) {
115
+ d.info("broadcast: subscribed", {
116
+ provider: l.name,
117
+ channel: f,
118
+ attempts: k
119
+ }), w({ reason: `this replica was not subscribed to '${f}' for ${Math.round((Date.now() - e) / 1e3)}s` });
120
+ return;
121
+ }
122
+ }
123
+ })();
124
+ let j = l.onTransportEvent?.((e) => {
125
+ O || (e.kind === "disconnected" ? (C(!1), d.warn("broadcast: transport disconnected — cross-replica fan-out is down until it re-dials", {
126
+ provider: l.name,
127
+ ...e.detail === void 0 ? {} : { detail: e.detail }
128
+ })) : (C(!0), S.reconnects += 1, n.runSync(r.update(x, 1)), d.warn("broadcast transport reconnected", {
129
+ provider: l.name,
130
+ channel: f,
131
+ replicaId: u,
132
+ reconnects: S.reconnects,
133
+ lastReceivedAt: S.lastReceivedAt
134
+ }), w({ reason: `the ${l.name} transport reconnected after an outage` })));
135
+ }), M = c.onChange((e) => {
136
+ if (e.origin === "injected" || p && e === m) return;
137
+ h += 1;
138
+ let t = {
139
+ origin: u,
140
+ event: e,
141
+ n: h,
142
+ epoch: _
143
+ };
144
+ E.enqueue(() => JSON.stringify(t), h);
145
+ });
146
+ d.info("broadcast bus attached", {
147
+ provider: l.name,
148
+ channel: f,
149
+ replicaId: u
150
+ });
151
+ let N;
152
+ return {
153
+ health: () => ({
154
+ provider: l.name,
155
+ channel: f,
156
+ replicaId: u,
157
+ ...S
158
+ }),
159
+ close: () => (N ??= (async () => {
160
+ O = !0, M(), j?.(), C(!1);
161
+ try {
162
+ D?.();
163
+ } catch {}
164
+ await E.close();
165
+ let e = new AbortController(), t, r = n.runPromise(l.close(), { signal: e.signal }).catch((e) => {
166
+ d.warn("broadcast: provider close failed", { error: e });
167
+ });
168
+ try {
169
+ await Promise.race([r, new Promise((n) => {
170
+ t = setTimeout(() => {
171
+ d.warn("broadcast: provider shutdown timed out"), e.abort(), n();
172
+ }, s.publishQueue?.shutdownTimeoutMs ?? 1e3);
173
+ })]);
174
+ } finally {
175
+ t !== void 0 && clearTimeout(t);
176
+ }
177
+ })(), N)
178
+ };
179
+ };
180
+ //#endregion
181
+ export { s as attachBroadcastBus, a as subscribeRetryDelayMs, i as withoutWireOrigin };