@powerhousedao/reactor-browser 6.2.3-dev.8 → 6.2.3-dev.81
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-D3EhiAJ7.d.ts → attachment-service-DPWkKp3y.d.ts} +636 -83
- package/dist/attachment-service-DPWkKp3y.d.ts.map +1 -0
- package/dist/{client-DjK30EQ-.js → client-BFnMV-EO.js} +39 -22
- package/dist/client-BFnMV-EO.js.map +1 -0
- package/dist/{client-D66jVnot.js → client-BUpynoY6.js} +345 -33
- package/dist/client-BUpynoY6.js.map +1 -0
- package/dist/{client-BIHN_UyR.d.ts → client-XPGQrO4a.d.ts} +3 -3
- package/dist/client-XPGQrO4a.d.ts.map +1 -0
- package/dist/dispatch-C8J9jQ-o.js +1171 -0
- package/dist/dispatch-C8J9jQ-o.js.map +1 -0
- package/dist/document-by-id-Dpp76ZNE.js +16 -0
- package/dist/document-by-id-Dpp76ZNE.js.map +1 -0
- package/dist/document-model-modules-XrYfGXt8.js +644 -0
- package/dist/document-model-modules-XrYfGXt8.js.map +1 -0
- package/dist/{document-operations-WeE6wIDt.js → document-operations-CdfiLNQN.js} +1919 -278
- package/dist/document-operations-CdfiLNQN.js.map +1 -0
- package/dist/global-BSyOOTvL.d.ts +647 -0
- package/dist/global-BSyOOTvL.d.ts.map +1 -0
- package/dist/{index-B33TKEqp.d.ts → index-Bjm0bSzf.d.ts} +19 -98
- package/dist/index-Bjm0bSzf.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 +813 -410
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +771 -119
- package/dist/index.js.map +1 -1
- package/dist/inspector-proxy-DODqs15F.d.ts +25 -0
- package/dist/inspector-proxy-DODqs15F.d.ts.map +1 -0
- package/dist/make-ph-event-functions-B5GU5xcR.js +180 -0
- package/dist/make-ph-event-functions-B5GU5xcR.js.map +1 -0
- package/dist/navigation-BqphkrOB.js +302 -0
- package/dist/navigation-BqphkrOB.js.map +1 -0
- 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-DZuyKp2y.js} +66 -5
- package/dist/relational-DZuyKp2y.js.map +1 -0
- package/dist/{renown-rqK8sokh.js → renown-BtjgHBjH.js} +33 -28
- package/dist/{renown-rqK8sokh.js.map → renown-BtjgHBjH.js.map} +1 -1
- package/dist/{renown-BHxwP7xU.js → renown-BxkZYzbQ.js} +2 -2
- package/dist/{renown-BHxwP7xU.js.map → renown-BxkZYzbQ.js.map} +1 -1
- package/dist/src/ai/index.d.ts +53 -70
- package/dist/src/ai/index.d.ts.map +1 -1
- package/dist/src/ai/index.js +12 -28
- 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 +4 -4
- 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 +4 -4
- package/dist/src/relational/index.d.ts +15 -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 +214 -140
- package/dist/src/rpc/index.d.ts.map +1 -1
- package/dist/src/rpc/index.js +587 -622
- 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-CaXQ4-5Q.js → switchboard-CYTCYt4Z.js} +61 -11
- package/dist/switchboard-CYTCYt4Z.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-Dcv1ZLoW.d.ts → types-BNVqRNli.d.ts} +320 -18
- package/dist/types-BNVqRNli.d.ts.map +1 -0
- package/package.json +23 -23
- package/dist/attachment-service-D3EhiAJ7.d.ts.map +0 -1
- package/dist/client-BIHN_UyR.d.ts.map +0 -1
- package/dist/client-D66jVnot.js.map +0 -1
- package/dist/client-DjK30EQ-.js.map +0 -1
- package/dist/document-by-id-B4FIzG1w.js +0 -519
- package/dist/document-by-id-B4FIzG1w.js.map +0 -1
- package/dist/document-model-modules-bTP87nyr.js +0 -419
- package/dist/document-model-modules-bTP87nyr.js.map +0 -1
- package/dist/document-operations-WeE6wIDt.js.map +0 -1
- package/dist/global-OuINvEGT.d.ts +0 -401
- package/dist/global-OuINvEGT.d.ts.map +0 -1
- package/dist/index-B33TKEqp.d.ts.map +0 -1
- package/dist/index-BIVDXw3K.d.ts.map +0 -1
- package/dist/inspector-proxy-6h5VKAwt.d.ts +0 -257
- package/dist/inspector-proxy-6h5VKAwt.d.ts.map +0 -1
- package/dist/make-ph-event-functions-DBq3iWYn.js +0 -53
- package/dist/make-ph-event-functions-DBq3iWYn.js.map +0 -1
- package/dist/pglite-CntadC_p-9NDG14dS.d.ts.map +0 -1
- package/dist/relational-D1RB45sA.js.map +0 -1
- package/dist/switchboard-CaXQ4-5Q.js.map +0 -1
- package/dist/types-6vDzbRRS.d.ts.map +0 -1
- package/dist/types-Dcv1ZLoW.d.ts.map +0 -1
|
@@ -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;;UA6CM;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;cAqGU,yBAAyB,gBAAgB;WAC1C;WACA;EACT,YAAY,gBAAgB;WACnB;EACT;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;KAwDC,QAAQ,WAAW;EACpB;EACA,KAAK,eAAe;;KAEnB,YAAY;EACb;IACI,OAAO,WAAW;IAClB,QAAQ,WAAW;IACnB,OAAO;;EAEX;;UAEM,oBAAoB,KAAK;EAC/B,SAAS;KACJ,KAAK;;EAEV,QAAQ;KACH,KAAK;;EAEV,SAAS;KACJ,KAAK;;EAEV,IAAI;EACJ;EACA;EACA;EACA,eAAe,eAAe,QAAQ;EACtC;EACA;EACA;EACA,qBAAqB;EACrB,mBAAmB,gBAAgB;EACnC,sBAAsB,iBAAiB;EACvC,cAAc,KAAK,UAAU,yBAAyB;EACtD,iBAAiB;;KAWhB;;;;;;UAUK;;;;EAIN,KAAK,IAAI,QAAQ,mBAAmB,QAAQ,eAAe;IACvD,gBAAgB,QAAQ;;;;;EAK5B,SAAS,8BAA8B;;;;EAIvC,iBAAiB;;;;EAIjB,QAAQ,gBAAgB,cAAc,4BAA4B,QAAQ,OAAO;;;;EAIjF,W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BAAiB,YAAY,0BAA0B,KAAK,cAAc;;;;;EAKnF,eAAe,WAAW,iBAAiB;;;;;EAK3C,gBAAgB,WAAW,iBAAiB;;;;;;EAM5C,YAAY,cAAc,4BAA4B,QAAQ,OAAO;;;;;;EAMrE,mBAAmB,GAAG,UAAU,QAAQ,KAAK,QAAQ;;;;;;EAMrD,yBAAyB,GAAG,UAAU,QAAQ,KAAK,QAAQ;EAC3D,SAAS,QAAQ;EACjB,oBAAoB,GAAG,UAAU,QAAQ,KAAK,QAAQ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createRelationalDb } from "@powerhousedao/reactor";
|
|
2
1
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { HardenedPGliteDialect, createRelationalDb } from "@powerhousedao/reactor";
|
|
3
3
|
import { Kysely } from "kysely";
|
|
4
4
|
import { PGliteDialect } from "kysely-pglite-dialect";
|
|
5
5
|
import deepEqual from "lodash.isequal";
|
|
@@ -32,15 +32,71 @@ function setPGliteDB(pglite) {
|
|
|
32
32
|
window.dispatchEvent(new CustomEvent(PGLITE_UPDATE_EVENT));
|
|
33
33
|
}
|
|
34
34
|
//#endregion
|
|
35
|
+
//#region src/relational/utils/relational-dialect.ts
|
|
36
|
+
/** A query-only proxy (Connect's worker RPC) has no session here to harden; its worker does that. */
|
|
37
|
+
function relationalDialect(instance, options = {}) {
|
|
38
|
+
const session = instance;
|
|
39
|
+
if (typeof session.exec === "function" && typeof session.isInTransaction === "function") return new HardenedPGliteDialect(session, options);
|
|
40
|
+
return new PGliteDialect(instance);
|
|
41
|
+
}
|
|
42
|
+
const sharedByInstance = /* @__PURE__ */ new WeakMap();
|
|
43
|
+
function sharedFor(instance, options = {}) {
|
|
44
|
+
let shared = sharedByInstance.get(instance);
|
|
45
|
+
if (shared === void 0) {
|
|
46
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
47
|
+
const created = {
|
|
48
|
+
listeners,
|
|
49
|
+
kysely: new Kysely({ dialect: relationalDialect(instance, {
|
|
50
|
+
...options,
|
|
51
|
+
onPoisoned: (cause) => {
|
|
52
|
+
created.poisoned = cause;
|
|
53
|
+
for (const listener of [...listeners]) try {
|
|
54
|
+
listener(cause);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.error("relational onPoisoned listener threw", error);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}) })
|
|
60
|
+
};
|
|
61
|
+
shared = created;
|
|
62
|
+
sharedByInstance.set(instance, shared);
|
|
63
|
+
}
|
|
64
|
+
return shared;
|
|
65
|
+
}
|
|
66
|
+
/** One Kysely, so one queue, per PGlite; `options` apply from the first caller, which creates it. */
|
|
67
|
+
function relationalKysely(instance, options = {}) {
|
|
68
|
+
return sharedFor(instance, options).kysely;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Tells `listener` once the shared session of `instance` is poisoned, however
|
|
72
|
+
* many consumers share it and whichever opened it first; a late subscriber is
|
|
73
|
+
* told at once. Returns the unsubscribe.
|
|
74
|
+
*/
|
|
75
|
+
function subscribeRelationalPoisoned(instance, listener) {
|
|
76
|
+
const shared = sharedFor(instance);
|
|
77
|
+
if (shared.poisoned !== void 0) {
|
|
78
|
+
listener(shared.poisoned);
|
|
79
|
+
return () => void 0;
|
|
80
|
+
}
|
|
81
|
+
shared.listeners.add(listener);
|
|
82
|
+
return () => {
|
|
83
|
+
shared.listeners.delete(listener);
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
35
87
|
//#region src/relational/hooks/useRelationalDb.ts
|
|
36
88
|
function createRelationalDbWithLive(pgliteInstance) {
|
|
37
|
-
const
|
|
89
|
+
const baseDb = relationalKysely(pgliteInstance);
|
|
90
|
+
const relationalDBWithLive = createRelationalDb(baseDb);
|
|
38
91
|
relationalDBWithLive.live = pgliteInstance.live;
|
|
39
92
|
return relationalDBWithLive;
|
|
40
93
|
}
|
|
41
|
-
const useRelationalDb = () => {
|
|
94
|
+
const useRelationalDb = (options = {}) => {
|
|
42
95
|
const pglite = usePGliteDB();
|
|
43
|
-
|
|
96
|
+
const onPoisoned = useRef(options.onPoisoned);
|
|
97
|
+
onPoisoned.current = options.onPoisoned;
|
|
98
|
+
const wantsPoisoned = options.onPoisoned !== void 0;
|
|
99
|
+
const relationalDb = useMemo(() => {
|
|
44
100
|
if (!pglite.db || pglite.isLoading || pglite.error) return {
|
|
45
101
|
db: null,
|
|
46
102
|
isLoading: pglite.isLoading,
|
|
@@ -52,6 +108,11 @@ const useRelationalDb = () => {
|
|
|
52
108
|
error: null
|
|
53
109
|
};
|
|
54
110
|
}, [pglite]);
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
if (!pglite.db || !wantsPoisoned) return;
|
|
113
|
+
return subscribeRelationalPoisoned(pglite.db, (cause) => onPoisoned.current?.(cause));
|
|
114
|
+
}, [pglite.db, wantsPoisoned]);
|
|
115
|
+
return relationalDb;
|
|
55
116
|
};
|
|
56
117
|
//#endregion
|
|
57
118
|
//#region src/relational/hooks/useRelationalQuery.ts
|
|
@@ -132,4 +193,4 @@ function createProcessorQuery(ProcessorClass) {
|
|
|
132
193
|
//#endregion
|
|
133
194
|
export { setPGliteDB as i, useRelationalQuery as n, useRelationalDb as r, createProcessorQuery as t };
|
|
134
195
|
|
|
135
|
-
//# sourceMappingURL=relational-
|
|
196
|
+
//# sourceMappingURL=relational-DZuyKp2y.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relational-DZuyKp2y.js","names":[],"sources":["../src/pglite/usePGlite.ts","../src/relational/utils/relational-dialect.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 {\n HardenedPGliteDialect,\n type HardenedPGliteDialectOptions,\n type PGliteSession,\n} from \"@powerhousedao/reactor\";\nimport { Kysely, type Dialect } from \"kysely\";\nimport { PGliteDialect } from \"kysely-pglite-dialect\";\n\n/** A query-only proxy (Connect's worker RPC) has no session here to harden; its worker does that. */\nexport function relationalDialect(\n instance: unknown,\n options: Partial<HardenedPGliteDialectOptions> = {},\n): Dialect {\n const session = instance as Partial<PGliteSession>;\n if (\n typeof session.exec === \"function\" &&\n typeof session.isInTransaction === \"function\"\n ) {\n return new HardenedPGliteDialect(session as PGliteSession, options);\n }\n return new PGliteDialect(instance as PGlite);\n}\n\ntype PoisonListener = (cause: Error) => void;\n\ntype SharedRelationalDb = {\n kysely: Kysely<unknown>;\n listeners: Set<PoisonListener>;\n poisoned?: Error;\n};\n\nconst sharedByInstance = new WeakMap<object, SharedRelationalDb>();\n\nfunction sharedFor(\n instance: object,\n options: Partial<Omit<HardenedPGliteDialectOptions, \"onPoisoned\">> = {},\n): SharedRelationalDb {\n let shared = sharedByInstance.get(instance);\n if (shared === undefined) {\n const listeners = new Set<PoisonListener>();\n const created: SharedRelationalDb = {\n listeners,\n kysely: new Kysely<unknown>({\n dialect: relationalDialect(instance, {\n ...options,\n onPoisoned: (cause) => {\n created.poisoned = cause;\n for (const listener of [...listeners]) {\n try {\n listener(cause);\n } catch (error) {\n console.error(\"relational onPoisoned listener threw\", error);\n }\n }\n },\n }),\n }),\n };\n shared = created;\n sharedByInstance.set(instance, shared);\n }\n return shared;\n}\n\n/** One Kysely, so one queue, per PGlite; `options` apply from the first caller, which creates it. */\nexport function relationalKysely<Schema>(\n instance: object,\n options: Partial<Omit<HardenedPGliteDialectOptions, \"onPoisoned\">> = {},\n): Kysely<Schema> {\n return sharedFor(instance, options).kysely as Kysely<Schema>;\n}\n\n/**\n * Tells `listener` once the shared session of `instance` is poisoned, however\n * many consumers share it and whichever opened it first; a late subscriber is\n * told at once. Returns the unsubscribe.\n */\nexport function subscribeRelationalPoisoned(\n instance: object,\n listener: PoisonListener,\n): () => void {\n const shared = sharedFor(instance);\n if (shared.poisoned !== undefined) {\n listener(shared.poisoned);\n return () => undefined;\n }\n shared.listeners.add(listener);\n return () => {\n shared.listeners.delete(listener);\n };\n}\n","import type { LiveNamespace, PGliteWithLive } from \"@electric-sql/pglite/live\";\nimport { createRelationalDb } from \"@powerhousedao/reactor\";\nimport type { IRelationalDb as IRelationalDbCore } from \"@powerhousedao/shared/processors\";\nimport { useEffect, useMemo, useRef } from \"react\";\nimport { usePGliteDB } from \"../../pglite/usePGlite.js\";\nimport {\n relationalKysely,\n subscribeRelationalPoisoned,\n} from \"../utils/relational-dialect.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 = relationalKysely<Schema>(pgliteInstance);\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 type RelationalDbOptions = {\n /**\n * Called once if the shared PGlite session becomes unusable; every hook that\n * passes one is told, and it unsubscribes on unmount. Recovery is the caller's.\n */\n onPoisoned?: (cause: Error) => void;\n};\n\nexport const useRelationalDb = <Schema>(\n options: RelationalDbOptions = {},\n): IRelationalDbState<Schema> => {\n const pglite = usePGliteDB();\n const onPoisoned = useRef(options.onPoisoned);\n onPoisoned.current = options.onPoisoned;\n const wantsPoisoned = options.onPoisoned !== undefined;\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 useEffect(() => {\n if (!pglite.db || !wantsPoisoned) return;\n return subscribeRelationalPoisoned(pglite.db, (cause) =>\n onPoisoned.current?.(cause),\n );\n }, [pglite.db, wantsPoisoned]);\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,kBACrC;CAEA,gBAAgB;EACd,MAAM,2BACJ,SAAS,OAAO,YAAY,UAAU,kBAAkB;EAE1D,OAAO,iBAAiB,qBAAqB,kBAAkB;EAE/D,aACE,OAAO,oBAAoB,qBAAqB,kBAAkB;CACtE,GAAG,CAAC,CAAC;CAEL,OAAO;AACT;AAEA,SAAgB,YAAY,QAAoC;C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,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,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { c as getPHStore } from "./make-ph-event-functions-B5GU5xcR.js";
|
|
2
|
+
import { C as setSearchParams, l as getPHNavigation } from "./navigation-BqphkrOB.js";
|
|
3
|
+
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-BxkZYzbQ.js";
|
|
3
4
|
import { Children, cloneElement, createContext, forwardRef, isValidElement, useCallback, useContext, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
4
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { logger } from "document-model";
|
|
5
7
|
import { BrowserKeyStorage, CREDENTIAL_SCHEMA_EIP712_TYPE, CREDENTIAL_SUBJECT_TYPE, CREDENTIAL_TYPES, DOMAIN_TYPE, ISSUER_TYPE, MissingSwitchboardError, RenownBuilder, RenownCryptoBuilder, VERIFIABLE_CREDENTIAL_EIP712_TYPE, readPersistedUser } from "@renown/sdk";
|
|
6
8
|
import { LoginMethod, isWalletRedirectReturn, resolveAdapters } from "@renown/sdk/wallet";
|
|
7
9
|
//#region src/renown/wallet-registry.ts
|
|
@@ -114,7 +116,7 @@ const RENOWN_RETURN_URL_STRIPPED_PARAMS = [
|
|
|
114
116
|
//#endregion
|
|
115
117
|
//#region src/renown/session.ts
|
|
116
118
|
function openRenown(documentId) {
|
|
117
|
-
const renown =
|
|
119
|
+
const renown = getPHStore()?.renown;
|
|
118
120
|
let renownUrl = renown?.baseUrl;
|
|
119
121
|
if (!renownUrl) {
|
|
120
122
|
logger.warn("Renown instance not found, falling back to: @url", RENOWN_URL);
|
|
@@ -135,7 +137,7 @@ function openRenown(documentId) {
|
|
|
135
137
|
window.open(url, "_self")?.focus();
|
|
136
138
|
}
|
|
137
139
|
async function signIn(session) {
|
|
138
|
-
const renown =
|
|
140
|
+
const renown = getPHStore()?.renown;
|
|
139
141
|
if (!renown) {
|
|
140
142
|
logger.warn("Renown instance not found, cannot sign in");
|
|
141
143
|
return;
|
|
@@ -150,7 +152,7 @@ let inFlightSignIn;
|
|
|
150
152
|
let inFlightAddress;
|
|
151
153
|
let lastSignedAddress;
|
|
152
154
|
function notifyReactorClientCredentialsChanged() {
|
|
153
|
-
(
|
|
155
|
+
(getPHStore()?.reactorClient)?.notifyCredentialsChanged?.();
|
|
154
156
|
}
|
|
155
157
|
async function completeSignIn(session) {
|
|
156
158
|
const { address } = session;
|
|
@@ -179,21 +181,27 @@ function resetSignInGuard() {
|
|
|
179
181
|
}
|
|
180
182
|
function hasRedirectSignIn() {
|
|
181
183
|
if (typeof window === "undefined") return false;
|
|
182
|
-
return new URLSearchParams(
|
|
184
|
+
return new URLSearchParams(getPHNavigation().location().search).has("user");
|
|
183
185
|
}
|
|
184
|
-
function
|
|
186
|
+
function readDidFromUrl() {
|
|
185
187
|
if (typeof window === "undefined") return;
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
188
|
+
const { search } = getPHNavigation().location();
|
|
189
|
+
const userParam = new URLSearchParams(search).get("user");
|
|
190
|
+
return userParam ? decodeURIComponent(userParam) : void 0;
|
|
191
|
+
}
|
|
192
|
+
function clearUserParamFromUrl() {
|
|
193
|
+
if (typeof window === "undefined") return;
|
|
194
|
+
const { search } = getPHNavigation().location();
|
|
195
|
+
if (!new URLSearchParams(search).has("user")) return;
|
|
196
|
+
setSearchParams((prev) => ({
|
|
197
|
+
...prev,
|
|
198
|
+
user: void 0
|
|
199
|
+
}), { replace: true });
|
|
193
200
|
}
|
|
194
201
|
async function login(userDid, renown) {
|
|
195
202
|
if (!renown) return;
|
|
196
|
-
const
|
|
203
|
+
const urlDid = readDidFromUrl();
|
|
204
|
+
const did = userDid ?? urlDid;
|
|
197
205
|
try {
|
|
198
206
|
const user = renown.user;
|
|
199
207
|
if (user?.did && (user.did === did || !did)) return user;
|
|
@@ -203,6 +211,8 @@ async function login(userDid, renown) {
|
|
|
203
211
|
return loggedIn;
|
|
204
212
|
} catch (error) {
|
|
205
213
|
logger.error(error instanceof Error ? error.message : JSON.stringify(error));
|
|
214
|
+
} finally {
|
|
215
|
+
if (urlDid) clearUserParamFromUrl();
|
|
206
216
|
}
|
|
207
217
|
}
|
|
208
218
|
async function logout() {
|
|
@@ -211,14 +221,10 @@ async function logout() {
|
|
|
211
221
|
} catch (error) {
|
|
212
222
|
logger.error(error instanceof Error ? error.message : String(error));
|
|
213
223
|
}
|
|
214
|
-
await (
|
|
224
|
+
await (getPHStore()?.renown)?.logout();
|
|
215
225
|
resetSignInGuard();
|
|
216
226
|
notifyReactorClientCredentialsChanged();
|
|
217
|
-
|
|
218
|
-
if (url.searchParams.has("user")) {
|
|
219
|
-
url.searchParams.delete("user");
|
|
220
|
-
window.history.replaceState(null, "", url.toString());
|
|
221
|
-
}
|
|
227
|
+
clearUserParamFromUrl();
|
|
222
228
|
}
|
|
223
229
|
//#endregion
|
|
224
230
|
//#region src/renown/use-renown-auth.ts
|
|
@@ -605,7 +611,6 @@ function RenownLoginButton({ onLogin: onLoginProp, style, className, asChild = f
|
|
|
605
611
|
//#endregion
|
|
606
612
|
//#region src/renown/components/RenownUserButton.tsx
|
|
607
613
|
const POPOVER_GAP = 4;
|
|
608
|
-
const POPOVER_HEIGHT = 150;
|
|
609
614
|
const styles = {
|
|
610
615
|
wrapper: {
|
|
611
616
|
position: "relative",
|
|
@@ -773,7 +778,7 @@ function RenownUserButton({ address: addressProp, username: usernameProp, avatar
|
|
|
773
778
|
const calculatePosition = useCallback(() => {
|
|
774
779
|
if (!wrapperRef.current) return;
|
|
775
780
|
const spaceAbove = wrapperRef.current.getBoundingClientRect().top;
|
|
776
|
-
setShowAbove(spaceAbove >=
|
|
781
|
+
setShowAbove(spaceAbove >= 154);
|
|
777
782
|
}, []);
|
|
778
783
|
const handleMouseEnter = useCallback(() => {
|
|
779
784
|
setIsHovered(true);
|
|
@@ -1021,7 +1026,7 @@ async function initRenownCrypto() {
|
|
|
1021
1026
|
//#endregion
|
|
1022
1027
|
//#region src/renown/use-renown-session.ts
|
|
1023
1028
|
const DEFAULT_ENDPOINT = "/api/renown/session";
|
|
1024
|
-
const DEFAULT_EXPIRES_IN =
|
|
1029
|
+
const DEFAULT_EXPIRES_IN = 604800;
|
|
1025
1030
|
function useRenownSessionCookie(options = {}) {
|
|
1026
1031
|
const endpoint = options.endpoint ?? DEFAULT_ENDPOINT;
|
|
1027
1032
|
const expiresIn = options.expiresIn ?? DEFAULT_EXPIRES_IN;
|
|
@@ -1230,7 +1235,6 @@ function AdapterControllerBridge(props) {
|
|
|
1230
1235
|
function RenownWalletProvider({ adapters: adaptersConfig, theme, children }) {
|
|
1231
1236
|
const [descriptors] = useState(() => adaptersConfig);
|
|
1232
1237
|
useEffect(() => {
|
|
1233
|
-
if (typeof process !== "undefined" && true) return;
|
|
1234
1238
|
if (adaptersConfig === descriptors) return;
|
|
1235
1239
|
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
1240
|
}, [adaptersConfig, descriptors]);
|
|
@@ -1277,7 +1281,7 @@ function RenownWalletProvider({ adapters: adaptersConfig, theme, children }) {
|
|
|
1277
1281
|
setWalletAdapterController(meta.id, controller);
|
|
1278
1282
|
setActiveWalletController(mergeControllers(Array.from(mountedRef.current.values())));
|
|
1279
1283
|
}, []);
|
|
1280
|
-
|
|
1284
|
+
const walletTree = descriptors && active && adapters && adapters.length > 0 ? adapters.reduceRight((acc, adapter) => {
|
|
1281
1285
|
const Provider = adapter.Provider;
|
|
1282
1286
|
return /* @__PURE__ */ jsx(Provider, {
|
|
1283
1287
|
theme,
|
|
@@ -1287,7 +1291,8 @@ function RenownWalletProvider({ adapters: adaptersConfig, theme, children }) {
|
|
|
1287
1291
|
adapter,
|
|
1288
1292
|
onController,
|
|
1289
1293
|
onSession
|
|
1290
|
-
}, adapter.meta.id)) })) : null
|
|
1294
|
+
}, adapter.meta.id)) })) : null;
|
|
1295
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [children, walletTree] });
|
|
1291
1296
|
}
|
|
1292
1297
|
//#endregion
|
|
1293
1298
|
//#region src/renown/provider.tsx
|
|
@@ -1391,4 +1396,4 @@ function useRenownWalletAdapter(id) {
|
|
|
1391
1396
|
//#endregion
|
|
1392
1397
|
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
1398
|
|
|
1394
|
-
//# sourceMappingURL=renown-
|
|
1399
|
+
//# sourceMappingURL=renown-BtjgHBjH.js.map
|