jazz-tools 0.18.12 → 0.18.13
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/.svelte-kit/__package__/jazz.class.svelte.d.ts +24 -7
- package/.svelte-kit/__package__/jazz.class.svelte.d.ts.map +1 -1
- package/.svelte-kit/__package__/jazz.class.svelte.js +8 -0
- package/.turbo/turbo-build.log +53 -53
- package/CHANGELOG.md +15 -0
- package/dist/{chunk-PRSMJMJR.js → chunk-AEXYCCQS.js} +180 -65
- package/dist/chunk-AEXYCCQS.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/prosemirror/index.js +7 -1
- package/dist/prosemirror/index.js.map +1 -1
- package/dist/prosemirror/lib/plugin.d.ts.map +1 -1
- package/dist/react-core/hooks.d.ts +49 -1
- package/dist/react-core/hooks.d.ts.map +1 -1
- package/dist/react-core/index.js +49 -4814
- package/dist/react-core/index.js.map +1 -1
- package/dist/svelte/jazz.class.svelte.d.ts +24 -7
- package/dist/svelte/jazz.class.svelte.d.ts.map +1 -1
- package/dist/svelte/jazz.class.svelte.js +8 -0
- package/dist/testing.js +1 -1
- package/dist/tools/coValues/CoValueBase.d.ts +14 -2
- package/dist/tools/coValues/CoValueBase.d.ts.map +1 -1
- package/dist/tools/coValues/account.d.ts +3 -6
- package/dist/tools/coValues/account.d.ts.map +1 -1
- package/dist/tools/coValues/coFeed.d.ts +3 -11
- package/dist/tools/coValues/coFeed.d.ts.map +1 -1
- package/dist/tools/coValues/coList.d.ts +3 -6
- package/dist/tools/coValues/coList.d.ts.map +1 -1
- package/dist/tools/coValues/coMap.d.ts +3 -6
- package/dist/tools/coValues/coMap.d.ts.map +1 -1
- package/dist/tools/coValues/coPlainText.d.ts +0 -1
- package/dist/tools/coValues/coPlainText.d.ts.map +1 -1
- package/dist/tools/coValues/group.d.ts +8 -2
- package/dist/tools/coValues/group.d.ts.map +1 -1
- package/dist/tools/coValues/interfaces.d.ts +17 -0
- package/dist/tools/coValues/interfaces.d.ts.map +1 -1
- package/dist/tools/exports.d.ts +1 -1
- package/dist/tools/exports.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/coExport.d.ts +2 -1
- package/dist/tools/implementation/zodSchema/coExport.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/runtimeConverters/coValueSchemaTransformation.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts +7 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.d.ts +2 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts +7 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts +7 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts +7 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts +7 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts +3 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/GroupSchema.d.ts +25 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/GroupSchema.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts +6 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts +6 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts +3 -2
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts +3 -2
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/zodCo.d.ts +2 -0
- package/dist/tools/implementation/zodSchema/zodCo.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/zodSchema.d.ts +4 -2
- package/dist/tools/implementation/zodSchema/zodSchema.d.ts.map +1 -1
- package/dist/tools/internal.d.ts +1 -0
- package/dist/tools/internal.d.ts.map +1 -1
- package/dist/tools/subscribe/CoValueCoreSubscription.d.ts +1 -5
- package/dist/tools/subscribe/CoValueCoreSubscription.d.ts.map +1 -1
- package/dist/tools/subscribe/SubscriptionScope.d.ts +3 -2
- package/dist/tools/subscribe/SubscriptionScope.d.ts.map +1 -1
- package/dist/tools/subscribe/types.d.ts +5 -1
- package/dist/tools/subscribe/types.d.ts.map +1 -1
- package/dist/tools/testing.d.ts.map +1 -1
- package/dist/tools/tests/coFeed.branch.test.d.ts +2 -0
- package/dist/tools/tests/coFeed.branch.test.d.ts.map +1 -0
- package/dist/tools/tests/coList.branch.test.d.ts +2 -0
- package/dist/tools/tests/coList.branch.test.d.ts.map +1 -0
- package/dist/tools/tests/coMap.branch.test.d.ts +2 -0
- package/dist/tools/tests/coMap.branch.test.d.ts.map +1 -0
- package/dist/tools/tests/group.test.d.ts +2 -0
- package/dist/tools/tests/group.test.d.ts.map +1 -0
- package/package.json +4 -4
- package/src/prosemirror/lib/plugin.ts +7 -1
- package/src/react-core/hooks.ts +86 -6
- package/src/react-core/tests/useAccount.test.ts +94 -2
- package/src/react-core/tests/useCoState.test.ts +74 -0
- package/src/svelte/jazz.class.svelte.ts +39 -7
- package/src/tools/coValues/CoValueBase.ts +44 -9
- package/src/tools/coValues/account.ts +6 -9
- package/src/tools/coValues/coFeed.ts +10 -18
- package/src/tools/coValues/coList.ts +10 -10
- package/src/tools/coValues/coMap.ts +7 -9
- package/src/tools/coValues/coPlainText.ts +1 -4
- package/src/tools/coValues/group.ts +9 -2
- package/src/tools/coValues/interfaces.ts +92 -1
- package/src/tools/exports.ts +1 -0
- package/src/tools/implementation/zodSchema/coExport.ts +2 -0
- package/src/tools/implementation/zodSchema/runtimeConverters/coValueSchemaTransformation.ts +4 -0
- package/src/tools/implementation/zodSchema/schemaTypes/AccountSchema.ts +15 -1
- package/src/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.ts +2 -0
- package/src/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.ts +17 -0
- package/src/tools/implementation/zodSchema/schemaTypes/CoListSchema.ts +17 -0
- package/src/tools/implementation/zodSchema/schemaTypes/CoMapSchema.ts +23 -0
- package/src/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.ts +15 -0
- package/src/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.ts +9 -0
- package/src/tools/implementation/zodSchema/schemaTypes/GroupSchema.ts +71 -0
- package/src/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.ts +18 -2
- package/src/tools/implementation/zodSchema/schemaTypes/RichTextSchema.ts +18 -2
- package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.ts +36 -30
- package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.ts +42 -38
- package/src/tools/implementation/zodSchema/zodCo.ts +9 -0
- package/src/tools/implementation/zodSchema/zodSchema.ts +24 -19
- package/src/tools/internal.ts +2 -0
- package/src/tools/subscribe/CoValueCoreSubscription.test.ts +110 -7
- package/src/tools/subscribe/CoValueCoreSubscription.ts +17 -9
- package/src/tools/subscribe/SubscriptionScope.ts +5 -1
- package/src/tools/subscribe/types.ts +9 -1
- package/src/tools/tests/coFeed.branch.test.ts +676 -0
- package/src/tools/tests/coList.branch.test.ts +797 -0
- package/src/tools/tests/coMap.branch.test.ts +883 -0
- package/src/tools/tests/group.test.ts +77 -0
- package/dist/chunk-PRSMJMJR.js.map +0 -1
@@ -145,6 +145,13 @@ var CoValueJazzApi = class {
|
|
145
145
|
enumerable: false
|
146
146
|
});
|
147
147
|
}
|
148
|
+
get id() {
|
149
|
+
const sourceId = this.raw.core.getCurrentBranchSourceId();
|
150
|
+
if (sourceId) {
|
151
|
+
return sourceId;
|
152
|
+
}
|
153
|
+
return this.raw.id;
|
154
|
+
}
|
148
155
|
/** @internal */
|
149
156
|
get localNode() {
|
150
157
|
return this.raw.core.node;
|
@@ -188,6 +195,29 @@ var CoValueJazzApi = class {
|
|
188
195
|
}
|
189
196
|
return value;
|
190
197
|
}
|
198
|
+
/**
|
199
|
+
* The name of the active branch of the CoValue
|
200
|
+
*/
|
201
|
+
get branchName() {
|
202
|
+
const subscriptionScope = this._subscriptionScope;
|
203
|
+
return subscriptionScope?.unstable_branch?.name;
|
204
|
+
}
|
205
|
+
get isBranched() {
|
206
|
+
const subscriptionScope = this._subscriptionScope;
|
207
|
+
return Boolean(subscriptionScope?.unstable_branch);
|
208
|
+
}
|
209
|
+
/**
|
210
|
+
* Deeply merge the current branch into the main CoValues.
|
211
|
+
*
|
212
|
+
* Doesn't have any effect when there are no changes to merge, or the current CoValue is not a branch
|
213
|
+
*/
|
214
|
+
unstable_merge() {
|
215
|
+
const subscriptionScope = this._subscriptionScope;
|
216
|
+
if (!subscriptionScope) {
|
217
|
+
return;
|
218
|
+
}
|
219
|
+
unstable_mergeBranch(subscriptionScope);
|
220
|
+
}
|
191
221
|
};
|
192
222
|
|
193
223
|
// src/tools/implementation/inspect.ts
|
@@ -494,13 +524,6 @@ var CoMapJazzApi = class extends CoValueJazzApi {
|
|
494
524
|
this.coMap = coMap;
|
495
525
|
this.getRaw = getRaw;
|
496
526
|
}
|
497
|
-
/**
|
498
|
-
* The ID of this `CoMap`
|
499
|
-
* @category Content
|
500
|
-
*/
|
501
|
-
get id() {
|
502
|
-
return this.raw.id;
|
503
|
-
}
|
504
527
|
get owner() {
|
505
528
|
return getCoValueOwner(this.coMap);
|
506
529
|
}
|
@@ -1132,13 +1155,6 @@ var CoListJazzApi = class extends CoValueJazzApi {
|
|
1132
1155
|
this.coList = coList;
|
1133
1156
|
this.getRaw = getRaw;
|
1134
1157
|
}
|
1135
|
-
/**
|
1136
|
-
* The ID of this `CoList`
|
1137
|
-
* @category Content
|
1138
|
-
*/
|
1139
|
-
get id() {
|
1140
|
-
return this.raw.id;
|
1141
|
-
}
|
1142
1158
|
/** @category Collaboration */
|
1143
1159
|
get owner() {
|
1144
1160
|
return getCoValueOwner(this.coList);
|
@@ -1647,13 +1663,6 @@ var CoFeedJazzApi = class extends CoValueJazzApi {
|
|
1647
1663
|
this.coFeed = coFeed;
|
1648
1664
|
this.raw = raw;
|
1649
1665
|
}
|
1650
|
-
/**
|
1651
|
-
* The ID of this `CoFeed`
|
1652
|
-
* @category Content
|
1653
|
-
*/
|
1654
|
-
get id() {
|
1655
|
-
return this.raw.id;
|
1656
|
-
}
|
1657
1666
|
get owner() {
|
1658
1667
|
return getCoValueOwner(this.coFeed);
|
1659
1668
|
}
|
@@ -2094,13 +2103,6 @@ var FileStreamJazzApi = class extends CoValueJazzApi {
|
|
2094
2103
|
this.fileStream = fileStream;
|
2095
2104
|
this.raw = raw;
|
2096
2105
|
}
|
2097
|
-
/**
|
2098
|
-
* The ID of this `FileStream`
|
2099
|
-
* @category Content
|
2100
|
-
*/
|
2101
|
-
get id() {
|
2102
|
-
return this.raw.id;
|
2103
|
-
}
|
2104
2106
|
get owner() {
|
2105
2107
|
return getCoValueOwner(this.fileStream);
|
2106
2108
|
}
|
@@ -2325,13 +2327,6 @@ var AccountJazzApi = class extends CoValueJazzApi {
|
|
2325
2327
|
this.sessionID = this.localNode.currentSessionID;
|
2326
2328
|
}
|
2327
2329
|
}
|
2328
|
-
/**
|
2329
|
-
* The ID of this `Account`
|
2330
|
-
* @category Content
|
2331
|
-
*/
|
2332
|
-
get id() {
|
2333
|
-
return this.raw.id;
|
2334
|
-
}
|
2335
2330
|
/**
|
2336
2331
|
* Accounts have no owner. They can be accessed by everyone.
|
2337
2332
|
*/
|
@@ -2635,7 +2630,10 @@ var _Group = class _Group extends CoValueBase {
|
|
2635
2630
|
await this.$jazz.raw.revokeExtend(parent.$jazz.raw);
|
2636
2631
|
return this;
|
2637
2632
|
}
|
2638
|
-
/** @category Subscription & Loading
|
2633
|
+
/** @category Subscription & Loading
|
2634
|
+
*
|
2635
|
+
* @deprecated Use `co.group(...).load` instead.
|
2636
|
+
*/
|
2639
2637
|
static load(id, options) {
|
2640
2638
|
return loadCoValueWithoutMe(this, id, options);
|
2641
2639
|
}
|
@@ -3149,9 +3147,6 @@ var CoTextJazzApi = class extends CoValueJazzApi {
|
|
3149
3147
|
this.coText = coText;
|
3150
3148
|
this.raw = raw;
|
3151
3149
|
}
|
3152
|
-
get id() {
|
3153
|
-
return this.raw.id;
|
3154
|
-
}
|
3155
3150
|
get owner() {
|
3156
3151
|
return getCoValueOwner(this.coText);
|
3157
3152
|
}
|
@@ -3512,6 +3507,9 @@ function applyCoValueMigrations(instance) {
|
|
3512
3507
|
}
|
3513
3508
|
|
3514
3509
|
// src/tools/subscribe/CoValueCoreSubscription.ts
|
3510
|
+
import {
|
3511
|
+
cojsonInternals as cojsonInternals5
|
3512
|
+
} from "cojson";
|
3515
3513
|
var CoValueCoreSubscription = class {
|
3516
3514
|
constructor(localNode, id, listener, skipRetry, branch) {
|
3517
3515
|
this._unsubscribe = () => {
|
@@ -3532,7 +3530,7 @@ var CoValueCoreSubscription = class {
|
|
3532
3530
|
initializeSubscription() {
|
3533
3531
|
const source = this.source;
|
3534
3532
|
if (source.isAvailable()) {
|
3535
|
-
this.handleAvailableSource(
|
3533
|
+
this.handleAvailableSource();
|
3536
3534
|
return;
|
3537
3535
|
}
|
3538
3536
|
if (this.branchName) {
|
@@ -3545,15 +3543,18 @@ var CoValueCoreSubscription = class {
|
|
3545
3543
|
* Handles the case where the CoValue source is immediately available.
|
3546
3544
|
* Either subscribes directly or attempts to get the requested branch.
|
3547
3545
|
*/
|
3548
|
-
handleAvailableSource(
|
3549
|
-
if (!this.branchName) {
|
3550
|
-
this.subscribe(source.getCurrentContent());
|
3546
|
+
handleAvailableSource() {
|
3547
|
+
if (!this.branchName || !cojsonInternals5.canBeBranched(this.source)) {
|
3548
|
+
this.subscribe(this.source.getCurrentContent());
|
3551
3549
|
return;
|
3552
3550
|
}
|
3553
|
-
const branch = source.getBranch(this.branchName, this.branchOwnerId);
|
3551
|
+
const branch = this.source.getBranch(this.branchName, this.branchOwnerId);
|
3554
3552
|
if (branch.isAvailable()) {
|
3555
3553
|
this.subscribe(branch.getCurrentContent());
|
3556
3554
|
return;
|
3555
|
+
} else if (!this.source.hasBranch(this.branchName, this.branchOwnerId)) {
|
3556
|
+
this.source.createBranch(this.branchName, this.branchOwnerId);
|
3557
|
+
this.subscribe(branch.getCurrentContent());
|
3557
3558
|
} else {
|
3558
3559
|
this.handleBranchCheckout();
|
3559
3560
|
}
|
@@ -3725,12 +3726,13 @@ function createCoValue(ref2, raw, subscriptionScope) {
|
|
3725
3726
|
|
3726
3727
|
// src/tools/subscribe/SubscriptionScope.ts
|
3727
3728
|
var SubscriptionScope = class _SubscriptionScope {
|
3728
|
-
constructor(node, resolve, id, schema, skipRetry = false, bestEffortResolution = false) {
|
3729
|
+
constructor(node, resolve, id, schema, skipRetry = false, bestEffortResolution = false, unstable_branch) {
|
3729
3730
|
this.node = node;
|
3730
3731
|
this.id = id;
|
3731
3732
|
this.schema = schema;
|
3732
3733
|
this.skipRetry = skipRetry;
|
3733
3734
|
this.bestEffortResolution = bestEffortResolution;
|
3735
|
+
this.unstable_branch = unstable_branch;
|
3734
3736
|
this.childNodes = /* @__PURE__ */ new Map();
|
3735
3737
|
this.childValues = /* @__PURE__ */ new Map();
|
3736
3738
|
this.childErrors = /* @__PURE__ */ new Map();
|
@@ -3793,7 +3795,8 @@ var SubscriptionScope = class _SubscriptionScope {
|
|
3793
3795
|
}
|
3794
3796
|
this.handleUpdate(value);
|
3795
3797
|
},
|
3796
|
-
skipRetry
|
3798
|
+
skipRetry,
|
3799
|
+
this.unstable_branch
|
3797
3800
|
);
|
3798
3801
|
}
|
3799
3802
|
updateValue(value) {
|
@@ -3995,7 +3998,8 @@ var SubscriptionScope = class _SubscriptionScope {
|
|
3995
3998
|
id,
|
3996
3999
|
descriptor,
|
3997
4000
|
this.skipRetry,
|
3998
|
-
this.bestEffortResolution
|
4001
|
+
this.bestEffortResolution,
|
4002
|
+
this.unstable_branch
|
3999
4003
|
);
|
4000
4004
|
this.childNodes.set(id, child);
|
4001
4005
|
child.setListener((value) => this.handleChildUpdate(id, value));
|
@@ -4176,7 +4180,8 @@ var SubscriptionScope = class _SubscriptionScope {
|
|
4176
4180
|
id,
|
4177
4181
|
descriptor,
|
4178
4182
|
this.skipRetry,
|
4179
|
-
this.bestEffortResolution
|
4183
|
+
this.bestEffortResolution,
|
4184
|
+
this.unstable_branch
|
4180
4185
|
);
|
4181
4186
|
this.childNodes.set(id, child);
|
4182
4187
|
child.setListener((value) => this.handleChildUpdate(id, value, key));
|
@@ -4234,7 +4239,7 @@ function accessChildById(parent, childId, schema) {
|
|
4234
4239
|
|
4235
4240
|
// src/tools/implementation/createContext.ts
|
4236
4241
|
import {
|
4237
|
-
LocalNode as
|
4242
|
+
LocalNode as LocalNode4
|
4238
4243
|
} from "cojson";
|
4239
4244
|
async function randomSessionProvider(accountID, crypto) {
|
4240
4245
|
return {
|
@@ -4259,7 +4264,7 @@ async function createJazzContextFromExistingCredentials({
|
|
4259
4264
|
);
|
4260
4265
|
const CurrentAccountSchema = PropsAccountSchema ?? RegisteredSchemas["Account"];
|
4261
4266
|
const AccountClass = coValueClassFromCoValueClassOrSchema(CurrentAccountSchema);
|
4262
|
-
const node = await
|
4267
|
+
const node = await LocalNode4.withLoadedAccount({
|
4263
4268
|
accountID: credentials.accountID,
|
4264
4269
|
accountSecret: credentials.secret,
|
4265
4270
|
sessionID,
|
@@ -4303,7 +4308,7 @@ async function createJazzContextForNewAccount({
|
|
4303
4308
|
}) {
|
4304
4309
|
const CurrentAccountSchema = PropsAccountSchema ?? RegisteredSchemas["Account"];
|
4305
4310
|
const AccountClass = coValueClassFromCoValueClassOrSchema(CurrentAccountSchema);
|
4306
|
-
const { node } = await
|
4311
|
+
const { node } = await LocalNode4.withNewlyCreatedAccount({
|
4307
4312
|
creationProps,
|
4308
4313
|
peersToLoadFrom,
|
4309
4314
|
crypto,
|
@@ -4388,7 +4393,7 @@ function createAnonymousJazzContext({
|
|
4388
4393
|
storage
|
4389
4394
|
}) {
|
4390
4395
|
const agentSecret = crypto.newRandomAgentSecret();
|
4391
|
-
const node = new
|
4396
|
+
const node = new LocalNode4(
|
4392
4397
|
agentSecret,
|
4393
4398
|
crypto.newRandomSessionID(crypto.getAgentID(agentSecret)),
|
4394
4399
|
crypto
|
@@ -4497,6 +4502,9 @@ var RichTextSchema = class {
|
|
4497
4502
|
subscribe(...args) {
|
4498
4503
|
return this.coValueClass.subscribe(...args);
|
4499
4504
|
}
|
4505
|
+
unstable_merge(id, options) {
|
4506
|
+
return unstable_mergeBranchWithResolve2(this.coValueClass, id, options);
|
4507
|
+
}
|
4500
4508
|
getCoValueClass() {
|
4501
4509
|
return this.coValueClass;
|
4502
4510
|
}
|
@@ -4505,6 +4513,35 @@ var RichTextSchema = class {
|
|
4505
4513
|
}
|
4506
4514
|
};
|
4507
4515
|
|
4516
|
+
// src/tools/implementation/zodSchema/schemaTypes/GroupSchema.ts
|
4517
|
+
function createCoreGroupSchema() {
|
4518
|
+
return {
|
4519
|
+
collaborative: true,
|
4520
|
+
builtin: "Group"
|
4521
|
+
};
|
4522
|
+
}
|
4523
|
+
var GroupSchema = class {
|
4524
|
+
constructor() {
|
4525
|
+
this.collaborative = true;
|
4526
|
+
this.builtin = "Group";
|
4527
|
+
}
|
4528
|
+
getCoValueClass() {
|
4529
|
+
return Group6;
|
4530
|
+
}
|
4531
|
+
optional() {
|
4532
|
+
return coOptionalDefiner(this);
|
4533
|
+
}
|
4534
|
+
create(options) {
|
4535
|
+
return Group6.create(options);
|
4536
|
+
}
|
4537
|
+
load(id, options) {
|
4538
|
+
return Group6.load(id, options);
|
4539
|
+
}
|
4540
|
+
subscribe(id, ...args) {
|
4541
|
+
return Group6.subscribe(id, ...args);
|
4542
|
+
}
|
4543
|
+
};
|
4544
|
+
|
4508
4545
|
// src/tools/implementation/zodSchema/zodCo.ts
|
4509
4546
|
var isZodV4Schema = (schema) => {
|
4510
4547
|
return typeof schema === "object" && schema !== null && "_zod" in schema;
|
@@ -4541,6 +4578,10 @@ var coAccountDefiner = (shape = {
|
|
4541
4578
|
const coreSchema = createCoreAccountSchema(shape);
|
4542
4579
|
return hydrateCoreCoValueSchema(coreSchema);
|
4543
4580
|
};
|
4581
|
+
var coGroupDefiner = () => {
|
4582
|
+
const coreSchema = createCoreGroupSchema();
|
4583
|
+
return hydrateCoreCoValueSchema(coreSchema);
|
4584
|
+
};
|
4544
4585
|
var coRecordDefiner = (_keyType, valueType) => {
|
4545
4586
|
return coMapDefiner({}).catchall(valueType);
|
4546
4587
|
};
|
@@ -4604,6 +4645,7 @@ __export(coExport_exports, {
|
|
4604
4645
|
DiscriminatedUnion: () => CoDiscriminatedUnionSchema,
|
4605
4646
|
Feed: () => CoFeedSchema,
|
4606
4647
|
FileStream: () => FileStreamSchema,
|
4648
|
+
Group: () => GroupSchema,
|
4607
4649
|
List: () => CoListSchema,
|
4608
4650
|
Optional: () => CoOptionalSchema,
|
4609
4651
|
PlainText: () => PlainTextSchema,
|
@@ -4612,6 +4654,7 @@ __export(coExport_exports, {
|
|
4612
4654
|
discriminatedUnion: () => coDiscriminatedUnionDefiner,
|
4613
4655
|
feed: () => coFeedDefiner,
|
4614
4656
|
fileStream: () => coFileStreamDefiner,
|
4657
|
+
group: () => coGroupDefiner,
|
4615
4658
|
image: () => coImageDefiner,
|
4616
4659
|
list: () => coListDefiner,
|
4617
4660
|
map: () => coMapDefiner,
|
@@ -4673,6 +4716,9 @@ function enrichCoMapSchema(schema, coValueClass) {
|
|
4673
4716
|
loadUnique: (...args) => {
|
4674
4717
|
return coValueClass.loadUnique(...args);
|
4675
4718
|
},
|
4719
|
+
unstable_merge: (...args) => {
|
4720
|
+
return unstable_mergeBranchWithResolve2(coValueClass, ...args);
|
4721
|
+
},
|
4676
4722
|
catchall: (catchAll) => {
|
4677
4723
|
const schemaWithCatchAll = createCoreCoMapSchema(
|
4678
4724
|
coValueSchema.getDefinition().shape,
|
@@ -4739,6 +4785,9 @@ var CoListSchema = class {
|
|
4739
4785
|
load(id, options) {
|
4740
4786
|
return this.coValueClass.load(id, options);
|
4741
4787
|
}
|
4788
|
+
unstable_merge(id, options) {
|
4789
|
+
return unstable_mergeBranchWithResolve2(this.coValueClass, id, options);
|
4790
|
+
}
|
4742
4791
|
subscribe(id, options, listener) {
|
4743
4792
|
return this.coValueClass.subscribe(id, options, listener);
|
4744
4793
|
}
|
@@ -4781,6 +4830,9 @@ var CoFeedSchema = class {
|
|
4781
4830
|
load(id, options) {
|
4782
4831
|
return this.coValueClass.load(id, options);
|
4783
4832
|
}
|
4833
|
+
unstable_merge(id, options) {
|
4834
|
+
return unstable_mergeBranchWithResolve2(this.coValueClass, id, options);
|
4835
|
+
}
|
4784
4836
|
subscribe(...args) {
|
4785
4837
|
return this.coValueClass.subscribe(...args);
|
4786
4838
|
}
|
@@ -4821,6 +4873,9 @@ var PlainTextSchema = class {
|
|
4821
4873
|
subscribe(...args) {
|
4822
4874
|
return this.coValueClass.subscribe(...args);
|
4823
4875
|
}
|
4876
|
+
unstable_merge(id, options) {
|
4877
|
+
return unstable_mergeBranchWithResolve2(this.coValueClass, id, options);
|
4878
|
+
}
|
4824
4879
|
fromRaw(raw) {
|
4825
4880
|
return this.coValueClass.fromRaw(raw);
|
4826
4881
|
}
|
@@ -4860,6 +4915,9 @@ var FileStreamSchema = class {
|
|
4860
4915
|
load(id, options) {
|
4861
4916
|
return this.coValueClass.load(id, options);
|
4862
4917
|
}
|
4918
|
+
unstable_merge(id, options) {
|
4919
|
+
return unstable_mergeBranchWithResolve2(this.coValueClass, id, options);
|
4920
|
+
}
|
4863
4921
|
subscribe(...args) {
|
4864
4922
|
return this.coValueClass.subscribe(...args);
|
4865
4923
|
}
|
@@ -4898,6 +4956,9 @@ function enrichAccountSchema(schema, coValueClass) {
|
|
4898
4956
|
fromRaw: (...args) => {
|
4899
4957
|
return coValueClass.fromRaw(...args);
|
4900
4958
|
},
|
4959
|
+
unstable_merge: (...args) => {
|
4960
|
+
return unstable_mergeBranchWithResolve(coValueClass, ...args);
|
4961
|
+
},
|
4901
4962
|
withMigration: (migration) => {
|
4902
4963
|
coValueClass.prototype.migrate = async function(creationProps) {
|
4903
4964
|
await migration(this, creationProps);
|
@@ -5157,6 +5218,8 @@ function hydrateCoreCoValueSchema(schema) {
|
|
5157
5218
|
const coValueClass = SchemaUnion.Of(schemaUnionDiscriminatorFor(schema));
|
5158
5219
|
const coValueSchema = new CoDiscriminatedUnionSchema(schema, coValueClass);
|
5159
5220
|
return coValueSchema;
|
5221
|
+
} else if (schema.builtin === "Group") {
|
5222
|
+
return new GroupSchema();
|
5160
5223
|
} else {
|
5161
5224
|
const notReachable = schema;
|
5162
5225
|
throw new Error(
|
@@ -5183,7 +5246,7 @@ var ImageDefinitionBase = coMapDefiner({
|
|
5183
5246
|
var ImageDefinition = ImageDefinitionBase;
|
5184
5247
|
|
5185
5248
|
// src/tools/implementation/ContextManager.ts
|
5186
|
-
import { cojsonInternals as
|
5249
|
+
import { cojsonInternals as cojsonInternals6 } from "cojson";
|
5187
5250
|
import { PureJSCrypto } from "cojson/dist/crypto/PureJSCrypto";
|
5188
5251
|
|
5189
5252
|
// src/tools/auth/KvStoreContext.ts
|
@@ -5543,7 +5606,7 @@ var JazzContextManager = class {
|
|
5543
5606
|
}
|
5544
5607
|
const currentContext = this.context;
|
5545
5608
|
if (prevContext && currentContext && "me" in prevContext && "me" in currentContext) {
|
5546
|
-
const [prevAccountAsPeer, currentAccountAsPeer] =
|
5609
|
+
const [prevAccountAsPeer, currentAccountAsPeer] = cojsonInternals6.connectedPeers(
|
5547
5610
|
prevContext.me.$jazz.id,
|
5548
5611
|
currentContext.me.$jazz.id,
|
5549
5612
|
{
|
@@ -5663,7 +5726,8 @@ function isCoValueClass(value) {
|
|
5663
5726
|
function loadCoValueWithoutMe(cls, id, options) {
|
5664
5727
|
return loadCoValue(cls, id, {
|
5665
5728
|
...options,
|
5666
|
-
loadAs: options?.loadAs ?? activeAccountContext.get()
|
5729
|
+
loadAs: options?.loadAs ?? activeAccountContext.get(),
|
5730
|
+
unstable_branch: options?.unstable_branch
|
5667
5731
|
});
|
5668
5732
|
}
|
5669
5733
|
function loadCoValue(cls, id, options) {
|
@@ -5681,7 +5745,8 @@ function loadCoValue(cls, id, options) {
|
|
5681
5745
|
},
|
5682
5746
|
onUnauthorized: () => {
|
5683
5747
|
resolve(null);
|
5684
|
-
}
|
5748
|
+
},
|
5749
|
+
unstable_branch: options.unstable_branch
|
5685
5750
|
},
|
5686
5751
|
(value, unsubscribe) => {
|
5687
5752
|
resolve(value);
|
@@ -5696,7 +5761,8 @@ async function ensureCoValueLoaded(existing, options) {
|
|
5696
5761
|
existing.$jazz.id,
|
5697
5762
|
{
|
5698
5763
|
loadAs: existing.$jazz.loadedAs,
|
5699
|
-
resolve: options?.resolve
|
5764
|
+
resolve: options?.resolve,
|
5765
|
+
unstable_branch: options?.unstable_branch
|
5700
5766
|
}
|
5701
5767
|
);
|
5702
5768
|
if (!response) {
|
@@ -5712,7 +5778,8 @@ function parseSubscribeRestArgs(args) {
|
|
5712
5778
|
resolve: args[0].resolve,
|
5713
5779
|
loadAs: args[0].loadAs,
|
5714
5780
|
onUnauthorized: args[0].onUnauthorized,
|
5715
|
-
onUnavailable: args[0].onUnavailable
|
5781
|
+
onUnavailable: args[0].onUnavailable,
|
5782
|
+
unstable_branch: args[0].unstable_branch
|
5716
5783
|
},
|
5717
5784
|
listener: args[1]
|
5718
5785
|
};
|
@@ -5751,7 +5818,9 @@ function subscribeToCoValue(cls, id, options, listener) {
|
|
5751
5818
|
ref: cls,
|
5752
5819
|
optional: false
|
5753
5820
|
},
|
5754
|
-
options.skipRetry
|
5821
|
+
options.skipRetry,
|
5822
|
+
false,
|
5823
|
+
options.unstable_branch
|
5755
5824
|
);
|
5756
5825
|
const handleUpdate = (value) => {
|
5757
5826
|
if (unsubscribed) return;
|
@@ -5790,7 +5859,8 @@ function subscribeToExistingCoValue(existing, options, listener) {
|
|
5790
5859
|
loadAs: existing.$jazz.loadedAs,
|
5791
5860
|
resolve: options?.resolve,
|
5792
5861
|
onUnavailable: options?.onUnavailable,
|
5793
|
-
onUnauthorized: options?.onUnauthorized
|
5862
|
+
onUnauthorized: options?.onUnauthorized,
|
5863
|
+
unstable_branch: options?.unstable_branch
|
5794
5864
|
},
|
5795
5865
|
listener
|
5796
5866
|
);
|
@@ -5802,9 +5872,9 @@ function isAccountInstance(instance) {
|
|
5802
5872
|
return TypeSym in instance && instance[TypeSym] === "Account";
|
5803
5873
|
}
|
5804
5874
|
function parseCoValueCreateOptions(options) {
|
5805
|
-
const
|
5875
|
+
const Group17 = RegisteredSchemas["Group"];
|
5806
5876
|
if (!options) {
|
5807
|
-
return { owner:
|
5877
|
+
return { owner: Group17.create(), uniqueness: void 0 };
|
5808
5878
|
}
|
5809
5879
|
if (TypeSym in options) {
|
5810
5880
|
if (options[TypeSym] === "Account") {
|
@@ -5815,7 +5885,7 @@ function parseCoValueCreateOptions(options) {
|
|
5815
5885
|
}
|
5816
5886
|
const uniqueness = options.unique ? { uniqueness: options.unique } : void 0;
|
5817
5887
|
const opts = {
|
5818
|
-
owner: options.owner ? accountOrGroupToGroup(options.owner) :
|
5888
|
+
owner: options.owner ? accountOrGroupToGroup(options.owner) : Group17.create(),
|
5819
5889
|
uniqueness
|
5820
5890
|
};
|
5821
5891
|
return opts;
|
@@ -5845,7 +5915,8 @@ async function exportCoValue(cls, id, options) {
|
|
5845
5915
|
optional: false
|
5846
5916
|
},
|
5847
5917
|
options.skipRetry,
|
5848
|
-
options.bestEffortResolution
|
5918
|
+
options.bestEffortResolution,
|
5919
|
+
options.unstable_branch
|
5849
5920
|
);
|
5850
5921
|
const value = await new Promise((resolve2) => {
|
5851
5922
|
rootNode.setListener((value2) => {
|
@@ -5905,6 +5976,50 @@ function importContentPieces(contentPieces, loadAs) {
|
|
5905
5976
|
node.syncManager.handleNewContent(piece, "import");
|
5906
5977
|
}
|
5907
5978
|
}
|
5979
|
+
function unstable_mergeBranch(subscriptionScope) {
|
5980
|
+
if (!subscriptionScope.unstable_branch) {
|
5981
|
+
return;
|
5982
|
+
}
|
5983
|
+
function handleMerge(subscriptionNode) {
|
5984
|
+
if (subscriptionNode.value.type === "loaded") {
|
5985
|
+
subscriptionNode.value.value.$jazz.raw.core.mergeBranch();
|
5986
|
+
}
|
5987
|
+
for (const childNode of subscriptionNode.childNodes.values()) {
|
5988
|
+
handleMerge(childNode);
|
5989
|
+
}
|
5990
|
+
}
|
5991
|
+
handleMerge(subscriptionScope);
|
5992
|
+
}
|
5993
|
+
async function unstable_mergeBranchWithResolve2(cls, id, options) {
|
5994
|
+
const loadAs = options.loadAs ?? activeAccountContext.get();
|
5995
|
+
const node = "node" in loadAs ? loadAs.node : loadAs.$jazz.localNode;
|
5996
|
+
const resolve = options.resolve ?? true;
|
5997
|
+
const rootNode = new SubscriptionScope(
|
5998
|
+
node,
|
5999
|
+
resolve,
|
6000
|
+
id,
|
6001
|
+
{
|
6002
|
+
ref: coValueClassFromCoValueClassOrSchema(cls),
|
6003
|
+
optional: false
|
6004
|
+
},
|
6005
|
+
false,
|
6006
|
+
false,
|
6007
|
+
options.branch
|
6008
|
+
);
|
6009
|
+
await new Promise((resolve2, reject) => {
|
6010
|
+
rootNode.setListener((value) => {
|
6011
|
+
if (value.type === "unavailable") {
|
6012
|
+
reject(new Error("Unable to load the branch. " + value.toString()));
|
6013
|
+
} else if (value.type === "unauthorized") {
|
6014
|
+
reject(new Error("Unable to load the branch. " + value.toString()));
|
6015
|
+
} else if (value.type === "loaded") {
|
6016
|
+
resolve2();
|
6017
|
+
}
|
6018
|
+
rootNode.destroy();
|
6019
|
+
});
|
6020
|
+
});
|
6021
|
+
unstable_mergeBranch(rootNode);
|
6022
|
+
}
|
5908
6023
|
|
5909
6024
|
export {
|
5910
6025
|
zodReExport_exports,
|
@@ -5948,4 +6063,4 @@ export {
|
|
5948
6063
|
JazzContextManager
|
5949
6064
|
};
|
5950
6065
|
/* istanbul ignore file -- @preserve */
|
5951
|
-
//# sourceMappingURL=chunk-
|
6066
|
+
//# sourceMappingURL=chunk-AEXYCCQS.js.map
|