@powerhousedao/reactor-browser 6.2.2-dev.5 → 6.2.2-dev.51

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 (66) hide show
  1. package/README.md +283 -0
  2. package/dist/attachment-service-BImio0aq.d.ts +982 -0
  3. package/dist/attachment-service-BImio0aq.d.ts.map +1 -0
  4. package/dist/client-BaHKLGy5.d.ts +14 -0
  5. package/dist/client-BaHKLGy5.d.ts.map +1 -0
  6. package/dist/{client-u13cr-Vg.js → client-Zz_l9QzI.js} +30 -3
  7. package/dist/client-Zz_l9QzI.js.map +1 -0
  8. package/dist/{client-_Gh2Uf0E.js → client-s_ISz_Zs.js} +30 -4
  9. package/dist/client-s_ISz_Zs.js.map +1 -0
  10. package/dist/{document-by-id-dLYFX-xz.js → document-by-id-BSZqTN66.js} +81 -51
  11. package/dist/document-by-id-BSZqTN66.js.map +1 -0
  12. package/dist/document-operations-ZLuPOV3H.js +2778 -0
  13. package/dist/document-operations-ZLuPOV3H.js.map +1 -0
  14. package/dist/global-CbyAMlZd.d.ts +400 -0
  15. package/dist/global-CbyAMlZd.d.ts.map +1 -0
  16. package/dist/index-CxxxP14A.d.ts +144 -0
  17. package/dist/index-CxxxP14A.d.ts.map +1 -0
  18. package/dist/index-DPq1VjpB.d.ts +345 -0
  19. package/dist/index-DPq1VjpB.d.ts.map +1 -0
  20. package/dist/index.d.ts +296 -706
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +599 -1657
  23. package/dist/index.js.map +1 -1
  24. package/dist/{inspector-proxy-CvQDDxmT.d.ts → inspector-proxy-CaCFdEG4.d.ts} +4 -2
  25. package/dist/inspector-proxy-CaCFdEG4.d.ts.map +1 -0
  26. package/dist/{make-ph-event-functions-BHoLPif5.js → make-ph-event-functions-DBq3iWYn.js} +1 -1
  27. package/dist/{make-ph-event-functions-BHoLPif5.js.map → make-ph-event-functions-DBq3iWYn.js.map} +1 -1
  28. package/dist/{index-DS4W07Y8.d.ts → pglite-CntadC_p-BtEalg1H.d.ts} +2 -142
  29. package/dist/pglite-CntadC_p-BtEalg1H.d.ts.map +1 -0
  30. package/dist/{relational-Dj06-YkI.js → relational-C_0GdGVN.js} +2 -2
  31. package/dist/{relational-Dj06-YkI.js.map → relational-C_0GdGVN.js.map} +1 -1
  32. package/dist/renown-BZabzj4l.js +68 -0
  33. package/dist/renown-BZabzj4l.js.map +1 -0
  34. package/dist/{renown-D-1c_Bvx.js → renown-C7a1ygsj.js} +471 -57
  35. package/dist/renown-C7a1ygsj.js.map +1 -0
  36. package/dist/src/analytics/index.d.ts +1 -1
  37. package/dist/src/analytics/index.js +2 -1
  38. package/dist/src/analytics/index.js.map +1 -1
  39. package/dist/src/graphql/client.d.ts +3 -2
  40. package/dist/src/graphql/client.js +1 -1
  41. package/dist/src/graphql-client/entry.d.ts +4 -0
  42. package/dist/src/graphql-client/entry.js +3 -0
  43. package/dist/src/relational/index.d.ts +1 -1
  44. package/dist/src/relational/index.js +1 -1
  45. package/dist/src/renown/index.d.ts +2 -2
  46. package/dist/src/renown/index.js +3 -2
  47. package/dist/src/rpc/index.d.ts +5 -3
  48. package/dist/src/rpc/index.d.ts.map +1 -1
  49. package/dist/src/rpc/index.js +37 -10
  50. package/dist/src/rpc/index.js.map +1 -1
  51. package/dist/store-DAJq6vSs.js +37 -0
  52. package/dist/store-DAJq6vSs.js.map +1 -0
  53. package/dist/{client-09xv0Dq6.d.ts → types-Bitg5Z5j.d.ts} +25 -13
  54. package/dist/types-Bitg5Z5j.d.ts.map +1 -0
  55. package/dist/{types-CPV0Cnsy.d.ts → types-wGaiXwjh.d.ts} +1 -1
  56. package/dist/{types-CPV0Cnsy.d.ts.map → types-wGaiXwjh.d.ts.map} +1 -1
  57. package/package.json +15 -9
  58. package/dist/client-09xv0Dq6.d.ts.map +0 -1
  59. package/dist/client-_Gh2Uf0E.js.map +0 -1
  60. package/dist/client-u13cr-Vg.js.map +0 -1
  61. package/dist/document-by-id-dLYFX-xz.js.map +0 -1
  62. package/dist/index-D3bV5rcl.d.ts +0 -216
  63. package/dist/index-D3bV5rcl.d.ts.map +0 -1
  64. package/dist/index-DS4W07Y8.d.ts.map +0 -1
  65. package/dist/inspector-proxy-CvQDDxmT.d.ts.map +0 -1
  66. package/dist/renown-D-1c_Bvx.js.map +0 -1
@@ -0,0 +1,982 @@
1
+ import { a as PHGlobal$1, b as IPackagesListener, ct as PromiseWithState, d as UsePHGlobalValue$1, ot as IDocumentCache, rt as IReactorBrowserClient$1, st as PromiseState, u as SetPHGlobalValue$1, v as IPackageListerUnsubscribe, x as PackageManagerInstallResult, y as IPackageManager } from "./global-CbyAMlZd.js";
2
+ import { t as PGlite } from "./pglite-CntadC_p-BtEalg1H.js";
3
+ import { D as Scalars, E as PropagationMode$1, O as SdkFunctionWrapper, S as GetDocumentQuery, T as PhDocumentFieldsFragment, c as ReactorGraphQLClient, k as ViewFilterInput, x as GetDocumentOperationsQuery, y as DocumentChangesSubscription } from "./types-Bitg5Z5j.js";
4
+ import { Action, DocumentModelLib, DocumentModelModule, Operation, PHDocument } from "document-model";
5
+ import { Action as Action$1, DocumentOperations, ISigner, Operation as Operation$1, PHBaseState, PHDocument as PHDocument$1, PHDocumentHeader } from "@powerhousedao/shared/document-model";
6
+ import { ReactNode } from "react";
7
+ import * as _powerhousedao_reactor0 from "@powerhousedao/reactor";
8
+ import { Database, DocumentChangeEvent, DocumentModelSource, IDocumentModelRegistry, ISyncManager, OperationFilter, PagedResults, PagingOptions, PropagationMode, SearchFilter, ViewFilter } from "@powerhousedao/reactor";
9
+ import { GraphQLClient, Variables } from "graphql-request";
10
+ import * as graphql from "graphql";
11
+ import { DocumentNode } from "graphql";
12
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
13
+ import { IAttachmentService } from "@powerhousedao/reactor-attachments/client";
14
+ import { Kysely } from "kysely";
15
+ import { AddPHGlobalEventHandler, BrowserReactorClientModule, IReactorBrowserClient, SetPHGlobalValue, UsePHGlobalValue, WorkerReactorClientModule } from "@powerhousedao/reactor-browser";
16
+ import { RegistryPackageSource } from "@powerhousedao/shared";
17
+
18
+ //#region src/document-cache.d.ts
19
+ declare function addPromiseState<T>(promise: Promise<T>): PromiseWithState<T>;
20
+ declare function readPromiseState<T>(promise: Promise<T> | PromiseWithState<T>): PromiseState<T>;
21
+ /**
22
+ * Document cache implementation that uses the new ReactorClient API.
23
+ *
24
+ * This cache subscribes to document change events via IReactorBrowserClient.subscribe()
25
+ * and automatically updates the cache when documents are created, updated, or deleted.
26
+ */
27
+ declare class DocumentCache implements IDocumentCache {
28
+ private client;
29
+ private documents;
30
+ private batchPromises;
31
+ private listeners;
32
+ /**
33
+ * Cache keys that fetched a document under a name other than its id --
34
+ * slugs, which `client.get` resolves. Change events dispatch by `header.id`,
35
+ * so without this mapping a slug-keyed entry (and its listeners) would never
36
+ * see an update: keyed by the id the events carry, valued by the other keys
37
+ * the same document is cached under.
38
+ */
39
+ private aliasKeys;
40
+ private unsubscribe;
41
+ constructor(client: IReactorBrowserClient$1);
42
+ private handleDocumentChange;
43
+ private handleDocumentDeleted;
44
+ private handleDocumentUpdated;
45
+ /** The id an event dispatches by, plus every alias the document is cached under. */
46
+ private cacheKeysFor;
47
+ /** Records that `key` cached the document change events know as `header.id`. */
48
+ private recordAlias;
49
+ private invalidateBatchesContaining;
50
+ get(id: string, refetch?: boolean): Promise<PHDocument$1>;
51
+ getBatch(ids: string[]): Promise<PHDocument$1[]>;
52
+ subscribe(id: string | string[], callback: () => void): () => void;
53
+ /**
54
+ * Disposes of the cache and unsubscribes from document change events.
55
+ */
56
+ dispose(): void;
57
+ }
58
+ //#endregion
59
+ //#region src/remote-controller/types.d.ts
60
+ type RemoteControllerGraphQLClient = Pick<ReactorGraphQLClient, "GetDocument" | "GetDocumentWithOperations" | "GetDocumentOperations" | "MutateDocument" | "CreateDocument" | "CreateEmptyDocument" | "DeleteDocument" | "BatchGetDocumentOperations" | "BatchGetDocumentWithOperations">;
61
+ type RemoteDocumentData = PhDocumentFieldsFragment;
62
+ type RemoteOperation = GetDocumentOperationsQuery["documentOperations"]["items"][number];
63
+ type RemoteOperationResultPage = GetDocumentOperationsQuery["documentOperations"];
64
+ /**
65
+ * Options for creating a RemoteDocumentController.
66
+ */
67
+ type RemoteControllerOptions = {
68
+ client: RemoteControllerGraphQLClient; /** Remote document id. Omit for new documents. */
69
+ documentId?: string; /** "batch" requires explicit push(), "streaming" auto-pushes after actions. Defaults to "batch" */
70
+ mode?: "batch" | "streaming"; /** Optional signer for action signing. */
71
+ signer?: ISigner; /** Branch name, defaults to "main". */
72
+ branch?: string; /** Parent document identifier for creating new documents. */
73
+ parentIdentifier?: string; /** Conflict resolution strategy when remote has new operations. Default: no check (current behavior). */
74
+ onConflict?: ConflictStrategy; /** Called when a streaming-mode push fails. If not provided, errors are silently swallowed. */
75
+ onPushError?: (error: unknown) => void; /** Number of operations to fetch per page. Defaults to 100. */
76
+ operationsPageSize?: number;
77
+ };
78
+ /**
79
+ * Result of a push operation.
80
+ */
81
+ type PushResult = {
82
+ remoteDocument: RemoteDocumentData;
83
+ actionCount: number; /** The actions that were sent to the server (after signing, if applicable). */
84
+ operations: ReadonlyArray<Action$1>;
85
+ };
86
+ /**
87
+ * Sync status of the controller.
88
+ */
89
+ type SyncStatus$1 = {
90
+ pendingActionCount: number;
91
+ connected: boolean;
92
+ documentId: string;
93
+ remoteRevision: Record<string, number>;
94
+ };
95
+ /**
96
+ * A tracked action with operation context for signing.
97
+ */
98
+ type TrackedAction = {
99
+ action: Action$1;
100
+ prevOpHash: string;
101
+ prevOpIndex: number;
102
+ };
103
+ /** Information about a detected conflict. */
104
+ type ConflictInfo = {
105
+ /** Remote operations added since the last pull, grouped by scope. */remoteOperations: Record<string, RemoteOperation[]>; /** Local actions pending push. */
106
+ localActions: TrackedAction[]; /** Remote revision at last pull. */
107
+ knownRevision: Record<string, number>; /** Current remote revision. */
108
+ currentRevision: Record<string, number>;
109
+ };
110
+ /** Custom merge handler receives conflict info and returns actions to push (or throws to abort). */
111
+ type MergeHandler = (conflict: ConflictInfo) => Action$1[] | Promise<Action$1[]>;
112
+ /** Conflict resolution strategy. */
113
+ type ConflictStrategy = "reject" | "rebase" | MergeHandler;
114
+ /** Event emitted when the document changes. */
115
+ type RemoteDocumentChangeEvent = {
116
+ source: "action" | "pull";
117
+ document: PHDocument$1<PHBaseState>;
118
+ };
119
+ /** Listener for document change events. */
120
+ type DocumentChangeListener = (event: RemoteDocumentChangeEvent) => void;
121
+ /** Result of fetching operations. */
122
+ type GetOperationsResult = {
123
+ operationsByScope: Record<string, RemoteOperation[]>;
124
+ };
125
+ /** Result of fetching a document together with its operations. */
126
+ type GetDocumentWithOperationsResult = {
127
+ document: RemoteDocumentData;
128
+ childIds: ReadonlyArray<string>;
129
+ operations: GetOperationsResult;
130
+ };
131
+ interface IRemoteClient {
132
+ getDocument(identifier: string, branch?: string): Promise<GetDocumentResult | null>;
133
+ /** Fetch document metadata and operations in a single call. */
134
+ getDocumentWithOperations(identifier: string, branch?: string, sinceRevision?: Record<string, number>, scopes?: string[]): Promise<GetDocumentWithOperationsResult | null>;
135
+ getAllOperations(documentId: string, branch?: string, sinceRevision?: Record<string, number>, scopes?: string[]): Promise<GetOperationsResult>;
136
+ pushActions(documentIdentifier: string, actions: ReadonlyArray<NonNullable<unknown>>, branch?: string): Promise<RemoteDocumentData>;
137
+ createDocument(document: NonNullable<unknown>, parentIdentifier?: string): Promise<RemoteDocumentData>;
138
+ createEmptyDocument(documentType: string, parentIdentifier?: string): Promise<RemoteDocumentData>;
139
+ deleteDocument(identifier: string, propagate?: PropagationMode$1): Promise<boolean>;
140
+ }
141
+ type GetDocumentResult = {
142
+ document: RemoteDocumentData;
143
+ childIds: ReadonlyArray<string>;
144
+ };
145
+ interface IRemoteController<TState extends PHBaseState = PHBaseState> {
146
+ readonly header: PHDocumentHeader;
147
+ readonly state: TState;
148
+ readonly operations: DocumentOperations;
149
+ readonly document: PHDocument$1<TState>;
150
+ readonly status: SyncStatus$1;
151
+ onChange(listener: DocumentChangeListener): () => void;
152
+ push(): Promise<PushResult>;
153
+ pull(): Promise<RemoteDocumentData>;
154
+ delete(propagate?: PropagationMode$1): Promise<boolean>;
155
+ }
156
+ //#endregion
157
+ //#region src/graphql-client/adapter.d.ts
158
+ /** The `document` payload of a `GetDocument` query, once the null case is handled. */
159
+ type GetDocumentQueryResult = NonNullable<GetDocumentQuery["document"]>;
160
+ /** The `PHDocumentFields` fragment as returned by `GetDocument`. */
161
+ type GetDocumentQueryFields = GetDocumentQueryResult["document"];
162
+ /** The `revisionsList` selection of the `PHDocumentFields` fragment. */
163
+ type RevisionsListSelection = GetDocumentQueryFields["revisionsList"];
164
+ /**
165
+ * Converts a `GetDocument` result into a `PHDocument`.
166
+ *
167
+ * Unlike the legacy `src/graphql/adapters.ts` this preserves the per-scope
168
+ * revision map, which the write path needs to compute the `prevOpIndex` of a
169
+ * signed action. `sig` is filled with the empty shape used by
170
+ * `createPresignedHeader`: the creation signature is not fetchable over
171
+ * GraphQL and is not part of the operation signing payload.
172
+ *
173
+ * The read path never fetches operation history, so `operations` is a map of
174
+ * the document's known scopes to empty arrays.
175
+ *
176
+ * `branch` is the branch the document was read from. The GraphQL type does not
177
+ * carry it, so it has to be passed back in by the caller; it defaults to the
178
+ * server's own default branch.
179
+ */
180
+ declare function phDocumentFromGetDocument<TDocument extends PHDocument = PHDocument>(document: GetDocumentQueryFields, branch?: string): TDocument;
181
+ /**
182
+ * Converts a mutation result into a `PHDocument`, carrying the operations the
183
+ * mutation produced.
184
+ *
185
+ * `dispatchActions` reads per-action failures out of `operations[scope]`, so
186
+ * unlike the read path this one must not return empty operation lists.
187
+ */
188
+ declare function phDocumentFromMutation<TDocument extends PHDocument = PHDocument>(document: GetDocumentQueryFields, operations: readonly RemoteOperation[], branch?: string): TDocument;
189
+ /** Turns a `revisionsList` selection into the header's per-scope revision map. */
190
+ declare function revisionMapFromRevisionsList(revisionsList: RevisionsListSelection): Record<string, number>;
191
+ //#endregion
192
+ //#region src/graphql-client/auth.d.ts
193
+ /**
194
+ * Resolves the bearer token to send with a request.
195
+ *
196
+ * Returning `undefined` (or an empty string) means "send this request
197
+ * anonymously": open Switchboards must keep serving reads to logged-out users.
198
+ */
199
+ type BearerTokenProvider = () => Promise<string | undefined>;
200
+ /**
201
+ * The default token provider: the token of the currently logged-in Renown user.
202
+ *
203
+ * It is deliberately resolved from `window.ph` on every call rather than
204
+ * captured at construction time, so a client built before login starts sending
205
+ * the token as soon as there is one.
206
+ *
207
+ * The token is requested WITHOUT an `aud` claim - the Switchboard verifier
208
+ * rejects tokens that carry an audience.
209
+ */
210
+ declare function ambientRenownTokenProvider(): Promise<string | undefined>;
211
+ /**
212
+ * Builds the SDK middleware that authenticates every request.
213
+ *
214
+ * The token is resolved per request and never cached, so a login, a logout or
215
+ * an expiry between two calls is picked up by the next one. When no token is
216
+ * available the request goes out unauthenticated.
217
+ */
218
+ declare function makeAuthMiddleware(tokenProvider: BearerTokenProvider): SdkFunctionWrapper;
219
+ //#endregion
220
+ //#region src/graphql-client/subgraph.d.ts
221
+ /**
222
+ * The factory a GraphQL code generator produces for a schema.
223
+ *
224
+ * It is the signature of `getSdk` emitted by the `typescript-graphql-request`
225
+ * plugin - the generated `getSdk` in `src/graphql/gen/schema.ts` is the
226
+ * canonical example - so a project can hand its own generated function straight
227
+ * to {@link SubgraphSdkRegistry.get} and keep every operation typed.
228
+ */
229
+ type SubgraphSdkFactory<TSdk> = (client: GraphQLClient, withWrapper?: SdkFunctionWrapper) => TSdk;
230
+ /**
231
+ * A GraphQL document that carries its result and variable types.
232
+ *
233
+ * This is the shape a code generator gives a document (`TypedDocumentNode`),
234
+ * declared structurally so that reactor-browser needs no dependency on
235
+ * `@graphql-typed-document-node/core`. A plain `DocumentNode` satisfies it too,
236
+ * with the result type falling back to whatever the caller passes explicitly.
237
+ */
238
+ type TypedGraphQLDocument<TResult, TVariables> = DocumentNode & {
239
+ __apiType?: (variables: TVariables) => TResult;
240
+ };
241
+ /** Extras for a one-off request. */
242
+ type GraphQLRequestOptions = {
243
+ /**
244
+ * The operation name reported to the auth and logging middleware. Read off
245
+ * the document when it is not given.
246
+ */
247
+ operationName?: string;
248
+ /**
249
+ * The operation type reported to the middleware, e.g. `"mutation"`. Read off
250
+ * the document when it is not given.
251
+ */
252
+ operationType?: string;
253
+ signal?: AbortSignal;
254
+ };
255
+ /**
256
+ * Derives a subgraph's endpoint from the Switchboard's GraphQL endpoint.
257
+ *
258
+ * Subgraphs are served next to the supergraph, at `<graphql base>/<name>`, so
259
+ * `http://localhost:4001/graphql` plus `statements` is
260
+ * `http://localhost:4001/graphql/statements`.
261
+ */
262
+ declare function subgraphUrlFromGraphqlUrl(url: string, name: string): string;
263
+ /**
264
+ * Reads the operation name and type off a document, for the middleware.
265
+ *
266
+ * Nothing depends on getting this right - it is reported to the middleware, not
267
+ * sent to the server - so an unreadable document falls back to an anonymous
268
+ * query rather than throwing.
269
+ */
270
+ declare function describeGraphQLDocument(document: string | DocumentNode): {
271
+ operationName: string;
272
+ operationType: string;
273
+ };
274
+ /**
275
+ * Binds typed subgraph SDKs to one Switchboard's transport and auth.
276
+ *
277
+ * Every capability a Switchboard exposes lives behind the same base URL, so an
278
+ * app should not have to build a second client - with a second copy of the auth
279
+ * configuration - to reach a project's own subgraph. The registry derives the
280
+ * endpoint, reuses one transport per subgraph and hands the code generator's
281
+ * `getSdk` the very middleware the reactor operations already go through.
282
+ *
283
+ * Transport and typing only: subgraph results are not cached and produce no
284
+ * change events.
285
+ */
286
+ declare class SubgraphSdkRegistry {
287
+ private readonly url;
288
+ private readonly middleware;
289
+ private readonly bindings;
290
+ constructor(url: string, middleware?: SdkFunctionWrapper);
291
+ /**
292
+ * Returns the subgraph's SDK, building it on first use.
293
+ *
294
+ * The transport is kept per subgraph name, so repeated calls do not rebuild
295
+ * it. The SDK itself is only reused when the same factory is passed again -
296
+ * two different generated SDKs over one subgraph each get their own, rather
297
+ * than the second call being handed the first one's methods.
298
+ */
299
+ get<TSdk>(name: string, getSdk: SubgraphSdkFactory<TSdk>): TSdk;
300
+ /** Returns the subgraph's endpoint, for diagnostics and tests. */
301
+ urlFor(name: string): string;
302
+ private binding;
303
+ }
304
+ //#endregion
305
+ //#region src/graphql-client/graphql-reactor-client.d.ts
306
+ type GraphQLReactorClientOptions = {
307
+ /** The Switchboard GraphQL endpoint, e.g. `http://localhost:4001/graphql`. */url: string;
308
+ /**
309
+ * A pre-built SDK to use instead of the transport derived from `url`.
310
+ * Mainly a test seam.
311
+ *
312
+ * A client built this way carries no auth middleware: the injected SDK owns
313
+ * its own transport, and therefore its own headers.
314
+ */
315
+ graphqlClient?: ReactorGraphQLClient;
316
+ /**
317
+ * Resolves the bearer token sent with every request, per request.
318
+ *
319
+ * Defaults to {@link ambientRenownTokenProvider}, i.e. the token of the
320
+ * logged-in Renown user, or none when nobody is logged in.
321
+ */
322
+ tokenProvider?: BearerTokenProvider;
323
+ /**
324
+ * The Switchboard GraphQL subscriptions endpoint, e.g.
325
+ * `ws://localhost:4001/graphql/subscriptions`.
326
+ *
327
+ * Defaults to the endpoint derived from `url` by
328
+ * {@link subscriptionsUrlFromGraphqlUrl}.
329
+ */
330
+ subscriptionsUrl?: string;
331
+ /**
332
+ * Whether server-pushed changes are delivered to subscribers.
333
+ *
334
+ * On by default: the first `subscribe` call opens a websocket and every
335
+ * change the Switchboard reports is emitted to matching subscribers, so
336
+ * documents another user, tab or processor writes invalidate the cache.
337
+ *
338
+ * Set it to `false` where there is no websocket to talk to. The client then
339
+ * only emits the changes it made itself.
340
+ */
341
+ realtime?: boolean;
342
+ };
343
+ /**
344
+ * The marker {@link isGraphQLReactorClient} looks for.
345
+ *
346
+ * A page can end up with two copies of this module - an app that bundles a
347
+ * package carrying its own copy, or a dev server that hot-replaced it - and
348
+ * then `instanceof` compares an instance against the other copy's class object
349
+ * and answers `false`. A branded property survives both.
350
+ */
351
+ declare const graphQLReactorClientBrand: "__powerhouseGraphQLReactorClient";
352
+ /**
353
+ * A light implementation of {@link IReactorBrowserClient} that talks plain
354
+ * GraphQL to a Switchboard, with no reactor in the bundle.
355
+ *
356
+ * It fills the same `window.ph` slots the full in-browser reactor client fills,
357
+ * so the reactor-browser hooks cannot tell the two apart.
358
+ */
359
+ declare class GraphQLReactorClient implements IReactorBrowserClient$1 {
360
+ /** See {@link isGraphQLReactorClient}. */
361
+ readonly [graphQLReactorClientBrand] = true;
362
+ private readonly sdk;
363
+ private readonly subgraphs;
364
+ private readonly listeners;
365
+ private readonly tokenProvider;
366
+ private readonly subscriptionsUrl;
367
+ private stopRealtime;
368
+ private realtimeStarted;
369
+ private realtimeGeneration;
370
+ private realtimeErrorLogged;
371
+ constructor(options: GraphQLReactorClientOptions);
372
+ get<TDocument extends PHDocument>(identifier: string, view?: ViewFilter, signal?: AbortSignal): Promise<TDocument>;
373
+ getOperations(documentIdentifier: string, view?: ViewFilter, filter?: OperationFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<Operation>>;
374
+ create<TDocument extends PHDocument = PHDocument>(document: PHDocument, parentIdentifier?: string, signal?: AbortSignal): Promise<TDocument>;
375
+ /**
376
+ * Pushes actions to the Switchboard and returns the updated document.
377
+ *
378
+ * The document is fetched first: the response is the baseline for the
379
+ * `sinceRevision` filter that narrows the returned operations to the ones
380
+ * this call appended, and it carries the state hash a signed action is
381
+ * stamped with.
382
+ *
383
+ * The emitted `Updated` event carries the document's id, never the
384
+ * identifier this was called with: subscribers - including `DocumentCache` -
385
+ * work in id space.
386
+ */
387
+ execute<TDocument extends PHDocument>(documentIdentifier: string, branch: string, actions: Action[], signal?: AbortSignal): Promise<TDocument>;
388
+ /**
389
+ * Deletes a document and announces it as a `Deleted` event.
390
+ *
391
+ * Pass a document id. The server resolves a slug just as happily, but
392
+ * `deleteDocument` returns a boolean - there is no document left to read an
393
+ * id off - so the identifier is announced verbatim on `context.childId`. A
394
+ * subscriber keyed by id, `DocumentCache` included, therefore only reacts to
395
+ * a delete by id.
396
+ */
397
+ deleteDocument(identifier: string, propagate?: PropagationMode, signal?: AbortSignal): Promise<void>;
398
+ /**
399
+ * Registers a change subscriber and returns its unsubscribe function.
400
+ *
401
+ * Two things produce the events delivered here. Every successful `create`,
402
+ * `execute` and `deleteDocument` emits one, which is what makes a
403
+ * `DocumentCache` built on this client invalidate after a dispatch. And,
404
+ * unless realtime is switched off, the first call to this method opens a
405
+ * websocket to the Switchboard and every change it reports - from another
406
+ * user, another tab or a server-side processor - is emitted too. A write of
407
+ * this client's own is therefore announced twice, once locally and once by
408
+ * the server; the cache refetches twice, which is harmless.
409
+ *
410
+ * A websocket that cannot be opened or is refused is logged once and then
411
+ * ignored: realtime is an enhancement, never a dependency. The failed socket
412
+ * is closed, so the next subscriber to arrive tries again.
413
+ *
414
+ * `view` is accepted for interface compatibility and ignored: the emitted
415
+ * documents are whatever the write returned, so there is nothing to re-scope.
416
+ *
417
+ * Events live in id space: `search.ids` is matched against the resolved
418
+ * document id, never against the identifier the write was issued with. The
419
+ * one exception is `deleteDocument`, which has no document to resolve an id
420
+ * from - see its own note. A `DocumentCache` on this client must therefore
421
+ * be read by id: a slug-keyed entry is never invalidated.
422
+ */
423
+ subscribe(search: SearchFilter, callback: (event: DocumentChangeEvent) => void, view?: ViewFilter): () => void;
424
+ /**
425
+ * Closes the realtime socket, if one was opened.
426
+ *
427
+ * Registered subscribers are left in place: they still receive the events
428
+ * this client produces itself.
429
+ *
430
+ * Disposing is NOT final - a later `subscribe` opens a new socket. React
431
+ * remounts a tree by running an effect's cleanup and then the effect again,
432
+ * on the same client, and `StrictMode` does exactly that on every mount; a
433
+ * terminal flag here would leave those pages without realtime for good, with
434
+ * nothing logged.
435
+ */
436
+ dispose(): void;
437
+ /**
438
+ * Binds a project's generated SDK to this client's transport and auth.
439
+ *
440
+ * Subgraphs are served next to the reactor's own supergraph, so the endpoint
441
+ * is derived from the client's `url` by appending the name, and the SDK is
442
+ * handed the same auth middleware every reactor call goes through. An app
443
+ * therefore configures one URL and one token provider, and reaches every
444
+ * capability of its Switchboard through this one client.
445
+ *
446
+ * `getSdk` is the function a GraphQL code generator emits for the subgraph's
447
+ * schema - see the README in this folder for the codegen recipe.
448
+ *
449
+ * Transport and typing only. Subgraph results are not cached, produce no
450
+ * change events and never reach `useDocument`.
451
+ */
452
+ subgraph<TSdk>(name: string, getSdk: SubgraphSdkFactory<TSdk>): TSdk;
453
+ /**
454
+ * Runs a one-off GraphQL document against the Switchboard's own endpoint,
455
+ * through the same transport and auth as everything else.
456
+ *
457
+ * The escape hatch for an operation not worth generating an SDK for. Pass a
458
+ * document a code generator typed and the result type follows; pass a plain
459
+ * `gql` document or a string and name the result type at the call site.
460
+ */
461
+ request<TResult = unknown, TVariables extends Variables = Variables>(document: TypedGraphQLDocument<TResult, TVariables> | string, variables?: TVariables, options?: GraphQLRequestOptions): Promise<TResult>;
462
+ /**
463
+ * Opens the realtime socket on the first subscriber.
464
+ *
465
+ * The subscription is a firehose - no `search` argument - and this client
466
+ * applies each subscriber's own filter on the way out, exactly as it does for
467
+ * its own emissions.
468
+ */
469
+ private startRealtime;
470
+ /**
471
+ * Gives up on a failed socket so that a later subscriber can try again.
472
+ *
473
+ * `graphql-ws` retries on its own and only reports here once it has given up,
474
+ * or once the server refused the subscription outright - which is what an
475
+ * auth-enabled Switchboard does to an anonymous subscriber. Keeping the dead
476
+ * stop function would make every later `subscribe` a no-op, so realtime would
477
+ * stay off for the life of the page even after the user signs in.
478
+ *
479
+ * The generation stamp discards a report from a socket that has already been
480
+ * replaced or disposed.
481
+ */
482
+ private handleRealtimeFailure;
483
+ /** Closes the socket and lets a later subscriber open a new one. */
484
+ private teardownRealtime;
485
+ /** Maps a server event onto the client-side event and emits it. */
486
+ private emitServerEvent;
487
+ /**
488
+ * Reports a broken realtime socket once per client, however many sockets it
489
+ * goes through.
490
+ *
491
+ * `graphql-ws` retries on its own, and a Switchboard without a websocket
492
+ * endpoint would otherwise fill the console for as long as the page is open.
493
+ */
494
+ private logRealtimeError;
495
+ /**
496
+ * Delivers an event to every matching subscriber.
497
+ *
498
+ * A subscriber that throws is logged and skipped so one bad listener cannot
499
+ * stop the others from being notified.
500
+ */
501
+ private emitChange;
502
+ }
503
+ /**
504
+ * Whether a value is a {@link GraphQLReactorClient}, including one built by
505
+ * another copy of this module.
506
+ *
507
+ * Use this rather than `instanceof`: the brand it tests for is shared by every
508
+ * copy of the class, so a client built by a hot-replaced module or by a package
509
+ * that bundled its own copy is still recognised.
510
+ */
511
+ declare function isGraphQLReactorClient(client: unknown): client is GraphQLReactorClient;
512
+ /**
513
+ * Maps a reactor `ViewFilter` onto the GraphQL `ViewFilterInput`.
514
+ *
515
+ * Point-in-time reads are rejected: the Switchboard read API has no revision
516
+ * argument, so silently returning the head state would be wrong.
517
+ */
518
+ declare function viewFilterInputFromViewFilter(view?: ViewFilter): ViewFilterInput | undefined;
519
+ //#endregion
520
+ //#region src/graphql-client/graphql-reactor-provider.d.ts
521
+ declare global {
522
+ interface Window {
523
+ /** Set by {@link ensurePHEventHandlers}; see its doc comment. */
524
+ __phEventHandlersRegistered?: boolean;
525
+ }
526
+ }
527
+ /**
528
+ * Registers the `window.ph` event handlers once per page.
529
+ *
530
+ * The `set*` helpers only dispatch CustomEvents - nothing writes `window.ph`
531
+ * until `addPHEventHandlers` has registered the listeners that do. Registration
532
+ * is guarded by a marker on `window` rather than a module-level flag so that a
533
+ * hot module replacement, or two copies of this module, still register once.
534
+ */
535
+ declare function ensurePHEventHandlers(): void;
536
+ type GraphQLReactorProviderProps = {
537
+ /** The Switchboard GraphQL endpoint, e.g. `http://localhost:4001/graphql`. */url: string;
538
+ /**
539
+ * Resolves the bearer token sent with every request, per request. Defaults to
540
+ * the token of the logged-in Renown user, or none when nobody is logged in.
541
+ */
542
+ tokenProvider?: GraphQLReactorClientOptions["tokenProvider"];
543
+ /**
544
+ * The Switchboard GraphQL subscriptions endpoint, e.g.
545
+ * `ws://localhost:4001/graphql/subscriptions`. Defaults to the endpoint
546
+ * derived from `url`.
547
+ */
548
+ subscriptionsUrl?: GraphQLReactorClientOptions["subscriptionsUrl"];
549
+ /**
550
+ * Whether server-pushed changes are delivered. On by default; set it to
551
+ * `false` where there is no websocket to talk to.
552
+ */
553
+ realtime?: GraphQLReactorClientOptions["realtime"];
554
+ /**
555
+ * The attachment service the editors below this provider read attachments
556
+ * through, published into the same `window.ph` slot Connect publishes it in.
557
+ *
558
+ * The app constructs it: attachments are a separate package, and which
559
+ * storage an app talks to is the app's business. Leave it out and the slot
560
+ * stays empty, exactly as it is without this provider.
561
+ */
562
+ attachmentService?: PHGlobal$1["attachmentService"];
563
+ /**
564
+ * The document model modules the app works with, imported from its generated
565
+ * package's `document-models` SUBPATH:
566
+ *
567
+ * ```tsx
568
+ * import { TodoV1, TodoV2 } from "my-models/document-models";
569
+ * <GraphQLReactorProvider url={url} documentModels={[TodoV1, TodoV2]}>
570
+ * ```
571
+ *
572
+ * Wrapped via {@link packageFromDocumentModels} and published through a
573
+ * {@link StaticPackageManager} into the same `window.ph.vetraPackageManager`
574
+ * slot Connect fills, so `useDocumentModelModules` and
575
+ * `useDocumentModelModuleById` work below this provider.
576
+ *
577
+ * Modules only, deliberately - not whole packages. Editors are not portable
578
+ * outside Connect yet (they read the selected document from Connect's
579
+ * drive/node selection) and would inflate the bundle; a light app that needs
580
+ * an editor imports the React component directly.
581
+ *
582
+ * Import from the `document-models` subpath, never from the package ROOT:
583
+ * the root entry also exports the package's `processorFactory`, and module
584
+ * resolution happens before tree-shaking, so a root import drags processor
585
+ * (server-side) code into the browser bundle and can break the build.
586
+ *
587
+ * Optional on purpose: a light app may equally ship NO modules and let the
588
+ * Switchboard own the model entirely - both modes are supported.
589
+ */
590
+ documentModels?: readonly DocumentModelModule<any>[];
591
+ children: ReactNode;
592
+ };
593
+ /**
594
+ * Mounts a {@link GraphQLReactorClient} into the `window.ph` slots the
595
+ * reactor-browser hooks read, so `useDocument`, `useDispatch` and
596
+ * `useReactorClient` work below it against a Switchboard, with no reactor in
597
+ * the bundle.
598
+ *
599
+ * It fills the document slots, plus `window.ph.vetraPackageManager` when
600
+ * `documentModels` is given (a fixed {@link StaticPackageManager}, which makes
601
+ * the document-model hooks work). `window.ph.reactorClientModule` always stays
602
+ * empty, so full-reactor surfaces (drives, jobs, editor auto-discovery) find
603
+ * nothing - an app below this provider renders components it imports itself.
604
+ *
605
+ * The client is built on the client only: on the server the slots stay empty
606
+ * and the hooks report their normal loading states. The props are read once,
607
+ * when the client is built - changing `url` afterwards does not rebuild it.
608
+ *
609
+ * The effect's cleanup disposes the cache and the client's socket, and the
610
+ * effect rebuilds both if it runs again on the same client - which is what a
611
+ * `StrictMode` mount does.
612
+ */
613
+ declare function GraphQLReactorProvider({
614
+ url,
615
+ tokenProvider,
616
+ subscriptionsUrl,
617
+ realtime,
618
+ attachmentService,
619
+ documentModels,
620
+ children
621
+ }: GraphQLReactorProviderProps): react_jsx_runtime0.JSX.Element;
622
+ /**
623
+ * Returns the {@link GraphQLReactorClient} mounted by
624
+ * {@link GraphQLReactorProvider}, or `undefined` when the slot holds something
625
+ * else - the full in-browser reactor client, or nothing yet.
626
+ *
627
+ * `useReactorClient` is typed as the narrow `IReactorBrowserClient` subset both
628
+ * implementations share. This is how a component reaches the light client's own
629
+ * surface, i.e. `subgraph` and `request`.
630
+ *
631
+ * The narrowing is by brand, not by `instanceof`: a page can carry two copies
632
+ * of this module - a bundled package with its own copy, or a hot-replaced one -
633
+ * and `instanceof` would then answer `false` for a perfectly good client and
634
+ * leave the component silently without one.
635
+ */
636
+ declare function useSwitchboardClient(): GraphQLReactorClient | undefined;
637
+ //#endregion
638
+ //#region src/graphql-client/operations.d.ts
639
+ /**
640
+ * The operation selection of `GetDocumentOperations`, lifted into a fragment so
641
+ * the write path can reuse `remoteOperationToLocal` on the items it selects.
642
+ */
643
+ declare const ReactorOperationFieldsFragmentDoc: graphql.DocumentNode;
644
+ /**
645
+ * `mutateDocument` plus the operations the mutation produced.
646
+ *
647
+ * The generated `MutateDocument` only selects the document fields, but
648
+ * `dispatchActions` reads per-action failures out of `result.operations[scope]`
649
+ * (`src/actions/dispatch.ts`), so the reducer-level errors would be lost.
650
+ *
651
+ * The operations filter keeps the extra selection to the operations this call
652
+ * could have appended rather than the whole history. All three of its fields
653
+ * matter:
654
+ * - `sinceRevision` is the lowest head revision across the targeted scopes, so
655
+ * it is only a safe window when the selection is scope-limited as well;
656
+ * - `scopes` limits the response to the scopes the pushed actions target,
657
+ * without it the server walks every scope of the document
658
+ * (`packages/reactor/src/core/reactor.ts` `getOperations`);
659
+ * - `branch` must match the branch the mutation writes to, otherwise the
660
+ * operations come from `main` (the server's default) while the actions were
661
+ * applied elsewhere.
662
+ */
663
+ declare const MutateDocumentWithOperationsDocument: graphql.DocumentNode;
664
+ type MutateDocumentWithOperationsVariables = {
665
+ documentIdentifier: Scalars["String"]["input"];
666
+ actions: ReadonlyArray<Scalars["JSONObject"]["input"]>;
667
+ view?: ViewFilterInput;
668
+ sinceRevision?: Scalars["Int"]["input"];
669
+ scopes?: ReadonlyArray<Scalars["String"]["input"]>;
670
+ branch?: Scalars["String"]["input"];
671
+ };
672
+ type MutateDocumentWithOperationsResult = {
673
+ readonly mutateDocument: PhDocumentFieldsFragment & {
674
+ readonly operations?: {
675
+ readonly items: ReadonlyArray<RemoteOperation>;
676
+ } | null;
677
+ };
678
+ };
679
+ //#endregion
680
+ //#region src/graphql-client/signing.d.ts
681
+ /**
682
+ * Stamps an action with the head of the scope it targets.
683
+ *
684
+ * `prevOpHash` is the hash of the scope state the action is meant to apply to;
685
+ * for a document at head that is the hash of the last operation in the scope,
686
+ * which the read path cannot fetch, so it is recomputed from the state.
687
+ * `prevOpIndex` is the index of that last operation: revisions count
688
+ * operations and indices are zero based, so an empty scope stamps `-1`, which
689
+ * matches what the remote controller records.
690
+ */
691
+ declare function stampAction(action: Action$1, document: PHDocument$1): Action$1;
692
+ /**
693
+ * Signs a stamped action, preserving any signatures it already carries.
694
+ *
695
+ * The signer reads `context.prevOpHash` off the action, so this must run after
696
+ * {@link stampAction}.
697
+ */
698
+ declare function signStampedAction(action: Action$1, signer: ISigner): Promise<Action$1>;
699
+ //#endregion
700
+ //#region src/graphql-client/static-package-manager.d.ts
701
+ /**
702
+ * A fixed set of packages presented through the `IPackageManager` interface,
703
+ * so the package-derived hooks - `useDocumentModelModules`,
704
+ * `useDocumentModelModuleById`, `useEditorModules`, `useVetraPackages` - work
705
+ * below `GraphQLReactorProvider` exactly as they do below Connect.
706
+ *
707
+ * Connect's package manager installs, updates and removes packages at runtime.
708
+ * A light app instead declares its packages once, as code it imports itself
709
+ * (every generated package root exports `manifest`, `documentModels`, `editors`
710
+ * and `upgradeManifests` by name), so every mutating member throws and
711
+ * `subscribe` never emits. For hand-picked modules without package artifacts,
712
+ * {@link packageFromDocumentModels} wraps them in one synthetic package.
713
+ */
714
+ declare class StaticPackageManager implements IPackageManager {
715
+ readonly registryUrl: null;
716
+ readonly packages: DocumentModelLib[];
717
+ constructor(packages: readonly DocumentModelLib<any>[]);
718
+ /**
719
+ * Resolves a module by document type across all packages. Mirrors the
720
+ * registry's semantics (`IDocumentModelRegistry.getModule`): the LATEST
721
+ * version wins, with `version ?? 1` as each module's default.
722
+ */
723
+ load(documentType: string): Promise<DocumentModelSource>;
724
+ subscribe(_handler: IPackagesListener): IPackageListerUnsubscribe;
725
+ getPackageSource(_packageName: string): RegistryPackageSource | null;
726
+ getPackageVersion(_packageName: string): string | undefined;
727
+ getRegistryPackages(): {
728
+ name: string;
729
+ version: string | undefined;
730
+ }[];
731
+ addPackage(_packageName: string): PackageManagerInstallResult;
732
+ addPackages(_packageNames: string[]): PackageManagerInstallResult[];
733
+ removePackage(_name: string): void;
734
+ updateLocalPackage(_pkg: DocumentModelLib, _version?: string): void;
735
+ addLocalPackage(_name: string, _loadedPackage: DocumentModelLib, _version?: string): void;
736
+ }
737
+ /**
738
+ * Wraps hand-picked modules in one synthetic `DocumentModelLib`, for apps that
739
+ * assemble their model list from mixed sources instead of passing whole
740
+ * packages. The manifest is fabricated - loose modules carry none - so prefer
741
+ * the `packages` prop with the real package exports when you have them: a real
742
+ * package also carries `editors`, which makes the editor hooks work.
743
+ */
744
+ declare function packageFromDocumentModels(documentModels: readonly DocumentModelModule<any>[]): DocumentModelLib;
745
+ //#endregion
746
+ //#region src/graphql-client/subscriptions.d.ts
747
+ /** The `documentChanges` payload, exactly as the Switchboard sends it. */
748
+ type DocumentChangesEventPayload = DocumentChangesSubscription["documentChanges"];
749
+ /** The connection payload sent with the `ConnectionInit` message. */
750
+ type ConnectionParams = Record<string, string>;
751
+ type DocumentChangesSubscriptionOptions = {
752
+ /** The websocket endpoint, e.g. `ws://localhost:4001/graphql/subscriptions`. */wsUrl: string;
753
+ /**
754
+ * Resolves the `ConnectionInit` payload. Called again on every reconnect, so
755
+ * a token that expired while the socket was down is refreshed on the way back
756
+ * up.
757
+ */
758
+ connectionParams?: () => Promise<ConnectionParams>; /** Called once per server event. */
759
+ onEvent: (event: DocumentChangesEventPayload) => void;
760
+ /**
761
+ * Called when the socket gives up: the retries built into `graphql-ws` are
762
+ * exhausted, or the server rejected the subscription. Realtime is an
763
+ * enhancement, so callers are expected to log and carry on.
764
+ */
765
+ onError: (error: unknown) => void;
766
+ };
767
+ /**
768
+ * Opens one `documentChanges` subscription and feeds every event to `onEvent`.
769
+ *
770
+ * The subscription is a firehose: no `search` argument, so the server sends
771
+ * every change the connection is allowed to see and the caller filters. This is
772
+ * the only module that knows about `graphql-ws`.
773
+ *
774
+ * Returns the stop function, which cancels the subscription and closes the
775
+ * socket. It is safe to call more than once.
776
+ */
777
+ declare function startDocumentChangesSubscription(options: DocumentChangesSubscriptionOptions): () => void;
778
+ /**
779
+ * Derives the websocket endpoint from the GraphQL http endpoint.
780
+ *
781
+ * `http://host/graphql` becomes `ws://host/graphql/subscriptions`, which is
782
+ * where the Switchboard mounts its websocket server (`packages/reactor-api`
783
+ * `startServer`). A URL that already speaks `ws`/`wss` only gets the path.
784
+ */
785
+ declare function subscriptionsUrlFromGraphqlUrl(url: string): string;
786
+ /**
787
+ * Turns a bearer token provider into `connectionParams`.
788
+ *
789
+ * The header key is the lowercase `authorization` the Switchboard's websocket
790
+ * context factory reads. Without a token the payload is empty: an open
791
+ * Switchboard serves anonymous subscribers.
792
+ */
793
+ declare function makeAuthConnectionParams(tokenProvider: BearerTokenProvider): () => Promise<ConnectionParams>;
794
+ //#endregion
795
+ //#region src/hooks/document-cache.d.ts
796
+ /** Returns all documents in the reactor. */
797
+ declare const useDocumentCache: UsePHGlobalValue$1<IDocumentCache>;
798
+ /** Sets all of the documents in the reactor. */
799
+ declare const setDocumentCache: SetPHGlobalValue$1<IDocumentCache>;
800
+ /** Adds an event handler for all of the documents in the reactor. */
801
+ declare const addDocumentCacheEventHandler: () => void;
802
+ /**
803
+ * Retrieves a document from the reactor and subscribes to changes using React Suspense.
804
+ * This hook will suspend rendering while the document is loading.
805
+ * @param id - The document ID to retrieve, or null/undefined to skip retrieval
806
+ * @returns The document if found, or undefined if id is null/undefined
807
+ */
808
+ declare function useDocument(id: string | null | undefined): PHDocument$1 | undefined;
809
+ /**
810
+ * Retrieves a document from the reactor and subscribes to changes without
811
+ * suspending or throwing. Use this when the ID might be stale (e.g., a
812
+ * previously selected node that has since been deleted) and the consumer
813
+ * wants to render a placeholder instead of crashing.
814
+ *
815
+ * Unlike {@link useGetDocumentAsync}, this hook subscribes to cache
816
+ * updates, so the returned state stays in sync with reactor changes.
817
+ *
818
+ * @param id - The document ID to retrieve, or null/undefined to skip retrieval
819
+ * @returns An object containing:
820
+ * - status: "initial" | "pending" | "success" | "error"
821
+ * - data: The document if successfully loaded
822
+ * - isPending: Whether the document is currently loading
823
+ * - error: Any error that occurred during loading (e.g., document not found)
824
+ * - reload: Function to force a refetch, or undefined when no id is supplied
825
+ */
826
+ declare function useDocumentSafe(id: string | null | undefined): {
827
+ readonly status: "initial";
828
+ readonly isPending: false;
829
+ readonly error: undefined;
830
+ readonly data: undefined;
831
+ readonly reload: undefined;
832
+ } | {
833
+ readonly reload: () => Promise<PHDocument$1>;
834
+ readonly status: "pending";
835
+ readonly isPending: true;
836
+ readonly error: undefined;
837
+ readonly data: undefined;
838
+ } | {
839
+ readonly reload: () => Promise<PHDocument$1>;
840
+ readonly status: "success";
841
+ readonly isPending: false;
842
+ readonly error: undefined;
843
+ readonly data: PHDocument$1;
844
+ } | {
845
+ readonly reload: () => Promise<PHDocument$1>;
846
+ readonly status: "error";
847
+ readonly isPending: false;
848
+ readonly error: unknown;
849
+ readonly data: undefined;
850
+ };
851
+ /**
852
+ * Retrieves multiple documents from the reactor using React Suspense.
853
+ * This hook will suspend rendering while any of the documents are loading.
854
+ *
855
+ * Uses getBatch from the document cache which handles promise caching internally,
856
+ * ensuring stable references for useSyncExternalStore.
857
+ *
858
+ * @param ids - Array of document IDs to retrieve, or null/undefined to skip retrieval
859
+ * @returns An array of documents if found, or empty array if ids is null/undefined
860
+ */
861
+ declare function useDocuments(ids: string[] | null | undefined): PHDocument$1[];
862
+ /**
863
+ * Returns a function to retrieve a document from the cache.
864
+ * The returned function fetches and returns a document by ID.
865
+ * @returns A function that takes a document ID and returns a Promise of the document
866
+ */
867
+ declare function useGetDocument(): (id: string) => Promise<PHDocument$1>;
868
+ /**
869
+ * Returns a function to retrieve multiple documents from the cache.
870
+ * The returned function fetches and returns documents by their IDs.
871
+ * @returns A function that takes an array of document IDs and returns a Promise of the documents
872
+ */
873
+ declare function useGetDocuments(): (ids: string[]) => Promise<PHDocument$1[]>;
874
+ /**
875
+ * Retrieves a document from the reactor without suspending rendering.
876
+ * Returns the current state of the document loading operation.
877
+ * @param id - The document ID to retrieve, or null/undefined to skip retrieval
878
+ * @returns An object containing:
879
+ * - status: "initial" | "pending" | "success" | "error"
880
+ * - data: The document if successfully loaded
881
+ * - isPending: Boolean indicating if the document is currently loading
882
+ * - error: Any error that occurred during loading
883
+ * - reload: Function to force reload the document from cache
884
+ */
885
+ declare function useGetDocumentAsync(id: string | null | undefined): {
886
+ readonly status: "initial";
887
+ readonly data: undefined;
888
+ readonly isPending: false;
889
+ readonly error: undefined;
890
+ readonly reload: undefined;
891
+ } | {
892
+ readonly reload: () => Promise<PHDocument$1>;
893
+ readonly status: "pending";
894
+ readonly isPending: true;
895
+ readonly error: undefined;
896
+ readonly data: undefined;
897
+ } | {
898
+ readonly reload: () => Promise<PHDocument$1>;
899
+ readonly status: "success";
900
+ readonly isPending: false;
901
+ readonly error: undefined;
902
+ readonly data: PHDocument$1;
903
+ } | {
904
+ readonly reload: () => Promise<PHDocument$1>;
905
+ readonly status: "error";
906
+ readonly isPending: false;
907
+ readonly error: unknown;
908
+ readonly data: undefined;
909
+ };
910
+ //#endregion
911
+ //#region src/hooks/reactor.d.ts
912
+ /** Returns the reactor client module (in-process or worker-backed) */
913
+ declare const useReactorClientModule: UsePHGlobalValue<BrowserReactorClientModule | WorkerReactorClientModule>;
914
+ /** Sets the reactor client module */
915
+ declare const setReactorClientModule: SetPHGlobalValue<BrowserReactorClientModule | WorkerReactorClientModule>;
916
+ /** Adds an event handler for the reactor client module */
917
+ declare const addReactorClientModuleEventHandler: AddPHGlobalEventHandler;
918
+ /** Returns the reactor client */
919
+ declare const useReactorClient: UsePHGlobalValue<IReactorBrowserClient>;
920
+ /** Sets the reactor client */
921
+ declare const setReactorClient: SetPHGlobalValue<IReactorBrowserClient>;
922
+ /** Adds an event handler for the reactor client */
923
+ declare const addReactorClientEventHandler: AddPHGlobalEventHandler;
924
+ declare const useSync: () => ISyncManager | undefined;
925
+ declare const useSyncList: () => _powerhousedao_reactor0.Remote[];
926
+ declare const useModelRegistry: () => IDocumentModelRegistry | undefined;
927
+ declare const useDatabase: () => Kysely<Database> | undefined;
928
+ declare const usePGlite: () => PGlite | undefined;
929
+ //#endregion
930
+ //#region src/hooks/dispatch.d.ts
931
+ /**
932
+ * Returns a dispatch function for dispatching actions to a document.
933
+ * Used internally by other hooks to provide action dispatching capabilities.
934
+ * @param document - The document to dispatch actions to.
935
+ * @returns A tuple containing the document and a dispatch function.
936
+ */
937
+ type DispatchFn<TAction> = (actionOrActions: TAction[] | TAction | undefined, onErrors?: (errors: Error[]) => void, onSuccess?: (result: PHDocument$1) => void) => void;
938
+ type UseDispatchResult<TDocument, TAction> = readonly [TDocument | undefined, DispatchFn<TAction>];
939
+ declare function useDispatch<TDocument = PHDocument$1, TAction = Action$1>(document: TDocument | undefined): UseDispatchResult<TDocument, TAction>;
940
+ //#endregion
941
+ //#region src/hooks/document-model-modules.d.ts
942
+ declare function useDocumentModelModules(): DocumentModelModule[] | undefined;
943
+ /**
944
+ * Resolves a document model module by document type, mirroring the registry's
945
+ * semantics (`IDocumentModelRegistry.getModule`): with `version` omitted the
946
+ * LATEST version of the type wins (`version ?? 1` as each module's default),
947
+ * with `version` given only an exact match is returned. The reactor resolves
948
+ * modules the same way when a document is created, so metadata read through
949
+ * this hook and the version a creation actually uses cannot disagree.
950
+ */
951
+ declare function useDocumentModelModuleById(id: string | null | undefined, version?: number): DocumentModelModule | undefined;
952
+ //#endregion
953
+ //#region src/hooks/document-operations.d.ts
954
+ type InternalState = {
955
+ globalOperations: Operation$1[];
956
+ localOperations: Operation$1[];
957
+ isLoading: boolean;
958
+ error: Error | undefined;
959
+ };
960
+ /** What `useDocumentOperations` returns; exported so consumers can name it. */
961
+ type DocumentOperationsState = InternalState & {
962
+ refetch: () => void;
963
+ };
964
+ /**
965
+ * Hook to fetch document operations via the reactor client.
966
+ * Operations are no longer auto-populated on documents and must be fetched explicitly.
967
+ *
968
+ * @param documentId - The document ID to fetch operations for
969
+ * @returns Object containing globalOperations, localOperations, isLoading, and error
970
+ */
971
+ declare function useDocumentOperations(documentId: string | null | undefined): DocumentOperationsState;
972
+ //#endregion
973
+ //#region src/hooks/attachment-service.d.ts
974
+ /** Returns the attachment service from window.ph */
975
+ declare const useAttachmentService: UsePHGlobalValue<IAttachmentService>;
976
+ /** Sets the attachment service on window.ph */
977
+ declare const setAttachmentService: SetPHGlobalValue<IAttachmentService>;
978
+ /** Registers the attachmentService window event handler */
979
+ declare const addAttachmentServiceEventHandler: AddPHGlobalEventHandler;
980
+ //#endregion
981
+ export { GraphQLRequestOptions as $, useGetDocuments as A, SyncStatus$1 as At, stampAction as B, setDocumentCache as C, PushResult as Ct, useDocuments as D, RemoteDocumentData as Dt, useDocumentSafe as E, RemoteDocumentChangeEvent as Et, startDocumentChangesSubscription as F, GraphQLReactorProvider as G, MutateDocumentWithOperationsResult as H, subscriptionsUrlFromGraphqlUrl as I, useSwitchboardClient as J, GraphQLReactorProviderProps as K, StaticPackageManager as L, DocumentChangesEventPayload as M, DocumentCache as Mt, DocumentChangesSubscriptionOptions as N, addPromiseState as Nt, useGetDocument as O, RemoteOperation as Ot, makeAuthConnectionParams as P, readPromiseState as Pt, viewFilterInputFromViewFilter as Q, packageFromDocumentModels as R, addDocumentCacheEventHandler as S, MergeHandler as St, useDocumentCache as T, RemoteControllerOptions as Tt, MutateDocumentWithOperationsVariables as U, MutateDocumentWithOperationsDocument as V, ReactorOperationFieldsFragmentDoc as W, GraphQLReactorClientOptions as X, GraphQLReactorClient as Y, isGraphQLReactorClient as Z, usePGlite as _, GetDocumentResult as _t, useDocumentOperations as a, BearerTokenProvider as at, useSync as b, IRemoteClient as bt, DispatchFn as c, GetDocumentQueryFields as ct, addReactorClientEventHandler as d, phDocumentFromGetDocument as dt, SubgraphSdkFactory as et, addReactorClientModuleEventHandler as f, phDocumentFromMutation as ft, useModelRegistry as g, DocumentChangeListener as gt, useDatabase as h, ConflictStrategy as ht, DocumentOperationsState as i, subgraphUrlFromGraphqlUrl as it, ConnectionParams as j, TrackedAction as jt, useGetDocumentAsync as k, RemoteOperationResultPage as kt, UseDispatchResult as l, GetDocumentQueryResult as lt, setReactorClientModule as m, ConflictInfo as mt, setAttachmentService as n, TypedGraphQLDocument as nt, useDocumentModelModuleById as o, ambientRenownTokenProvider as ot, setReactorClient as p, revisionMapFromRevisionsList as pt, ensurePHEventHandlers as q, useAttachmentService as r, describeGraphQLDocument as rt, useDocumentModelModules as s, makeAuthMiddleware as st, addAttachmentServiceEventHandler as t, SubgraphSdkRegistry as tt, useDispatch as u, RevisionsListSelection as ut, useReactorClient as v, GetDocumentWithOperationsResult as vt, useDocument as w, RemoteControllerGraphQLClient as wt, useSyncList as x, IRemoteController as xt, useReactorClientModule as y, GetOperationsResult as yt, signStampedAction as z };
982
+ //# sourceMappingURL=attachment-service-BImio0aq.d.ts.map