@use-everywhere/core 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.cjs +45 -28
- package/dist/index.d.cts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +45 -28
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -161,7 +161,7 @@ tabB.getSnapshot().n; // 1
|
|
|
161
161
|
- SSR-safe: without `BroadcastChannel`, engines fall back to a local no-op
|
|
162
162
|
transport.
|
|
163
163
|
|
|
164
|
-
📖 **[Documentation](https://rxova.
|
|
164
|
+
📖 **[Documentation](https://rxova.org/packages/use-everywhere/)** — mental
|
|
165
165
|
model, how sync works, security model, recipes, and generated API reference.
|
|
166
166
|
Source and demo app (with a real cross-origin payment flow):
|
|
167
167
|
[github.com/rxova/use-everywhere](https://github.com/rxova/use-everywhere)
|
package/dist/index.cjs
CHANGED
|
@@ -56,6 +56,26 @@ module.exports = __toCommonJS(src_exports);
|
|
|
56
56
|
// src/defaults.ts
|
|
57
57
|
var DEFAULT_NAME = "use-everywhere";
|
|
58
58
|
|
|
59
|
+
// src/dev.ts
|
|
60
|
+
var inDev = false;
|
|
61
|
+
try {
|
|
62
|
+
inDev = process.env.NODE_ENV !== "production";
|
|
63
|
+
} catch {
|
|
64
|
+
}
|
|
65
|
+
var warned = /* @__PURE__ */ new Set();
|
|
66
|
+
var DOCS = "https://rxova.org/packages/use-everywhere/errors";
|
|
67
|
+
function diagnostic(code, message) {
|
|
68
|
+
return `[use-everywhere] ${code}: ${message}
|
|
69
|
+
\u2192 ${DOCS}/#${code.toLowerCase()}`;
|
|
70
|
+
}
|
|
71
|
+
function devWarn(code, message) {
|
|
72
|
+
if (!inDev) return;
|
|
73
|
+
const line = diagnostic(code, message);
|
|
74
|
+
if (warned.has(line)) return;
|
|
75
|
+
warned.add(line);
|
|
76
|
+
console.warn(line);
|
|
77
|
+
}
|
|
78
|
+
|
|
59
79
|
// src/debug.ts
|
|
60
80
|
var observers = /* @__PURE__ */ new Map();
|
|
61
81
|
function emitBusEvent(name, direction, wire) {
|
|
@@ -66,7 +86,7 @@ function emitBusEvent(name, direction, wire) {
|
|
|
66
86
|
try {
|
|
67
87
|
fn(event);
|
|
68
88
|
} catch (error) {
|
|
69
|
-
console.error(`
|
|
89
|
+
console.error(diagnostic("UE1012", `a bus observer for "${name}" threw`), error);
|
|
70
90
|
}
|
|
71
91
|
}
|
|
72
92
|
}
|
|
@@ -93,19 +113,6 @@ function enableDebug(options = {}) {
|
|
|
93
113
|
});
|
|
94
114
|
}
|
|
95
115
|
|
|
96
|
-
// src/dev.ts
|
|
97
|
-
var inDev = false;
|
|
98
|
-
try {
|
|
99
|
-
inDev = process.env.NODE_ENV !== "production";
|
|
100
|
-
} catch {
|
|
101
|
-
}
|
|
102
|
-
var warned = /* @__PURE__ */ new Set();
|
|
103
|
-
function devWarn(message) {
|
|
104
|
-
if (!inDev || warned.has(message)) return;
|
|
105
|
-
warned.add(message);
|
|
106
|
-
console.warn(message);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
116
|
// src/ids.ts
|
|
110
117
|
function randomHex(bytes) {
|
|
111
118
|
const crypto = globalThis.crypto;
|
|
@@ -117,7 +124,8 @@ function randomHex(bytes) {
|
|
|
117
124
|
}
|
|
118
125
|
if (process.env.NODE_ENV !== "production") {
|
|
119
126
|
devWarn(
|
|
120
|
-
"
|
|
127
|
+
"UE1006",
|
|
128
|
+
"crypto.getRandomValues is unavailable; falling back to Math.random for ids. Cross-origin window nonces are not cryptographically strong in this environment."
|
|
121
129
|
);
|
|
122
130
|
}
|
|
123
131
|
let out = "";
|
|
@@ -145,7 +153,8 @@ function announce() {
|
|
|
145
153
|
if (census.protocols.length > 1) {
|
|
146
154
|
if (process.env.NODE_ENV !== "production") {
|
|
147
155
|
devWarn(
|
|
148
|
-
|
|
156
|
+
"UE1008",
|
|
157
|
+
`two incompatible versions of this library are loaded on one page (rendezvous protocols ${census.protocols.join(", ")}). They will not share a client identity: expect one presence entry per version and no synchronous delivery between them. They still sync over the bus. Align the versions to fix it.`
|
|
149
158
|
);
|
|
150
159
|
}
|
|
151
160
|
}
|
|
@@ -218,7 +227,7 @@ var jsonSerializer = {
|
|
|
218
227
|
const type = lossyType(this[key], forJson);
|
|
219
228
|
if (type) {
|
|
220
229
|
throw new TypeError(
|
|
221
|
-
`use-everywhere: ${key ? `"${key}" is ` : ""}${type}, which JSON cannot round-trip. https://rxova.org/guides/serialization/`
|
|
230
|
+
`use-everywhere: ${key ? `"${key}" is ` : ""}${type}, which JSON cannot round-trip. https://rxova.org/packages/use-everywhere/guides/serialization/`
|
|
222
231
|
);
|
|
223
232
|
}
|
|
224
233
|
return forJson;
|
|
@@ -235,7 +244,10 @@ var StorageTransport = class {
|
|
|
235
244
|
this.seq = 0;
|
|
236
245
|
if (!storage) {
|
|
237
246
|
throw new Error(
|
|
238
|
-
|
|
247
|
+
diagnostic(
|
|
248
|
+
"UE1011",
|
|
249
|
+
"StorageTransport needs localStorage; workers have none. Use BroadcastChannel there."
|
|
250
|
+
)
|
|
239
251
|
);
|
|
240
252
|
}
|
|
241
253
|
this.serializer = serializer;
|
|
@@ -293,14 +305,16 @@ function defaultTransport(name) {
|
|
|
293
305
|
if (isStorageEventAvailable()) {
|
|
294
306
|
if (process.env.NODE_ENV !== "production") {
|
|
295
307
|
devWarn(
|
|
296
|
-
"
|
|
308
|
+
"UE1009",
|
|
309
|
+
"no BroadcastChannel; using the storage-event fallback. Values serialise as JSON, not structured clone \u2014 keep them JSON-shaped."
|
|
297
310
|
);
|
|
298
311
|
}
|
|
299
312
|
return new StorageTransport(name);
|
|
300
313
|
}
|
|
301
314
|
if (process.env.NODE_ENV !== "production") {
|
|
302
315
|
devWarn(
|
|
303
|
-
"
|
|
316
|
+
"UE1010",
|
|
317
|
+
"no BroadcastChannel and no usable localStorage: nothing is shared between tabs. Storage is probably blocked."
|
|
304
318
|
);
|
|
305
319
|
}
|
|
306
320
|
return new NoopTransport();
|
|
@@ -330,7 +344,8 @@ function recordSkew(name, version) {
|
|
|
330
344
|
versions.add(version);
|
|
331
345
|
if (process.env.NODE_ENV !== "production") {
|
|
332
346
|
devWarn(
|
|
333
|
-
|
|
347
|
+
"UE1007",
|
|
348
|
+
`bus "${name}": a peer speaks wire protocol v${version}, this build speaks v${WIRE_VERSION} \u2014 a ${version > WIRE_VERSION ? "newer" : "older"} deploy. They cannot share state, presence, or a leader seat. https://rxova.org/packages/use-everywhere/under-the-hood/version-skew/`
|
|
334
349
|
);
|
|
335
350
|
}
|
|
336
351
|
}
|
|
@@ -462,15 +477,14 @@ function getBus(name, options = {}) {
|
|
|
462
477
|
if (options.heartbeatMs !== void 0 && options.heartbeatMs !== core.heartbeatMs) {
|
|
463
478
|
if (process.env.NODE_ENV !== "production") {
|
|
464
479
|
devWarn(
|
|
465
|
-
|
|
480
|
+
"UE1004",
|
|
481
|
+
`bus "${name}": heartbeatMs ignored \u2014 the first creator fixes bus options`
|
|
466
482
|
);
|
|
467
483
|
}
|
|
468
484
|
}
|
|
469
485
|
if (options.kind !== void 0 && options.kind !== core.kind) {
|
|
470
486
|
if (process.env.NODE_ENV !== "production") {
|
|
471
|
-
devWarn(
|
|
472
|
-
`[use-everywhere] bus "${name}": kind ignored \u2014 the first creator fixes bus options`
|
|
473
|
-
);
|
|
487
|
+
devWarn("UE1005", `bus "${name}": kind ignored \u2014 the first creator fixes bus options`);
|
|
474
488
|
}
|
|
475
489
|
}
|
|
476
490
|
}
|
|
@@ -499,7 +513,8 @@ function createGate(name, schemas, onInvalid) {
|
|
|
499
513
|
if (onInvalid) onInvalid(info);
|
|
500
514
|
else if (process.env.NODE_ENV !== "production") {
|
|
501
515
|
devWarn(
|
|
502
|
-
|
|
516
|
+
"UE1003",
|
|
517
|
+
`${name}/${key}: ${direction}bound payload rejected by its schema \u2014 ${result.issues.join("; ")}. https://rxova.org/packages/use-everywhere/guides/validating-payloads/`
|
|
503
518
|
);
|
|
504
519
|
}
|
|
505
520
|
return result.issues;
|
|
@@ -678,7 +693,8 @@ function createSharedStore(name, initial, options = {}) {
|
|
|
678
693
|
if (live > 0) {
|
|
679
694
|
if (process.env.NODE_ENV !== "production") {
|
|
680
695
|
devWarn(
|
|
681
|
-
|
|
696
|
+
"UE1001",
|
|
697
|
+
`second shared store for "${name}" in this tab \u2014 they stay in sync, but you are paying twice for one store's state, subscriptions, and persistence writes. Reuse one per name.`
|
|
682
698
|
);
|
|
683
699
|
}
|
|
684
700
|
}
|
|
@@ -842,7 +858,8 @@ function createSharedStore(name, initial, options = {}) {
|
|
|
842
858
|
if (onRestoreError) onRestoreError(error);
|
|
843
859
|
else if (process.env.NODE_ENV !== "production") {
|
|
844
860
|
devWarn(
|
|
845
|
-
|
|
861
|
+
"UE1002",
|
|
862
|
+
`${name}: persisted schema v${error.found} not restored, expected v${error.expected} (${error.reason}). https://rxova.org/packages/use-everywhere/guides/persistence/`
|
|
846
863
|
);
|
|
847
864
|
}
|
|
848
865
|
};
|
package/dist/index.d.cts
CHANGED
|
@@ -349,7 +349,13 @@ interface LeaderOptions extends CommonOptions {
|
|
|
349
349
|
eligible?: boolean;
|
|
350
350
|
/** How to arbitrate the seat. Default 'auto'. */
|
|
351
351
|
strategy?: LeaderStrategy;
|
|
352
|
-
/**
|
|
352
|
+
/**
|
|
353
|
+
* The Web Locks manager to elect on. Defaults to `navigator.locks`.
|
|
354
|
+
*
|
|
355
|
+
* A test seam: `@use-everywhere/test-utils` passes a `FakeLockManager` here
|
|
356
|
+
* so several simulated tabs can queue on one seat — and so a crashed tab's
|
|
357
|
+
* lock is reclaimed — in a plain test process.
|
|
358
|
+
*/
|
|
353
359
|
locks?: LockManagerLike;
|
|
354
360
|
}
|
|
355
361
|
/** The slice of the Web Locks API this library uses. */
|
|
@@ -1105,4 +1111,4 @@ declare function isStorageEventAvailable(): boolean;
|
|
|
1105
1111
|
*/
|
|
1106
1112
|
declare function defaultTransport(name: string): Transport;
|
|
1107
1113
|
|
|
1108
|
-
export { type AskOptions, BroadcastChannelTransport, type BusEvent, type BusObserver, type BusWire, CID_PARAM, type Channel, type ChannelOptions, type CommonOptions, type ConnectToOpenerOptions, DEFAULT_NAME, type DebugOptions, HandshakeTimeoutError, type IndexedDbAdapterOptions, type InvalidPayload, type Leader, type LeaderOptions, type LeaderSnapshot, type LeaderStrategy, type MessageEventLike, type MessageMap, type MessageMeta, type Namespace, NoopTransport, type OnInvalid, type OnOptions, type OpenWindowOptions, type OpenedWindow, type OpenerConnection, type Peer, type PeerKind, type PersistAdapter, type PersistOptions, type Persisted, type PostOptions, type Presence, type PresenceOptions, type ReplyMap, type RestoreError, type SchemaMap, type SchemaOptions, type Serializer, type SharedReducer, type SharedReducerOptions, type SharedStore, type SharedStoreOptions, type StandardSchemaV1, type StorageLike, StorageTransport, Transport, TransportKind, type Version, WIRE_VERSION, type WebStorageAdapterOptions, WindowClosedError, type WindowEventTarget, type WindowLike, connectToOpener, createChannel, createLeader, createNamespace, createPresence, createSharedReducer, createSharedStore, defaultTransport, enableDebug, getBusNames, getTransportKind, getWireSkew, indexedDbAdapter, isBroadcastChannelAvailable, isStorageEventAvailable, jsonSerializer, localStorageAdapter, newer, observeBus, openWindow, sessionStorageAdapter, webStorageAdapter };
|
|
1114
|
+
export { type AskOptions, BroadcastChannelTransport, type BusEvent, type BusObserver, type BusWire, CID_PARAM, type Channel, type ChannelOptions, type CommonOptions, type ConnectToOpenerOptions, DEFAULT_NAME, type DebugOptions, HandshakeTimeoutError, type IndexedDbAdapterOptions, type InvalidPayload, type Leader, type LeaderOptions, type LeaderSnapshot, type LeaderStrategy, type LockManagerLike, type MessageEventLike, type MessageMap, type MessageMeta, type Namespace, NoopTransport, type OnInvalid, type OnOptions, type OpenWindowOptions, type OpenedWindow, type OpenerConnection, type Peer, type PeerKind, type PersistAdapter, type PersistOptions, type Persisted, type PostOptions, type Presence, type PresenceOptions, type ReplyMap, type RestoreError, type SchemaMap, type SchemaOptions, type Serializer, type SharedReducer, type SharedReducerOptions, type SharedStore, type SharedStoreOptions, type StandardSchemaV1, type StorageLike, StorageTransport, Transport, TransportKind, type Version, WIRE_VERSION, type WebStorageAdapterOptions, WindowClosedError, type WindowEventTarget, type WindowLike, connectToOpener, createChannel, createLeader, createNamespace, createPresence, createSharedReducer, createSharedStore, defaultTransport, enableDebug, getBusNames, getTransportKind, getWireSkew, indexedDbAdapter, isBroadcastChannelAvailable, isStorageEventAvailable, jsonSerializer, localStorageAdapter, newer, observeBus, openWindow, sessionStorageAdapter, webStorageAdapter };
|
package/dist/index.d.ts
CHANGED
|
@@ -349,7 +349,13 @@ interface LeaderOptions extends CommonOptions {
|
|
|
349
349
|
eligible?: boolean;
|
|
350
350
|
/** How to arbitrate the seat. Default 'auto'. */
|
|
351
351
|
strategy?: LeaderStrategy;
|
|
352
|
-
/**
|
|
352
|
+
/**
|
|
353
|
+
* The Web Locks manager to elect on. Defaults to `navigator.locks`.
|
|
354
|
+
*
|
|
355
|
+
* A test seam: `@use-everywhere/test-utils` passes a `FakeLockManager` here
|
|
356
|
+
* so several simulated tabs can queue on one seat — and so a crashed tab's
|
|
357
|
+
* lock is reclaimed — in a plain test process.
|
|
358
|
+
*/
|
|
353
359
|
locks?: LockManagerLike;
|
|
354
360
|
}
|
|
355
361
|
/** The slice of the Web Locks API this library uses. */
|
|
@@ -1105,4 +1111,4 @@ declare function isStorageEventAvailable(): boolean;
|
|
|
1105
1111
|
*/
|
|
1106
1112
|
declare function defaultTransport(name: string): Transport;
|
|
1107
1113
|
|
|
1108
|
-
export { type AskOptions, BroadcastChannelTransport, type BusEvent, type BusObserver, type BusWire, CID_PARAM, type Channel, type ChannelOptions, type CommonOptions, type ConnectToOpenerOptions, DEFAULT_NAME, type DebugOptions, HandshakeTimeoutError, type IndexedDbAdapterOptions, type InvalidPayload, type Leader, type LeaderOptions, type LeaderSnapshot, type LeaderStrategy, type MessageEventLike, type MessageMap, type MessageMeta, type Namespace, NoopTransport, type OnInvalid, type OnOptions, type OpenWindowOptions, type OpenedWindow, type OpenerConnection, type Peer, type PeerKind, type PersistAdapter, type PersistOptions, type Persisted, type PostOptions, type Presence, type PresenceOptions, type ReplyMap, type RestoreError, type SchemaMap, type SchemaOptions, type Serializer, type SharedReducer, type SharedReducerOptions, type SharedStore, type SharedStoreOptions, type StandardSchemaV1, type StorageLike, StorageTransport, Transport, TransportKind, type Version, WIRE_VERSION, type WebStorageAdapterOptions, WindowClosedError, type WindowEventTarget, type WindowLike, connectToOpener, createChannel, createLeader, createNamespace, createPresence, createSharedReducer, createSharedStore, defaultTransport, enableDebug, getBusNames, getTransportKind, getWireSkew, indexedDbAdapter, isBroadcastChannelAvailable, isStorageEventAvailable, jsonSerializer, localStorageAdapter, newer, observeBus, openWindow, sessionStorageAdapter, webStorageAdapter };
|
|
1114
|
+
export { type AskOptions, BroadcastChannelTransport, type BusEvent, type BusObserver, type BusWire, CID_PARAM, type Channel, type ChannelOptions, type CommonOptions, type ConnectToOpenerOptions, DEFAULT_NAME, type DebugOptions, HandshakeTimeoutError, type IndexedDbAdapterOptions, type InvalidPayload, type Leader, type LeaderOptions, type LeaderSnapshot, type LeaderStrategy, type LockManagerLike, type MessageEventLike, type MessageMap, type MessageMeta, type Namespace, NoopTransport, type OnInvalid, type OnOptions, type OpenWindowOptions, type OpenedWindow, type OpenerConnection, type Peer, type PeerKind, type PersistAdapter, type PersistOptions, type Persisted, type PostOptions, type Presence, type PresenceOptions, type ReplyMap, type RestoreError, type SchemaMap, type SchemaOptions, type Serializer, type SharedReducer, type SharedReducerOptions, type SharedStore, type SharedStoreOptions, type StandardSchemaV1, type StorageLike, StorageTransport, Transport, TransportKind, type Version, WIRE_VERSION, type WebStorageAdapterOptions, WindowClosedError, type WindowEventTarget, type WindowLike, connectToOpener, createChannel, createLeader, createNamespace, createPresence, createSharedReducer, createSharedStore, defaultTransport, enableDebug, getBusNames, getTransportKind, getWireSkew, indexedDbAdapter, isBroadcastChannelAvailable, isStorageEventAvailable, jsonSerializer, localStorageAdapter, newer, observeBus, openWindow, sessionStorageAdapter, webStorageAdapter };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
// src/defaults.ts
|
|
2
2
|
var DEFAULT_NAME = "use-everywhere";
|
|
3
3
|
|
|
4
|
+
// src/dev.ts
|
|
5
|
+
var inDev = false;
|
|
6
|
+
try {
|
|
7
|
+
inDev = process.env.NODE_ENV !== "production";
|
|
8
|
+
} catch {
|
|
9
|
+
}
|
|
10
|
+
var warned = /* @__PURE__ */ new Set();
|
|
11
|
+
var DOCS = "https://rxova.org/packages/use-everywhere/errors";
|
|
12
|
+
function diagnostic(code, message) {
|
|
13
|
+
return `[use-everywhere] ${code}: ${message}
|
|
14
|
+
\u2192 ${DOCS}/#${code.toLowerCase()}`;
|
|
15
|
+
}
|
|
16
|
+
function devWarn(code, message) {
|
|
17
|
+
if (!inDev) return;
|
|
18
|
+
const line = diagnostic(code, message);
|
|
19
|
+
if (warned.has(line)) return;
|
|
20
|
+
warned.add(line);
|
|
21
|
+
console.warn(line);
|
|
22
|
+
}
|
|
23
|
+
|
|
4
24
|
// src/debug.ts
|
|
5
25
|
var observers = /* @__PURE__ */ new Map();
|
|
6
26
|
function emitBusEvent(name, direction, wire) {
|
|
@@ -11,7 +31,7 @@ function emitBusEvent(name, direction, wire) {
|
|
|
11
31
|
try {
|
|
12
32
|
fn(event);
|
|
13
33
|
} catch (error) {
|
|
14
|
-
console.error(`
|
|
34
|
+
console.error(diagnostic("UE1012", `a bus observer for "${name}" threw`), error);
|
|
15
35
|
}
|
|
16
36
|
}
|
|
17
37
|
}
|
|
@@ -38,19 +58,6 @@ function enableDebug(options = {}) {
|
|
|
38
58
|
});
|
|
39
59
|
}
|
|
40
60
|
|
|
41
|
-
// src/dev.ts
|
|
42
|
-
var inDev = false;
|
|
43
|
-
try {
|
|
44
|
-
inDev = process.env.NODE_ENV !== "production";
|
|
45
|
-
} catch {
|
|
46
|
-
}
|
|
47
|
-
var warned = /* @__PURE__ */ new Set();
|
|
48
|
-
function devWarn(message) {
|
|
49
|
-
if (!inDev || warned.has(message)) return;
|
|
50
|
-
warned.add(message);
|
|
51
|
-
console.warn(message);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
61
|
// src/ids.ts
|
|
55
62
|
function randomHex(bytes) {
|
|
56
63
|
const crypto = globalThis.crypto;
|
|
@@ -62,7 +69,8 @@ function randomHex(bytes) {
|
|
|
62
69
|
}
|
|
63
70
|
if (process.env.NODE_ENV !== "production") {
|
|
64
71
|
devWarn(
|
|
65
|
-
"
|
|
72
|
+
"UE1006",
|
|
73
|
+
"crypto.getRandomValues is unavailable; falling back to Math.random for ids. Cross-origin window nonces are not cryptographically strong in this environment."
|
|
66
74
|
);
|
|
67
75
|
}
|
|
68
76
|
let out = "";
|
|
@@ -90,7 +98,8 @@ function announce() {
|
|
|
90
98
|
if (census.protocols.length > 1) {
|
|
91
99
|
if (process.env.NODE_ENV !== "production") {
|
|
92
100
|
devWarn(
|
|
93
|
-
|
|
101
|
+
"UE1008",
|
|
102
|
+
`two incompatible versions of this library are loaded on one page (rendezvous protocols ${census.protocols.join(", ")}). They will not share a client identity: expect one presence entry per version and no synchronous delivery between them. They still sync over the bus. Align the versions to fix it.`
|
|
94
103
|
);
|
|
95
104
|
}
|
|
96
105
|
}
|
|
@@ -163,7 +172,7 @@ var jsonSerializer = {
|
|
|
163
172
|
const type = lossyType(this[key], forJson);
|
|
164
173
|
if (type) {
|
|
165
174
|
throw new TypeError(
|
|
166
|
-
`use-everywhere: ${key ? `"${key}" is ` : ""}${type}, which JSON cannot round-trip. https://rxova.org/guides/serialization/`
|
|
175
|
+
`use-everywhere: ${key ? `"${key}" is ` : ""}${type}, which JSON cannot round-trip. https://rxova.org/packages/use-everywhere/guides/serialization/`
|
|
167
176
|
);
|
|
168
177
|
}
|
|
169
178
|
return forJson;
|
|
@@ -180,7 +189,10 @@ var StorageTransport = class {
|
|
|
180
189
|
this.seq = 0;
|
|
181
190
|
if (!storage) {
|
|
182
191
|
throw new Error(
|
|
183
|
-
|
|
192
|
+
diagnostic(
|
|
193
|
+
"UE1011",
|
|
194
|
+
"StorageTransport needs localStorage; workers have none. Use BroadcastChannel there."
|
|
195
|
+
)
|
|
184
196
|
);
|
|
185
197
|
}
|
|
186
198
|
this.serializer = serializer;
|
|
@@ -238,14 +250,16 @@ function defaultTransport(name) {
|
|
|
238
250
|
if (isStorageEventAvailable()) {
|
|
239
251
|
if (process.env.NODE_ENV !== "production") {
|
|
240
252
|
devWarn(
|
|
241
|
-
"
|
|
253
|
+
"UE1009",
|
|
254
|
+
"no BroadcastChannel; using the storage-event fallback. Values serialise as JSON, not structured clone \u2014 keep them JSON-shaped."
|
|
242
255
|
);
|
|
243
256
|
}
|
|
244
257
|
return new StorageTransport(name);
|
|
245
258
|
}
|
|
246
259
|
if (process.env.NODE_ENV !== "production") {
|
|
247
260
|
devWarn(
|
|
248
|
-
"
|
|
261
|
+
"UE1010",
|
|
262
|
+
"no BroadcastChannel and no usable localStorage: nothing is shared between tabs. Storage is probably blocked."
|
|
249
263
|
);
|
|
250
264
|
}
|
|
251
265
|
return new NoopTransport();
|
|
@@ -275,7 +289,8 @@ function recordSkew(name, version) {
|
|
|
275
289
|
versions.add(version);
|
|
276
290
|
if (process.env.NODE_ENV !== "production") {
|
|
277
291
|
devWarn(
|
|
278
|
-
|
|
292
|
+
"UE1007",
|
|
293
|
+
`bus "${name}": a peer speaks wire protocol v${version}, this build speaks v${WIRE_VERSION} \u2014 a ${version > WIRE_VERSION ? "newer" : "older"} deploy. They cannot share state, presence, or a leader seat. https://rxova.org/packages/use-everywhere/under-the-hood/version-skew/`
|
|
279
294
|
);
|
|
280
295
|
}
|
|
281
296
|
}
|
|
@@ -407,15 +422,14 @@ function getBus(name, options = {}) {
|
|
|
407
422
|
if (options.heartbeatMs !== void 0 && options.heartbeatMs !== core.heartbeatMs) {
|
|
408
423
|
if (process.env.NODE_ENV !== "production") {
|
|
409
424
|
devWarn(
|
|
410
|
-
|
|
425
|
+
"UE1004",
|
|
426
|
+
`bus "${name}": heartbeatMs ignored \u2014 the first creator fixes bus options`
|
|
411
427
|
);
|
|
412
428
|
}
|
|
413
429
|
}
|
|
414
430
|
if (options.kind !== void 0 && options.kind !== core.kind) {
|
|
415
431
|
if (process.env.NODE_ENV !== "production") {
|
|
416
|
-
devWarn(
|
|
417
|
-
`[use-everywhere] bus "${name}": kind ignored \u2014 the first creator fixes bus options`
|
|
418
|
-
);
|
|
432
|
+
devWarn("UE1005", `bus "${name}": kind ignored \u2014 the first creator fixes bus options`);
|
|
419
433
|
}
|
|
420
434
|
}
|
|
421
435
|
}
|
|
@@ -444,7 +458,8 @@ function createGate(name, schemas, onInvalid) {
|
|
|
444
458
|
if (onInvalid) onInvalid(info);
|
|
445
459
|
else if (process.env.NODE_ENV !== "production") {
|
|
446
460
|
devWarn(
|
|
447
|
-
|
|
461
|
+
"UE1003",
|
|
462
|
+
`${name}/${key}: ${direction}bound payload rejected by its schema \u2014 ${result.issues.join("; ")}. https://rxova.org/packages/use-everywhere/guides/validating-payloads/`
|
|
448
463
|
);
|
|
449
464
|
}
|
|
450
465
|
return result.issues;
|
|
@@ -623,7 +638,8 @@ function createSharedStore(name, initial, options = {}) {
|
|
|
623
638
|
if (live > 0) {
|
|
624
639
|
if (process.env.NODE_ENV !== "production") {
|
|
625
640
|
devWarn(
|
|
626
|
-
|
|
641
|
+
"UE1001",
|
|
642
|
+
`second shared store for "${name}" in this tab \u2014 they stay in sync, but you are paying twice for one store's state, subscriptions, and persistence writes. Reuse one per name.`
|
|
627
643
|
);
|
|
628
644
|
}
|
|
629
645
|
}
|
|
@@ -787,7 +803,8 @@ function createSharedStore(name, initial, options = {}) {
|
|
|
787
803
|
if (onRestoreError) onRestoreError(error);
|
|
788
804
|
else if (process.env.NODE_ENV !== "production") {
|
|
789
805
|
devWarn(
|
|
790
|
-
|
|
806
|
+
"UE1002",
|
|
807
|
+
`${name}: persisted schema v${error.found} not restored, expected v${error.expected} (${error.reason}). https://rxova.org/packages/use-everywhere/guides/persistence/`
|
|
791
808
|
);
|
|
792
809
|
}
|
|
793
810
|
};
|
package/package.json
CHANGED