@fairfox/polly 0.58.0 → 0.59.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.
@@ -23,6 +23,7 @@ import { Repo, type StorageAdapterInterface } from "@automerge/automerge-repo/sl
23
23
  import type { KeyringStorage } from "./keyring-storage";
24
24
  import { type MeshKeyring, MeshNetworkAdapter } from "./mesh-network-adapter";
25
25
  import { MeshSignalingClient, type MeshSignalingClientOptions } from "./mesh-signaling-client";
26
+ import { type MeshStateLoadedRejectionBreadcrumb } from "./mesh-state";
26
27
  import { MeshWebRTCAdapter, type MeshWebRTCAdapterOptions } from "./mesh-webrtc-adapter";
27
28
  /** Options for {@link createMeshClient}. */
28
29
  export interface CreateMeshClientOptions {
@@ -232,6 +233,28 @@ export interface MeshStateModuleDiagnostics {
232
233
  * true` (they're using a module instance no mesh client ever
233
234
  * configured). */
234
235
  wasResolved: boolean;
236
+ /** Polly#107 post-H5 instrumentation. Count of `$meshState`-family
237
+ * lazy factory invocations since module load. Once the consumer's
238
+ * pre-warm pass completes, this equals the number of distinct
239
+ * `$mesh*` wrappers whose handles the loader actually tried to
240
+ * resolve. Compared to {@link lazyReachedRepo}: gap = throws
241
+ * before any Repo work. */
242
+ lazyInvocations: number;
243
+ /** Polly#107 post-H5 instrumentation. Count of factory invocations
244
+ * that reached the Repo subsystem (`repo.handles[...]`, `repo.find`
245
+ * or `repo.import`) before returning or throwing. If
246
+ * {@link lazyInvocations} is N and this is N, every wrapper
247
+ * touched the Repo — any missing handles are downstream of Repo
248
+ * registration. If this is < N, the gap is the call site to
249
+ * instrument next. */
250
+ lazyReachedRepo: number;
251
+ /** Polly#107 post-H5 instrumentation. Breadcrumb for the most
252
+ * recent rejection from a `$meshState`-family `loaded` promise
253
+ * (or its factory). Captured even when the consumer's wrapper
254
+ * never awaits `loaded` and the rejection would otherwise vanish
255
+ * silently. `undefined` means no rejection has escaped any
256
+ * wrapper on THIS module instance since module load. */
257
+ lastLoadedRejection: MeshStateLoadedRejectionBreadcrumb | undefined;
235
258
  }
236
259
  /** The mesh client's enriched per-peer state snapshot. Mirrors the
237
260
  * underlying {@link MeshWebRTCAdapter.getPeerStateSnapshot} shape but
@@ -113,6 +113,33 @@ export declare function isMeshStateConfigured(): boolean;
113
113
  * called against this module instance. See
114
114
  * {@link meshStateEverResolved}. */
115
115
  export declare function wasMeshStateResolved(): boolean;
116
+ /** Returns the count of factory invocations since module load. See
117
+ * {@link lazyInvocations}. */
118
+ export declare function getLazyInvocations(): number;
119
+ /** Returns the count of factory invocations that reached
120
+ * `repo.find` / `repo.import` since module load. See
121
+ * {@link lazyReachedRepo}. */
122
+ export declare function getLazyReachedRepo(): number;
123
+ /** Polly#107 post-H5 instrumentation. Records the most recent
124
+ * rejection (or synchronous throw) escaping the factory body — the
125
+ * `loaded` promise's rejection path. Today an unawaited rejection
126
+ * inside a consumer wrapper vanishes without trace; capturing the
127
+ * message + stack here on the module and exposing it via the
128
+ * snapshot leaves a breadcrumb the operator can read in one paste.
129
+ *
130
+ * The format is the JSON-safe `{ name, message, stack, at }` shape
131
+ * so the snapshot read does not have to traffic in `Error`
132
+ * instances. `at` is `Date.now()` at the time the rejection was
133
+ * captured. */
134
+ export interface MeshStateLoadedRejectionBreadcrumb {
135
+ name: string;
136
+ message: string;
137
+ stack: string | undefined;
138
+ at: number;
139
+ }
140
+ /** Returns the most recent rejection escaping a `$meshState` factory
141
+ * invocation since module load. See {@link lastLoadedRejection}. */
142
+ export declare function getLastLoadedRejection(): MeshStateLoadedRejectionBreadcrumb | undefined;
116
143
  /**
117
144
  * Create a peer-replicated state primitive backed by Automerge with a mesh
118
145
  * transport. Every device holds a full replica; no central server holds a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fairfox/polly",
3
- "version": "0.58.0",
3
+ "version": "0.59.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Multi-execution-context framework with reactive state and cross-context messaging for Chrome extensions, PWAs, and worker-based applications",