@powerhousedao/connect 6.0.0-dev.83 → 6.0.0-dev.88
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/src/components/app.d.ts.map +1 -1
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/modal/modals/settings/package-manager.d.ts.map +1 -1
- package/dist/src/components/package-install-prompt.d.ts +3 -0
- package/dist/src/components/package-install-prompt.d.ts.map +1 -0
- package/dist/src/context/index.js +1269 -836
- package/dist/src/hooks/index.js +1267 -834
- package/dist/src/main.js +1769 -1154
- package/dist/src/pages/index.js +1767 -1152
- package/dist/src/store/index.js +1470 -946
- package/dist/src/store/reactor.d.ts.map +1 -1
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/index.d.ts.map +1 -1
- package/dist/src/utils/index.js +1289 -816
- package/dist/src/utils/reactor.d.ts +2 -2
- package/dist/src/utils/reactor.d.ts.map +1 -1
- package/dist/src/utils/registry-url.d.ts +2 -0
- package/dist/src/utils/registry-url.d.ts.map +1 -0
- package/dist/style.css +9 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -12
package/dist/src/utils/index.js
CHANGED
|
@@ -4499,7 +4499,7 @@ var init_package = __esm(() => {
|
|
|
4499
4499
|
package_default = {
|
|
4500
4500
|
name: "@powerhousedao/connect",
|
|
4501
4501
|
productName: "Powerhouse-Connect",
|
|
4502
|
-
version: "6.0.0-dev.
|
|
4502
|
+
version: "6.0.0-dev.87",
|
|
4503
4503
|
description: "Powerhouse Connect",
|
|
4504
4504
|
main: "dist/index.html",
|
|
4505
4505
|
type: "module",
|
|
@@ -11192,6 +11192,11 @@ class CollectionMembershipCache {
|
|
|
11192
11192
|
constructor(operationIndex) {
|
|
11193
11193
|
this.operationIndex = operationIndex;
|
|
11194
11194
|
}
|
|
11195
|
+
withScopedIndex(operationIndex) {
|
|
11196
|
+
const scoped = new CollectionMembershipCache(operationIndex);
|
|
11197
|
+
scoped.cache = this.cache;
|
|
11198
|
+
return scoped;
|
|
11199
|
+
}
|
|
11195
11200
|
async getCollectionsForDocuments(documentIds) {
|
|
11196
11201
|
const result = {};
|
|
11197
11202
|
const missing = [];
|
|
@@ -11479,6 +11484,12 @@ class DocumentMetaCache {
|
|
|
11479
11484
|
this.cache = new Map;
|
|
11480
11485
|
this.lruTracker = new LRUTracker;
|
|
11481
11486
|
}
|
|
11487
|
+
withScopedStore(operationStore) {
|
|
11488
|
+
const scoped = new DocumentMetaCache(operationStore, this.config);
|
|
11489
|
+
scoped.cache = this.cache;
|
|
11490
|
+
scoped.lruTracker = this.lruTracker;
|
|
11491
|
+
return scoped;
|
|
11492
|
+
}
|
|
11482
11493
|
async startup() {
|
|
11483
11494
|
return Promise.resolve();
|
|
11484
11495
|
}
|
|
@@ -11628,9 +11639,18 @@ class KyselyOperationIndexTxn {
|
|
|
11628
11639
|
|
|
11629
11640
|
class KyselyOperationIndex {
|
|
11630
11641
|
db;
|
|
11642
|
+
trx;
|
|
11631
11643
|
constructor(db) {
|
|
11632
11644
|
this.db = db;
|
|
11633
11645
|
}
|
|
11646
|
+
get queryExecutor() {
|
|
11647
|
+
return this.trx ?? this.db;
|
|
11648
|
+
}
|
|
11649
|
+
withTransaction(trx) {
|
|
11650
|
+
const instance = new KyselyOperationIndex(this.db);
|
|
11651
|
+
instance.trx = trx;
|
|
11652
|
+
return instance;
|
|
11653
|
+
}
|
|
11634
11654
|
start() {
|
|
11635
11655
|
return new KyselyOperationIndexTxn;
|
|
11636
11656
|
}
|
|
@@ -11639,70 +11659,76 @@ class KyselyOperationIndex {
|
|
|
11639
11659
|
throw new Error("Operation aborted");
|
|
11640
11660
|
}
|
|
11641
11661
|
const kyselyTxn = txn;
|
|
11662
|
+
if (this.trx) {
|
|
11663
|
+
return this.executeCommit(this.trx, kyselyTxn);
|
|
11664
|
+
}
|
|
11665
|
+
let resultOrdinals = [];
|
|
11666
|
+
await this.db.transaction().execute(async (trx) => {
|
|
11667
|
+
resultOrdinals = await this.executeCommit(trx, kyselyTxn);
|
|
11668
|
+
});
|
|
11669
|
+
return resultOrdinals;
|
|
11670
|
+
}
|
|
11671
|
+
async executeCommit(trx, kyselyTxn) {
|
|
11642
11672
|
const collections = kyselyTxn.getCollections();
|
|
11643
11673
|
const memberships = kyselyTxn.getCollectionMembershipRecords();
|
|
11644
11674
|
const removals = kyselyTxn.getCollectionRemovals();
|
|
11645
11675
|
const operations = kyselyTxn.getOperations();
|
|
11646
|
-
|
|
11647
|
-
|
|
11648
|
-
|
|
11649
|
-
|
|
11650
|
-
|
|
11651
|
-
|
|
11652
|
-
|
|
11676
|
+
if (collections.length > 0) {
|
|
11677
|
+
const collectionRows = collections.map((collectionId) => ({
|
|
11678
|
+
documentId: collectionId,
|
|
11679
|
+
collectionId,
|
|
11680
|
+
joinedOrdinal: BigInt(0),
|
|
11681
|
+
leftOrdinal: null
|
|
11682
|
+
}));
|
|
11683
|
+
await trx.insertInto("document_collections").values(collectionRows).onConflict((oc) => oc.doNothing()).execute();
|
|
11684
|
+
}
|
|
11685
|
+
let operationOrdinals = [];
|
|
11686
|
+
if (operations.length > 0) {
|
|
11687
|
+
const operationRows = operations.map((op) => ({
|
|
11688
|
+
opId: op.id || "",
|
|
11689
|
+
documentId: op.documentId,
|
|
11690
|
+
documentType: op.documentType,
|
|
11691
|
+
scope: op.scope,
|
|
11692
|
+
branch: op.branch,
|
|
11693
|
+
timestampUtcMs: op.timestampUtcMs,
|
|
11694
|
+
index: op.index,
|
|
11695
|
+
skip: op.skip,
|
|
11696
|
+
hash: op.hash,
|
|
11697
|
+
action: op.action,
|
|
11698
|
+
sourceRemote: op.sourceRemote
|
|
11699
|
+
}));
|
|
11700
|
+
const insertedOps = await trx.insertInto("operation_index_operations").values(operationRows).returning("ordinal").execute();
|
|
11701
|
+
operationOrdinals = insertedOps.map((row) => row.ordinal);
|
|
11702
|
+
}
|
|
11703
|
+
if (memberships.length > 0) {
|
|
11704
|
+
for (const m of memberships) {
|
|
11705
|
+
const ordinal = operationOrdinals[m.operationIndex];
|
|
11706
|
+
await trx.insertInto("document_collections").values({
|
|
11707
|
+
documentId: m.documentId,
|
|
11708
|
+
collectionId: m.collectionId,
|
|
11709
|
+
joinedOrdinal: BigInt(ordinal),
|
|
11653
11710
|
leftOrdinal: null
|
|
11654
|
-
}))
|
|
11655
|
-
|
|
11656
|
-
|
|
11657
|
-
|
|
11658
|
-
if (operations.length > 0) {
|
|
11659
|
-
const operationRows = operations.map((op) => ({
|
|
11660
|
-
opId: op.id || "",
|
|
11661
|
-
documentId: op.documentId,
|
|
11662
|
-
documentType: op.documentType,
|
|
11663
|
-
scope: op.scope,
|
|
11664
|
-
branch: op.branch,
|
|
11665
|
-
timestampUtcMs: op.timestampUtcMs,
|
|
11666
|
-
index: op.index,
|
|
11667
|
-
skip: op.skip,
|
|
11668
|
-
hash: op.hash,
|
|
11669
|
-
action: op.action,
|
|
11670
|
-
sourceRemote: op.sourceRemote
|
|
11671
|
-
}));
|
|
11672
|
-
const insertedOps = await trx.insertInto("operation_index_operations").values(operationRows).returning("ordinal").execute();
|
|
11673
|
-
operationOrdinals = insertedOps.map((row) => row.ordinal);
|
|
11674
|
-
resultOrdinals = operationOrdinals;
|
|
11675
|
-
}
|
|
11676
|
-
if (memberships.length > 0) {
|
|
11677
|
-
for (const m of memberships) {
|
|
11678
|
-
const ordinal = operationOrdinals[m.operationIndex];
|
|
11679
|
-
await trx.insertInto("document_collections").values({
|
|
11680
|
-
documentId: m.documentId,
|
|
11681
|
-
collectionId: m.collectionId,
|
|
11682
|
-
joinedOrdinal: BigInt(ordinal),
|
|
11683
|
-
leftOrdinal: null
|
|
11684
|
-
}).onConflict((oc) => oc.columns(["documentId", "collectionId"]).doUpdateSet({
|
|
11685
|
-
joinedOrdinal: BigInt(ordinal),
|
|
11686
|
-
leftOrdinal: null
|
|
11687
|
-
})).execute();
|
|
11688
|
-
}
|
|
11711
|
+
}).onConflict((oc) => oc.columns(["documentId", "collectionId"]).doUpdateSet({
|
|
11712
|
+
joinedOrdinal: BigInt(ordinal),
|
|
11713
|
+
leftOrdinal: null
|
|
11714
|
+
})).execute();
|
|
11689
11715
|
}
|
|
11690
|
-
|
|
11691
|
-
|
|
11692
|
-
|
|
11693
|
-
|
|
11694
|
-
|
|
11695
|
-
|
|
11696
|
-
}
|
|
11716
|
+
}
|
|
11717
|
+
if (removals.length > 0) {
|
|
11718
|
+
for (const r of removals) {
|
|
11719
|
+
const ordinal = operationOrdinals[r.operationIndex];
|
|
11720
|
+
await trx.updateTable("document_collections").set({
|
|
11721
|
+
leftOrdinal: BigInt(ordinal)
|
|
11722
|
+
}).where("collectionId", "=", r.collectionId).where("documentId", "=", r.documentId).where("leftOrdinal", "is", null).execute();
|
|
11697
11723
|
}
|
|
11698
|
-
}
|
|
11699
|
-
return
|
|
11724
|
+
}
|
|
11725
|
+
return operationOrdinals;
|
|
11700
11726
|
}
|
|
11701
11727
|
async find(collectionId, cursor, view, paging, signal) {
|
|
11702
11728
|
if (signal?.aborted) {
|
|
11703
11729
|
throw new Error("Operation aborted");
|
|
11704
11730
|
}
|
|
11705
|
-
let query = this.
|
|
11731
|
+
let query = this.queryExecutor.selectFrom("operation_index_operations as oi").innerJoin("document_collections as dc", "oi.documentId", "dc.documentId").selectAll("oi").select(["dc.documentId", "dc.collectionId"]).where("dc.collectionId", "=", collectionId).where(sql`(dc."leftOrdinal" IS NULL OR oi.ordinal < dc."leftOrdinal")`).orderBy("oi.ordinal", "asc");
|
|
11706
11732
|
if (cursor !== undefined) {
|
|
11707
11733
|
query = query.where("oi.ordinal", ">", cursor);
|
|
11708
11734
|
}
|
|
@@ -11744,7 +11770,7 @@ class KyselyOperationIndex {
|
|
|
11744
11770
|
if (signal?.aborted) {
|
|
11745
11771
|
throw new Error("Operation aborted");
|
|
11746
11772
|
}
|
|
11747
|
-
let query = this.
|
|
11773
|
+
let query = this.queryExecutor.selectFrom("operation_index_operations").selectAll().where("documentId", "=", documentId).orderBy("ordinal", "asc");
|
|
11748
11774
|
if (view?.branch) {
|
|
11749
11775
|
query = query.where("branch", "=", view.branch);
|
|
11750
11776
|
}
|
|
@@ -11780,7 +11806,7 @@ class KyselyOperationIndex {
|
|
|
11780
11806
|
if (signal?.aborted) {
|
|
11781
11807
|
throw new Error("Operation aborted");
|
|
11782
11808
|
}
|
|
11783
|
-
let query = this.
|
|
11809
|
+
let query = this.queryExecutor.selectFrom("operation_index_operations").selectAll().where("ordinal", ">", ordinal).orderBy("ordinal", "asc");
|
|
11784
11810
|
if (paging?.cursor) {
|
|
11785
11811
|
const cursorOrdinal = Number.parseInt(paging.cursor, 10);
|
|
11786
11812
|
query = query.where("ordinal", ">", cursorOrdinal);
|
|
@@ -11845,14 +11871,14 @@ class KyselyOperationIndex {
|
|
|
11845
11871
|
if (signal?.aborted) {
|
|
11846
11872
|
throw new Error("Operation aborted");
|
|
11847
11873
|
}
|
|
11848
|
-
const result = await this.
|
|
11874
|
+
const result = await this.queryExecutor.selectFrom("operation_index_operations as oi").innerJoin("document_collections as dc", "oi.documentId", "dc.documentId").select("oi.timestampUtcMs").where("dc.collectionId", "=", collectionId).where(sql`(dc."leftOrdinal" IS NULL OR oi.ordinal < dc."leftOrdinal")`).orderBy("oi.ordinal", "desc").limit(1).executeTakeFirst();
|
|
11849
11875
|
return result?.timestampUtcMs ?? null;
|
|
11850
11876
|
}
|
|
11851
11877
|
async getCollectionsForDocuments(documentIds) {
|
|
11852
11878
|
if (documentIds.length === 0) {
|
|
11853
11879
|
return {};
|
|
11854
11880
|
}
|
|
11855
|
-
const rows = await this.
|
|
11881
|
+
const rows = await this.queryExecutor.selectFrom("document_collections").select(["documentId", "collectionId"]).where("documentId", "in", documentIds).where("leftOrdinal", "is", null).execute();
|
|
11856
11882
|
const result = {};
|
|
11857
11883
|
for (const row of rows) {
|
|
11858
11884
|
if (!(row.documentId in result)) {
|
|
@@ -11926,6 +11952,12 @@ class KyselyWriteCache {
|
|
|
11926
11952
|
this.streams = new Map;
|
|
11927
11953
|
this.lruTracker = new LRUTracker;
|
|
11928
11954
|
}
|
|
11955
|
+
withScopedStores(operationStore, keyframeStore) {
|
|
11956
|
+
const scoped = new KyselyWriteCache(keyframeStore, operationStore, this.registry, this.config);
|
|
11957
|
+
scoped.streams = this.streams;
|
|
11958
|
+
scoped.lruTracker = this.lruTracker;
|
|
11959
|
+
return scoped;
|
|
11960
|
+
}
|
|
11929
11961
|
async startup() {
|
|
11930
11962
|
return Promise.resolve();
|
|
11931
11963
|
}
|
|
@@ -12234,6 +12266,63 @@ class EventBus {
|
|
|
12234
12266
|
}
|
|
12235
12267
|
}
|
|
12236
12268
|
|
|
12269
|
+
class DefaultExecutionScope {
|
|
12270
|
+
operationStore;
|
|
12271
|
+
operationIndex;
|
|
12272
|
+
writeCache;
|
|
12273
|
+
documentMetaCache;
|
|
12274
|
+
collectionMembershipCache;
|
|
12275
|
+
constructor(operationStore, operationIndex, writeCache, documentMetaCache, collectionMembershipCache) {
|
|
12276
|
+
this.operationStore = operationStore;
|
|
12277
|
+
this.operationIndex = operationIndex;
|
|
12278
|
+
this.writeCache = writeCache;
|
|
12279
|
+
this.documentMetaCache = documentMetaCache;
|
|
12280
|
+
this.collectionMembershipCache = collectionMembershipCache;
|
|
12281
|
+
}
|
|
12282
|
+
async run(fn) {
|
|
12283
|
+
return fn({
|
|
12284
|
+
operationStore: this.operationStore,
|
|
12285
|
+
operationIndex: this.operationIndex,
|
|
12286
|
+
writeCache: this.writeCache,
|
|
12287
|
+
documentMetaCache: this.documentMetaCache,
|
|
12288
|
+
collectionMembershipCache: this.collectionMembershipCache
|
|
12289
|
+
});
|
|
12290
|
+
}
|
|
12291
|
+
}
|
|
12292
|
+
|
|
12293
|
+
class KyselyExecutionScope {
|
|
12294
|
+
db;
|
|
12295
|
+
operationStore;
|
|
12296
|
+
operationIndex;
|
|
12297
|
+
keyframeStore;
|
|
12298
|
+
writeCache;
|
|
12299
|
+
documentMetaCache;
|
|
12300
|
+
collectionMembershipCache;
|
|
12301
|
+
constructor(db, operationStore, operationIndex, keyframeStore, writeCache, documentMetaCache, collectionMembershipCache) {
|
|
12302
|
+
this.db = db;
|
|
12303
|
+
this.operationStore = operationStore;
|
|
12304
|
+
this.operationIndex = operationIndex;
|
|
12305
|
+
this.keyframeStore = keyframeStore;
|
|
12306
|
+
this.writeCache = writeCache;
|
|
12307
|
+
this.documentMetaCache = documentMetaCache;
|
|
12308
|
+
this.collectionMembershipCache = collectionMembershipCache;
|
|
12309
|
+
}
|
|
12310
|
+
async run(fn) {
|
|
12311
|
+
return this.db.transaction().execute(async (trx) => {
|
|
12312
|
+
const scopedOperationStore = this.operationStore.withTransaction(trx);
|
|
12313
|
+
const scopedOperationIndex = this.operationIndex.withTransaction(trx);
|
|
12314
|
+
const scopedKeyframeStore = this.keyframeStore.withTransaction(trx);
|
|
12315
|
+
return fn({
|
|
12316
|
+
operationStore: scopedOperationStore,
|
|
12317
|
+
operationIndex: scopedOperationIndex,
|
|
12318
|
+
writeCache: this.writeCache.withScopedStores(scopedOperationStore, scopedKeyframeStore),
|
|
12319
|
+
documentMetaCache: this.documentMetaCache.withScopedStore(scopedOperationStore),
|
|
12320
|
+
collectionMembershipCache: this.collectionMembershipCache.withScopedIndex(scopedOperationIndex)
|
|
12321
|
+
});
|
|
12322
|
+
});
|
|
12323
|
+
}
|
|
12324
|
+
}
|
|
12325
|
+
|
|
12237
12326
|
class DocumentModelRegistry {
|
|
12238
12327
|
modules = [];
|
|
12239
12328
|
manifests = [];
|
|
@@ -12693,37 +12782,29 @@ function driveCollectionId(branch, driveId) {
|
|
|
12693
12782
|
}
|
|
12694
12783
|
|
|
12695
12784
|
class DocumentActionHandler {
|
|
12696
|
-
writeCache;
|
|
12697
|
-
operationStore;
|
|
12698
|
-
documentMetaCache;
|
|
12699
|
-
collectionMembershipCache;
|
|
12700
12785
|
registry;
|
|
12701
12786
|
logger;
|
|
12702
|
-
constructor(
|
|
12703
|
-
this.writeCache = writeCache;
|
|
12704
|
-
this.operationStore = operationStore;
|
|
12705
|
-
this.documentMetaCache = documentMetaCache;
|
|
12706
|
-
this.collectionMembershipCache = collectionMembershipCache;
|
|
12787
|
+
constructor(registry, logger2) {
|
|
12707
12788
|
this.registry = registry;
|
|
12708
12789
|
this.logger = logger2;
|
|
12709
12790
|
}
|
|
12710
|
-
async execute(job, action, startTime, indexTxn, skip = 0, sourceRemote = "") {
|
|
12791
|
+
async execute(job, action, startTime, indexTxn, stores, skip = 0, sourceRemote = "") {
|
|
12711
12792
|
switch (action.type) {
|
|
12712
12793
|
case "CREATE_DOCUMENT":
|
|
12713
|
-
return this.executeCreate(job, action, startTime, indexTxn, skip, sourceRemote);
|
|
12794
|
+
return this.executeCreate(job, action, startTime, indexTxn, stores, skip, sourceRemote);
|
|
12714
12795
|
case "DELETE_DOCUMENT":
|
|
12715
|
-
return this.executeDelete(job, action, startTime, indexTxn, sourceRemote);
|
|
12796
|
+
return this.executeDelete(job, action, startTime, indexTxn, stores, sourceRemote);
|
|
12716
12797
|
case "UPGRADE_DOCUMENT":
|
|
12717
|
-
return this.executeUpgrade(job, action, startTime, indexTxn, skip, sourceRemote);
|
|
12798
|
+
return this.executeUpgrade(job, action, startTime, indexTxn, stores, skip, sourceRemote);
|
|
12718
12799
|
case "ADD_RELATIONSHIP":
|
|
12719
|
-
return this.executeAddRelationship(job, action, startTime, indexTxn, sourceRemote);
|
|
12800
|
+
return this.executeAddRelationship(job, action, startTime, indexTxn, stores, sourceRemote);
|
|
12720
12801
|
case "REMOVE_RELATIONSHIP":
|
|
12721
|
-
return this.executeRemoveRelationship(job, action, startTime, indexTxn, sourceRemote);
|
|
12802
|
+
return this.executeRemoveRelationship(job, action, startTime, indexTxn, stores, sourceRemote);
|
|
12722
12803
|
default:
|
|
12723
12804
|
return buildErrorResult(job, new Error(`Unknown document action type: ${action.type}`), startTime);
|
|
12724
12805
|
}
|
|
12725
12806
|
}
|
|
12726
|
-
async executeCreate(job, action, startTime, indexTxn, skip = 0, sourceRemote = "") {
|
|
12807
|
+
async executeCreate(job, action, startTime, indexTxn, stores, skip = 0, sourceRemote = "") {
|
|
12727
12808
|
if (job.scope !== "document") {
|
|
12728
12809
|
return {
|
|
12729
12810
|
job,
|
|
@@ -12743,12 +12824,12 @@ class DocumentActionHandler {
|
|
|
12743
12824
|
...document2.state
|
|
12744
12825
|
};
|
|
12745
12826
|
const resultingState = JSON.stringify(resultingStateObj);
|
|
12746
|
-
const writeError = await this.writeOperationToStore(document2.header.id, document2.header.documentType, job.scope, job.branch, operation, job, startTime);
|
|
12827
|
+
const writeError = await this.writeOperationToStore(document2.header.id, document2.header.documentType, job.scope, job.branch, operation, job, startTime, stores);
|
|
12747
12828
|
if (writeError !== null) {
|
|
12748
12829
|
return writeError;
|
|
12749
12830
|
}
|
|
12750
12831
|
updateDocumentRevision(document2, job.scope, operation.index);
|
|
12751
|
-
|
|
12832
|
+
stores.writeCache.putState(document2.header.id, job.scope, job.branch, operation.index, document2);
|
|
12752
12833
|
indexTxn.write([
|
|
12753
12834
|
{
|
|
12754
12835
|
...operation,
|
|
@@ -12764,14 +12845,14 @@ class DocumentActionHandler {
|
|
|
12764
12845
|
indexTxn.createCollection(collectionId);
|
|
12765
12846
|
indexTxn.addToCollection(collectionId, document2.header.id);
|
|
12766
12847
|
}
|
|
12767
|
-
|
|
12848
|
+
stores.documentMetaCache.putDocumentMeta(document2.header.id, job.branch, {
|
|
12768
12849
|
state: document2.state.document,
|
|
12769
12850
|
documentType: document2.header.documentType,
|
|
12770
12851
|
documentScopeRevision: 1
|
|
12771
12852
|
});
|
|
12772
12853
|
return buildSuccessResult(job, operation, document2.header.id, document2.header.documentType, resultingState, startTime);
|
|
12773
12854
|
}
|
|
12774
|
-
async executeDelete(job, action, startTime, indexTxn, sourceRemote = "") {
|
|
12855
|
+
async executeDelete(job, action, startTime, indexTxn, stores, sourceRemote = "") {
|
|
12775
12856
|
const input = action.input;
|
|
12776
12857
|
if (!input.documentId) {
|
|
12777
12858
|
return buildErrorResult(job, new Error("DELETE_DOCUMENT action requires a documentId in input"), startTime);
|
|
@@ -12779,7 +12860,7 @@ class DocumentActionHandler {
|
|
|
12779
12860
|
const documentId = input.documentId;
|
|
12780
12861
|
let document2;
|
|
12781
12862
|
try {
|
|
12782
|
-
document2 = await
|
|
12863
|
+
document2 = await stores.writeCache.getState(documentId, job.scope, job.branch);
|
|
12783
12864
|
} catch (error) {
|
|
12784
12865
|
return buildErrorResult(job, new Error(`Failed to fetch document before deletion: ${error instanceof Error ? error.message : String(error)}`), startTime);
|
|
12785
12866
|
}
|
|
@@ -12799,12 +12880,12 @@ class DocumentActionHandler {
|
|
|
12799
12880
|
document: document2.state.document
|
|
12800
12881
|
};
|
|
12801
12882
|
const resultingState = JSON.stringify(resultingStateObj);
|
|
12802
|
-
const writeError = await this.writeOperationToStore(documentId, document2.header.documentType, job.scope, job.branch, operation, job, startTime);
|
|
12883
|
+
const writeError = await this.writeOperationToStore(documentId, document2.header.documentType, job.scope, job.branch, operation, job, startTime, stores);
|
|
12803
12884
|
if (writeError !== null) {
|
|
12804
12885
|
return writeError;
|
|
12805
12886
|
}
|
|
12806
12887
|
updateDocumentRevision(document2, job.scope, operation.index);
|
|
12807
|
-
|
|
12888
|
+
stores.writeCache.putState(documentId, job.scope, job.branch, operation.index, document2);
|
|
12808
12889
|
indexTxn.write([
|
|
12809
12890
|
{
|
|
12810
12891
|
...operation,
|
|
@@ -12815,14 +12896,14 @@ class DocumentActionHandler {
|
|
|
12815
12896
|
sourceRemote
|
|
12816
12897
|
}
|
|
12817
12898
|
]);
|
|
12818
|
-
|
|
12899
|
+
stores.documentMetaCache.putDocumentMeta(documentId, job.branch, {
|
|
12819
12900
|
state: document2.state.document,
|
|
12820
12901
|
documentType: document2.header.documentType,
|
|
12821
12902
|
documentScopeRevision: operation.index + 1
|
|
12822
12903
|
});
|
|
12823
12904
|
return buildSuccessResult(job, operation, documentId, document2.header.documentType, resultingState, startTime);
|
|
12824
12905
|
}
|
|
12825
|
-
async executeUpgrade(job, action, startTime, indexTxn, skip = 0, sourceRemote = "") {
|
|
12906
|
+
async executeUpgrade(job, action, startTime, indexTxn, stores, skip = 0, sourceRemote = "") {
|
|
12826
12907
|
const input = action.input;
|
|
12827
12908
|
if (!input.documentId) {
|
|
12828
12909
|
return buildErrorResult(job, new Error("UPGRADE_DOCUMENT action requires a documentId in input"), startTime);
|
|
@@ -12832,7 +12913,7 @@ class DocumentActionHandler {
|
|
|
12832
12913
|
const toVersion = input.toVersion;
|
|
12833
12914
|
let document2;
|
|
12834
12915
|
try {
|
|
12835
|
-
document2 = await
|
|
12916
|
+
document2 = await stores.writeCache.getState(documentId, job.scope, job.branch);
|
|
12836
12917
|
} catch (error) {
|
|
12837
12918
|
return buildErrorResult(job, new Error(`Failed to fetch document for upgrade: ${error instanceof Error ? error.message : String(error)}`), startTime);
|
|
12838
12919
|
}
|
|
@@ -12873,12 +12954,12 @@ class DocumentActionHandler {
|
|
|
12873
12954
|
...document2.state
|
|
12874
12955
|
};
|
|
12875
12956
|
const resultingState = JSON.stringify(resultingStateObj);
|
|
12876
|
-
const writeError = await this.writeOperationToStore(documentId, document2.header.documentType, job.scope, job.branch, operation, job, startTime);
|
|
12957
|
+
const writeError = await this.writeOperationToStore(documentId, document2.header.documentType, job.scope, job.branch, operation, job, startTime, stores);
|
|
12877
12958
|
if (writeError !== null) {
|
|
12878
12959
|
return writeError;
|
|
12879
12960
|
}
|
|
12880
12961
|
updateDocumentRevision(document2, job.scope, operation.index);
|
|
12881
|
-
|
|
12962
|
+
stores.writeCache.putState(documentId, job.scope, job.branch, operation.index, document2);
|
|
12882
12963
|
indexTxn.write([
|
|
12883
12964
|
{
|
|
12884
12965
|
...operation,
|
|
@@ -12889,14 +12970,14 @@ class DocumentActionHandler {
|
|
|
12889
12970
|
sourceRemote
|
|
12890
12971
|
}
|
|
12891
12972
|
]);
|
|
12892
|
-
|
|
12973
|
+
stores.documentMetaCache.putDocumentMeta(documentId, job.branch, {
|
|
12893
12974
|
state: document2.state.document,
|
|
12894
12975
|
documentType: document2.header.documentType,
|
|
12895
12976
|
documentScopeRevision: operation.index + 1
|
|
12896
12977
|
});
|
|
12897
12978
|
return buildSuccessResult(job, operation, documentId, document2.header.documentType, resultingState, startTime);
|
|
12898
12979
|
}
|
|
12899
|
-
async executeAddRelationship(job, action, startTime, indexTxn, sourceRemote = "") {
|
|
12980
|
+
async executeAddRelationship(job, action, startTime, indexTxn, stores, sourceRemote = "") {
|
|
12900
12981
|
if (job.scope !== "document") {
|
|
12901
12982
|
return buildErrorResult(job, new Error(`ADD_RELATIONSHIP must be in "document" scope, got "${job.scope}"`), startTime);
|
|
12902
12983
|
}
|
|
@@ -12909,7 +12990,7 @@ class DocumentActionHandler {
|
|
|
12909
12990
|
}
|
|
12910
12991
|
let sourceDoc;
|
|
12911
12992
|
try {
|
|
12912
|
-
sourceDoc = await
|
|
12993
|
+
sourceDoc = await stores.writeCache.getState(input.sourceId, "document", job.branch);
|
|
12913
12994
|
} catch (error) {
|
|
12914
12995
|
return buildErrorResult(job, new Error(`ADD_RELATIONSHIP: source document ${input.sourceId} not found: ${error instanceof Error ? error.message : String(error)}`), startTime);
|
|
12915
12996
|
}
|
|
@@ -12919,7 +13000,7 @@ class DocumentActionHandler {
|
|
|
12919
13000
|
scope: job.scope,
|
|
12920
13001
|
branch: job.branch
|
|
12921
13002
|
});
|
|
12922
|
-
const writeError = await this.writeOperationToStore(input.sourceId, sourceDoc.header.documentType, job.scope, job.branch, operation, job, startTime);
|
|
13003
|
+
const writeError = await this.writeOperationToStore(input.sourceId, sourceDoc.header.documentType, job.scope, job.branch, operation, job, startTime, stores);
|
|
12923
13004
|
if (writeError !== null) {
|
|
12924
13005
|
return writeError;
|
|
12925
13006
|
}
|
|
@@ -12935,7 +13016,7 @@ class DocumentActionHandler {
|
|
|
12935
13016
|
[job.scope]: scopeState === undefined ? {} : structuredClone(scopeState)
|
|
12936
13017
|
};
|
|
12937
13018
|
const resultingState = JSON.stringify(resultingStateObj);
|
|
12938
|
-
|
|
13019
|
+
stores.writeCache.putState(input.sourceId, job.scope, job.branch, operation.index, sourceDoc);
|
|
12939
13020
|
indexTxn.write([
|
|
12940
13021
|
{
|
|
12941
13022
|
...operation,
|
|
@@ -12949,16 +13030,16 @@ class DocumentActionHandler {
|
|
|
12949
13030
|
if (sourceDoc.header.documentType === "powerhouse/document-drive") {
|
|
12950
13031
|
const collectionId = driveCollectionId(job.branch, input.sourceId);
|
|
12951
13032
|
indexTxn.addToCollection(collectionId, input.targetId);
|
|
12952
|
-
|
|
13033
|
+
stores.collectionMembershipCache.invalidate(input.targetId);
|
|
12953
13034
|
}
|
|
12954
|
-
|
|
13035
|
+
stores.documentMetaCache.putDocumentMeta(input.sourceId, job.branch, {
|
|
12955
13036
|
state: sourceDoc.state.document,
|
|
12956
13037
|
documentType: sourceDoc.header.documentType,
|
|
12957
13038
|
documentScopeRevision: operation.index + 1
|
|
12958
13039
|
});
|
|
12959
13040
|
return buildSuccessResult(job, operation, input.sourceId, sourceDoc.header.documentType, resultingState, startTime);
|
|
12960
13041
|
}
|
|
12961
|
-
async executeRemoveRelationship(job, action, startTime, indexTxn, sourceRemote = "") {
|
|
13042
|
+
async executeRemoveRelationship(job, action, startTime, indexTxn, stores, sourceRemote = "") {
|
|
12962
13043
|
if (job.scope !== "document") {
|
|
12963
13044
|
return buildErrorResult(job, new Error(`REMOVE_RELATIONSHIP must be in "document" scope, got "${job.scope}"`), startTime);
|
|
12964
13045
|
}
|
|
@@ -12968,7 +13049,7 @@ class DocumentActionHandler {
|
|
|
12968
13049
|
}
|
|
12969
13050
|
let sourceDoc;
|
|
12970
13051
|
try {
|
|
12971
|
-
sourceDoc = await
|
|
13052
|
+
sourceDoc = await stores.writeCache.getState(input.sourceId, "document", job.branch);
|
|
12972
13053
|
} catch (error) {
|
|
12973
13054
|
return buildErrorResult(job, new Error(`REMOVE_RELATIONSHIP: source document ${input.sourceId} not found: ${error instanceof Error ? error.message : String(error)}`), startTime);
|
|
12974
13055
|
}
|
|
@@ -12978,7 +13059,7 @@ class DocumentActionHandler {
|
|
|
12978
13059
|
scope: job.scope,
|
|
12979
13060
|
branch: job.branch
|
|
12980
13061
|
});
|
|
12981
|
-
const writeError = await this.writeOperationToStore(input.sourceId, sourceDoc.header.documentType, job.scope, job.branch, operation, job, startTime);
|
|
13062
|
+
const writeError = await this.writeOperationToStore(input.sourceId, sourceDoc.header.documentType, job.scope, job.branch, operation, job, startTime, stores);
|
|
12982
13063
|
if (writeError !== null) {
|
|
12983
13064
|
return writeError;
|
|
12984
13065
|
}
|
|
@@ -12994,7 +13075,7 @@ class DocumentActionHandler {
|
|
|
12994
13075
|
[job.scope]: scopeState === undefined ? {} : structuredClone(scopeState)
|
|
12995
13076
|
};
|
|
12996
13077
|
const resultingState = JSON.stringify(resultingStateObj);
|
|
12997
|
-
|
|
13078
|
+
stores.writeCache.putState(input.sourceId, job.scope, job.branch, operation.index, sourceDoc);
|
|
12998
13079
|
indexTxn.write([
|
|
12999
13080
|
{
|
|
13000
13081
|
...operation,
|
|
@@ -13008,24 +13089,24 @@ class DocumentActionHandler {
|
|
|
13008
13089
|
if (sourceDoc.header.documentType === "powerhouse/document-drive") {
|
|
13009
13090
|
const collectionId = driveCollectionId(job.branch, input.sourceId);
|
|
13010
13091
|
indexTxn.removeFromCollection(collectionId, input.targetId);
|
|
13011
|
-
|
|
13092
|
+
stores.collectionMembershipCache.invalidate(input.targetId);
|
|
13012
13093
|
}
|
|
13013
|
-
|
|
13094
|
+
stores.documentMetaCache.putDocumentMeta(input.sourceId, job.branch, {
|
|
13014
13095
|
state: sourceDoc.state.document,
|
|
13015
13096
|
documentType: sourceDoc.header.documentType,
|
|
13016
13097
|
documentScopeRevision: operation.index + 1
|
|
13017
13098
|
});
|
|
13018
13099
|
return buildSuccessResult(job, operation, input.sourceId, sourceDoc.header.documentType, resultingState, startTime);
|
|
13019
13100
|
}
|
|
13020
|
-
async writeOperationToStore(documentId, documentType, scope, branch, operation, job, startTime) {
|
|
13101
|
+
async writeOperationToStore(documentId, documentType, scope, branch, operation, job, startTime, stores) {
|
|
13021
13102
|
try {
|
|
13022
|
-
await
|
|
13103
|
+
await stores.operationStore.apply(documentId, documentType, scope, branch, operation.index, (txn) => {
|
|
13023
13104
|
txn.addOperations(operation);
|
|
13024
13105
|
});
|
|
13025
13106
|
return null;
|
|
13026
13107
|
} catch (error) {
|
|
13027
13108
|
this.logger.error("Error writing @Operation to IOperationStore: @Error", operation, error);
|
|
13028
|
-
|
|
13109
|
+
stores.writeCache.invalidate(documentId, scope, branch);
|
|
13029
13110
|
return {
|
|
13030
13111
|
job,
|
|
13031
13112
|
success: false,
|
|
@@ -13114,7 +13195,8 @@ class SimpleJobExecutor {
|
|
|
13114
13195
|
config;
|
|
13115
13196
|
signatureVerifierModule;
|
|
13116
13197
|
documentActionHandler;
|
|
13117
|
-
|
|
13198
|
+
executionScope;
|
|
13199
|
+
constructor(logger2, registry, operationStore, eventBus, writeCache, operationIndex, documentMetaCache, collectionMembershipCache, config, signatureVerifier, executionScope) {
|
|
13118
13200
|
this.logger = logger2;
|
|
13119
13201
|
this.registry = registry;
|
|
13120
13202
|
this.operationStore = operationStore;
|
|
@@ -13131,71 +13213,101 @@ class SimpleJobExecutor {
|
|
|
13131
13213
|
retryMaxDelayMs: config.retryMaxDelayMs ?? 5000
|
|
13132
13214
|
};
|
|
13133
13215
|
this.signatureVerifierModule = new SignatureVerifier(signatureVerifier);
|
|
13134
|
-
this.documentActionHandler = new DocumentActionHandler(
|
|
13216
|
+
this.documentActionHandler = new DocumentActionHandler(registry, logger2);
|
|
13217
|
+
this.executionScope = executionScope ?? new DefaultExecutionScope(operationStore, operationIndex, writeCache, documentMetaCache, collectionMembershipCache);
|
|
13135
13218
|
}
|
|
13136
13219
|
async executeJob(job) {
|
|
13137
13220
|
const startTime = Date.now();
|
|
13138
|
-
const
|
|
13139
|
-
|
|
13140
|
-
|
|
13141
|
-
|
|
13142
|
-
|
|
13143
|
-
|
|
13144
|
-
|
|
13221
|
+
const touchedCacheEntries = [];
|
|
13222
|
+
let pendingEvent;
|
|
13223
|
+
let result;
|
|
13224
|
+
try {
|
|
13225
|
+
result = await this.executionScope.run(async (stores) => {
|
|
13226
|
+
const indexTxn = stores.operationIndex.start();
|
|
13227
|
+
if (job.kind === "load") {
|
|
13228
|
+
const loadResult = await this.executeLoadJob(job, startTime, indexTxn, stores);
|
|
13229
|
+
if (loadResult.success && loadResult.operationsWithContext) {
|
|
13230
|
+
for (const owc of loadResult.operationsWithContext) {
|
|
13231
|
+
touchedCacheEntries.push({
|
|
13232
|
+
documentId: owc.context.documentId,
|
|
13233
|
+
scope: owc.context.scope,
|
|
13234
|
+
branch: owc.context.branch
|
|
13235
|
+
});
|
|
13236
|
+
}
|
|
13237
|
+
const ordinals2 = await stores.operationIndex.commit(indexTxn);
|
|
13238
|
+
for (let i = 0;i < loadResult.operationsWithContext.length; i++) {
|
|
13239
|
+
loadResult.operationsWithContext[i].context.ordinal = ordinals2[i];
|
|
13240
|
+
}
|
|
13241
|
+
const collectionMemberships = loadResult.operationsWithContext.length > 0 ? await this.getCollectionMembershipsForOperations(loadResult.operationsWithContext, stores) : {};
|
|
13242
|
+
pendingEvent = {
|
|
13243
|
+
jobId: job.id,
|
|
13244
|
+
operations: loadResult.operationsWithContext,
|
|
13245
|
+
jobMeta: job.meta,
|
|
13246
|
+
collectionMemberships
|
|
13247
|
+
};
|
|
13248
|
+
}
|
|
13249
|
+
return loadResult;
|
|
13145
13250
|
}
|
|
13146
|
-
const
|
|
13147
|
-
|
|
13148
|
-
|
|
13149
|
-
|
|
13150
|
-
|
|
13151
|
-
|
|
13251
|
+
const actionResult = await this.processActions(job, job.actions, startTime, indexTxn, stores);
|
|
13252
|
+
if (!actionResult.success) {
|
|
13253
|
+
return {
|
|
13254
|
+
job,
|
|
13255
|
+
success: false,
|
|
13256
|
+
error: actionResult.error,
|
|
13257
|
+
duration: Date.now() - startTime
|
|
13258
|
+
};
|
|
13259
|
+
}
|
|
13260
|
+
if (actionResult.operationsWithContext.length > 0) {
|
|
13261
|
+
for (const owc of actionResult.operationsWithContext) {
|
|
13262
|
+
touchedCacheEntries.push({
|
|
13263
|
+
documentId: owc.context.documentId,
|
|
13264
|
+
scope: owc.context.scope,
|
|
13265
|
+
branch: owc.context.branch
|
|
13266
|
+
});
|
|
13267
|
+
}
|
|
13268
|
+
}
|
|
13269
|
+
const ordinals = await stores.operationIndex.commit(indexTxn);
|
|
13270
|
+
if (actionResult.operationsWithContext.length > 0) {
|
|
13271
|
+
for (let i = 0;i < actionResult.operationsWithContext.length; i++) {
|
|
13272
|
+
actionResult.operationsWithContext[i].context.ordinal = ordinals[i];
|
|
13273
|
+
}
|
|
13274
|
+
const collectionMemberships = await this.getCollectionMembershipsForOperations(actionResult.operationsWithContext, stores);
|
|
13275
|
+
pendingEvent = {
|
|
13276
|
+
jobId: job.id,
|
|
13277
|
+
operations: actionResult.operationsWithContext,
|
|
13278
|
+
jobMeta: job.meta,
|
|
13279
|
+
collectionMemberships
|
|
13280
|
+
};
|
|
13281
|
+
}
|
|
13282
|
+
return {
|
|
13283
|
+
job,
|
|
13284
|
+
success: true,
|
|
13285
|
+
operations: actionResult.generatedOperations,
|
|
13286
|
+
operationsWithContext: actionResult.operationsWithContext,
|
|
13287
|
+
duration: Date.now() - startTime
|
|
13152
13288
|
};
|
|
13153
|
-
|
|
13154
|
-
|
|
13155
|
-
|
|
13289
|
+
});
|
|
13290
|
+
} catch (error) {
|
|
13291
|
+
for (const entry of touchedCacheEntries) {
|
|
13292
|
+
this.writeCache.invalidate(entry.documentId, entry.scope, entry.branch);
|
|
13293
|
+
this.documentMetaCache.invalidate(entry.documentId, entry.branch);
|
|
13156
13294
|
}
|
|
13157
|
-
|
|
13158
|
-
}
|
|
13159
|
-
const result = await this.processActions(job, job.actions, startTime, indexTxn);
|
|
13160
|
-
if (!result.success) {
|
|
13161
|
-
return {
|
|
13162
|
-
job,
|
|
13163
|
-
success: false,
|
|
13164
|
-
error: result.error,
|
|
13165
|
-
duration: Date.now() - startTime
|
|
13166
|
-
};
|
|
13295
|
+
throw error;
|
|
13167
13296
|
}
|
|
13168
|
-
|
|
13169
|
-
|
|
13170
|
-
|
|
13171
|
-
result.operationsWithContext[i].context.ordinal = ordinals[i];
|
|
13172
|
-
}
|
|
13173
|
-
const collectionMemberships = await this.getCollectionMembershipsForOperations(result.operationsWithContext);
|
|
13174
|
-
const event = {
|
|
13175
|
-
jobId: job.id,
|
|
13176
|
-
operations: result.operationsWithContext,
|
|
13177
|
-
jobMeta: job.meta,
|
|
13178
|
-
collectionMemberships
|
|
13179
|
-
};
|
|
13180
|
-
this.eventBus.emit(ReactorEventTypes.JOB_WRITE_READY, event).catch((error) => {
|
|
13181
|
-
this.logger.error("Failed to emit JOB_WRITE_READY event: @Event : @Error", event, error);
|
|
13297
|
+
if (pendingEvent) {
|
|
13298
|
+
this.eventBus.emit(ReactorEventTypes.JOB_WRITE_READY, pendingEvent).catch((error) => {
|
|
13299
|
+
this.logger.error("Failed to emit JOB_WRITE_READY event: @Event : @Error", pendingEvent, error);
|
|
13182
13300
|
});
|
|
13183
13301
|
}
|
|
13184
|
-
return
|
|
13185
|
-
job,
|
|
13186
|
-
success: true,
|
|
13187
|
-
operations: result.generatedOperations,
|
|
13188
|
-
operationsWithContext: result.operationsWithContext,
|
|
13189
|
-
duration: Date.now() - startTime
|
|
13190
|
-
};
|
|
13302
|
+
return result;
|
|
13191
13303
|
}
|
|
13192
|
-
async getCollectionMembershipsForOperations(operations) {
|
|
13304
|
+
async getCollectionMembershipsForOperations(operations, stores) {
|
|
13193
13305
|
const documentIds = [
|
|
13194
13306
|
...new Set(operations.map((op) => op.context.documentId))
|
|
13195
13307
|
];
|
|
13196
|
-
return
|
|
13308
|
+
return stores.collectionMembershipCache.getCollectionsForDocuments(documentIds);
|
|
13197
13309
|
}
|
|
13198
|
-
async processActions(job, actions2, startTime, indexTxn, skipValues, sourceOperations, sourceRemote = "") {
|
|
13310
|
+
async processActions(job, actions2, startTime, indexTxn, stores, skipValues, sourceOperations, sourceRemote = "") {
|
|
13199
13311
|
const generatedOperations = [];
|
|
13200
13312
|
const operationsWithContext = [];
|
|
13201
13313
|
try {
|
|
@@ -13213,7 +13325,7 @@ class SimpleJobExecutor {
|
|
|
13213
13325
|
const skip = skipValues?.[actionIndex] ?? 0;
|
|
13214
13326
|
const sourceOperation = sourceOperations?.[actionIndex];
|
|
13215
13327
|
const isDocumentAction = documentScopeActions.includes(action.type);
|
|
13216
|
-
const result = isDocumentAction ? await this.documentActionHandler.execute(job, action, startTime, indexTxn, skip, sourceRemote) : await this.executeRegularAction(job, action, startTime, indexTxn, skip, sourceOperation, sourceRemote);
|
|
13328
|
+
const result = isDocumentAction ? await this.documentActionHandler.execute(job, action, startTime, indexTxn, stores, skip, sourceRemote) : await this.executeRegularAction(job, action, startTime, indexTxn, stores, skip, sourceOperation, sourceRemote);
|
|
13217
13329
|
const error = this.accumulateResultOrReturnError(result, generatedOperations, operationsWithContext);
|
|
13218
13330
|
if (error !== null) {
|
|
13219
13331
|
return {
|
|
@@ -13230,10 +13342,10 @@ class SimpleJobExecutor {
|
|
|
13230
13342
|
operationsWithContext
|
|
13231
13343
|
};
|
|
13232
13344
|
}
|
|
13233
|
-
async executeRegularAction(job, action, startTime, indexTxn, skip = 0, sourceOperation, sourceRemote = "") {
|
|
13345
|
+
async executeRegularAction(job, action, startTime, indexTxn, stores, skip = 0, sourceOperation, sourceRemote = "") {
|
|
13234
13346
|
let docMeta;
|
|
13235
13347
|
try {
|
|
13236
|
-
docMeta = await
|
|
13348
|
+
docMeta = await stores.documentMetaCache.getDocumentMeta(job.documentId, job.branch);
|
|
13237
13349
|
} catch (error) {
|
|
13238
13350
|
return buildErrorResult(job, error instanceof Error ? error : new Error(String(error)), startTime);
|
|
13239
13351
|
}
|
|
@@ -13241,11 +13353,11 @@ class SimpleJobExecutor {
|
|
|
13241
13353
|
return buildErrorResult(job, new DocumentDeletedError(job.documentId, docMeta.state.deletedAtUtcIso), startTime);
|
|
13242
13354
|
}
|
|
13243
13355
|
if (isUndoRedo(action) || action.type === "PRUNE" || action.type === "NOOP" && skip > 0) {
|
|
13244
|
-
|
|
13356
|
+
stores.writeCache.invalidate(job.documentId, job.scope, job.branch);
|
|
13245
13357
|
}
|
|
13246
13358
|
let document2;
|
|
13247
13359
|
try {
|
|
13248
|
-
document2 = await
|
|
13360
|
+
document2 = await stores.writeCache.getState(job.documentId, job.scope, job.branch);
|
|
13249
13361
|
} catch (error) {
|
|
13250
13362
|
return buildErrorResult(job, error instanceof Error ? error : new Error(String(error)), startTime);
|
|
13251
13363
|
}
|
|
@@ -13296,12 +13408,12 @@ ${error.stack}`;
|
|
|
13296
13408
|
header: updatedDocument.header
|
|
13297
13409
|
});
|
|
13298
13410
|
try {
|
|
13299
|
-
await
|
|
13411
|
+
await stores.operationStore.apply(job.documentId, document2.header.documentType, scope, job.branch, newOperation.index, (txn) => {
|
|
13300
13412
|
txn.addOperations(newOperation);
|
|
13301
13413
|
});
|
|
13302
13414
|
} catch (error) {
|
|
13303
13415
|
this.logger.error("Error writing @Operation to IOperationStore: @Error", newOperation, error);
|
|
13304
|
-
|
|
13416
|
+
stores.writeCache.invalidate(job.documentId, scope, job.branch);
|
|
13305
13417
|
return {
|
|
13306
13418
|
job,
|
|
13307
13419
|
success: false,
|
|
@@ -13313,7 +13425,7 @@ ${error.stack}`;
|
|
|
13313
13425
|
...updatedDocument.header.revision,
|
|
13314
13426
|
[scope]: newOperation.index + 1
|
|
13315
13427
|
};
|
|
13316
|
-
|
|
13428
|
+
stores.writeCache.putState(job.documentId, scope, job.branch, newOperation.index, updatedDocument);
|
|
13317
13429
|
indexTxn.write([
|
|
13318
13430
|
{
|
|
13319
13431
|
...newOperation,
|
|
@@ -13344,13 +13456,13 @@ ${error.stack}`;
|
|
|
13344
13456
|
duration: Date.now() - startTime
|
|
13345
13457
|
};
|
|
13346
13458
|
}
|
|
13347
|
-
async executeLoadJob(job, startTime, indexTxn) {
|
|
13459
|
+
async executeLoadJob(job, startTime, indexTxn, stores) {
|
|
13348
13460
|
if (job.operations.length === 0) {
|
|
13349
13461
|
return buildErrorResult(job, new Error("Load job must include at least one operation"), startTime);
|
|
13350
13462
|
}
|
|
13351
13463
|
let docMeta;
|
|
13352
13464
|
try {
|
|
13353
|
-
docMeta = await
|
|
13465
|
+
docMeta = await stores.documentMetaCache.getDocumentMeta(job.documentId, job.branch);
|
|
13354
13466
|
} catch {}
|
|
13355
13467
|
if (docMeta?.state.isDeleted) {
|
|
13356
13468
|
return buildErrorResult(job, new DocumentDeletedError(job.documentId, docMeta.state.deletedAtUtcIso), startTime);
|
|
@@ -13358,7 +13470,7 @@ ${error.stack}`;
|
|
|
13358
13470
|
const scope = job.scope;
|
|
13359
13471
|
let latestRevision = 0;
|
|
13360
13472
|
try {
|
|
13361
|
-
const revisions = await
|
|
13473
|
+
const revisions = await stores.operationStore.getRevisions(job.documentId, job.branch);
|
|
13362
13474
|
latestRevision = revisions.revision[scope] ?? 0;
|
|
13363
13475
|
} catch {
|
|
13364
13476
|
latestRevision = 0;
|
|
@@ -13374,7 +13486,7 @@ ${error.stack}`;
|
|
|
13374
13486
|
}
|
|
13375
13487
|
let conflictingOps = [];
|
|
13376
13488
|
try {
|
|
13377
|
-
const conflictingResult = await
|
|
13489
|
+
const conflictingResult = await stores.operationStore.getConflicting(job.documentId, scope, job.branch, minIncomingTimestamp);
|
|
13378
13490
|
conflictingOps = conflictingResult.results;
|
|
13379
13491
|
} catch {
|
|
13380
13492
|
conflictingOps = [];
|
|
@@ -13383,7 +13495,7 @@ ${error.stack}`;
|
|
|
13383
13495
|
if (conflictingOps.length > 0) {
|
|
13384
13496
|
const minConflictingIndex = Math.min(...conflictingOps.map((op) => op.index));
|
|
13385
13497
|
try {
|
|
13386
|
-
const allOpsResult = await
|
|
13498
|
+
const allOpsResult = await stores.operationStore.getSince(job.documentId, scope, job.branch, minConflictingIndex - 1);
|
|
13387
13499
|
allOpsFromMinConflictingIndex = allOpsResult.results;
|
|
13388
13500
|
} catch {
|
|
13389
13501
|
allOpsFromMinConflictingIndex = conflictingOps;
|
|
@@ -13444,7 +13556,7 @@ ${error.stack}`;
|
|
|
13444
13556
|
const actions2 = reshuffledOperations.map((operation) => operation.action);
|
|
13445
13557
|
const skipValues = reshuffledOperations.map((operation) => operation.skip);
|
|
13446
13558
|
const effectiveSourceRemote = skipCount > 0 ? "" : job.meta.sourceRemote || "";
|
|
13447
|
-
const result = await this.processActions(job, actions2, startTime, indexTxn, skipValues, reshuffledOperations, effectiveSourceRemote);
|
|
13559
|
+
const result = await this.processActions(job, actions2, startTime, indexTxn, stores, skipValues, reshuffledOperations, effectiveSourceRemote);
|
|
13448
13560
|
if (!result.success) {
|
|
13449
13561
|
return {
|
|
13450
13562
|
job,
|
|
@@ -13453,9 +13565,9 @@ ${error.stack}`;
|
|
|
13453
13565
|
duration: Date.now() - startTime
|
|
13454
13566
|
};
|
|
13455
13567
|
}
|
|
13456
|
-
|
|
13568
|
+
stores.writeCache.invalidate(job.documentId, scope, job.branch);
|
|
13457
13569
|
if (scope === "document") {
|
|
13458
|
-
|
|
13570
|
+
stores.documentMetaCache.invalidate(job.documentId, job.branch);
|
|
13459
13571
|
}
|
|
13460
13572
|
return {
|
|
13461
13573
|
job,
|
|
@@ -14404,14 +14516,23 @@ async function collectAllPages(firstPage, signal) {
|
|
|
14404
14516
|
|
|
14405
14517
|
class KyselyKeyframeStore {
|
|
14406
14518
|
db;
|
|
14519
|
+
trx;
|
|
14407
14520
|
constructor(db) {
|
|
14408
14521
|
this.db = db;
|
|
14409
14522
|
}
|
|
14523
|
+
get queryExecutor() {
|
|
14524
|
+
return this.trx ?? this.db;
|
|
14525
|
+
}
|
|
14526
|
+
withTransaction(trx) {
|
|
14527
|
+
const instance = new KyselyKeyframeStore(this.db);
|
|
14528
|
+
instance.trx = trx;
|
|
14529
|
+
return instance;
|
|
14530
|
+
}
|
|
14410
14531
|
async putKeyframe(documentId, scope, branch, revision, document2, signal) {
|
|
14411
14532
|
if (signal?.aborted) {
|
|
14412
14533
|
throw new Error("Operation aborted");
|
|
14413
14534
|
}
|
|
14414
|
-
await this.
|
|
14535
|
+
await this.queryExecutor.insertInto("Keyframe").values({
|
|
14415
14536
|
documentId,
|
|
14416
14537
|
documentType: document2.header.documentType,
|
|
14417
14538
|
scope,
|
|
@@ -14424,7 +14545,7 @@ class KyselyKeyframeStore {
|
|
|
14424
14545
|
if (signal?.aborted) {
|
|
14425
14546
|
throw new Error("Operation aborted");
|
|
14426
14547
|
}
|
|
14427
|
-
const row = await this.
|
|
14548
|
+
const row = await this.queryExecutor.selectFrom("Keyframe").selectAll().where("documentId", "=", documentId).where("scope", "=", scope).where("branch", "=", branch).where("revision", "<=", targetRevision).orderBy("revision", "desc").limit(1).executeTakeFirst();
|
|
14428
14549
|
if (!row) {
|
|
14429
14550
|
return;
|
|
14430
14551
|
}
|
|
@@ -14437,7 +14558,7 @@ class KyselyKeyframeStore {
|
|
|
14437
14558
|
if (signal?.aborted) {
|
|
14438
14559
|
throw new Error("Operation aborted");
|
|
14439
14560
|
}
|
|
14440
|
-
let query = this.
|
|
14561
|
+
let query = this.queryExecutor.deleteFrom("Keyframe").where("documentId", "=", documentId);
|
|
14441
14562
|
if (scope !== undefined && branch !== undefined) {
|
|
14442
14563
|
query = query.where("scope", "=", scope).where("branch", "=", branch);
|
|
14443
14564
|
} else if (scope !== undefined) {
|
|
@@ -14488,48 +14609,64 @@ class AtomicTransaction {
|
|
|
14488
14609
|
|
|
14489
14610
|
class KyselyOperationStore {
|
|
14490
14611
|
db;
|
|
14612
|
+
trx;
|
|
14491
14613
|
constructor(db) {
|
|
14492
14614
|
this.db = db;
|
|
14493
14615
|
}
|
|
14616
|
+
get queryExecutor() {
|
|
14617
|
+
return this.trx ?? this.db;
|
|
14618
|
+
}
|
|
14619
|
+
withTransaction(trx) {
|
|
14620
|
+
const instance = new KyselyOperationStore(this.db);
|
|
14621
|
+
instance.trx = trx;
|
|
14622
|
+
return instance;
|
|
14623
|
+
}
|
|
14494
14624
|
async apply(documentId, documentType, scope, branch, revision, fn, signal) {
|
|
14495
|
-
|
|
14496
|
-
|
|
14497
|
-
|
|
14625
|
+
if (this.trx) {
|
|
14626
|
+
await this.executeApply(this.trx, documentId, documentType, scope, branch, revision, fn, signal);
|
|
14627
|
+
} else {
|
|
14628
|
+
await this.db.transaction().execute(async (trx) => {
|
|
14629
|
+
await this.executeApply(trx, documentId, documentType, scope, branch, revision, fn, signal);
|
|
14630
|
+
});
|
|
14631
|
+
}
|
|
14632
|
+
}
|
|
14633
|
+
async executeApply(trx, documentId, documentType, scope, branch, revision, fn, signal) {
|
|
14634
|
+
if (signal?.aborted) {
|
|
14635
|
+
throw new Error("Operation aborted");
|
|
14636
|
+
}
|
|
14637
|
+
const latestOp = await trx.selectFrom("Operation").selectAll().where("documentId", "=", documentId).where("scope", "=", scope).where("branch", "=", branch).orderBy("index", "desc").limit(1).executeTakeFirst();
|
|
14638
|
+
const currentRevision = latestOp ? latestOp.index : -1;
|
|
14639
|
+
if (currentRevision !== revision - 1) {
|
|
14640
|
+
throw new RevisionMismatchError(currentRevision + 1, revision);
|
|
14641
|
+
}
|
|
14642
|
+
const atomicTxn = new AtomicTransaction(documentId, documentType, scope, branch, revision);
|
|
14643
|
+
await fn(atomicTxn);
|
|
14644
|
+
const operations = atomicTxn.getOperations();
|
|
14645
|
+
if (operations.length > 0) {
|
|
14646
|
+
let prevOpId = latestOp?.opId || "";
|
|
14647
|
+
for (const op of operations) {
|
|
14648
|
+
op.prevOpId = prevOpId;
|
|
14649
|
+
prevOpId = op.opId;
|
|
14498
14650
|
}
|
|
14499
|
-
|
|
14500
|
-
|
|
14501
|
-
|
|
14502
|
-
|
|
14503
|
-
|
|
14504
|
-
|
|
14505
|
-
|
|
14506
|
-
const operations = atomicTxn.getOperations();
|
|
14507
|
-
if (operations.length > 0) {
|
|
14508
|
-
let prevOpId = latestOp?.opId || "";
|
|
14509
|
-
for (const op of operations) {
|
|
14510
|
-
op.prevOpId = prevOpId;
|
|
14511
|
-
prevOpId = op.opId;
|
|
14512
|
-
}
|
|
14513
|
-
try {
|
|
14514
|
-
await trx.insertInto("Operation").values(operations).execute();
|
|
14515
|
-
} catch (error) {
|
|
14516
|
-
if (error instanceof Error) {
|
|
14517
|
-
if (error.message.includes("unique constraint")) {
|
|
14518
|
-
const op = operations[0];
|
|
14519
|
-
throw new DuplicateOperationError(`${op.opId} at index ${op.index} with skip ${op.skip}`);
|
|
14520
|
-
}
|
|
14521
|
-
throw error;
|
|
14651
|
+
try {
|
|
14652
|
+
await trx.insertInto("Operation").values(operations).execute();
|
|
14653
|
+
} catch (error) {
|
|
14654
|
+
if (error instanceof Error) {
|
|
14655
|
+
if (error.message.includes("unique constraint")) {
|
|
14656
|
+
const op = operations[0];
|
|
14657
|
+
throw new DuplicateOperationError(`${op.opId} at index ${op.index} with skip ${op.skip}`);
|
|
14522
14658
|
}
|
|
14523
14659
|
throw error;
|
|
14524
14660
|
}
|
|
14661
|
+
throw error;
|
|
14525
14662
|
}
|
|
14526
|
-
}
|
|
14663
|
+
}
|
|
14527
14664
|
}
|
|
14528
14665
|
async getSince(documentId, scope, branch, revision, filter, paging, signal) {
|
|
14529
14666
|
if (signal?.aborted) {
|
|
14530
14667
|
throw new Error("Operation aborted");
|
|
14531
14668
|
}
|
|
14532
|
-
let query = this.
|
|
14669
|
+
let query = this.queryExecutor.selectFrom("Operation").selectAll().where("documentId", "=", documentId).where("scope", "=", scope).where("branch", "=", branch).where("index", ">", revision).orderBy("index", "asc");
|
|
14533
14670
|
if (filter) {
|
|
14534
14671
|
if (filter.actionTypes && filter.actionTypes.length > 0) {
|
|
14535
14672
|
const actionTypesArray = filter.actionTypes.map((t) => `'${t.replace(/'/g, "''")}'`).join(",");
|
|
@@ -14576,7 +14713,7 @@ class KyselyOperationStore {
|
|
|
14576
14713
|
if (signal?.aborted) {
|
|
14577
14714
|
throw new Error("Operation aborted");
|
|
14578
14715
|
}
|
|
14579
|
-
let query = this.
|
|
14716
|
+
let query = this.queryExecutor.selectFrom("Operation").selectAll().where("id", ">", id).orderBy("id", "asc");
|
|
14580
14717
|
if (paging) {
|
|
14581
14718
|
const cursorValue = Number.parseInt(paging.cursor, 10);
|
|
14582
14719
|
if (cursorValue > 0) {
|
|
@@ -14608,7 +14745,7 @@ class KyselyOperationStore {
|
|
|
14608
14745
|
if (signal?.aborted) {
|
|
14609
14746
|
throw new Error("Operation aborted");
|
|
14610
14747
|
}
|
|
14611
|
-
let query = this.
|
|
14748
|
+
let query = this.queryExecutor.selectFrom("Operation").selectAll().where("documentId", "=", documentId).where("scope", "=", scope).where("branch", "=", branch).where("timestampUtcMs", ">=", new Date(minTimestamp)).orderBy("index", "asc");
|
|
14612
14749
|
if (paging) {
|
|
14613
14750
|
const cursorValue = Number.parseInt(paging.cursor, 10);
|
|
14614
14751
|
if (cursorValue > 0) {
|
|
@@ -14640,7 +14777,7 @@ class KyselyOperationStore {
|
|
|
14640
14777
|
if (signal?.aborted) {
|
|
14641
14778
|
throw new Error("Operation aborted");
|
|
14642
14779
|
}
|
|
14643
|
-
const scopeRevisions = await this.
|
|
14780
|
+
const scopeRevisions = await this.queryExecutor.selectFrom("Operation as o1").select(["o1.scope", "o1.index", "o1.timestampUtcMs"]).where("o1.documentId", "=", documentId).where("o1.branch", "=", branch).where((eb) => eb("o1.index", "=", eb.selectFrom("Operation as o2").select((eb2) => eb2.fn.max("o2.index").as("maxIndex")).where("o2.documentId", "=", eb.ref("o1.documentId")).where("o2.branch", "=", eb.ref("o1.branch")).where("o2.scope", "=", eb.ref("o1.scope")))).execute();
|
|
14644
14781
|
const revision = {};
|
|
14645
14782
|
let latestTimestamp = new Date(0).toISOString();
|
|
14646
14783
|
for (const row of scopeRevisions) {
|
|
@@ -18434,9 +18571,10 @@ class ReactorBuilder {
|
|
|
18434
18571
|
});
|
|
18435
18572
|
await documentMetaCache.startup();
|
|
18436
18573
|
const collectionMembershipCache = new CollectionMembershipCache(operationIndex);
|
|
18574
|
+
const executionScope = new KyselyExecutionScope(database, operationStore, operationIndex, keyframeStore, writeCache, documentMetaCache, collectionMembershipCache);
|
|
18437
18575
|
let executorManager = this.executorManager;
|
|
18438
18576
|
if (!executorManager) {
|
|
18439
|
-
executorManager = new SimpleJobExecutorManager(() => new SimpleJobExecutor(this.logger, documentModelRegistry, operationStore, eventBus, writeCache, operationIndex, documentMetaCache, collectionMembershipCache, this.executorConfig, this.signatureVerifier), eventBus, queue, jobTracker, this.logger, resolver);
|
|
18577
|
+
executorManager = new SimpleJobExecutorManager(() => new SimpleJobExecutor(this.logger, documentModelRegistry, operationStore, eventBus, writeCache, operationIndex, documentMetaCache, collectionMembershipCache, this.executorConfig, this.signatureVerifier, executionScope), eventBus, queue, jobTracker, this.logger, resolver);
|
|
18440
18578
|
}
|
|
18441
18579
|
await executorManager.start(this.executorConfig.maxConcurrency ?? 1);
|
|
18442
18580
|
const readModelInstances = Array.from(new Set([...this.readModels]));
|
|
@@ -18567,6 +18705,7 @@ class ReactorClientBuilder {
|
|
|
18567
18705
|
signatureVerifier;
|
|
18568
18706
|
subscriptionManager;
|
|
18569
18707
|
jobAwaiter;
|
|
18708
|
+
documentModelLoader;
|
|
18570
18709
|
withLogger(logger2) {
|
|
18571
18710
|
this.logger = logger2;
|
|
18572
18711
|
return this;
|
|
@@ -18605,6 +18744,10 @@ class ReactorClientBuilder {
|
|
|
18605
18744
|
this.jobAwaiter = jobAwaiter;
|
|
18606
18745
|
return this;
|
|
18607
18746
|
}
|
|
18747
|
+
withDocumentModelLoader(loader) {
|
|
18748
|
+
this.documentModelLoader = loader;
|
|
18749
|
+
return this;
|
|
18750
|
+
}
|
|
18608
18751
|
async build() {
|
|
18609
18752
|
const module = await this.buildModule();
|
|
18610
18753
|
return module.client;
|
|
@@ -18622,6 +18765,9 @@ class ReactorClientBuilder {
|
|
|
18622
18765
|
if (this.signatureVerifier) {
|
|
18623
18766
|
this.reactorBuilder.withSignatureVerifier(this.signatureVerifier);
|
|
18624
18767
|
}
|
|
18768
|
+
if (this.documentModelLoader) {
|
|
18769
|
+
this.reactorBuilder.withDocumentModelLoader(this.documentModelLoader);
|
|
18770
|
+
}
|
|
18625
18771
|
reactorModule = await this.reactorBuilder.buildModule();
|
|
18626
18772
|
reactor = reactorModule.reactor;
|
|
18627
18773
|
eventBus = reactorModule.eventBus;
|
|
@@ -24082,6 +24228,7 @@ __export(exports_src, {
|
|
|
24082
24228
|
useVetraPackages: () => useVetraPackages,
|
|
24083
24229
|
useVetraPackageManager: () => useVetraPackageManager,
|
|
24084
24230
|
useUserPermissions: () => useUserPermissions,
|
|
24231
|
+
useUser: () => useUser,
|
|
24085
24232
|
useSupportedDocumentTypesInReactor: () => useSupportedDocumentTypesInReactor,
|
|
24086
24233
|
useSubgraphModules: () => useSubgraphModules,
|
|
24087
24234
|
useSetPHDriveEditorConfig: () => useSetPHDriveEditorConfig,
|
|
@@ -24100,8 +24247,12 @@ __export(exports_src, {
|
|
|
24100
24247
|
useSelectedDocumentId: () => useSelectedDocumentId,
|
|
24101
24248
|
useSelectedDocument: () => useSelectedDocument,
|
|
24102
24249
|
useRevisionHistoryVisible: () => useRevisionHistoryVisible,
|
|
24250
|
+
useRenownInit: () => useRenownInit,
|
|
24251
|
+
useRenownAuth: () => useRenownAuth,
|
|
24252
|
+
useRenown: () => useRenown,
|
|
24103
24253
|
useRelationalQuery: () => useRelationalQuery,
|
|
24104
24254
|
useRelationalDb: () => useRelationalDb,
|
|
24255
|
+
usePendingInstallations: () => usePendingInstallations,
|
|
24105
24256
|
useParentFolderForSelectedNode: () => useParentFolderForSelectedNode,
|
|
24106
24257
|
usePHToast: () => usePHToast,
|
|
24107
24258
|
usePHModal: () => usePHModal,
|
|
@@ -24117,6 +24268,8 @@ __export(exports_src, {
|
|
|
24117
24268
|
useNodeParentFolderById: () => useNodeParentFolderById,
|
|
24118
24269
|
useNodeById: () => useNodeById,
|
|
24119
24270
|
useNodeActions: () => useNodeActions,
|
|
24271
|
+
useLoginStatus: () => useLoginStatus,
|
|
24272
|
+
useLoading: () => useLoading,
|
|
24120
24273
|
useIsExternalControlsEnabled: () => useIsExternalControlsEnabled,
|
|
24121
24274
|
useIsDragAndDropEnabled: () => useIsDragAndDropEnabled,
|
|
24122
24275
|
useInspectorEnabled: () => useInspectorEnabled,
|
|
@@ -24152,6 +24305,8 @@ __export(exports_src, {
|
|
|
24152
24305
|
useDocumentCache: () => useDocumentCache,
|
|
24153
24306
|
useDocumentById: () => useDocumentById,
|
|
24154
24307
|
useDocument: () => useDocument,
|
|
24308
|
+
useDismissedPackages: () => useDismissedPackages,
|
|
24309
|
+
useDid: () => useDid,
|
|
24155
24310
|
useDefaultDriveEditorModule: () => useDefaultDriveEditorModule,
|
|
24156
24311
|
useConnectionStates: () => useConnectionStates,
|
|
24157
24312
|
useConnectionState: () => useConnectionState,
|
|
@@ -24176,6 +24331,7 @@ __export(exports_src, {
|
|
|
24176
24331
|
setPHDriveEditorConfig: () => setPHDriveEditorConfig,
|
|
24177
24332
|
setPHDocumentEditorConfigByKey: () => setPHDocumentEditorConfigByKey,
|
|
24178
24333
|
setPHDocumentEditorConfig: () => setPHDocumentEditorConfig,
|
|
24334
|
+
setLoading: () => setLoading,
|
|
24179
24335
|
setGlobal: () => setGlobal,
|
|
24180
24336
|
setFeatures: () => setFeatures,
|
|
24181
24337
|
setDriveSharingType: () => setDriveSharingType,
|
|
@@ -24195,6 +24351,7 @@ __export(exports_src, {
|
|
|
24195
24351
|
makeDriveUrlComponent: () => makeDriveUrlComponent,
|
|
24196
24352
|
logout: () => logout,
|
|
24197
24353
|
login: () => login,
|
|
24354
|
+
loading: () => loading,
|
|
24198
24355
|
isInspectorEnabledSync: () => isInspectorEnabledSync,
|
|
24199
24356
|
isFolderNodeKind: () => isFolderNodeKind,
|
|
24200
24357
|
isFileNodeKind: () => isFileNodeKind,
|
|
@@ -24243,6 +24400,7 @@ __export(exports_src, {
|
|
|
24243
24400
|
baseDocumentModelsMap: () => baseDocumentModelsMap,
|
|
24244
24401
|
baseDocumentModels: () => baseDocumentModels,
|
|
24245
24402
|
addTrigger: () => addTrigger,
|
|
24403
|
+
addRenownEventHandler: () => addRenownEventHandler,
|
|
24246
24404
|
addRemoteDrive: () => addRemoteDrive,
|
|
24247
24405
|
addPromiseState: () => addPromiseState,
|
|
24248
24406
|
addFolder: () => addFolder,
|
|
@@ -24254,10 +24412,10 @@ __export(exports_src, {
|
|
|
24254
24412
|
SyncOperationStatus: () => SyncOperationStatus,
|
|
24255
24413
|
SpinnerIcon: () => SpinnerIcon,
|
|
24256
24414
|
RenownUserButton: () => RenownUserButton,
|
|
24257
|
-
RenownProvider: () => RenownProvider,
|
|
24258
24415
|
RenownLogo: () => RenownLogo,
|
|
24259
24416
|
RenownLoginButton: () => RenownLoginButton,
|
|
24260
24417
|
RenownAuthButton: () => RenownAuthButton,
|
|
24418
|
+
Renown: () => Renown2,
|
|
24261
24419
|
RemoteDocumentController: () => RemoteDocumentController,
|
|
24262
24420
|
RemoteClient: () => RemoteClient,
|
|
24263
24421
|
RelationalDbProcessor: () => RelationalDbProcessor,
|
|
@@ -24275,7 +24433,6 @@ __export(exports_src, {
|
|
|
24275
24433
|
InMemoryQueue: () => InMemoryQueue,
|
|
24276
24434
|
ISSUER_TYPE: () => ISSUER_TYPE,
|
|
24277
24435
|
GqlRequestChannel: () => GqlRequestChannel,
|
|
24278
|
-
ExternalLinkIcon: () => ExternalLinkIcon,
|
|
24279
24436
|
DocumentChangeType: () => DocumentChangeType,
|
|
24280
24437
|
DocumentCache: () => DocumentCache,
|
|
24281
24438
|
DisconnectIcon: () => DisconnectIcon,
|
|
@@ -24284,6 +24441,7 @@ __export(exports_src, {
|
|
|
24284
24441
|
CopyIcon: () => CopyIcon,
|
|
24285
24442
|
ConsoleLogger: () => ConsoleLogger,
|
|
24286
24443
|
ConflictError: () => ConflictError,
|
|
24444
|
+
ChevronDownIcon: () => ChevronDownIcon,
|
|
24287
24445
|
ChannelScheme: () => ChannelScheme,
|
|
24288
24446
|
CREDENTIAL_TYPES: () => CREDENTIAL_TYPES,
|
|
24289
24447
|
CREDENTIAL_SUBJECT_TYPE: () => CREDENTIAL_SUBJECT_TYPE,
|
|
@@ -24323,17 +24481,20 @@ import {
|
|
|
24323
24481
|
setSharingType
|
|
24324
24482
|
} from "document-drive";
|
|
24325
24483
|
import { documentModelDocumentModelModule } from "document-model";
|
|
24484
|
+
import { useCallback } from "react";
|
|
24485
|
+
import { useEffect, useState, useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
24326
24486
|
import { useSyncExternalStore } from "react";
|
|
24327
|
-
import { useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
24328
|
-
import { useEffect, useRef, useState } from "react";
|
|
24329
24487
|
import { logger as logger5 } from "document-drive";
|
|
24330
|
-
import {
|
|
24488
|
+
import { useSyncExternalStore as useSyncExternalStore3 } from "react";
|
|
24489
|
+
import { logger as logger6 } from "document-drive";
|
|
24490
|
+
import { use, useCallback as useCallback2, useSyncExternalStore as useSyncExternalStore4 } from "react";
|
|
24331
24491
|
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
24492
|
+
import { useEffect as useEffect3, useRef, useState as useState3 } from "react";
|
|
24332
24493
|
import {
|
|
24333
24494
|
DocumentModelNotFoundError,
|
|
24334
24495
|
DocumentNotFoundError as DocumentNotFoundError2
|
|
24335
24496
|
} from "document-drive";
|
|
24336
|
-
import { useCallback as
|
|
24497
|
+
import { useCallback as useCallback4, useEffect as useEffect4, useRef as useRef2, useState as useState4 } from "react";
|
|
24337
24498
|
import { isFileNode as isFileNode2 } from "document-drive";
|
|
24338
24499
|
import { useMemo } from "react";
|
|
24339
24500
|
import {
|
|
@@ -24343,20 +24504,24 @@ import {
|
|
|
24343
24504
|
} from "document-model";
|
|
24344
24505
|
import { createState } from "document-model";
|
|
24345
24506
|
import { defaultBaseState as defaultBaseState2, generateId as generateId22 } from "document-model/core";
|
|
24346
|
-
import { logger as logger6 } from "document-drive";
|
|
24347
|
-
import { useEffect as useEffect4, useState as useState4 } from "react";
|
|
24348
24507
|
import { useEffect as useEffect5, useState as useState5 } from "react";
|
|
24349
24508
|
import { createRelationalDbLegacy } from "document-drive";
|
|
24350
24509
|
import { useMemo as useMemo2 } from "react";
|
|
24351
24510
|
import { useEffect as useEffect6, useRef as useRef3, useState as useState6 } from "react";
|
|
24352
|
-
import { useCallback as
|
|
24353
|
-
import { useCallback as
|
|
24511
|
+
import { useCallback as useCallback5, useMemo as useMemo3, useRef as useRef4 } from "react";
|
|
24512
|
+
import { useCallback as useCallback6, useState as useState7 } from "react";
|
|
24354
24513
|
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
24514
|
+
import {
|
|
24515
|
+
Children,
|
|
24516
|
+
cloneElement,
|
|
24517
|
+
forwardRef,
|
|
24518
|
+
isValidElement
|
|
24519
|
+
} from "react";
|
|
24355
24520
|
import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
|
|
24356
|
-
import { useCallback as
|
|
24521
|
+
import { useCallback as useCallback7, useEffect as useEffect7, useRef as useRef5, useState as useState8 } from "react";
|
|
24357
24522
|
import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
|
|
24358
|
-
import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
|
|
24359
|
-
import {
|
|
24523
|
+
import { jsxDEV as jsxDEV4, Fragment } from "react/jsx-dev-runtime";
|
|
24524
|
+
import { useRef as useRef6 } from "react";
|
|
24360
24525
|
function asUint8Array(buf) {
|
|
24361
24526
|
if (globalThis.Buffer != null) {
|
|
24362
24527
|
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
@@ -27707,38 +27872,61 @@ function makePHEventFunctions(key) {
|
|
|
27707
27872
|
const setEventName = `ph:set${capitalCase(key)}`;
|
|
27708
27873
|
const updateEventName = `ph:${key}Updated`;
|
|
27709
27874
|
function setValue(value) {
|
|
27875
|
+
if (isServer) {
|
|
27876
|
+
return;
|
|
27877
|
+
}
|
|
27710
27878
|
const event = new CustomEvent(setEventName, {
|
|
27711
27879
|
detail: { [key]: value }
|
|
27712
27880
|
});
|
|
27713
27881
|
window.dispatchEvent(event);
|
|
27714
27882
|
}
|
|
27715
27883
|
function dispatchUpdatedEvent() {
|
|
27884
|
+
if (isServer) {
|
|
27885
|
+
return;
|
|
27886
|
+
}
|
|
27716
27887
|
const event = new CustomEvent(updateEventName);
|
|
27717
27888
|
window.dispatchEvent(event);
|
|
27718
27889
|
}
|
|
27719
27890
|
function handleSetValueEvent(event) {
|
|
27891
|
+
if (isServer) {
|
|
27892
|
+
return;
|
|
27893
|
+
}
|
|
27720
27894
|
const value = event.detail[key];
|
|
27721
|
-
if (!window.ph)
|
|
27722
|
-
|
|
27895
|
+
if (!window.ph) {
|
|
27896
|
+
window.ph = {};
|
|
27897
|
+
}
|
|
27723
27898
|
window.ph[key] = value;
|
|
27724
27899
|
dispatchUpdatedEvent();
|
|
27725
27900
|
}
|
|
27726
27901
|
function addEventHandler() {
|
|
27902
|
+
if (isServer) {
|
|
27903
|
+
return;
|
|
27904
|
+
}
|
|
27727
27905
|
window.addEventListener(setEventName, handleSetValueEvent);
|
|
27728
27906
|
}
|
|
27729
27907
|
function subscribeToValue(onStoreChange) {
|
|
27908
|
+
if (isServer)
|
|
27909
|
+
return () => {};
|
|
27730
27910
|
window.addEventListener(updateEventName, onStoreChange);
|
|
27731
27911
|
return () => {
|
|
27732
27912
|
window.removeEventListener(updateEventName, onStoreChange);
|
|
27733
27913
|
};
|
|
27734
27914
|
}
|
|
27735
27915
|
function getSnapshot() {
|
|
27736
|
-
if (
|
|
27737
|
-
|
|
27916
|
+
if (isServer) {
|
|
27917
|
+
return;
|
|
27918
|
+
}
|
|
27919
|
+
if (!window.ph) {
|
|
27920
|
+
console.warn(`ph global store is not initialized. Did you call set${capitalCase(key)}?`);
|
|
27921
|
+
return;
|
|
27922
|
+
}
|
|
27738
27923
|
return window.ph[key];
|
|
27739
27924
|
}
|
|
27925
|
+
function getServerSnapshot() {
|
|
27926
|
+
return;
|
|
27927
|
+
}
|
|
27740
27928
|
function useValue() {
|
|
27741
|
-
return useSyncExternalStore(subscribeToValue, getSnapshot);
|
|
27929
|
+
return useSyncExternalStore(subscribeToValue, getSnapshot, getServerSnapshot);
|
|
27742
27930
|
}
|
|
27743
27931
|
return {
|
|
27744
27932
|
useValue,
|
|
@@ -27746,6 +27934,138 @@ function makePHEventFunctions(key) {
|
|
|
27746
27934
|
addEventHandler
|
|
27747
27935
|
};
|
|
27748
27936
|
}
|
|
27937
|
+
function useDid() {
|
|
27938
|
+
const renown = useRenown();
|
|
27939
|
+
return renown?.did;
|
|
27940
|
+
}
|
|
27941
|
+
function useUser() {
|
|
27942
|
+
const renown = useRenown();
|
|
27943
|
+
const [user, setUser] = useState(renown?.user);
|
|
27944
|
+
useEffect(() => {
|
|
27945
|
+
setUser(renown?.user);
|
|
27946
|
+
if (!renown)
|
|
27947
|
+
return;
|
|
27948
|
+
return renown.on("user", setUser);
|
|
27949
|
+
}, [renown]);
|
|
27950
|
+
return user;
|
|
27951
|
+
}
|
|
27952
|
+
function useLoginStatus() {
|
|
27953
|
+
const renown = useRenown();
|
|
27954
|
+
return useSyncExternalStore2((cb) => {
|
|
27955
|
+
if (!renown) {
|
|
27956
|
+
return () => {};
|
|
27957
|
+
}
|
|
27958
|
+
return renown.on("status", cb);
|
|
27959
|
+
}, () => renown === loading ? "loading" : renown?.status, () => {
|
|
27960
|
+
return;
|
|
27961
|
+
});
|
|
27962
|
+
}
|
|
27963
|
+
function openRenown(documentId) {
|
|
27964
|
+
const renown = window.ph?.renown;
|
|
27965
|
+
let renownUrl = renown?.baseUrl;
|
|
27966
|
+
if (!renownUrl) {
|
|
27967
|
+
logger5.warn("Renown instance not found, falling back to: ", RENOWN_URL);
|
|
27968
|
+
renownUrl = RENOWN_URL;
|
|
27969
|
+
}
|
|
27970
|
+
if (documentId) {
|
|
27971
|
+
window.open(`${renownUrl}/profile/${documentId}`, "_blank")?.focus();
|
|
27972
|
+
return;
|
|
27973
|
+
}
|
|
27974
|
+
const url = new URL(renownUrl);
|
|
27975
|
+
url.searchParams.set("app", renown?.did ?? "");
|
|
27976
|
+
url.searchParams.set("connect", renown?.did ?? "");
|
|
27977
|
+
url.searchParams.set("network", RENOWN_NETWORK_ID);
|
|
27978
|
+
url.searchParams.set("chain", RENOWN_CHAIN_ID);
|
|
27979
|
+
const returnUrl = new URL(window.location.pathname, window.location.origin);
|
|
27980
|
+
url.searchParams.set("returnUrl", returnUrl.toJSON());
|
|
27981
|
+
window.open(url, "_self")?.focus();
|
|
27982
|
+
}
|
|
27983
|
+
function consumeDidFromUrl() {
|
|
27984
|
+
if (typeof window === "undefined")
|
|
27985
|
+
return;
|
|
27986
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
27987
|
+
const userParam = urlParams.get("user");
|
|
27988
|
+
if (!userParam)
|
|
27989
|
+
return;
|
|
27990
|
+
const userDid = decodeURIComponent(userParam);
|
|
27991
|
+
const cleanUrl = new URL(window.location.href);
|
|
27992
|
+
cleanUrl.searchParams.delete("user");
|
|
27993
|
+
window.history.replaceState({}, "", cleanUrl.toString());
|
|
27994
|
+
return userDid;
|
|
27995
|
+
}
|
|
27996
|
+
async function login(userDid, renown) {
|
|
27997
|
+
if (!renown) {
|
|
27998
|
+
return;
|
|
27999
|
+
}
|
|
28000
|
+
const did = userDid ?? consumeDidFromUrl();
|
|
28001
|
+
try {
|
|
28002
|
+
const user = renown.user;
|
|
28003
|
+
if (user?.did && (user.did === did || !did)) {
|
|
28004
|
+
return user;
|
|
28005
|
+
}
|
|
28006
|
+
if (!did) {
|
|
28007
|
+
return;
|
|
28008
|
+
}
|
|
28009
|
+
return await renown.login(did);
|
|
28010
|
+
} catch (error) {
|
|
28011
|
+
logger5.error(error instanceof Error ? error.message : JSON.stringify(error));
|
|
28012
|
+
}
|
|
28013
|
+
}
|
|
28014
|
+
async function logout() {
|
|
28015
|
+
const renown = window.ph?.renown;
|
|
28016
|
+
await renown?.logout();
|
|
28017
|
+
const url = new URL(window.location.href);
|
|
28018
|
+
if (url.searchParams.has("user")) {
|
|
28019
|
+
url.searchParams.delete("user");
|
|
28020
|
+
window.history.replaceState(null, "", url.toString());
|
|
28021
|
+
}
|
|
28022
|
+
}
|
|
28023
|
+
function truncateAddress(address) {
|
|
28024
|
+
if (address.length <= 13)
|
|
28025
|
+
return address;
|
|
28026
|
+
return `${address.slice(0, 7)}...${address.slice(-5)}`;
|
|
28027
|
+
}
|
|
28028
|
+
function toRenownAuthStatus(loginStatus, user) {
|
|
28029
|
+
if (loginStatus === "authorized") {
|
|
28030
|
+
return user ? "authorized" : "checking";
|
|
28031
|
+
}
|
|
28032
|
+
return loginStatus;
|
|
28033
|
+
}
|
|
28034
|
+
function useRenownAuth() {
|
|
28035
|
+
const user = useUser();
|
|
28036
|
+
const loginStatus = useLoginStatus();
|
|
28037
|
+
const status = toRenownAuthStatus(loginStatus, user);
|
|
28038
|
+
const address = user?.address;
|
|
28039
|
+
const ensName = user?.ens?.name;
|
|
28040
|
+
const avatarUrl = user?.profile?.userImage ?? user?.ens?.avatarUrl;
|
|
28041
|
+
const profileId = user?.profile?.documentId;
|
|
28042
|
+
const displayName = ensName ?? user?.profile?.username ?? undefined;
|
|
28043
|
+
const displayAddress = address ? truncateAddress(address) : undefined;
|
|
28044
|
+
const login2 = useCallback(() => {
|
|
28045
|
+
openRenown();
|
|
28046
|
+
}, []);
|
|
28047
|
+
const logout2 = useCallback(async () => {
|
|
28048
|
+
await logout();
|
|
28049
|
+
}, []);
|
|
28050
|
+
const openProfile = useCallback(() => {
|
|
28051
|
+
if (profileId) {
|
|
28052
|
+
openRenown(profileId);
|
|
28053
|
+
}
|
|
28054
|
+
}, [profileId]);
|
|
28055
|
+
return {
|
|
28056
|
+
status,
|
|
28057
|
+
user,
|
|
28058
|
+
address,
|
|
28059
|
+
ensName,
|
|
28060
|
+
avatarUrl,
|
|
28061
|
+
profileId,
|
|
28062
|
+
displayName,
|
|
28063
|
+
displayAddress,
|
|
28064
|
+
login: login2,
|
|
28065
|
+
logout: logout2,
|
|
28066
|
+
openProfile
|
|
28067
|
+
};
|
|
28068
|
+
}
|
|
27749
28069
|
function useAllowedDocumentTypes() {
|
|
27750
28070
|
const definedAllowedDocumentTypes = allowedDocumentTypesEventFunctions.useValue();
|
|
27751
28071
|
return definedAllowedDocumentTypes;
|
|
@@ -27757,6 +28077,14 @@ function setVetraPackageManager(packageManager) {
|
|
|
27757
28077
|
updateReactorClientDocumentModels(packages);
|
|
27758
28078
|
});
|
|
27759
28079
|
}
|
|
28080
|
+
function usePendingInstallations() {
|
|
28081
|
+
const pm = useVetraPackageManager();
|
|
28082
|
+
return useSyncExternalStore3((cb) => pm ? pm.subscribePendingChanges(cb) : NOOP_UNSUBSCRIBE, () => pm?.getPendingInstallations() ?? EMPTY_PENDING);
|
|
28083
|
+
}
|
|
28084
|
+
function useDismissedPackages() {
|
|
28085
|
+
const pm = useVetraPackageManager();
|
|
28086
|
+
return useSyncExternalStore3((cb) => pm ? pm.subscribePendingChanges(cb) : NOOP_UNSUBSCRIBE, () => pm?.getDismissedPackages() ?? EMPTY_DISMISSED);
|
|
28087
|
+
}
|
|
27760
28088
|
function updateReactorClientDocumentModels(packages) {
|
|
27761
28089
|
const documentModelModules = packages.flatMap((pkg) => pkg.modules.documentModelModules).filter((module) => module !== undefined);
|
|
27762
28090
|
const registry = window.ph?.reactorClientModule?.reactorModule?.documentModelRegistry;
|
|
@@ -27788,52 +28116,6 @@ function useAllowedDocumentModelModules() {
|
|
|
27788
28116
|
return documentModelModules;
|
|
27789
28117
|
return documentModelModules?.filter((module) => allowedDocumentTypes.includes(module.documentModel.global.id));
|
|
27790
28118
|
}
|
|
27791
|
-
function useConnectionStates() {
|
|
27792
|
-
const syncManager = useSync();
|
|
27793
|
-
const [states, setStates] = useState(() => buildSnapshot(syncManager));
|
|
27794
|
-
const unsubscribesRef = useRef([]);
|
|
27795
|
-
useEffect(() => {
|
|
27796
|
-
if (!syncManager)
|
|
27797
|
-
return;
|
|
27798
|
-
function subscribe() {
|
|
27799
|
-
for (const unsub of unsubscribesRef.current) {
|
|
27800
|
-
unsub();
|
|
27801
|
-
}
|
|
27802
|
-
unsubscribesRef.current = [];
|
|
27803
|
-
const remotes = syncManager.list();
|
|
27804
|
-
for (const remote of remotes) {
|
|
27805
|
-
const unsub = remote.channel.onConnectionStateChange(() => {
|
|
27806
|
-
setStates(buildSnapshot(syncManager));
|
|
27807
|
-
});
|
|
27808
|
-
unsubscribesRef.current.push(unsub);
|
|
27809
|
-
}
|
|
27810
|
-
setStates(buildSnapshot(syncManager));
|
|
27811
|
-
}
|
|
27812
|
-
subscribe();
|
|
27813
|
-
const interval = setInterval(subscribe, 5000);
|
|
27814
|
-
return () => {
|
|
27815
|
-
clearInterval(interval);
|
|
27816
|
-
for (const unsub of unsubscribesRef.current) {
|
|
27817
|
-
unsub();
|
|
27818
|
-
}
|
|
27819
|
-
unsubscribesRef.current = [];
|
|
27820
|
-
};
|
|
27821
|
-
}, [syncManager]);
|
|
27822
|
-
return states;
|
|
27823
|
-
}
|
|
27824
|
-
function useConnectionState(remoteName) {
|
|
27825
|
-
const states = useConnectionStates();
|
|
27826
|
-
return states.get(remoteName);
|
|
27827
|
-
}
|
|
27828
|
-
function buildSnapshot(syncManager) {
|
|
27829
|
-
const map = new Map;
|
|
27830
|
-
if (!syncManager)
|
|
27831
|
-
return map;
|
|
27832
|
-
for (const remote of syncManager.list()) {
|
|
27833
|
-
map.set(remote.name, remote.channel.getConnectionState());
|
|
27834
|
-
}
|
|
27835
|
-
return map;
|
|
27836
|
-
}
|
|
27837
28119
|
function sortNodesByName(nodes) {
|
|
27838
28120
|
return nodes.toSorted((a, b) => a.name.localeCompare(b.name));
|
|
27839
28121
|
}
|
|
@@ -27849,7 +28131,7 @@ function isFolderNodeKind(node) {
|
|
|
27849
28131
|
}
|
|
27850
28132
|
function useDispatch(document2) {
|
|
27851
28133
|
function dispatch(actionOrActions, onErrors, onSuccess) {
|
|
27852
|
-
dispatchActions(actionOrActions, document2, onErrors, onSuccess).catch(
|
|
28134
|
+
dispatchActions(actionOrActions, document2, onErrors, onSuccess).catch(logger6.error);
|
|
27853
28135
|
}
|
|
27854
28136
|
return [document2, dispatch];
|
|
27855
28137
|
}
|
|
@@ -27881,12 +28163,12 @@ function getDocumentQueryState(promise) {
|
|
|
27881
28163
|
}
|
|
27882
28164
|
function useDocument(id) {
|
|
27883
28165
|
const documentCache = useDocumentCache();
|
|
27884
|
-
const document2 =
|
|
28166
|
+
const document2 = useSyncExternalStore4((cb) => id && documentCache ? documentCache.subscribe(id, cb) : () => {}, () => id ? documentCache?.get(id) : undefined);
|
|
27885
28167
|
return document2 ? use(document2) : undefined;
|
|
27886
28168
|
}
|
|
27887
28169
|
function useDocuments(ids) {
|
|
27888
28170
|
const documentCache = useDocumentCache();
|
|
27889
|
-
const documents =
|
|
28171
|
+
const documents = useSyncExternalStore4((cb) => ids?.length && documentCache ? documentCache.subscribe(ids, cb) : () => {}, () => ids?.length && documentCache ? documentCache.getBatch(ids) : undefined);
|
|
27890
28172
|
return documents ? use(documents) : [];
|
|
27891
28173
|
}
|
|
27892
28174
|
function useGetDocument() {
|
|
@@ -28227,6 +28509,52 @@ function usePHDocumentEditorConfigByKey(key) {
|
|
|
28227
28509
|
const useValueHook = phDocumentEditorConfigHooks[key];
|
|
28228
28510
|
return useValueHook();
|
|
28229
28511
|
}
|
|
28512
|
+
function useConnectionStates() {
|
|
28513
|
+
const syncManager = useSync();
|
|
28514
|
+
const [states, setStates] = useState3(() => buildSnapshot(syncManager));
|
|
28515
|
+
const unsubscribesRef = useRef([]);
|
|
28516
|
+
useEffect3(() => {
|
|
28517
|
+
if (!syncManager)
|
|
28518
|
+
return;
|
|
28519
|
+
function subscribe() {
|
|
28520
|
+
for (const unsub of unsubscribesRef.current) {
|
|
28521
|
+
unsub();
|
|
28522
|
+
}
|
|
28523
|
+
unsubscribesRef.current = [];
|
|
28524
|
+
const remotes = syncManager.list();
|
|
28525
|
+
for (const remote of remotes) {
|
|
28526
|
+
const unsub = remote.channel.onConnectionStateChange(() => {
|
|
28527
|
+
setStates(buildSnapshot(syncManager));
|
|
28528
|
+
});
|
|
28529
|
+
unsubscribesRef.current.push(unsub);
|
|
28530
|
+
}
|
|
28531
|
+
setStates(buildSnapshot(syncManager));
|
|
28532
|
+
}
|
|
28533
|
+
subscribe();
|
|
28534
|
+
const interval = setInterval(subscribe, 5000);
|
|
28535
|
+
return () => {
|
|
28536
|
+
clearInterval(interval);
|
|
28537
|
+
for (const unsub of unsubscribesRef.current) {
|
|
28538
|
+
unsub();
|
|
28539
|
+
}
|
|
28540
|
+
unsubscribesRef.current = [];
|
|
28541
|
+
};
|
|
28542
|
+
}, [syncManager]);
|
|
28543
|
+
return states;
|
|
28544
|
+
}
|
|
28545
|
+
function useConnectionState(remoteName) {
|
|
28546
|
+
const states = useConnectionStates();
|
|
28547
|
+
return states.get(remoteName);
|
|
28548
|
+
}
|
|
28549
|
+
function buildSnapshot(syncManager) {
|
|
28550
|
+
const map = new Map;
|
|
28551
|
+
if (!syncManager)
|
|
28552
|
+
return map;
|
|
28553
|
+
for (const remote of syncManager.list()) {
|
|
28554
|
+
map.set(remote.name, remote.channel.getConnectionState());
|
|
28555
|
+
}
|
|
28556
|
+
return map;
|
|
28557
|
+
}
|
|
28230
28558
|
function useDocumentOfType(documentId, documentType) {
|
|
28231
28559
|
const [document2, dispatch] = useDocumentById(documentId);
|
|
28232
28560
|
const documentModelModule = useDocumentModelModuleById(documentType);
|
|
@@ -28246,13 +28574,13 @@ function useDocumentOfType(documentId, documentType) {
|
|
|
28246
28574
|
function useDocumentOperations(documentId) {
|
|
28247
28575
|
const reactorClient = useReactorClient();
|
|
28248
28576
|
const hasFetchedRef = useRef2(false);
|
|
28249
|
-
const [state, setState] =
|
|
28577
|
+
const [state, setState] = useState4(() => ({
|
|
28250
28578
|
globalOperations: [],
|
|
28251
28579
|
localOperations: [],
|
|
28252
28580
|
isLoading: !!documentId,
|
|
28253
28581
|
error: undefined
|
|
28254
28582
|
}));
|
|
28255
|
-
const fetchOperations =
|
|
28583
|
+
const fetchOperations = useCallback4(async (retryCount = 0) => {
|
|
28256
28584
|
const MAX_RETRIES = 5;
|
|
28257
28585
|
const RETRY_DELAY_MS = 500;
|
|
28258
28586
|
if (!documentId || !reactorClient) {
|
|
@@ -28298,7 +28626,7 @@ function useDocumentOperations(documentId) {
|
|
|
28298
28626
|
});
|
|
28299
28627
|
hasFetchedRef.current = true;
|
|
28300
28628
|
}, [documentId, reactorClient]);
|
|
28301
|
-
|
|
28629
|
+
useEffect4(() => {
|
|
28302
28630
|
if (documentId && reactorClient) {
|
|
28303
28631
|
fetchOperations();
|
|
28304
28632
|
} else if (!documentId) {
|
|
@@ -28311,7 +28639,7 @@ function useDocumentOperations(documentId) {
|
|
|
28311
28639
|
hasFetchedRef.current = false;
|
|
28312
28640
|
}
|
|
28313
28641
|
}, [documentId, reactorClient, fetchOperations]);
|
|
28314
|
-
const refetch =
|
|
28642
|
+
const refetch = useCallback4(() => {
|
|
28315
28643
|
fetchOperations(0);
|
|
28316
28644
|
}, [fetchOperations]);
|
|
28317
28645
|
return { ...state, refetch };
|
|
@@ -28758,81 +29086,6 @@ function makeVetraPackageManifestModulesEntry(modules) {
|
|
|
28758
29086
|
return acc;
|
|
28759
29087
|
}, {});
|
|
28760
29088
|
}
|
|
28761
|
-
function openRenown(documentId) {
|
|
28762
|
-
if (documentId) {
|
|
28763
|
-
window.open(`${RENOWN_URL}/profile/${documentId}`, "_blank")?.focus();
|
|
28764
|
-
return;
|
|
28765
|
-
}
|
|
28766
|
-
const url = new URL(RENOWN_URL);
|
|
28767
|
-
url.searchParams.set("connect", window.ph?.renown?.did ?? "");
|
|
28768
|
-
url.searchParams.set("network", RENOWN_NETWORK_ID);
|
|
28769
|
-
url.searchParams.set("chain", RENOWN_CHAIN_ID);
|
|
28770
|
-
const returnUrl = new URL(window.location.pathname, window.location.origin);
|
|
28771
|
-
url.searchParams.set("returnUrl", returnUrl.toJSON());
|
|
28772
|
-
window.open(url, "_self")?.focus();
|
|
28773
|
-
}
|
|
28774
|
-
function consumeDidFromUrl() {
|
|
28775
|
-
if (typeof window === "undefined")
|
|
28776
|
-
return;
|
|
28777
|
-
const urlParams = new URLSearchParams(window.location.search);
|
|
28778
|
-
const userParam = urlParams.get("user");
|
|
28779
|
-
if (!userParam)
|
|
28780
|
-
return;
|
|
28781
|
-
const userDid = decodeURIComponent(userParam);
|
|
28782
|
-
const cleanUrl = new URL(window.location.href);
|
|
28783
|
-
cleanUrl.searchParams.delete("user");
|
|
28784
|
-
window.history.replaceState({}, "", cleanUrl.toString());
|
|
28785
|
-
return userDid;
|
|
28786
|
-
}
|
|
28787
|
-
async function login(userDid, renown) {
|
|
28788
|
-
if (!renown) {
|
|
28789
|
-
return;
|
|
28790
|
-
}
|
|
28791
|
-
const did = userDid ?? consumeDidFromUrl();
|
|
28792
|
-
try {
|
|
28793
|
-
const user = renown.user;
|
|
28794
|
-
if (user?.did && (user.did === did || !did)) {
|
|
28795
|
-
return user;
|
|
28796
|
-
}
|
|
28797
|
-
if (!did) {
|
|
28798
|
-
return;
|
|
28799
|
-
}
|
|
28800
|
-
return await renown.login(did);
|
|
28801
|
-
} catch (error) {
|
|
28802
|
-
logger6.error("@error", error);
|
|
28803
|
-
}
|
|
28804
|
-
}
|
|
28805
|
-
async function logout() {
|
|
28806
|
-
const renown = window.ph?.renown;
|
|
28807
|
-
await renown?.logout();
|
|
28808
|
-
const url = new URL(window.location.href);
|
|
28809
|
-
if (url.searchParams.has("user")) {
|
|
28810
|
-
url.searchParams.delete("user");
|
|
28811
|
-
window.history.replaceState(null, "", url.toString());
|
|
28812
|
-
}
|
|
28813
|
-
}
|
|
28814
|
-
function useUser() {
|
|
28815
|
-
const renown = useRenown();
|
|
28816
|
-
const [user, setUser] = useState4(() => renown?.user);
|
|
28817
|
-
useEffect4(() => {
|
|
28818
|
-
setUser(renown?.user);
|
|
28819
|
-
if (!renown)
|
|
28820
|
-
return;
|
|
28821
|
-
return renown.on("user", setUser);
|
|
28822
|
-
}, [renown]);
|
|
28823
|
-
return user;
|
|
28824
|
-
}
|
|
28825
|
-
function useLoginStatus() {
|
|
28826
|
-
const renown = useRenown();
|
|
28827
|
-
const [status, setStatus] = useState4(() => renown ? renown.status : "initializing");
|
|
28828
|
-
useEffect4(() => {
|
|
28829
|
-
setStatus(renown ? renown.status : "initializing");
|
|
28830
|
-
if (!renown)
|
|
28831
|
-
return;
|
|
28832
|
-
return renown.on("status", setStatus);
|
|
28833
|
-
}, [renown]);
|
|
28834
|
-
return status;
|
|
28835
|
-
}
|
|
28836
29089
|
function useGetSwitchboardLink(document2) {
|
|
28837
29090
|
const [drive] = useSelectedDrive();
|
|
28838
29091
|
const remotes = useSyncList();
|
|
@@ -28875,6 +29128,47 @@ function useUserPermissions() {
|
|
|
28875
29128
|
isAllowedToEditDocuments: allowList.includes(user?.address ?? "")
|
|
28876
29129
|
};
|
|
28877
29130
|
}
|
|
29131
|
+
function cdnUrlToApiUrl(cdnUrl) {
|
|
29132
|
+
return cdnUrl.replace(/\/-\/cdn\/?$/, "");
|
|
29133
|
+
}
|
|
29134
|
+
function mapPackageInfo(pkg) {
|
|
29135
|
+
return {
|
|
29136
|
+
name: pkg.name,
|
|
29137
|
+
description: pkg.manifest?.description,
|
|
29138
|
+
version: pkg.manifest?.version,
|
|
29139
|
+
category: pkg.manifest?.category,
|
|
29140
|
+
publisher: pkg.manifest?.publisher?.name,
|
|
29141
|
+
publisherUrl: pkg.manifest?.publisher?.url
|
|
29142
|
+
};
|
|
29143
|
+
}
|
|
29144
|
+
|
|
29145
|
+
class RegistryClient {
|
|
29146
|
+
apiUrl;
|
|
29147
|
+
constructor(cdnUrl) {
|
|
29148
|
+
this.apiUrl = cdnUrlToApiUrl(cdnUrl);
|
|
29149
|
+
}
|
|
29150
|
+
async getPackages() {
|
|
29151
|
+
const res = await fetch(`${this.apiUrl}/packages`);
|
|
29152
|
+
if (!res.ok)
|
|
29153
|
+
throw new Error(`Registry error: HTTP ${res.status}`);
|
|
29154
|
+
const data = await res.json();
|
|
29155
|
+
return data.map(mapPackageInfo);
|
|
29156
|
+
}
|
|
29157
|
+
async getPackagesByDocumentType(documentType) {
|
|
29158
|
+
const encodedType = encodeURIComponent(documentType);
|
|
29159
|
+
const res = await fetch(`${this.apiUrl}/packages/by-document-type?type=${encodedType}`);
|
|
29160
|
+
if (!res.ok)
|
|
29161
|
+
throw new Error(`Registry error: HTTP ${res.status}`);
|
|
29162
|
+
return await res.json();
|
|
29163
|
+
}
|
|
29164
|
+
async searchPackages(query) {
|
|
29165
|
+
const packages = await this.getPackages();
|
|
29166
|
+
if (!query)
|
|
29167
|
+
return packages;
|
|
29168
|
+
const lowerQuery = query.toLowerCase();
|
|
29169
|
+
return packages.filter((pkg) => pkg.name.toLowerCase().includes(lowerQuery) || pkg.description?.toLowerCase().includes(lowerQuery));
|
|
29170
|
+
}
|
|
29171
|
+
}
|
|
28878
29172
|
|
|
28879
29173
|
class BaseStorage {
|
|
28880
29174
|
#store;
|
|
@@ -28896,6 +29190,19 @@ class BaseStorage {
|
|
|
28896
29190
|
return this.#store.delete(this.#buildKey(key));
|
|
28897
29191
|
}
|
|
28898
29192
|
}
|
|
29193
|
+
function loadDismissedPackages() {
|
|
29194
|
+
try {
|
|
29195
|
+
const raw = localStorage.getItem(DISMISSED_STORAGE_KEY);
|
|
29196
|
+
if (raw)
|
|
29197
|
+
return JSON.parse(raw);
|
|
29198
|
+
} catch {}
|
|
29199
|
+
return [];
|
|
29200
|
+
}
|
|
29201
|
+
function persistDismissedPackages(dismissed) {
|
|
29202
|
+
try {
|
|
29203
|
+
localStorage.setItem(DISMISSED_STORAGE_KEY, JSON.stringify(dismissed));
|
|
29204
|
+
} catch {}
|
|
29205
|
+
}
|
|
28899
29206
|
function loadCSS(pkg, registryUrl) {
|
|
28900
29207
|
const head = document.getElementsByTagName("head")[0];
|
|
28901
29208
|
const existingStyle = head.querySelector(`link[data-package='${pkg}']`);
|
|
@@ -28916,10 +29223,13 @@ function removeCSS(pkg) {
|
|
|
28916
29223
|
style.remove();
|
|
28917
29224
|
}
|
|
28918
29225
|
}
|
|
29226
|
+
async function runtimeImport(url) {
|
|
29227
|
+
return new Function("u", "return import(u)")(url);
|
|
29228
|
+
}
|
|
28919
29229
|
async function loadExternalPackage(name4, registryUrl) {
|
|
28920
29230
|
registryUrl = registryUrl.endsWith("/") ? registryUrl : `${registryUrl}/`;
|
|
28921
29231
|
const url = `${registryUrl}${name4}/index.js`;
|
|
28922
|
-
const module = await
|
|
29232
|
+
const module = await runtimeImport(url);
|
|
28923
29233
|
loadCSS(name4, registryUrl);
|
|
28924
29234
|
return convertLegacyLibToVetraPackage(module);
|
|
28925
29235
|
}
|
|
@@ -28930,12 +29240,23 @@ class BrowserPackageManager {
|
|
|
28930
29240
|
#localPackageIds = new Set;
|
|
28931
29241
|
#subscribers = new Set;
|
|
28932
29242
|
#packagesMemo = [];
|
|
28933
|
-
|
|
29243
|
+
#registryCdnUrl;
|
|
29244
|
+
#registryClient;
|
|
29245
|
+
#documentModelRegistry;
|
|
29246
|
+
#pending = [];
|
|
29247
|
+
#dismissed = loadDismissedPackages();
|
|
29248
|
+
#deferredActions = new Map;
|
|
29249
|
+
#pendingListeners = new Set;
|
|
29250
|
+
constructor(namespace, registryCdnUrl) {
|
|
28934
29251
|
this.#storage = new BrowserLocalStorage(namespace + ":PH_PACKAGES");
|
|
28935
29252
|
const packages = this.#storage.get("packages");
|
|
28936
29253
|
if (!packages) {
|
|
28937
29254
|
this.#storage.set("packages", []);
|
|
28938
29255
|
}
|
|
29256
|
+
if (registryCdnUrl) {
|
|
29257
|
+
this.#registryCdnUrl = registryCdnUrl;
|
|
29258
|
+
this.#registryClient = new RegistryClient(registryCdnUrl);
|
|
29259
|
+
}
|
|
28939
29260
|
}
|
|
28940
29261
|
async init() {
|
|
28941
29262
|
const packages = this.#storage.get("packages");
|
|
@@ -28991,6 +29312,99 @@ class BrowserPackageManager {
|
|
|
28991
29312
|
handler({ packages });
|
|
28992
29313
|
});
|
|
28993
29314
|
}
|
|
29315
|
+
setDocumentModelRegistry(registry) {
|
|
29316
|
+
this.#documentModelRegistry = registry;
|
|
29317
|
+
}
|
|
29318
|
+
async load(documentType) {
|
|
29319
|
+
if (!this.#registryClient || !this.#registryCdnUrl) {
|
|
29320
|
+
throw new Error("Registry CDN URL not configured — cannot discover packages");
|
|
29321
|
+
}
|
|
29322
|
+
const packageNames = await this.#registryClient.getPackagesByDocumentType(documentType);
|
|
29323
|
+
if (packageNames.length === 0) {
|
|
29324
|
+
throw new Error(`No package found containing document type: ${documentType}`);
|
|
29325
|
+
}
|
|
29326
|
+
const packageName = packageNames.sort((a, b) => a.localeCompare(b))[0];
|
|
29327
|
+
this.#pending = [...this.#pending, { documentType, packageName }];
|
|
29328
|
+
this.#notifyPendingListeners();
|
|
29329
|
+
return new Promise((resolve, reject) => {
|
|
29330
|
+
this.#deferredActions.set(packageName, { resolve, reject });
|
|
29331
|
+
});
|
|
29332
|
+
}
|
|
29333
|
+
async approveInstallation(packageName) {
|
|
29334
|
+
const deferred = this.#deferredActions.get(packageName);
|
|
29335
|
+
if (!deferred)
|
|
29336
|
+
return;
|
|
29337
|
+
try {
|
|
29338
|
+
await this.addPackage(packageName, this.#registryCdnUrl);
|
|
29339
|
+
} catch (error) {
|
|
29340
|
+
this.#removePending(packageName);
|
|
29341
|
+
this.#deferredActions.delete(packageName);
|
|
29342
|
+
deferred.reject(error instanceof Error ? error : new Error(`Failed to install package: ${packageName}`));
|
|
29343
|
+
return;
|
|
29344
|
+
}
|
|
29345
|
+
const pendingEntries = this.#pending.filter((p) => p.packageName === packageName);
|
|
29346
|
+
this.#removePending(packageName);
|
|
29347
|
+
this.#deferredActions.delete(packageName);
|
|
29348
|
+
if (!this.#documentModelRegistry) {
|
|
29349
|
+
deferred.reject(new Error("Document model registry not available"));
|
|
29350
|
+
return;
|
|
29351
|
+
}
|
|
29352
|
+
for (const entry of pendingEntries) {
|
|
29353
|
+
try {
|
|
29354
|
+
const module = this.#documentModelRegistry.getModule(entry.documentType);
|
|
29355
|
+
deferred.resolve(module);
|
|
29356
|
+
return;
|
|
29357
|
+
} catch {}
|
|
29358
|
+
}
|
|
29359
|
+
deferred.reject(new Error(`Module not found after installing package: ${packageName}`));
|
|
29360
|
+
}
|
|
29361
|
+
rejectInstallation(packageName) {
|
|
29362
|
+
const deferred = this.#deferredActions.get(packageName);
|
|
29363
|
+
if (!deferred)
|
|
29364
|
+
return;
|
|
29365
|
+
const rejectedEntries = this.#pending.filter((p) => p.packageName === packageName);
|
|
29366
|
+
const documentTypes = rejectedEntries.map((e) => e.documentType);
|
|
29367
|
+
this.#addDismissed(packageName, documentTypes);
|
|
29368
|
+
this.#removePending(packageName);
|
|
29369
|
+
this.#deferredActions.delete(packageName);
|
|
29370
|
+
deferred.reject(new Error(`Installation rejected for package: ${packageName}`));
|
|
29371
|
+
}
|
|
29372
|
+
subscribePendingChanges(listener) {
|
|
29373
|
+
this.#pendingListeners.add(listener);
|
|
29374
|
+
return () => {
|
|
29375
|
+
this.#pendingListeners.delete(listener);
|
|
29376
|
+
};
|
|
29377
|
+
}
|
|
29378
|
+
getPendingInstallations() {
|
|
29379
|
+
return this.#pending;
|
|
29380
|
+
}
|
|
29381
|
+
getDismissedPackages() {
|
|
29382
|
+
return this.#dismissed;
|
|
29383
|
+
}
|
|
29384
|
+
removeDismissed(packageName) {
|
|
29385
|
+
this.#dismissed = this.#dismissed.filter((d) => d.packageName !== packageName);
|
|
29386
|
+
persistDismissedPackages(this.#dismissed);
|
|
29387
|
+
this.#notifyPendingListeners();
|
|
29388
|
+
}
|
|
29389
|
+
#addDismissed(packageName, documentTypes) {
|
|
29390
|
+
const existing = this.#dismissed.find((d) => d.packageName === packageName);
|
|
29391
|
+
if (existing) {
|
|
29392
|
+
const merged = new Set([...existing.documentTypes, ...documentTypes]);
|
|
29393
|
+
existing.documentTypes = [...merged];
|
|
29394
|
+
} else {
|
|
29395
|
+
this.#dismissed = [...this.#dismissed, { packageName, documentTypes }];
|
|
29396
|
+
}
|
|
29397
|
+
persistDismissedPackages(this.#dismissed);
|
|
29398
|
+
}
|
|
29399
|
+
#removePending(packageName) {
|
|
29400
|
+
this.#pending = this.#pending.filter((p) => p.packageName !== packageName);
|
|
29401
|
+
this.#notifyPendingListeners();
|
|
29402
|
+
}
|
|
29403
|
+
#notifyPendingListeners() {
|
|
29404
|
+
for (const listener of this.#pendingListeners) {
|
|
29405
|
+
listener();
|
|
29406
|
+
}
|
|
29407
|
+
}
|
|
28994
29408
|
}
|
|
28995
29409
|
async function dropTablesInSchema(pg, schema) {
|
|
28996
29410
|
await pg.exec(`
|
|
@@ -29016,40 +29430,6 @@ async function dropAllReactorStorage(pg) {
|
|
|
29016
29430
|
await dropTablesInSchema(pg, REACTOR_SCHEMA);
|
|
29017
29431
|
await dropTablesInSchema(pg, "public");
|
|
29018
29432
|
}
|
|
29019
|
-
function cdnUrlToApiUrl(cdnUrl) {
|
|
29020
|
-
return cdnUrl.replace(/\/-\/cdn\/?$/, "");
|
|
29021
|
-
}
|
|
29022
|
-
function mapPackageInfo(pkg) {
|
|
29023
|
-
return {
|
|
29024
|
-
name: pkg.name,
|
|
29025
|
-
description: pkg.manifest?.description,
|
|
29026
|
-
version: pkg.manifest?.version,
|
|
29027
|
-
category: pkg.manifest?.category,
|
|
29028
|
-
publisher: pkg.manifest?.publisher?.name,
|
|
29029
|
-
publisherUrl: pkg.manifest?.publisher?.url
|
|
29030
|
-
};
|
|
29031
|
-
}
|
|
29032
|
-
|
|
29033
|
-
class RegistryClient {
|
|
29034
|
-
apiUrl;
|
|
29035
|
-
constructor(cdnUrl) {
|
|
29036
|
-
this.apiUrl = cdnUrlToApiUrl(cdnUrl);
|
|
29037
|
-
}
|
|
29038
|
-
async getPackages() {
|
|
29039
|
-
const res = await fetch(`${this.apiUrl}/packages`);
|
|
29040
|
-
if (!res.ok)
|
|
29041
|
-
throw new Error(`Registry error: HTTP ${res.status}`);
|
|
29042
|
-
const data = await res.json();
|
|
29043
|
-
return data.map(mapPackageInfo);
|
|
29044
|
-
}
|
|
29045
|
-
async searchPackages(query) {
|
|
29046
|
-
const packages = await this.getPackages();
|
|
29047
|
-
if (!query)
|
|
29048
|
-
return packages;
|
|
29049
|
-
const lowerQuery = query.toLowerCase();
|
|
29050
|
-
return packages.filter((pkg) => pkg.name.toLowerCase().includes(lowerQuery) || pkg.description?.toLowerCase().includes(lowerQuery));
|
|
29051
|
-
}
|
|
29052
|
-
}
|
|
29053
29433
|
|
|
29054
29434
|
class ReactorClientDocumentCache {
|
|
29055
29435
|
client;
|
|
@@ -29355,7 +29735,7 @@ function split2(lst, le = false) {
|
|
|
29355
29735
|
}
|
|
29356
29736
|
function add(Ah, Al, Bh, Bl) {
|
|
29357
29737
|
const l = (Al >>> 0) + (Bl >>> 0);
|
|
29358
|
-
return { h: Ah + Bh + (l /
|
|
29738
|
+
return { h: Ah + Bh + (l / 2 ** 32 | 0) | 0, l: l | 0 };
|
|
29359
29739
|
}
|
|
29360
29740
|
function _abool2(value, title = "") {
|
|
29361
29741
|
if (typeof value !== "boolean") {
|
|
@@ -30166,7 +30546,7 @@ function edwards(params, extraOpts = {}) {
|
|
|
30166
30546
|
_abool2(zip215, "zip215");
|
|
30167
30547
|
const normed = copyBytes(bytes);
|
|
30168
30548
|
const lastByte = bytes[len - 1];
|
|
30169
|
-
normed[len - 1] = lastByte &
|
|
30549
|
+
normed[len - 1] = lastByte & ~128;
|
|
30170
30550
|
const y = bytesToNumberLE(normed);
|
|
30171
30551
|
const max = zip215 ? MASK : Fp.ORDER;
|
|
30172
30552
|
aInRange("point.y", y, _0n4, max);
|
|
@@ -31552,7 +31932,7 @@ function ripemd_f(group, x, y, z) {
|
|
|
31552
31932
|
return x ^ (y | ~z);
|
|
31553
31933
|
}
|
|
31554
31934
|
function keccakP(s, rounds = 24) {
|
|
31555
|
-
const B = new Uint32Array(
|
|
31935
|
+
const B = new Uint32Array(5 * 2);
|
|
31556
31936
|
for (let round = 24 - rounds;round < 24; round++) {
|
|
31557
31937
|
for (let x = 0;x < 10; x++)
|
|
31558
31938
|
B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];
|
|
@@ -31941,7 +32321,7 @@ function convertRadix2(data, from3, to, padding2) {
|
|
|
31941
32321
|
}
|
|
31942
32322
|
function radix(num) {
|
|
31943
32323
|
anumber2(num);
|
|
31944
|
-
const _256 =
|
|
32324
|
+
const _256 = 2 ** 8;
|
|
31945
32325
|
return {
|
|
31946
32326
|
encode: (bytes) => {
|
|
31947
32327
|
if (!isBytes2(bytes))
|
|
@@ -40558,7 +40938,7 @@ function useStableParams(params) {
|
|
|
40558
40938
|
function createProcessorQuery(ProcessorClass) {
|
|
40559
40939
|
function useQuery(driveId, queryCallback, parameters, options) {
|
|
40560
40940
|
const stableParams = useStableParams(parameters);
|
|
40561
|
-
const memoizedCallback =
|
|
40941
|
+
const memoizedCallback = useCallback5(queryCallback, [stableParams]);
|
|
40562
40942
|
return useRelationalQuery(ProcessorClass, driveId, memoizedCallback, stableParams, options);
|
|
40563
40943
|
}
|
|
40564
40944
|
return useQuery;
|
|
@@ -41092,41 +41472,6 @@ function CopyIcon({ size = 14, color = "#9EA0A1" }) {
|
|
|
41092
41472
|
]
|
|
41093
41473
|
}, undefined, true, undefined, this);
|
|
41094
41474
|
}
|
|
41095
|
-
function ExternalLinkIcon({
|
|
41096
|
-
size = 14,
|
|
41097
|
-
color = "currentColor"
|
|
41098
|
-
}) {
|
|
41099
|
-
return /* @__PURE__ */ jsxDEV("svg", {
|
|
41100
|
-
width: size,
|
|
41101
|
-
height: size,
|
|
41102
|
-
viewBox: "0 0 16 16",
|
|
41103
|
-
fill: "none",
|
|
41104
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
41105
|
-
children: [
|
|
41106
|
-
/* @__PURE__ */ jsxDEV("path", {
|
|
41107
|
-
d: "M12 8.66667V12.6667C12 13.0203 11.8595 13.3594 11.6095 13.6095C11.3594 13.8595 11.0203 14 10.6667 14H3.33333C2.97971 14 2.64057 13.8595 2.39052 13.6095C2.14048 13.3594 2 13.0203 2 12.6667V5.33333C2 4.97971 2.14048 4.64057 2.39052 4.39052C2.64057 4.14048 2.97971 4 3.33333 4H7.33333",
|
|
41108
|
-
stroke: color,
|
|
41109
|
-
strokeWidth: "1.5",
|
|
41110
|
-
strokeLinecap: "round",
|
|
41111
|
-
strokeLinejoin: "round"
|
|
41112
|
-
}, undefined, false, undefined, this),
|
|
41113
|
-
/* @__PURE__ */ jsxDEV("path", {
|
|
41114
|
-
d: "M10 2H14V6",
|
|
41115
|
-
stroke: color,
|
|
41116
|
-
strokeWidth: "1.5",
|
|
41117
|
-
strokeLinecap: "round",
|
|
41118
|
-
strokeLinejoin: "round"
|
|
41119
|
-
}, undefined, false, undefined, this),
|
|
41120
|
-
/* @__PURE__ */ jsxDEV("path", {
|
|
41121
|
-
d: "M6.66669 9.33333L14 2",
|
|
41122
|
-
stroke: color,
|
|
41123
|
-
strokeWidth: "1.5",
|
|
41124
|
-
strokeLinecap: "round",
|
|
41125
|
-
strokeLinejoin: "round"
|
|
41126
|
-
}, undefined, false, undefined, this)
|
|
41127
|
-
]
|
|
41128
|
-
}, undefined, true, undefined, this);
|
|
41129
|
-
}
|
|
41130
41475
|
function DisconnectIcon({ size = 14, color = "#EA4335" }) {
|
|
41131
41476
|
return /* @__PURE__ */ jsxDEV("svg", {
|
|
41132
41477
|
width: size,
|
|
@@ -41229,6 +41574,27 @@ function SpinnerIcon({ size = 14, color = "currentColor" }) {
|
|
|
41229
41574
|
]
|
|
41230
41575
|
}, undefined, true, undefined, this);
|
|
41231
41576
|
}
|
|
41577
|
+
function ChevronDownIcon({
|
|
41578
|
+
size = 14,
|
|
41579
|
+
color = "currentColor",
|
|
41580
|
+
style
|
|
41581
|
+
}) {
|
|
41582
|
+
return /* @__PURE__ */ jsxDEV("svg", {
|
|
41583
|
+
width: size,
|
|
41584
|
+
height: size,
|
|
41585
|
+
viewBox: "0 0 16 16",
|
|
41586
|
+
fill: "none",
|
|
41587
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
41588
|
+
style,
|
|
41589
|
+
children: /* @__PURE__ */ jsxDEV("path", {
|
|
41590
|
+
d: "M4 6L8 10L12 6",
|
|
41591
|
+
stroke: color,
|
|
41592
|
+
strokeWidth: "1.5",
|
|
41593
|
+
strokeLinecap: "round",
|
|
41594
|
+
strokeLinejoin: "round"
|
|
41595
|
+
}, undefined, false, undefined, this)
|
|
41596
|
+
}, undefined, false, undefined, this);
|
|
41597
|
+
}
|
|
41232
41598
|
function UserIcon({ size = 24, color = "#6366f1" }) {
|
|
41233
41599
|
return /* @__PURE__ */ jsxDEV("svg", {
|
|
41234
41600
|
width: size,
|
|
@@ -41253,134 +41619,80 @@ function UserIcon({ size = 24, color = "#6366f1" }) {
|
|
|
41253
41619
|
]
|
|
41254
41620
|
}, undefined, true, undefined, this);
|
|
41255
41621
|
}
|
|
41622
|
+
function mergeProps(parentProps, childProps) {
|
|
41623
|
+
const merged = { ...parentProps };
|
|
41624
|
+
for (const key of Object.keys(childProps)) {
|
|
41625
|
+
const parentValue = parentProps[key];
|
|
41626
|
+
const childValue = childProps[key];
|
|
41627
|
+
if (key === "style") {
|
|
41628
|
+
merged[key] = { ...parentValue, ...childValue };
|
|
41629
|
+
} else if (key === "className") {
|
|
41630
|
+
merged[key] = [parentValue, childValue].filter(Boolean).join(" ");
|
|
41631
|
+
} else if (typeof parentValue === "function" && typeof childValue === "function") {
|
|
41632
|
+
merged[key] = (...args) => {
|
|
41633
|
+
childValue(...args);
|
|
41634
|
+
parentValue(...args);
|
|
41635
|
+
};
|
|
41636
|
+
} else if (childValue !== undefined) {
|
|
41637
|
+
merged[key] = childValue;
|
|
41638
|
+
}
|
|
41639
|
+
}
|
|
41640
|
+
return merged;
|
|
41641
|
+
}
|
|
41256
41642
|
function RenownLoginButton({
|
|
41257
41643
|
onLogin: onLoginProp,
|
|
41258
41644
|
darkMode = false,
|
|
41259
41645
|
style,
|
|
41260
41646
|
className,
|
|
41261
|
-
|
|
41262
|
-
|
|
41647
|
+
asChild = false,
|
|
41648
|
+
children
|
|
41263
41649
|
}) {
|
|
41264
41650
|
const onLogin = onLoginProp ?? (() => openRenown());
|
|
41265
|
-
const [isOpen, setIsOpen] = useState7(false);
|
|
41266
41651
|
const [isLoading, setIsLoading] = useState7(false);
|
|
41267
41652
|
const [isHovered, setIsHovered] = useState7(false);
|
|
41268
|
-
const
|
|
41269
|
-
const
|
|
41270
|
-
const
|
|
41271
|
-
|
|
41272
|
-
if (!wrapperRef.current)
|
|
41273
|
-
return;
|
|
41274
|
-
const rect = wrapperRef.current.getBoundingClientRect();
|
|
41275
|
-
const spaceAbove = rect.top;
|
|
41276
|
-
setShowAbove(spaceAbove >= POPOVER_HEIGHT + POPOVER_GAP);
|
|
41277
|
-
}, []);
|
|
41278
|
-
const handleMouseEnter = useCallback5(() => {
|
|
41279
|
-
setIsHovered(true);
|
|
41280
|
-
if (!showPopover)
|
|
41281
|
-
return;
|
|
41282
|
-
if (closeTimeoutRef.current) {
|
|
41283
|
-
clearTimeout(closeTimeoutRef.current);
|
|
41284
|
-
closeTimeoutRef.current = null;
|
|
41285
|
-
}
|
|
41286
|
-
calculatePosition();
|
|
41287
|
-
setIsOpen(true);
|
|
41288
|
-
}, [calculatePosition, showPopover]);
|
|
41289
|
-
const handleMouseLeave = useCallback5(() => {
|
|
41290
|
-
closeTimeoutRef.current = setTimeout(() => {
|
|
41291
|
-
setIsOpen(false);
|
|
41292
|
-
setIsHovered(false);
|
|
41293
|
-
}, 150);
|
|
41294
|
-
}, []);
|
|
41295
|
-
useEffect7(() => {
|
|
41296
|
-
return () => {
|
|
41297
|
-
if (closeTimeoutRef.current) {
|
|
41298
|
-
clearTimeout(closeTimeoutRef.current);
|
|
41299
|
-
}
|
|
41300
|
-
};
|
|
41301
|
-
}, []);
|
|
41302
|
-
const handleConnect = () => {
|
|
41303
|
-
setIsLoading(true);
|
|
41304
|
-
onLogin();
|
|
41305
|
-
};
|
|
41306
|
-
const handleDirectClick = () => {
|
|
41307
|
-
if (!showPopover && !isLoading) {
|
|
41653
|
+
const handleMouseEnter = useCallback6(() => setIsHovered(true), []);
|
|
41654
|
+
const handleMouseLeave = useCallback6(() => setIsHovered(false), []);
|
|
41655
|
+
const handleClick = () => {
|
|
41656
|
+
if (!isLoading) {
|
|
41308
41657
|
setIsLoading(true);
|
|
41309
41658
|
onLogin();
|
|
41310
41659
|
}
|
|
41311
41660
|
};
|
|
41661
|
+
const themeStyles = darkMode ? darkStyles : lightStyles;
|
|
41312
41662
|
const triggerStyle = {
|
|
41313
41663
|
...styles.trigger,
|
|
41314
|
-
|
|
41664
|
+
...themeStyles.trigger,
|
|
41665
|
+
...isHovered && !isLoading ? themeStyles.triggerHover : {},
|
|
41666
|
+
cursor: isLoading ? "wait" : "pointer",
|
|
41315
41667
|
...style
|
|
41316
41668
|
};
|
|
41317
|
-
const
|
|
41318
|
-
|
|
41319
|
-
|
|
41320
|
-
...
|
|
41321
|
-
|
|
41322
|
-
}
|
|
41323
|
-
|
|
41324
|
-
|
|
41325
|
-
|
|
41326
|
-
|
|
41327
|
-
|
|
41328
|
-
|
|
41329
|
-
|
|
41669
|
+
const triggerElement = asChild ? /* @__PURE__ */ jsxDEV2(Slot, {
|
|
41670
|
+
onClick: handleClick,
|
|
41671
|
+
"data-renown-state": "login",
|
|
41672
|
+
...isLoading ? { "data-loading": "" } : {},
|
|
41673
|
+
children
|
|
41674
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV2("button", {
|
|
41675
|
+
type: "button",
|
|
41676
|
+
style: triggerStyle,
|
|
41677
|
+
"aria-label": "Log in with Renown",
|
|
41678
|
+
onClick: handleClick,
|
|
41679
|
+
"data-renown-state": "login",
|
|
41680
|
+
...isLoading ? { "data-loading": "" } : {},
|
|
41681
|
+
children: isLoading ? /* @__PURE__ */ jsxDEV2(SpinnerIcon, {
|
|
41682
|
+
size: 16
|
|
41683
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV2("span", {
|
|
41684
|
+
children: "Log in"
|
|
41685
|
+
}, undefined, false, undefined, this)
|
|
41686
|
+
}, undefined, false, undefined, this);
|
|
41330
41687
|
return /* @__PURE__ */ jsxDEV2("div", {
|
|
41331
|
-
ref: wrapperRef,
|
|
41332
41688
|
style: styles.wrapper,
|
|
41333
41689
|
className,
|
|
41334
41690
|
onMouseEnter: handleMouseEnter,
|
|
41335
41691
|
onMouseLeave: handleMouseLeave,
|
|
41336
|
-
children:
|
|
41337
|
-
|
|
41338
|
-
onMouseEnter: handleMouseEnter,
|
|
41339
|
-
onMouseLeave: handleMouseLeave,
|
|
41340
|
-
isLoading
|
|
41341
|
-
}) : /* @__PURE__ */ jsxDEV2("button", {
|
|
41342
|
-
type: "button",
|
|
41343
|
-
style: triggerStyle,
|
|
41344
|
-
"aria-label": showPopover ? "Open Renown Login" : "Login with Renown",
|
|
41345
|
-
onClick: showPopover ? undefined : handleDirectClick,
|
|
41346
|
-
children: isLoading ? /* @__PURE__ */ jsxDEV2(SpinnerIcon, {
|
|
41347
|
-
size: 42
|
|
41348
|
-
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV2("img", {
|
|
41349
|
-
width: 42,
|
|
41350
|
-
height: 42,
|
|
41351
|
-
src: isHovered ? renownShortHoverDataUrl : renownShortDataUrl,
|
|
41352
|
-
alt: "Renown Login",
|
|
41353
|
-
style: triggerImageStyle
|
|
41354
|
-
}, undefined, false, undefined, this)
|
|
41355
|
-
}, undefined, false, undefined, this),
|
|
41356
|
-
isOpen && showPopover && /* @__PURE__ */ jsxDEV2("div", {
|
|
41357
|
-
style: popoverStyle,
|
|
41358
|
-
children: /* @__PURE__ */ jsxDEV2("div", {
|
|
41359
|
-
style: styles.popoverContent,
|
|
41360
|
-
children: [
|
|
41361
|
-
/* @__PURE__ */ jsxDEV2("div", {
|
|
41362
|
-
style: styles.logoContainer,
|
|
41363
|
-
children: /* @__PURE__ */ jsxDEV2(RenownLogo, {
|
|
41364
|
-
width: 83,
|
|
41365
|
-
height: 22,
|
|
41366
|
-
color: logoColor
|
|
41367
|
-
}, undefined, false, undefined, this)
|
|
41368
|
-
}, undefined, false, undefined, this),
|
|
41369
|
-
/* @__PURE__ */ jsxDEV2("button", {
|
|
41370
|
-
type: "button",
|
|
41371
|
-
onClick: allowLogin ? handleConnect : undefined,
|
|
41372
|
-
style: connectButtonStyle,
|
|
41373
|
-
children: isLoading ? /* @__PURE__ */ jsxDEV2(SpinnerIcon, {
|
|
41374
|
-
size: 14
|
|
41375
|
-
}, undefined, false, undefined, this) : "Connect"
|
|
41376
|
-
}, undefined, false, undefined, this)
|
|
41377
|
-
]
|
|
41378
|
-
}, undefined, true, undefined, this)
|
|
41379
|
-
}, undefined, false, undefined, this)
|
|
41380
|
-
]
|
|
41381
|
-
}, undefined, true, undefined, this);
|
|
41692
|
+
children: triggerElement
|
|
41693
|
+
}, undefined, false, undefined, this);
|
|
41382
41694
|
}
|
|
41383
|
-
function
|
|
41695
|
+
function truncateAddress2(address) {
|
|
41384
41696
|
if (address.length <= 13)
|
|
41385
41697
|
return address;
|
|
41386
41698
|
return `${address.slice(0, 7)}...${address.slice(-5)}`;
|
|
@@ -41393,27 +41705,34 @@ function RenownUserButton({
|
|
|
41393
41705
|
onDisconnect: onDisconnectProp,
|
|
41394
41706
|
style,
|
|
41395
41707
|
className,
|
|
41396
|
-
|
|
41708
|
+
asChild = false,
|
|
41709
|
+
children,
|
|
41710
|
+
menuItems
|
|
41397
41711
|
}) {
|
|
41398
41712
|
const user = useUser();
|
|
41399
41713
|
const address = addressProp ?? user?.address ?? "";
|
|
41400
|
-
const username = usernameProp ?? user?.ens?.name;
|
|
41401
|
-
const avatarUrl = avatarUrlProp ?? user?.ens?.avatarUrl;
|
|
41714
|
+
const username = usernameProp ?? user?.profile?.username ?? user?.ens?.name;
|
|
41715
|
+
const avatarUrl = avatarUrlProp ?? user?.profile?.userImage ?? user?.ens?.avatarUrl;
|
|
41402
41716
|
const userId = userIdProp ?? user?.profile?.documentId;
|
|
41403
41717
|
const onDisconnect = onDisconnectProp ?? (() => void logout());
|
|
41718
|
+
const displayName = username ?? (address ? truncateAddress2(address) : "Account");
|
|
41719
|
+
const profileId = userId ?? address;
|
|
41404
41720
|
const [isOpen, setIsOpen] = useState8(false);
|
|
41721
|
+
const [isHovered, setIsHovered] = useState8(false);
|
|
41405
41722
|
const [isCopied, setIsCopied] = useState8(false);
|
|
41406
41723
|
const [showAbove, setShowAbove] = useState8(true);
|
|
41407
|
-
const
|
|
41408
|
-
const
|
|
41409
|
-
const
|
|
41724
|
+
const [hoveredItem, setHoveredItem] = useState8(null);
|
|
41725
|
+
const wrapperRef = useRef5(null);
|
|
41726
|
+
const closeTimeoutRef = useRef5(null);
|
|
41727
|
+
const calculatePosition = useCallback7(() => {
|
|
41410
41728
|
if (!wrapperRef.current)
|
|
41411
41729
|
return;
|
|
41412
41730
|
const rect = wrapperRef.current.getBoundingClientRect();
|
|
41413
41731
|
const spaceAbove = rect.top;
|
|
41414
|
-
setShowAbove(spaceAbove >=
|
|
41732
|
+
setShowAbove(spaceAbove >= POPOVER_HEIGHT + POPOVER_GAP);
|
|
41415
41733
|
}, []);
|
|
41416
|
-
const handleMouseEnter =
|
|
41734
|
+
const handleMouseEnter = useCallback7(() => {
|
|
41735
|
+
setIsHovered(true);
|
|
41417
41736
|
if (closeTimeoutRef.current) {
|
|
41418
41737
|
clearTimeout(closeTimeoutRef.current);
|
|
41419
41738
|
closeTimeoutRef.current = null;
|
|
@@ -41421,19 +41740,21 @@ function RenownUserButton({
|
|
|
41421
41740
|
calculatePosition();
|
|
41422
41741
|
setIsOpen(true);
|
|
41423
41742
|
}, [calculatePosition]);
|
|
41424
|
-
const handleMouseLeave =
|
|
41743
|
+
const handleMouseLeave = useCallback7(() => {
|
|
41425
41744
|
closeTimeoutRef.current = setTimeout(() => {
|
|
41426
41745
|
setIsOpen(false);
|
|
41746
|
+
setIsHovered(false);
|
|
41747
|
+
setHoveredItem(null);
|
|
41427
41748
|
}, 150);
|
|
41428
41749
|
}, []);
|
|
41429
|
-
|
|
41750
|
+
useEffect7(() => {
|
|
41430
41751
|
return () => {
|
|
41431
41752
|
if (closeTimeoutRef.current) {
|
|
41432
41753
|
clearTimeout(closeTimeoutRef.current);
|
|
41433
41754
|
}
|
|
41434
41755
|
};
|
|
41435
41756
|
}, []);
|
|
41436
|
-
const copyToClipboard =
|
|
41757
|
+
const copyToClipboard = useCallback7(async () => {
|
|
41437
41758
|
try {
|
|
41438
41759
|
await navigator.clipboard.writeText(address);
|
|
41439
41760
|
setIsCopied(true);
|
|
@@ -41442,6 +41763,43 @@ function RenownUserButton({
|
|
|
41442
41763
|
console.error("Failed to copy address:", err);
|
|
41443
41764
|
}
|
|
41444
41765
|
}, [address]);
|
|
41766
|
+
const triggerElement = asChild ? /* @__PURE__ */ jsxDEV3(Slot, {
|
|
41767
|
+
"data-renown-state": "authenticated",
|
|
41768
|
+
children
|
|
41769
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV3("button", {
|
|
41770
|
+
type: "button",
|
|
41771
|
+
style: {
|
|
41772
|
+
...styles2.trigger,
|
|
41773
|
+
...isHovered ? styles2.triggerHover : {},
|
|
41774
|
+
...style
|
|
41775
|
+
},
|
|
41776
|
+
"aria-label": "Open account menu",
|
|
41777
|
+
"data-renown-state": "authenticated",
|
|
41778
|
+
children: [
|
|
41779
|
+
avatarUrl ? /* @__PURE__ */ jsxDEV3("img", {
|
|
41780
|
+
src: avatarUrl,
|
|
41781
|
+
alt: "Avatar",
|
|
41782
|
+
style: styles2.avatar
|
|
41783
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV3("div", {
|
|
41784
|
+
style: styles2.avatarPlaceholder,
|
|
41785
|
+
children: /* @__PURE__ */ jsxDEV3("span", {
|
|
41786
|
+
style: styles2.avatarInitial,
|
|
41787
|
+
children: (displayName || "U")[0].toUpperCase()
|
|
41788
|
+
}, undefined, false, undefined, this)
|
|
41789
|
+
}, undefined, false, undefined, this),
|
|
41790
|
+
/* @__PURE__ */ jsxDEV3("span", {
|
|
41791
|
+
style: styles2.displayName,
|
|
41792
|
+
children: displayName
|
|
41793
|
+
}, undefined, false, undefined, this),
|
|
41794
|
+
/* @__PURE__ */ jsxDEV3(ChevronDownIcon, {
|
|
41795
|
+
size: 14,
|
|
41796
|
+
style: {
|
|
41797
|
+
...styles2.chevron,
|
|
41798
|
+
...isOpen ? styles2.chevronOpen : {}
|
|
41799
|
+
}
|
|
41800
|
+
}, undefined, false, undefined, this)
|
|
41801
|
+
]
|
|
41802
|
+
}, undefined, true, undefined, this);
|
|
41445
41803
|
return /* @__PURE__ */ jsxDEV3("div", {
|
|
41446
41804
|
ref: wrapperRef,
|
|
41447
41805
|
style: styles2.wrapper,
|
|
@@ -41449,46 +41807,25 @@ function RenownUserButton({
|
|
|
41449
41807
|
onMouseEnter: handleMouseEnter,
|
|
41450
41808
|
onMouseLeave: handleMouseLeave,
|
|
41451
41809
|
children: [
|
|
41452
|
-
|
|
41453
|
-
onMouseEnter: handleMouseEnter,
|
|
41454
|
-
onMouseLeave: handleMouseLeave,
|
|
41455
|
-
address,
|
|
41456
|
-
username,
|
|
41457
|
-
avatarUrl
|
|
41458
|
-
}) : /* @__PURE__ */ jsxDEV3("button", {
|
|
41459
|
-
type: "button",
|
|
41460
|
-
style: { ...styles2.trigger, ...style },
|
|
41461
|
-
"aria-label": "Open account menu",
|
|
41462
|
-
children: avatarUrl ? /* @__PURE__ */ jsxDEV3("img", {
|
|
41463
|
-
src: avatarUrl,
|
|
41464
|
-
alt: "Avatar",
|
|
41465
|
-
style: styles2.avatar
|
|
41466
|
-
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV3("div", {
|
|
41467
|
-
style: styles2.avatarPlaceholder,
|
|
41468
|
-
children: /* @__PURE__ */ jsxDEV3(UserIcon, {
|
|
41469
|
-
size: 24,
|
|
41470
|
-
color: "#9ca3af"
|
|
41471
|
-
}, undefined, false, undefined, this)
|
|
41472
|
-
}, undefined, false, undefined, this)
|
|
41473
|
-
}, undefined, false, undefined, this),
|
|
41810
|
+
triggerElement,
|
|
41474
41811
|
isOpen && /* @__PURE__ */ jsxDEV3("div", {
|
|
41475
41812
|
style: {
|
|
41476
41813
|
...styles2.popoverBase,
|
|
41477
|
-
...showAbove ? { bottom: `calc(100% + ${
|
|
41814
|
+
...showAbove ? { bottom: `calc(100% + ${POPOVER_GAP}px)` } : { top: `calc(100% + ${POPOVER_GAP}px)` }
|
|
41478
41815
|
},
|
|
41479
41816
|
children: [
|
|
41480
41817
|
/* @__PURE__ */ jsxDEV3("div", {
|
|
41481
|
-
style: styles2.
|
|
41818
|
+
style: styles2.header,
|
|
41482
41819
|
children: [
|
|
41483
41820
|
username && /* @__PURE__ */ jsxDEV3("div", {
|
|
41484
|
-
style: styles2.
|
|
41821
|
+
style: styles2.headerUsername,
|
|
41485
41822
|
children: username
|
|
41486
41823
|
}, undefined, false, undefined, this),
|
|
41487
|
-
/* @__PURE__ */ jsxDEV3("div", {
|
|
41824
|
+
address && /* @__PURE__ */ jsxDEV3("div", {
|
|
41488
41825
|
style: styles2.addressRow,
|
|
41489
41826
|
children: /* @__PURE__ */ jsxDEV3("button", {
|
|
41490
41827
|
type: "button",
|
|
41491
|
-
onClick: copyToClipboard,
|
|
41828
|
+
onClick: () => void copyToClipboard(),
|
|
41492
41829
|
style: styles2.addressButton,
|
|
41493
41830
|
children: /* @__PURE__ */ jsxDEV3("div", {
|
|
41494
41831
|
style: {
|
|
@@ -41500,20 +41837,26 @@ function RenownUserButton({
|
|
|
41500
41837
|
},
|
|
41501
41838
|
children: [
|
|
41502
41839
|
/* @__PURE__ */ jsxDEV3("div", {
|
|
41503
|
-
style: {
|
|
41840
|
+
style: {
|
|
41841
|
+
...styles2.addressText,
|
|
41842
|
+
opacity: isCopied ? 0 : 1
|
|
41843
|
+
},
|
|
41504
41844
|
children: [
|
|
41505
41845
|
/* @__PURE__ */ jsxDEV3("span", {
|
|
41506
|
-
children:
|
|
41846
|
+
children: truncateAddress2(address)
|
|
41507
41847
|
}, undefined, false, undefined, this),
|
|
41508
41848
|
/* @__PURE__ */ jsxDEV3(CopyIcon, {
|
|
41509
|
-
size:
|
|
41510
|
-
color: "#
|
|
41849
|
+
size: 12,
|
|
41850
|
+
color: "#9ca3af"
|
|
41511
41851
|
}, undefined, false, undefined, this)
|
|
41512
41852
|
]
|
|
41513
41853
|
}, undefined, true, undefined, this),
|
|
41514
41854
|
/* @__PURE__ */ jsxDEV3("div", {
|
|
41515
|
-
style: {
|
|
41516
|
-
|
|
41855
|
+
style: {
|
|
41856
|
+
...styles2.copiedText,
|
|
41857
|
+
opacity: isCopied ? 1 : 0
|
|
41858
|
+
},
|
|
41859
|
+
children: "Copied!"
|
|
41517
41860
|
}, undefined, false, undefined, this)
|
|
41518
41861
|
]
|
|
41519
41862
|
}, undefined, true, undefined, this)
|
|
@@ -41521,35 +41864,64 @@ function RenownUserButton({
|
|
|
41521
41864
|
}, undefined, false, undefined, this)
|
|
41522
41865
|
]
|
|
41523
41866
|
}, undefined, true, undefined, this),
|
|
41524
|
-
|
|
41525
|
-
style: styles2.
|
|
41526
|
-
children:
|
|
41527
|
-
|
|
41528
|
-
|
|
41529
|
-
|
|
41530
|
-
|
|
41531
|
-
|
|
41532
|
-
|
|
41533
|
-
|
|
41534
|
-
|
|
41535
|
-
|
|
41536
|
-
|
|
41867
|
+
/* @__PURE__ */ jsxDEV3("div", {
|
|
41868
|
+
style: styles2.menuSection,
|
|
41869
|
+
children: [
|
|
41870
|
+
profileId && /* @__PURE__ */ jsxDEV3("button", {
|
|
41871
|
+
type: "button",
|
|
41872
|
+
onClick: () => openRenown(profileId),
|
|
41873
|
+
onMouseEnter: () => setHoveredItem("profile"),
|
|
41874
|
+
onMouseLeave: () => setHoveredItem(null),
|
|
41875
|
+
style: {
|
|
41876
|
+
...styles2.menuItem,
|
|
41877
|
+
...hoveredItem === "profile" ? styles2.menuItemHover : {}
|
|
41878
|
+
},
|
|
41879
|
+
children: [
|
|
41880
|
+
/* @__PURE__ */ jsxDEV3(UserIcon, {
|
|
41881
|
+
size: 14,
|
|
41882
|
+
color: "#6b7280"
|
|
41883
|
+
}, undefined, false, undefined, this),
|
|
41884
|
+
"View Profile"
|
|
41885
|
+
]
|
|
41886
|
+
}, undefined, true, undefined, this),
|
|
41887
|
+
menuItems?.map((item) => /* @__PURE__ */ jsxDEV3("button", {
|
|
41888
|
+
type: "button",
|
|
41889
|
+
onClick: item.onClick,
|
|
41890
|
+
onMouseEnter: () => setHoveredItem(item.label),
|
|
41891
|
+
onMouseLeave: () => setHoveredItem(null),
|
|
41892
|
+
style: {
|
|
41893
|
+
...styles2.menuItem,
|
|
41894
|
+
...hoveredItem === item.label ? styles2.menuItemHover : {},
|
|
41895
|
+
...item.style
|
|
41896
|
+
},
|
|
41897
|
+
children: [
|
|
41898
|
+
item.icon,
|
|
41899
|
+
item.label
|
|
41900
|
+
]
|
|
41901
|
+
}, item.label, true, undefined, this))
|
|
41902
|
+
]
|
|
41903
|
+
}, undefined, true, undefined, this),
|
|
41904
|
+
/* @__PURE__ */ jsxDEV3("hr", {
|
|
41905
|
+
style: styles2.separator
|
|
41537
41906
|
}, undefined, false, undefined, this),
|
|
41538
41907
|
/* @__PURE__ */ jsxDEV3("div", {
|
|
41539
|
-
style: styles2.
|
|
41908
|
+
style: styles2.menuSection,
|
|
41540
41909
|
children: /* @__PURE__ */ jsxDEV3("button", {
|
|
41541
41910
|
type: "button",
|
|
41542
41911
|
onClick: onDisconnect,
|
|
41912
|
+
onMouseEnter: () => setHoveredItem("disconnect"),
|
|
41913
|
+
onMouseLeave: () => setHoveredItem(null),
|
|
41543
41914
|
style: {
|
|
41544
41915
|
...styles2.menuItem,
|
|
41545
|
-
...styles2.disconnectItem
|
|
41916
|
+
...styles2.disconnectItem,
|
|
41917
|
+
...hoveredItem === "disconnect" ? styles2.menuItemHover : {}
|
|
41546
41918
|
},
|
|
41547
41919
|
children: [
|
|
41548
41920
|
/* @__PURE__ */ jsxDEV3(DisconnectIcon, {
|
|
41549
41921
|
size: 14,
|
|
41550
|
-
color: "#
|
|
41922
|
+
color: "#dc2626"
|
|
41551
41923
|
}, undefined, false, undefined, this),
|
|
41552
|
-
"
|
|
41924
|
+
"Log out"
|
|
41553
41925
|
]
|
|
41554
41926
|
}, undefined, true, undefined, this)
|
|
41555
41927
|
}, undefined, false, undefined, this)
|
|
@@ -41560,23 +41932,23 @@ function RenownUserButton({
|
|
|
41560
41932
|
}
|
|
41561
41933
|
function RenownAuthButton({
|
|
41562
41934
|
className = "",
|
|
41563
|
-
|
|
41564
|
-
|
|
41565
|
-
|
|
41935
|
+
darkMode,
|
|
41936
|
+
loginContent,
|
|
41937
|
+
userContent,
|
|
41938
|
+
loadingContent,
|
|
41939
|
+
children
|
|
41566
41940
|
}) {
|
|
41567
|
-
const
|
|
41568
|
-
|
|
41569
|
-
|
|
41570
|
-
|
|
41571
|
-
|
|
41572
|
-
|
|
41573
|
-
|
|
41574
|
-
|
|
41575
|
-
if (isLoading) {
|
|
41576
|
-
if (renderLoading) {
|
|
41941
|
+
const auth = useRenownAuth();
|
|
41942
|
+
if (children) {
|
|
41943
|
+
return /* @__PURE__ */ jsxDEV4(Fragment, {
|
|
41944
|
+
children: children(auth)
|
|
41945
|
+
}, undefined, false, undefined, this);
|
|
41946
|
+
}
|
|
41947
|
+
if (auth.status === "loading" || auth.status === "checking") {
|
|
41948
|
+
if (loadingContent) {
|
|
41577
41949
|
return /* @__PURE__ */ jsxDEV4("div", {
|
|
41578
41950
|
className,
|
|
41579
|
-
children:
|
|
41951
|
+
children: loadingContent
|
|
41580
41952
|
}, undefined, false, undefined, this);
|
|
41581
41953
|
}
|
|
41582
41954
|
return /* @__PURE__ */ jsxDEV4("div", {
|
|
@@ -41584,24 +41956,44 @@ function RenownAuthButton({
|
|
|
41584
41956
|
children: [
|
|
41585
41957
|
/* @__PURE__ */ jsxDEV4("div", {
|
|
41586
41958
|
style: {
|
|
41587
|
-
|
|
41588
|
-
|
|
41589
|
-
|
|
41590
|
-
|
|
41959
|
+
display: "flex",
|
|
41960
|
+
alignItems: "center",
|
|
41961
|
+
gap: "8px",
|
|
41962
|
+
padding: "6px 12px",
|
|
41963
|
+
borderRadius: "8px",
|
|
41964
|
+
border: "1px solid #e5e7eb",
|
|
41591
41965
|
animation: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"
|
|
41592
|
-
}
|
|
41593
|
-
|
|
41966
|
+
},
|
|
41967
|
+
children: [
|
|
41968
|
+
/* @__PURE__ */ jsxDEV4("div", {
|
|
41969
|
+
style: {
|
|
41970
|
+
width: "28px",
|
|
41971
|
+
height: "28px",
|
|
41972
|
+
borderRadius: "50%",
|
|
41973
|
+
backgroundColor: "#e5e7eb"
|
|
41974
|
+
}
|
|
41975
|
+
}, undefined, false, undefined, this),
|
|
41976
|
+
/* @__PURE__ */ jsxDEV4("div", {
|
|
41977
|
+
style: {
|
|
41978
|
+
width: "80px",
|
|
41979
|
+
height: "14px",
|
|
41980
|
+
borderRadius: "4px",
|
|
41981
|
+
backgroundColor: "#e5e7eb"
|
|
41982
|
+
}
|
|
41983
|
+
}, undefined, false, undefined, this)
|
|
41984
|
+
]
|
|
41985
|
+
}, undefined, true, undefined, this),
|
|
41594
41986
|
/* @__PURE__ */ jsxDEV4("style", {
|
|
41595
41987
|
children: `@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }`
|
|
41596
41988
|
}, undefined, false, undefined, this)
|
|
41597
41989
|
]
|
|
41598
41990
|
}, undefined, true, undefined, this);
|
|
41599
41991
|
}
|
|
41600
|
-
if (
|
|
41601
|
-
if (
|
|
41992
|
+
if (auth.status === "authorized") {
|
|
41993
|
+
if (userContent) {
|
|
41602
41994
|
return /* @__PURE__ */ jsxDEV4("div", {
|
|
41603
41995
|
className,
|
|
41604
|
-
children:
|
|
41996
|
+
children: userContent
|
|
41605
41997
|
}, undefined, false, undefined, this);
|
|
41606
41998
|
}
|
|
41607
41999
|
return /* @__PURE__ */ jsxDEV4("div", {
|
|
@@ -41609,54 +42001,52 @@ function RenownAuthButton({
|
|
|
41609
42001
|
children: /* @__PURE__ */ jsxDEV4(RenownUserButton, {}, undefined, false, undefined, this)
|
|
41610
42002
|
}, undefined, false, undefined, this);
|
|
41611
42003
|
}
|
|
41612
|
-
if (
|
|
42004
|
+
if (loginContent) {
|
|
41613
42005
|
return /* @__PURE__ */ jsxDEV4("div", {
|
|
41614
42006
|
className,
|
|
41615
|
-
children:
|
|
42007
|
+
children: loginContent
|
|
41616
42008
|
}, undefined, false, undefined, this);
|
|
41617
42009
|
}
|
|
41618
42010
|
return /* @__PURE__ */ jsxDEV4("div", {
|
|
41619
42011
|
className,
|
|
41620
|
-
children: /* @__PURE__ */ jsxDEV4(RenownLoginButton, {
|
|
42012
|
+
children: /* @__PURE__ */ jsxDEV4(RenownLoginButton, {
|
|
42013
|
+
darkMode
|
|
42014
|
+
}, undefined, false, undefined, this)
|
|
41621
42015
|
}, undefined, false, undefined, this);
|
|
41622
42016
|
}
|
|
41623
|
-
function
|
|
42017
|
+
async function initRenown(appName, namespace, url) {
|
|
42018
|
+
addRenownEventHandler();
|
|
42019
|
+
setRenown(loading);
|
|
42020
|
+
const builder = new RenownBuilder(appName, {
|
|
42021
|
+
basename: namespace,
|
|
42022
|
+
baseUrl: url
|
|
42023
|
+
});
|
|
42024
|
+
const renown = await builder.build();
|
|
42025
|
+
setRenown(renown);
|
|
42026
|
+
await login(undefined, renown);
|
|
42027
|
+
return renown;
|
|
42028
|
+
}
|
|
42029
|
+
function useRenownInit({
|
|
41624
42030
|
appName,
|
|
41625
|
-
|
|
41626
|
-
|
|
41627
|
-
children
|
|
42031
|
+
namespace,
|
|
42032
|
+
url
|
|
41628
42033
|
}) {
|
|
41629
|
-
const
|
|
41630
|
-
const
|
|
42034
|
+
const promiseRef = useRef6(Promise.withResolvers());
|
|
42035
|
+
const initRef = useRef6(false);
|
|
42036
|
+
if (typeof window === "undefined") {
|
|
42037
|
+
promiseRef.current.reject(new Error("window is undefined"));
|
|
42038
|
+
return promiseRef.current.promise;
|
|
42039
|
+
}
|
|
41631
42040
|
if (initRef.current) {
|
|
41632
|
-
|
|
41633
|
-
if (appName !== initial.appName) {
|
|
41634
|
-
console.warn("RenownProvider: 'appName' changed after mount. This prop is only read once during initialization.");
|
|
41635
|
-
}
|
|
41636
|
-
if (basename !== initial.basename) {
|
|
41637
|
-
console.warn("RenownProvider: 'basename' changed after mount. This prop is only read once during initialization.");
|
|
41638
|
-
}
|
|
41639
|
-
if (baseUrl !== initial.baseUrl) {
|
|
41640
|
-
console.warn("RenownProvider: 'baseUrl' changed after mount. This prop is only read once during initialization.");
|
|
41641
|
-
}
|
|
42041
|
+
return promiseRef.current.promise;
|
|
41642
42042
|
}
|
|
41643
|
-
|
|
41644
|
-
|
|
41645
|
-
|
|
41646
|
-
|
|
41647
|
-
|
|
41648
|
-
|
|
41649
|
-
|
|
41650
|
-
addRenownEventHandler();
|
|
41651
|
-
const init = async () => {
|
|
41652
|
-
const builder = new RenownBuilder(appName, { basename, baseUrl });
|
|
41653
|
-
const instance = await builder.build();
|
|
41654
|
-
setRenown(instance);
|
|
41655
|
-
await login(undefined, instance);
|
|
41656
|
-
};
|
|
41657
|
-
init().catch(console.error);
|
|
41658
|
-
}, []);
|
|
41659
|
-
return children;
|
|
42043
|
+
initRef.current = true;
|
|
42044
|
+
initRenown(appName, namespace, url).then(promiseRef.current.resolve).catch(promiseRef.current.reject);
|
|
42045
|
+
return promiseRef.current.promise;
|
|
42046
|
+
}
|
|
42047
|
+
function Renown2({ onError, ...initOptions }) {
|
|
42048
|
+
useRenownInit(initOptions).catch(onError ?? console.error);
|
|
42049
|
+
return null;
|
|
41660
42050
|
}
|
|
41661
42051
|
var __create2, __getProtoOf2, __defProp3, __getOwnPropNames2, __getOwnPropDesc2, __hasOwnProp2, __toESM2 = (mod, isNodeMode, target) => {
|
|
41662
42052
|
target = mod != null ? __create2(__getProtoOf2(mod)) : {};
|
|
@@ -42222,13 +42612,13 @@ ${String(result)}`);
|
|
|
42222
42612
|
return t;
|
|
42223
42613
|
};
|
|
42224
42614
|
return __assign.apply(this, arguments);
|
|
42225
|
-
}, docCache, fragmentSourceMap, printFragmentWarnings = true, experimentalFragmentVariables = false, extras, PropagationMode2, PhDocumentFieldsFragmentDoc, GetDocumentModelsDocument, GetDocumentDocument, GetDocumentChildrenDocument, GetDocumentParentsDocument, FindDocumentsDocument, GetDocumentOperationsDocument, GetJobStatusDocument, CreateDocumentDocument, CreateEmptyDocumentDocument, MutateDocumentDocument, MutateDocumentAsyncDocument, RenameDocumentDocument, AddChildrenDocument, RemoveChildrenDocument, MoveChildrenDocument, DeleteDocumentDocument, DeleteDocumentsDocument, DocumentChangesDocument, JobChangesDocument, PollSyncEnvelopesDocument, TouchChannelDocument, PushSyncEnvelopesDocument, defaultWrapper = (action, _operationName, _operationType, _variables) => action(), SPLIT_LOWER_UPPER_RE, SPLIT_UPPER_UPPER_RE, SPLIT_SEPARATE_NUMBER_RE, DEFAULT_STRIP_REGEXP, SPLIT_REPLACE_VALUE = "$1\x00$2", DEFAULT_PREFIX_SUFFIX_CHARACTERS = "", isExternalControlsEnabledEventFunctions, setIsExternalControlsEnabled, useIsExternalControlsEnabled, addIsExternalControlsEnabledEventHandler, isDragAndDropEnabledEventFunctions, setIsDragAndDropEnabled, useIsDragAndDropEnabled, addIsDragAndDropEnabledEventHandler, allowedDocumentTypesEventFunctions, setAllowedDocumentTypes, addAllowedDocumentTypesEventHandler, phDriveEditorConfigSetters, phDocumentEditorConfigSetters, phDriveEditorConfigHooks, phDocumentEditorConfigHooks, vetraPackageManagerFunctions, useVetraPackageManager, useVetraPackages = () => {
|
|
42615
|
+
}, docCache, fragmentSourceMap, printFragmentWarnings = true, experimentalFragmentVariables = false, extras, PropagationMode2, PhDocumentFieldsFragmentDoc, GetDocumentModelsDocument, GetDocumentDocument, GetDocumentChildrenDocument, GetDocumentParentsDocument, FindDocumentsDocument, GetDocumentOperationsDocument, GetJobStatusDocument, CreateDocumentDocument, CreateEmptyDocumentDocument, MutateDocumentDocument, MutateDocumentAsyncDocument, RenameDocumentDocument, AddChildrenDocument, RemoveChildrenDocument, MoveChildrenDocument, DeleteDocumentDocument, DeleteDocumentsDocument, DocumentChangesDocument, JobChangesDocument, PollSyncEnvelopesDocument, TouchChannelDocument, PushSyncEnvelopesDocument, defaultWrapper = (action, _operationName, _operationType, _variables) => action(), SPLIT_LOWER_UPPER_RE, SPLIT_UPPER_UPPER_RE, SPLIT_SEPARATE_NUMBER_RE, DEFAULT_STRIP_REGEXP, SPLIT_REPLACE_VALUE = "$1\x00$2", DEFAULT_PREFIX_SUFFIX_CHARACTERS = "", isServer, useLoading, setLoading, addLoadingEventHandler, loading = null, renownEventFunctions, addRenownEventHandler, useRenown, setRenown, RENOWN_URL = "https://www.renown.id", RENOWN_NETWORK_ID = "eip155", RENOWN_CHAIN_ID = "1", DOMAIN_TYPE, VERIFIABLE_CREDENTIAL_EIP712_TYPE, CREDENTIAL_SCHEMA_EIP712_TYPE, CREDENTIAL_SUBJECT_TYPE, ISSUER_TYPE, CREDENTIAL_TYPES, isExternalControlsEnabledEventFunctions, setIsExternalControlsEnabled, useIsExternalControlsEnabled, addIsExternalControlsEnabledEventHandler, isDragAndDropEnabledEventFunctions, setIsDragAndDropEnabled, useIsDragAndDropEnabled, addIsDragAndDropEnabledEventHandler, allowedDocumentTypesEventFunctions, setAllowedDocumentTypes, addAllowedDocumentTypesEventHandler, phDriveEditorConfigSetters, phDocumentEditorConfigSetters, phDriveEditorConfigHooks, phDocumentEditorConfigHooks, vetraPackageManagerFunctions, useVetraPackageManager, useVetraPackages = () => {
|
|
42226
42616
|
const packageManager = useVetraPackageManager();
|
|
42227
|
-
return
|
|
42228
|
-
}, addVetraPackageManagerEventHandler, reactorClientModuleEventFunctions, reactorClientEventFunctions, useReactorClientModule, setReactorClientModule, addReactorClientModuleEventHandler, useReactorClient, setReactorClient, addReactorClientEventHandler, useSync = () => useReactorClientModule()?.reactorModule?.syncModule?.syncManager, useSyncList = () => {
|
|
42617
|
+
return useSyncExternalStore3((cb) => packageManager ? packageManager.subscribe(cb) : () => {}, () => packageManager?.packages ?? []);
|
|
42618
|
+
}, addVetraPackageManagerEventHandler, EMPTY_PENDING, EMPTY_DISMISSED, NOOP_UNSUBSCRIBE = () => {}, documentEventFunctions, useDocumentCache, setDocumentCache, addDocumentCacheEventHandler, base64, locales, defaultLocale, initialMulticharmap, initialCharmap, slug_default, drivesEventFunctions, useDrives, setDrives, addDrivesEventHandler, selectedDriveIdEventFunctions, useSelectedDriveId, setSelectedDriveId, addSelectedDriveIdEventHandler, selectedNodeIdEventFunctions, useSelectedNodeId, setSelectedNodeId, addSelectedNodeIdEventHandler, useRouterBasename, setRouterBasename, addRouterBasenameEventHandler, useVersion, setVersion, addVersionEventHandler, useRequiresHardRefresh, setRequiresHardRefresh, addRequiresHardRefreshEventHandler, useWarnOutdatedApp, setWarnOutdatedApp, addWarnOutdatedAppEventHandler, useStudioMode, setStudioMode, addStudioModeEventHandler, useBasePath, setBasePath, addBasePathEventHandler, useVersionCheckInterval, setVersionCheckInterval, addVersionCheckIntervalEventHandler, useCliVersion, setCliVersion, addCliVersionEventHandler, useFileUploadOperationsChunkSize, setFileUploadOperationsChunkSize, addFileUploadOperationsChunkSizeEventHandler, useIsDocumentModelSelectionSettingsEnabled, setIsDocumentModelSelectionSettingsEnabled, addIsDocumentModelSelectionSettingsEnabledEventHandler, useGaTrackingId, setGaTrackingId, addGaTrackingIdEventHandler, useDefaultDrivesUrl, setDefaultDrivesUrl, addDefaultDrivesUrlEventHandler, useDrivesPreserveStrategy, setDrivesPreserveStrategy, addDrivesPreserveStrategyEventHandler, useIsLocalDrivesEnabled, setIsLocalDrivesEnabled, addIsLocalDrivesEnabledEventHandler, useIsAddDriveEnabled, setIsAddDriveEnabled, addIsAddDriveEnabledEventHandler, useIsPublicDrivesEnabled, setIsPublicDrivesEnabled, addIsPublicDrivesEnabledEventHandler, useIsAddPublicDrivesEnabled, setIsAddPublicDrivesEnabled, addIsAddPublicDrivesEnabledEventHandler, useIsDeletePublicDrivesEnabled, setIsDeletePublicDrivesEnabled, addIsDeletePublicDrivesEnabledEventHandler, useIsCloudDrivesEnabled, setIsCloudDrivesEnabled, addIsCloudDrivesEnabledEventHandler, useIsAddCloudDrivesEnabled, setIsAddCloudDrivesEnabled, addIsAddCloudDrivesEnabledEventHandler, useIsDeleteCloudDrivesEnabled, setIsDeleteCloudDrivesEnabled, addIsDeleteCloudDrivesEnabledEventHandler, useLocalDrivesEnabled, setLocalDrivesEnabled, addLocalDrivesEnabledEventHandler, useIsAddLocalDrivesEnabled, setIsAddLocalDrivesEnabled, addIsAddLocalDrivesEnabledEventHandler, useIsDeleteLocalDrivesEnabled, setIsDeleteLocalDrivesEnabled, addIsDeleteLocalDrivesEnabledEventHandler, useIsEditorDebugModeEnabled, setIsEditorDebugModeEnabled, addIsEditorDebugModeEnabledEventHandler, useIsEditorReadModeEnabled, setIsEditorReadModeEnabled, addIsEditorReadModeEnabledEventHandler, useIsAnalyticsDatabaseWorkerEnabled, setIsAnalyticsDatabaseWorkerEnabled, addIsAnalyticsDatabaseWorkerEnabledEventHandler, useIsDiffAnalyticsEnabled, setIsDiffAnalyticsEnabled, addIsDiffAnalyticsEnabledEventHandler, useIsDriveAnalyticsEnabled, setIsDriveAnalyticsEnabled, addIsDriveAnalyticsEnabledEventHandler, useRenownUrl, setRenownUrl, addRenownUrlEventHandler, useRenownNetworkId, setRenownNetworkId, addRenownNetworkIdEventHandler, useRenownChainId, setRenownChainId, addRenownChainIdEventHandler, useSentryRelease, setSentryRelease, addSentryReleaseEventHandler, useSentryDsn, setSentryDsn, addSentryDsnEventHandler, useSentryEnv, setSentryEnv, addSentryEnvEventHandler, useIsSentryTracingEnabled, setIsSentryTracingEnabled, addIsSentryTracingEnabledEventHandler, useIsExternalProcessorsEnabled, setIsExternalProcessorsEnabled, addIsExternalProcessorsEnabledEventHandler, useIsExternalPackagesEnabled, setIsExternalPackagesEnabled, addIsExternalPackagesEnabledEventHandler, enabledEditorsEventFunctions, setEnabledEditors, useEnabledEditors, addEnabledEditorsEventHandler, disabledEditorsEventFunctions, setDisabledEditors, useDisabledEditors, addDisabledEditorsEventHandler, isRelationalProcessorsEnabled, setIsRelationalProcessorsEnabled, useIsRelationalProcessorsEnabled, addIsRelationalProcessorsEnabledEventHandler, isExternalRelationalProcessorsEnabled, setIsExternalRelationalProcessorsEnabled, useIsExternalRelationalProcessorsEnabled, addIsExternalRelationalProcessorsEnabledEventHandler, isAnalyticsEnabledEventFunctions, setIsAnalyticsEnabled, useIsAnalyticsEnabled, addIsAnalyticsEnabledEventHandler, isAnalyticsExternalProcessorsEnabled, setIsAnalyticsExternalProcessorsEnabled, useIsAnalyticsExternalProcessorsEnabled, addIsAnalyticsExternalProcessorsEnabledEventHandler, analyticsDatabaseNameEventFunctions, setAnalyticsDatabaseName, useAnalyticsDatabaseName, addAnalyticsDatabaseNameEventHandler, logLevelEventFunctions, setLogLevel2, useLogLevel, addLogLevelEventHandler, allowListEventFunctions, setAllowList, useAllowList, addAllowListEventHandler, nonUserConfigSetters, phGlobalConfigSetters, nonUserConfigHooks, phGlobalConfigHooks, reactorClientModuleEventFunctions, reactorClientEventFunctions, useReactorClientModule, setReactorClientModule, addReactorClientModuleEventHandler, useReactorClient, setReactorClient, addReactorClientEventHandler, useSync = () => useReactorClientModule()?.reactorModule?.syncModule?.syncManager, useSyncList = () => {
|
|
42229
42619
|
const sync = useSync();
|
|
42230
42620
|
return sync?.list() ?? [];
|
|
42231
|
-
},
|
|
42621
|
+
}, featuresEventFunctions, useFeatures, setFeatures, addFeaturesEventHandler, modalEventFunctions, usePHModal, setPHModal, addModalEventHandler, revisionHistoryEventFunctions, useRevisionHistoryVisible, setRevisionHistoryVisible, addRevisionHistoryVisibleEventHandler, selectedTimelineItemEventFunctions, useSelectedTimelineItem, setSelectedTimelineItem, addSelectedTimelineItemEventHandler, selectedTimelineRevisionEventFunctions, useSelectedTimelineRevision, setSelectedTimelineRevision, addSelectedTimelineRevisionEventHandler, toastEventFunctions, usePHToast, setPHToast, addToastEventHandler, FEATURE_INSPECTOR_ENABLED = "FEATURE_INSPECTOR_ENABLED", FEATURE_INSPECTOR_ENABLED_DEFAULT = false, syncStatusToUI, validateDocument = (document2) => {
|
|
42232
42622
|
const errors2 = [];
|
|
42233
42623
|
if (document2.header.documentType !== "powerhouse/document-model") {
|
|
42234
42624
|
return errors2;
|
|
@@ -42280,7 +42670,7 @@ ${String(result)}`);
|
|
|
42280
42670
|
return operationDate >= startDate && operationDate <= endDate;
|
|
42281
42671
|
});
|
|
42282
42672
|
return operation ? operation.index : 0;
|
|
42283
|
-
}, lzString,
|
|
42673
|
+
}, lzString, useOnDropFile = (documentTypesOverride) => {
|
|
42284
42674
|
const selectedDriveId = useSelectedDriveId();
|
|
42285
42675
|
const selectedFolder = useSelectedFolder();
|
|
42286
42676
|
const documentTypes = useDocumentTypes();
|
|
@@ -42294,7 +42684,7 @@ ${String(result)}`);
|
|
|
42294
42684
|
return await addFileWithProgress(file, selectedDriveId, fileName, targetNodeId, onProgress, documentTypesOverride ?? documentTypes, resolveConflict);
|
|
42295
42685
|
};
|
|
42296
42686
|
return onDropFile;
|
|
42297
|
-
}, store, BrowserLocalStorage, PGLITE_UPDATE_EVENT = "ph:pglite-update", defaultPGliteState, usePGliteDB = () => {
|
|
42687
|
+
}, store, BrowserLocalStorage, DISMISSED_STORAGE_KEY = "ph-connect-dismissed-packages", PGLITE_UPDATE_EVENT = "ph:pglite-update", defaultPGliteState, usePGliteDB = () => {
|
|
42298
42688
|
const [state, setState] = useState5(() => window.powerhouse?.pglite ?? defaultPGliteState);
|
|
42299
42689
|
useEffect5(() => {
|
|
42300
42690
|
const handlePgliteUpdate = () => setState(window.powerhouse?.pglite ?? defaultPGliteState);
|
|
@@ -42320,7 +42710,7 @@ ${String(result)}`);
|
|
|
42320
42710
|
const pglite = usePGliteDB();
|
|
42321
42711
|
const setPGlite = useSetPGliteDB();
|
|
42322
42712
|
return [pglite, setPGlite];
|
|
42323
|
-
}, DEFAULT_RENOWN_URL = "https://www.renown.id", crypto2, isLE, swap32IfBE, hasHexBuiltin, hexes, asciis, HashMD, SHA256_IV, SHA384_IV, SHA512_IV, U32_MASK64, _32n, shrSH = (h, _l, s) => h >>> s, shrSL = (h, l, s) => h << 32 - s | l >>> s, rotrSH = (h, l, s) => h >>> s | l << 32 - s, rotrSL = (h, l, s) => h << 32 - s | l >>> s, rotrBH = (h, l, s) => h << 64 - s | l >>> s - 32, rotrBL = (h, l, s) => h >>> s - 32 | l << 64 - s, rotlSH = (h, l, s) => h << s | l >>> 32 - s, rotlSL = (h, l, s) => l << s | h >>> 32 - s, rotlBH = (h, l, s) => l << s - 32 | h >>> 64 - s, rotlBL = (h, l, s) => h << s - 32 | l >>> 64 - s, add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0), add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low /
|
|
42713
|
+
}, DEFAULT_RENOWN_URL = "https://www.renown.id", crypto2, isLE, swap32IfBE, hasHexBuiltin, hexes, asciis, HashMD, SHA256_IV, SHA384_IV, SHA512_IV, U32_MASK64, _32n, shrSH = (h, _l, s) => h >>> s, shrSL = (h, l, s) => h << 32 - s | l >>> s, rotrSH = (h, l, s) => h >>> s | l << 32 - s, rotrSL = (h, l, s) => h << 32 - s | l >>> s, rotrBH = (h, l, s) => h << 64 - s | l >>> s - 32, rotrBL = (h, l, s) => h >>> s - 32 | l << 64 - s, rotlSH = (h, l, s) => h << s | l >>> 32 - s, rotlSL = (h, l, s) => l << s | h >>> 32 - s, rotlBH = (h, l, s) => l << s - 32 | h >>> 64 - s, rotlBL = (h, l, s) => h << s - 32 | l >>> 64 - s, add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0), add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0, add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0), add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0, add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0), add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0, SHA256_K, SHA256_W, SHA256, K512, SHA512_Kh, SHA512_Kl, SHA512_W_H, SHA512_W_L, SHA512, SHA384, sha2562, sha5122, sha384, _0n, _1n, isPosBig = (n) => typeof n === "bigint" && _0n <= n, bitMask = (n) => (_1n << BigInt(n)) - _1n, notImplemented = () => {
|
|
42324
42714
|
throw new Error("not implemented");
|
|
42325
42715
|
}, _0n2, _1n2, _2n, _3n, _4n, _5n, _7n, _8n, _9n, _16n, isNegativeLE = (num, modulo) => (mod(num, modulo) & _1n2) === _1n2, FIELD_FIELDS, _0n3, _1n3, pointPrecomputes, pointWindowSizes, _0n4, _1n4, _2n2, _8n2, _0n5, _1n5, _2n3, _3n2, _5n2, _8n3, ed25519_CURVE_p, ed25519_CURVE, ED25519_SQRT_M1, Fp, Fn, ed25519Defaults, ed25519, SQRT_M1, SQRT_AD_MINUS_ONE, INVSQRT_A_MINUS_D, ONE_MINUS_D_SQ, D_MINUS_ONE_SQ, invertSqrt = (number) => uvRatio(_1n5, number), MAX_255B, bytes255ToNumberLE = (bytes) => ed25519.Point.Fp.create(bytesToNumberLE(bytes) & MAX_255B), _RistrettoPoint, import_multibase, HMAC, hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest(), divNearest = (num, den) => (num + (num >= 0 ? den : -den) / _2n4) / den, DERErr, DER, _0n6, _1n6, _2n4, _3n3, _4n2, secp256k1_CURVE, secp256k1_ENDO, _2n5, Fpk1, secp256k1, p256_CURVE, p384_CURVE, p521_CURVE, Fp256, Fp384, Fp521, p256, p384, p521, p2562, sha2563, Rho160, Id160, Pi160, idxLR, idxL, idxR, shifts160, shiftsL160, shiftsR160, Kl160, Kr160, BUF_160, RIPEMD160, ripemd160, ripemd1602, _0n7, _1n7, _2n6, _7n2, _256n, _0x71n, SHA3_PI, SHA3_ROTL, _SHA3_IOTA, IOTAS, SHA3_IOTA_H, SHA3_IOTA_L, rotlH = (h, l, s) => s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s), rotlL = (h, l, s) => s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s), Keccak, gen = (suffix, blockLen, outputLen) => createHasher(() => new Keccak(blockLen, suffix, outputLen)), keccak_256, import_canonicalize, PCT_ENCODED = "(?:%[0-9a-fA-F]{2})", ID_CHAR, METHOD = "([a-z0-9]+)", METHOD_ID, PARAM_CHAR = "[a-zA-Z0-9_.:%-]", PARAM, PARAMS, PATH = `(/[^#?]*)?`, QUERY = `([?][^#]*)?`, FRAGMENT = `(#.*)?`, DID_MATCHER, EMPTY_RESULT, gcd = (a, b) => b === 0 ? a : gcd(b, a % b), radix2carry = (from3, to) => from3 + (to - gcd(from3, to)), powers, base162, base322, base32nopad, base32hex2, base32hexnopad, base32crockford, hasBase64Builtin, decodeBase64Builtin = (s, isUrl) => {
|
|
42326
42716
|
astr("base64", s);
|
|
@@ -43095,7 +43485,7 @@ ${String(result)}`);
|
|
|
43095
43485
|
}, MAX_RETRIES = 5, RETRY_DELAY = 200, isRelationNotExistError = (error) => {
|
|
43096
43486
|
const errorMessage = error instanceof Error ? error.message : typeof error === "string" ? error : String(error);
|
|
43097
43487
|
return errorMessage.toLowerCase().includes("relation") && errorMessage.toLowerCase().includes("does not exist");
|
|
43098
|
-
}, import_lodash, ConflictError,
|
|
43488
|
+
}, import_lodash, ConflictError, Slot, lightStyles, darkStyles, styles, POPOVER_GAP = 4, POPOVER_HEIGHT = 150, styles2;
|
|
43099
43489
|
var init_src2 = __esm(() => {
|
|
43100
43490
|
init_src();
|
|
43101
43491
|
init_src();
|
|
@@ -47452,6 +47842,52 @@ spurious results.`);
|
|
|
47452
47842
|
SPLIT_UPPER_UPPER_RE = /(\p{Lu})([\p{Lu}][\p{Ll}])/gu;
|
|
47453
47843
|
SPLIT_SEPARATE_NUMBER_RE = /(\d)\p{Ll}|(\p{L})\d/u;
|
|
47454
47844
|
DEFAULT_STRIP_REGEXP = /[^\p{L}\d]+/giu;
|
|
47845
|
+
isServer = typeof window === "undefined";
|
|
47846
|
+
({
|
|
47847
|
+
useValue: useLoading,
|
|
47848
|
+
setValue: setLoading,
|
|
47849
|
+
addEventHandler: addLoadingEventHandler
|
|
47850
|
+
} = makePHEventFunctions("loading"));
|
|
47851
|
+
renownEventFunctions = makePHEventFunctions("renown");
|
|
47852
|
+
addRenownEventHandler = renownEventFunctions.addEventHandler;
|
|
47853
|
+
useRenown = renownEventFunctions.useValue;
|
|
47854
|
+
setRenown = renownEventFunctions.setValue;
|
|
47855
|
+
DOMAIN_TYPE = [
|
|
47856
|
+
{ name: "name", type: "string" },
|
|
47857
|
+
{ name: "version", type: "string" },
|
|
47858
|
+
{ name: "chainId", type: "uint256" },
|
|
47859
|
+
{ name: "verifyingContract", type: "address" }
|
|
47860
|
+
];
|
|
47861
|
+
VERIFIABLE_CREDENTIAL_EIP712_TYPE = [
|
|
47862
|
+
{ name: "@context", type: "string[]" },
|
|
47863
|
+
{ name: "type", type: "string[]" },
|
|
47864
|
+
{ name: "id", type: "string" },
|
|
47865
|
+
{ name: "issuer", type: "Issuer" },
|
|
47866
|
+
{ name: "credentialSubject", type: "CredentialSubject" },
|
|
47867
|
+
{ name: "credentialSchema", type: "CredentialSchema" },
|
|
47868
|
+
{ name: "issuanceDate", type: "string" },
|
|
47869
|
+
{ name: "expirationDate", type: "string" }
|
|
47870
|
+
];
|
|
47871
|
+
CREDENTIAL_SCHEMA_EIP712_TYPE = [
|
|
47872
|
+
{ name: "id", type: "string" },
|
|
47873
|
+
{ name: "type", type: "string" }
|
|
47874
|
+
];
|
|
47875
|
+
CREDENTIAL_SUBJECT_TYPE = [
|
|
47876
|
+
{ name: "app", type: "string" },
|
|
47877
|
+
{ name: "id", type: "string" },
|
|
47878
|
+
{ name: "name", type: "string" }
|
|
47879
|
+
];
|
|
47880
|
+
ISSUER_TYPE = [
|
|
47881
|
+
{ name: "id", type: "string" },
|
|
47882
|
+
{ name: "ethereumAddress", type: "string" }
|
|
47883
|
+
];
|
|
47884
|
+
CREDENTIAL_TYPES = {
|
|
47885
|
+
EIP712Domain: DOMAIN_TYPE,
|
|
47886
|
+
VerifiableCredential: VERIFIABLE_CREDENTIAL_EIP712_TYPE,
|
|
47887
|
+
CredentialSchema: CREDENTIAL_SCHEMA_EIP712_TYPE,
|
|
47888
|
+
CredentialSubject: CREDENTIAL_SUBJECT_TYPE,
|
|
47889
|
+
Issuer: ISSUER_TYPE
|
|
47890
|
+
};
|
|
47455
47891
|
isExternalControlsEnabledEventFunctions = makePHEventFunctions("isExternalControlsEnabled");
|
|
47456
47892
|
setIsExternalControlsEnabled = isExternalControlsEnabledEventFunctions.setValue;
|
|
47457
47893
|
useIsExternalControlsEnabled = isExternalControlsEnabledEventFunctions.useValue;
|
|
@@ -47480,14 +47916,8 @@ spurious results.`);
|
|
|
47480
47916
|
vetraPackageManagerFunctions = makePHEventFunctions("vetraPackageManager");
|
|
47481
47917
|
useVetraPackageManager = vetraPackageManagerFunctions.useValue;
|
|
47482
47918
|
addVetraPackageManagerEventHandler = vetraPackageManagerFunctions.addEventHandler;
|
|
47483
|
-
|
|
47484
|
-
|
|
47485
|
-
useReactorClientModule = reactorClientModuleEventFunctions.useValue;
|
|
47486
|
-
setReactorClientModule = reactorClientModuleEventFunctions.setValue;
|
|
47487
|
-
addReactorClientModuleEventHandler = reactorClientModuleEventFunctions.addEventHandler;
|
|
47488
|
-
useReactorClient = reactorClientEventFunctions.useValue;
|
|
47489
|
-
setReactorClient = reactorClientEventFunctions.setValue;
|
|
47490
|
-
addReactorClientEventHandler = reactorClientEventFunctions.addEventHandler;
|
|
47919
|
+
EMPTY_PENDING = [];
|
|
47920
|
+
EMPTY_DISMISSED = [];
|
|
47491
47921
|
documentEventFunctions = makePHEventFunctions("documentCache");
|
|
47492
47922
|
useDocumentCache = documentEventFunctions.useValue;
|
|
47493
47923
|
setDocumentCache = documentEventFunctions.setValue;
|
|
@@ -48535,6 +48965,14 @@ spurious results.`);
|
|
|
48535
48965
|
...phDocumentEditorConfigHooks,
|
|
48536
48966
|
...nonUserConfigHooks
|
|
48537
48967
|
};
|
|
48968
|
+
reactorClientModuleEventFunctions = makePHEventFunctions("reactorClientModule");
|
|
48969
|
+
reactorClientEventFunctions = makePHEventFunctions("reactorClient");
|
|
48970
|
+
useReactorClientModule = reactorClientModuleEventFunctions.useValue;
|
|
48971
|
+
setReactorClientModule = reactorClientModuleEventFunctions.setValue;
|
|
48972
|
+
addReactorClientModuleEventHandler = reactorClientModuleEventFunctions.addEventHandler;
|
|
48973
|
+
useReactorClient = reactorClientEventFunctions.useValue;
|
|
48974
|
+
setReactorClient = reactorClientEventFunctions.setValue;
|
|
48975
|
+
addReactorClientEventHandler = reactorClientEventFunctions.addEventHandler;
|
|
48538
48976
|
featuresEventFunctions = makePHEventFunctions("features");
|
|
48539
48977
|
useFeatures = featuresEventFunctions.useValue;
|
|
48540
48978
|
setFeatures = featuresEventFunctions.setValue;
|
|
@@ -48567,51 +49005,6 @@ spurious results.`);
|
|
|
48567
49005
|
[SyncStatus.Error]: "ERROR"
|
|
48568
49006
|
};
|
|
48569
49007
|
lzString = __toESM2(require_lz_string(), 1);
|
|
48570
|
-
DOMAIN_TYPE = [
|
|
48571
|
-
{ name: "name", type: "string" },
|
|
48572
|
-
{ name: "version", type: "string" },
|
|
48573
|
-
{ name: "chainId", type: "uint256" },
|
|
48574
|
-
{ name: "verifyingContract", type: "address" }
|
|
48575
|
-
];
|
|
48576
|
-
VERIFIABLE_CREDENTIAL_EIP712_TYPE = [
|
|
48577
|
-
{ name: "@context", type: "string[]" },
|
|
48578
|
-
{ name: "type", type: "string[]" },
|
|
48579
|
-
{ name: "id", type: "string" },
|
|
48580
|
-
{ name: "issuer", type: "Issuer" },
|
|
48581
|
-
{ name: "credentialSubject", type: "CredentialSubject" },
|
|
48582
|
-
{ name: "credentialSchema", type: "CredentialSchema" },
|
|
48583
|
-
{ name: "issuanceDate", type: "string" },
|
|
48584
|
-
{ name: "expirationDate", type: "string" }
|
|
48585
|
-
];
|
|
48586
|
-
CREDENTIAL_SCHEMA_EIP712_TYPE = [
|
|
48587
|
-
{ name: "id", type: "string" },
|
|
48588
|
-
{ name: "type", type: "string" }
|
|
48589
|
-
];
|
|
48590
|
-
CREDENTIAL_SUBJECT_TYPE = [
|
|
48591
|
-
{ name: "app", type: "string" },
|
|
48592
|
-
{ name: "id", type: "string" },
|
|
48593
|
-
{ name: "name", type: "string" }
|
|
48594
|
-
];
|
|
48595
|
-
ISSUER_TYPE = [
|
|
48596
|
-
{ name: "id", type: "string" },
|
|
48597
|
-
{ name: "ethereumAddress", type: "string" }
|
|
48598
|
-
];
|
|
48599
|
-
CREDENTIAL_TYPES = {
|
|
48600
|
-
EIP712Domain: DOMAIN_TYPE,
|
|
48601
|
-
VerifiableCredential: VERIFIABLE_CREDENTIAL_EIP712_TYPE,
|
|
48602
|
-
CredentialSchema: CREDENTIAL_SCHEMA_EIP712_TYPE,
|
|
48603
|
-
CredentialSubject: CREDENTIAL_SUBJECT_TYPE,
|
|
48604
|
-
Issuer: ISSUER_TYPE
|
|
48605
|
-
};
|
|
48606
|
-
({
|
|
48607
|
-
useValue: useLoading,
|
|
48608
|
-
setValue: setLoading,
|
|
48609
|
-
addEventHandler: addLoadingEventHandler
|
|
48610
|
-
} = makePHEventFunctions("loading"));
|
|
48611
|
-
renownEventFunctions = makePHEventFunctions("renown");
|
|
48612
|
-
useRenown = renownEventFunctions.useValue;
|
|
48613
|
-
setRenown = renownEventFunctions.setValue;
|
|
48614
|
-
addRenownEventHandler = renownEventFunctions.addEventHandler;
|
|
48615
49008
|
store = {
|
|
48616
49009
|
get: function(key) {
|
|
48617
49010
|
const value = localStorage.getItem(key);
|
|
@@ -48784,7 +49177,7 @@ spurious results.`);
|
|
|
48784
49177
|
1541459225,
|
|
48785
49178
|
327033209
|
|
48786
49179
|
]);
|
|
48787
|
-
U32_MASK64 = /* @__PURE__ */ BigInt(
|
|
49180
|
+
U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
48788
49181
|
_32n = /* @__PURE__ */ BigInt(32);
|
|
48789
49182
|
SHA256_K = /* @__PURE__ */ Uint32Array.from([
|
|
48790
49183
|
1116352408,
|
|
@@ -49334,7 +49727,7 @@ spurious results.`);
|
|
|
49334
49727
|
this.iHash.update(pad);
|
|
49335
49728
|
this.oHash = hash.create();
|
|
49336
49729
|
for (let i = 0;i < pad.length; i++)
|
|
49337
|
-
pad[i] ^=
|
|
49730
|
+
pad[i] ^= 54 ^ 92;
|
|
49338
49731
|
this.oHash.update(pad);
|
|
49339
49732
|
clean(pad);
|
|
49340
49733
|
}
|
|
@@ -49599,11 +49992,11 @@ spurious results.`);
|
|
|
49599
49992
|
RIPEMD160 = class RIPEMD160 extends HashMD {
|
|
49600
49993
|
constructor() {
|
|
49601
49994
|
super(64, 20, 8, true);
|
|
49602
|
-
this.h0 = 1732584193;
|
|
49603
|
-
this.h1 =
|
|
49604
|
-
this.h2 =
|
|
49605
|
-
this.h3 = 271733878;
|
|
49606
|
-
this.h4 =
|
|
49995
|
+
this.h0 = 1732584193 | 0;
|
|
49996
|
+
this.h1 = 4023233417 | 0;
|
|
49997
|
+
this.h2 = 2562383102 | 0;
|
|
49998
|
+
this.h3 = 271733878 | 0;
|
|
49999
|
+
this.h4 = 3285377520 | 0;
|
|
49607
50000
|
}
|
|
49608
50001
|
get() {
|
|
49609
50002
|
const { h0, h1, h2, h3, h4 } = this;
|
|
@@ -49781,7 +50174,7 @@ spurious results.`);
|
|
|
49781
50174
|
return to;
|
|
49782
50175
|
}
|
|
49783
50176
|
};
|
|
49784
|
-
keccak_256 = /* @__PURE__ */ (() => gen(1, 136,
|
|
50177
|
+
keccak_256 = /* @__PURE__ */ (() => gen(1, 136, 256 / 8))();
|
|
49785
50178
|
import_canonicalize = __toESM2(require_canonicalize(), 1);
|
|
49786
50179
|
ID_CHAR = `(?:[a-zA-Z0-9._-]|${PCT_ENCODED})`;
|
|
49787
50180
|
METHOD_ID = `((?:${ID_CHAR}*:)*(${ID_CHAR}+))`;
|
|
@@ -54632,72 +55025,63 @@ spurious results.`);
|
|
|
54632
55025
|
this.name = "ConflictError";
|
|
54633
55026
|
}
|
|
54634
55027
|
};
|
|
54635
|
-
|
|
55028
|
+
Slot = forwardRef(({ children, ...props }, ref) => {
|
|
55029
|
+
const child = Children.only(children);
|
|
55030
|
+
if (!isValidElement(child)) {
|
|
55031
|
+
return null;
|
|
55032
|
+
}
|
|
55033
|
+
const childElement = child;
|
|
55034
|
+
const mergedProps = mergeProps(props, childElement.props);
|
|
55035
|
+
if (ref) {
|
|
55036
|
+
mergedProps.ref = ref;
|
|
55037
|
+
}
|
|
55038
|
+
return cloneElement(childElement, mergedProps);
|
|
55039
|
+
});
|
|
55040
|
+
Slot.displayName = "Slot";
|
|
55041
|
+
lightStyles = {
|
|
54636
55042
|
trigger: {
|
|
54637
|
-
|
|
54638
|
-
|
|
54639
|
-
|
|
54640
|
-
|
|
54641
|
-
|
|
54642
|
-
background: "transparent",
|
|
54643
|
-
cursor: "pointer"
|
|
54644
|
-
},
|
|
54645
|
-
popoverBase: {
|
|
54646
|
-
position: "absolute",
|
|
54647
|
-
left: 0,
|
|
54648
|
-
borderRadius: "8px",
|
|
54649
|
-
width: "208px",
|
|
54650
|
-
zIndex: 1000
|
|
54651
|
-
},
|
|
54652
|
-
popoverLight: {
|
|
54653
|
-
backgroundColor: "white",
|
|
54654
|
-
boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"
|
|
55043
|
+
backgroundColor: "#ffffff",
|
|
55044
|
+
borderWidth: "1px",
|
|
55045
|
+
borderStyle: "solid",
|
|
55046
|
+
borderColor: "#d1d5db",
|
|
55047
|
+
color: "#111827"
|
|
54655
55048
|
},
|
|
54656
|
-
|
|
55049
|
+
triggerHover: {
|
|
55050
|
+
backgroundColor: "#ecf3f8",
|
|
55051
|
+
borderColor: "#9ca3af"
|
|
55052
|
+
}
|
|
55053
|
+
};
|
|
55054
|
+
darkStyles = {
|
|
55055
|
+
trigger: {
|
|
54657
55056
|
backgroundColor: "#1f2937",
|
|
54658
|
-
|
|
54659
|
-
|
|
54660
|
-
|
|
54661
|
-
|
|
55057
|
+
borderWidth: "1px",
|
|
55058
|
+
borderStyle: "solid",
|
|
55059
|
+
borderColor: "#4b5563",
|
|
55060
|
+
color: "#ecf3f8"
|
|
54662
55061
|
},
|
|
54663
|
-
|
|
54664
|
-
|
|
54665
|
-
|
|
54666
|
-
|
|
54667
|
-
|
|
54668
|
-
|
|
54669
|
-
|
|
55062
|
+
triggerHover: {
|
|
55063
|
+
backgroundColor: "#374151",
|
|
55064
|
+
borderColor: "#6b7280"
|
|
55065
|
+
}
|
|
55066
|
+
};
|
|
55067
|
+
styles = {
|
|
55068
|
+
wrapper: {
|
|
55069
|
+
position: "relative",
|
|
55070
|
+
display: "inline-block"
|
|
54670
55071
|
},
|
|
54671
|
-
|
|
55072
|
+
trigger: {
|
|
54672
55073
|
display: "flex",
|
|
54673
55074
|
alignItems: "center",
|
|
54674
55075
|
justifyContent: "center",
|
|
54675
|
-
|
|
54676
|
-
|
|
55076
|
+
gap: "8px",
|
|
55077
|
+
padding: "8px 32px",
|
|
54677
55078
|
borderRadius: "8px",
|
|
54678
|
-
backgroundColor: "transparent",
|
|
54679
|
-
fontSize: "14px",
|
|
54680
55079
|
cursor: "pointer",
|
|
54681
|
-
|
|
54682
|
-
|
|
54683
|
-
|
|
54684
|
-
|
|
54685
|
-
|
|
54686
|
-
},
|
|
54687
|
-
connectButtonDark: {
|
|
54688
|
-
border: "1px solid #4b5563",
|
|
54689
|
-
color: "#f9fafb"
|
|
54690
|
-
},
|
|
54691
|
-
wrapper: {
|
|
54692
|
-
position: "relative",
|
|
54693
|
-
display: "inline-block"
|
|
54694
|
-
},
|
|
54695
|
-
triggerImageLight: {
|
|
54696
|
-
display: "block"
|
|
54697
|
-
},
|
|
54698
|
-
triggerImageDark: {
|
|
54699
|
-
display: "block",
|
|
54700
|
-
filter: "invert(1)"
|
|
55080
|
+
fontSize: "14px",
|
|
55081
|
+
fontWeight: 500,
|
|
55082
|
+
fontFamily: "inherit",
|
|
55083
|
+
lineHeight: "20px",
|
|
55084
|
+
transition: "background-color 150ms, border-color 150ms"
|
|
54701
55085
|
}
|
|
54702
55086
|
};
|
|
54703
55087
|
styles2 = {
|
|
@@ -54708,56 +55092,89 @@ spurious results.`);
|
|
|
54708
55092
|
trigger: {
|
|
54709
55093
|
display: "flex",
|
|
54710
55094
|
alignItems: "center",
|
|
54711
|
-
|
|
54712
|
-
padding:
|
|
54713
|
-
|
|
54714
|
-
|
|
55095
|
+
gap: "8px",
|
|
55096
|
+
padding: "6px 12px",
|
|
55097
|
+
borderWidth: "1px",
|
|
55098
|
+
borderStyle: "solid",
|
|
55099
|
+
borderColor: "#e5e7eb",
|
|
55100
|
+
backgroundColor: "#ffffff",
|
|
54715
55101
|
cursor: "pointer",
|
|
54716
|
-
borderRadius: "
|
|
54717
|
-
|
|
55102
|
+
borderRadius: "8px",
|
|
55103
|
+
fontSize: "12px",
|
|
55104
|
+
fontWeight: 500,
|
|
55105
|
+
fontFamily: "inherit",
|
|
55106
|
+
color: "#111827",
|
|
55107
|
+
transition: "background-color 150ms, border-color 150ms"
|
|
55108
|
+
},
|
|
55109
|
+
triggerHover: {
|
|
55110
|
+
backgroundColor: "#f9fafb",
|
|
55111
|
+
borderColor: "#9ca3af"
|
|
54718
55112
|
},
|
|
54719
55113
|
avatar: {
|
|
54720
|
-
width: "
|
|
54721
|
-
height: "
|
|
55114
|
+
width: "28px",
|
|
55115
|
+
height: "28px",
|
|
54722
55116
|
borderRadius: "50%",
|
|
54723
|
-
objectFit: "cover"
|
|
55117
|
+
objectFit: "cover",
|
|
55118
|
+
flexShrink: 0
|
|
54724
55119
|
},
|
|
54725
55120
|
avatarPlaceholder: {
|
|
54726
|
-
width: "
|
|
54727
|
-
height: "
|
|
55121
|
+
width: "28px",
|
|
55122
|
+
height: "28px",
|
|
54728
55123
|
borderRadius: "50%",
|
|
54729
|
-
|
|
55124
|
+
background: "linear-gradient(135deg, #8b5cf6, #3b82f6)",
|
|
54730
55125
|
display: "flex",
|
|
54731
55126
|
alignItems: "center",
|
|
54732
|
-
justifyContent: "center"
|
|
55127
|
+
justifyContent: "center",
|
|
55128
|
+
flexShrink: 0
|
|
55129
|
+
},
|
|
55130
|
+
avatarInitial: {
|
|
55131
|
+
fontSize: "12px",
|
|
55132
|
+
fontWeight: 700,
|
|
55133
|
+
color: "#ffffff",
|
|
55134
|
+
lineHeight: 1
|
|
55135
|
+
},
|
|
55136
|
+
displayName: {
|
|
55137
|
+
maxWidth: "120px",
|
|
55138
|
+
overflow: "hidden",
|
|
55139
|
+
textOverflow: "ellipsis",
|
|
55140
|
+
whiteSpace: "nowrap"
|
|
55141
|
+
},
|
|
55142
|
+
chevron: {
|
|
55143
|
+
flexShrink: 0,
|
|
55144
|
+
transition: "transform 150ms",
|
|
55145
|
+
color: "#6b7280"
|
|
55146
|
+
},
|
|
55147
|
+
chevronOpen: {
|
|
55148
|
+
transform: "rotate(180deg)"
|
|
54733
55149
|
},
|
|
54734
55150
|
popoverBase: {
|
|
54735
55151
|
position: "absolute",
|
|
54736
|
-
|
|
54737
|
-
backgroundColor: "
|
|
55152
|
+
right: 0,
|
|
55153
|
+
backgroundColor: "#ffffff",
|
|
54738
55154
|
borderRadius: "8px",
|
|
54739
|
-
boxShadow: "0 4px
|
|
54740
|
-
width: "
|
|
55155
|
+
boxShadow: "0 4px 12px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08)",
|
|
55156
|
+
width: "100%",
|
|
54741
55157
|
zIndex: 1000,
|
|
54742
|
-
color: "#111827"
|
|
55158
|
+
color: "#111827",
|
|
55159
|
+
borderWidth: "1px",
|
|
55160
|
+
borderStyle: "solid",
|
|
55161
|
+
borderColor: "#e5e7eb",
|
|
55162
|
+
overflow: "hidden"
|
|
54743
55163
|
},
|
|
54744
|
-
|
|
54745
|
-
padding: "
|
|
55164
|
+
header: {
|
|
55165
|
+
padding: "12px 16px",
|
|
54746
55166
|
borderBottom: "1px solid #e5e7eb"
|
|
54747
55167
|
},
|
|
54748
|
-
|
|
54749
|
-
padding: "8px 12px",
|
|
54750
|
-
borderBottom: "none"
|
|
54751
|
-
},
|
|
54752
|
-
username: {
|
|
55168
|
+
headerUsername: {
|
|
54753
55169
|
fontSize: "14px",
|
|
54754
|
-
fontWeight:
|
|
54755
|
-
color: "#111827"
|
|
55170
|
+
fontWeight: 600,
|
|
55171
|
+
color: "#111827",
|
|
55172
|
+
margin: 0
|
|
54756
55173
|
},
|
|
54757
55174
|
addressRow: {
|
|
54758
55175
|
display: "flex",
|
|
54759
55176
|
alignItems: "center",
|
|
54760
|
-
gap: "
|
|
55177
|
+
gap: "4px",
|
|
54761
55178
|
marginTop: "4px"
|
|
54762
55179
|
},
|
|
54763
55180
|
addressButton: {
|
|
@@ -54766,19 +55183,21 @@ spurious results.`);
|
|
|
54766
55183
|
gap: "4px",
|
|
54767
55184
|
padding: 0,
|
|
54768
55185
|
border: "none",
|
|
54769
|
-
|
|
55186
|
+
backgroundColor: "transparent",
|
|
54770
55187
|
cursor: "pointer",
|
|
54771
55188
|
fontSize: "12px",
|
|
54772
|
-
color: "#
|
|
55189
|
+
color: "#6b7280",
|
|
55190
|
+
fontFamily: "inherit",
|
|
54773
55191
|
position: "relative",
|
|
54774
55192
|
width: "100%"
|
|
54775
55193
|
},
|
|
54776
55194
|
copiedText: {
|
|
54777
55195
|
fontSize: "12px",
|
|
54778
|
-
color: "#
|
|
55196
|
+
color: "#059669",
|
|
54779
55197
|
position: "absolute",
|
|
54780
55198
|
left: 0,
|
|
54781
|
-
transition: "opacity 150ms"
|
|
55199
|
+
transition: "opacity 150ms",
|
|
55200
|
+
fontWeight: 500
|
|
54782
55201
|
},
|
|
54783
55202
|
addressText: {
|
|
54784
55203
|
display: "flex",
|
|
@@ -54786,21 +55205,35 @@ spurious results.`);
|
|
|
54786
55205
|
gap: "4px",
|
|
54787
55206
|
transition: "opacity 150ms"
|
|
54788
55207
|
},
|
|
55208
|
+
menuSection: {
|
|
55209
|
+
padding: "4px 0"
|
|
55210
|
+
},
|
|
54789
55211
|
menuItem: {
|
|
54790
55212
|
display: "flex",
|
|
54791
55213
|
alignItems: "center",
|
|
54792
55214
|
gap: "8px",
|
|
54793
55215
|
width: "100%",
|
|
54794
|
-
padding:
|
|
55216
|
+
padding: "8px 16px",
|
|
54795
55217
|
border: "none",
|
|
54796
|
-
|
|
55218
|
+
backgroundColor: "transparent",
|
|
54797
55219
|
cursor: "pointer",
|
|
54798
55220
|
fontSize: "14px",
|
|
54799
|
-
color: "#
|
|
54800
|
-
textDecoration: "none"
|
|
55221
|
+
color: "#374151",
|
|
55222
|
+
textDecoration: "none",
|
|
55223
|
+
fontFamily: "inherit",
|
|
55224
|
+
transition: "background-color 150ms"
|
|
55225
|
+
},
|
|
55226
|
+
menuItemHover: {
|
|
55227
|
+
backgroundColor: "#f3f4f6"
|
|
54801
55228
|
},
|
|
54802
55229
|
disconnectItem: {
|
|
54803
|
-
color: "#
|
|
55230
|
+
color: "#dc2626"
|
|
55231
|
+
},
|
|
55232
|
+
separator: {
|
|
55233
|
+
height: "1px",
|
|
55234
|
+
backgroundColor: "#e5e7eb",
|
|
55235
|
+
margin: 0,
|
|
55236
|
+
border: "none"
|
|
54804
55237
|
}
|
|
54805
55238
|
};
|
|
54806
55239
|
});
|
|
@@ -65726,7 +66159,7 @@ var init_common2 = __esm(() => {
|
|
|
65726
66159
|
});
|
|
65727
66160
|
|
|
65728
66161
|
// ../../packages/renown/dist/src/common.js
|
|
65729
|
-
class
|
|
66162
|
+
class Renown3 {
|
|
65730
66163
|
#baseUrl;
|
|
65731
66164
|
#store;
|
|
65732
66165
|
#eventEmitter;
|
|
@@ -65976,7 +66409,7 @@ class BaseRenownBuilder2 {
|
|
|
65976
66409
|
const storage = this.#storage ?? new RenownMemoryStorage2;
|
|
65977
66410
|
const eventEmitter = this.#eventEmitter ?? new MemoryEventEmitter2;
|
|
65978
66411
|
const baseUrl = this.#baseUrl ?? DEFAULT_RENOWN_URL2;
|
|
65979
|
-
const renown = new
|
|
66412
|
+
const renown = new Renown3(storage, eventEmitter, crypto4, this.#appName, baseUrl, this.#profileFetcher ?? fetchRenownProfile2);
|
|
65980
66413
|
if (renown.user) {
|
|
65981
66414
|
try {
|
|
65982
66415
|
await renown.login(renown.user.did);
|
|
@@ -79602,7 +80035,7 @@ var init_dist2 = __esm(() => {
|
|
|
79602
80035
|
|
|
79603
80036
|
// src/utils/reactor.ts
|
|
79604
80037
|
import { PGlite as PGlite2 } from "@electric-sql/pglite";
|
|
79605
|
-
async function createBrowserReactor(documentModelModules, upgradeManifests, renown) {
|
|
80038
|
+
async function createBrowserReactor(documentModelModules, upgradeManifests, renown, documentModelLoader) {
|
|
79606
80039
|
const signerConfig = {
|
|
79607
80040
|
signer: renown.signer,
|
|
79608
80041
|
verifier: createSignatureVerifier()
|
|
@@ -79620,6 +80053,9 @@ async function createBrowserReactor(documentModelModules, upgradeManifests, reno
|
|
|
79620
80053
|
const builder = new ReactorClientBuilder().withLogger(logger7).withSigner(signerConfig).withReactorBuilder(new ReactorBuilder().withDocumentModels(documentModelModules).withUpgradeManifests(upgradeManifests).withChannelScheme(ChannelScheme.CONNECT).withJwtHandler(jwtHandler).withKysely(new Kysely3({
|
|
79621
80054
|
dialect: new PGliteDialect3(pg)
|
|
79622
80055
|
})));
|
|
80056
|
+
if (documentModelLoader) {
|
|
80057
|
+
builder.withDocumentModelLoader(documentModelLoader);
|
|
80058
|
+
}
|
|
79623
80059
|
const module = await builder.buildModule();
|
|
79624
80060
|
return {
|
|
79625
80061
|
...module,
|
|
@@ -79649,6 +80085,41 @@ var init_reactor = __esm(() => {
|
|
|
79649
80085
|
init_dist2();
|
|
79650
80086
|
});
|
|
79651
80087
|
|
|
80088
|
+
// src/utils/registry-url.ts
|
|
80089
|
+
function loadPersistedState() {
|
|
80090
|
+
try {
|
|
80091
|
+
const raw = localStorage.getItem(STORAGE_KEY);
|
|
80092
|
+
if (raw)
|
|
80093
|
+
return JSON.parse(raw);
|
|
80094
|
+
} catch {}
|
|
80095
|
+
return null;
|
|
80096
|
+
}
|
|
80097
|
+
function getConfiguredRegistryUrls() {
|
|
80098
|
+
const registry = connectConfig.packagesRegistry;
|
|
80099
|
+
if (!registry)
|
|
80100
|
+
return [];
|
|
80101
|
+
return registry.split(",").map((u) => u.trim()).filter(Boolean);
|
|
80102
|
+
}
|
|
80103
|
+
function getDefaultRegistryCdnUrl() {
|
|
80104
|
+
const persisted = loadPersistedState();
|
|
80105
|
+
const urls = getConfiguredRegistryUrls();
|
|
80106
|
+
if (persisted) {
|
|
80107
|
+
if (persisted.selectedRegistryId === "custom") {
|
|
80108
|
+
if (persisted.customRegistryUrl)
|
|
80109
|
+
return persisted.customRegistryUrl;
|
|
80110
|
+
} else {
|
|
80111
|
+
const index = parseInt(persisted.selectedRegistryId.replace("registry-", ""), 10);
|
|
80112
|
+
if (!isNaN(index) && urls[index])
|
|
80113
|
+
return urls[index];
|
|
80114
|
+
}
|
|
80115
|
+
}
|
|
80116
|
+
return urls[0];
|
|
80117
|
+
}
|
|
80118
|
+
var STORAGE_KEY = "ph-connect-registry-selection";
|
|
80119
|
+
var init_registry_url = __esm(() => {
|
|
80120
|
+
init_connect_config();
|
|
80121
|
+
});
|
|
80122
|
+
|
|
79652
80123
|
// src/utils/registerServiceWorker.ts
|
|
79653
80124
|
class ServiceWorkerManager {
|
|
79654
80125
|
ready = false;
|
|
@@ -79751,6 +80222,7 @@ var init_utils6 = __esm(() => {
|
|
|
79751
80222
|
init_openUrl();
|
|
79752
80223
|
init_package_json();
|
|
79753
80224
|
init_reactor();
|
|
80225
|
+
init_registry_url();
|
|
79754
80226
|
init_registerServiceWorker();
|
|
79755
80227
|
});
|
|
79756
80228
|
init_utils6();
|
|
@@ -79768,6 +80240,7 @@ export {
|
|
|
79768
80240
|
getFileNodeOptions,
|
|
79769
80241
|
getDrivePreservationStrategy,
|
|
79770
80242
|
getDriveNodeOptions,
|
|
80243
|
+
getDefaultRegistryCdnUrl,
|
|
79771
80244
|
getDefaultDrivesFromEnv,
|
|
79772
80245
|
getBasePath,
|
|
79773
80246
|
driveSections,
|