@powerhousedao/reactor-browser 6.2.3-dev.24 → 6.2.3-dev.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{attachment-service-cIdRZcTa.d.ts → attachment-service-CF8LWxyM.d.ts} +65 -53
- package/dist/attachment-service-CF8LWxyM.d.ts.map +1 -0
- package/dist/{client-DjK30EQ-.js → client-BiJAJ9dW.js} +1 -1
- package/dist/{client-DjK30EQ-.js.map → client-BiJAJ9dW.js.map} +1 -1
- package/dist/{client-CxJD0Ck2.d.ts → client-CngU4mtn.d.ts} +3 -3
- package/dist/client-CngU4mtn.d.ts.map +1 -0
- package/dist/{client-D4bkR4pH.js → client-VV9M73s_.js} +15 -20
- package/dist/client-VV9M73s_.js.map +1 -0
- package/dist/{document-by-id-DgdUGMVm.js → dispatch-BOQgTK9B.js} +15 -25
- package/dist/dispatch-BOQgTK9B.js.map +1 -0
- package/dist/document-by-id-Kuxk62l1.js +16 -0
- package/dist/document-by-id-Kuxk62l1.js.map +1 -0
- package/dist/{document-model-modules-D1ZEoGjN.js → document-model-modules-Cv9KSduJ.js} +14 -59
- package/dist/document-model-modules-Cv9KSduJ.js.map +1 -0
- package/dist/{document-operations-DhrcpXMf.js → document-operations-D16LsXDs.js} +22 -21
- package/dist/document-operations-D16LsXDs.js.map +1 -0
- package/dist/{global-BGoyNc1s.d.ts → global-yMvtFjK6.d.ts} +21 -16
- package/dist/global-yMvtFjK6.d.ts.map +1 -0
- package/dist/{index-DrgDweMA.d.ts → index-UsPtg1Z3.d.ts} +19 -98
- package/dist/index-UsPtg1Z3.d.ts.map +1 -0
- package/dist/{index-BIVDXw3K.d.ts → index-rtDmzViP.d.ts} +3 -3
- package/dist/index-rtDmzViP.d.ts.map +1 -0
- package/dist/index.d.ts +361 -361
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -23
- package/dist/index.js.map +1 -1
- package/dist/{inspector-proxy-6h5VKAwt.d.ts → inspector-proxy-B2qjCMEv.d.ts} +9 -4
- package/dist/inspector-proxy-B2qjCMEv.d.ts.map +1 -0
- package/dist/{make-ph-event-functions-DBq3iWYn.js → make-ph-event-functions-FzpvQtj6.js} +1 -1
- package/dist/{make-ph-event-functions-DBq3iWYn.js.map → make-ph-event-functions-FzpvQtj6.js.map} +1 -1
- package/dist/{pglite-CntadC_p-9NDG14dS.d.ts → pglite-CntadC_p-DTkdF8sr.d.ts} +11 -33
- package/dist/pglite-CntadC_p-DTkdF8sr.d.ts.map +1 -0
- package/dist/{relational-D1RB45sA.js → relational-ChC_AWAK.js} +3 -2
- package/dist/{relational-D1RB45sA.js.map → relational-ChC_AWAK.js.map} +1 -1
- package/dist/{renown-rqK8sokh.js → renown-C9pYZRqf.js} +7 -8
- package/dist/{renown-rqK8sokh.js.map → renown-C9pYZRqf.js.map} +1 -1
- package/dist/{renown-BHxwP7xU.js → renown-Def5iO8k.js} +2 -2
- package/dist/{renown-BHxwP7xU.js.map → renown-Def5iO8k.js.map} +1 -1
- package/dist/src/ai/index.d.ts +50 -61
- package/dist/src/ai/index.d.ts.map +1 -1
- package/dist/src/ai/index.js +5 -8
- package/dist/src/ai/index.js.map +1 -1
- package/dist/src/analytics/index.d.ts +36 -44
- package/dist/src/analytics/index.d.ts.map +1 -1
- package/dist/src/analytics/index.js +2 -2
- package/dist/src/analytics/index.js.map +1 -1
- package/dist/src/document-model.d.ts +3 -4
- package/dist/src/document-model.d.ts.map +1 -1
- package/dist/src/document-model.js.map +1 -1
- package/dist/src/graphql/client.d.ts +4 -3
- package/dist/src/graphql/client.js +1 -1
- package/dist/src/graphql-client/entry.d.ts +5 -4
- package/dist/src/graphql-client/entry.js +3 -3
- package/dist/src/relational/index.d.ts +8 -9
- package/dist/src/relational/index.d.ts.map +1 -1
- package/dist/src/relational/index.js +1 -1
- package/dist/src/renown/index.d.ts +3 -2
- package/dist/src/renown/index.js +2 -2
- package/dist/src/rpc/index.d.ts +31 -30
- package/dist/src/rpc/index.d.ts.map +1 -1
- package/dist/src/rpc/index.js +5 -3
- package/dist/src/rpc/index.js.map +1 -1
- package/dist/{store-BJYcr_FL.js → store-DInXcjal.js} +1 -1
- package/dist/{store-BJYcr_FL.js.map → store-DInXcjal.js.map} +1 -1
- package/dist/{switchboard-BEiFkv9K.js → switchboard-Nyr7CXcr.js} +58 -6
- package/dist/switchboard-Nyr7CXcr.js.map +1 -0
- package/dist/{types-6vDzbRRS.d.ts → types-520nWrB3.d.ts} +2 -2
- package/dist/types-520nWrB3.d.ts.map +1 -0
- package/dist/{types-N3Jy6Nry.d.ts → types-B7-_l_wE.d.ts} +17 -17
- package/dist/types-B7-_l_wE.d.ts.map +1 -0
- package/package.json +13 -14
- package/dist/attachment-service-cIdRZcTa.d.ts.map +0 -1
- package/dist/client-CxJD0Ck2.d.ts.map +0 -1
- package/dist/client-D4bkR4pH.js.map +0 -1
- package/dist/document-by-id-DgdUGMVm.js.map +0 -1
- package/dist/document-model-modules-D1ZEoGjN.js.map +0 -1
- package/dist/document-operations-DhrcpXMf.js.map +0 -1
- package/dist/global-BGoyNc1s.d.ts.map +0 -1
- package/dist/index-BIVDXw3K.d.ts.map +0 -1
- package/dist/index-DrgDweMA.d.ts.map +0 -1
- package/dist/inspector-proxy-6h5VKAwt.d.ts.map +0 -1
- package/dist/pglite-CntadC_p-9NDG14dS.d.ts.map +0 -1
- package/dist/switchboard-BEiFkv9K.js.map +0 -1
- package/dist/types-6vDzbRRS.d.ts.map +0 -1
- package/dist/types-N3Jy6Nry.d.ts.map +0 -1
|
@@ -112,7 +112,8 @@ type WorkerInspectorInfo = {
|
|
|
112
112
|
bootedAtMs: number;
|
|
113
113
|
connectedClients: number;
|
|
114
114
|
appBuildId: string;
|
|
115
|
-
rpcProtocolVersion: number;
|
|
115
|
+
rpcProtocolVersion: number;
|
|
116
|
+
/** Flags this worker is enforcing, from the fingerprint that built it. */
|
|
116
117
|
featureFlags?: string;
|
|
117
118
|
};
|
|
118
119
|
type ReactorIdentity = {
|
|
@@ -170,8 +171,11 @@ type RpcMessage = ClientMessage | OwnerMessage;
|
|
|
170
171
|
//#endregion
|
|
171
172
|
//#region src/rpc/rpc-correlator.d.ts
|
|
172
173
|
type RpcRequestOptions = {
|
|
173
|
-
/** Reject if no response arrives within this many ms; omit for no timeout. */
|
|
174
|
-
|
|
174
|
+
/** Reject if no response arrives within this many ms; omit for no timeout. */
|
|
175
|
+
timeoutMs?: number;
|
|
176
|
+
/** Maps a successful response value (e.g. paged-result rehydration). */
|
|
177
|
+
transform?: (value: unknown) => unknown;
|
|
178
|
+
/** Runs after the post; may return a cleanup invoked when the request settles. */
|
|
175
179
|
setup?: (id: CorrelationId) => (() => void) | void;
|
|
176
180
|
};
|
|
177
181
|
/** Anything that can send a client message (the router). */
|
|
@@ -254,4 +258,5 @@ interface IInspectorProxy {
|
|
|
254
258
|
declare function createInspectorProxy(router: MessageRouter): IInspectorProxy;
|
|
255
259
|
//#endregion
|
|
256
260
|
export { RpcMessage as C, WorkerMigrationState as E, RpcLiveUnsub as S, WorkerInspectorInfo as T, RPC_PROTOCOL_VERSION as _, MessageRouter as a, RpcLiveEvent as b, RpcCorrelator as c, ClientMessage as d, CorrelationId as f, OwnerMessage as g, OpKind as h, createWorkerAdminClient as i, RpcPoster as l, MethodCallMessage as m, createInspectorProxy as n, IRpcTransport as o, ErrorInfo as p, IWorkerAdminClient as r, createPortTransport as s, IInspectorProxy as t, RpcRequestOptions as u, ReactorIdentity as v, VersionFingerprint as w, RpcLiveSubscribe as x, RpcDbOp as y };
|
|
257
|
-
|
|
261
|
+
export {};
|
|
262
|
+
//# sourceMappingURL=inspector-proxy-B2qjCMEv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspector-proxy-B2qjCMEv.d.ts","names":[],"sources":["../src/rpc/protocol.ts","../src/rpc/rpc-correlator.ts","../src/rpc/transport.ts","../src/rpc/message-router.ts","../src/rpc/admin-client.ts","../src/rpc/inspector-proxy.ts"],"m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IAAI;;;KAIH;EAAc,KAAK,SAAS;;;;;;cAM3B;mBAKQ;mBACA;UALX;mBACS;EAEjB,YACmB,QAAQ,WACR;EAGnB,UAAU;;EAKV,cAAc,SAAS;;EAuBvB,QACE,QAAQ,IAAI,kBAAkB,eAC9B,UAAS,oBACR;;;;UCjEY;EACf,KAAK,SAAS;EACd,UAAU,WAAW,SAAS;EAC9B;;iBAGc,oBAAoB,MAAM,cAAc;;;KCJnD,YAAY;;;;;;cAQJ;mBACM;mBACA;UACT;UACA;EAER,YAAY;EAQZ,OAAO,WAAW;EASlB;EAMA,KAAK,SAAS;;EAQd,GAAG,UAAU,WACX,MAAM,GACN,UAAU,SAAS,QAAQ;IAAgB,GAAG;;EAchD,QACE,QAAQ,IAAI,kBAAkB,eAC9B,UAAU,oBACT;EAIH,UAAU;;;;UCnEK;EACf,QAAQ,QAAQ;EAChB,WAAW;EACX,gBAAgB;EAChB,WAAW;EACX,qBAAqB;EACrB,mBAAmB;;;iBAIL,wBACd,QAAQ,gBACP;;;UCdc;EACf,iBAAiB;EACjB,cAAc;EACd,eAAe;EACf,iBAAiB;EACjB,eAAe,sBAAsB;EACrC,iBAAiB,oBAAoB,kBAAkB;EACvD,iBAAiB,oBAAoB,kBAAkB;EACvD,iBAAiB,oBAAoB,kBAAkB;EACvD,eAAe,aAAa,qBAAqB;;iBAGnC,qBAAqB,QAAQ,gBAAgB"}
|
package/dist/{make-ph-event-functions-DBq3iWYn.js.map → make-ph-event-functions-FzpvQtj6.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"make-ph-event-functions-
|
|
1
|
+
{"version":3,"file":"make-ph-event-functions-FzpvQtj6.js","names":[],"sources":["../src/hooks/make-ph-event-functions.ts"],"sourcesContent":["import type {\n PHGlobal,\n PHGlobalKey,\n SetEvent,\n} from \"@powerhousedao/reactor-browser\";\nimport { capitalCase } from \"change-case\";\nimport { useSyncExternalStore } from \"react\";\n\n// guard condition for server side rendering\nconst isServer = typeof window === \"undefined\";\n\nexport function makePHEventFunctions<TKey extends PHGlobalKey>(key: TKey) {\n const setEventName = `ph:set${capitalCase(key)}` as const;\n const updateEventName = `ph:${key}Updated` as const;\n\n function setValue(value: PHGlobal[TKey] | undefined) {\n if (isServer) {\n return;\n }\n const event = new CustomEvent(setEventName, {\n detail: { [key]: value },\n });\n window.dispatchEvent(event);\n }\n\n function dispatchUpdatedEvent() {\n if (isServer) {\n return;\n }\n const event = new CustomEvent(updateEventName);\n window.dispatchEvent(event);\n }\n\n function handleSetValueEvent(event: SetEvent<TKey>) {\n if (isServer) {\n return;\n }\n const value = event.detail[key];\n if (!window.ph) {\n window.ph = {};\n }\n window.ph[key] = value;\n dispatchUpdatedEvent();\n }\n\n function addEventHandler() {\n if (isServer) {\n return;\n }\n window.addEventListener(setEventName, handleSetValueEvent as EventListener);\n }\n\n function subscribeToValue(onStoreChange: () => void) {\n if (isServer) return () => {};\n window.addEventListener(updateEventName, onStoreChange);\n return () => {\n window.removeEventListener(updateEventName, onStoreChange);\n };\n }\n\n function getSnapshot() {\n if (isServer) {\n return undefined;\n }\n // The store is legitimately read before the first `setValue` (subscribers\n // mount before init runs), so an uninitialized store is expected, not an\n // error — return `undefined` quietly rather than warning on every render.\n return window.ph?.[key];\n }\n\n function getServerSnapshot() {\n return undefined;\n }\n\n function useValue() {\n return useSyncExternalStore(\n subscribeToValue,\n getSnapshot,\n getServerSnapshot,\n );\n }\n\n return {\n useValue,\n setValue,\n addEventHandler,\n };\n}\n"],"mappings":";;;AASA,MAAM,WAAW,OAAO,WAAW;AAEnC,SAAgB,qBAA+C,KAAW;CACxE,MAAM,eAAe,SAAS,YAAY,GAAG;CAC7C,MAAM,kBAAkB,MAAM,IAAI;CAElC,SAAS,SAAS,OAAmC;EACnD,IAAI,UACF;EAEF,MAAM,QAAQ,IAAI,YAAY,cAAc,EAC1C,QAAQ,GAAG,MAAM,MAAM,EACzB,CAAC;EACD,OAAO,cAAc,KAAK;CAC5B;CAEA,SAAS,uBAAuB;EAC9B,IAAI,UACF;EAEF,MAAM,QAAQ,IAAI,YAAY,eAAe;EAC7C,OAAO,cAAc,KAAK;CAC5B;CAEA,SAAS,oBAAoB,OAAuB;EAClD,IAAI,UACF;EAEF,MAAM,QAAQ,MAAM,OAAO;EAC3B,IAAI,CAAC,OAAO,IACV,OAAO,KAAK,CAAC;EAEf,OAAO,GAAG,OAAO;EACjB,qBAAqB;CACvB;CAEA,SAAS,kBAAkB;EACzB,IAAI,UACF;EAEF,OAAO,iBAAiB,cAAc,mBAAoC;CAC5E;CAEA,SAAS,iBAAiB,eAA2B;EACnD,IAAI,UAAU,aAAa,CAAC;EAC5B,OAAO,iBAAiB,iBAAiB,aAAa;EACtD,aAAa;GACX,OAAO,oBAAoB,iBAAiB,aAAa;EAC3D;CACF;CAEA,SAAS,cAAc;EACrB,IAAI,UACF;EAKF,OAAO,OAAO,KAAK;CACrB;CAEA,SAAS,oBAAoB,CAE7B;CAEA,SAAS,WAAW;EAClB,OAAO,qBACL,kBACA,aACA,iBACF;CACF;CAEA,OAAO;EACL;EACA;EACA;CACF;AACF"}
|
|
@@ -111,9 +111,6 @@ interface Filesystem {
|
|
|
111
111
|
*/
|
|
112
112
|
closeFs(): Promise<void>;
|
|
113
113
|
}
|
|
114
|
-
/**
|
|
115
|
-
* Base class for all emscripten built-in filesystems.
|
|
116
|
-
*/
|
|
117
114
|
type DebugLevel = 0 | 1 | 2 | 3 | 4 | 5;
|
|
118
115
|
type RowMode = 'array' | 'object';
|
|
119
116
|
interface ParserOptions {
|
|
@@ -151,7 +148,7 @@ type ExtensionNamespace<T> = T extends Extension<infer TNamespace> ? TNamespace
|
|
|
151
148
|
type Extensions = {
|
|
152
149
|
[namespace: string]: Extension | URL;
|
|
153
150
|
};
|
|
154
|
-
type InitializedExtensions<TExtensions extends Extensions = Extensions> = { [K in keyof TExtensions]: ExtensionNamespace<TExtensions[K]
|
|
151
|
+
type InitializedExtensions<TExtensions extends Extensions = Extensions> = { [K in keyof TExtensions]: ExtensionNamespace<TExtensions[K]>; };
|
|
155
152
|
interface ExecProtocolResult {
|
|
156
153
|
messages: BackendMessage[];
|
|
157
154
|
data: Uint8Array;
|
|
@@ -192,7 +189,7 @@ type PGliteInterface<T extends Extensions = Extensions> = InitializedExtensions<
|
|
|
192
189
|
dumpDataDir(compression?: DumpTarCompressionOptions): Promise<File | Blob>;
|
|
193
190
|
refreshArrayTypes(): Promise<void>;
|
|
194
191
|
};
|
|
195
|
-
type PGliteInterfaceExtensions<E> = E extends Extensions ? { [K in keyof E]: E[K] extends Extension ? Awaited<ReturnType<E[K]['setup']>>['namespaceObj'] extends infer N ? N extends undefined | null | void ? never : N : never : never } : Record<string, never>;
|
|
192
|
+
type PGliteInterfaceExtensions<E> = E extends Extensions ? { [K in keyof E]: E[K] extends Extension ? Awaited<ReturnType<E[K]['setup']>>['namespaceObj'] extends (infer N) ? N extends undefined | null | void ? never : N : never : never; } : Record<string, never>;
|
|
196
193
|
type Row<T = {
|
|
197
194
|
[key: string]: any;
|
|
198
195
|
}> = T;
|
|
@@ -238,19 +235,13 @@ declare abstract class BasePGlite implements Pick<PGliteInterface, 'query' | 'sq
|
|
|
238
235
|
* @param message The postgres wire protocol message to execute
|
|
239
236
|
* @returns The result of the query
|
|
240
237
|
*/
|
|
241
|
-
abstract execProtocol(message: Uint8Array, {
|
|
242
|
-
syncToFs,
|
|
243
|
-
onNotice
|
|
244
|
-
}: ExecProtocolOptions): Promise<ExecProtocolResult>;
|
|
238
|
+
abstract execProtocol(message: Uint8Array, { syncToFs, onNotice }: ExecProtocolOptions): Promise<ExecProtocolResult>;
|
|
245
239
|
/**
|
|
246
240
|
* Execute a postgres wire protocol message
|
|
247
241
|
* @param message The postgres wire protocol message to execute
|
|
248
242
|
* @returns The parsed results of the query
|
|
249
243
|
*/
|
|
250
|
-
abstract execProtocolStream(message: Uint8Array, {
|
|
251
|
-
syncToFs,
|
|
252
|
-
onNotice
|
|
253
|
-
}: ExecProtocolOptions): Promise<BackendMessage[]>;
|
|
244
|
+
abstract execProtocolStream(message: Uint8Array, { syncToFs, onNotice }: ExecProtocolOptions): Promise<BackendMessage[]>;
|
|
254
245
|
/**
|
|
255
246
|
* Execute a postgres wire protocol message directly without wrapping the response.
|
|
256
247
|
* Only use if `execProtocol()` doesn't suite your needs.
|
|
@@ -262,9 +253,7 @@ declare abstract class BasePGlite implements Pick<PGliteInterface, 'query' | 'sq
|
|
|
262
253
|
* @param message The postgres wire protocol message to execute
|
|
263
254
|
* @returns The direct message data response produced by Postgres
|
|
264
255
|
*/
|
|
265
|
-
abstract execProtocolRaw(message: Uint8Array, {
|
|
266
|
-
syncToFs
|
|
267
|
-
}: ExecProtocolOptions): Promise<Uint8Array>;
|
|
256
|
+
abstract execProtocolRaw(message: Uint8Array, { syncToFs }: ExecProtocolOptions): Promise<Uint8Array>;
|
|
268
257
|
/**
|
|
269
258
|
* Sync the database to the filesystem
|
|
270
259
|
* @returns Promise that resolves when the database is synced to the filesystem
|
|
@@ -298,9 +287,7 @@ declare abstract class BasePGlite implements Pick<PGliteInterface, 'query' | 'sq
|
|
|
298
287
|
* each type.
|
|
299
288
|
* This should be called at the end of #init() in the implementing class.
|
|
300
289
|
*/
|
|
301
|
-
_initArrayTypes({
|
|
302
|
-
force
|
|
303
|
-
}?: {
|
|
290
|
+
_initArrayTypes({ force }?: {
|
|
304
291
|
force?: boolean | undefined;
|
|
305
292
|
}): Promise<void>;
|
|
306
293
|
/**
|
|
@@ -462,29 +449,19 @@ declare class PGlite extends BasePGlite implements PGliteInterface, AsyncDisposa
|
|
|
462
449
|
* @param message The postgres wire protocol message to execute
|
|
463
450
|
* @returns The direct message data response produced by Postgres
|
|
464
451
|
*/
|
|
465
|
-
execProtocolRaw(message: Uint8Array, {
|
|
466
|
-
syncToFs
|
|
467
|
-
}?: ExecProtocolOptions): Promise<Uint8Array>;
|
|
452
|
+
execProtocolRaw(message: Uint8Array, { syncToFs }?: ExecProtocolOptions): Promise<Uint8Array>;
|
|
468
453
|
/**
|
|
469
454
|
* Execute a postgres wire protocol message
|
|
470
455
|
* @param message The postgres wire protocol message to execute
|
|
471
456
|
* @returns The result of the query
|
|
472
457
|
*/
|
|
473
|
-
execProtocol(message: Uint8Array, {
|
|
474
|
-
syncToFs,
|
|
475
|
-
throwOnError,
|
|
476
|
-
onNotice
|
|
477
|
-
}?: ExecProtocolOptions): Promise<ExecProtocolResult>;
|
|
458
|
+
execProtocol(message: Uint8Array, { syncToFs, throwOnError, onNotice }?: ExecProtocolOptions): Promise<ExecProtocolResult>;
|
|
478
459
|
/**
|
|
479
460
|
* Execute a postgres wire protocol message
|
|
480
461
|
* @param message The postgres wire protocol message to execute
|
|
481
462
|
* @returns The parsed results of the query
|
|
482
463
|
*/
|
|
483
|
-
execProtocolStream(message: Uint8Array, {
|
|
484
|
-
syncToFs,
|
|
485
|
-
throwOnError,
|
|
486
|
-
onNotice
|
|
487
|
-
}?: ExecProtocolOptions): Promise<BackendMessage[]>;
|
|
464
|
+
execProtocolStream(message: Uint8Array, { syncToFs, throwOnError, onNotice }?: ExecProtocolOptions): Promise<BackendMessage[]>;
|
|
488
465
|
/**
|
|
489
466
|
* Check if the database is in a transaction
|
|
490
467
|
* @returns True if the database is in a transaction, false otherwise
|
|
@@ -540,4 +517,5 @@ declare class PGlite extends BasePGlite implements PGliteInterface, AsyncDisposa
|
|
|
540
517
|
}
|
|
541
518
|
//#endregion
|
|
542
519
|
export { type PGliteInterface as n, type Results as r, PGlite as t };
|
|
543
|
-
|
|
520
|
+
export {};
|
|
521
|
+
//# sourceMappingURL=pglite-CntadC_p-DTkdF8sr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pglite-CntadC_p-DTkdF8sr.d.ts","names":[],"sources":["../../../node_modules/.pnpm/@electric-sql+pglite@0.3.15/node_modules/@electric-sql/pglite/dist/pglite-CntadC_p.d.ts"],"x_google_ignoreList":[0],"mappings":";KAOK;KACA;EACD,MAAM;EACN;;UA6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hooks/useRelationalDb.ts
|
|
36
36
|
function createRelationalDbWithLive(pgliteInstance) {
|
|
37
|
-
const
|
|
37
|
+
const baseDb = new Kysely({ dialect: new PGliteDialect(pgliteInstance) });
|
|
38
|
+
const relationalDBWithLive = createRelationalDb(baseDb);
|
|
38
39
|
relationalDBWithLive.live = pgliteInstance.live;
|
|
39
40
|
return relationalDBWithLive;
|
|
40
41
|
}
|
|
@@ -132,4 +133,4 @@ function createProcessorQuery(ProcessorClass) {
|
|
|
132
133
|
//#endregion
|
|
133
134
|
export { setPGliteDB as i, useRelationalQuery as n, useRelationalDb as r, createProcessorQuery as t };
|
|
134
135
|
|
|
135
|
-
//# sourceMappingURL=relational-
|
|
136
|
+
//# sourceMappingURL=relational-ChC_AWAK.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relational-D1RB45sA.js","names":[],"sources":["../src/pglite/usePGlite.ts","../src/relational/hooks/useRelationalDb.ts","../src/relational/hooks/useRelationalQuery.ts","../src/relational/utils/createProcessorQuery.ts"],"sourcesContent":["import type { PGliteWithLive } from \"@electric-sql/pglite/live\";\nimport { useEffect, useState } from \"react\";\n\nexport const PGLITE_UPDATE_EVENT = \"ph:pglite-update\";\n\nexport interface PGliteState {\n db: PGliteWithLive | null;\n isLoading: boolean;\n error: Error | null;\n}\n\nconst defaultPGliteState: PGliteState = {\n db: null,\n isLoading: true,\n error: null,\n};\n\nexport const usePGliteDB = () => {\n const [state, setState] = useState<PGliteState>(\n () => window.powerhouse?.pglite ?? defaultPGliteState,\n );\n\n useEffect(() => {\n const handlePgliteUpdate = () =>\n setState(window.powerhouse?.pglite ?? defaultPGliteState);\n\n window.addEventListener(PGLITE_UPDATE_EVENT, handlePgliteUpdate);\n\n return () =>\n window.removeEventListener(PGLITE_UPDATE_EVENT, handlePgliteUpdate);\n }, []);\n\n return state;\n};\n\nexport function setPGliteDB(pglite: Partial<PGliteState>): void {\n const currentPowerhouse = window.powerhouse ?? {};\n const currentPGliteState = window.powerhouse?.pglite ?? defaultPGliteState;\n\n window.powerhouse = {\n ...currentPowerhouse,\n pglite: {\n ...currentPGliteState,\n ...pglite,\n },\n };\n window.dispatchEvent(new CustomEvent(PGLITE_UPDATE_EVENT));\n}\n\nexport const useSetPGliteDB = () => setPGliteDB;\n\nexport const usePGlite = () => {\n const pglite = usePGliteDB();\n const setPGlite = useSetPGliteDB();\n\n return [pglite, setPGlite];\n};\n","import type { PGlite } from \"@electric-sql/pglite\";\nimport type { LiveNamespace, PGliteWithLive } from \"@electric-sql/pglite/live\";\nimport { createRelationalDb } from \"@powerhousedao/reactor\";\nimport type { IRelationalDb as IRelationalDbCore } from \"@powerhousedao/shared/processors\";\nimport { Kysely } from \"kysely\";\nimport { PGliteDialect } from \"kysely-pglite-dialect\";\nimport { useMemo } from \"react\";\nimport { usePGliteDB } from \"../../pglite/usePGlite.js\";\n\n// Type for Relational DB instance enhanced with live capabilities\nexport type RelationalDbWithLive<Schema> = IRelationalDbCore<Schema> & {\n live: LiveNamespace;\n};\n\ninterface IRelationalDbState<Schema> {\n db: RelationalDbWithLive<Schema> | null;\n isLoading: boolean;\n error: Error | null;\n}\n\n// Custom initializer that creates enhanced Kysely instance with live capabilities\nfunction createRelationalDbWithLive<Schema>(\n pgliteInstance: PGliteWithLive,\n): RelationalDbWithLive<Schema> {\n const baseDb = new Kysely<Schema>({\n dialect: new PGliteDialect(pgliteInstance as unknown as PGlite),\n });\n const relationalDb = createRelationalDb(baseDb);\n\n // Inject the live namespace with proper typing\n const relationalDBWithLive =\n relationalDb as unknown as RelationalDbWithLive<Schema>;\n relationalDBWithLive.live = pgliteInstance.live;\n\n return relationalDBWithLive;\n}\n\nexport const useRelationalDb = <Schema>(): IRelationalDbState<Schema> => {\n const pglite = usePGliteDB();\n\n const relationalDb = useMemo<IRelationalDbState<Schema>>(() => {\n if (!pglite.db || pglite.isLoading || pglite.error) {\n return {\n db: null,\n isLoading: pglite.isLoading,\n error: pglite.error,\n };\n }\n\n const db = createRelationalDbWithLive<Schema>(pglite.db);\n\n return {\n db,\n isLoading: false,\n error: null,\n };\n }, [pglite]);\n\n return relationalDb;\n};\n","import type { LiveQueryResults } from \"@electric-sql/pglite/live\";\nimport type {\n IRelationalQueryBuilder,\n RelationalDbProcessorClass,\n} from \"@powerhousedao/shared/processors\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { useRelationalDb } from \"./useRelationalDb.js\";\n\nexport type QueryCallbackReturnType = {\n sql: string;\n parameters?: readonly unknown[];\n};\n\nexport type useRelationalQueryOptions = {\n // Whether to hash the namespace to avoid namespace size limit. True by default\n hashNamespace?: boolean;\n};\n\nconst MAX_RETRIES = 5;\nconst RETRY_DELAY = 200;\n\nconst isRelationNotExistError = (error: unknown): boolean => {\n const errorMessage =\n error instanceof Error\n ? error.message\n : typeof error === \"string\"\n ? error\n : String(error);\n\n return (\n errorMessage.toLowerCase().includes(\"relation\") &&\n errorMessage.toLowerCase().includes(\"does not exist\")\n );\n};\n\ntype LiveQueryType = {\n unsubscribe: () => void;\n};\n\nexport function useRelationalQuery<Schema, T = unknown, TParams = undefined>(\n ProcessorClass: RelationalDbProcessorClass<Schema>,\n driveId: string,\n queryCallback: (\n db: IRelationalQueryBuilder<Schema>,\n parameters?: TParams,\n ) => QueryCallbackReturnType,\n parameters?: TParams,\n _options?: useRelationalQueryOptions,\n) {\n const [result, setResult] = useState<LiveQueryResults<T> | null>(null);\n const [queryLoading, setQueryLoading] = useState(true);\n const [error, setError] = useState<Error | undefined>(undefined);\n const retryCount = useRef(0);\n const retryTimeoutRef = useRef<NodeJS.Timeout>(null);\n\n const relationalDb = useRelationalDb<Schema>();\n\n const executeLiveQuery = async (\n sql: string,\n queryParameters: readonly unknown[] | undefined,\n retryAttempt = 0,\n ): Promise<LiveQueryType | null> => {\n if (!relationalDb.db) {\n return null;\n }\n\n try {\n const live = await relationalDb.db.live.query<T>(\n sql,\n queryParameters ? [...queryParameters] : [],\n (result) => {\n setResult(result);\n setQueryLoading(false);\n retryCount.current = 0; // Reset retry count on success\n },\n );\n\n return live as LiveQueryType;\n } catch (err: unknown) {\n if (isRelationNotExistError(err) && retryAttempt < MAX_RETRIES) {\n return new Promise((resolve) => {\n retryTimeoutRef.current = setTimeout(() => {\n resolve(executeLiveQuery(sql, queryParameters, retryAttempt + 1));\n }, RETRY_DELAY);\n });\n }\n\n setQueryLoading(false);\n setError(err instanceof Error ? err : new Error(String(err)));\n return null;\n }\n };\n\n useEffect(() => {\n setError(undefined);\n setQueryLoading(true);\n retryCount.current = 0;\n\n if (!relationalDb.db) {\n return;\n }\n\n // Use the processor helper to obtain a typed namespaced query builder\n const db = ProcessorClass.query(driveId, relationalDb.db);\n\n const compiledQuery = queryCallback(db, parameters);\n const { sql, parameters: queryParameters } = compiledQuery;\n\n const liveQueryPromise = executeLiveQuery(sql, queryParameters);\n\n return () => {\n if (retryTimeoutRef.current) {\n clearTimeout(retryTimeoutRef.current);\n }\n void liveQueryPromise.then((live) => {\n if (live?.unsubscribe) {\n live.unsubscribe();\n }\n });\n };\n }, [relationalDb.db, ProcessorClass, driveId, queryCallback, parameters]);\n\n return {\n isLoading: relationalDb.isLoading || queryLoading,\n error: error || relationalDb.error,\n result,\n } as const;\n}\n","import type { LiveQueryResults } from \"@electric-sql/pglite/live\";\nimport type {\n QueryCallbackReturnType,\n useRelationalQueryOptions,\n} from \"@powerhousedao/reactor-browser\";\nimport type {\n IRelationalQueryBuilder,\n RelationalDbProcessorClass,\n} from \"@powerhousedao/shared/processors\";\nimport type { CompiledQuery } from \"kysely\";\nimport deepEqual from \"lodash.isequal\";\nimport { useCallback, useMemo, useRef } from \"react\";\nimport { useRelationalQuery } from \"../hooks/useRelationalQuery.js\";\n\n// Custom hook for parameter memoization\nfunction useStableParams<T>(params: T): T {\n const prevParamsRef = useRef<T>(null);\n\n return useMemo(() => {\n if (!deepEqual(prevParamsRef.current, params)) {\n prevParamsRef.current = params;\n }\n return prevParamsRef.current as T;\n }, [params]);\n}\n\nexport function createProcessorQuery<TSchema>(\n ProcessorClass: RelationalDbProcessorClass<TSchema>,\n) {\n // Overload for queries without parameters\n function useQuery<\n TQueryBuilder extends (\n db: IRelationalQueryBuilder<TSchema>,\n ) => QueryCallbackReturnType,\n >(\n driveId: string,\n queryCallback: TQueryBuilder,\n ): {\n isLoading: boolean;\n error: Error | null;\n result: LiveQueryResults<\n ReturnType<TQueryBuilder> extends CompiledQuery<infer R> ? R : any\n > | null;\n };\n\n // Overload for queries with parameters\n function useQuery<\n TParams,\n TQueryBuilder extends (\n db: IRelationalQueryBuilder<TSchema>,\n parameters: TParams,\n ) => QueryCallbackReturnType,\n >(\n driveId: string,\n queryCallback: TQueryBuilder,\n parameters: TParams,\n options?: useRelationalQueryOptions,\n ): {\n isLoading: boolean;\n error: Error | null;\n result: LiveQueryResults<\n ReturnType<TQueryBuilder> extends CompiledQuery<infer R> ? R : any\n > | null;\n };\n\n function useQuery<\n TParams,\n TQueryBuilder extends (\n db: IRelationalQueryBuilder<TSchema>,\n parameters?: TParams,\n ) => QueryCallbackReturnType,\n >(\n driveId: string,\n queryCallback: TQueryBuilder,\n parameters?: TParams,\n options?: useRelationalQueryOptions,\n ): {\n isLoading: boolean;\n error: Error | null;\n result: LiveQueryResults<\n ReturnType<TQueryBuilder> extends CompiledQuery<infer R> ? R : any\n > | null;\n } {\n type InferredResult =\n ReturnType<TQueryBuilder> extends CompiledQuery<infer R> ? R : any;\n\n // Automatically memoize parameters using deep comparison\n const stableParams = useStableParams(parameters);\n\n // Memoize the callback to prevent infinite loops, updating when parameters change\n const memoizedCallback = useCallback(queryCallback, [stableParams]);\n\n return useRelationalQuery<TSchema, InferredResult, TParams>(\n ProcessorClass,\n driveId,\n memoizedCallback,\n stableParams,\n options,\n ) as {\n isLoading: boolean;\n error: Error | null;\n result: LiveQueryResults<InferredResult> | null;\n };\n }\n\n return useQuery;\n}\n"],"mappings":";;;;;;AAGA,MAAa,sBAAsB;AAQnC,MAAM,qBAAkC;CACtC,IAAI;CACJ,WAAW;C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,aAAa;EAC7B;EACD;;;;AC/GH,SAAS,gBAAmB,QAAc;CACxC,MAAM,gBAAgB,OAAU,KAAK;AAErC,QAAO,cAAc;AACnB,MAAI,CAAC,UAAU,cAAc,SAAS,OAAO,CAC3C,eAAc,UAAU;AAE1B,SAAO,cAAc;IACpB,CAAC,OAAO,CAAC;;AAGd,SAAgB,qBACd,gBACA;CAqCA,SAAS,SAOP,SACA,eACA,YACA,SAOA;EAKA,MAAM,eAAe,gBAAgB,WAAW;AAKhD,SAAO,mBACL,gBACA,SAJuB,YAAY,eAAe,CAAC,aAAa,CAAC,EAMjE,cACA,QACD;;AAOH,QAAO"}
|
|
1
|
+
{"version":3,"file":"relational-ChC_AWAK.js","names":[],"sources":["../src/pglite/usePGlite.ts","../src/relational/hooks/useRelationalDb.ts","../src/relational/hooks/useRelationalQuery.ts","../src/relational/utils/createProcessorQuery.ts"],"sourcesContent":["import type { PGliteWithLive } from \"@electric-sql/pglite/live\";\nimport { useEffect, useState } from \"react\";\n\nexport const PGLITE_UPDATE_EVENT = \"ph:pglite-update\";\n\nexport interface PGliteState {\n db: PGliteWithLive | null;\n isLoading: boolean;\n error: Error | null;\n}\n\nconst defaultPGliteState: PGliteState = {\n db: null,\n isLoading: true,\n error: null,\n};\n\nexport const usePGliteDB = () => {\n const [state, setState] = useState<PGliteState>(\n () => window.powerhouse?.pglite ?? defaultPGliteState,\n );\n\n useEffect(() => {\n const handlePgliteUpdate = () =>\n setState(window.powerhouse?.pglite ?? defaultPGliteState);\n\n window.addEventListener(PGLITE_UPDATE_EVENT, handlePgliteUpdate);\n\n return () =>\n window.removeEventListener(PGLITE_UPDATE_EVENT, handlePgliteUpdate);\n }, []);\n\n return state;\n};\n\nexport function setPGliteDB(pglite: Partial<PGliteState>): void {\n const currentPowerhouse = window.powerhouse ?? {};\n const currentPGliteState = window.powerhouse?.pglite ?? defaultPGliteState;\n\n window.powerhouse = {\n ...currentPowerhouse,\n pglite: {\n ...currentPGliteState,\n ...pglite,\n },\n };\n window.dispatchEvent(new CustomEvent(PGLITE_UPDATE_EVENT));\n}\n\nexport const useSetPGliteDB = () => setPGliteDB;\n\nexport const usePGlite = () => {\n const pglite = usePGliteDB();\n const setPGlite = useSetPGliteDB();\n\n return [pglite, setPGlite];\n};\n","import type { PGlite } from \"@electric-sql/pglite\";\nimport type { LiveNamespace, PGliteWithLive } from \"@electric-sql/pglite/live\";\nimport { createRelationalDb } from \"@powerhousedao/reactor\";\nimport type { IRelationalDb as IRelationalDbCore } from \"@powerhousedao/shared/processors\";\nimport { Kysely } from \"kysely\";\nimport { PGliteDialect } from \"kysely-pglite-dialect\";\nimport { useMemo } from \"react\";\nimport { usePGliteDB } from \"../../pglite/usePGlite.js\";\n\n// Type for Relational DB instance enhanced with live capabilities\nexport type RelationalDbWithLive<Schema> = IRelationalDbCore<Schema> & {\n live: LiveNamespace;\n};\n\ninterface IRelationalDbState<Schema> {\n db: RelationalDbWithLive<Schema> | null;\n isLoading: boolean;\n error: Error | null;\n}\n\n// Custom initializer that creates enhanced Kysely instance with live capabilities\nfunction createRelationalDbWithLive<Schema>(\n pgliteInstance: PGliteWithLive,\n): RelationalDbWithLive<Schema> {\n const baseDb = new Kysely<Schema>({\n dialect: new PGliteDialect(pgliteInstance as unknown as PGlite),\n });\n const relationalDb = createRelationalDb(baseDb);\n\n // Inject the live namespace with proper typing\n const relationalDBWithLive =\n relationalDb as unknown as RelationalDbWithLive<Schema>;\n relationalDBWithLive.live = pgliteInstance.live;\n\n return relationalDBWithLive;\n}\n\nexport const useRelationalDb = <Schema>(): IRelationalDbState<Schema> => {\n const pglite = usePGliteDB();\n\n const relationalDb = useMemo<IRelationalDbState<Schema>>(() => {\n if (!pglite.db || pglite.isLoading || pglite.error) {\n return {\n db: null,\n isLoading: pglite.isLoading,\n error: pglite.error,\n };\n }\n\n const db = createRelationalDbWithLive<Schema>(pglite.db);\n\n return {\n db,\n isLoading: false,\n error: null,\n };\n }, [pglite]);\n\n return relationalDb;\n};\n","import type { LiveQueryResults } from \"@electric-sql/pglite/live\";\nimport type {\n IRelationalQueryBuilder,\n RelationalDbProcessorClass,\n} from \"@powerhousedao/shared/processors\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { useRelationalDb } from \"./useRelationalDb.js\";\n\nexport type QueryCallbackReturnType = {\n sql: string;\n parameters?: readonly unknown[];\n};\n\nexport type useRelationalQueryOptions = {\n // Whether to hash the namespace to avoid namespace size limit. True by default\n hashNamespace?: boolean;\n};\n\nconst MAX_RETRIES = 5;\nconst RETRY_DELAY = 200;\n\nconst isRelationNotExistError = (error: unknown): boolean => {\n const errorMessage =\n error instanceof Error\n ? error.message\n : typeof error === \"string\"\n ? error\n : String(error);\n\n return (\n errorMessage.toLowerCase().includes(\"relation\") &&\n errorMessage.toLowerCase().includes(\"does not exist\")\n );\n};\n\ntype LiveQueryType = {\n unsubscribe: () => void;\n};\n\nexport function useRelationalQuery<Schema, T = unknown, TParams = undefined>(\n ProcessorClass: RelationalDbProcessorClass<Schema>,\n driveId: string,\n queryCallback: (\n db: IRelationalQueryBuilder<Schema>,\n parameters?: TParams,\n ) => QueryCallbackReturnType,\n parameters?: TParams,\n _options?: useRelationalQueryOptions,\n) {\n const [result, setResult] = useState<LiveQueryResults<T> | null>(null);\n const [queryLoading, setQueryLoading] = useState(true);\n const [error, setError] = useState<Error | undefined>(undefined);\n const retryCount = useRef(0);\n const retryTimeoutRef = useRef<NodeJS.Timeout>(null);\n\n const relationalDb = useRelationalDb<Schema>();\n\n const executeLiveQuery = async (\n sql: string,\n queryParameters: readonly unknown[] | undefined,\n retryAttempt = 0,\n ): Promise<LiveQueryType | null> => {\n if (!relationalDb.db) {\n return null;\n }\n\n try {\n const live = await relationalDb.db.live.query<T>(\n sql,\n queryParameters ? [...queryParameters] : [],\n (result) => {\n setResult(result);\n setQueryLoading(false);\n retryCount.current = 0; // Reset retry count on success\n },\n );\n\n return live as LiveQueryType;\n } catch (err: unknown) {\n if (isRelationNotExistError(err) && retryAttempt < MAX_RETRIES) {\n return new Promise((resolve) => {\n retryTimeoutRef.current = setTimeout(() => {\n resolve(executeLiveQuery(sql, queryParameters, retryAttempt + 1));\n }, RETRY_DELAY);\n });\n }\n\n setQueryLoading(false);\n setError(err instanceof Error ? err : new Error(String(err)));\n return null;\n }\n };\n\n useEffect(() => {\n setError(undefined);\n setQueryLoading(true);\n retryCount.current = 0;\n\n if (!relationalDb.db) {\n return;\n }\n\n // Use the processor helper to obtain a typed namespaced query builder\n const db = ProcessorClass.query(driveId, relationalDb.db);\n\n const compiledQuery = queryCallback(db, parameters);\n const { sql, parameters: queryParameters } = compiledQuery;\n\n const liveQueryPromise = executeLiveQuery(sql, queryParameters);\n\n return () => {\n if (retryTimeoutRef.current) {\n clearTimeout(retryTimeoutRef.current);\n }\n void liveQueryPromise.then((live) => {\n if (live?.unsubscribe) {\n live.unsubscribe();\n }\n });\n };\n }, [relationalDb.db, ProcessorClass, driveId, queryCallback, parameters]);\n\n return {\n isLoading: relationalDb.isLoading || queryLoading,\n error: error || relationalDb.error,\n result,\n } as const;\n}\n","import type { LiveQueryResults } from \"@electric-sql/pglite/live\";\nimport type {\n QueryCallbackReturnType,\n useRelationalQueryOptions,\n} from \"@powerhousedao/reactor-browser\";\nimport type {\n IRelationalQueryBuilder,\n RelationalDbProcessorClass,\n} from \"@powerhousedao/shared/processors\";\nimport type { CompiledQuery } from \"kysely\";\nimport deepEqual from \"lodash.isequal\";\nimport { useCallback, useMemo, useRef } from \"react\";\nimport { useRelationalQuery } from \"../hooks/useRelationalQuery.js\";\n\n// Custom hook for parameter memoization\nfunction useStableParams<T>(params: T): T {\n const prevParamsRef = useRef<T>(null);\n\n return useMemo(() => {\n if (!deepEqual(prevParamsRef.current, params)) {\n prevParamsRef.current = params;\n }\n return prevParamsRef.current as T;\n }, [params]);\n}\n\nexport function createProcessorQuery<TSchema>(\n ProcessorClass: RelationalDbProcessorClass<TSchema>,\n) {\n // Overload for queries without parameters\n function useQuery<\n TQueryBuilder extends (\n db: IRelationalQueryBuilder<TSchema>,\n ) => QueryCallbackReturnType,\n >(\n driveId: string,\n queryCallback: TQueryBuilder,\n ): {\n isLoading: boolean;\n error: Error | null;\n result: LiveQueryResults<\n ReturnType<TQueryBuilder> extends CompiledQuery<infer R> ? R : any\n > | null;\n };\n\n // Overload for queries with parameters\n function useQuery<\n TParams,\n TQueryBuilder extends (\n db: IRelationalQueryBuilder<TSchema>,\n parameters: TParams,\n ) => QueryCallbackReturnType,\n >(\n driveId: string,\n queryCallback: TQueryBuilder,\n parameters: TParams,\n options?: useRelationalQueryOptions,\n ): {\n isLoading: boolean;\n error: Error | null;\n result: LiveQueryResults<\n ReturnType<TQueryBuilder> extends CompiledQuery<infer R> ? R : any\n > | null;\n };\n\n function useQuery<\n TParams,\n TQueryBuilder extends (\n db: IRelationalQueryBuilder<TSchema>,\n parameters?: TParams,\n ) => QueryCallbackReturnType,\n >(\n driveId: string,\n queryCallback: TQueryBuilder,\n parameters?: TParams,\n options?: useRelationalQueryOptions,\n ): {\n isLoading: boolean;\n error: Error | null;\n result: LiveQueryResults<\n ReturnType<TQueryBuilder> extends CompiledQuery<infer R> ? R : any\n > | null;\n } {\n type InferredResult =\n ReturnType<TQueryBuilder> extends CompiledQuery<infer R> ? R : any;\n\n // Automatically memoize parameters using deep comparison\n const stableParams = useStableParams(parameters);\n\n // Memoize the callback to prevent infinite loops, updating when parameters change\n const memoizedCallback = useCallback(queryCallback, [stableParams]);\n\n return useRelationalQuery<TSchema, InferredResult, TParams>(\n ProcessorClass,\n driveId,\n memoizedCallback,\n stableParams,\n options,\n ) as {\n isLoading: boolean;\n error: Error | null;\n result: LiveQueryResults<InferredResult> | null;\n };\n }\n\n return useQuery;\n}\n"],"mappings":";;;;;;AAGA,MAAa,sBAAsB;AAQnC,MAAM,qBAAkC;CACtC,IAAI;CACJ,WAAW;CACX,OAAO;AACT;AAEA,MAAa,oBAAoB;CAC/B,MAAM,CAAC,OAAO,YAAY,eAClB,OAAO,YAAY,UAAU,kBAC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AO,SAAS,aAAa;EAC7B;CACF;AACF;;;AChHA,SAAS,gBAAmB,QAAc;CACxC,MAAM,gBAAgB,OAAU,IAAI;CAEpC,OAAO,cAAc;EACnB,IAAI,CAAC,UAAU,cAAc,SAAS,MAAM,GAC1C,cAAc,UAAU;EAE1B,OAAO,cAAc;CACvB,GAAG,CAAC,MAAM,CAAC;AACb;AAEA,SAAgB,qBACd,gBACA;CAqCA,SAAS,SAOP,SACA,eACA,YACA,SAOA;EAKA,MAAM,eAAe,gBAAgB,UAAU;EAK/C,OAAO,mBACL,gBACA,SAJuB,YAAY,eAAe,CAAC,YAAY,CAK/D,GACA,cACA,OACF;CAKF;CAEA,OAAO;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as useRenown, c as RENOWN_INITIAL_UNKNOWN, i as useLoginStatus, l as RenownInitialUserProvider, n as setRenown, o as useUser, s as RENOWN_INITIAL_ANONYMOUS, t as addRenownEventHandler, u as useRenownInitialAuth } from "./renown-
|
|
1
|
+
import { a as useRenown, c as RENOWN_INITIAL_UNKNOWN, i as useLoginStatus, l as RenownInitialUserProvider, n as setRenown, o as useUser, s as RENOWN_INITIAL_ANONYMOUS, t as addRenownEventHandler, u as useRenownInitialAuth } from "./renown-Def5iO8k.js";
|
|
2
2
|
import { logger } from "document-model";
|
|
3
3
|
import { Children, cloneElement, createContext, forwardRef, isValidElement, useCallback, useContext, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
4
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -605,7 +605,6 @@ function RenownLoginButton({ onLogin: onLoginProp, style, className, asChild = f
|
|
|
605
605
|
//#endregion
|
|
606
606
|
//#region src/renown/components/RenownUserButton.tsx
|
|
607
607
|
const POPOVER_GAP = 4;
|
|
608
|
-
const POPOVER_HEIGHT = 150;
|
|
609
608
|
const styles = {
|
|
610
609
|
wrapper: {
|
|
611
610
|
position: "relative",
|
|
@@ -773,7 +772,7 @@ function RenownUserButton({ address: addressProp, username: usernameProp, avatar
|
|
|
773
772
|
const calculatePosition = useCallback(() => {
|
|
774
773
|
if (!wrapperRef.current) return;
|
|
775
774
|
const spaceAbove = wrapperRef.current.getBoundingClientRect().top;
|
|
776
|
-
setShowAbove(spaceAbove >=
|
|
775
|
+
setShowAbove(spaceAbove >= 154);
|
|
777
776
|
}, []);
|
|
778
777
|
const handleMouseEnter = useCallback(() => {
|
|
779
778
|
setIsHovered(true);
|
|
@@ -1021,7 +1020,7 @@ async function initRenownCrypto() {
|
|
|
1021
1020
|
//#endregion
|
|
1022
1021
|
//#region src/renown/use-renown-session.ts
|
|
1023
1022
|
const DEFAULT_ENDPOINT = "/api/renown/session";
|
|
1024
|
-
const DEFAULT_EXPIRES_IN =
|
|
1023
|
+
const DEFAULT_EXPIRES_IN = 604800;
|
|
1025
1024
|
function useRenownSessionCookie(options = {}) {
|
|
1026
1025
|
const endpoint = options.endpoint ?? DEFAULT_ENDPOINT;
|
|
1027
1026
|
const expiresIn = options.expiresIn ?? DEFAULT_EXPIRES_IN;
|
|
@@ -1230,7 +1229,6 @@ function AdapterControllerBridge(props) {
|
|
|
1230
1229
|
function RenownWalletProvider({ adapters: adaptersConfig, theme, children }) {
|
|
1231
1230
|
const [descriptors] = useState(() => adaptersConfig);
|
|
1232
1231
|
useEffect(() => {
|
|
1233
|
-
if (typeof process !== "undefined" && true) return;
|
|
1234
1232
|
if (adaptersConfig === descriptors) return;
|
|
1235
1233
|
console.error("RenownWalletProvider: the `adapters` array changed identity after mount, and the new value was ignored. Build it once at module scope (or memoize it) — see the @powerhousedao/reactor-browser README.");
|
|
1236
1234
|
}, [adaptersConfig, descriptors]);
|
|
@@ -1277,7 +1275,7 @@ function RenownWalletProvider({ adapters: adaptersConfig, theme, children }) {
|
|
|
1277
1275
|
setWalletAdapterController(meta.id, controller);
|
|
1278
1276
|
setActiveWalletController(mergeControllers(Array.from(mountedRef.current.values())));
|
|
1279
1277
|
}, []);
|
|
1280
|
-
|
|
1278
|
+
const walletTree = descriptors && active && adapters && adapters.length > 0 ? adapters.reduceRight((acc, adapter) => {
|
|
1281
1279
|
const Provider = adapter.Provider;
|
|
1282
1280
|
return /* @__PURE__ */ jsx(Provider, {
|
|
1283
1281
|
theme,
|
|
@@ -1287,7 +1285,8 @@ function RenownWalletProvider({ adapters: adaptersConfig, theme, children }) {
|
|
|
1287
1285
|
adapter,
|
|
1288
1286
|
onController,
|
|
1289
1287
|
onSession
|
|
1290
|
-
}, adapter.meta.id)) })) : null
|
|
1288
|
+
}, adapter.meta.id)) })) : null;
|
|
1289
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [children, walletTree] });
|
|
1291
1290
|
}
|
|
1292
1291
|
//#endregion
|
|
1293
1292
|
//#region src/renown/provider.tsx
|
|
@@ -1391,4 +1390,4 @@ function useRenownWalletAdapter(id) {
|
|
|
1391
1390
|
//#endregion
|
|
1392
1391
|
export { RENOWN_CHAIN_ID as A, logout as C, CREDENTIAL_TYPES as D, CREDENTIAL_SUBJECT_TYPE as E, RENOWN_RETURN_URL_STRIPPED_PARAMS as M, RENOWN_URL as N, DOMAIN_TYPE as O, VERIFIABLE_CREDENTIAL_EIP712_TYPE as P, login as S, CREDENTIAL_SCHEMA_EIP712_TYPE as T, RenownLogo as _, Renown as a, useRenownAuth as b, useRenownSessionSynced as c, RenownAuthButton as d, RenownUserButton as f, DisconnectIcon as g, CopyIcon as h, RenownWalletProvider as i, RENOWN_NETWORK_ID as j, ISSUER_TYPE as k, initConnectCrypto as l, ChevronDownIcon as m, useRenownLoginMethods as n, useRenownInit as o, RenownLoginButton as p, RenownProvider as r, useRenownSessionCookie as s, useRenownWalletAdapter as t, initRenownCrypto as u, SpinnerIcon as v, openRenown as w, useRenownAuthAsync as x, UserIcon as y };
|
|
1393
1392
|
|
|
1394
|
-
//# sourceMappingURL=renown-
|
|
1393
|
+
//# sourceMappingURL=renown-C9pYZRqf.js.map
|