jazz-tools 0.18.26 → 0.18.28
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/.turbo/turbo-build.log +61 -61
- package/CHANGELOG.md +24 -0
- package/dist/{chunk-ZIAN4UY5.js → chunk-YOL3XDDW.js} +158 -120
- package/dist/chunk-YOL3XDDW.js.map +1 -0
- package/dist/index.js +97 -5
- package/dist/index.js.map +1 -1
- package/dist/media/{chunk-W3S526L3.js → chunk-K6GCHLQU.js} +1 -1
- package/dist/media/chunk-K6GCHLQU.js.map +1 -0
- package/dist/media/create-image/browser.d.ts +1 -1
- package/dist/media/create-image/react-native.d.ts +1 -1
- package/dist/media/create-image/react-native.d.ts.map +1 -1
- package/dist/media/create-image/server.d.ts +1 -1
- package/dist/media/create-image-factory.d.ts +5 -2
- package/dist/media/create-image-factory.d.ts.map +1 -1
- package/dist/media/index.browser.js +1 -1
- package/dist/media/index.d.ts +3 -4
- package/dist/media/index.d.ts.map +1 -1
- package/dist/media/index.js +1 -1
- package/dist/media/index.native.js +63 -28
- package/dist/media/index.native.js.map +1 -1
- package/dist/media/index.server.js +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react-core/hooks.d.ts +4 -0
- package/dist/react-core/hooks.d.ts.map +1 -1
- package/dist/react-core/index.js +5 -0
- package/dist/react-core/index.js.map +1 -1
- package/dist/testing.js +1 -1
- package/dist/tools/coValues/coList.d.ts +11 -3
- package/dist/tools/coValues/coList.d.ts.map +1 -1
- package/dist/tools/coValues/coMap.d.ts +21 -5
- package/dist/tools/coValues/coMap.d.ts.map +1 -1
- package/dist/tools/coValues/group.d.ts +2 -2
- package/dist/tools/coValues/group.d.ts.map +1 -1
- package/dist/tools/coValues/inbox.d.ts.map +1 -1
- package/dist/tools/coValues/interfaces.d.ts +9 -0
- package/dist/tools/coValues/interfaces.d.ts.map +1 -1
- package/dist/tools/coValues/request.d.ts +70 -0
- package/dist/tools/coValues/request.d.ts.map +1 -1
- package/dist/tools/exports.d.ts +2 -2
- package/dist/tools/exports.d.ts.map +1 -1
- package/dist/tools/tests/authenticate-request.test.d.ts +2 -0
- package/dist/tools/tests/authenticate-request.test.d.ts.map +1 -0
- package/dist/tools/tests/coList.unique.test.d.ts +2 -0
- package/dist/tools/tests/coList.unique.test.d.ts.map +1 -0
- package/dist/tools/tests/coMap.unique.test.d.ts +2 -0
- package/dist/tools/tests/coMap.unique.test.d.ts.map +1 -0
- package/package.json +8 -4
- package/src/media/create-image/react-native.ts +75 -30
- package/src/media/create-image-factory.test.ts +18 -0
- package/src/media/create-image-factory.ts +6 -1
- package/src/media/index.ts +7 -4
- package/src/react-core/hooks.ts +8 -0
- package/src/react-core/tests/useAccount.test.ts +61 -1
- package/src/react-core/tests/usePassPhraseAuth.test.ts +74 -2
- package/src/tools/coValues/coList.ts +38 -35
- package/src/tools/coValues/coMap.ts +38 -38
- package/src/tools/coValues/group.ts +5 -1
- package/src/tools/coValues/inbox.ts +4 -3
- package/src/tools/coValues/interfaces.ts +88 -0
- package/src/tools/coValues/request.ts +188 -4
- package/src/tools/exports.ts +4 -0
- package/src/tools/tests/authenticate-request.test.ts +194 -0
- package/src/tools/tests/coList.test.ts +0 -190
- package/src/tools/tests/coList.unique.test.ts +244 -0
- package/src/tools/tests/coMap.test.ts +0 -433
- package/src/tools/tests/coMap.unique.test.ts +474 -0
- package/dist/chunk-ZIAN4UY5.js.map +0 -1
- package/dist/media/chunk-W3S526L3.js.map +0 -1
|
@@ -118,6 +118,11 @@ function isAnyCoValueSchema(schema) {
|
|
|
118
118
|
return typeof schema === "object" && schema !== null && "collaborative" in schema && schema.collaborative === true;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
+
// src/tools/coValues/interfaces.ts
|
|
122
|
+
import {
|
|
123
|
+
cojsonInternals as cojsonInternals6
|
|
124
|
+
} from "cojson";
|
|
125
|
+
|
|
121
126
|
// src/tools/coValues/CoValueBase.ts
|
|
122
127
|
import { ControlledAccount } from "cojson";
|
|
123
128
|
var CoValueBase = class {
|
|
@@ -232,9 +237,6 @@ var TypeSym = "$type$";
|
|
|
232
237
|
var RegisteredSchemas = {};
|
|
233
238
|
|
|
234
239
|
// src/tools/coValues/coMap.ts
|
|
235
|
-
import {
|
|
236
|
-
cojsonInternals
|
|
237
|
-
} from "cojson";
|
|
238
240
|
var _CoMap = class _CoMap extends CoValueBase {
|
|
239
241
|
/** @internal */
|
|
240
242
|
constructor(options) {
|
|
@@ -429,12 +431,12 @@ var _CoMap = class _CoMap extends CoValueBase {
|
|
|
429
431
|
}
|
|
430
432
|
/** @deprecated Use `CoMap.upsertUnique` and `CoMap.loadUnique` instead. */
|
|
431
433
|
static findUnique(unique, ownerID, as) {
|
|
432
|
-
|
|
434
|
+
const header = _CoMap._getUniqueHeader(unique, ownerID);
|
|
435
|
+
return getIdFromHeader(header, as);
|
|
433
436
|
}
|
|
434
437
|
/** @internal */
|
|
435
|
-
static
|
|
436
|
-
|
|
437
|
-
const header = {
|
|
438
|
+
static _getUniqueHeader(unique, ownerID) {
|
|
439
|
+
return {
|
|
438
440
|
type: "comap",
|
|
439
441
|
ruleset: {
|
|
440
442
|
type: "ownedByGroup",
|
|
@@ -443,8 +445,6 @@ var _CoMap = class _CoMap extends CoValueBase {
|
|
|
443
445
|
meta: null,
|
|
444
446
|
uniqueness: unique
|
|
445
447
|
};
|
|
446
|
-
const crypto = as[TypeSym] === "Anonymous" ? as.node.crypto : as.$jazz.localNode.crypto;
|
|
447
|
-
return cojsonInternals.idforHeader(header, crypto);
|
|
448
448
|
}
|
|
449
449
|
/**
|
|
450
450
|
* Given some data, updates an existing CoMap or initialises a new one if none exists.
|
|
@@ -472,31 +472,23 @@ var _CoMap = class _CoMap extends CoValueBase {
|
|
|
472
472
|
* @deprecated Use `co.map(...).upsertUnique` instead.
|
|
473
473
|
*/
|
|
474
474
|
static async upsertUnique(options) {
|
|
475
|
-
const
|
|
475
|
+
const header = _CoMap._getUniqueHeader(
|
|
476
476
|
options.unique,
|
|
477
|
-
options.owner.$jazz.id
|
|
478
|
-
options.owner.$jazz.loadedAs
|
|
477
|
+
options.owner.$jazz.id
|
|
479
478
|
);
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
options.value
|
|
494
|
-
);
|
|
495
|
-
}
|
|
496
|
-
return await loadCoValueWithoutMe(this, mapId, {
|
|
497
|
-
...options,
|
|
498
|
-
loadAs: options.owner.$jazz.loadedAs,
|
|
499
|
-
skipRetry: true
|
|
479
|
+
return unstable_loadUnique(this, {
|
|
480
|
+
header,
|
|
481
|
+
owner: options.owner,
|
|
482
|
+
resolve: options.resolve,
|
|
483
|
+
onCreateWhenMissing: () => {
|
|
484
|
+
this.create(options.value, {
|
|
485
|
+
owner: options.owner,
|
|
486
|
+
unique: options.unique
|
|
487
|
+
});
|
|
488
|
+
},
|
|
489
|
+
onUpdateWhenFound(value) {
|
|
490
|
+
value.$jazz.applyDiff(options.value);
|
|
491
|
+
}
|
|
500
492
|
});
|
|
501
493
|
}
|
|
502
494
|
/**
|
|
@@ -508,12 +500,17 @@ var _CoMap = class _CoMap extends CoValueBase {
|
|
|
508
500
|
*
|
|
509
501
|
* @deprecated Use `co.map(...).loadUnique` instead.
|
|
510
502
|
*/
|
|
511
|
-
static loadUnique(unique, ownerID, options) {
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
);
|
|
503
|
+
static async loadUnique(unique, ownerID, options) {
|
|
504
|
+
const header = _CoMap._getUniqueHeader(unique, ownerID);
|
|
505
|
+
const owner = await Group2.load(ownerID, {
|
|
506
|
+
loadAs: options?.loadAs
|
|
507
|
+
});
|
|
508
|
+
if (!owner) return owner;
|
|
509
|
+
return unstable_loadUnique(this, {
|
|
510
|
+
header,
|
|
511
|
+
owner,
|
|
512
|
+
resolve: options?.resolve
|
|
513
|
+
});
|
|
517
514
|
}
|
|
518
515
|
};
|
|
519
516
|
_CoMap.prototype[TypeSym] = "CoMap";
|
|
@@ -844,7 +841,6 @@ function getEditFromRaw(target, rawEdit, descriptor, key) {
|
|
|
844
841
|
}
|
|
845
842
|
|
|
846
843
|
// src/tools/coValues/coList.ts
|
|
847
|
-
import { cojsonInternals as cojsonInternals2 } from "cojson";
|
|
848
844
|
import { calcPatch } from "fast-myers-diff";
|
|
849
845
|
var _CoList = class _CoList extends Array {
|
|
850
846
|
/**
|
|
@@ -994,12 +990,12 @@ var _CoList = class _CoList extends Array {
|
|
|
994
990
|
}
|
|
995
991
|
/** @deprecated Use `CoList.upsertUnique` and `CoList.loadUnique` instead. */
|
|
996
992
|
static findUnique(unique, ownerID, as) {
|
|
997
|
-
|
|
993
|
+
const header = _CoList._getUniqueHeader(unique, ownerID);
|
|
994
|
+
return getIdFromHeader(header, as);
|
|
998
995
|
}
|
|
999
996
|
/** @internal */
|
|
1000
|
-
static
|
|
1001
|
-
|
|
1002
|
-
const header = {
|
|
997
|
+
static _getUniqueHeader(unique, ownerID) {
|
|
998
|
+
return {
|
|
1003
999
|
type: "colist",
|
|
1004
1000
|
ruleset: {
|
|
1005
1001
|
type: "ownedByGroup",
|
|
@@ -1008,8 +1004,6 @@ var _CoList = class _CoList extends Array {
|
|
|
1008
1004
|
meta: null,
|
|
1009
1005
|
uniqueness: unique
|
|
1010
1006
|
};
|
|
1011
|
-
const crypto = as[TypeSym] === "Anonymous" ? as.node.crypto : as.$jazz.localNode.crypto;
|
|
1012
|
-
return cojsonInternals2.idforHeader(header, crypto);
|
|
1013
1007
|
}
|
|
1014
1008
|
/**
|
|
1015
1009
|
* Given some data, updates an existing CoList or initialises a new one if none exists.
|
|
@@ -1032,28 +1026,23 @@ var _CoList = class _CoList extends Array {
|
|
|
1032
1026
|
* @category Subscription & Loading
|
|
1033
1027
|
*/
|
|
1034
1028
|
static async upsertUnique(options) {
|
|
1035
|
-
const
|
|
1029
|
+
const header = _CoList._getUniqueHeader(
|
|
1036
1030
|
options.unique,
|
|
1037
|
-
options.owner.$jazz.id
|
|
1038
|
-
options.owner.$jazz.loadedAs
|
|
1031
|
+
options.owner.$jazz.id
|
|
1039
1032
|
);
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
}
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
return await loadCoValueWithoutMe(this, listId, {
|
|
1054
|
-
...options,
|
|
1055
|
-
loadAs: options.owner.$jazz.loadedAs,
|
|
1056
|
-
skipRetry: true
|
|
1033
|
+
return unstable_loadUnique(this, {
|
|
1034
|
+
header,
|
|
1035
|
+
owner: options.owner,
|
|
1036
|
+
resolve: options.resolve,
|
|
1037
|
+
onCreateWhenMissing: () => {
|
|
1038
|
+
this.create(options.value, {
|
|
1039
|
+
owner: options.owner,
|
|
1040
|
+
unique: options.unique
|
|
1041
|
+
});
|
|
1042
|
+
},
|
|
1043
|
+
onUpdateWhenFound(value) {
|
|
1044
|
+
value.$jazz.applyDiff(options.value);
|
|
1045
|
+
}
|
|
1057
1046
|
});
|
|
1058
1047
|
}
|
|
1059
1048
|
/**
|
|
@@ -1063,12 +1052,17 @@ var _CoList = class _CoList extends Array {
|
|
|
1063
1052
|
* @param options Additional options for loading the CoList.
|
|
1064
1053
|
* @returns The loaded CoList, or null if unavailable.
|
|
1065
1054
|
*/
|
|
1066
|
-
static loadUnique(unique, ownerID, options) {
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
);
|
|
1055
|
+
static async loadUnique(unique, ownerID, options) {
|
|
1056
|
+
const header = _CoList._getUniqueHeader(unique, ownerID);
|
|
1057
|
+
const owner = await Group2.load(ownerID, {
|
|
1058
|
+
loadAs: options?.loadAs
|
|
1059
|
+
});
|
|
1060
|
+
if (!owner) return owner;
|
|
1061
|
+
return unstable_loadUnique(this, {
|
|
1062
|
+
header,
|
|
1063
|
+
owner,
|
|
1064
|
+
resolve: options?.resolve
|
|
1065
|
+
});
|
|
1072
1066
|
}
|
|
1073
1067
|
// Override mutation methods defined on Array, as CoLists aren't meant to be mutated directly
|
|
1074
1068
|
/**
|
|
@@ -1505,7 +1499,7 @@ var CoListProxyHandler = {
|
|
|
1505
1499
|
};
|
|
1506
1500
|
|
|
1507
1501
|
// src/tools/coValues/coFeed.ts
|
|
1508
|
-
import { cojsonInternals
|
|
1502
|
+
import { cojsonInternals } from "cojson";
|
|
1509
1503
|
var _CoFeed = class _CoFeed extends CoValueBase {
|
|
1510
1504
|
/**
|
|
1511
1505
|
* Declare a `CoFeed` by subclassing `CoFeed.Of(...)` and passing the item schema using a `co` primitive or a `coField.ref`.
|
|
@@ -1846,12 +1840,12 @@ var CoStreamPerSessionProxyHandler = (innerTarget, accessFrom) => ({
|
|
|
1846
1840
|
const sessionID = key;
|
|
1847
1841
|
const rawEntry = innerTarget.$jazz.raw.lastItemIn(sessionID);
|
|
1848
1842
|
if (!rawEntry) return;
|
|
1849
|
-
const by =
|
|
1843
|
+
const by = cojsonInternals.accountOrAgentIDfromSessionID(sessionID);
|
|
1850
1844
|
const entry = entryFromRawEntry(
|
|
1851
1845
|
accessFrom,
|
|
1852
1846
|
rawEntry,
|
|
1853
1847
|
innerTarget.$jazz.loadedAs,
|
|
1854
|
-
|
|
1848
|
+
cojsonInternals.isAccountID(by) ? by : void 0,
|
|
1855
1849
|
innerTarget.$jazz.schema[ItemsSym]
|
|
1856
1850
|
);
|
|
1857
1851
|
Object.defineProperty(entry, "all", {
|
|
@@ -1865,7 +1859,7 @@ var CoStreamPerSessionProxyHandler = (innerTarget, accessFrom) => ({
|
|
|
1865
1859
|
accessFrom,
|
|
1866
1860
|
rawEntry2.value,
|
|
1867
1861
|
innerTarget.$jazz.loadedAs,
|
|
1868
|
-
|
|
1862
|
+
cojsonInternals.isAccountID(by) ? by : void 0,
|
|
1869
1863
|
innerTarget.$jazz.schema[ItemsSym]
|
|
1870
1864
|
);
|
|
1871
1865
|
}
|
|
@@ -2038,7 +2032,7 @@ var FileStream = class extends CoValueBase {
|
|
|
2038
2032
|
totalSizeBytes: arrayBuffer.byteLength,
|
|
2039
2033
|
fileName
|
|
2040
2034
|
});
|
|
2041
|
-
const chunkSize =
|
|
2035
|
+
const chunkSize = cojsonInternals.TRANSACTION_CONFIG.MAX_RECOMMENDED_TX_SIZE;
|
|
2042
2036
|
let lastProgressUpdate = Date.now();
|
|
2043
2037
|
for (let idx = 0; idx < data.length; idx += chunkSize) {
|
|
2044
2038
|
stream.push(data.slice(idx, idx + chunkSize));
|
|
@@ -2132,7 +2126,7 @@ var FileStreamJazzApi = class extends CoValueJazzApi {
|
|
|
2132
2126
|
import {
|
|
2133
2127
|
ControlledAccount as RawControlledAccount,
|
|
2134
2128
|
LocalNode as LocalNode2,
|
|
2135
|
-
cojsonInternals as
|
|
2129
|
+
cojsonInternals as cojsonInternals2
|
|
2136
2130
|
} from "cojson";
|
|
2137
2131
|
var Account = class extends CoValueBase {
|
|
2138
2132
|
constructor(options) {
|
|
@@ -2157,7 +2151,7 @@ var Account = class extends CoValueBase {
|
|
|
2157
2151
|
* Whether this account is the currently active account.
|
|
2158
2152
|
*/
|
|
2159
2153
|
get isMe() {
|
|
2160
|
-
return
|
|
2154
|
+
return activeAccountContext3.get().$jazz.id === this.$jazz.id;
|
|
2161
2155
|
}
|
|
2162
2156
|
/**
|
|
2163
2157
|
* Accept an invite to a `CoValue` or `Group`.
|
|
@@ -2176,7 +2170,7 @@ var Account = class extends CoValueBase {
|
|
|
2176
2170
|
inviteSecret
|
|
2177
2171
|
);
|
|
2178
2172
|
return loadCoValue(
|
|
2179
|
-
coValueClassFromCoValueClassOrSchema(coValueClass ??
|
|
2173
|
+
coValueClassFromCoValueClassOrSchema(coValueClass ?? Group2),
|
|
2180
2174
|
valueID,
|
|
2181
2175
|
{
|
|
2182
2176
|
loadAs: this
|
|
@@ -2243,13 +2237,13 @@ var Account = class extends CoValueBase {
|
|
|
2243
2237
|
return this.fromNode(node);
|
|
2244
2238
|
}
|
|
2245
2239
|
static getMe() {
|
|
2246
|
-
return
|
|
2240
|
+
return activeAccountContext3.get();
|
|
2247
2241
|
}
|
|
2248
2242
|
/**
|
|
2249
2243
|
* @deprecated Use `co.account(...).createAs` instead.
|
|
2250
2244
|
*/
|
|
2251
2245
|
static async createAs(as, options) {
|
|
2252
|
-
const connectedPeers =
|
|
2246
|
+
const connectedPeers = cojsonInternals2.connectedPeers(
|
|
2253
2247
|
"creatingAccount",
|
|
2254
2248
|
"createdAccount",
|
|
2255
2249
|
{ peer1role: "server", peer2role: "client" }
|
|
@@ -2597,7 +2591,7 @@ var _Group = class _Group extends CoValueBase {
|
|
|
2597
2591
|
return this.getMembersFromKeys(this.$jazz.raw.getMemberKeys());
|
|
2598
2592
|
}
|
|
2599
2593
|
getRoleOf(member) {
|
|
2600
|
-
const accountId = member === "me" ?
|
|
2594
|
+
const accountId = member === "me" ? activeAccountContext3.get().$jazz.id : member === "everyone" ? member : member;
|
|
2601
2595
|
return this.$jazz.raw.roleOf(accountId);
|
|
2602
2596
|
}
|
|
2603
2597
|
/**
|
|
@@ -2666,7 +2660,7 @@ var _Group = class _Group extends CoValueBase {
|
|
|
2666
2660
|
}
|
|
2667
2661
|
};
|
|
2668
2662
|
_Group.prototype[TypeSym] = "Group";
|
|
2669
|
-
var
|
|
2663
|
+
var Group2 = _Group;
|
|
2670
2664
|
var GroupJazzApi = class extends CoValueJazzApi {
|
|
2671
2665
|
constructor(group, raw) {
|
|
2672
2666
|
super(group);
|
|
@@ -2711,7 +2705,7 @@ var GroupJazzApi = class extends CoValueJazzApi {
|
|
|
2711
2705
|
return this.raw.core.waitForSync(options);
|
|
2712
2706
|
}
|
|
2713
2707
|
};
|
|
2714
|
-
RegisteredSchemas["Group"] =
|
|
2708
|
+
RegisteredSchemas["Group"] = Group2;
|
|
2715
2709
|
function isAccountID(id) {
|
|
2716
2710
|
return id.startsWith("co_");
|
|
2717
2711
|
}
|
|
@@ -2919,11 +2913,11 @@ var Inbox = class _Inbox {
|
|
|
2919
2913
|
);
|
|
2920
2914
|
const handleNewMessages = () => {
|
|
2921
2915
|
for (const tx of messagesFeed.getNewItems()) {
|
|
2922
|
-
const accountID = getAccountIDfromSessionID(tx.
|
|
2916
|
+
const accountID = getAccountIDfromSessionID(tx.currentTxID.sessionID);
|
|
2923
2917
|
if (!accountID) {
|
|
2924
2918
|
console.warn(
|
|
2925
2919
|
"Received message from unknown account",
|
|
2926
|
-
tx.
|
|
2920
|
+
tx.currentTxID.sessionID
|
|
2927
2921
|
);
|
|
2928
2922
|
continue;
|
|
2929
2923
|
}
|
|
@@ -2931,7 +2925,7 @@ var Inbox = class _Inbox {
|
|
|
2931
2925
|
if (!isCoValueId(id)) {
|
|
2932
2926
|
continue;
|
|
2933
2927
|
}
|
|
2934
|
-
const txKey = `${tx.
|
|
2928
|
+
const txKey = `${tx.currentTxID.sessionID}/${tx.currentTxID.txIndex}`;
|
|
2935
2929
|
if (processed.has(txKey)) {
|
|
2936
2930
|
continue;
|
|
2937
2931
|
}
|
|
@@ -2996,7 +2990,7 @@ var InboxSender = class _InboxSender {
|
|
|
2996
2990
|
});
|
|
2997
2991
|
}
|
|
2998
2992
|
static async load(inboxOwnerID, currentAccount) {
|
|
2999
|
-
currentAccount ||=
|
|
2993
|
+
currentAccount ||= activeAccountContext3.get();
|
|
3000
2994
|
const node = currentAccount.$jazz.localNode;
|
|
3001
2995
|
const inboxOwnerRaw = await node.load(
|
|
3002
2996
|
inboxOwnerID
|
|
@@ -3026,7 +3020,7 @@ var InboxSender = class _InboxSender {
|
|
|
3026
3020
|
}
|
|
3027
3021
|
};
|
|
3028
3022
|
async function acceptInvite(invite, account) {
|
|
3029
|
-
account ||=
|
|
3023
|
+
account ||= activeAccountContext3.get();
|
|
3030
3024
|
const id = invite.slice(0, invite.indexOf("/"));
|
|
3031
3025
|
const inviteSecret = invite.slice(invite.indexOf("/") + 1);
|
|
3032
3026
|
if (!isCoValueId(id) || !inviteSecret.startsWith("inviteSecret_")) {
|
|
@@ -3300,7 +3294,7 @@ var SchemaUnion = class _SchemaUnion extends CoValueBase {
|
|
|
3300
3294
|
};
|
|
3301
3295
|
|
|
3302
3296
|
// src/tools/coValues/coVector.ts
|
|
3303
|
-
import { cojsonInternals as
|
|
3297
|
+
import { cojsonInternals as cojsonInternals3 } from "cojson";
|
|
3304
3298
|
var _CoVector = class _CoVector extends Float32Array {
|
|
3305
3299
|
static get [Symbol.species]() {
|
|
3306
3300
|
return Float32Array;
|
|
@@ -3357,7 +3351,7 @@ var _CoVector = class _CoVector extends Float32Array {
|
|
|
3357
3351
|
mimeType: "application/vector+octet-stream",
|
|
3358
3352
|
totalSizeBytes: byteArray.byteLength
|
|
3359
3353
|
});
|
|
3360
|
-
const chunkSize =
|
|
3354
|
+
const chunkSize = cojsonInternals3.TRANSACTION_CONFIG.MAX_RECOMMENDED_TX_SIZE;
|
|
3361
3355
|
for (let idx = 0; idx < byteArray.length; idx += chunkSize) {
|
|
3362
3356
|
coVector.$jazz.raw.pushBinaryStreamChunk(
|
|
3363
3357
|
byteArray.slice(idx, idx + chunkSize)
|
|
@@ -3611,7 +3605,7 @@ var ActiveAccountContext = class {
|
|
|
3611
3605
|
return this.activeAccount;
|
|
3612
3606
|
}
|
|
3613
3607
|
};
|
|
3614
|
-
var
|
|
3608
|
+
var activeAccountContext3 = new ActiveAccountContext();
|
|
3615
3609
|
|
|
3616
3610
|
// src/tools/implementation/refs.ts
|
|
3617
3611
|
var Ref = class {
|
|
@@ -3813,7 +3807,7 @@ function instantiateRefEncodedWithInit(schema, init, parentOwner) {
|
|
|
3813
3807
|
}
|
|
3814
3808
|
const node = parentOwner.$jazz.localNode;
|
|
3815
3809
|
const rawGroup = node.createGroup();
|
|
3816
|
-
const owner = new
|
|
3810
|
+
const owner = new Group2({ fromRaw: rawGroup });
|
|
3817
3811
|
owner.addMember(parentOwner);
|
|
3818
3812
|
return schema.ref.create(init, owner);
|
|
3819
3813
|
}
|
|
@@ -3833,7 +3827,7 @@ function applyCoValueMigrations(instance) {
|
|
|
3833
3827
|
|
|
3834
3828
|
// src/tools/subscribe/CoValueCoreSubscription.ts
|
|
3835
3829
|
import {
|
|
3836
|
-
cojsonInternals as
|
|
3830
|
+
cojsonInternals as cojsonInternals4
|
|
3837
3831
|
} from "cojson";
|
|
3838
3832
|
var CoValueCoreSubscription = class {
|
|
3839
3833
|
constructor(localNode, id, listener, skipRetry, branch) {
|
|
@@ -3880,7 +3874,7 @@ var CoValueCoreSubscription = class {
|
|
|
3880
3874
|
* Either subscribes directly or attempts to get the requested branch.
|
|
3881
3875
|
*/
|
|
3882
3876
|
handleAvailableSource() {
|
|
3883
|
-
if (!this.branchName || !
|
|
3877
|
+
if (!this.branchName || !cojsonInternals4.canBeBranched(this.source)) {
|
|
3884
3878
|
this.subscribe(this.source.getCurrentContent());
|
|
3885
3879
|
return;
|
|
3886
3880
|
}
|
|
@@ -4667,14 +4661,14 @@ async function createJazzContextFromExistingCredentials({
|
|
|
4667
4661
|
migration: async (rawAccount, _node, creationProps) => {
|
|
4668
4662
|
const account2 = AccountClass.fromRaw(rawAccount);
|
|
4669
4663
|
if (asActiveAccount) {
|
|
4670
|
-
|
|
4664
|
+
activeAccountContext3.set(account2);
|
|
4671
4665
|
}
|
|
4672
4666
|
await account2.applyMigration(creationProps);
|
|
4673
4667
|
}
|
|
4674
4668
|
});
|
|
4675
4669
|
const account = AccountClass.fromNode(node);
|
|
4676
4670
|
if (asActiveAccount) {
|
|
4677
|
-
|
|
4671
|
+
activeAccountContext3.set(account);
|
|
4678
4672
|
}
|
|
4679
4673
|
return {
|
|
4680
4674
|
node,
|
|
@@ -4709,12 +4703,12 @@ async function createJazzContextForNewAccount({
|
|
|
4709
4703
|
storage,
|
|
4710
4704
|
migration: async (rawAccount, _node, creationProps2) => {
|
|
4711
4705
|
const account2 = AccountClass.fromRaw(rawAccount);
|
|
4712
|
-
|
|
4706
|
+
activeAccountContext3.set(account2);
|
|
4713
4707
|
await account2.applyMigration(creationProps2);
|
|
4714
4708
|
}
|
|
4715
4709
|
});
|
|
4716
4710
|
const account = AccountClass.fromNode(node);
|
|
4717
|
-
|
|
4711
|
+
activeAccountContext3.set(account);
|
|
4718
4712
|
return {
|
|
4719
4713
|
node,
|
|
4720
4714
|
account,
|
|
@@ -4797,7 +4791,7 @@ function createAnonymousJazzContext({
|
|
|
4797
4791
|
if (storage) {
|
|
4798
4792
|
node.setStorage(storage);
|
|
4799
4793
|
}
|
|
4800
|
-
|
|
4794
|
+
activeAccountContext3.setGuestMode();
|
|
4801
4795
|
return {
|
|
4802
4796
|
agent: new AnonymousJazzAgent(node),
|
|
4803
4797
|
done: () => {
|
|
@@ -4919,22 +4913,22 @@ var GroupSchema = class {
|
|
|
4919
4913
|
this.builtin = "Group";
|
|
4920
4914
|
}
|
|
4921
4915
|
getCoValueClass() {
|
|
4922
|
-
return
|
|
4916
|
+
return Group2;
|
|
4923
4917
|
}
|
|
4924
4918
|
optional() {
|
|
4925
4919
|
return coOptionalDefiner(this);
|
|
4926
4920
|
}
|
|
4927
4921
|
create(options) {
|
|
4928
|
-
return
|
|
4922
|
+
return Group2.create(options);
|
|
4929
4923
|
}
|
|
4930
4924
|
load(id, options) {
|
|
4931
|
-
return
|
|
4925
|
+
return Group2.load(id, options);
|
|
4932
4926
|
}
|
|
4933
4927
|
createInvite(id, options) {
|
|
4934
|
-
return
|
|
4928
|
+
return Group2.createInvite(id, options);
|
|
4935
4929
|
}
|
|
4936
4930
|
subscribe(id, ...args) {
|
|
4937
|
-
return
|
|
4931
|
+
return Group2.subscribe(id, ...args);
|
|
4938
4932
|
}
|
|
4939
4933
|
};
|
|
4940
4934
|
|
|
@@ -5733,7 +5727,7 @@ var ImageDefinitionBase = coMapDefiner({
|
|
|
5733
5727
|
var ImageDefinition = ImageDefinitionBase;
|
|
5734
5728
|
|
|
5735
5729
|
// src/tools/implementation/ContextManager.ts
|
|
5736
|
-
import { cojsonInternals as
|
|
5730
|
+
import { cojsonInternals as cojsonInternals5 } from "cojson";
|
|
5737
5731
|
import { PureJSCrypto } from "cojson/dist/crypto/PureJSCrypto";
|
|
5738
5732
|
|
|
5739
5733
|
// src/tools/auth/KvStoreContext.ts
|
|
@@ -6104,7 +6098,7 @@ var JazzContextManager = class {
|
|
|
6104
6098
|
}
|
|
6105
6099
|
const currentContext = this.context;
|
|
6106
6100
|
if (prevContext && currentContext && "me" in prevContext && "me" in currentContext) {
|
|
6107
|
-
const [prevAccountAsPeer, currentAccountAsPeer] =
|
|
6101
|
+
const [prevAccountAsPeer, currentAccountAsPeer] = cojsonInternals5.connectedPeers(
|
|
6108
6102
|
prevContext.me.$jazz.id,
|
|
6109
6103
|
currentContext.me.$jazz.id,
|
|
6110
6104
|
{
|
|
@@ -6224,7 +6218,7 @@ function isCoValueClass(value) {
|
|
|
6224
6218
|
function loadCoValueWithoutMe(cls, id, options) {
|
|
6225
6219
|
return loadCoValue(cls, id, {
|
|
6226
6220
|
...options,
|
|
6227
|
-
loadAs: options?.loadAs ??
|
|
6221
|
+
loadAs: options?.loadAs ?? activeAccountContext3.get(),
|
|
6228
6222
|
unstable_branch: options?.unstable_branch
|
|
6229
6223
|
});
|
|
6230
6224
|
}
|
|
@@ -6298,13 +6292,13 @@ function subscribeToCoValueWithoutMe(cls, id, options, listener) {
|
|
|
6298
6292
|
id,
|
|
6299
6293
|
{
|
|
6300
6294
|
...options,
|
|
6301
|
-
loadAs: options.loadAs ??
|
|
6295
|
+
loadAs: options.loadAs ?? activeAccountContext3.get()
|
|
6302
6296
|
},
|
|
6303
6297
|
listener
|
|
6304
6298
|
);
|
|
6305
6299
|
}
|
|
6306
6300
|
function subscribeToCoValue(cls, id, options, listener) {
|
|
6307
|
-
const loadAs = options.loadAs ??
|
|
6301
|
+
const loadAs = options.loadAs ?? activeAccountContext3.get();
|
|
6308
6302
|
const node = "node" in loadAs ? loadAs.node : loadAs.$jazz.localNode;
|
|
6309
6303
|
const resolve = options.resolve ?? true;
|
|
6310
6304
|
let unsubscribed = false;
|
|
@@ -6372,9 +6366,9 @@ function isAccountInstance(instance) {
|
|
|
6372
6366
|
return TypeSym in instance && instance[TypeSym] === "Account";
|
|
6373
6367
|
}
|
|
6374
6368
|
function parseCoValueCreateOptions(options) {
|
|
6375
|
-
const
|
|
6369
|
+
const Group16 = RegisteredSchemas["Group"];
|
|
6376
6370
|
if (!options) {
|
|
6377
|
-
return { owner:
|
|
6371
|
+
return { owner: Group16.create(), uniqueness: void 0 };
|
|
6378
6372
|
}
|
|
6379
6373
|
if (TypeSym in options) {
|
|
6380
6374
|
if (options[TypeSym] === "Account") {
|
|
@@ -6385,7 +6379,7 @@ function parseCoValueCreateOptions(options) {
|
|
|
6385
6379
|
}
|
|
6386
6380
|
const uniqueness = options.unique ? { uniqueness: options.unique } : void 0;
|
|
6387
6381
|
const opts = {
|
|
6388
|
-
owner: options.owner ? accountOrGroupToGroup(options.owner) :
|
|
6382
|
+
owner: options.owner ? accountOrGroupToGroup(options.owner) : Group16.create(),
|
|
6389
6383
|
uniqueness
|
|
6390
6384
|
};
|
|
6391
6385
|
return opts;
|
|
@@ -6398,12 +6392,56 @@ function accountOrGroupToGroup(accountOrGroup) {
|
|
|
6398
6392
|
}
|
|
6399
6393
|
function parseGroupCreateOptions(options) {
|
|
6400
6394
|
if (!options) {
|
|
6401
|
-
return { owner:
|
|
6395
|
+
return { owner: activeAccountContext3.get() };
|
|
6402
6396
|
}
|
|
6403
|
-
return TypeSym in options && isAccountInstance(options) ? { owner: options } : { owner: options.owner ??
|
|
6397
|
+
return TypeSym in options && isAccountInstance(options) ? { owner: options } : { owner: options.owner ?? activeAccountContext3.get() };
|
|
6398
|
+
}
|
|
6399
|
+
function getIdFromHeader(header, loadAs) {
|
|
6400
|
+
loadAs ||= activeAccountContext3.get();
|
|
6401
|
+
const node = loadAs[TypeSym] === "Anonymous" ? loadAs.node : loadAs.$jazz.localNode;
|
|
6402
|
+
return cojsonInternals6.idforHeader(header, node.crypto);
|
|
6403
|
+
}
|
|
6404
|
+
async function unstable_loadUnique(cls, options) {
|
|
6405
|
+
const loadAs = options.owner.$jazz.loadedAs;
|
|
6406
|
+
const node = loadAs[TypeSym] === "Anonymous" ? loadAs.node : loadAs.$jazz.localNode;
|
|
6407
|
+
const id = cojsonInternals6.idforHeader(options.header, node.crypto);
|
|
6408
|
+
let result = await loadCoValueWithoutMe(cls, id, {
|
|
6409
|
+
skipRetry: true,
|
|
6410
|
+
loadAs
|
|
6411
|
+
});
|
|
6412
|
+
if (options.onCreateWhenMissing) {
|
|
6413
|
+
if (!result && node.getCoValue(id).hasVerifiedContent()) {
|
|
6414
|
+
result = await loadCoValueWithoutMe(cls, id, {
|
|
6415
|
+
loadAs
|
|
6416
|
+
});
|
|
6417
|
+
}
|
|
6418
|
+
if (!result) {
|
|
6419
|
+
options.onCreateWhenMissing();
|
|
6420
|
+
return loadCoValueWithoutMe(cls, id, {
|
|
6421
|
+
loadAs,
|
|
6422
|
+
resolve: options.resolve
|
|
6423
|
+
});
|
|
6424
|
+
}
|
|
6425
|
+
}
|
|
6426
|
+
if (!result) return result;
|
|
6427
|
+
if (options.onUpdateWhenFound) {
|
|
6428
|
+
const loaded = await loadCoValueWithoutMe(cls, id, {
|
|
6429
|
+
loadAs,
|
|
6430
|
+
resolve: options.resolve
|
|
6431
|
+
});
|
|
6432
|
+
if (loaded) {
|
|
6433
|
+
options.onUpdateWhenFound(loaded);
|
|
6434
|
+
} else {
|
|
6435
|
+
return loaded;
|
|
6436
|
+
}
|
|
6437
|
+
}
|
|
6438
|
+
return loadCoValueWithoutMe(cls, id, {
|
|
6439
|
+
loadAs,
|
|
6440
|
+
resolve: options.resolve
|
|
6441
|
+
});
|
|
6404
6442
|
}
|
|
6405
6443
|
async function exportCoValue(cls, id, options) {
|
|
6406
|
-
const loadAs = options.loadAs ??
|
|
6444
|
+
const loadAs = options.loadAs ?? activeAccountContext3.get();
|
|
6407
6445
|
const node = "node" in loadAs ? loadAs.node : loadAs.$jazz.localNode;
|
|
6408
6446
|
const resolve = options.resolve ?? true;
|
|
6409
6447
|
const rootNode = new SubscriptionScope(
|
|
@@ -6491,7 +6529,7 @@ function unstable_mergeBranch(subscriptionScope) {
|
|
|
6491
6529
|
handleMerge(subscriptionScope);
|
|
6492
6530
|
}
|
|
6493
6531
|
async function unstable_mergeBranchWithResolve2(cls, id, options) {
|
|
6494
|
-
const loadAs = options.loadAs ??
|
|
6532
|
+
const loadAs = options.loadAs ?? activeAccountContext3.get();
|
|
6495
6533
|
const node = "node" in loadAs ? loadAs.node : loadAs.$jazz.localNode;
|
|
6496
6534
|
const resolve = options.resolve ?? true;
|
|
6497
6535
|
const rootNode = new SubscriptionScope(
|
|
@@ -6534,7 +6572,7 @@ export {
|
|
|
6534
6572
|
FileStream,
|
|
6535
6573
|
Account,
|
|
6536
6574
|
isControlledAccount,
|
|
6537
|
-
|
|
6575
|
+
Group2 as Group,
|
|
6538
6576
|
Profile,
|
|
6539
6577
|
isCoValueId,
|
|
6540
6578
|
Inbox,
|
|
@@ -6543,7 +6581,7 @@ export {
|
|
|
6543
6581
|
CoRichText,
|
|
6544
6582
|
SchemaUnion,
|
|
6545
6583
|
AnonymousJazzAgent,
|
|
6546
|
-
activeAccountContext,
|
|
6584
|
+
activeAccountContext3 as activeAccountContext,
|
|
6547
6585
|
Ref,
|
|
6548
6586
|
Encoders,
|
|
6549
6587
|
coField,
|
|
@@ -6563,4 +6601,4 @@ export {
|
|
|
6563
6601
|
JazzContextManager
|
|
6564
6602
|
};
|
|
6565
6603
|
/* istanbul ignore file -- @preserve */
|
|
6566
|
-
//# sourceMappingURL=chunk-
|
|
6604
|
+
//# sourceMappingURL=chunk-YOL3XDDW.js.map
|