@powerhousedao/reactor-browser 6.2.3-dev.9 → 6.2.3

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 (85) hide show
  1. package/dist/{attachment-service-D3EhiAJ7.d.ts → attachment-service-But1Xljo.d.ts} +169 -59
  2. package/dist/attachment-service-But1Xljo.d.ts.map +1 -0
  3. package/dist/{client-DjK30EQ-.js → client-BiJAJ9dW.js} +1 -1
  4. package/dist/{client-DjK30EQ-.js.map → client-BiJAJ9dW.js.map} +1 -1
  5. package/dist/{client-BIHN_UyR.d.ts → client-CngU4mtn.d.ts} +3 -3
  6. package/dist/client-CngU4mtn.d.ts.map +1 -0
  7. package/dist/{client-D66jVnot.js → client-VV9M73s_.js} +126 -18
  8. package/dist/client-VV9M73s_.js.map +1 -0
  9. package/dist/{document-by-id-B4FIzG1w.js → dispatch-qRXS70fh.js} +389 -54
  10. package/dist/dispatch-qRXS70fh.js.map +1 -0
  11. package/dist/document-by-id-B_8DA4yZ.js +16 -0
  12. package/dist/document-by-id-B_8DA4yZ.js.map +1 -0
  13. package/dist/{document-model-modules-bTP87nyr.js → document-model-modules-D6I-UUXq.js} +32 -65
  14. package/dist/document-model-modules-D6I-UUXq.js.map +1 -0
  15. package/dist/{document-operations-WeE6wIDt.js → document-operations-Bt-1-ThH.js} +147 -120
  16. package/dist/document-operations-Bt-1-ThH.js.map +1 -0
  17. package/dist/{global-OuINvEGT.d.ts → global-fql2bmb0.d.ts} +50 -13
  18. package/dist/global-fql2bmb0.d.ts.map +1 -0
  19. package/dist/{index-B33TKEqp.d.ts → index-BABMK8cO.d.ts} +19 -98
  20. package/dist/index-BABMK8cO.d.ts.map +1 -0
  21. package/dist/{index-BIVDXw3K.d.ts → index-rtDmzViP.d.ts} +3 -3
  22. package/dist/index-rtDmzViP.d.ts.map +1 -0
  23. package/dist/index.d.ts +379 -364
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +111 -39
  26. package/dist/index.js.map +1 -1
  27. package/dist/{inspector-proxy-6h5VKAwt.d.ts → inspector-proxy-DCowaeeH.d.ts} +11 -4
  28. package/dist/inspector-proxy-DCowaeeH.d.ts.map +1 -0
  29. package/dist/{make-ph-event-functions-DBq3iWYn.js → make-ph-event-functions-FzpvQtj6.js} +1 -1
  30. package/dist/{make-ph-event-functions-DBq3iWYn.js.map → make-ph-event-functions-FzpvQtj6.js.map} +1 -1
  31. package/dist/{pglite-CntadC_p-9NDG14dS.d.ts → pglite-CntadC_p-DTkdF8sr.d.ts} +11 -33
  32. package/dist/pglite-CntadC_p-DTkdF8sr.d.ts.map +1 -0
  33. package/dist/{relational-D1RB45sA.js → relational-ChC_AWAK.js} +3 -2
  34. package/dist/{relational-D1RB45sA.js.map → relational-ChC_AWAK.js.map} +1 -1
  35. package/dist/{renown-rqK8sokh.js → renown-C9pYZRqf.js} +7 -8
  36. package/dist/{renown-rqK8sokh.js.map → renown-C9pYZRqf.js.map} +1 -1
  37. package/dist/{renown-BHxwP7xU.js → renown-Def5iO8k.js} +2 -2
  38. package/dist/{renown-BHxwP7xU.js.map → renown-Def5iO8k.js.map} +1 -1
  39. package/dist/src/ai/index.d.ts +51 -62
  40. package/dist/src/ai/index.d.ts.map +1 -1
  41. package/dist/src/ai/index.js +5 -8
  42. package/dist/src/ai/index.js.map +1 -1
  43. package/dist/src/analytics/index.d.ts +36 -44
  44. package/dist/src/analytics/index.d.ts.map +1 -1
  45. package/dist/src/analytics/index.js +2 -2
  46. package/dist/src/analytics/index.js.map +1 -1
  47. package/dist/src/document-model.d.ts +3 -4
  48. package/dist/src/document-model.d.ts.map +1 -1
  49. package/dist/src/document-model.js.map +1 -1
  50. package/dist/src/graphql/client.d.ts +4 -3
  51. package/dist/src/graphql/client.js +1 -1
  52. package/dist/src/graphql-client/entry.d.ts +5 -4
  53. package/dist/src/graphql-client/entry.js +4 -4
  54. package/dist/src/relational/index.d.ts +8 -9
  55. package/dist/src/relational/index.d.ts.map +1 -1
  56. package/dist/src/relational/index.js +1 -1
  57. package/dist/src/renown/index.d.ts +3 -2
  58. package/dist/src/renown/index.js +2 -2
  59. package/dist/src/rpc/index.d.ts +52 -32
  60. package/dist/src/rpc/index.d.ts.map +1 -1
  61. package/dist/src/rpc/index.js +58 -9
  62. package/dist/src/rpc/index.js.map +1 -1
  63. package/dist/{store-BJYcr_FL.js → store-DInXcjal.js} +1 -1
  64. package/dist/{store-BJYcr_FL.js.map → store-DInXcjal.js.map} +1 -1
  65. package/dist/{switchboard-CaXQ4-5Q.js → switchboard-CFyD_5_e.js} +58 -6
  66. package/dist/switchboard-CFyD_5_e.js.map +1 -0
  67. package/dist/{types-6vDzbRRS.d.ts → types-520nWrB3.d.ts} +2 -2
  68. package/dist/types-520nWrB3.d.ts.map +1 -0
  69. package/dist/{types-Dcv1ZLoW.d.ts → types-B7-_l_wE.d.ts} +86 -16
  70. package/dist/types-B7-_l_wE.d.ts.map +1 -0
  71. package/package.json +15 -16
  72. package/dist/attachment-service-D3EhiAJ7.d.ts.map +0 -1
  73. package/dist/client-BIHN_UyR.d.ts.map +0 -1
  74. package/dist/client-D66jVnot.js.map +0 -1
  75. package/dist/document-by-id-B4FIzG1w.js.map +0 -1
  76. package/dist/document-model-modules-bTP87nyr.js.map +0 -1
  77. package/dist/document-operations-WeE6wIDt.js.map +0 -1
  78. package/dist/global-OuINvEGT.d.ts.map +0 -1
  79. package/dist/index-B33TKEqp.d.ts.map +0 -1
  80. package/dist/index-BIVDXw3K.d.ts.map +0 -1
  81. package/dist/inspector-proxy-6h5VKAwt.d.ts.map +0 -1
  82. package/dist/pglite-CntadC_p-9NDG14dS.d.ts.map +0 -1
  83. package/dist/switchboard-CaXQ4-5Q.js.map +0 -1
  84. package/dist/types-6vDzbRRS.d.ts.map +0 -1
  85. package/dist/types-Dcv1ZLoW.d.ts.map +0 -1
@@ -1,34 +1,41 @@
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-OuINvEGT.js";
2
- import { t as PGlite } from "./pglite-CntadC_p-9NDG14dS.js";
3
- import { A as ViewFilterInput, C as GetDocumentQuery, D as PropagationMode$1, E as PhDocumentFieldsFragment, O as Scalars, S as GetDocumentOperationsQuery, b as DocumentChangesSubscription, c as ReactorGraphQLClient, g as ActionInput, k as SdkFunctionWrapper } from "./types-Dcv1ZLoW.js";
1
+ import { a as PHGlobal$1, at as DocumentRefetchState, b as IPackagesListener, ct as IOperationCache, d as UsePHGlobalValue$1, dt as PromiseWithState, lt as OperationsCacheEntry, rt as IReactorBrowserClient$1, st as IDocumentCache, u as SetPHGlobalValue$1, ut as PromiseState, v as IPackageListerUnsubscribe, x as PackageManagerInstallResult, y as IPackageManager } from "./global-fql2bmb0.js";
2
+ import { t as PGlite } from "./pglite-CntadC_p-DTkdF8sr.js";
3
+ import { A as ViewFilterInput, C as GetDocumentQuery, D as PropagationMode$1, E as PhDocumentFieldsFragment, O as Scalars, S as GetDocumentOperationsQuery, b as DocumentChangesSubscription, c as ReactorGraphQLClient, g as ActionInput, k as SdkFunctionWrapper } from "./types-B7-_l_wE.js";
4
4
  import { Action, DocumentModelLib, DocumentModelModule, Operation, PHDocument } from "document-model";
5
- import { Action as Action$1, DocumentModelModule as DocumentModelModule$1, DocumentOperations, ISigner, Operation as Operation$1, PHBaseState, PHDocument as PHDocument$1, PHDocumentHeader } from "@powerhousedao/shared/document-model";
6
- import * as _powerhousedao_reactor0 from "@powerhousedao/reactor";
7
5
  import { Database, DocumentChangeEvent, DocumentModelSource, IDocumentModelRegistry, ISyncManager, OperationFilter, PagedResults, PagingOptions, PropagationMode, SearchFilter, ViewFilter } from "@powerhousedao/reactor";
6
+ import { Action as Action$1, ActionSigningTarget, DocumentModelModule as DocumentModelModule$1, DocumentOperations, ISigner, Operation as Operation$1, PHBaseState, PHDocument as PHDocument$1, PHDocumentHeader } from "@powerhousedao/shared/document-model";
8
7
  import { ReactNode } from "react";
9
8
  import { GraphQLClient, Variables } from "graphql-request";
10
- import * as graphql from "graphql";
11
9
  import { DocumentNode } from "graphql";
12
- import * as react_jsx_runtime0 from "react/jsx-runtime";
13
10
  import { IAttachmentService } from "@powerhousedao/reactor-attachments/client";
14
11
  import { Kysely } from "kysely";
15
12
  import { AddPHGlobalEventHandler, BrowserReactorClientModule, IReactorBrowserClient, SetPHGlobalValue, UsePHGlobalValue, WorkerReactorClientModule } from "@powerhousedao/reactor-browser";
16
13
  import { RegistryPackageSource } from "@powerhousedao/shared";
17
-
14
+ //#region src/document-refetcher.d.ts
15
+ /** The refetch snapshot of a document with nothing in flight and no kept failure. */
16
+ declare const IDLE_REFETCH_STATE: DocumentRefetchState;
17
+ //#endregion
18
18
  //#region src/document-cache.d.ts
19
19
  declare function addPromiseState<T>(promise: Promise<T>): PromiseWithState<T>;
20
20
  declare function readPromiseState<T>(promise: Promise<T> | PromiseWithState<T>): PromiseState<T>;
21
+ /** The snapshot every uncached document scope reads as. One frozen object, so `useSyncExternalStore` sees a stable value. */
22
+ declare const IDLE_OPERATIONS_ENTRY: OperationsCacheEntry;
23
+ /** Whether a document cache also serves operation history. `GraphQLClientDocumentCache` does not. */
24
+ declare function isOperationCache(cache: unknown): cache is IOperationCache;
21
25
  /**
22
26
  * Document cache implementation that uses the new ReactorClient API.
23
27
  *
24
28
  * This cache subscribes to document change events via IReactorBrowserClient.subscribe()
25
29
  * and automatically updates the cache when documents are created, updated, or deleted.
30
+ * It also holds paginated operation history per document scope (see `IOperationCache`),
31
+ * which is dropped for a document whenever a change event for it arrives.
26
32
  */
27
- declare class DocumentCache implements IDocumentCache {
33
+ declare class DocumentCache implements IDocumentCache, IOperationCache {
28
34
  private client;
29
35
  private documents;
30
36
  private batchPromises;
31
37
  private listeners;
38
+ private refetcher;
32
39
  /**
33
40
  * Cache keys that fetched a document under a name other than its id --
34
41
  * slugs, which `client.get` resolves. Change events dispatch by `header.id`,
@@ -37,19 +44,55 @@ declare class DocumentCache implements IDocumentCache {
37
44
  * the same document is cached under.
38
45
  */
39
46
  private aliasKeys;
47
+ /** Operations by document id, then scope. Entries are replaced, never mutated. */
48
+ private operationEntries;
49
+ /** In-flight controllers and the next page's cursor/limit, by document id then scope. */
50
+ private operationRequests;
51
+ private operationListeners;
40
52
  private unsubscribe;
41
53
  constructor(client: IReactorBrowserClient$1);
42
54
  private handleDocumentChange;
43
55
  private handleDocumentDeleted;
44
56
  private handleDocumentUpdated;
57
+ private notifyListeners;
45
58
  /** The id an event dispatches by, plus every alias the document is cached under. */
46
59
  private cacheKeysFor;
47
60
  /** Records that `key` cached the document change events know as `header.id`. */
48
61
  private recordAlias;
49
62
  private invalidateBatchesContaining;
50
63
  get(id: string, refetch?: boolean): Promise<PHDocument$1>;
64
+ getRefetchState(id: string): DocumentRefetchState;
51
65
  getBatch(ids: string[]): Promise<PHDocument$1[]>;
52
66
  subscribe(id: string | string[], callback: () => void): () => void;
67
+ getOperationsState(documentId: string, scope: string): OperationsCacheEntry;
68
+ loadOperations(documentId: string, scope: string, limit: number): void;
69
+ loadMoreOperations(documentId: string, scope: string): void;
70
+ /**
71
+ * Bring a document's cached scopes up to date after it changed, without
72
+ * throwing away what is already loaded.
73
+ *
74
+ * The operation stream is append-only: an update adds operations at higher
75
+ * revisions and never rewrites the ones below, so history already paged in
76
+ * is still correct. Dropping it meant a panel showing a fully loaded
77
+ * document re-walked every page on each edit -- the cost of which grows
78
+ * with the document, exactly where it hurts most. Each scope instead asks
79
+ * only for what comes after the newest revision it holds, using the
80
+ * `sinceRevision` filter, and appends the answer.
81
+ *
82
+ * A scope that has not finished paging is dropped as before: it has no
83
+ * meaningful "newest revision" to resume from, since asking for everything
84
+ * past the newest row it happens to hold would skip the pages between that
85
+ * row and the end of the stream.
86
+ */
87
+ private refreshOperations;
88
+ /** Drops one scope of a document, aborting its request if one is in flight. */
89
+ private invalidateOperationsScope;
90
+ invalidateOperations(documentId: string): void;
91
+ subscribeOperations(documentId: string, callback: () => void): () => void;
92
+ private settleOperationsPage;
93
+ private setOperationsEntry;
94
+ private setOperationsRequest;
95
+ private notifyOperationListeners;
53
96
  /**
54
97
  * Disposes of the cache and unsubscribes from document change events.
55
98
  */
@@ -65,14 +108,22 @@ type RemoteOperationResultPage = GetDocumentOperationsQuery["documentOperations"
65
108
  * Options for creating a RemoteDocumentController.
66
109
  */
67
110
  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. */
111
+ client: RemoteControllerGraphQLClient;
112
+ /** Remote document id. Omit for new documents. */
113
+ documentId?: string;
114
+ /** "batch" requires explicit push(), "streaming" auto-pushes after actions. Defaults to "batch" */
115
+ mode?: "batch" | "streaming";
116
+ /** Optional signer for action signing. */
117
+ signer?: ISigner;
118
+ /** Branch name, defaults to "main". */
119
+ branch?: string;
120
+ /** Parent document identifier for creating new documents. */
121
+ parentIdentifier?: string;
122
+ /** Conflict resolution strategy when remote has new operations. Default: no check (current behavior). */
123
+ onConflict?: ConflictStrategy;
124
+ /** Called when a streaming-mode push fails. If not provided, errors are silently swallowed. */
125
+ onPushError?: (error: unknown) => void;
126
+ /** Number of operations to fetch per page. Defaults to 100. */
76
127
  operationsPageSize?: number;
77
128
  };
78
129
  /**
@@ -80,7 +131,8 @@ type RemoteControllerOptions = {
80
131
  */
81
132
  type PushResult = {
82
133
  remoteDocument: RemoteDocumentData;
83
- actionCount: number; /** The actions that were sent to the server (after signing, if applicable). */
134
+ actionCount: number;
135
+ /** The actions that were sent to the server (after signing, if applicable). */
84
136
  operations: ReadonlyArray<Action$1>;
85
137
  };
86
138
  /**
@@ -102,9 +154,13 @@ type TrackedAction = {
102
154
  };
103
155
  /** Information about a detected conflict. */
104
156
  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. */
157
+ /** Remote operations added since the last pull, grouped by scope. */
158
+ remoteOperations: Record<string, RemoteOperation[]>;
159
+ /** Local actions pending push. */
160
+ localActions: TrackedAction[];
161
+ /** Remote revision at last pull. */
162
+ knownRevision: Record<string, number>;
163
+ /** Current remote revision. */
108
164
  currentRevision: Record<string, number>;
109
165
  };
110
166
  /** Custom merge handler receives conflict info and returns actions to push (or throws to abort). */
@@ -304,7 +360,8 @@ declare class SubgraphSdkRegistry {
304
360
  //#endregion
305
361
  //#region src/graphql-client/graphql-reactor-client.d.ts
306
362
  type GraphQLReactorClientOptions = {
307
- /** The Switchboard GraphQL endpoint, e.g. `http://localhost:4001/graphql`. */url: string;
363
+ /** The Switchboard GraphQL endpoint, e.g. `http://localhost:4001/graphql`. */
364
+ url: string;
308
365
  /**
309
366
  * A pre-built SDK to use instead of the transport derived from `url`.
310
367
  * Mainly a test seam.
@@ -589,7 +646,8 @@ declare global {
589
646
  */
590
647
  declare function ensurePHEventHandlers(): void;
591
648
  type GraphQLReactorProviderProps = {
592
- /** The Switchboard GraphQL endpoint, e.g. `http://localhost:4001/graphql`. */url: string;
649
+ /** The Switchboard GraphQL endpoint, e.g. `http://localhost:4001/graphql`. */
650
+ url: string;
593
651
  /**
594
652
  * Resolves the bearer token sent with every request, per request. Defaults to
595
653
  * the token of the logged-in Renown user, or none when nobody is logged in.
@@ -675,15 +733,7 @@ type GraphQLReactorProviderProps = {
675
733
  * effect rebuilds both if it runs again on the same client - which is what a
676
734
  * `StrictMode` mount does.
677
735
  */
678
- declare function GraphQLReactorProvider({
679
- url,
680
- tokenProvider,
681
- subscriptionsUrl,
682
- realtime,
683
- attachmentService,
684
- documentModels,
685
- children
686
- }: GraphQLReactorProviderProps): react_jsx_runtime0.JSX.Element;
736
+ declare function GraphQLReactorProvider({ url, tokenProvider, subscriptionsUrl, realtime, attachmentService, documentModels, children }: GraphQLReactorProviderProps): import("react/jsx-runtime").JSX.Element;
687
737
  /**
688
738
  * Returns the {@link GraphQLReactorClient} mounted by
689
739
  * {@link GraphQLReactorProvider}, or `undefined` when the slot holds something
@@ -705,7 +755,7 @@ declare function useSwitchboardClient(): GraphQLReactorClient | undefined;
705
755
  * The operation selection of `GetDocumentOperations`, lifted into a fragment so
706
756
  * the write path can reuse `remoteOperationToLocal` on the items it selects.
707
757
  */
708
- declare const ReactorOperationFieldsFragmentDoc: graphql.DocumentNode;
758
+ declare const ReactorOperationFieldsFragmentDoc: import("graphql").DocumentNode;
709
759
  /**
710
760
  * `mutateDocument` plus the operations the mutation produced.
711
761
  *
@@ -727,7 +777,7 @@ declare const ReactorOperationFieldsFragmentDoc: graphql.DocumentNode;
727
777
  * by hand or the operations came from `main` while the actions were applied
728
778
  * elsewhere. One variable cannot disagree with itself.
729
779
  */
730
- declare const MutateDocumentWithOperationsDocument: graphql.DocumentNode;
780
+ declare const MutateDocumentWithOperationsDocument: import("graphql").DocumentNode;
731
781
  type MutateDocumentWithOperationsVariables = {
732
782
  documentIdentifier: Scalars["String"]["input"];
733
783
  actions: ReadonlyArray<ActionInput>;
@@ -761,12 +811,12 @@ type MutateDocumentWithOperationsResult = {
761
811
  */
762
812
  declare function stampAction(action: Action$1, document: PHDocument$1, revision?: number): Action$1;
763
813
  /**
764
- * Signs a stamped action, preserving any signatures it already carries.
765
- *
766
- * The signer reads `context.prevOpHash` off the action, so this must run after
767
- * {@link stampAction}.
814
+ * Signs a stamped action for `target`, keeping any signatures it already
815
+ * carries. The signer reads `context.prevOpHash`, so this runs after
816
+ * {@link stampAction}. A v2 tuple covers the signer's identity, so the context
817
+ * takes the signer's user and app even when the action named others.
768
818
  */
769
- declare function signStampedAction(action: Action$1, signer: ISigner, signal?: AbortSignal): Promise<Action$1>;
819
+ declare function signStampedAction(action: Action$1, signer: ISigner, target: ActionSigningTarget, signal?: AbortSignal): Promise<Action$1>;
770
820
  /**
771
821
  * Stamps and signs a batch of actions against one document snapshot, so every
772
822
  * action carries the head its predecessor will leave behind.
@@ -856,13 +906,15 @@ type DocumentChangesEventPayload = DocumentChangesSubscription["documentChanges"
856
906
  /** The connection payload sent with the `ConnectionInit` message. */
857
907
  type ConnectionParams = Record<string, string>;
858
908
  type DocumentChangesSubscriptionOptions = {
859
- /** The websocket endpoint, e.g. `ws://localhost:4001/graphql/subscriptions`. */wsUrl: string;
909
+ /** The websocket endpoint, e.g. `ws://localhost:4001/graphql/subscriptions`. */
910
+ wsUrl: string;
860
911
  /**
861
912
  * Resolves the `ConnectionInit` payload. Called again on every reconnect, so
862
913
  * a token that expired while the socket was down is refreshed on the way back
863
914
  * up.
864
915
  */
865
- connectionParams?: () => Promise<ConnectionParams>; /** Called once per server event. */
916
+ connectionParams?: () => Promise<ConnectionParams>;
917
+ /** Called once per server event. */
866
918
  onEvent: (event: DocumentChangesEventPayload) => void;
867
919
  /**
868
920
  * Called when the socket gives up: the retries built into `graphql-ws` are
@@ -938,6 +990,8 @@ declare function useDocument(id: string | null | undefined): PHDocument$1 | unde
938
990
  * - isPending: Whether the document is currently loading
939
991
  * - error: Any error that occurred during loading (e.g., document not found)
940
992
  * - reload: Function to force a refetch, or undefined when no id is supplied
993
+ * - isRefetching: A loaded document is being refetched; `data` is the loaded one
994
+ * - refetchError: The last refetch failure that kept the loaded document
941
995
  */
942
996
  declare function useDocumentSafe(id: string | null | undefined): {
943
997
  readonly status: "initial";
@@ -945,24 +999,32 @@ declare function useDocumentSafe(id: string | null | undefined): {
945
999
  readonly error: undefined;
946
1000
  readonly data: undefined;
947
1001
  readonly reload: undefined;
1002
+ readonly isRefetching: false;
1003
+ readonly refetchError: undefined;
948
1004
  } | {
949
- readonly reload: () => Promise<PHDocument$1>;
950
1005
  readonly status: "pending";
951
1006
  readonly isPending: true;
952
1007
  readonly error: undefined;
953
1008
  readonly data: undefined;
954
- } | {
955
1009
  readonly reload: () => Promise<PHDocument$1>;
1010
+ readonly isRefetching: boolean;
1011
+ readonly refetchError: unknown;
1012
+ } | {
956
1013
  readonly status: "success";
957
1014
  readonly isPending: false;
958
1015
  readonly error: undefined;
959
1016
  readonly data: PHDocument$1;
960
- } | {
961
1017
  readonly reload: () => Promise<PHDocument$1>;
1018
+ readonly isRefetching: boolean;
1019
+ readonly refetchError: unknown;
1020
+ } | {
962
1021
  readonly status: "error";
963
1022
  readonly isPending: false;
964
1023
  readonly error: unknown;
965
1024
  readonly data: undefined;
1025
+ readonly reload: () => Promise<PHDocument$1>;
1026
+ readonly isRefetching: boolean;
1027
+ readonly refetchError: unknown;
966
1028
  };
967
1029
  /**
968
1030
  * Retrieves multiple documents from the reactor using React Suspense.
@@ -997,6 +1059,8 @@ declare function useGetDocuments(): (ids: string[]) => Promise<PHDocument$1[]>;
997
1059
  * - isPending: Boolean indicating if the document is currently loading
998
1060
  * - error: Any error that occurred during loading
999
1061
  * - reload: Function to force reload the document from cache
1062
+ * - isRefetching: A loaded document is being refetched; `data` is the loaded one
1063
+ * - refetchError: The last refetch failure that kept the loaded document
1000
1064
  */
1001
1065
  declare function useGetDocumentAsync(id: string | null | undefined): {
1002
1066
  readonly status: "initial";
@@ -1004,24 +1068,32 @@ declare function useGetDocumentAsync(id: string | null | undefined): {
1004
1068
  readonly isPending: false;
1005
1069
  readonly error: undefined;
1006
1070
  readonly reload: undefined;
1071
+ readonly isRefetching: false;
1072
+ readonly refetchError: undefined;
1007
1073
  } | {
1008
- readonly reload: () => Promise<PHDocument$1>;
1009
1074
  readonly status: "pending";
1010
1075
  readonly isPending: true;
1011
1076
  readonly error: undefined;
1012
1077
  readonly data: undefined;
1013
- } | {
1014
1078
  readonly reload: () => Promise<PHDocument$1>;
1079
+ readonly isRefetching: boolean;
1080
+ readonly refetchError: unknown;
1081
+ } | {
1015
1082
  readonly status: "success";
1016
1083
  readonly isPending: false;
1017
1084
  readonly error: undefined;
1018
1085
  readonly data: PHDocument$1;
1019
- } | {
1020
1086
  readonly reload: () => Promise<PHDocument$1>;
1087
+ readonly isRefetching: boolean;
1088
+ readonly refetchError: unknown;
1089
+ } | {
1021
1090
  readonly status: "error";
1022
1091
  readonly isPending: false;
1023
1092
  readonly error: unknown;
1024
1093
  readonly data: undefined;
1094
+ readonly reload: () => Promise<PHDocument$1>;
1095
+ readonly isRefetching: boolean;
1096
+ readonly refetchError: unknown;
1025
1097
  };
1026
1098
  //#endregion
1027
1099
  //#region src/hooks/reactor.d.ts
@@ -1038,7 +1110,7 @@ declare const setReactorClient: SetPHGlobalValue<IReactorBrowserClient>;
1038
1110
  /** Adds an event handler for the reactor client */
1039
1111
  declare const addReactorClientEventHandler: AddPHGlobalEventHandler;
1040
1112
  declare const useSync: () => ISyncManager | undefined;
1041
- declare const useSyncList: () => _powerhousedao_reactor0.Remote[];
1113
+ declare const useSyncList: () => import("@powerhousedao/reactor").Remote[];
1042
1114
  declare const useModelRegistry: () => IDocumentModelRegistry | undefined;
1043
1115
  declare const useDatabase: () => Kysely<Database> | undefined;
1044
1116
  declare const usePGlite: () => PGlite | undefined;
@@ -1067,24 +1139,61 @@ declare function useDocumentModelModules(): DocumentModelModule[] | undefined;
1067
1139
  declare function useDocumentModelModuleById(id: string | null | undefined, version?: number): DocumentModelModule | undefined;
1068
1140
  //#endregion
1069
1141
  //#region src/hooks/document-operations.d.ts
1070
- type InternalState = {
1142
+ type UseDocumentOperationsOptions = {
1143
+ /**
1144
+ * Operations per page. Default 100. Applies to the next first-page load;
1145
+ * changing it while pages are already loaded has no effect until the next
1146
+ * invalidation or `refetch`.
1147
+ */
1148
+ limit?: number;
1149
+ /** Whether to fetch at all. Default true. Pass false until the operations are needed. */
1150
+ enabled?: boolean;
1151
+ };
1152
+ /** What `useDocumentOperations` returns; exported so consumers can name it. */
1153
+ type DocumentOperationsResult = {
1154
+ /** Every operation of the scope loaded so far, oldest first. */
1155
+ operations: readonly Operation$1[];
1156
+ /** A page is in flight. */
1157
+ isLoading: boolean;
1158
+ /** The last page failed. Operations loaded before it stay available. */
1159
+ error: Error | undefined;
1160
+ /** The last page reported a further page. */
1161
+ hasNextPage: boolean;
1162
+ /** Loads the next page and appends it. No-op while loading or when there is none. */
1163
+ fetchNextPage: () => void;
1164
+ /** Drops the document's cached operations and reloads from the first page. */
1165
+ refetch: () => void;
1166
+ };
1167
+ /**
1168
+ * Legacy result of `useDocumentOperations(documentId)`.
1169
+ * @deprecated Call `useDocumentOperations(documentId, scope, options)` and read `operations`. Removed in the next major.
1170
+ */
1171
+ type DocumentOperationsState = {
1071
1172
  globalOperations: Operation$1[];
1072
1173
  localOperations: Operation$1[];
1073
1174
  isLoading: boolean;
1074
1175
  error: Error | undefined;
1075
- };
1076
- /** What `useDocumentOperations` returns; exported so consumers can name it. */
1077
- type DocumentOperationsState = InternalState & {
1078
1176
  refetch: () => void;
1079
1177
  };
1178
+ /** @deprecated Pass a scope: `useDocumentOperations(documentId, "global")`. The legacy form fetches the whole global and local history eagerly. Removed in the next major. */
1179
+ declare function useDocumentOperations(documentId: string | null | undefined): DocumentOperationsState;
1080
1180
  /**
1081
- * Hook to fetch document operations via the reactor client.
1082
- * Operations are no longer auto-populated on documents and must be fetched explicitly.
1181
+ * Operation history of a document, read from the document cache and kept in
1182
+ * step with it: a change event for the document drops the cached pages and
1183
+ * the hook loads the first page again.
1184
+ *
1185
+ * Pages arrive oldest first. A view that wants the whole history calls
1186
+ * `fetchNextPage` while `hasNextPage` is true.
1083
1187
  *
1084
- * @param documentId - The document ID to fetch operations for
1085
- * @returns Object containing globalOperations, localOperations, isLoading, and error
1188
+ * An empty first page is a final result; there is no retry. When the active
1189
+ * document cache does not serve operations, the result is empty and not
1190
+ * loading.
1191
+ *
1192
+ * @param documentId - The document id, or null/undefined to skip fetching
1193
+ * @param scope - The operation scope, for example "global" or "local"
1194
+ * @param options - Page size and whether fetching is enabled
1086
1195
  */
1087
- declare function useDocumentOperations(documentId: string | null | undefined): DocumentOperationsState;
1196
+ declare function useDocumentOperations(documentId: string | null | undefined, scope: string, options?: UseDocumentOperationsOptions): DocumentOperationsResult;
1088
1197
  //#endregion
1089
1198
  //#region src/hooks/attachment-service.d.ts
1090
1199
  /** Returns the attachment service from window.ph */
@@ -1094,5 +1203,6 @@ declare const setAttachmentService: SetPHGlobalValue<IAttachmentService>;
1094
1203
  /** Registers the attachmentService window event handler */
1095
1204
  declare const addAttachmentServiceEventHandler: AddPHGlobalEventHandler;
1096
1205
  //#endregion
1097
- export { GraphQLReactorClientOptions as $, useGetDocuments as A, RemoteDocumentData as At, resolveDocumentModelModule as B, setDocumentCache as C, IRemoteClient as Ct, useDocuments as D, RemoteControllerGraphQLClient as Dt, useDocumentSafe as E, PushResult as Et, makeAuthConnectionParams as F, DocumentCache as Ft, MutateDocumentWithOperationsResult as G, signStampedAction as H, startDocumentChangesSubscription as I, addPromiseState as It, GraphQLReactorProvider as J, MutateDocumentWithOperationsVariables as K, subscriptionsUrlFromGraphqlUrl as L, readPromiseState as Lt, DocumentChangesEventPayload as M, RemoteOperationResultPage as Mt, DocumentChangesSubscriptionOptions as N, SyncStatus$1 as Nt, useGetDocument as O, RemoteControllerOptions as Ot, isAuthRefusalClose as P, TrackedAction as Pt, GraphQLReactorClient as Q, StaticPackageManager as R, addDocumentCacheEventHandler as S, GetOperationsResult as St, useDocumentCache as T, MergeHandler as Tt, stampAction as U, prepareSignedActions as V, MutateDocumentWithOperationsDocument as W, ensurePHEventHandlers as X, GraphQLReactorProviderProps as Y, useSwitchboardClient as Z, usePGlite as _, ConflictInfo as _t, useDocumentOperations as a, TypedGraphQLDocument as at, useSync as b, GetDocumentResult as bt, DispatchFn as c, BearerTokenProvider as ct, addReactorClientEventHandler as d, GetDocumentQueryFields as dt, isGraphQLReactorClient as et, addReactorClientModuleEventHandler as f, GetDocumentQueryResult as ft, useModelRegistry as g, revisionMapFromRevisionsList as gt, useDatabase as h, phDocumentFromMutation as ht, DocumentOperationsState as i, SubgraphSdkRegistry as it, ConnectionParams as j, RemoteOperation as jt, useGetDocumentAsync as k, RemoteDocumentChangeEvent as kt, UseDispatchResult as l, ambientRenownTokenProvider as lt, setReactorClientModule as m, phDocumentFromGetDocument as mt, setAttachmentService as n, GraphQLRequestOptions as nt, useDocumentModelModuleById as o, describeGraphQLDocument as ot, setReactorClient as p, RevisionsListSelection as pt, ReactorOperationFieldsFragmentDoc as q, useAttachmentService as r, SubgraphSdkFactory as rt, useDocumentModelModules as s, subgraphUrlFromGraphqlUrl as st, addAttachmentServiceEventHandler as t, viewFilterInputFromViewFilter as tt, useDispatch as u, makeAuthMiddleware as ut, useReactorClient as v, ConflictStrategy as vt, useDocument as w, IRemoteController as wt, useSyncList as x, GetDocumentWithOperationsResult as xt, useReactorClientModule as y, DocumentChangeListener as yt, packageFromDocumentModels as z };
1098
- //# sourceMappingURL=attachment-service-D3EhiAJ7.d.ts.map
1206
+ export { useSwitchboardClient as $, useGetDocument as A, RemoteControllerOptions as At, StaticPackageManager as B, isOperationCache as Bt, useSyncList as C, GetDocumentWithOperationsResult as Ct, useDocumentCache as D, MergeHandler as Dt, useDocument as E, IRemoteController as Et, DocumentChangesSubscriptionOptions as F, SyncStatus$1 as Ft, stampAction as G, resolveDocumentModelModule as H, IDLE_REFETCH_STATE as Ht, isAuthRefusalClose as I, TrackedAction as It, MutateDocumentWithOperationsVariables as J, MutateDocumentWithOperationsDocument as K, makeAuthConnectionParams as L, DocumentCache as Lt, useGetDocuments as M, RemoteDocumentData as Mt, ConnectionParams as N, RemoteOperation as Nt, useDocumentSafe as O, PushResult as Ot, DocumentChangesEventPayload as P, RemoteOperationResultPage as Pt, ensurePHEventHandlers as Q, startDocumentChangesSubscription as R, IDLE_OPERATIONS_ENTRY as Rt, useSync as S, GetDocumentResult as St, setDocumentCache as T, IRemoteClient as Tt, prepareSignedActions as U, packageFromDocumentModels as V, readPromiseState as Vt, signStampedAction as W, GraphQLReactorProvider as X, ReactorOperationFieldsFragmentDoc as Y, GraphQLReactorProviderProps as Z, useDatabase as _, phDocumentFromMutation as _t, DocumentOperationsState as a, SubgraphSdkFactory as at, useReactorClient as b, ConflictStrategy as bt, useDocumentModelModuleById as c, describeGraphQLDocument as ct, UseDispatchResult as d, ambientRenownTokenProvider as dt, GraphQLReactorClient as et, useDispatch as f, makeAuthMiddleware as ft, setReactorClientModule as g, phDocumentFromGetDocument as gt, setReactorClient as h, RevisionsListSelection as ht, DocumentOperationsResult as i, GraphQLRequestOptions as it, useGetDocumentAsync as j, RemoteDocumentChangeEvent as jt, useDocuments as k, RemoteControllerGraphQLClient as kt, useDocumentModelModules as l, subgraphUrlFromGraphqlUrl as lt, addReactorClientModuleEventHandler as m, GetDocumentQueryResult as mt, setAttachmentService as n, isGraphQLReactorClient as nt, UseDocumentOperationsOptions as o, SubgraphSdkRegistry as ot, addReactorClientEventHandler as p, GetDocumentQueryFields as pt, MutateDocumentWithOperationsResult as q, useAttachmentService as r, viewFilterInputFromViewFilter as rt, useDocumentOperations as s, TypedGraphQLDocument as st, addAttachmentServiceEventHandler as t, GraphQLReactorClientOptions as tt, DispatchFn as u, BearerTokenProvider as ut, useModelRegistry as v, revisionMapFromRevisionsList as vt, addDocumentCacheEventHandler as w, GetOperationsResult as wt, useReactorClientModule as x, DocumentChangeListener as xt, usePGlite as y, ConflictInfo as yt, subscriptionsUrlFromGraphqlUrl as z, addPromiseState as zt };
1207
+ export {};
1208
+ //# sourceMappingURL=attachment-service-But1Xljo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachment-service-But1Xljo.d.ts","names":[],"sources":["../src/document-refetcher.ts","../src/document-cache.ts","../src/remote-controller/types.ts","../src/graphql-client/adapter.ts","../src/graphql-client/auth.ts","../src/graphql-client/subgraph.ts","../src/graphql-client/graphql-reactor-client.ts","../src/graphql-client/graphql-reactor-provider.tsx","../src/graphql-client/operations.ts","../src/graphql-client/signing.ts","../src/graphql-client/static-package-manager.ts","../src/graphql-client/subscriptions.ts","../src/hooks/document-cache.ts","../src/hooks/reactor.ts","../src/hooks/dispatch.ts","../src/hooks/document-model-modules.ts","../src/hooks/document-operations.ts","../src/hooks/attachment-service.ts"],"mappings":";;;;;;;;;;;;;;;cASa,oBAAoB;;;iBCUjB,gBAAgB,GAAG,SAAS,QAAQ,KAAK,iBAAiB;iBAwB1D,iBAAiB,GAC/B,SAAS,QAAQ,KAAK,iBAAiB,KACtC,aAAa;;cA4BH,uBAAuB;;iBAQpB,iBAAiB,iBAAiB,SAAS;;;;;;;;;cAiD9C,yBAAyB,gBAAgB;UAuChC;UAtCZ;UACA;UAIA;UAEA;;;;;;;;UAkBA;;UAGA;;UAKA;UACA;UAEA;EAER,YAAoB,QAAQ;UAMpB;UAuBA;UAeM;UAON;;UAOA;;UAKA;UAMA;EAQR,IAAI,YAAY,oBAAoB,QAAQ;EA0B5C,gBAAgB,aAAa;EAI7B,SAAS,gBAAgB,QAAQ;EA8DjC,UAAU,uBAAuB;EAiBjC,mBAAmB,oBAAoB,gBAAgB;EAMvD,eAAe,oBAAoB,eAAe;EA8BlD,mBAAmB,oBAAoB;;;;;;;;;;;;;;;;;;UAuD/B;;UA8CA;EAmBR,qBAAqB;EAarB,oBAAoB,oBAAoB;UAYhC;UAmCA;UAaA;UAYA;;;;EASR;;;;KC5kBU,gCAAgC,KAC1C;KAYU,qBAAqB;KAErB,kBACV;KAEU,4BACV;;;;KAKU;EACV,QAAQ;;EAER;;EAEA;;EAEA,SAAS;;EAET;;EAEA;;EAEA,aAAa;;EAEb,eAAe;;EAEf;;;;;KAMU;EACV,gBAAgB;EAChB;;EAEA,YAAY,cAAc;;;;;KAM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d,+BACA,mBACC;;;KCvBS;;;;;;EAMV;;EAEA;;;KAIU;;EAEV,qBAAqB;;EAErB;;EAEA,OAAO;;EAEP;;EAEA;;EAEA;;;;;;KAaU;EACV,kBAAkB;EAClB,iBAAiB;EACjB;EACA,OAAO;EACP;;;iBAoFc,sBACd,wCACC;;;;;;;;;;;;;;;;;iBAiBa,sBACd,uCACA,eACA,UAAU,+BACT;;;;cC/IU,sBAAsB,iBAAiB;;cAIvC,sBAAsB,iBAAiB;;cAIvC,kCAAkC"}
@@ -87,4 +87,4 @@ var RegistryClient = class {
87
87
  //#endregion
88
88
  export { getPackagesByDocumentType as a, getPackages as i, getPackageInfo as n, getPackagesForDocumentType as o, getPackagePage as r, trimTrailingSlash as s, RegistryClient as t };
89
89
 
90
- //# sourceMappingURL=client-DjK30EQ-.js.map
90
+ //# sourceMappingURL=client-BiJAJ9dW.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"client-DjK30EQ-.js","names":[],"sources":["../src/registry/fetchers.ts","../src/registry/client.ts"],"sourcesContent":["import type { PackageInfo, PackagePage } from \"@powerhousedao/shared/registry\";\n\n// Strip a trailing \"/\" so we don't emit `http://host//packages` when a user\n// writes `packageRegistryUrl: \"http://host/\"`. Verdaccio's own web backend\n// 404s on the doubled slash, which cascades into an empty registry list and\n// masks the real install flow.\nexport function trimTrailingSlash(url: string): string {\n return url.endsWith(\"/\") ? url.slice(0, -1) : url;\n}\n\nexport async function getPackages(registryUrl: string) {\n const res = await fetch(`${trimTrailingSlash(registryUrl)}/packages`);\n if (!res.ok) throw new Error(`Registry error: HTTP ${res.status}`);\n const data = (await res.json()) as PackageInfo[];\n return data;\n}\n\n/**\n * Fetch one page of the registry listing (trimmed items). Backed by the\n * paginated `GET /packages?limit=&offset=&search=` mode. Used by the Package\n * Manager's Available tab for infinite scroll + server-side search.\n */\nexport async function getPackagePage(\n registryUrl: string,\n params: { limit: number; offset: number; search?: string },\n): Promise<PackagePage> {\n const query = new URLSearchParams({\n limit: String(params.limit),\n offset: String(params.offset),\n });\n if (params.search) query.set(\"search\", params.search);\n const res = await fetch(\n `${trimTrailingSlash(registryUrl)}/packages?${query.toString()}`,\n );\n if (!res.ok) throw new Error(`Registry error: HTTP ${res.status}`);\n return (await res.json()) as PackagePage;\n}\n\n/**\n * Fetch full package info for every package exposing a given document type,\n * via the legacy `?documentType=` filter (returns full PackageInfo objects,\n * not just names). Used by the MissingPackageModal to offer installs without\n * loading the entire paginated listing.\n */\nexport async function getPackagesForDocumentType(\n registryUrl: string,\n documentType: string,\n): Promise<PackageInfo[]> {\n const encodedType = encodeURIComponent(documentType);\n const res = await fetch(\n `${trimTrailingSlash(registryUrl)}/packages?documentType=${encodedType}`,\n );\n if (!res.ok) throw new Error(`Registry error: HTTP ${res.status}`);\n return (await res.json()) as PackageInfo[];\n}\n\nexport async function getPackagesByDocumentType(\n registryUrl: string,\n documentType: string,\n): Promise<string[]> {\n const encodedType = encodeURIComponent(documentType);\n const res = await fetch(\n `${trimTrailingSlash(registryUrl)}/packages/by-document-type?type=${encodedType}`,\n );\n if (!res.ok) throw new Error(`Registry error: HTTP ${res.status}`);\n return (await res.json()) as string[];\n}\n\n/**\n * Fetch full metadata (versions + dist-tags) for one package from the\n * single-package endpoint. Returns null when the package no longer exists\n * upstream.\n */\nexport async function getPackageInfo(\n registryUrl: string,\n name: string,\n): Promise<PackageInfo | null> {\n const encodedName = encodeURIComponent(name);\n const res = await fetch(\n `${trimTrailingSlash(registryUrl)}/packages/${encodedName}`,\n );\n if (res.status === 404) return null;\n if (!res.ok) throw new Error(`Registry error: HTTP ${res.status}`);\n return (await res.json()) as PackageInfo;\n}\n","import type { PackageInfo } from \"@powerhousedao/shared/registry\";\nimport { getPackages, getPackagesByDocumentType } from \"./fetchers.js\";\nimport type { PublishEvent } from \"./types.js\";\n\nfunction cdnUrlToApiUrl(cdnUrl: string): string {\n return cdnUrl.replace(/\\/-\\/cdn\\/?$/, \"\");\n}\nexport class RegistryClient {\n readonly apiUrl: string;\n\n constructor(cdnUrl: string) {\n this.apiUrl = cdnUrlToApiUrl(cdnUrl);\n }\n\n async getPackages(): Promise<PackageInfo[]> {\n const data = await getPackages(this.apiUrl);\n return data;\n }\n\n async getPackagesByDocumentType(documentType: string): Promise<string[]> {\n return await getPackagesByDocumentType(this.apiUrl, documentType);\n }\n\n async searchPackages(query: string): Promise<PackageInfo[]> {\n const packages = await this.getPackages();\n if (!query) return packages;\n const lowerQuery = query.toLowerCase();\n // Match on package name only (not description).\n return packages.filter((pkg) =>\n pkg.name.toLowerCase().includes(lowerQuery),\n );\n }\n\n onPublish(callback: (event: PublishEvent) => void): () => void {\n const eventSource = new EventSource(`${this.apiUrl}/-/events`);\n\n eventSource.addEventListener(\"publish\", (e: MessageEvent<string>) => {\n const data = JSON.parse(e.data) as PublishEvent;\n callback(data);\n });\n\n return () => {\n eventSource.close();\n };\n }\n}\n"],"mappings":";AAMA,SAAgB,kBAAkB,KAAqB;AACrD,QAAO,IAAI,SAAS,IAAI,GAAG,IAAI,MAAM,GAAG,GAAG,GAAG;;AAGhD,eAAsB,YAAY,aAAqB;CACrD,MAAM,MAAM,MAAM,MAAM,GAAG,kBAAkB,YAAY,CAAC,WAAW;AACrE,KAAI,CAAC,IAAI,GAAI,OAAM,IAAI,MAAM,wBAAwB,IAAI,SAAS;AAElE,QADc,MAAM,IAAI,MAAM;;;;;;;AAShC,eAAsB,eACpB,aACA,QACsB;CACtB,MAAM,QAAQ,IAAI,gBAAgB;EAChC,OAAO,OAAO,OAAO,MAAM;EAC3B,QAAQ,OAAO,OAAO,OAAO;EAC9B,CAAC;AACF,KAAI,OAAO,OAAQ,OAAM,IAAI,UAAU,OAAO,OAAO;CACrD,MAAM,MAAM,MAAM,MAChB,GAAG,kBAAkB,YAAY,CAAC,YAAY,MAAM,UAAU,GAC/D;AACD,KAAI,CAAC,IAAI,GAAI,OAAM,IAAI,MAAM,wBAAwB,IAAI,SAAS;AAClE,QAAQ,MAAM,IAAI,MAAM;;;;;;;;AA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AAW,CAC5C;;CAGH,UAAU,UAAqD;EAC7D,MAAM,cAAc,IAAI,YAAY,GAAG,KAAK,OAAO,WAAW;AAE9D,cAAY,iBAAiB,YAAY,MAA4B;AAEnE,YADa,KAAK,MAAM,EAAE,KAAK,CACjB;IACd;AAEF,eAAa;AACX,eAAY,OAAO"}
1
+ {"version":3,"file":"client-BiJAJ9dW.js","names":[],"sources":["../src/registry/fetchers.ts","../src/registry/client.ts"],"sourcesContent":["import type { PackageInfo, PackagePage } from \"@powerhousedao/shared/registry\";\n\n// Strip a trailing \"/\" so we don't emit `http://host//packages` when a user\n// writes `packageRegistryUrl: \"http://host/\"`. Verdaccio's own web backend\n// 404s on the doubled slash, which cascades into an empty registry list and\n// masks the real install flow.\nexport function trimTrailingSlash(url: string): string {\n return url.endsWith(\"/\") ? url.slice(0, -1) : url;\n}\n\nexport async function getPackages(registryUrl: string) {\n const res = await fetch(`${trimTrailingSlash(registryUrl)}/packages`);\n if (!res.ok) throw new Error(`Registry error: HTTP ${res.status}`);\n const data = (await res.json()) as PackageInfo[];\n return data;\n}\n\n/**\n * Fetch one page of the registry listing (trimmed items). Backed by the\n * paginated `GET /packages?limit=&offset=&search=` mode. Used by the Package\n * Manager's Available tab for infinite scroll + server-side search.\n */\nexport async function getPackagePage(\n registryUrl: string,\n params: { limit: number; offset: number; search?: string },\n): Promise<PackagePage> {\n const query = new URLSearchParams({\n limit: String(params.limit),\n offset: String(params.offset),\n });\n if (params.search) query.set(\"search\", params.search);\n const res = await fetch(\n `${trimTrailingSlash(registryUrl)}/packages?${query.toString()}`,\n );\n if (!res.ok) throw new Error(`Registry error: HTTP ${res.status}`);\n return (await res.json()) as PackagePage;\n}\n\n/**\n * Fetch full package info for every package exposing a given document type,\n * via the legacy `?documentType=` filter (returns full PackageInfo objects,\n * not just names). Used by the MissingPackageModal to offer installs without\n * loading the entire paginated listing.\n */\nexport async function getPackagesForDocumentType(\n registryUrl: string,\n documentType: string,\n): Promise<PackageInfo[]> {\n const encodedType = encodeURIComponent(documentType);\n const res = await fetch(\n `${trimTrailingSlash(registryUrl)}/packages?documentType=${encodedType}`,\n );\n if (!res.ok) throw new Error(`Registry error: HTTP ${res.status}`);\n return (await res.json()) as PackageInfo[];\n}\n\nexport async function getPackagesByDocumentType(\n registryUrl: string,\n documentType: string,\n): Promise<string[]> {\n const encodedType = encodeURIComponent(documentType);\n const res = await fetch(\n `${trimTrailingSlash(registryUrl)}/packages/by-document-type?type=${encodedType}`,\n );\n if (!res.ok) throw new Error(`Registry error: HTTP ${res.status}`);\n return (await res.json()) as string[];\n}\n\n/**\n * Fetch full metadata (versions + dist-tags) for one package from the\n * single-package endpoint. Returns null when the package no longer exists\n * upstream.\n */\nexport async function getPackageInfo(\n registryUrl: string,\n name: string,\n): Promise<PackageInfo | null> {\n const encodedName = encodeURIComponent(name);\n const res = await fetch(\n `${trimTrailingSlash(registryUrl)}/packages/${encodedName}`,\n );\n if (res.status === 404) return null;\n if (!res.ok) throw new Error(`Registry error: HTTP ${res.status}`);\n return (await res.json()) as PackageInfo;\n}\n","import type { PackageInfo } from \"@powerhousedao/shared/registry\";\nimport { getPackages, getPackagesByDocumentType } from \"./fetchers.js\";\nimport type { PublishEvent } from \"./types.js\";\n\nfunction cdnUrlToApiUrl(cdnUrl: string): string {\n return cdnUrl.replace(/\\/-\\/cdn\\/?$/, \"\");\n}\nexport class RegistryClient {\n readonly apiUrl: string;\n\n constructor(cdnUrl: string) {\n this.apiUrl = cdnUrlToApiUrl(cdnUrl);\n }\n\n async getPackages(): Promise<PackageInfo[]> {\n const data = await getPackages(this.apiUrl);\n return data;\n }\n\n async getPackagesByDocumentType(documentType: string): Promise<string[]> {\n return await getPackagesByDocumentType(this.apiUrl, documentType);\n }\n\n async searchPackages(query: string): Promise<PackageInfo[]> {\n const packages = await this.getPackages();\n if (!query) return packages;\n const lowerQuery = query.toLowerCase();\n // Match on package name only (not description).\n return packages.filter((pkg) =>\n pkg.name.toLowerCase().includes(lowerQuery),\n );\n }\n\n onPublish(callback: (event: PublishEvent) => void): () => void {\n const eventSource = new EventSource(`${this.apiUrl}/-/events`);\n\n eventSource.addEventListener(\"publish\", (e: MessageEvent<string>) => {\n const data = JSON.parse(e.data) as PublishEvent;\n callback(data);\n });\n\n return () => {\n eventSource.close();\n };\n }\n}\n"],"mappings":";AAMA,SAAgB,kBAAkB,KAAqB;CACrD,OAAO,IAAI,SAAS,GAAG,IAAI,IAAI,MAAM,GAAG,EAAE,IAAI;AAChD;AAEA,eAAsB,YAAY,aAAqB;CACrD,MAAM,MAAM,MAAM,MAAM,GAAG,kBAAkB,WAAW,EAAE,UAAU;CACpE,IAAI,CAAC,IAAI,IAAI,MAAM,IAAI,MAAM,wBAAwB,IAAI,QAAQ;CAEjE,OAAO,MADa,IAAI,KAAK;AAE/B;;;;;;AAOA,eAAsB,eACpB,aACA,QACsB;CACtB,MAAM,QAAQ,IAAI,gBAAgB;EAChC,OAAO,OAAO,OAAO,KAAK;EAC1B,QAAQ,OAAO,OAAO,MAAM;CAC9B,CAAC;CACD,IAAI,OAAO,QAAQ,MAAM,IAAI,UAAU,OAAO,MAAM;CACpD,MAAM,MAAM,MAAM,MAChB,GAAG,kBAAkB,WAAW,EAAE,YAAY,MAAM,SAAS,GAC/D;CACA,IAAI,CAAC,IAAI,IAAI,MAAM,IAAI,MAAM,wBAAwB,IAAI,QAAQ;CACjE,OAAQ,MAAM,IAAI,KAAK;AACzB;;;;;;;AAQA,eAAsB,2BACpB,aACA,cACwB;CACxB,MAAM,cAAc,mBAAmB,YAAY;CACnD,MAAM,MAAM,MAAM,MAChB,GAAG,kBAAkB,WAAW,EAAE,yBAAyB,aAC7D;CACA,IAAI,CAAC,IAAI,IAAI,MAAM,IAAI,MAAM,wBAAwB,IAAI,QAAQ;CACjE,OAAQ,MAAM,IAAI,KAAK;AACzB;AAEA,eAAsB,0BACpB,aACA,cACmB;CACnB,MAAM,cAAc,mBAAmB,YAAY;CACnD,MAAM,MAAM,MAAM,MAChB,GAAG,k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import { c as ReactorGraphQLClient, k as SdkFunctionWrapper } from "./types-B7-_l_wE.js";
2
2
  import { GraphQLClient } from "graphql-request";
3
-
4
3
  //#region src/graphql/client.d.ts
5
4
  /**
6
5
  * Creates a GraphQL client for the Reactor Subgraph API.
@@ -11,4 +10,5 @@ import { GraphQLClient } from "graphql-request";
11
10
  declare function createClient(urlOrGQLClient: string | GraphQLClient, middleware?: SdkFunctionWrapper): ReactorGraphQLClient;
12
11
  //#endregion
13
12
  export { createClient as t };
14
- //# sourceMappingURL=client-BIHN_UyR.d.ts.map
13
+ export {};
14
+ //# sourceMappingURL=client-CngU4mtn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-CngU4mtn.d.ts","names":[],"sources":["../src/graphql/client.ts"],"mappings":";;;;;;;;;iBA4BgB,aACd,yBAAyB,eACzB,aAAa,qBACZ"}