@nice-code/commander 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.
- package/build/cli.cjs +330 -154
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +330 -154
- package/build/cli.mjs.map +1 -1
- package/build/client/assets/index-CD69frev.js +23 -0
- package/build/client/assets/index-CD69frev.js.map +1 -0
- package/build/client/index.html +1 -1
- package/package.json +6 -6
- package/build/client/assets/index-Bl7iM1Ei.js +0 -23
- package/build/client/assets/index-Bl7iM1Ei.js.map +0 -1
package/build/cli.cjs
CHANGED
|
@@ -1118,111 +1118,6 @@ function staggerFor(config, terms) {
|
|
|
1118
1118
|
return stagger;
|
|
1119
1119
|
}
|
|
1120
1120
|
//#endregion
|
|
1121
|
-
//#region ../nice-wire/src/Carrier/duplex/ws/ws_util.ts
|
|
1122
|
-
/**
|
|
1123
|
-
* Send a text or binary frame over a socket. A binary formatter may hand back a `Uint8Array` whose
|
|
1124
|
-
* backing buffer is typed as `ArrayBufferLike` (msgpackr pools buffers / may be `SharedArrayBuffer`),
|
|
1125
|
-
* which `WebSocket.send`'s `BufferSource` parameter rejects — copy it into a fresh `ArrayBuffer`-backed
|
|
1126
|
-
* view so the type (and the bytes) are safe to send.
|
|
1127
|
-
*/
|
|
1128
|
-
function sendFrame(ws, data) {
|
|
1129
|
-
if (typeof data === "string" || data instanceof ArrayBuffer) {
|
|
1130
|
-
ws.send(data);
|
|
1131
|
-
return;
|
|
1132
|
-
}
|
|
1133
|
-
ws.send(new Uint8Array(data));
|
|
1134
|
-
}
|
|
1135
|
-
/** Compact a WebSocket URL to `host/pathname` for devtools display, falling back to the raw url. */
|
|
1136
|
-
function shortWs(url) {
|
|
1137
|
-
try {
|
|
1138
|
-
const u = new URL(url);
|
|
1139
|
-
return `${u.host}${u.pathname}`;
|
|
1140
|
-
} catch {
|
|
1141
|
-
return url;
|
|
1142
|
-
}
|
|
1143
|
-
}
|
|
1144
|
-
//#endregion
|
|
1145
|
-
//#region ../nice-wire/src/Carrier/duplex/ws/webSocketByteChannel.ts
|
|
1146
|
-
/**
|
|
1147
|
-
* Adapt a `WebSocket` to the carrier-agnostic {@link IDuplexCarrier}, so the WebSocket becomes
|
|
1148
|
-
* "just another carrier" under the shared secure session. It owns every WebSocket-specific concern —
|
|
1149
|
-
* awaiting `open`, normalizing `Blob` frames to bytes, suppressing the log on a deliberate `close`, and
|
|
1150
|
-
* buffering any frame that arrives before the session attaches its handler — leaving the session itself
|
|
1151
|
-
* carrier-neutral.
|
|
1152
|
-
*/
|
|
1153
|
-
function webSocketByteChannel(ws) {
|
|
1154
|
-
let intentional = false;
|
|
1155
|
-
/**
|
|
1156
|
-
* True once the socket actually opened. A failure *before* this is a failed **dial**, not an
|
|
1157
|
-
* outage: it is reported by rejecting `ready` (and the connector's keep-alive ladder retries it
|
|
1158
|
-
* with backoff). Logging it here would spam the console on every attempt while a peer boots — the
|
|
1159
|
-
* routine dev-restart race — so the pre-open path stays silent and lets `ready` do the talking.
|
|
1160
|
-
*/
|
|
1161
|
-
let opened = ws.readyState === WebSocket.OPEN;
|
|
1162
|
-
let onMessage;
|
|
1163
|
-
let onClose;
|
|
1164
|
-
const preAttach = [];
|
|
1165
|
-
const deliver = (frame) => {
|
|
1166
|
-
if (onMessage != null) onMessage(frame);
|
|
1167
|
-
else preAttach.push(frame);
|
|
1168
|
-
};
|
|
1169
|
-
ws.addEventListener("open", () => {
|
|
1170
|
-
opened = true;
|
|
1171
|
-
});
|
|
1172
|
-
ws.addEventListener("message", async (event) => {
|
|
1173
|
-
const frame = await normalizeFrame(event.data);
|
|
1174
|
-
if (frame !== void 0) deliver(frame);
|
|
1175
|
-
});
|
|
1176
|
-
ws.addEventListener("close", (event) => {
|
|
1177
|
-
if (opened && !intentional) console.warn("WebSocket closed:", event);
|
|
1178
|
-
onClose?.();
|
|
1179
|
-
});
|
|
1180
|
-
ws.addEventListener("error", () => {
|
|
1181
|
-
if (opened) console.warn(`WebSocket error: ${describeSocket(ws)}`);
|
|
1182
|
-
onClose?.();
|
|
1183
|
-
});
|
|
1184
|
-
return {
|
|
1185
|
-
ready: new Promise((resolve, reject) => {
|
|
1186
|
-
if (ws.readyState === WebSocket.OPEN) {
|
|
1187
|
-
resolve();
|
|
1188
|
-
return;
|
|
1189
|
-
}
|
|
1190
|
-
ws.addEventListener("open", () => resolve(), { once: true });
|
|
1191
|
-
ws.addEventListener("error", () => reject(dialFailedError(ws)), { once: true });
|
|
1192
|
-
ws.addEventListener("close", (event) => reject(/* @__PURE__ */ new Error(`WebSocket closed before open (code=${event.code}): ${describeSocket(ws)}`)), { once: true });
|
|
1193
|
-
}),
|
|
1194
|
-
isOpen: () => ws.readyState === WebSocket.OPEN,
|
|
1195
|
-
send: (frame) => sendFrame(ws, frame),
|
|
1196
|
-
attach: (handlers) => {
|
|
1197
|
-
onMessage = handlers.onMessage;
|
|
1198
|
-
onClose = handlers.onClose;
|
|
1199
|
-
for (const frame of preAttach) handlers.onMessage(frame);
|
|
1200
|
-
preAttach.length = 0;
|
|
1201
|
-
},
|
|
1202
|
-
close: () => {
|
|
1203
|
-
intentional = true;
|
|
1204
|
-
try {
|
|
1205
|
-
ws.close();
|
|
1206
|
-
} catch {}
|
|
1207
|
-
},
|
|
1208
|
-
get label() {
|
|
1209
|
-
return ws.url != null && ws.url !== "" ? ws.url : void 0;
|
|
1210
|
-
}
|
|
1211
|
-
};
|
|
1212
|
-
}
|
|
1213
|
-
/** A failed dial, as a structured error the error pipeline (and a consumer's logs) can actually read. */
|
|
1214
|
-
function dialFailedError(ws) {
|
|
1215
|
-
return /* @__PURE__ */ new Error(`WebSocket dial failed: ${describeSocket(ws)}`);
|
|
1216
|
-
}
|
|
1217
|
-
function describeSocket(ws) {
|
|
1218
|
-
return ws.url != null && ws.url !== "" ? ws.url : "(no url)";
|
|
1219
|
-
}
|
|
1220
|
-
/** Accept text + binary frames (ArrayBuffer / Uint8Array / Blob); Blobs are converted to a buffer. */
|
|
1221
|
-
async function normalizeFrame(data) {
|
|
1222
|
-
if (typeof data === "string" || data instanceof ArrayBuffer || data instanceof Uint8Array) return data;
|
|
1223
|
-
if (typeof Blob !== "undefined" && data instanceof Blob) return await data.arrayBuffer();
|
|
1224
|
-
}
|
|
1225
|
-
//#endregion
|
|
1226
1121
|
//#region ../nice-error/src/internal/internal_errors.ts
|
|
1227
1122
|
let _build;
|
|
1228
1123
|
/** Wired once by `nice_core_errors` at module init to avoid an import cycle. */
|
|
@@ -2246,8 +2141,12 @@ const err_wire_connect = err_nice.createChildDomain({
|
|
|
2246
2141
|
connect_exhausted: err({ message: ({ peerId, attempted }) => `connect() to peer [${peerId}] exhausted its transport chain (tried: ${attempted.join(", ") || "none configured"}).` }),
|
|
2247
2142
|
/** Phase 2 — `connect()` after `close()`; a closed client is terminal, build a new one. */
|
|
2248
2143
|
connect_closed: err({ message: ({ peerId }) => `connect() to peer [${peerId}] on a closed WireClient — closed is terminal; create a new client.` }),
|
|
2249
|
-
/**
|
|
2250
|
-
|
|
2144
|
+
/**
|
|
2145
|
+
* Phase 2 — one transport's dial or handshake failed (the chain item detail inside
|
|
2146
|
+
* `connect_exhausted`). `endpoint`/`kind` are the feedback W2/W3 additions: the URL actually
|
|
2147
|
+
* dialed, and the typed class of failure (see `EWireConnectFailureKind`).
|
|
2148
|
+
*/
|
|
2149
|
+
dial_failed: err({ message: ({ peerId, carrierLabel, reason, endpoint }) => `Dialing peer [${peerId}] over "${carrierLabel}"${endpoint != null ? ` against ${endpoint}` : ""} failed: ${reason}` }),
|
|
2251
2150
|
/**
|
|
2252
2151
|
* Resilience-surface §6 — the carrier has **no valid endpoint right now** (`createRequest`
|
|
2253
2152
|
* returned `null`, e.g. a torn-down session's mutable dial context). Not a failure: a policy
|
|
@@ -2255,6 +2154,34 @@ const err_wire_connect = err_nice.createChildDomain({
|
|
|
2255
2154
|
* it — no dialing garbage, no backoff churn — until the next explicit `connect()`/dispatch.
|
|
2256
2155
|
*/
|
|
2257
2156
|
dial_unavailable: err({ message: ({ carrierLabel }) => `Dial over "${carrierLabel}" unavailable — createRequest returned null (no valid endpoint right now). A keep-alive redial parks on this until the next explicit connect()/dispatch.` }),
|
|
2157
|
+
/**
|
|
2158
|
+
* Consumer feedback (meteor-connect-bridge W1/W3) — **something answered, and it is not
|
|
2159
|
+
* nice-wire**. The dominant real-world causes are a wrong URL/port, an intercepting proxy or
|
|
2160
|
+
* WAF, or an endpoint that is simply a different server. Thrown where the evidence still
|
|
2161
|
+
* exists (the carrier holds the HTTP status; the handshake holds the frame), so the data
|
|
2162
|
+
* carries what came back instead of only what we wanted. Branch on it with
|
|
2163
|
+
* `err.hasId("endpoint_answered_non_protocol")` — never on the message text.
|
|
2164
|
+
*/
|
|
2165
|
+
endpoint_answered_non_protocol: err({ message: ({ stage, expected, url, httpStatus, contentType, receivedKind, bodyPreview }) => {
|
|
2166
|
+
const received = httpStatus != null ? `an HTTP ${httpStatus}${contentType != null ? ` ${contentType}` : ""} response` : receivedKind != null ? `a "${receivedKind}" frame` : "a response it could not decode";
|
|
2167
|
+
return `[${stage}] expected ${expected ?? "a nice-wire frame"} but received ${received} — the endpoint answered but is not speaking the nice-wire protocol (wrong URL, an intercepting proxy/WAF, or a different server)${url != null ? `. Dialed: ${url}` : ""}${bodyPreview != null ? `. Body: ${JSON.stringify(bodyPreview)}` : ""}.`;
|
|
2168
|
+
} }),
|
|
2169
|
+
/**
|
|
2170
|
+
* Consumer feedback (meteor-connect-bridge W3) — **nothing answered**: DNS/refused/TLS/offline,
|
|
2171
|
+
* or a socket that errored before it opened. The sibling of
|
|
2172
|
+
* `endpoint_answered_non_protocol`, and the reason the two are separate ids: they need
|
|
2173
|
+
* opposite developer responses (start the server / open the firewall, vs fix the URL or the
|
|
2174
|
+
* proxy in front of it).
|
|
2175
|
+
*/
|
|
2176
|
+
endpoint_unreachable: err({ message: ({ url, carrierLabel, reason }) => `Could not reach ${url ?? (carrierLabel != null ? `the "${carrierLabel}" endpoint` : "the endpoint")}: ${reason} — nothing answered there (wrong host/port, the server is not running, or a firewall/offline network).` }),
|
|
2177
|
+
/**
|
|
2178
|
+
* The peer **is** a nice-code backend and refused the handshake for a reason that carries no
|
|
2179
|
+
* machine-readable id of its own (an older peer, a dictionary/security mismatch, a custom
|
|
2180
|
+
* gate). Typed so `classifyConnectFailure` can report `handshake_rejected` — a third
|
|
2181
|
+
* developer response ("fix the identity/version"), distinct from a wrong URL or a dead host.
|
|
2182
|
+
* `identity_pin_mismatch` stays its own id: it is permanent and the redial loop parks on it.
|
|
2183
|
+
*/
|
|
2184
|
+
handshake_rejected: err({ message: ({ stage, reason }) => `[${stage}] rejected by peer: ${reason}` }),
|
|
2258
2185
|
/** Phase 3 — a protocol sent on a connection whose peer did not advertise it (or the host never registered it). */
|
|
2259
2186
|
protocol_unsupported: err({ message: ({ protocolId }) => `Protocol "${protocolId}" cannot speak on this connection — the peer did not advertise "proto:${protocolId}" (or it is not registered here).` }),
|
|
2260
2187
|
/** Phase 6 — a prefixed protocol registered on an exchange-only connection (protocols need duplex; plan D-11). */
|
|
@@ -2277,6 +2204,123 @@ const err_wire_connect = err_nice.createChildDomain({
|
|
|
2277
2204
|
}
|
|
2278
2205
|
});
|
|
2279
2206
|
//#endregion
|
|
2207
|
+
//#region ../nice-wire/src/Carrier/duplex/ws/ws_util.ts
|
|
2208
|
+
/**
|
|
2209
|
+
* Send a text or binary frame over a socket. A binary formatter may hand back a `Uint8Array` whose
|
|
2210
|
+
* backing buffer is typed as `ArrayBufferLike` (msgpackr pools buffers / may be `SharedArrayBuffer`),
|
|
2211
|
+
* which `WebSocket.send`'s `BufferSource` parameter rejects — copy it into a fresh `ArrayBuffer`-backed
|
|
2212
|
+
* view so the type (and the bytes) are safe to send.
|
|
2213
|
+
*/
|
|
2214
|
+
function sendFrame(ws, data) {
|
|
2215
|
+
if (typeof data === "string" || data instanceof ArrayBuffer) {
|
|
2216
|
+
ws.send(data);
|
|
2217
|
+
return;
|
|
2218
|
+
}
|
|
2219
|
+
ws.send(new Uint8Array(data));
|
|
2220
|
+
}
|
|
2221
|
+
/** Compact a WebSocket URL to `host/pathname` for devtools display, falling back to the raw url. */
|
|
2222
|
+
function shortWs(url) {
|
|
2223
|
+
try {
|
|
2224
|
+
const u = new URL(url);
|
|
2225
|
+
return `${u.host}${u.pathname}`;
|
|
2226
|
+
} catch {
|
|
2227
|
+
return url;
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
//#endregion
|
|
2231
|
+
//#region ../nice-wire/src/Carrier/duplex/ws/webSocketByteChannel.ts
|
|
2232
|
+
/**
|
|
2233
|
+
* Adapt a `WebSocket` to the carrier-agnostic {@link IDuplexCarrier}, so the WebSocket becomes
|
|
2234
|
+
* "just another carrier" under the shared secure session. It owns every WebSocket-specific concern —
|
|
2235
|
+
* awaiting `open`, normalizing `Blob` frames to bytes, suppressing the log on a deliberate `close`, and
|
|
2236
|
+
* buffering any frame that arrives before the session attaches its handler — leaving the session itself
|
|
2237
|
+
* carrier-neutral.
|
|
2238
|
+
*/
|
|
2239
|
+
function webSocketByteChannel(ws) {
|
|
2240
|
+
let intentional = false;
|
|
2241
|
+
/**
|
|
2242
|
+
* True once the socket actually opened. A failure *before* this is a failed **dial**, not an
|
|
2243
|
+
* outage: it is reported by rejecting `ready` (and the connector's keep-alive ladder retries it
|
|
2244
|
+
* with backoff). Logging it here would spam the console on every attempt while a peer boots — the
|
|
2245
|
+
* routine dev-restart race — so the pre-open path stays silent and lets `ready` do the talking.
|
|
2246
|
+
*/
|
|
2247
|
+
let opened = ws.readyState === WebSocket.OPEN;
|
|
2248
|
+
let onMessage;
|
|
2249
|
+
let onClose;
|
|
2250
|
+
const preAttach = [];
|
|
2251
|
+
const deliver = (frame) => {
|
|
2252
|
+
if (onMessage != null) onMessage(frame);
|
|
2253
|
+
else preAttach.push(frame);
|
|
2254
|
+
};
|
|
2255
|
+
ws.addEventListener("open", () => {
|
|
2256
|
+
opened = true;
|
|
2257
|
+
});
|
|
2258
|
+
ws.addEventListener("message", async (event) => {
|
|
2259
|
+
const frame = await normalizeFrame(event.data);
|
|
2260
|
+
if (frame !== void 0) deliver(frame);
|
|
2261
|
+
});
|
|
2262
|
+
ws.addEventListener("close", (event) => {
|
|
2263
|
+
if (opened && !intentional) console.warn("WebSocket closed:", event);
|
|
2264
|
+
onClose?.();
|
|
2265
|
+
});
|
|
2266
|
+
ws.addEventListener("error", () => {
|
|
2267
|
+
if (opened) console.warn(`WebSocket error: ${describeSocket(ws)}`);
|
|
2268
|
+
onClose?.();
|
|
2269
|
+
});
|
|
2270
|
+
return {
|
|
2271
|
+
ready: new Promise((resolve, reject) => {
|
|
2272
|
+
if (ws.readyState === WebSocket.OPEN) {
|
|
2273
|
+
resolve();
|
|
2274
|
+
return;
|
|
2275
|
+
}
|
|
2276
|
+
ws.addEventListener("open", () => resolve(), { once: true });
|
|
2277
|
+
ws.addEventListener("error", () => reject(dialFailedError(ws)), { once: true });
|
|
2278
|
+
ws.addEventListener("close", (event) => reject(unreachableError(ws, `WebSocket closed before open (code=${event.code})`)), { once: true });
|
|
2279
|
+
}),
|
|
2280
|
+
isOpen: () => ws.readyState === WebSocket.OPEN,
|
|
2281
|
+
send: (frame) => sendFrame(ws, frame),
|
|
2282
|
+
attach: (handlers) => {
|
|
2283
|
+
onMessage = handlers.onMessage;
|
|
2284
|
+
onClose = handlers.onClose;
|
|
2285
|
+
for (const frame of preAttach) handlers.onMessage(frame);
|
|
2286
|
+
preAttach.length = 0;
|
|
2287
|
+
},
|
|
2288
|
+
close: () => {
|
|
2289
|
+
intentional = true;
|
|
2290
|
+
try {
|
|
2291
|
+
ws.close();
|
|
2292
|
+
} catch {}
|
|
2293
|
+
},
|
|
2294
|
+
get label() {
|
|
2295
|
+
return ws.url != null && ws.url !== "" ? ws.url : void 0;
|
|
2296
|
+
}
|
|
2297
|
+
};
|
|
2298
|
+
}
|
|
2299
|
+
/**
|
|
2300
|
+
* A failed dial, as a structured error the error pipeline (and a consumer's logs) can actually
|
|
2301
|
+
* read. A socket that errors or closes *before* it opened means nothing answered, so it carries
|
|
2302
|
+
* the same typed `endpoint_unreachable` id as the HTTP carrier's `fetch` rejection — that is what
|
|
2303
|
+
* makes `EWireConnectFailureKind` trustworthy on both carriers rather than HTTP-only (feedback W3).
|
|
2304
|
+
*/
|
|
2305
|
+
function dialFailedError(ws) {
|
|
2306
|
+
return unreachableError(ws, "WebSocket dial failed");
|
|
2307
|
+
}
|
|
2308
|
+
function unreachableError(ws, reason) {
|
|
2309
|
+
return err_wire_connect.fromId("endpoint_unreachable", {
|
|
2310
|
+
url: ws.url != null && ws.url !== "" ? ws.url : void 0,
|
|
2311
|
+
carrierLabel: "ws",
|
|
2312
|
+
reason
|
|
2313
|
+
});
|
|
2314
|
+
}
|
|
2315
|
+
function describeSocket(ws) {
|
|
2316
|
+
return ws.url != null && ws.url !== "" ? ws.url : "(no url)";
|
|
2317
|
+
}
|
|
2318
|
+
/** Accept text + binary frames (ArrayBuffer / Uint8Array / Blob); Blobs are converted to a buffer. */
|
|
2319
|
+
async function normalizeFrame(data) {
|
|
2320
|
+
if (typeof data === "string" || data instanceof ArrayBuffer || data instanceof Uint8Array) return data;
|
|
2321
|
+
if (typeof Blob !== "undefined" && data instanceof Blob) return await data.arrayBuffer();
|
|
2322
|
+
}
|
|
2323
|
+
//#endregion
|
|
2280
2324
|
//#region ../nice-wire/src/Carrier/duplex/ws/wsCarrier.ts
|
|
2281
2325
|
/**
|
|
2282
2326
|
* A WebSocket {@link IWireDuplexCarrierSource}: opens an `arraybuffer` socket (cached per endpoint)
|
|
@@ -2321,6 +2365,43 @@ function wsCarrier$1(createRequest, options = {}) {
|
|
|
2321
2365
|
};
|
|
2322
2366
|
}
|
|
2323
2367
|
//#endregion
|
|
2368
|
+
//#region ../nice-wire/src/Connect/endpointEvidence.ts
|
|
2369
|
+
/**
|
|
2370
|
+
* How much of a non-protocol body an error message may carry. Deliberately short: a WAF's 40 KB
|
|
2371
|
+
* HTML page pasted into an error is worse DX than no preview at all.
|
|
2372
|
+
*/
|
|
2373
|
+
const BODY_PREVIEW_LIMIT = 200;
|
|
2374
|
+
/** C0 + DEL + C1 — a raw control character in an error message corrupts terminals and log lines. */
|
|
2375
|
+
const CONTROL_CHARS = /[\u0000-\u001F\u007F-\u009F]+/g;
|
|
2376
|
+
/**
|
|
2377
|
+
* A bounded, single-line, control-character-free head of whatever a non-protocol endpoint sent
|
|
2378
|
+
* back — enough to recognize an HTML error page or a proxy banner on sight. Only the *response* is
|
|
2379
|
+
* ever summarized: no request headers, no request body.
|
|
2380
|
+
*/
|
|
2381
|
+
function describeNonProtocolBody(raw) {
|
|
2382
|
+
if (typeof raw !== "string") return void 0;
|
|
2383
|
+
const flattened = raw.replace(CONTROL_CHARS, " ").replace(/\s+/g, " ").trim();
|
|
2384
|
+
if (flattened.length === 0) return void 0;
|
|
2385
|
+
return flattened.length > BODY_PREVIEW_LIMIT ? `${flattened.slice(0, BODY_PREVIEW_LIMIT)}…` : flattened;
|
|
2386
|
+
}
|
|
2387
|
+
/**
|
|
2388
|
+
* Classify a dial failure. Reads typed ids only — the ids are raised at the layer that still holds
|
|
2389
|
+
* the evidence precisely so this never has to sniff message text.
|
|
2390
|
+
*/
|
|
2391
|
+
function classifyConnectFailure(error) {
|
|
2392
|
+
if (!err_wire_connect.isExact(error)) return "unknown";
|
|
2393
|
+
if (error.hasId("endpoint_answered_non_protocol")) return "endpoint_answered_non_protocol";
|
|
2394
|
+
if (error.hasId("endpoint_unreachable")) return "endpoint_unreachable";
|
|
2395
|
+
if (error.hasId("identity_pin_mismatch") || error.hasId("handshake_rejected")) return "handshake_rejected";
|
|
2396
|
+
return "unknown";
|
|
2397
|
+
}
|
|
2398
|
+
/** The endpoint a failure names, when it carries one — the URL actually dialed. */
|
|
2399
|
+
function endpointFromConnectFailure(error) {
|
|
2400
|
+
if (!err_wire_connect.isExact(error)) return void 0;
|
|
2401
|
+
if (error.hasId("endpoint_answered_non_protocol")) return error.getContext("endpoint_answered_non_protocol").url;
|
|
2402
|
+
if (error.hasId("endpoint_unreachable")) return error.getContext("endpoint_unreachable").url;
|
|
2403
|
+
}
|
|
2404
|
+
//#endregion
|
|
2324
2405
|
//#region ../nice-wire/src/Connect/ConnectionTransportManager.ts
|
|
2325
2406
|
/**
|
|
2326
2407
|
* Preference-ordered transport selection over a shared connection cache — moved from nice-action
|
|
@@ -2362,13 +2443,19 @@ var ConnectionTransportManager$1 = class {
|
|
|
2362
2443
|
const cached = this._cache.get(cacheKey);
|
|
2363
2444
|
if (cached != null) {
|
|
2364
2445
|
if (cached instanceof Promise) {
|
|
2365
|
-
candidates.push(
|
|
2446
|
+
candidates.push({
|
|
2447
|
+
transport,
|
|
2448
|
+
promise: cached
|
|
2449
|
+
});
|
|
2366
2450
|
continue;
|
|
2367
2451
|
}
|
|
2368
|
-
candidates.push(
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2452
|
+
candidates.push({
|
|
2453
|
+
transport,
|
|
2454
|
+
promise: Promise.resolve({
|
|
2455
|
+
...cached,
|
|
2456
|
+
transport
|
|
2457
|
+
})
|
|
2458
|
+
});
|
|
2372
2459
|
break;
|
|
2373
2460
|
}
|
|
2374
2461
|
}
|
|
@@ -2385,10 +2472,13 @@ var ConnectionTransportManager$1 = class {
|
|
|
2385
2472
|
if (this._cache.get(cacheKey) === entry) this._cache.delete(cacheKey);
|
|
2386
2473
|
});
|
|
2387
2474
|
}
|
|
2388
|
-
candidates.push(
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2475
|
+
candidates.push({
|
|
2476
|
+
transport,
|
|
2477
|
+
promise: Promise.resolve({
|
|
2478
|
+
methods: readyData,
|
|
2479
|
+
transport
|
|
2480
|
+
})
|
|
2481
|
+
});
|
|
2392
2482
|
break;
|
|
2393
2483
|
}
|
|
2394
2484
|
if (statusInfo.status === "unsupported") {
|
|
@@ -2416,7 +2506,10 @@ var ConnectionTransportManager$1 = class {
|
|
|
2416
2506
|
throw e;
|
|
2417
2507
|
});
|
|
2418
2508
|
if (cacheKey != null) this._cache.set(cacheKey, promise);
|
|
2419
|
-
candidates.push(
|
|
2509
|
+
candidates.push({
|
|
2510
|
+
transport,
|
|
2511
|
+
promise
|
|
2512
|
+
});
|
|
2420
2513
|
}
|
|
2421
2514
|
}
|
|
2422
2515
|
if (candidates.length === 0) {
|
|
@@ -2424,13 +2517,20 @@ var ConnectionTransportManager$1 = class {
|
|
|
2424
2517
|
throw this._errors.notFound(input);
|
|
2425
2518
|
}
|
|
2426
2519
|
let lastError;
|
|
2520
|
+
let lastTransport;
|
|
2427
2521
|
for (const candidate of candidates) try {
|
|
2428
|
-
return await candidate;
|
|
2522
|
+
return await candidate.promise;
|
|
2429
2523
|
} catch (e) {
|
|
2430
2524
|
lastError = e;
|
|
2525
|
+
lastTransport = candidate.transport;
|
|
2431
2526
|
}
|
|
2432
2527
|
if (err_wire_connect.isExact(lastError) && (lastError.hasId("dial_unavailable") || lastError.hasId("identity_pin_mismatch"))) throw lastError;
|
|
2433
|
-
throw this._errors.initializationFailed(input,
|
|
2528
|
+
throw this._errors.initializationFailed(input, {
|
|
2529
|
+
cause: describeTransportFailure(lastError),
|
|
2530
|
+
endpoint: endpointFromConnectFailure(lastError) ?? lastTransport?.getRouteInfo(input)?.url,
|
|
2531
|
+
kind: classifyConnectFailure(lastError),
|
|
2532
|
+
origin: lastError
|
|
2533
|
+
});
|
|
2434
2534
|
}
|
|
2435
2535
|
};
|
|
2436
2536
|
/**
|
|
@@ -8304,16 +8404,31 @@ function wireFrameByteSize(frame) {
|
|
|
8304
8404
|
* §3). A reject carrying a machine-readable `id` becomes the matching typed `err_wire_connect`
|
|
8305
8405
|
* error — today `identity_pin_mismatch`, which the transport selection rethrows UNWRAPPED (like
|
|
8306
8406
|
* `dial_unavailable`) so `err.hasId("identity_pin_mismatch")` works at the `connect()`/dispatch
|
|
8307
|
-
* caller and the keep-alive redial loop can park on it. A reject without an id (
|
|
8308
|
-
*
|
|
8407
|
+
* caller and the keep-alive redial loop can park on it. A reject without an id (an older peer,
|
|
8408
|
+
* whose frames never carry one) becomes `handshake_rejected` — same message text, now typed, so
|
|
8409
|
+
* `classifyConnectFailure` can tell "the backend said no" from "wrong address" (feedback W3).
|
|
8309
8410
|
*/
|
|
8310
8411
|
function handshakeRejectError(stage, rejectFrame) {
|
|
8311
8412
|
if (rejectFrame.id === "identity_pin_mismatch") return err_wire_connect.fromId("identity_pin_mismatch", { reason: rejectFrame.reason });
|
|
8312
|
-
return
|
|
8413
|
+
return err_wire_connect.fromId("handshake_rejected", {
|
|
8414
|
+
stage,
|
|
8415
|
+
reason: rejectFrame.reason
|
|
8416
|
+
});
|
|
8313
8417
|
}
|
|
8314
8418
|
//#endregion
|
|
8315
8419
|
//#region ../nice-wire/src/Connect/duplexLinkSession.ts
|
|
8316
8420
|
const HANDSHAKE_TIMEOUT_MS$1 = 15e3;
|
|
8421
|
+
const LINK_HANDSHAKE_STAGE = "link-handshake";
|
|
8422
|
+
/** The duplex twin of the exchange path's `nonProtocolReply` — same typed id, so a consumer's
|
|
8423
|
+
* `kind` branch means the same thing whichever carrier served the dial. */
|
|
8424
|
+
function wrongHandshakeFrame(channel, expected, receivedKind) {
|
|
8425
|
+
return err_wire_connect.fromId("endpoint_answered_non_protocol", {
|
|
8426
|
+
stage: LINK_HANDSHAKE_STAGE,
|
|
8427
|
+
expected,
|
|
8428
|
+
url: channel.label,
|
|
8429
|
+
receivedKind: `hs/${receivedKind}`
|
|
8430
|
+
});
|
|
8431
|
+
}
|
|
8317
8432
|
/** The literal wire keepalive frames — the acceptor answers raw, before any session dispatch. */
|
|
8318
8433
|
const KEEPALIVE_PING$1 = "ping";
|
|
8319
8434
|
const KEEPALIVE_PONG$1 = "pong";
|
|
@@ -8456,6 +8571,7 @@ async function establishSecureDuplexSession(ctx) {
|
|
|
8456
8571
|
const handshakeQueue = [];
|
|
8457
8572
|
const handshakeWaiters = [];
|
|
8458
8573
|
const pendingFrames = [];
|
|
8574
|
+
let nonProtocolFrame;
|
|
8459
8575
|
let keepalive;
|
|
8460
8576
|
const mux = ctx.mux;
|
|
8461
8577
|
channel.attach({
|
|
@@ -8486,6 +8602,7 @@ async function establishSecureDuplexSession(ctx) {
|
|
|
8486
8602
|
else handshakeQueue.push(message);
|
|
8487
8603
|
return;
|
|
8488
8604
|
}
|
|
8605
|
+
nonProtocolFrame ??= frame;
|
|
8489
8606
|
}
|
|
8490
8607
|
pendingFrames.push(frame);
|
|
8491
8608
|
},
|
|
@@ -8496,7 +8613,12 @@ async function establishSecureDuplexSession(ctx) {
|
|
|
8496
8613
|
const queued = handshakeQueue.shift();
|
|
8497
8614
|
if (queued != null) return Promise.resolve(queued);
|
|
8498
8615
|
return new Promise((resolve, reject) => {
|
|
8499
|
-
const timeout = setTimeout(() => reject(
|
|
8616
|
+
const timeout = setTimeout(() => reject(nonProtocolFrame != null ? err_wire_connect.fromId("endpoint_answered_non_protocol", {
|
|
8617
|
+
stage: LINK_HANDSHAKE_STAGE,
|
|
8618
|
+
expected: "a handshake frame",
|
|
8619
|
+
url: channel.label,
|
|
8620
|
+
bodyPreview: describeNonProtocolBody(nonProtocolFrame)
|
|
8621
|
+
}) : /* @__PURE__ */ new Error(`[${LINK_HANDSHAKE_STAGE}] timed out waiting for peer reply`)), HANDSHAKE_TIMEOUT_MS$1);
|
|
8500
8622
|
handshakeWaiters.push((message) => {
|
|
8501
8623
|
clearTimeout(timeout);
|
|
8502
8624
|
resolve(message);
|
|
@@ -8584,12 +8706,12 @@ async function runClientHandshake(ctx, nextHandshakeMessage) {
|
|
|
8584
8706
|
});
|
|
8585
8707
|
sendHandshake(encodeHandshakeMessage(await handshake.createHello()));
|
|
8586
8708
|
const welcome = await nextHandshakeMessage();
|
|
8587
|
-
if (welcome.t === "reject") throw handshakeRejectError(
|
|
8588
|
-
if (welcome.t !== "welcome") throw
|
|
8709
|
+
if (welcome.t === "reject") throw handshakeRejectError(LINK_HANDSHAKE_STAGE, welcome);
|
|
8710
|
+
if (welcome.t !== "welcome") throw wrongHandshakeFrame(ctx.channel, "a welcome frame", welcome.t);
|
|
8589
8711
|
sendHandshake(encodeHandshakeMessage(await handshake.onWelcome(welcome)));
|
|
8590
8712
|
const accept = await nextHandshakeMessage();
|
|
8591
|
-
if (accept.t === "reject") throw handshakeRejectError(
|
|
8592
|
-
if (accept.t !== "accept") throw
|
|
8713
|
+
if (accept.t === "reject") throw handshakeRejectError(LINK_HANDSHAKE_STAGE, accept);
|
|
8714
|
+
if (accept.t !== "accept") throw wrongHandshakeFrame(ctx.channel, "an accept frame", accept.t);
|
|
8593
8715
|
const result = await handshake.onAccept(accept);
|
|
8594
8716
|
return {
|
|
8595
8717
|
crypto: result.securityLevel === "encrypted" && result.encryptionKeyMaterial != null ? createActionFrameCrypto({
|
|
@@ -8989,29 +9111,25 @@ async function runConnectorExchangeHandshake(carrier, secure, lane) {
|
|
|
8989
9111
|
securityLevel: secure.securityLevel,
|
|
8990
9112
|
channelTags: lane.channels
|
|
8991
9113
|
});
|
|
8992
|
-
const
|
|
8993
|
-
const welcomeReply = decodeExchangeReply(asString(await carrier.exchange(encodeExchange({
|
|
9114
|
+
const welcomeReply = await exchangeHandshakeFrame(carrier, {
|
|
8994
9115
|
k: "hs",
|
|
8995
|
-
m: encodeHandshakeMessage(
|
|
8996
|
-
})
|
|
8997
|
-
if (welcomeReply?.k !== "hs") throw new Error("[exchange-handshake] expected a welcome reply");
|
|
9116
|
+
m: encodeHandshakeMessage(await handshake.createHello())
|
|
9117
|
+
}, "a welcome frame");
|
|
8998
9118
|
const welcome = decodeHandshakeMessage(welcomeReply.m);
|
|
8999
|
-
if (welcome == null) throw
|
|
9000
|
-
if (welcome.t === "reject") throw handshakeRejectError(
|
|
9001
|
-
if (welcome.t !== "welcome") throw
|
|
9002
|
-
if (welcomeReply.hsc == null) throw new Error(
|
|
9003
|
-
const
|
|
9004
|
-
const acceptReply = decodeExchangeReply(asString(await carrier.exchange(encodeExchange({
|
|
9119
|
+
if (welcome == null) throw nonProtocolReply(carrier, "a welcome frame", "hs (undecodable)");
|
|
9120
|
+
if (welcome.t === "reject") throw handshakeRejectError(HANDSHAKE_STAGE, welcome);
|
|
9121
|
+
if (welcome.t !== "welcome") throw nonProtocolReply(carrier, "a welcome frame", `hs/${welcome.t}`);
|
|
9122
|
+
if (welcomeReply.hsc == null) throw new Error(`[${HANDSHAKE_STAGE}] welcome missing handshake continuation token${at(carrier)}`);
|
|
9123
|
+
const acceptReply = await exchangeHandshakeFrame(carrier, {
|
|
9005
9124
|
k: "hs",
|
|
9006
|
-
m: encodeHandshakeMessage(
|
|
9125
|
+
m: encodeHandshakeMessage(await handshake.onWelcome(welcome)),
|
|
9007
9126
|
hsc: welcomeReply.hsc
|
|
9008
|
-
})
|
|
9009
|
-
if (acceptReply?.k !== "hs") throw new Error("[exchange-handshake] expected an accept reply");
|
|
9127
|
+
}, "an accept frame");
|
|
9010
9128
|
const accept = decodeHandshakeMessage(acceptReply.m);
|
|
9011
|
-
if (accept == null) throw
|
|
9012
|
-
if (accept.t === "reject") throw handshakeRejectError(
|
|
9013
|
-
if (accept.t !== "accept") throw
|
|
9014
|
-
if (acceptReply.t == null) throw new Error(
|
|
9129
|
+
if (accept == null) throw nonProtocolReply(carrier, "an accept frame", "hs (undecodable)");
|
|
9130
|
+
if (accept.t === "reject") throw handshakeRejectError(HANDSHAKE_STAGE, accept);
|
|
9131
|
+
if (accept.t !== "accept") throw nonProtocolReply(carrier, "an accept frame", `hs/${accept.t}`);
|
|
9132
|
+
if (acceptReply.t == null) throw new Error(`[${HANDSHAKE_STAGE}] accept missing session token${at(carrier)}`);
|
|
9015
9133
|
const result = await handshake.onAccept(accept);
|
|
9016
9134
|
const crypto = result.securityLevel === "encrypted" && result.encryptionKeyMaterial != null ? createActionFrameCrypto({
|
|
9017
9135
|
link: secure.link,
|
|
@@ -9022,6 +9140,42 @@ async function runConnectorExchangeHandshake(carrier, secure, lane) {
|
|
|
9022
9140
|
crypto
|
|
9023
9141
|
};
|
|
9024
9142
|
}
|
|
9143
|
+
const HANDSHAKE_STAGE = "exchange-handshake";
|
|
9144
|
+
/**
|
|
9145
|
+
* One handshake exchange, with the failure told from the *reply's* point of view (feedback W1).
|
|
9146
|
+
* The reply is in hand at the throw site, so the error says what came back — a frame kind, or a
|
|
9147
|
+
* bounded preview of a body that was never a protocol frame at all — instead of only what we
|
|
9148
|
+
* hoped for. A body preview is attached ONLY when nothing decoded: a decodable `act` envelope may
|
|
9149
|
+
* carry application data, which has no business in a connection error.
|
|
9150
|
+
*/
|
|
9151
|
+
async function exchangeHandshakeFrame(carrier, request, expected) {
|
|
9152
|
+
const raw = asString(await carrier.exchange(encodeExchange(request)));
|
|
9153
|
+
const reply = decodeExchangeReply(raw);
|
|
9154
|
+
if (reply == null) throw err_wire_connect.fromId("endpoint_answered_non_protocol", {
|
|
9155
|
+
stage: HANDSHAKE_STAGE,
|
|
9156
|
+
expected,
|
|
9157
|
+
url: carrier.label,
|
|
9158
|
+
bodyPreview: describeNonProtocolBody(raw)
|
|
9159
|
+
});
|
|
9160
|
+
if (reply.k === "err") throw err_wire_connect.fromId("handshake_rejected", {
|
|
9161
|
+
stage: HANDSHAKE_STAGE,
|
|
9162
|
+
reason: reply.message
|
|
9163
|
+
});
|
|
9164
|
+
if (reply.k !== "hs") throw nonProtocolReply(carrier, expected, reply.k);
|
|
9165
|
+
return reply;
|
|
9166
|
+
}
|
|
9167
|
+
function nonProtocolReply(carrier, expected, receivedKind) {
|
|
9168
|
+
return err_wire_connect.fromId("endpoint_answered_non_protocol", {
|
|
9169
|
+
stage: HANDSHAKE_STAGE,
|
|
9170
|
+
expected,
|
|
9171
|
+
url: carrier.label,
|
|
9172
|
+
receivedKind
|
|
9173
|
+
});
|
|
9174
|
+
}
|
|
9175
|
+
/** Make a peer-bug message self-locating without inventing a typed id for it. */
|
|
9176
|
+
function at(carrier) {
|
|
9177
|
+
return carrier.label != null ? ` (endpoint: ${carrier.label})` : "";
|
|
9178
|
+
}
|
|
9025
9179
|
function asString(frame) {
|
|
9026
9180
|
if (typeof frame === "string") return frame;
|
|
9027
9181
|
return textDecoder$1.decode(frame instanceof ArrayBuffer ? new Uint8Array(frame) : frame);
|
|
@@ -12496,7 +12650,11 @@ const err_nice_transport = err_nice_action.createChildDomain({
|
|
|
12496
12650
|
["timeout"]: err({ message: ({ timeout }) => `ActionConnect transport timed out after ${timeout}ms.` }),
|
|
12497
12651
|
["not_found"]: err({ message: ({ actionId }) => `No connected transport found for action "${actionId}".` }),
|
|
12498
12652
|
["unsupported"]: err({ message: ({ transportShapes }) => `${transportShapes.length} Transport(s) [${transportShapes.join(", ")}] found but returned "unsupported" status.` }),
|
|
12499
|
-
["initialization_failed"]: err({ message: ({ actionId, cause }) =>
|
|
12653
|
+
["initialization_failed"]: err({ message: ({ actionId, cause, endpoint }) => {
|
|
12654
|
+
const head = `Could not connect any transport for action "${actionId}"${endpoint != null ? ` against ${endpoint}` : ""}`;
|
|
12655
|
+
if (cause == null) return `${head} (all transports failed to initialize).`;
|
|
12656
|
+
return `${head}: ${cause}${cause.endsWith(".") ? "" : "."}`;
|
|
12657
|
+
} }),
|
|
12500
12658
|
["send_failed"]: err({
|
|
12501
12659
|
message: ({ actionId, httpStatusCode, message }) => `Failed to send action "${actionId}" [${httpStatusCode ?? "Unknown status"}]: ${message ?? "Unknown error"}.`,
|
|
12502
12660
|
httpStatusCode: ({ httpStatusCode }) => httpStatusCode ?? 500
|
|
@@ -12521,10 +12679,12 @@ var ConnectionTransportManager = class extends ConnectionTransportManager$1 {
|
|
|
12521
12679
|
super(cache, {
|
|
12522
12680
|
unsupported: (transportShapes) => err_nice_transport.fromId("unsupported", { transportShapes }),
|
|
12523
12681
|
notFound: (input) => err_nice_transport.fromId("not_found", { actionId: input.action == null ? "connect()" : input.action.id }),
|
|
12524
|
-
initializationFailed: (input,
|
|
12682
|
+
initializationFailed: (input, failure) => err_nice_transport.fromId("initialization_failed", {
|
|
12525
12683
|
actionId: input.action == null ? "connect()" : input.action.id,
|
|
12526
|
-
cause
|
|
12527
|
-
|
|
12684
|
+
cause: failure.cause,
|
|
12685
|
+
endpoint: failure.endpoint,
|
|
12686
|
+
kind: failure.kind
|
|
12687
|
+
}).withOriginError(failure.origin)
|
|
12528
12688
|
});
|
|
12529
12689
|
}
|
|
12530
12690
|
};
|
|
@@ -18253,8 +18413,16 @@ function applyPatchesToStore(store, patches) {
|
|
|
18253
18413
|
* An updater that returned an object while leaving its draft untouched almost certainly meant
|
|
18254
18414
|
* exactly that, so it throws here instead. (Concise-arrow returns like `(d) => d.count++` or
|
|
18255
18415
|
* `(d) => (d.x = value)` modify the draft and stay allowed.)
|
|
18416
|
+
*
|
|
18417
|
+
* **A returned *draft* is not the footgun** — `Object.assign(draft, next)` already applied the
|
|
18418
|
+
* mutation, and returning the draft is merely redundant. Judging it by whether the draft happened
|
|
18419
|
+
* to change made the throw data-dependent: the pattern passed every first run and blew up later
|
|
18420
|
+
* on the one reset where `next` was identical (meteor-connect-bridge feedback S1). Splitting on
|
|
18421
|
+
* draft identity instead is deterministic — a returned draft always passes, a returned
|
|
18422
|
+
* *replacement* with an untouched draft always throws.
|
|
18256
18423
|
*/
|
|
18257
|
-
function assertNoReturnedState(returned, draftWasModified) {
|
|
18424
|
+
function assertNoReturnedState(returned, draftWasModified, returnedIsDraft) {
|
|
18425
|
+
if (returnedIsDraft) return;
|
|
18258
18426
|
if (!draftWasModified && typeof returned === "object" && returned != null) throw new Error("@nice-code/state: an update function returned a value without modifying its draft. Update functions are mutate-only — a returned state is ignored (unlike immer's produce). To reset or swap the state wholesale, use store.replace(next); to change part of it, mutate the draft.");
|
|
18259
18427
|
}
|
|
18260
18428
|
/**
|
|
@@ -18265,10 +18433,12 @@ function assertNoReturnedState(returned, draftWasModified) {
|
|
|
18265
18433
|
function applyUpdaterWithPatches(currentState, updater) {
|
|
18266
18434
|
if (typeof updater === "function") {
|
|
18267
18435
|
let returned;
|
|
18436
|
+
let returnedIsDraft = false;
|
|
18268
18437
|
const [next, patches, inversePatches] = produceWithPatches(currentState, (draft) => {
|
|
18269
18438
|
returned = updater(draft, currentState);
|
|
18439
|
+
returnedIsDraft = returned === draft;
|
|
18270
18440
|
});
|
|
18271
|
-
assertNoReturnedState(returned, next !== currentState);
|
|
18441
|
+
assertNoReturnedState(returned, next !== currentState, returnedIsDraft);
|
|
18272
18442
|
return [
|
|
18273
18443
|
next,
|
|
18274
18444
|
patches,
|
|
@@ -18280,10 +18450,12 @@ function applyUpdaterWithPatches(currentState, updater) {
|
|
|
18280
18450
|
const inversePatches = [];
|
|
18281
18451
|
for (const single of updater) {
|
|
18282
18452
|
let returned;
|
|
18453
|
+
let returnedIsDraft = false;
|
|
18283
18454
|
const [next, p, ip] = produceWithPatches(state, (draft) => {
|
|
18284
18455
|
returned = single(draft, state);
|
|
18456
|
+
returnedIsDraft = returned === draft;
|
|
18285
18457
|
});
|
|
18286
|
-
assertNoReturnedState(returned, next !== state);
|
|
18458
|
+
assertNoReturnedState(returned, next !== state, returnedIsDraft);
|
|
18287
18459
|
state = next;
|
|
18288
18460
|
patches.push(...p);
|
|
18289
18461
|
inversePatches.push(...ip);
|
|
@@ -18302,18 +18474,22 @@ function applyUpdaterWithPatches(currentState, updater) {
|
|
|
18302
18474
|
function applyUpdater(currentState, updater) {
|
|
18303
18475
|
if (typeof updater === "function") {
|
|
18304
18476
|
let returned;
|
|
18477
|
+
let returnedIsDraft = false;
|
|
18305
18478
|
const next = produce(currentState, (draft) => {
|
|
18306
18479
|
returned = updater(draft, currentState);
|
|
18480
|
+
returnedIsDraft = returned === draft;
|
|
18307
18481
|
});
|
|
18308
|
-
assertNoReturnedState(returned, next !== currentState);
|
|
18482
|
+
assertNoReturnedState(returned, next !== currentState, returnedIsDraft);
|
|
18309
18483
|
return next;
|
|
18310
18484
|
}
|
|
18311
18485
|
return updater.reduce((previousState, single) => {
|
|
18312
18486
|
let returned;
|
|
18487
|
+
let returnedIsDraft = false;
|
|
18313
18488
|
const next = produce(previousState, (draft) => {
|
|
18314
18489
|
returned = single(draft, previousState);
|
|
18490
|
+
returnedIsDraft = returned === draft;
|
|
18315
18491
|
});
|
|
18316
|
-
assertNoReturnedState(returned, next !== previousState);
|
|
18492
|
+
assertNoReturnedState(returned, next !== previousState, returnedIsDraft);
|
|
18317
18493
|
return next;
|
|
18318
18494
|
}, currentState);
|
|
18319
18495
|
}
|