@fixback/expo 0.8.3 → 0.9.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 (46) hide show
  1. package/README.md +5 -7
  2. package/dist/FeedbackModal.d.ts +7 -2
  3. package/dist/FeedbackModal.js +30 -3
  4. package/dist/FeedbackModal.js.map +1 -1
  5. package/dist/FixbackProvider.js +5 -1
  6. package/dist/FixbackProvider.js.map +1 -1
  7. package/dist/adapters.js +5 -4
  8. package/dist/adapters.js.map +1 -1
  9. package/dist/breadcrumbs.d.ts +15 -51
  10. package/dist/breadcrumbs.js +22 -169
  11. package/dist/breadcrumbs.js.map +1 -1
  12. package/dist/client-boot.d.ts +40 -0
  13. package/dist/client-boot.js +269 -0
  14. package/dist/client-boot.js.map +1 -0
  15. package/dist/client-connect.d.ts +33 -0
  16. package/dist/client-connect.js +306 -0
  17. package/dist/client-connect.js.map +1 -0
  18. package/dist/client-replay.d.ts +31 -0
  19. package/dist/client-replay.js +165 -0
  20. package/dist/client-replay.js.map +1 -0
  21. package/dist/client-state.d.ts +131 -0
  22. package/dist/client-state.js +158 -0
  23. package/dist/client-state.js.map +1 -0
  24. package/dist/client.d.ts +10 -245
  25. package/dist/client.js +80 -787
  26. package/dist/client.js.map +1 -1
  27. package/dist/error-capture.js +6 -26
  28. package/dist/error-capture.js.map +1 -1
  29. package/dist/identity.d.ts +0 -2
  30. package/dist/identity.js +0 -3
  31. package/dist/identity.js.map +1 -1
  32. package/dist/options.d.ts +263 -0
  33. package/dist/options.js +12 -0
  34. package/dist/options.js.map +1 -0
  35. package/dist/report.d.ts +13 -12
  36. package/dist/report.js +19 -38
  37. package/dist/report.js.map +1 -1
  38. package/dist/submit.d.ts +10 -37
  39. package/dist/submit.js +14 -64
  40. package/dist/submit.js.map +1 -1
  41. package/dist/tokens.d.ts +8 -3
  42. package/dist/tokens.js +12 -6
  43. package/dist/tokens.js.map +1 -1
  44. package/dist/version.d.ts +1 -1
  45. package/dist/version.js +1 -1
  46. package/package.json +4 -3
package/dist/client.js CHANGED
@@ -13,6 +13,13 @@
13
13
  * `resolveIdentity`, then `armCapture` — rather than one long procedure, so the
14
14
  * lifecycle reads as what it is and each step is testable on its own.
15
15
  *
16
+ * The client is a few pieces over one shared state object (`./client-state`, #661):
17
+ * boot and the capture it arms (`./client-boot`), mobile replay's arming
18
+ * (`./client-replay`), and Connect (`./client-connect`). What stays here is the
19
+ * lifecycle (`start`, `destroy`) and the composer-facing surface (`present`,
20
+ * `submit`, `trackScreen`). The public shapes live in `./options` and are
21
+ * re-exported from here.
22
+ *
16
23
  * Every platform touchpoint is an injected adapter (`FixbackAdapters`), so the
17
24
  * whole orchestration is unit-tested without React Native. Every path is
18
25
  * defensive: a Fixback problem leaves the host app untouched — `start` resolves
@@ -23,160 +30,32 @@ exports.REPLAY_BUCKET_MS = exports.DEFAULT_REPLAY_MAX_EDGE = exports.DEFAULT_REP
23
30
  exports.createFixbackClient = createFixbackClient;
24
31
  const sdk_core_1 = require("@fixback/sdk-core");
25
32
  Object.defineProperty(exports, "DEFAULT_API_URL", { enumerable: true, get: function () { return sdk_core_1.DEFAULT_API_URL; } });
26
- const breadcrumbs_1 = require("./breadcrumbs");
27
- const connect_1 = require("./connect");
28
- const reporter_session_store_1 = require("./reporter-session-store");
29
- const error_capture_1 = require("./error-capture");
33
+ const client_boot_1 = require("./client-boot");
34
+ const client_connect_1 = require("./client-connect");
35
+ const client_replay_1 = require("./client-replay");
36
+ const client_state_1 = require("./client-state");
30
37
  const identity_1 = require("./identity");
31
38
  const origin_1 = require("./origin");
32
39
  Object.defineProperty(exports, "canonicalizeOrigin", { enumerable: true, get: function () { return origin_1.canonicalizeOrigin; } });
33
- const propagation_1 = require("./propagation");
34
40
  const report_1 = require("./report");
35
- const replay_1 = require("./replay");
36
- const replay_encode_1 = require("./replay-encode");
41
+ const reporter_session_store_1 = require("./reporter-session-store");
37
42
  const shake_1 = require("./shake");
38
43
  const submit_1 = require("./submit");
39
44
  const version_1 = require("./version");
40
- /**
41
- * How long the browser door's `signIn()` waits for the connect page's redirect to come
42
- * back as a deep link (ADR-0052). Generous, because the round trip contains a real
43
- * sign-in — the doors, an email link, a password manager — and the only cost of
44
- * waiting is one pending promise. It exists so a person who abandons the page settles
45
- * that promise eventually rather than never; the Connect itself is not cancelled by it
46
- * and still lands through the inbound listener if they come back later.
47
- */
48
- const CONNECT_BROWSER_WAIT_MS = 5 * 60_000;
49
45
  var shake_2 = require("./shake");
50
46
  Object.defineProperty(exports, "DEFAULT_SHAKE_SAMPLE_INTERVAL_MS", { enumerable: true, get: function () { return shake_2.DEFAULT_SHAKE_SAMPLE_INTERVAL_MS; } });
51
- var replay_2 = require("./replay");
52
- Object.defineProperty(exports, "DEFAULT_REPLAY_FPS", { enumerable: true, get: function () { return replay_2.DEFAULT_REPLAY_FPS; } });
53
- Object.defineProperty(exports, "DEFAULT_REPLAY_MAX_EDGE", { enumerable: true, get: function () { return replay_2.DEFAULT_REPLAY_MAX_EDGE; } });
54
- Object.defineProperty(exports, "REPLAY_BUCKET_MS", { enumerable: true, get: function () { return replay_2.REPLAY_BUCKET_MS; } });
55
- /** Normalise a base URL: trim and drop trailing slashes. */
56
- function normalizeBase(value) {
57
- return value.trim().replace(/\/+$/, "");
58
- }
59
- /** Turn a screen name into the path segment of the report `url`. */
60
- function screenPath(name) {
61
- return name.trim().replace(/^\/+/, "");
62
- }
47
+ var replay_1 = require("./replay");
48
+ Object.defineProperty(exports, "DEFAULT_REPLAY_FPS", { enumerable: true, get: function () { return replay_1.DEFAULT_REPLAY_FPS; } });
49
+ Object.defineProperty(exports, "DEFAULT_REPLAY_MAX_EDGE", { enumerable: true, get: function () { return replay_1.DEFAULT_REPLAY_MAX_EDGE; } });
50
+ Object.defineProperty(exports, "REPLAY_BUCKET_MS", { enumerable: true, get: function () { return replay_1.REPLAY_BUCKET_MS; } });
63
51
  /** Create the headless client. See the module doc. */
64
52
  function createFixbackClient(options, adapters = {}) {
65
- const key = typeof options.key === "string" ? options.key.trim() : "";
66
- const origin = typeof options.origin === "string" ? (0, origin_1.canonicalizeOrigin)(options.origin) : "";
67
- const apiUrl = normalizeBase(options.apiUrl || sdk_core_1.DEFAULT_API_URL) || sdk_core_1.DEFAULT_API_URL;
68
- const now = adapters.now ?? Date.now;
69
- const readEnvironment = adapters.environment ?? (() => ({}));
70
- const warn = adapters.warn ?? (() => { });
71
- // The host app's Release (#117, ADR-0024), validated once here: an invalid value
72
- // is dropped with a warning rather than shipped for the server to discard — and
73
- // never a reason to refuse to start (capture must not break on config).
74
- const release = options.release ? (0, sdk_core_1.normaliseRelease)(options.release) : undefined;
75
- if (options.release && !release) {
76
- warn(`Fixback: ignoring invalid release ${JSON.stringify(options.release)} — use 1-100 ` +
77
- "visible characters with no whitespace or slashes (e.g. a git SHA or semver).");
78
- }
79
- // `environment` is no longer an option — the key selects the Environment (ADR
80
- // 2026-09-24) — but a plain-JS caller gets no type error for passing it, and would
81
- // otherwise believe it was honoured. Said once, here, never per report.
82
- const removedOption = (0, sdk_core_1.removedEnvironmentOptionWarning)(options);
83
- if (removedOption)
84
- warn(`Fixback: ${removedOption}`);
85
- // The Correlation id's targets (#540) — app topology known in code, so an init option
86
- // rather than a served setting, and allowlist-only on mobile. An entry that is not a
87
- // bare origin is never used, and said so once, the way an invalid release is — in the
88
- // words every capture SDK shares.
89
- const propagation = (0, propagation_1.normalizePropagateTo)(options.propagateTo);
90
- const ignoredPropagateTo = (0, sdk_core_1.ignoredPropagateToWarning)(propagation.rejected);
91
- if (ignoredPropagateTo)
92
- warn(`Fixback: ${ignoredPropagateTo}`);
93
- const buffer = (0, sdk_core_1.createBreadcrumbBuffer)({
94
- beforeBreadcrumb: options.beforeBreadcrumb,
95
- now,
96
- });
97
- let status = "idle";
98
- let boot = null;
99
- /** Monotonic id of the most recently *started* boot — see {@link bootAndArm}. */
100
- let bootSequence = 0;
101
- let currentScreen = null;
102
- let teardownTrace = null;
103
- let autoCapture = null;
104
- /**
105
- * The mobile replay recorder, and the window frozen when the composer opened
106
- * (ADR-0044). Both are null unless the Project enabled replay *and* this app asked
107
- * for it — recording an unmasked screen is never something the SDK starts on its own.
108
- */
109
- let replayRecorder = null;
110
- let pendingReplayWindow = null;
111
- let identity = {};
112
- // Connect state (ADR-0066): the Reporter session token held after a Connect, the
113
- // signed-in Account and its live tier (for the composer's identity row), and where the
114
- // SDK opens Connect — all set from the boot answer, refreshed on every boot.
115
- let reporterSessionToken = null;
116
- let account = null;
117
- let currentTier = null;
118
- let connectUrl;
119
- /** Removes the inbound deep-link listener; re-armed by each `start()`. */
120
- let teardownLinking = null;
121
- /**
122
- * The last inbound Connect code redeemed, so a replayed launch URL is not exchanged
123
- * twice. A code is single-use: the second attempt would fail, and a failed exchange
124
- * is indistinguishable from a Connect that never worked.
125
- */
126
- let lastInboundCode = null;
127
- /**
128
- * Callers waiting for the next inbound Connect to land — the browser door's
129
- * `signIn()` (ADR-0052), which hands control to the connect page and gets it back as
130
- * a deep link the inbound listener redeems. Resolved with `true` by a successful
131
- * redemption, `false` when the wait gives up or the client is destroyed, so an
132
- * awaited `signIn()` reports the identity the round trip actually produced instead
133
- * of the anonymous one it started from.
134
- */
135
- let inboundWaiters = [];
136
- /**
137
- * The lifecycle generation. Each `start()` claims a new generation and every
138
- * await inside it re-checks that it is still current; `destroy()` bumps the
139
- * generation so an in-flight start abandons itself. A destroyed client can be
140
- * started again — React 18+ StrictMode (and Fast Refresh) replay the
141
- * provider's effect as mount → cleanup → re-mount on the same client
142
- * instance, so destroy must not be terminal.
143
- */
144
- let generation = 0;
145
- /** Whether a start() has claimed the current generation. */
146
- let running = false;
147
- const statusListeners = new Set();
148
- const presentListeners = new Set();
149
- const identityListeners = new Set();
150
- function setStatus(next) {
151
- if (status === next)
152
- return;
153
- status = next;
154
- for (const listener of statusListeners) {
155
- try {
156
- listener(next);
157
- }
158
- catch {
159
- /* a listener must never break the client */
160
- }
161
- }
162
- }
163
- /**
164
- * The `url` a report carries right now (spec 0004 §D). With an `origin` configured
165
- * it reads `<origin>/<screen>`; without one — the default since ADR-0041 — the
166
- * screen stands alone, so the Evidence still says *where* the reporter was rather
167
- * than losing it to a setting nobody has to fill in. Ingest takes `url` as a free
168
- * string and the dashboard renders it as text, so a bare screen name is honest
169
- * here where a synthesised origin would be fiction.
170
- */
171
- function currentUrl() {
172
- if (!origin)
173
- return currentScreen ? screenPath(currentScreen) : undefined;
174
- return currentScreen ? `${origin}/${screenPath(currentScreen)}` : origin;
175
- }
176
- /** The transport deps every call shares: the injected seams plus this app's origin. */
177
- function submitDeps() {
178
- return { fetch: adapters.fetch, formData: adapters.formData, origin };
179
- }
53
+ const s = (0, client_state_1.createClientState)(options, adapters);
54
+ const { warn, now, readEnvironment, key, apiUrl, release, buffer } = s;
55
+ const replay = (0, client_replay_1.createReplayArming)(s);
56
+ const { releaseReplayFile, releaseReplayWindow, encodeReplay } = replay;
57
+ const { bootAndArm, resolveStreams, armTrace, disarmCapture, setMaintenance, clearMaintenanceRecheck, } = (0, client_boot_1.createBoot)(s, replay);
58
+ const { signIn, signOut, armConnectLinking, redeemLaunchUrl, settleInboundWaiters } = (0, client_connect_1.createConnect)(s, bootAndArm);
180
59
  /**
181
60
  * Step one of `start`: settle the identity evidence this session presents — the host
182
61
  * app's own `hostIdentity`, the SDK-managed anonymous id (persisted when storage is
@@ -186,362 +65,32 @@ function createFixbackClient(options, adapters = {}) {
186
65
  */
187
66
  async function resolveIdentity() {
188
67
  const anonymousId = options.anonymousId ?? (await (0, identity_1.ensureAnonymousId)(adapters.storage));
189
- reporterSessionToken = await (0, reporter_session_store_1.readReporterSession)(adapters.secureStore, key);
68
+ s.reporterSessionToken = await (0, reporter_session_store_1.readReporterSession)(adapters.secureStore, key);
190
69
  return {
191
70
  ...(options.hostIdentity ? { hostIdentity: options.hostIdentity } : {}),
192
- ...(reporterSessionToken ? { reporterSession: reporterSessionToken } : {}),
71
+ ...(s.reporterSessionToken ? { reporterSession: s.reporterSessionToken } : {}),
193
72
  anonymousId,
194
73
  };
195
74
  }
196
- /** The current Reporter identity for the composer's identity row and `identity()`. */
197
- function reporterIdentity() {
198
- return account
199
- ? {
200
- status: "connected",
201
- name: account.name,
202
- email: account.email,
203
- tier: currentTier ?? null,
204
- }
205
- : { status: "anonymous" };
206
- }
207
- /** Tell identity listeners the identity may have changed (boot / sign in / sign out). */
208
- function notifyIdentity() {
209
- const current = reporterIdentity();
210
- for (const listener of identityListeners) {
211
- try {
212
- listener(current);
213
- }
214
- catch {
215
- /* a listener must never break the client */
216
- }
217
- }
218
- }
219
- /** Tear down the trace hooks (best-effort), so they can be re-armed. */
220
- function disarmTrace() {
221
- try {
222
- teardownTrace?.();
223
- }
224
- catch {
225
- /* teardown is best-effort */
226
- }
227
- teardownTrace = null;
228
- }
229
- /** Tear down the trace + auto-capture hooks (best-effort), so they can be re-armed. */
230
- function disarmCapture() {
231
- disarmTrace();
232
- disarmReplay();
233
- try {
234
- autoCapture?.destroy();
235
- }
236
- catch {
237
- /* teardown is best-effort */
238
- }
239
- autoCapture = null;
240
- }
241
- /**
242
- * The effective per-stream capture flags: an init option overrides the served
243
- * config, and an absent (or malformed) served value means **on** — the default-on
244
- * rule (spec 0003 §C, ported). Called with no answer before boot has one, which is
245
- * how the pre-boot arming lands on "both streams on".
246
- */
247
- function resolveStreams(served) {
248
- return {
249
- console: options.capture?.console ??
250
- (typeof served?.console === "boolean" ? served.console : true),
251
- network: options.capture?.network ??
252
- (typeof served?.network === "boolean" ? served.network : true),
253
- };
254
- }
255
- /**
256
- * Whether this app asked for mobile replay. Unlike every other stream, replay is
257
- * **off until asked for** (ADR-0044): it records the device screen unmasked, so
258
- * shipping an SDK update must never start it. Either spelling opts in —
259
- * `capture: { replay: true }`, or simply passing a `replay` tuning object — and an
260
- * explicit `capture: { replay: false }` always wins.
261
- */
262
- function replayRequested() {
263
- if (typeof options.capture?.replay === "boolean")
264
- return options.capture.replay;
265
- return options.replay !== undefined;
266
- }
267
- /**
268
- * Whether replay records: this app asked for it, the Project has not turned it off
269
- * (its toggle stays the master kill switch, #138), and the platform can actually
270
- * capture and encode frames.
271
- */
272
- function replayEnabled(served) {
273
- if (!replayRequested())
274
- return false;
275
- if (typeof served?.replay === "boolean" && !served.replay)
276
- return false;
277
- return Boolean(adapters.captureReplayFrame && adapters.encodeReplaySegment);
278
- }
279
- /**
280
- * Start (or stop) the frame recorder for the Project's served config. Re-armed on
281
- * every boot, so a Project that turns replay off stops recording on the next boot
282
- * rather than at the next launch — and the frames already buffered are deleted with
283
- * the recorder, so nothing captured under the old answer can ship.
284
- */
285
- function armReplay(served) {
286
- disarmReplay();
287
- if (!replayEnabled(served)) {
288
- if (replayRequested() && typeof served?.replay === "boolean" && !served.replay) {
289
- warn("Fixback: replay is enabled in init but turned off for this Project — " +
290
- "no replay will be recorded until it is enabled in the dashboard.");
291
- }
292
- else if (replayRequested() && !adapters.encodeReplaySegment) {
293
- warn("Fixback: replay is enabled in init but no native encoder is linked — " +
294
- "mobile replay needs a development build (`npx expo prebuild`), not Expo Go.");
295
- }
296
- return;
297
- }
298
- replayRecorder = (0, replay_1.startMobileReplayRecorder)(options.replay ?? {}, {
299
- captureFrame: (quality) => adapters.captureReplayFrame(quality),
300
- releaseFrame: (uri) => releaseReplayFile(uri),
301
- isActive: adapters.isAppActive,
302
- now,
303
- });
304
- }
305
- /** Stop the recorder and drop every frame it owns (best-effort). */
306
- function disarmReplay() {
307
- try {
308
- replayRecorder?.stop();
309
- }
310
- catch {
311
- /* teardown is best-effort */
312
- }
313
- replayRecorder = null;
314
- pendingReplayWindow = null;
315
- }
316
- /** Delete a replay frame or encoded window file (best-effort, repeat-safe). */
317
- function releaseReplayFile(uri) {
318
- try {
319
- adapters.releaseReplayFrame?.(uri);
320
- }
321
- catch {
322
- /* release is best-effort */
323
- }
324
- }
325
- /** Give a frozen window back to the recorder, so its frames can be reclaimed. */
326
- function releaseReplayWindow(window) {
327
- if (!window)
328
- return;
329
- try {
330
- replayRecorder?.release(window);
331
- }
332
- catch {
333
- /* release is best-effort */
334
- }
335
- }
336
- /**
337
- * Freeze the window as it stands **now** and encode it — the auto-capture path's
338
- * whole replay step (ADR-0044): an uncaught error has no composer to open, so the
339
- * throw itself is the moment the window is taken. The window is given back as soon
340
- * as the encode is done, since nothing holds a draft for an auto report.
341
- */
342
- async function freezeAndEncodeReplay() {
343
- const window = replayRecorder?.snapshot() ?? null;
344
- if (!window)
345
- return null;
346
- try {
347
- return await encodeReplay(window);
348
- }
349
- finally {
350
- releaseReplayWindow(window);
351
- }
352
- }
353
- /**
354
- * Encode a frozen window for transport (ADR-0044). `null` whenever the window
355
- * cannot become a video — no recorder, nothing watchable buffered, or an encoder
356
- * that declined — so the report ships without replay rather than not at all.
357
- */
358
- async function encodeReplay(window) {
359
- if (!window || !adapters.encodeReplaySegment)
360
- return null;
361
- return (0, replay_encode_1.encodeReplayWindow)(window, {
362
- encodeSegment: adapters.encodeReplaySegment,
363
- windowSize: () => {
364
- const env = readEnvironment();
365
- return {
366
- width: env.windowWidth ?? 0,
367
- height: env.windowHeight ?? 0,
368
- };
369
- },
370
- maxEdge: (0, replay_1.resolvedMaxEdge)(options.replay),
371
- now,
372
- });
373
- }
374
- /**
375
- * Install the trace instrumentation for the given per-stream flags, replacing
376
- * whatever is installed — the teardown runs first, so a re-arm can never double-wrap
377
- * `console` or `XMLHttpRequest`.
378
- */
379
- function armTrace(streams) {
380
- disarmTrace();
381
- teardownTrace = (0, breadcrumbs_1.instrumentBreadcrumbs)(buffer, {
382
- consoleObj: adapters.consoleObj,
383
- xhr: adapters.xhr,
384
- ignoreUrl: (url) => (0, sdk_core_1.isFixbackApiRequest)(apiUrl, url),
385
- now,
386
- captureConsole: streams.console,
387
- captureNetwork: streams.network,
388
- propagateTo: propagation.origins,
389
- });
390
- }
391
- /**
392
- * Boot with the current identity and reconcile capture + the identity row. Shared by
393
- * `start`, `signIn`, and `signOut`: it swaps in the refreshed Reporter session token
394
- * (30-day sliding), records the Account / tier / connect URL the boot answer carries,
395
- * and arms capture only while a submission would be accepted — so a gated Project's
396
- * shake gesture arms exactly when the Account becomes eligible, and drops when it signs
397
- * out. `gen` is the caller's lifecycle generation; every await re-checks it so a
398
- * destroyed (or restarted) client abandons this in-flight boot.
399
- */
400
- async function bootAndArm(gen) {
401
- // Boots are last-one-wins. Two can be in flight at once — a deep link redeemed
402
- // while `start`'s boot is still out, a `signOut` racing a Connect — and they carry
403
- // *different* identities, so an older answer landing last would undo a newer one:
404
- // the shake gesture would stay withheld from a Reporter the server had just
405
- // accepted, with the session sitting unused in SecureStore until the next launch.
406
- const seq = ++bootSequence;
407
- let failure = null;
408
- const answer = await (0, sdk_core_1.requestBoot)(apiUrl, { key, ...(0, sdk_core_1.compactIdentity)(identity) }, {
409
- fetch: adapters.fetch,
410
- origin,
411
- onFailure: (reason) => {
412
- failure = reason;
413
- },
414
- });
415
- if (gen !== generation || seq !== bootSequence)
416
- return;
417
- boot = answer;
418
- // Swap in the refreshed session token (30-day sliding) when boot returned one.
419
- if (answer?.reporterSession) {
420
- reporterSessionToken = answer.reporterSession;
421
- identity = { ...identity, reporterSession: reporterSessionToken };
422
- await (0, reporter_session_store_1.writeReporterSession)(adapters.secureStore, key, reporterSessionToken);
423
- if (gen !== generation || seq !== bootSequence)
424
- return;
425
- }
426
- currentTier = answer?.tier ?? null;
427
- account = answer?.account ?? null;
428
- connectUrl = answer?.connectUrl;
429
- notifyIdentity();
430
- if (answer && answer.canSubmit) {
431
- // Re-arm from a clean slate (the shared trace buffer persists across a re-arm, so
432
- // no lead-up is lost) — a Connect that just made the Account eligible arms here.
433
- disarmCapture();
434
- armCapture(answer);
435
- lastDormancyWarning = null;
436
- setStatus("ready");
437
- }
438
- else {
439
- // Say why, once per dormant boot, in a development build (`warn` is silent in
440
- // production). A dormant SDK is otherwise indistinguishable on the device from
441
- // one that was never installed — and the reason is right here in the answer the
442
- // client already holds, or in the failure that stopped one arriving.
443
- warnDormant(answer, failure);
444
- // Not eligible (a gated Project the Account cannot yet report on, or a signed-out
445
- // visitor): nothing armed, but `connectUrl` is retained so `signIn` still works.
446
- // What the pre-boot arming optimistically recorded is dropped with it — this
447
- // Account cannot submit, so holding its console and network lead-up in memory
448
- // serves nothing. A later `signIn` re-arms and starts a fresh lead-up.
449
- disarmCapture();
450
- buffer.clear();
451
- setStatus("disabled");
452
- }
453
- }
454
- /**
455
- * The last dormancy line printed, so a re-boot that changes nothing (a `signOut`
456
- * back to the same refusal, an app resumed) does not repeat itself. Reset whenever
457
- * the client becomes able to submit, so a *later* relapse is reported again.
458
- */
459
- let lastDormancyWarning = null;
460
- /** Explain a dormant boot to the developer, at most once per distinct reason. */
461
- function warnDormant(answer, failure) {
462
- const message = (0, sdk_core_1.explainDormancy)({
463
- answer,
464
- failure,
465
- apiUrl,
466
- origin: origin || undefined,
467
- // Connect needs a door this app can actually open — an auth session it can
468
- // return through, or an in-app browser plus the seam the redirect comes back
469
- // on. With neither, naming `signIn()` would send the developer down a dead end.
470
- signInCall: canSignIn() ? "Fixback.signIn()" : undefined,
471
- });
472
- if (!message || message === lastDormancyWarning)
473
- return;
474
- lastDormancyWarning = message;
475
- warn(message);
476
- }
477
- /**
478
- * Step two of `start`: with a boot answer that says a submission would be
479
- * accepted, reconcile the trace instrumentation against the Project's served
480
- * capture config and install (unless turned off) automatic error capture.
481
- * Reaching here means the Gate is already satisfied, so an auto-error inherits
482
- * the very tier boot derived.
483
- *
484
- * The trace was already armed optimistically at `start()`, so this is a
485
- * **reconciliation**, not the first arming: a stream the Project turns off is both
486
- * uninstrumented and **purged**, so what the optimistic window recorded for it can
487
- * never ship.
488
- */
489
- function armCapture(answer) {
490
- const streams = resolveStreams(answer.capture);
491
- armTrace(streams);
492
- if (!streams.console)
493
- buffer.clearStream("console");
494
- if (!streams.network)
495
- buffer.clearStream("network");
496
- // Replay arms **here and only here** — never optimistically before boot, the way
497
- // the trace does. A trace that turns out to be unwanted is purged; frames already
498
- // written to the cache are a recording that should not have started (ADR-0044).
499
- armReplay(answer.capture);
500
- if (options.autoCapture === false)
501
- return;
502
- autoCapture = (0, error_capture_1.installErrorCapture)({
503
- apiUrl,
504
- key,
505
- origin,
506
- identity,
507
- sdkVersion: version_1.EXPO_SDK_VERSION,
508
- release,
509
- buffer,
510
- beforeSend: options.beforeSend,
511
- scrub: options.scrub,
512
- environment: readEnvironment,
513
- currentUrl,
514
- // The replay window as it stood at the throw (ADR-0044): frozen and encoded at
515
- // filing time, on the rich first report only — a flush is a count update, and
516
- // re-encoding the same window for it would be pure cost.
517
- captureReplay: () => freezeAndEncodeReplay(),
518
- errorUtils: adapters.errorUtils,
519
- appState: adapters.appState,
520
- deps: {
521
- submitReport: (url, input) => (0, submit_1.submitReport)(url, input, submitDeps()),
522
- },
523
- now,
524
- });
525
- }
526
75
  async function start() {
527
- if (running)
76
+ if (s.running)
528
77
  return;
529
- running = true;
530
- const gen = ++generation;
531
- setStatus("starting");
78
+ s.running = true;
79
+ const gen = ++s.generation;
80
+ (0, client_state_1.setStatus)(s, "starting");
532
81
  try {
533
82
  // The master gate (`enabled: false`) keeps the SDK completely dormant: no
534
83
  // identity, no boot call, nothing instrumented.
535
84
  if (options.enabled === false) {
536
- setStatus("disabled");
85
+ (0, client_state_1.setStatus)(s, "disabled");
537
86
  return;
538
87
  }
539
88
  // Only the key is required. An `origin` used to be mandatory here because
540
89
  // ingest refused a submission without one; it no longer does (ADR-0041), so an
541
90
  // app that configures none boots and reports normally.
542
91
  if (!key) {
543
- warn("Fixback: init needs a publishable `key`; staying dormant.");
544
- setStatus("disabled");
92
+ warn(`${sdk_core_1.WARN_PREFIX} init needs a publishable \`key\`; staying dormant.`);
93
+ (0, client_state_1.setStatus)(s, "disabled");
545
94
  return;
546
95
  }
547
96
  // Arm the trace **before** boot. Boot is a network round trip, and reading the
@@ -554,8 +103,8 @@ function createFixbackClient(options, adapters = {}) {
554
103
  // turns out to be off. Nothing can leave the process in between: a submission
555
104
  // needs `ready`, which only a `canSubmit` boot sets.
556
105
  armTrace(resolveStreams(undefined));
557
- identity = await resolveIdentity();
558
- if (gen !== generation)
106
+ s.identity = await resolveIdentity();
107
+ if (gen !== s.generation)
559
108
  return; // destroyed (or restarted) while resolving
560
109
  // Listen for Connect deep links before booting, so one delivered while the boot
561
110
  // round trip is in flight is not missed (ADR-0046).
@@ -564,7 +113,7 @@ function createFixbackClient(options, adapters = {}) {
564
113
  // invite the person claimed a moment ago is what opened the app, and the boot
565
114
  // below should already carry the Reporter session it established.
566
115
  await redeemLaunchUrl(gen);
567
- if (gen !== generation)
116
+ if (gen !== s.generation)
568
117
  return; // destroyed (or restarted) while redeeming
569
118
  // Boot, then arm auto-capture (and the shake gesture, via `ready`) only if a
570
119
  // submission would be accepted; sets `disabled` otherwise, keeping `connectUrl`
@@ -578,290 +127,22 @@ function createFixbackClient(options, adapters = {}) {
578
127
  warn(`Fixback is dormant: start() failed — ${error instanceof Error ? error.message : String(error)}`);
579
128
  // The optimistic pre-boot trace goes dormant with it: no submission can follow
580
129
  // a start that failed, so nothing should stay instrumented or held in memory.
581
- if (gen === generation) {
130
+ if (gen === s.generation) {
582
131
  disarmCapture();
583
132
  buffer.clear();
584
- setStatus("disabled");
585
- }
586
- }
587
- }
588
- /**
589
- * Start a **Connect** (ADR-0066): open the platform's connect page, exchange the
590
- * one-time code it hands back for a Reporter session, store it in SecureStore, and
591
- * re-boot as the Account — so a gated Project's shake gesture arms once the Account
592
- * is eligible. Exposed so a host app can put it on its own settings screen (the way
593
- * a gated Project, which shows nothing to a signed-out visitor, is entered), and
594
- * behind the composer's identity row. Never throws: any failure leaves the current
595
- * identity untouched.
596
- *
597
- * There are two doors, and which one opens depends only on what this app can offer
598
- * (ADR-0052):
599
- *
600
- * - **The auth session**, when `init` declared a `returnUrl` and an opener is
601
- * installed. The page returns *in place*, so the person never leaves the app.
602
- * - **The in-app browser**, otherwise. The page is opened with no return URL and
603
- * resolves where to land from the app links the *Project* lists, then redirects
604
- * to one — which re-opens this app, where the inbound listener redeems the code
605
- * (the journey a claimed Invite already travels). This is what keeps `signIn()`
606
- * from being inert on the default install, which declares no `returnUrl` at all.
607
- */
608
- async function signIn() {
609
- const gen = generation;
610
- if (!connectUrl)
611
- return reporterIdentity(); // not booted, or an older server
612
- try {
613
- if (options.returnUrl && adapters.openAuthSession) {
614
- const outcome = await (0, connect_1.startExpoConnect)(adapters.openAuthSession, {
615
- connectUrl,
616
- key,
617
- returnUrl: options.returnUrl,
618
- });
619
- if (gen !== generation)
620
- return reporterIdentity();
621
- if (outcome.kind === "code")
622
- await redeemConnectCode(outcome.code, gen);
623
- }
624
- else if (canConnectThroughBrowser()) {
625
- await connectThroughBrowser(gen);
626
- }
627
- else {
628
- warn(explainSignInDoor());
629
- }
630
- }
631
- catch {
632
- // A Connect problem must never disturb the host app.
633
- }
634
- return reporterIdentity();
635
- }
636
- /**
637
- * Whether the browser door is available: something to open the page with, and the
638
- * `linking` seam the code comes back on. Without the seam the page would land the
639
- * person back in the app with a code nothing reads, which is worse than not opening
640
- * it — so both are required, not either.
641
- */
642
- function canConnectThroughBrowser() {
643
- return Boolean(adapters.openBrowser && adapters.linking);
644
- }
645
- /** Whether `signIn()` can open a door at all — what the dormancy hint is gated on. */
646
- function canSignIn() {
647
- return Boolean((options.returnUrl && adapters.openAuthSession) || canConnectThroughBrowser());
648
- }
649
- /** Why `signIn()` could not open a door, named by what this app is actually missing. */
650
- function explainSignInDoor() {
651
- if (!adapters.openBrowser && !adapters.openAuthSession) {
652
- return "Fixback: signIn needs a browser to open the connect page — install expo-web-browser.";
653
- }
654
- if (!adapters.linking) {
655
- return "Fixback: signIn needs the Linking seam to receive the connect page's redirect — or declare a `returnUrl` in init to return through an auth session instead.";
656
- }
657
- return "Fixback: signIn needs either an auth-session opener plus a `returnUrl` in init, or an in-app browser (install expo-web-browser).";
658
- }
659
- /**
660
- * The browser door (ADR-0052): open the connect page with no return URL and wait for
661
- * the app link it redirects to, which the OS delivers back here as a deep link.
662
- *
663
- * The wait matters because the two halves are separated by the operating system: the
664
- * page redirects, the app is foregrounded, and {@link handleInboundUrl} redeems —
665
- * all after `openBrowser` has resolved (on Android it resolves as soon as the tab is
666
- * shown). Without it, an awaited `signIn()` would report the anonymous identity it
667
- * started from while the Connect it started was still completing. It is bounded, so
668
- * a person who wandered off never leaves a promise pending for the life of the app.
669
- */
670
- async function connectThroughBrowser(gen) {
671
- const landed = awaitInboundConnect();
672
- try {
673
- await adapters.openBrowser((0, connect_1.buildAppConnectUrl)(connectUrl, key));
674
- }
675
- catch {
676
- settleInboundWaiters(false);
677
- return;
678
- }
679
- if (gen !== generation)
680
- return settleInboundWaiters(false);
681
- // The redirect re-opens this app; dismiss the page it came from so the person is
682
- // returned to where they tapped Sign in rather than to a finished connect page.
683
- if (await landed)
684
- dismissBrowser();
685
- }
686
- /**
687
- * A promise for the next inbound Connect — `true` when one is redeemed, `false` when
688
- * the wait expires or the client is destroyed. The timer is cleared on either, so a
689
- * completed sign-in leaves nothing running.
690
- */
691
- function awaitInboundConnect() {
692
- return new Promise((resolve) => {
693
- const timer = setTimeout(() => settleInboundWaiters(false), CONNECT_BROWSER_WAIT_MS);
694
- inboundWaiters.push((landed) => {
695
- clearTimeout(timer);
696
- resolve(landed);
697
- });
698
- });
699
- }
700
- /** Resolve everyone waiting on an inbound Connect, and stop waiting. */
701
- function settleInboundWaiters(landed) {
702
- const waiting = inboundWaiters;
703
- inboundWaiters = [];
704
- for (const resolve of waiting) {
705
- try {
706
- resolve(landed);
707
- }
708
- catch {
709
- /* a waiter must never break the client */
710
- }
711
- }
712
- }
713
- /** Close the in-app browser this app opened — best-effort, like every seam here. */
714
- function dismissBrowser() {
715
- try {
716
- adapters.dismissBrowser?.();
717
- }
718
- catch {
719
- /* dismissing is a courtesy, never a failure */
720
- }
721
- }
722
- /**
723
- * Exchange a one-time Connect code for a Reporter session and persist it, leaving the
724
- * client identified as the Account. The tail every half of Connect on mobile shares:
725
- * {@link signIn}, where the app opened the connect page itself, and
726
- * {@link handleInboundUrl}, where the code arrived on a deep link from an invite the
727
- * person claimed elsewhere (ADR-0046). `gen` is the caller's lifecycle generation,
728
- * re-checked after every await so a destroyed client abandons the redemption.
729
- *
730
- * Booting on the new identity is the **caller's** step, because the two callers
731
- * differ: a redemption mid-run must re-boot to arm, while the one on the launch URL
732
- * is followed by `start`'s own boot and would only duplicate it.
733
- */
734
- async function exchangeAndStore(code, gen) {
735
- const result = await (0, sdk_core_1.exchangeConnectCode)(apiUrl, {
736
- key,
737
- code,
738
- anonymousId: identity.anonymousId,
739
- platform: "expo",
740
- }, { fetch: adapters.fetch });
741
- if (gen !== generation || !result)
742
- return false;
743
- reporterSessionToken = result.reporterSession;
744
- identity = { ...identity, reporterSession: reporterSessionToken };
745
- await (0, reporter_session_store_1.writeReporterSession)(adapters.secureStore, key, reporterSessionToken);
746
- return gen === generation;
747
- }
748
- /**
749
- * {@link exchangeAndStore} plus the re-boot that arms the client as the Account, and
750
- * whether the Connect landed. A refused exchange changes no identity, so it is not
751
- * re-booted on: the answer would be the one already in hand.
752
- */
753
- async function redeemConnectCode(code, gen) {
754
- if (!(await exchangeAndStore(code, gen)))
755
- return false;
756
- await bootAndArm(gen);
757
- return true;
758
- }
759
- /**
760
- * Finish a Connect that started outside the app: read the one-time code off an
761
- * inbound deep link and redeem it. Ignores a code it has already seen — iOS and
762
- * Android both replay the launch URL in ordinary situations (a cold start whose
763
- * `getInitialURL` is then re-delivered as a `url` event), and a code is single-use,
764
- * so a second exchange would fail and report a Connect that in fact succeeded as one
765
- * that did not. A declared `returnUrl` additionally narrows this to links on the
766
- * app's own return origin; an app that declared none still redeems, because the
767
- * claim page mints its code against the **Project's** app link, not against `init`.
768
- */
769
- async function handleInboundUrl(url, gen, { reboot = true } = {}) {
770
- try {
771
- const code = (0, connect_1.parseInboundConnectCode)(url, options.returnUrl);
772
- if (!code || code === lastInboundCode)
773
- return;
774
- lastInboundCode = code;
775
- const landed = reboot
776
- ? await redeemConnectCode(code, gen)
777
- : await exchangeAndStore(code, gen);
778
- // A `signIn()` that went through the browser door is waiting on exactly this —
779
- // the code it sent the person out for, arriving back on the app's own link.
780
- if (landed)
781
- settleInboundWaiters(true);
782
- }
783
- catch {
784
- // A Connect problem must never disturb the host app.
785
- }
786
- }
787
- /**
788
- * Listen for Connect deep links that arrive **while the app runs** — the person was
789
- * already in the app (or it was backgrounded) when they tapped the claim page's
790
- * button. Armed on the `linking` seam alone: a Project's app link is allowlisted on
791
- * the Project, so an app that never declared a `returnUrl` in `init` is still where
792
- * a claim lands (ADR-0046). Silent on an app that provides no seam, which can never
793
- * be a Connect target.
794
- */
795
- function armConnectLinking(gen) {
796
- const linking = adapters.linking;
797
- if (!linking)
798
- return;
799
- try {
800
- const subscription = linking.addEventListener("url", (event) => {
801
- void handleInboundUrl(event?.url ?? "", gen);
802
- });
803
- teardownLinking = () => subscription.remove();
804
- }
805
- catch {
806
- // A Linking seam that refuses to subscribe is not a reason to fail a start.
807
- }
808
- }
809
- /**
810
- * Redeem the code on the URL the app was **launched** with, before the first boot —
811
- * the invite journey's cold start (the person tapped the claim page's redirect and
812
- * the app opened). Awaited rather than left in flight, so the one boot that follows
813
- * carries the Reporter session: two concurrent boots race, and an anonymous answer
814
- * landing last leaves a Connect that succeeded looking like one that never happened.
815
- * The browser SDK exchanges a URL code before booting for the same reason.
816
- *
817
- * Best-effort throughout: a seam that throws, a launch URL that carries nothing, or
818
- * an exchange the server refuses all fall through to an ordinary anonymous boot.
819
- */
820
- async function redeemLaunchUrl(gen) {
821
- const linking = adapters.linking;
822
- if (!linking)
823
- return;
824
- try {
825
- const initial = await linking.getInitialURL();
826
- if (gen !== generation || !initial)
827
- return;
828
- await handleInboundUrl(initial, gen, { reboot: false });
829
- }
830
- catch {
831
- // Never throw into the host app.
832
- }
833
- }
834
- /**
835
- * Revoke the Reporter session, clear it from SecureStore, and re-boot as anonymous —
836
- * so a gated Project's launcher (shake gesture) drops at once. Never throws.
837
- */
838
- async function signOut() {
839
- const gen = generation;
840
- try {
841
- if (reporterSessionToken) {
842
- await (0, sdk_core_1.revokeReporterSession)(apiUrl, reporterSessionToken, {
843
- fetch: adapters.fetch,
844
- });
133
+ (0, client_state_1.setStatus)(s, "disabled");
845
134
  }
846
- await (0, reporter_session_store_1.clearReporterSession)(adapters.secureStore, key);
847
- reporterSessionToken = null;
848
- identity = { ...identity, reporterSession: undefined };
849
- if (gen === generation)
850
- await bootAndArm(gen);
851
- }
852
- catch {
853
- // A Fixback problem must never disturb the host app.
854
135
  }
855
136
  }
856
137
  async function present() {
857
- if (status !== "ready")
138
+ if (s.status !== "ready")
858
139
  return;
859
140
  // Freeze the replay window as the composer opens (ADR-0055's posture, ported):
860
141
  // what the Reporter is reporting is what just happened, not what happens while
861
142
  // they type. A window left over from a composer they dismissed is given back
862
143
  // first, so its frames are never retained twice.
863
- releaseReplayWindow(pendingReplayWindow);
864
- pendingReplayWindow = replayRecorder?.snapshot() ?? null;
144
+ releaseReplayWindow(s.pendingReplayWindow);
145
+ s.pendingReplayWindow = s.replayRecorder?.snapshot() ?? null;
865
146
  let screenshot = null;
866
147
  if (options.screenshots !== false && adapters.captureScreenshot) {
867
148
  try {
@@ -872,7 +153,7 @@ function createFixbackClient(options, adapters = {}) {
872
153
  }
873
154
  }
874
155
  const context = { screenshot };
875
- for (const listener of presentListeners) {
156
+ for (const listener of s.presentListeners) {
876
157
  try {
877
158
  listener(context);
878
159
  }
@@ -888,7 +169,7 @@ function createFixbackClient(options, adapters = {}) {
888
169
  // (ADR-0023).
889
170
  (0, report_1.assembleContent)({
890
171
  comment: draft.comment,
891
- url: currentUrl(),
172
+ url: (0, client_state_1.currentUrl)(s),
892
173
  environment: (0, report_1.collectEnvironment)(readEnvironment(), version_1.EXPO_SDK_VERSION, release),
893
174
  trace: buffer.snapshot(),
894
175
  }), { hook: options.beforeSend, scrub: options.scrub });
@@ -898,8 +179,12 @@ function createFixbackClient(options, adapters = {}) {
898
179
  // Encode the window frozen when the composer opened (ADR-0044). This runs after
899
180
  // the Reporter pressed send, inside a flow they initiated — the one place the
900
181
  // cost of an encode is theirs to spend rather than the app's.
901
- const replay = await encodeReplay(pendingReplayWindow);
902
- const result = await (0, submit_1.submitReport)(apiUrl, { key, identity, content, screenshot: draft.screenshot ?? null, replay }, submitDeps());
182
+ const replay = await encodeReplay(s.pendingReplayWindow);
183
+ const result = await (0, submit_1.submitReport)(apiUrl, { key, identity: s.identity, content, screenshot: draft.screenshot ?? null, replay }, (0, client_state_1.submitDeps)(s));
184
+ // Held for maintenance (an app that booted before it began): show the notice and
185
+ // ask boot when it ends — the composer keeps the draft for the Reporter to send then.
186
+ if (!result.ok && result.reason === "maintenance")
187
+ setMaintenance(result.maintenance);
903
188
  // A delivered screenshot's tmpfile has served its purpose — release it.
904
189
  // On a failure the file is kept: the composer holds the draft for retry.
905
190
  if (result.ok)
@@ -909,8 +194,8 @@ function createFixbackClient(options, adapters = {}) {
909
194
  if (replay)
910
195
  releaseReplayFile(replay.file.uri);
911
196
  if (result.ok) {
912
- releaseReplayWindow(pendingReplayWindow);
913
- pendingReplayWindow = null;
197
+ releaseReplayWindow(s.pendingReplayWindow);
198
+ s.pendingReplayWindow = null;
914
199
  }
915
200
  return result;
916
201
  }
@@ -940,17 +225,17 @@ function createFixbackClient(options, adapters = {}) {
940
225
  * session and the app's cache keeps a recording nobody reported.
941
226
  */
942
227
  function discardReplay() {
943
- releaseReplayWindow(pendingReplayWindow);
944
- pendingReplayWindow = null;
228
+ releaseReplayWindow(s.pendingReplayWindow);
229
+ s.pendingReplayWindow = null;
945
230
  }
946
231
  function trackScreen(name) {
947
232
  try {
948
233
  const trimmed = typeof name === "string" ? name.trim() : "";
949
234
  if (!trimmed)
950
235
  return;
951
- const from = currentUrl();
952
- currentScreen = trimmed;
953
- const to = currentUrl();
236
+ const from = (0, client_state_1.currentUrl)(s);
237
+ s.currentScreen = trimmed;
238
+ const to = (0, client_state_1.currentUrl)(s);
954
239
  if (from && to && from !== to) {
955
240
  buffer.add((0, sdk_core_1.navigationCrumb)(from, to, now()));
956
241
  }
@@ -961,17 +246,17 @@ function createFixbackClient(options, adapters = {}) {
961
246
  }
962
247
  return {
963
248
  start,
964
- getStatus: () => status,
965
- getBoot: () => boot,
966
- canSubmit: () => status === "ready" && boot?.canSubmit === true,
249
+ getStatus: () => s.status,
250
+ getBoot: () => s.boot,
251
+ canSubmit: () => s.status === "ready" && s.boot?.canSubmit === true,
967
252
  onStatus(listener) {
968
- statusListeners.add(listener);
969
- return () => statusListeners.delete(listener);
253
+ s.statusListeners.add(listener);
254
+ return () => s.statusListeners.delete(listener);
970
255
  },
971
256
  present,
972
257
  onPresent(listener) {
973
- presentListeners.add(listener);
974
- return () => presentListeners.delete(listener);
258
+ s.presentListeners.add(listener);
259
+ return () => s.presentListeners.delete(listener);
975
260
  },
976
261
  trackScreen,
977
262
  submit,
@@ -980,31 +265,39 @@ function createFixbackClient(options, adapters = {}) {
980
265
  shakeConfig: () => (0, shake_1.resolveShakeConfig)(options.shake),
981
266
  signIn,
982
267
  signOut,
983
- identity: () => reporterIdentity(),
268
+ identity: () => (0, client_state_1.reporterIdentity)(s),
984
269
  onIdentity(listener) {
985
- identityListeners.add(listener);
986
- return () => identityListeners.delete(listener);
270
+ s.identityListeners.add(listener);
271
+ return () => s.identityListeners.delete(listener);
272
+ },
273
+ maintenance: () => s.maintenance,
274
+ onMaintenance(listener) {
275
+ s.maintenanceListeners.add(listener);
276
+ return () => s.maintenanceListeners.delete(listener);
987
277
  },
988
278
  destroy() {
989
279
  // Abandon any in-flight start and allow a later start() to re-arm —
990
280
  // React StrictMode replays the provider's effect on this same instance.
991
- generation += 1;
992
- running = false;
281
+ s.generation += 1;
282
+ s.running = false;
283
+ clearMaintenanceRecheck();
284
+ s.maintenance = null;
993
285
  disarmCapture();
994
286
  try {
995
- teardownLinking?.();
287
+ s.teardownLinking?.();
996
288
  }
997
289
  catch {
998
290
  /* teardown is best-effort */
999
291
  }
1000
- teardownLinking = null;
292
+ s.teardownLinking = null;
1001
293
  // Nothing will redeem an inbound code now, so a `signIn()` still waiting on one
1002
294
  // is answered rather than left pending for the life of the app.
1003
295
  settleInboundWaiters(false);
1004
- statusListeners.clear();
1005
- presentListeners.clear();
1006
- identityListeners.clear();
1007
- setStatus("disabled");
296
+ s.statusListeners.clear();
297
+ s.presentListeners.clear();
298
+ s.identityListeners.clear();
299
+ s.maintenanceListeners.clear();
300
+ (0, client_state_1.setStatus)(s, "disabled");
1008
301
  },
1009
302
  };
1010
303
  }