@yorkie-js/react 0.6.11-rc → 0.6.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/dist/yorkie-js-react.es.js +513 -179
- package/dist/yorkie-js-react.es.js.map +1 -1
- package/dist/yorkie-js-react.js +513 -179
- package/dist/yorkie-js-react.js.map +1 -1
- package/package.json +2 -2
package/dist/yorkie-js-react.js
CHANGED
|
@@ -7,7 +7,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7
7
|
|
|
8
8
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
9
9
|
const name$1 = "@yorkie-js/react";
|
|
10
|
-
const version$1 = "0.6.
|
|
10
|
+
const version$1 = "0.6.13";
|
|
11
11
|
const pkg$1 = {
|
|
12
12
|
name: name$1,
|
|
13
13
|
version: version$1
|
|
@@ -6092,15 +6092,39 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6092
6092
|
*/
|
|
6093
6093
|
__publicField(this, "authWebhookMethods", []);
|
|
6094
6094
|
/**
|
|
6095
|
-
* @generated from field: string
|
|
6095
|
+
* @generated from field: string event_webhook_url = 7;
|
|
6096
|
+
*/
|
|
6097
|
+
__publicField(this, "eventWebhookUrl", "");
|
|
6098
|
+
/**
|
|
6099
|
+
* @generated from field: repeated string event_webhook_events = 8;
|
|
6100
|
+
*/
|
|
6101
|
+
__publicField(this, "eventWebhookEvents", []);
|
|
6102
|
+
/**
|
|
6103
|
+
* @generated from field: string client_deactivate_threshold = 9;
|
|
6096
6104
|
*/
|
|
6097
6105
|
__publicField(this, "clientDeactivateThreshold", "");
|
|
6098
6106
|
/**
|
|
6099
|
-
* @generated from field:
|
|
6107
|
+
* @generated from field: int32 max_subscribers_per_document = 10;
|
|
6108
|
+
*/
|
|
6109
|
+
__publicField(this, "maxSubscribersPerDocument", 0);
|
|
6110
|
+
/**
|
|
6111
|
+
* @generated from field: int32 max_attachments_per_document = 11;
|
|
6112
|
+
*/
|
|
6113
|
+
__publicField(this, "maxAttachmentsPerDocument", 0);
|
|
6114
|
+
/**
|
|
6115
|
+
* @generated from field: int32 max_size_per_document = 15;
|
|
6116
|
+
*/
|
|
6117
|
+
__publicField(this, "maxSizePerDocument", 0);
|
|
6118
|
+
/**
|
|
6119
|
+
* @generated from field: repeated string allowed_origins = 14;
|
|
6120
|
+
*/
|
|
6121
|
+
__publicField(this, "allowedOrigins", []);
|
|
6122
|
+
/**
|
|
6123
|
+
* @generated from field: google.protobuf.Timestamp created_at = 12;
|
|
6100
6124
|
*/
|
|
6101
6125
|
__publicField(this, "createdAt");
|
|
6102
6126
|
/**
|
|
6103
|
-
* @generated from field: google.protobuf.Timestamp updated_at =
|
|
6127
|
+
* @generated from field: google.protobuf.Timestamp updated_at = 13;
|
|
6104
6128
|
*/
|
|
6105
6129
|
__publicField(this, "updatedAt");
|
|
6106
6130
|
proto3.util.initPartial(data, this);
|
|
@@ -6159,13 +6183,43 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6159
6183
|
{ no: 6, name: "auth_webhook_methods", kind: "scalar", T: 9, repeated: true },
|
|
6160
6184
|
{
|
|
6161
6185
|
no: 7,
|
|
6186
|
+
name: "event_webhook_url",
|
|
6187
|
+
kind: "scalar",
|
|
6188
|
+
T: 9
|
|
6189
|
+
/* ScalarType.STRING */
|
|
6190
|
+
},
|
|
6191
|
+
{ no: 8, name: "event_webhook_events", kind: "scalar", T: 9, repeated: true },
|
|
6192
|
+
{
|
|
6193
|
+
no: 9,
|
|
6162
6194
|
name: "client_deactivate_threshold",
|
|
6163
6195
|
kind: "scalar",
|
|
6164
6196
|
T: 9
|
|
6165
6197
|
/* ScalarType.STRING */
|
|
6166
6198
|
},
|
|
6167
|
-
{
|
|
6168
|
-
|
|
6199
|
+
{
|
|
6200
|
+
no: 10,
|
|
6201
|
+
name: "max_subscribers_per_document",
|
|
6202
|
+
kind: "scalar",
|
|
6203
|
+
T: 5
|
|
6204
|
+
/* ScalarType.INT32 */
|
|
6205
|
+
},
|
|
6206
|
+
{
|
|
6207
|
+
no: 11,
|
|
6208
|
+
name: "max_attachments_per_document",
|
|
6209
|
+
kind: "scalar",
|
|
6210
|
+
T: 5
|
|
6211
|
+
/* ScalarType.INT32 */
|
|
6212
|
+
},
|
|
6213
|
+
{
|
|
6214
|
+
no: 15,
|
|
6215
|
+
name: "max_size_per_document",
|
|
6216
|
+
kind: "scalar",
|
|
6217
|
+
T: 5
|
|
6218
|
+
/* ScalarType.INT32 */
|
|
6219
|
+
},
|
|
6220
|
+
{ no: 14, name: "allowed_origins", kind: "scalar", T: 9, repeated: true },
|
|
6221
|
+
{ no: 12, name: "created_at", kind: "message", T: Timestamp },
|
|
6222
|
+
{ no: 13, name: "updated_at", kind: "message", T: Timestamp }
|
|
6169
6223
|
]));
|
|
6170
6224
|
let Project = _Project;
|
|
6171
6225
|
const _UpdatableProjectFields = class _UpdatableProjectFields extends Message {
|
|
@@ -6184,9 +6238,33 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6184
6238
|
*/
|
|
6185
6239
|
__publicField(this, "authWebhookMethods");
|
|
6186
6240
|
/**
|
|
6187
|
-
* @generated from field: google.protobuf.StringValue
|
|
6241
|
+
* @generated from field: google.protobuf.StringValue event_webhook_url = 4;
|
|
6242
|
+
*/
|
|
6243
|
+
__publicField(this, "eventWebhookUrl");
|
|
6244
|
+
/**
|
|
6245
|
+
* @generated from field: yorkie.v1.UpdatableProjectFields.EventWebhookEvents event_webhook_events = 5;
|
|
6246
|
+
*/
|
|
6247
|
+
__publicField(this, "eventWebhookEvents");
|
|
6248
|
+
/**
|
|
6249
|
+
* @generated from field: google.protobuf.StringValue client_deactivate_threshold = 6;
|
|
6188
6250
|
*/
|
|
6189
6251
|
__publicField(this, "clientDeactivateThreshold");
|
|
6252
|
+
/**
|
|
6253
|
+
* @generated from field: google.protobuf.Int32Value max_subscribers_per_document = 7;
|
|
6254
|
+
*/
|
|
6255
|
+
__publicField(this, "maxSubscribersPerDocument");
|
|
6256
|
+
/**
|
|
6257
|
+
* @generated from field: google.protobuf.Int32Value max_attachments_per_document = 8;
|
|
6258
|
+
*/
|
|
6259
|
+
__publicField(this, "maxAttachmentsPerDocument");
|
|
6260
|
+
/**
|
|
6261
|
+
* @generated from field: google.protobuf.Int32Value max_size_per_document = 10;
|
|
6262
|
+
*/
|
|
6263
|
+
__publicField(this, "maxSizePerDocument");
|
|
6264
|
+
/**
|
|
6265
|
+
* @generated from field: yorkie.v1.UpdatableProjectFields.AllowedOrigins allowed_origins = 9;
|
|
6266
|
+
*/
|
|
6267
|
+
__publicField(this, "allowedOrigins");
|
|
6190
6268
|
proto3.util.initPartial(data, this);
|
|
6191
6269
|
}
|
|
6192
6270
|
static fromBinary(bytes, options) {
|
|
@@ -6208,7 +6286,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6208
6286
|
{ no: 1, name: "name", kind: "message", T: StringValue },
|
|
6209
6287
|
{ no: 2, name: "auth_webhook_url", kind: "message", T: StringValue },
|
|
6210
6288
|
{ no: 3, name: "auth_webhook_methods", kind: "message", T: UpdatableProjectFields_AuthWebhookMethods },
|
|
6211
|
-
{ no: 4, name: "
|
|
6289
|
+
{ no: 4, name: "event_webhook_url", kind: "message", T: StringValue },
|
|
6290
|
+
{ no: 5, name: "event_webhook_events", kind: "message", T: UpdatableProjectFields_EventWebhookEvents },
|
|
6291
|
+
{ no: 6, name: "client_deactivate_threshold", kind: "message", T: StringValue },
|
|
6292
|
+
{ no: 7, name: "max_subscribers_per_document", kind: "message", T: Int32Value },
|
|
6293
|
+
{ no: 8, name: "max_attachments_per_document", kind: "message", T: Int32Value },
|
|
6294
|
+
{ no: 10, name: "max_size_per_document", kind: "message", T: Int32Value },
|
|
6295
|
+
{ no: 9, name: "allowed_origins", kind: "message", T: UpdatableProjectFields_AllowedOrigins }
|
|
6212
6296
|
]));
|
|
6213
6297
|
let UpdatableProjectFields = _UpdatableProjectFields;
|
|
6214
6298
|
const _UpdatableProjectFields_AuthWebhookMethods = class _UpdatableProjectFields_AuthWebhookMethods extends Message {
|
|
@@ -6239,6 +6323,62 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6239
6323
|
{ no: 1, name: "methods", kind: "scalar", T: 9, repeated: true }
|
|
6240
6324
|
]));
|
|
6241
6325
|
let UpdatableProjectFields_AuthWebhookMethods = _UpdatableProjectFields_AuthWebhookMethods;
|
|
6326
|
+
const _UpdatableProjectFields_EventWebhookEvents = class _UpdatableProjectFields_EventWebhookEvents extends Message {
|
|
6327
|
+
constructor(data) {
|
|
6328
|
+
super();
|
|
6329
|
+
/**
|
|
6330
|
+
* @generated from field: repeated string events = 1;
|
|
6331
|
+
*/
|
|
6332
|
+
__publicField(this, "events", []);
|
|
6333
|
+
proto3.util.initPartial(data, this);
|
|
6334
|
+
}
|
|
6335
|
+
static fromBinary(bytes, options) {
|
|
6336
|
+
return new _UpdatableProjectFields_EventWebhookEvents().fromBinary(bytes, options);
|
|
6337
|
+
}
|
|
6338
|
+
static fromJson(jsonValue, options) {
|
|
6339
|
+
return new _UpdatableProjectFields_EventWebhookEvents().fromJson(jsonValue, options);
|
|
6340
|
+
}
|
|
6341
|
+
static fromJsonString(jsonString, options) {
|
|
6342
|
+
return new _UpdatableProjectFields_EventWebhookEvents().fromJsonString(jsonString, options);
|
|
6343
|
+
}
|
|
6344
|
+
static equals(a, b) {
|
|
6345
|
+
return proto3.util.equals(_UpdatableProjectFields_EventWebhookEvents, a, b);
|
|
6346
|
+
}
|
|
6347
|
+
};
|
|
6348
|
+
__publicField(_UpdatableProjectFields_EventWebhookEvents, "runtime", proto3);
|
|
6349
|
+
__publicField(_UpdatableProjectFields_EventWebhookEvents, "typeName", "yorkie.v1.UpdatableProjectFields.EventWebhookEvents");
|
|
6350
|
+
__publicField(_UpdatableProjectFields_EventWebhookEvents, "fields", proto3.util.newFieldList(() => [
|
|
6351
|
+
{ no: 1, name: "events", kind: "scalar", T: 9, repeated: true }
|
|
6352
|
+
]));
|
|
6353
|
+
let UpdatableProjectFields_EventWebhookEvents = _UpdatableProjectFields_EventWebhookEvents;
|
|
6354
|
+
const _UpdatableProjectFields_AllowedOrigins = class _UpdatableProjectFields_AllowedOrigins extends Message {
|
|
6355
|
+
constructor(data) {
|
|
6356
|
+
super();
|
|
6357
|
+
/**
|
|
6358
|
+
* @generated from field: repeated string origins = 1;
|
|
6359
|
+
*/
|
|
6360
|
+
__publicField(this, "origins", []);
|
|
6361
|
+
proto3.util.initPartial(data, this);
|
|
6362
|
+
}
|
|
6363
|
+
static fromBinary(bytes, options) {
|
|
6364
|
+
return new _UpdatableProjectFields_AllowedOrigins().fromBinary(bytes, options);
|
|
6365
|
+
}
|
|
6366
|
+
static fromJson(jsonValue, options) {
|
|
6367
|
+
return new _UpdatableProjectFields_AllowedOrigins().fromJson(jsonValue, options);
|
|
6368
|
+
}
|
|
6369
|
+
static fromJsonString(jsonString, options) {
|
|
6370
|
+
return new _UpdatableProjectFields_AllowedOrigins().fromJsonString(jsonString, options);
|
|
6371
|
+
}
|
|
6372
|
+
static equals(a, b) {
|
|
6373
|
+
return proto3.util.equals(_UpdatableProjectFields_AllowedOrigins, a, b);
|
|
6374
|
+
}
|
|
6375
|
+
};
|
|
6376
|
+
__publicField(_UpdatableProjectFields_AllowedOrigins, "runtime", proto3);
|
|
6377
|
+
__publicField(_UpdatableProjectFields_AllowedOrigins, "typeName", "yorkie.v1.UpdatableProjectFields.AllowedOrigins");
|
|
6378
|
+
__publicField(_UpdatableProjectFields_AllowedOrigins, "fields", proto3.util.newFieldList(() => [
|
|
6379
|
+
{ no: 1, name: "origins", kind: "scalar", T: 9, repeated: true }
|
|
6380
|
+
]));
|
|
6381
|
+
let UpdatableProjectFields_AllowedOrigins = _UpdatableProjectFields_AllowedOrigins;
|
|
6242
6382
|
const _DocumentSummary = class _DocumentSummary extends Message {
|
|
6243
6383
|
constructor(data) {
|
|
6244
6384
|
super();
|
|
@@ -6795,6 +6935,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6795
6935
|
* @generated from field: string document_id = 1;
|
|
6796
6936
|
*/
|
|
6797
6937
|
__publicField(this, "documentId", "");
|
|
6938
|
+
/**
|
|
6939
|
+
* @generated from field: int32 max_size_per_document = 3;
|
|
6940
|
+
*/
|
|
6941
|
+
__publicField(this, "maxSizePerDocument", 0);
|
|
6798
6942
|
/**
|
|
6799
6943
|
* @generated from field: yorkie.v1.ChangePack change_pack = 2;
|
|
6800
6944
|
*/
|
|
@@ -6824,6 +6968,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6824
6968
|
T: 9
|
|
6825
6969
|
/* ScalarType.STRING */
|
|
6826
6970
|
},
|
|
6971
|
+
{
|
|
6972
|
+
no: 3,
|
|
6973
|
+
name: "max_size_per_document",
|
|
6974
|
+
kind: "scalar",
|
|
6975
|
+
T: 5
|
|
6976
|
+
/* ScalarType.INT32 */
|
|
6977
|
+
},
|
|
6827
6978
|
{ no: 2, name: "change_pack", kind: "message", T: ChangePack$1 }
|
|
6828
6979
|
]));
|
|
6829
6980
|
let AttachDocumentResponse = _AttachDocumentResponse;
|
|
@@ -7594,6 +7745,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7594
7745
|
Code2["ErrDocumentNotAttached"] = "ErrDocumentNotAttached";
|
|
7595
7746
|
Code2["ErrDocumentNotDetached"] = "ErrDocumentNotDetached";
|
|
7596
7747
|
Code2["ErrDocumentRemoved"] = "ErrDocumentRemoved";
|
|
7748
|
+
Code2["ErrDocumentSizeExceedsLimit"] = "ErrDocumentSizeExceedsLimit";
|
|
7597
7749
|
Code2["ErrInvalidObjectKey"] = "ErrInvalidObjectKey";
|
|
7598
7750
|
Code2["ErrInvalidArgument"] = "ErrInvalidArgument";
|
|
7599
7751
|
Code2["ErrNotInitialized"] = "ErrNotInitialized";
|
|
@@ -7616,76 +7768,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7616
7768
|
this.toString = () => `[code=${this.code}]: ${this.message}`;
|
|
7617
7769
|
}
|
|
7618
7770
|
}
|
|
7619
|
-
function deepcopy(object) {
|
|
7620
|
-
if (object instanceof Map) {
|
|
7621
|
-
const pairs = Array.from(object);
|
|
7622
|
-
return new Map(JSON.parse(JSON.stringify(pairs)));
|
|
7623
|
-
}
|
|
7624
|
-
return JSON.parse(JSON.stringify(object));
|
|
7625
|
-
}
|
|
7626
|
-
const isEmpty = (object) => {
|
|
7627
|
-
if (!object) {
|
|
7628
|
-
return true;
|
|
7629
|
-
}
|
|
7630
|
-
return Object.entries(object).length === 0;
|
|
7631
|
-
};
|
|
7632
|
-
const stringifyObjectValues = (attributes) => {
|
|
7633
|
-
const attrs = {};
|
|
7634
|
-
for (const [key, value] of Object.entries(attributes)) {
|
|
7635
|
-
attrs[key] = JSON.stringify(value);
|
|
7636
|
-
}
|
|
7637
|
-
return attrs;
|
|
7638
|
-
};
|
|
7639
|
-
const parseObjectValues = (attrs) => {
|
|
7640
|
-
const attributes = {};
|
|
7641
|
-
for (const [key, value] of Object.entries(attrs)) {
|
|
7642
|
-
attributes[key] = JSON.parse(value);
|
|
7643
|
-
}
|
|
7644
|
-
return attributes;
|
|
7645
|
-
};
|
|
7646
7771
|
var PresenceChangeType = /* @__PURE__ */ ((PresenceChangeType2) => {
|
|
7647
7772
|
PresenceChangeType2["Put"] = "put";
|
|
7648
7773
|
PresenceChangeType2["Clear"] = "clear";
|
|
7649
7774
|
return PresenceChangeType2;
|
|
7650
7775
|
})(PresenceChangeType || {});
|
|
7651
|
-
class Presence {
|
|
7652
|
-
constructor(changeContext, presence) {
|
|
7653
|
-
__publicField(this, "context");
|
|
7654
|
-
__publicField(this, "presence");
|
|
7655
|
-
this.context = changeContext;
|
|
7656
|
-
this.presence = presence;
|
|
7657
|
-
}
|
|
7658
|
-
/**
|
|
7659
|
-
* `set` updates the presence based on the partial presence.
|
|
7660
|
-
*/
|
|
7661
|
-
set(presence, option) {
|
|
7662
|
-
for (const key of Object.keys(presence)) {
|
|
7663
|
-
this.presence[key] = presence[key];
|
|
7664
|
-
}
|
|
7665
|
-
this.context.setPresenceChange({
|
|
7666
|
-
type: "put",
|
|
7667
|
-
presence: deepcopy(this.presence)
|
|
7668
|
-
});
|
|
7669
|
-
this.context.setReversePresence(presence, option);
|
|
7670
|
-
}
|
|
7671
|
-
/**
|
|
7672
|
-
* `get` returns the presence value of the given key.
|
|
7673
|
-
*/
|
|
7674
|
-
get(key) {
|
|
7675
|
-
return this.presence[key];
|
|
7676
|
-
}
|
|
7677
|
-
/**
|
|
7678
|
-
* `clear` clears the presence.
|
|
7679
|
-
* @internal
|
|
7680
|
-
*/
|
|
7681
|
-
clear() {
|
|
7682
|
-
this.presence = {};
|
|
7683
|
-
this.context.setPresenceChange({
|
|
7684
|
-
type: "clear"
|
|
7685
|
-
/* Clear */
|
|
7686
|
-
});
|
|
7687
|
-
}
|
|
7688
|
-
}
|
|
7689
7776
|
const InitialActorID = "000000000000000000000000";
|
|
7690
7777
|
const TimeTicketSize = 8 + 4 + 12;
|
|
7691
7778
|
class TimeTicket {
|
|
@@ -7801,10 +7888,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7801
7888
|
return 0;
|
|
7802
7889
|
}
|
|
7803
7890
|
}
|
|
7891
|
+
const InitialLamport = 0n;
|
|
7804
7892
|
const InitialDelimiter = 0;
|
|
7805
7893
|
const MaxLamport = 9223372036854775807n;
|
|
7806
7894
|
const InitialTimeTicket = new TimeTicket(
|
|
7807
|
-
|
|
7895
|
+
InitialLamport,
|
|
7808
7896
|
InitialDelimiter,
|
|
7809
7897
|
InitialActorID
|
|
7810
7898
|
);
|
|
@@ -11015,6 +11103,50 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
11015
11103
|
this.numberOfRemovedElement--;
|
|
11016
11104
|
}
|
|
11017
11105
|
}
|
|
11106
|
+
function deepcopy(object) {
|
|
11107
|
+
if (object instanceof Map) {
|
|
11108
|
+
const pairs = Array.from(object);
|
|
11109
|
+
return new Map(JSON.parse(JSON.stringify(pairs)));
|
|
11110
|
+
}
|
|
11111
|
+
return JSON.parse(JSON.stringify(object));
|
|
11112
|
+
}
|
|
11113
|
+
const isEmpty = (object) => {
|
|
11114
|
+
if (!object) {
|
|
11115
|
+
return true;
|
|
11116
|
+
}
|
|
11117
|
+
return Object.entries(object).length === 0;
|
|
11118
|
+
};
|
|
11119
|
+
const stringifyObjectValues = (attributes) => {
|
|
11120
|
+
const attrs = {};
|
|
11121
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
11122
|
+
attrs[key] = JSON.stringify(value);
|
|
11123
|
+
}
|
|
11124
|
+
return attrs;
|
|
11125
|
+
};
|
|
11126
|
+
const parseObjectValues = (attrs) => {
|
|
11127
|
+
const attributes = {};
|
|
11128
|
+
for (const [key, value] of Object.entries(attrs)) {
|
|
11129
|
+
attributes[key] = JSON.parse(value);
|
|
11130
|
+
}
|
|
11131
|
+
return attributes;
|
|
11132
|
+
};
|
|
11133
|
+
function totalDocSize(d) {
|
|
11134
|
+
if (!d) return 0;
|
|
11135
|
+
return totalDataSize(d.live) + totalDataSize(d.gc);
|
|
11136
|
+
}
|
|
11137
|
+
function totalDataSize(d) {
|
|
11138
|
+
return d.data + d.meta;
|
|
11139
|
+
}
|
|
11140
|
+
function addDataSizes(target, ...others) {
|
|
11141
|
+
for (const other of others) {
|
|
11142
|
+
target.data += other.data;
|
|
11143
|
+
target.meta += other.meta;
|
|
11144
|
+
}
|
|
11145
|
+
}
|
|
11146
|
+
function subDataSize(target, other) {
|
|
11147
|
+
target.data -= other.data;
|
|
11148
|
+
target.meta -= other.meta;
|
|
11149
|
+
}
|
|
11018
11150
|
class CRDTTextValue {
|
|
11019
11151
|
constructor(content) {
|
|
11020
11152
|
__publicField(this, "attributes");
|
|
@@ -11150,7 +11282,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
11150
11282
|
crdtTextValue.setAttr(k, v, editedAt);
|
|
11151
11283
|
}
|
|
11152
11284
|
}
|
|
11153
|
-
const [caretPos, pairs, valueChanges] = this.rgaTreeSplit.edit(
|
|
11285
|
+
const [caretPos, pairs, diff, valueChanges] = this.rgaTreeSplit.edit(
|
|
11154
11286
|
range,
|
|
11155
11287
|
editedAt,
|
|
11156
11288
|
crdtTextValue,
|
|
@@ -11168,7 +11300,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
11168
11300
|
type: "content"
|
|
11169
11301
|
/* Content */
|
|
11170
11302
|
}));
|
|
11171
|
-
return [changes, pairs, [caretPos, caretPos]];
|
|
11303
|
+
return [changes, pairs, diff, [caretPos, caretPos]];
|
|
11172
11304
|
}
|
|
11173
11305
|
/**
|
|
11174
11306
|
* `setStyle` applies the style of the given range.
|
|
@@ -11181,11 +11313,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
11181
11313
|
* @internal
|
|
11182
11314
|
*/
|
|
11183
11315
|
setStyle(range, attributes, editedAt, versionVector) {
|
|
11184
|
-
const
|
|
11185
|
-
const [,
|
|
11316
|
+
const diff = { data: 0, meta: 0 };
|
|
11317
|
+
const [, diffTo, toRight] = this.rgaTreeSplit.findNodeWithSplit(
|
|
11318
|
+
range[1],
|
|
11319
|
+
editedAt
|
|
11320
|
+
);
|
|
11321
|
+
const [, diffFrom, fromRight] = this.rgaTreeSplit.findNodeWithSplit(
|
|
11186
11322
|
range[0],
|
|
11187
11323
|
editedAt
|
|
11188
11324
|
);
|
|
11325
|
+
addDataSizes(diff, diffTo, diffFrom);
|
|
11189
11326
|
const changes = [];
|
|
11190
11327
|
const nodes = this.rgaTreeSplit.findBetween(fromRight, toRight);
|
|
11191
11328
|
const toBeStyleds = [];
|
|
@@ -11221,9 +11358,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
11221
11358
|
if (prev !== void 0) {
|
|
11222
11359
|
pairs.push({ parent: node.getValue(), child: prev });
|
|
11223
11360
|
}
|
|
11361
|
+
const curr = node.getValue().getAttrs().getNodeMapByKey().get(key);
|
|
11362
|
+
if (curr !== void 0) {
|
|
11363
|
+
addDataSizes(diff, curr.getDataSize());
|
|
11364
|
+
}
|
|
11224
11365
|
}
|
|
11225
11366
|
}
|
|
11226
|
-
return [pairs, changes];
|
|
11367
|
+
return [pairs, diff, changes];
|
|
11227
11368
|
}
|
|
11228
11369
|
/**
|
|
11229
11370
|
* `indexRangeToPosRange` returns the position range of the given index range.
|
|
@@ -11412,13 +11553,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
11412
11553
|
);
|
|
11413
11554
|
}
|
|
11414
11555
|
const text = parentObject;
|
|
11415
|
-
const [changes, pairs] = text.edit(
|
|
11556
|
+
const [changes, pairs, diff] = text.edit(
|
|
11416
11557
|
[this.fromPos, this.toPos],
|
|
11417
11558
|
this.content,
|
|
11418
11559
|
this.getExecutedAt(),
|
|
11419
11560
|
Object.fromEntries(this.attributes),
|
|
11420
11561
|
versionVector
|
|
11421
11562
|
);
|
|
11563
|
+
root.acc(diff);
|
|
11422
11564
|
for (const pair of pairs) {
|
|
11423
11565
|
root.registerGCPair(pair);
|
|
11424
11566
|
}
|
|
@@ -11515,12 +11657,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
11515
11657
|
);
|
|
11516
11658
|
}
|
|
11517
11659
|
const text = parentObject;
|
|
11518
|
-
const [pairs, changes] = text.setStyle(
|
|
11660
|
+
const [pairs, diff, changes] = text.setStyle(
|
|
11519
11661
|
[this.fromPos, this.toPos],
|
|
11520
11662
|
this.attributes ? Object.fromEntries(this.attributes) : {},
|
|
11521
11663
|
this.getExecutedAt(),
|
|
11522
11664
|
versionVector
|
|
11523
11665
|
);
|
|
11666
|
+
root.acc(diff);
|
|
11524
11667
|
for (const pair of pairs) {
|
|
11525
11668
|
root.registerGCPair(pair);
|
|
11526
11669
|
}
|
|
@@ -11674,19 +11817,23 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
11674
11817
|
* `splitText` splits the given node at the given offset.
|
|
11675
11818
|
*/
|
|
11676
11819
|
splitText(offset, absOffset) {
|
|
11820
|
+
const diff = { data: 0, meta: 0 };
|
|
11677
11821
|
if (offset === 0 || offset === this.size) {
|
|
11678
|
-
return;
|
|
11822
|
+
return [void 0, diff];
|
|
11679
11823
|
}
|
|
11680
11824
|
const leftValue = this.value.slice(0, offset);
|
|
11681
11825
|
const rightValue = this.value.slice(offset);
|
|
11682
11826
|
if (!rightValue.length) {
|
|
11683
|
-
return;
|
|
11827
|
+
return [void 0, diff];
|
|
11684
11828
|
}
|
|
11829
|
+
const prvSize = this.getDataSize();
|
|
11685
11830
|
this.value = leftValue;
|
|
11686
11831
|
const rightNode = this.cloneText(offset + absOffset);
|
|
11687
11832
|
rightNode.value = rightValue;
|
|
11688
11833
|
this.parent.insertAfterInternal(rightNode, this);
|
|
11689
|
-
|
|
11834
|
+
addDataSizes(diff, this.getDataSize(), rightNode.getDataSize());
|
|
11835
|
+
subDataSize(diff, prvSize);
|
|
11836
|
+
return [rightNode, diff];
|
|
11690
11837
|
}
|
|
11691
11838
|
/**
|
|
11692
11839
|
* `children` returns the children of the node.
|
|
@@ -11801,6 +11948,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
11801
11948
|
* `splitElement` splits the given element at the given offset.
|
|
11802
11949
|
*/
|
|
11803
11950
|
splitElement(offset, issueTimeTicket) {
|
|
11951
|
+
const diff = { data: 0, meta: 0 };
|
|
11952
|
+
const prvSize = this.getDataSize();
|
|
11804
11953
|
const clone = this.cloneElement(issueTimeTicket);
|
|
11805
11954
|
this.parent.insertAfterInternal(clone, this);
|
|
11806
11955
|
clone.updateAncestorsSize();
|
|
@@ -11819,7 +11968,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
11819
11968
|
for (const child of clone._children) {
|
|
11820
11969
|
child.parent = clone;
|
|
11821
11970
|
}
|
|
11822
|
-
|
|
11971
|
+
addDataSizes(diff, this.getDataSize(), clone.getDataSize());
|
|
11972
|
+
subDataSize(diff, prvSize);
|
|
11973
|
+
return [clone, diff];
|
|
11823
11974
|
}
|
|
11824
11975
|
/**
|
|
11825
11976
|
* `insertAfterInternal` inserts the given node after the given child.
|
|
@@ -12812,7 +12963,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
12812
12963
|
* `split` splits the given offset of this node.
|
|
12813
12964
|
*/
|
|
12814
12965
|
split(tree, offset, issueTimeTicket) {
|
|
12815
|
-
const split = this.isText ? this.splitText(offset, this.id.getOffset()) : this.splitElement(offset, issueTimeTicket);
|
|
12966
|
+
const [split, diff] = this.isText ? this.splitText(offset, this.id.getOffset()) : this.splitElement(offset, issueTimeTicket);
|
|
12816
12967
|
if (split) {
|
|
12817
12968
|
split.insPrevID = this.id;
|
|
12818
12969
|
if (this.insNextID) {
|
|
@@ -12823,7 +12974,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
12823
12974
|
this.insNextID = split.id;
|
|
12824
12975
|
tree.registerNode(split);
|
|
12825
12976
|
}
|
|
12826
|
-
return split;
|
|
12977
|
+
return [split, diff];
|
|
12827
12978
|
}
|
|
12828
12979
|
/**
|
|
12829
12980
|
* `getCreatedAt` returns the creation time of this element.
|
|
@@ -13014,15 +13165,17 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
13014
13165
|
* for concurrent insertion.
|
|
13015
13166
|
*/
|
|
13016
13167
|
findNodesAndSplitText(pos, editedAt) {
|
|
13168
|
+
let diff = { data: 0, meta: 0 };
|
|
13017
13169
|
const [parent, leftSibling] = pos.toTreeNodePair(this);
|
|
13018
13170
|
let leftNode = leftSibling;
|
|
13019
13171
|
const isLeftMost = parent === leftNode;
|
|
13020
13172
|
const realParent = leftNode.parent && !isLeftMost ? leftNode.parent : parent;
|
|
13021
13173
|
if (leftNode.isText) {
|
|
13022
|
-
leftNode.split(
|
|
13174
|
+
const [, splitedDiff] = leftNode.split(
|
|
13023
13175
|
this,
|
|
13024
13176
|
pos.getLeftSiblingID().getOffset() - leftNode.id.getOffset()
|
|
13025
13177
|
);
|
|
13178
|
+
diff = splitedDiff;
|
|
13026
13179
|
}
|
|
13027
13180
|
if (editedAt) {
|
|
13028
13181
|
const allChildren = realParent.allChildren;
|
|
@@ -13035,17 +13188,22 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
13035
13188
|
leftNode = next;
|
|
13036
13189
|
}
|
|
13037
13190
|
}
|
|
13038
|
-
return [realParent, leftNode];
|
|
13191
|
+
return [[realParent, leftNode], diff];
|
|
13039
13192
|
}
|
|
13040
13193
|
/**
|
|
13041
13194
|
* `style` applies the given attributes of the given range.
|
|
13042
13195
|
*/
|
|
13043
13196
|
style(range, attributes, editedAt, versionVector) {
|
|
13044
|
-
const
|
|
13197
|
+
const diff = { data: 0, meta: 0 };
|
|
13198
|
+
const [[fromParent, fromLeft], diffFrom] = this.findNodesAndSplitText(
|
|
13045
13199
|
range[0],
|
|
13046
13200
|
editedAt
|
|
13047
13201
|
);
|
|
13048
|
-
const [toParent, toLeft] = this.findNodesAndSplitText(
|
|
13202
|
+
const [[toParent, toLeft], diffTo] = this.findNodesAndSplitText(
|
|
13203
|
+
range[1],
|
|
13204
|
+
editedAt
|
|
13205
|
+
);
|
|
13206
|
+
addDataSizes(diff, diffTo, diffFrom);
|
|
13049
13207
|
const changes = [];
|
|
13050
13208
|
const attrs = attributes ? parseObjectValues(attributes) : {};
|
|
13051
13209
|
const pairs = [];
|
|
@@ -13054,7 +13212,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
13054
13212
|
fromLeft,
|
|
13055
13213
|
toParent,
|
|
13056
13214
|
toLeft,
|
|
13057
|
-
([node]) => {
|
|
13215
|
+
([node, tokenType]) => {
|
|
13216
|
+
var _a2;
|
|
13058
13217
|
const actorID = node.getCreatedAt().getActorID();
|
|
13059
13218
|
let clientLamportAtChange = MaxLamport;
|
|
13060
13219
|
if (versionVector != void 0) {
|
|
@@ -13090,20 +13249,31 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
13090
13249
|
pairs.push({ parent: node, child: prev });
|
|
13091
13250
|
}
|
|
13092
13251
|
}
|
|
13252
|
+
for (const [key] of Object.entries(attrs)) {
|
|
13253
|
+
const curr = (_a2 = node.attrs) == null ? void 0 : _a2.getNodeMapByKey().get(key);
|
|
13254
|
+
if (curr !== void 0 && tokenType !== TokenType.End) {
|
|
13255
|
+
addDataSizes(diff, curr.getDataSize());
|
|
13256
|
+
}
|
|
13257
|
+
}
|
|
13093
13258
|
}
|
|
13094
13259
|
}
|
|
13095
13260
|
);
|
|
13096
|
-
return [pairs, changes];
|
|
13261
|
+
return [pairs, changes, diff];
|
|
13097
13262
|
}
|
|
13098
13263
|
/**
|
|
13099
13264
|
* `removeStyle` removes the given attributes of the given range.
|
|
13100
13265
|
*/
|
|
13101
13266
|
removeStyle(range, attributesToRemove, editedAt, versionVector) {
|
|
13102
|
-
const
|
|
13267
|
+
const diff = { data: 0, meta: 0 };
|
|
13268
|
+
const [[fromParent, fromLeft], diffFrom] = this.findNodesAndSplitText(
|
|
13103
13269
|
range[0],
|
|
13104
13270
|
editedAt
|
|
13105
13271
|
);
|
|
13106
|
-
const [toParent, toLeft] = this.findNodesAndSplitText(
|
|
13272
|
+
const [[toParent, toLeft], diffTo] = this.findNodesAndSplitText(
|
|
13273
|
+
range[1],
|
|
13274
|
+
editedAt
|
|
13275
|
+
);
|
|
13276
|
+
addDataSizes(diff, diffTo, diffFrom);
|
|
13107
13277
|
const changes = [];
|
|
13108
13278
|
const pairs = [];
|
|
13109
13279
|
this.traverseInPosRange(
|
|
@@ -13141,18 +13311,23 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
13141
13311
|
}
|
|
13142
13312
|
}
|
|
13143
13313
|
);
|
|
13144
|
-
return [pairs, changes];
|
|
13314
|
+
return [pairs, changes, diff];
|
|
13145
13315
|
}
|
|
13146
13316
|
/**
|
|
13147
13317
|
* `edit` edits the tree with the given range and content.
|
|
13148
13318
|
* If the content is undefined, the range will be removed.
|
|
13149
13319
|
*/
|
|
13150
13320
|
edit(range, contents, splitLevel, editedAt, issueTimeTicket, versionVector) {
|
|
13151
|
-
const
|
|
13321
|
+
const diff = { data: 0, meta: 0 };
|
|
13322
|
+
const [[fromParent, fromLeft], diffFrom] = this.findNodesAndSplitText(
|
|
13152
13323
|
range[0],
|
|
13153
13324
|
editedAt
|
|
13154
13325
|
);
|
|
13155
|
-
const [toParent, toLeft] = this.findNodesAndSplitText(
|
|
13326
|
+
const [[toParent, toLeft], diffTo] = this.findNodesAndSplitText(
|
|
13327
|
+
range[1],
|
|
13328
|
+
editedAt
|
|
13329
|
+
);
|
|
13330
|
+
addDataSizes(diff, diffTo, diffFrom);
|
|
13156
13331
|
const fromIdx = this.toIndex(fromParent, fromLeft);
|
|
13157
13332
|
const fromPath = this.toPath(fromParent, fromLeft);
|
|
13158
13333
|
const nodesToBeRemoved = [];
|
|
@@ -13231,6 +13406,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
13231
13406
|
if (fromParent.isRemoved) {
|
|
13232
13407
|
node.remove(editedAt);
|
|
13233
13408
|
pairs.push({ parent: this, child: node });
|
|
13409
|
+
} else {
|
|
13410
|
+
addDataSizes(diff, node.getDataSize());
|
|
13234
13411
|
}
|
|
13235
13412
|
this.nodeMapByID.put(node.id, node);
|
|
13236
13413
|
});
|
|
@@ -13255,7 +13432,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
13255
13432
|
}
|
|
13256
13433
|
}
|
|
13257
13434
|
}
|
|
13258
|
-
return [changes, pairs];
|
|
13435
|
+
return [changes, pairs, diff];
|
|
13259
13436
|
}
|
|
13260
13437
|
/**
|
|
13261
13438
|
* `editT` edits the given range with the given value.
|
|
@@ -13534,16 +13711,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
13534
13711
|
* `posRangeToPathRange` converts the given position range to the path range.
|
|
13535
13712
|
*/
|
|
13536
13713
|
posRangeToPathRange(range) {
|
|
13537
|
-
const [fromParent, fromLeft] = this.findNodesAndSplitText(range[0]);
|
|
13538
|
-
const [toParent, toLeft] = this.findNodesAndSplitText(range[1]);
|
|
13714
|
+
const [[fromParent, fromLeft]] = this.findNodesAndSplitText(range[0]);
|
|
13715
|
+
const [[toParent, toLeft]] = this.findNodesAndSplitText(range[1]);
|
|
13539
13716
|
return [this.toPath(fromParent, fromLeft), this.toPath(toParent, toLeft)];
|
|
13540
13717
|
}
|
|
13541
13718
|
/**
|
|
13542
13719
|
* `posRangeToIndexRange` converts the given position range to the path range.
|
|
13543
13720
|
*/
|
|
13544
13721
|
posRangeToIndexRange(range) {
|
|
13545
|
-
const [fromParent, fromLeft] = this.findNodesAndSplitText(range[0]);
|
|
13546
|
-
const [toParent, toLeft] = this.findNodesAndSplitText(range[1]);
|
|
13722
|
+
const [[fromParent, fromLeft]] = this.findNodesAndSplitText(range[0]);
|
|
13723
|
+
const [[toParent, toLeft]] = this.findNodesAndSplitText(range[1]);
|
|
13547
13724
|
return [this.toIndex(fromParent, fromLeft), this.toIndex(toParent, toLeft)];
|
|
13548
13725
|
}
|
|
13549
13726
|
/**
|
|
@@ -13738,7 +13915,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
13738
13915
|
}
|
|
13739
13916
|
const editedAt = this.getExecutedAt();
|
|
13740
13917
|
const tree = parentObject;
|
|
13741
|
-
const [changes, pairs] = tree.edit(
|
|
13918
|
+
const [changes, pairs, diff] = tree.edit(
|
|
13742
13919
|
[this.fromPos, this.toPos],
|
|
13743
13920
|
(_a2 = this.contents) == null ? void 0 : _a2.map((content) => content.deepcopy()),
|
|
13744
13921
|
this.splitLevel,
|
|
@@ -13764,6 +13941,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
13764
13941
|
})(),
|
|
13765
13942
|
versionVector
|
|
13766
13943
|
);
|
|
13944
|
+
root.acc(diff);
|
|
13767
13945
|
for (const pair of pairs) {
|
|
13768
13946
|
root.registerGCPair(pair);
|
|
13769
13947
|
}
|
|
@@ -13930,12 +14108,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
13930
14108
|
__publicField(this, "clientSeq");
|
|
13931
14109
|
// `serverSeq` is optional and only present for changes stored on the server.
|
|
13932
14110
|
__publicField(this, "serverSeq");
|
|
13933
|
-
// `
|
|
13934
|
-
// This is used to determine the order of changes in logical time.
|
|
13935
|
-
__publicField(this, "lamport");
|
|
14111
|
+
// `actor` is the creator of this change.
|
|
13936
14112
|
__publicField(this, "actor");
|
|
14113
|
+
// `lamport` is the lamport clock of this change. This is used to determine
|
|
14114
|
+
// the order of changes in logical time. It is optional and only present
|
|
14115
|
+
// if the change has operations.
|
|
14116
|
+
__publicField(this, "lamport");
|
|
13937
14117
|
// `versionVector` is the vector clock of this change. This is used to
|
|
13938
|
-
// determine the relationship is causal or not between changes.
|
|
14118
|
+
// determine the relationship is causal or not between changes. It is optional
|
|
14119
|
+
// and only present if the change has operations.
|
|
13939
14120
|
__publicField(this, "versionVector");
|
|
13940
14121
|
this.clientSeq = clientSeq;
|
|
13941
14122
|
this.serverSeq = serverSeq;
|
|
@@ -13943,6 +14124,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
13943
14124
|
this.versionVector = vector;
|
|
13944
14125
|
this.actor = actor;
|
|
13945
14126
|
}
|
|
14127
|
+
/**
|
|
14128
|
+
* `hasClocks` returns true if this ID has logical clocks.
|
|
14129
|
+
*/
|
|
14130
|
+
hasClocks() {
|
|
14131
|
+
return this.versionVector.size() > 0 && this.lamport != InitialLamport;
|
|
14132
|
+
}
|
|
13946
14133
|
/**
|
|
13947
14134
|
* `of` creates a new instance of ChangeID.
|
|
13948
14135
|
*/
|
|
@@ -13952,7 +14139,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
13952
14139
|
/**
|
|
13953
14140
|
* `next` creates a next ID of this ID.
|
|
13954
14141
|
*/
|
|
13955
|
-
next() {
|
|
14142
|
+
next(excludeClocks = false) {
|
|
14143
|
+
if (excludeClocks) {
|
|
14144
|
+
return new ChangeID(
|
|
14145
|
+
this.clientSeq + 1,
|
|
14146
|
+
this.lamport,
|
|
14147
|
+
this.actor,
|
|
14148
|
+
InitialVersionVector,
|
|
14149
|
+
InitialLamport
|
|
14150
|
+
);
|
|
14151
|
+
}
|
|
13956
14152
|
const vector = this.versionVector.deepcopy();
|
|
13957
14153
|
vector.set(this.actor, this.lamport + 1n);
|
|
13958
14154
|
return new ChangeID(
|
|
@@ -13963,9 +14159,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
13963
14159
|
);
|
|
13964
14160
|
}
|
|
13965
14161
|
/**
|
|
13966
|
-
* `syncClocks` syncs logical clocks with the given ID.
|
|
14162
|
+
* `syncClocks` syncs logical clocks with the given ID. If the given ID
|
|
14163
|
+
* doesn't have logical clocks, this ID is returned.
|
|
13967
14164
|
*/
|
|
13968
14165
|
syncClocks(other) {
|
|
14166
|
+
if (!other.hasClocks()) {
|
|
14167
|
+
return this;
|
|
14168
|
+
}
|
|
13969
14169
|
const lamport = other.lamport > this.lamport ? other.lamport + 1n : this.lamport + 1n;
|
|
13970
14170
|
const maxVersionVector = this.versionVector.max(other.versionVector);
|
|
13971
14171
|
const newID = new ChangeID(
|
|
@@ -14006,6 +14206,18 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
14006
14206
|
this.serverSeq
|
|
14007
14207
|
);
|
|
14008
14208
|
}
|
|
14209
|
+
/**
|
|
14210
|
+
* `setLamport` sets the given lamport clock.
|
|
14211
|
+
*/
|
|
14212
|
+
setLamport(lamport) {
|
|
14213
|
+
return new ChangeID(
|
|
14214
|
+
this.clientSeq,
|
|
14215
|
+
lamport,
|
|
14216
|
+
this.actor,
|
|
14217
|
+
this.versionVector,
|
|
14218
|
+
this.serverSeq
|
|
14219
|
+
);
|
|
14220
|
+
}
|
|
14009
14221
|
/**
|
|
14010
14222
|
* `setVersionVector` sets the given version vector.
|
|
14011
14223
|
*/
|
|
@@ -14784,8 +14996,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
14784
14996
|
* @returns `[RGATreeSplitPos, Array<GCPair>, Array<Change>]`
|
|
14785
14997
|
*/
|
|
14786
14998
|
edit(range, editedAt, value, versionVector) {
|
|
14787
|
-
const
|
|
14788
|
-
const [
|
|
14999
|
+
const diff = { data: 0, meta: 0 };
|
|
15000
|
+
const [toLeft, diffTo, toRight] = this.findNodeWithSplit(
|
|
15001
|
+
range[1],
|
|
15002
|
+
editedAt
|
|
15003
|
+
);
|
|
15004
|
+
const [fromLeft, diffFrom, fromRight] = this.findNodeWithSplit(
|
|
15005
|
+
range[0],
|
|
15006
|
+
editedAt
|
|
15007
|
+
);
|
|
15008
|
+
addDataSizes(diff, diffTo, diffFrom);
|
|
14789
15009
|
const nodesToDelete = this.findBetween(fromRight, toRight);
|
|
14790
15010
|
const [changes, removedNodes] = this.deleteNodes(
|
|
14791
15011
|
nodesToDelete,
|
|
@@ -14800,6 +15020,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
14800
15020
|
fromLeft,
|
|
14801
15021
|
RGATreeSplitNode.create(RGATreeSplitNodeID.of(editedAt, 0), value)
|
|
14802
15022
|
);
|
|
15023
|
+
addDataSizes(diff, inserted.getDataSize());
|
|
14803
15024
|
if (changes.length && changes[changes.length - 1].from === idx) {
|
|
14804
15025
|
changes[changes.length - 1].value = value;
|
|
14805
15026
|
} else {
|
|
@@ -14819,7 +15040,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
14819
15040
|
for (const [, removedNode] of removedNodes) {
|
|
14820
15041
|
pairs.push({ parent: this, child: removedNode });
|
|
14821
15042
|
}
|
|
14822
|
-
return [caretPos, pairs, changes];
|
|
15043
|
+
return [caretPos, pairs, diff, changes];
|
|
14823
15044
|
}
|
|
14824
15045
|
/**
|
|
14825
15046
|
* `indexToPos` finds RGATreeSplitPos of given offset.
|
|
@@ -14958,11 +15179,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
14958
15179
|
const absoluteID = pos.getAbsoluteID();
|
|
14959
15180
|
let node = this.findFloorNodePreferToLeft(absoluteID);
|
|
14960
15181
|
const relativeOffset = absoluteID.getOffset() - node.getID().getOffset();
|
|
14961
|
-
this.splitNode(node, relativeOffset);
|
|
15182
|
+
const [, diff] = this.splitNode(node, relativeOffset);
|
|
14962
15183
|
while (node.hasNext() && node.getNext().getCreatedAt().after(editedAt)) {
|
|
14963
15184
|
node = node.getNext();
|
|
14964
15185
|
}
|
|
14965
|
-
return [node, node.getNext()];
|
|
15186
|
+
return [node, diff, node.getNext()];
|
|
14966
15187
|
}
|
|
14967
15188
|
findFloorNodePreferToLeft(id) {
|
|
14968
15189
|
let node = this.findFloorNode(id);
|
|
@@ -15003,6 +15224,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
15003
15224
|
return nodes;
|
|
15004
15225
|
}
|
|
15005
15226
|
splitNode(node, offset) {
|
|
15227
|
+
const diff = { data: 0, meta: 0 };
|
|
15006
15228
|
if (offset > node.getContentLength()) {
|
|
15007
15229
|
throw new YorkieError(
|
|
15008
15230
|
Code.ErrInvalidArgument,
|
|
@@ -15010,10 +15232,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
15010
15232
|
);
|
|
15011
15233
|
}
|
|
15012
15234
|
if (offset === 0) {
|
|
15013
|
-
return node;
|
|
15235
|
+
return [node, diff];
|
|
15014
15236
|
} else if (offset === node.getContentLength()) {
|
|
15015
|
-
return node.getNext();
|
|
15237
|
+
return [node.getNext(), diff];
|
|
15016
15238
|
}
|
|
15239
|
+
const prvSize = node.getDataSize();
|
|
15017
15240
|
const splitNode = node.split(offset);
|
|
15018
15241
|
this.treeByIndex.updateWeight(splitNode);
|
|
15019
15242
|
this.insertAfter(node, splitNode);
|
|
@@ -15022,7 +15245,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
15022
15245
|
insNext.setInsPrev(splitNode);
|
|
15023
15246
|
}
|
|
15024
15247
|
splitNode.setInsPrev(node);
|
|
15025
|
-
|
|
15248
|
+
addDataSizes(diff, node.getDataSize(), splitNode.getDataSize());
|
|
15249
|
+
subDataSize(diff, prvSize);
|
|
15250
|
+
return [splitNode, diff];
|
|
15026
15251
|
}
|
|
15027
15252
|
deleteNodes(candidates, editedAt, versionVector) {
|
|
15028
15253
|
if (!candidates.length) {
|
|
@@ -15491,10 +15716,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
15491
15716
|
const tree = parentObject;
|
|
15492
15717
|
let changes;
|
|
15493
15718
|
let pairs;
|
|
15719
|
+
let diff = { data: 0, meta: 0 };
|
|
15494
15720
|
if (this.attributes.size) {
|
|
15495
15721
|
const attributes = {};
|
|
15496
15722
|
[...this.attributes].forEach(([key, value]) => attributes[key] = value);
|
|
15497
|
-
[pairs, changes] = tree.style(
|
|
15723
|
+
[pairs, changes, diff] = tree.style(
|
|
15498
15724
|
[this.fromPos, this.toPos],
|
|
15499
15725
|
attributes,
|
|
15500
15726
|
this.getExecutedAt(),
|
|
@@ -15502,13 +15728,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
15502
15728
|
);
|
|
15503
15729
|
} else {
|
|
15504
15730
|
const attributesToRemove = this.attributesToRemove;
|
|
15505
|
-
[pairs, changes] = tree.removeStyle(
|
|
15731
|
+
[pairs, changes, diff] = tree.removeStyle(
|
|
15506
15732
|
[this.fromPos, this.toPos],
|
|
15507
15733
|
attributesToRemove,
|
|
15508
15734
|
this.getExecutedAt(),
|
|
15509
15735
|
versionVector
|
|
15510
15736
|
);
|
|
15511
15737
|
}
|
|
15738
|
+
root.acc(diff);
|
|
15512
15739
|
for (const pair of pairs) {
|
|
15513
15740
|
root.registerGCPair(pair);
|
|
15514
15741
|
}
|
|
@@ -16961,8 +17188,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
16961
17188
|
};
|
|
16962
17189
|
}
|
|
16963
17190
|
class ChangeContext {
|
|
16964
|
-
constructor(
|
|
16965
|
-
__publicField(this, "
|
|
17191
|
+
constructor(prevID, root, presence, message) {
|
|
17192
|
+
__publicField(this, "prevID");
|
|
17193
|
+
__publicField(this, "nextID");
|
|
16966
17194
|
__publicField(this, "delimiter");
|
|
16967
17195
|
__publicField(this, "message");
|
|
16968
17196
|
__publicField(this, "root");
|
|
@@ -16978,7 +17206,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
16978
17206
|
* presence changes.
|
|
16979
17207
|
*/
|
|
16980
17208
|
__publicField(this, "reversePresenceKeys");
|
|
16981
|
-
this.
|
|
17209
|
+
this.prevID = prevID;
|
|
17210
|
+
this.nextID = prevID.next();
|
|
16982
17211
|
this.delimiter = InitialDelimiter;
|
|
16983
17212
|
this.root = root;
|
|
16984
17213
|
this.operations = [];
|
|
@@ -16990,8 +17219,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
16990
17219
|
/**
|
|
16991
17220
|
* `create` creates a new instance of ChangeContext.
|
|
16992
17221
|
*/
|
|
16993
|
-
static create(
|
|
16994
|
-
return new ChangeContext(
|
|
17222
|
+
static create(prevID, root, presence, message) {
|
|
17223
|
+
return new ChangeContext(prevID, root, presence, message);
|
|
16995
17224
|
}
|
|
16996
17225
|
/**
|
|
16997
17226
|
* `push` pushes the given operation to this context.
|
|
@@ -17018,16 +17247,34 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17018
17247
|
this.root.registerGCPair(pair);
|
|
17019
17248
|
}
|
|
17020
17249
|
/**
|
|
17021
|
-
* `
|
|
17250
|
+
* `getNextID` returns the next ID of this context. It will be set to the
|
|
17251
|
+
* document for the next change.returns the next ID of this context.
|
|
17022
17252
|
*/
|
|
17023
|
-
|
|
17253
|
+
getNextID() {
|
|
17254
|
+
if (this.isPresenceOnlyChange()) {
|
|
17255
|
+
return this.prevID.next(true).setLamport(this.prevID.getLamport()).setVersionVector(this.prevID.getVersionVector());
|
|
17256
|
+
}
|
|
17257
|
+
return this.nextID;
|
|
17258
|
+
}
|
|
17259
|
+
/**
|
|
17260
|
+
* `toChange` creates a new instance of Change in this context.
|
|
17261
|
+
*/
|
|
17262
|
+
toChange() {
|
|
17263
|
+
const id = this.isPresenceOnlyChange() ? this.prevID.next(true) : this.nextID;
|
|
17024
17264
|
return Change.create({
|
|
17025
|
-
id
|
|
17265
|
+
id,
|
|
17026
17266
|
operations: this.operations,
|
|
17027
17267
|
presenceChange: this.presenceChange,
|
|
17028
17268
|
message: this.message
|
|
17029
17269
|
});
|
|
17030
17270
|
}
|
|
17271
|
+
/**
|
|
17272
|
+
* `isPresenceOnlyChange` returns whether this context is only for presence
|
|
17273
|
+
* change or not.
|
|
17274
|
+
*/
|
|
17275
|
+
isPresenceOnlyChange() {
|
|
17276
|
+
return this.operations.length === 0;
|
|
17277
|
+
}
|
|
17031
17278
|
/**
|
|
17032
17279
|
* `hasChange` returns whether this context has change or not.
|
|
17033
17280
|
*/
|
|
@@ -17068,13 +17315,19 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17068
17315
|
*/
|
|
17069
17316
|
issueTimeTicket() {
|
|
17070
17317
|
this.delimiter += 1;
|
|
17071
|
-
return this.
|
|
17318
|
+
return this.nextID.createTimeTicket(this.delimiter);
|
|
17072
17319
|
}
|
|
17073
17320
|
/**
|
|
17074
17321
|
* `getLastTimeTicket` returns the last time ticket issued in this context.
|
|
17075
17322
|
*/
|
|
17076
17323
|
getLastTimeTicket() {
|
|
17077
|
-
return this.
|
|
17324
|
+
return this.nextID.createTimeTicket(this.delimiter);
|
|
17325
|
+
}
|
|
17326
|
+
/**
|
|
17327
|
+
* `acc` accumulates the given DataSize to Live size of the root.
|
|
17328
|
+
*/
|
|
17329
|
+
acc(diff) {
|
|
17330
|
+
this.root.acc(diff);
|
|
17078
17331
|
}
|
|
17079
17332
|
}
|
|
17080
17333
|
class CRDTRoot {
|
|
@@ -17099,10 +17352,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17099
17352
|
* element itself and its parent.
|
|
17100
17353
|
*/
|
|
17101
17354
|
__publicField(this, "gcPairMap");
|
|
17355
|
+
/**
|
|
17356
|
+
* `docSize` is a structure that represents the size of the document.
|
|
17357
|
+
*/
|
|
17358
|
+
__publicField(this, "docSize");
|
|
17102
17359
|
this.rootObject = rootObject;
|
|
17103
17360
|
this.elementPairMapByCreatedAt = /* @__PURE__ */ new Map();
|
|
17104
17361
|
this.gcElementSetByCreatedAt = /* @__PURE__ */ new Set();
|
|
17105
17362
|
this.gcPairMap = /* @__PURE__ */ new Map();
|
|
17363
|
+
this.docSize = { live: { data: 0, meta: 0 }, gc: { data: 0, meta: 0 } };
|
|
17106
17364
|
this.registerElement(rootObject, void 0);
|
|
17107
17365
|
rootObject.getDescendants((elem) => {
|
|
17108
17366
|
if (elem.getRemovedAt()) {
|
|
@@ -17179,6 +17437,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17179
17437
|
parent,
|
|
17180
17438
|
element
|
|
17181
17439
|
});
|
|
17440
|
+
addDataSizes(this.docSize.live, element.getDataSize());
|
|
17182
17441
|
if (element instanceof CRDTContainer) {
|
|
17183
17442
|
element.getDescendants((elem, parent2) => {
|
|
17184
17443
|
this.registerElement(elem, parent2);
|
|
@@ -17193,6 +17452,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17193
17452
|
let count = 0;
|
|
17194
17453
|
const deregisterElementInternal = (elem) => {
|
|
17195
17454
|
const createdAt = elem.getCreatedAt().toIDString();
|
|
17455
|
+
subDataSize(this.docSize.gc, elem.getDataSize());
|
|
17196
17456
|
this.elementPairMapByCreatedAt.delete(createdAt);
|
|
17197
17457
|
this.gcElementSetByCreatedAt.delete(createdAt);
|
|
17198
17458
|
count++;
|
|
@@ -17210,6 +17470,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17210
17470
|
* `registerRemovedElement` registers the given element to the hash set.
|
|
17211
17471
|
*/
|
|
17212
17472
|
registerRemovedElement(element) {
|
|
17473
|
+
addDataSizes(this.docSize.gc, element.getDataSize());
|
|
17474
|
+
subDataSize(this.docSize.live, element.getDataSize());
|
|
17475
|
+
this.docSize.live.meta += TimeTicketSize;
|
|
17213
17476
|
this.gcElementSetByCreatedAt.add(element.getCreatedAt().toIDString());
|
|
17214
17477
|
}
|
|
17215
17478
|
/**
|
|
@@ -17222,6 +17485,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17222
17485
|
return;
|
|
17223
17486
|
}
|
|
17224
17487
|
this.gcPairMap.set(pair.child.toIDString(), pair);
|
|
17488
|
+
const size = this.gcPairMap.get(pair.child.toIDString()).child.getDataSize();
|
|
17489
|
+
addDataSizes(this.docSize.gc, size);
|
|
17490
|
+
subDataSize(this.docSize.live, size);
|
|
17491
|
+
if (!(pair.child instanceof RHTNode)) {
|
|
17492
|
+
this.docSize.live.meta += TimeTicketSize;
|
|
17493
|
+
}
|
|
17225
17494
|
}
|
|
17226
17495
|
/**
|
|
17227
17496
|
* `getElementMapSize` returns the size of element map.
|
|
@@ -17262,22 +17531,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17262
17531
|
* `getDocSize` returns the size of the document.
|
|
17263
17532
|
*/
|
|
17264
17533
|
getDocSize() {
|
|
17265
|
-
|
|
17266
|
-
for (const [createdAt, value] of this.elementPairMapByCreatedAt) {
|
|
17267
|
-
if (this.gcElementSetByCreatedAt.has(createdAt)) {
|
|
17268
|
-
docSize.gc.data += value.element.getDataSize().data;
|
|
17269
|
-
docSize.gc.meta += value.element.getDataSize().meta;
|
|
17270
|
-
} else {
|
|
17271
|
-
docSize.live.data += value.element.getDataSize().data;
|
|
17272
|
-
docSize.live.meta += value.element.getDataSize().meta;
|
|
17273
|
-
}
|
|
17274
|
-
}
|
|
17275
|
-
for (const pair of this.gcPairMap.values()) {
|
|
17276
|
-
const size = pair.child.getDataSize();
|
|
17277
|
-
docSize.gc.data += size.data;
|
|
17278
|
-
docSize.gc.meta += size.meta;
|
|
17279
|
-
}
|
|
17280
|
-
return docSize;
|
|
17534
|
+
return this.docSize;
|
|
17281
17535
|
}
|
|
17282
17536
|
/**
|
|
17283
17537
|
* `deepcopy` copies itself deeply.
|
|
@@ -17331,6 +17585,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17331
17585
|
gcElements: this.getGarbageElementSetSize()
|
|
17332
17586
|
};
|
|
17333
17587
|
}
|
|
17588
|
+
/**
|
|
17589
|
+
* `acc` accumulates the given DataSize to Live.
|
|
17590
|
+
*/
|
|
17591
|
+
acc(diff) {
|
|
17592
|
+
addDataSizes(this.docSize.live, diff);
|
|
17593
|
+
}
|
|
17334
17594
|
}
|
|
17335
17595
|
function createJSONObject(context, target) {
|
|
17336
17596
|
const objectProxy = new ObjectProxy(context);
|
|
@@ -17948,12 +18208,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17948
18208
|
}
|
|
17949
18209
|
const attrs = attributes ? stringifyObjectValues(attributes) : void 0;
|
|
17950
18210
|
const ticket = this.context.issueTimeTicket();
|
|
17951
|
-
const [, pairs, rangeAfterEdit] = this.text.edit(
|
|
18211
|
+
const [, pairs, diff, rangeAfterEdit] = this.text.edit(
|
|
17952
18212
|
range,
|
|
17953
18213
|
content,
|
|
17954
18214
|
ticket,
|
|
17955
18215
|
attrs
|
|
17956
18216
|
);
|
|
18217
|
+
this.context.acc(diff);
|
|
17957
18218
|
for (const pair of pairs) {
|
|
17958
18219
|
this.context.registerGCPair(pair);
|
|
17959
18220
|
}
|
|
@@ -18007,7 +18268,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
18007
18268
|
}
|
|
18008
18269
|
const attrs = stringifyObjectValues(attributes);
|
|
18009
18270
|
const ticket = this.context.issueTimeTicket();
|
|
18010
|
-
const [pairs] = this.text.setStyle(range, attrs, ticket);
|
|
18271
|
+
const [pairs, diff] = this.text.setStyle(range, attrs, ticket);
|
|
18272
|
+
this.context.acc(diff);
|
|
18011
18273
|
for (const pair of pairs) {
|
|
18012
18274
|
this.context.registerGCPair(pair);
|
|
18013
18275
|
}
|
|
@@ -18550,7 +18812,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
18550
18812
|
const [fromPos, toPos] = this.tree.pathToPosRange(path);
|
|
18551
18813
|
const ticket = this.context.issueTimeTicket();
|
|
18552
18814
|
const attrs = attributes ? stringifyObjectValues(attributes) : void 0;
|
|
18553
|
-
const [pairs] = this.tree.style([fromPos, toPos], attrs, ticket);
|
|
18815
|
+
const [pairs, , diff] = this.tree.style([fromPos, toPos], attrs, ticket);
|
|
18816
|
+
this.context.acc(diff);
|
|
18554
18817
|
for (const pair of pairs) {
|
|
18555
18818
|
this.context.registerGCPair(pair);
|
|
18556
18819
|
}
|
|
@@ -18584,7 +18847,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
18584
18847
|
const toPos = this.tree.findPos(toIdx);
|
|
18585
18848
|
const ticket = this.context.issueTimeTicket();
|
|
18586
18849
|
const attrs = attributes ? stringifyObjectValues(attributes) : void 0;
|
|
18587
|
-
const [pairs] = this.tree.style([fromPos, toPos], attrs, ticket);
|
|
18850
|
+
const [pairs, , diff] = this.tree.style([fromPos, toPos], attrs, ticket);
|
|
18851
|
+
this.context.acc(diff);
|
|
18588
18852
|
for (const pair of pairs) {
|
|
18589
18853
|
this.context.registerGCPair(pair);
|
|
18590
18854
|
}
|
|
@@ -18617,11 +18881,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
18617
18881
|
const fromPos = this.tree.findPos(fromIdx);
|
|
18618
18882
|
const toPos = this.tree.findPos(toIdx);
|
|
18619
18883
|
const ticket = this.context.issueTimeTicket();
|
|
18620
|
-
const [pairs] = this.tree.removeStyle(
|
|
18884
|
+
const [pairs, , diff] = this.tree.removeStyle(
|
|
18621
18885
|
[fromPos, toPos],
|
|
18622
18886
|
attributesToRemove,
|
|
18623
18887
|
ticket
|
|
18624
18888
|
);
|
|
18889
|
+
this.context.acc(diff);
|
|
18625
18890
|
for (const pair of pairs) {
|
|
18626
18891
|
this.context.registerGCPair(pair);
|
|
18627
18892
|
}
|
|
@@ -18664,13 +18929,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
18664
18929
|
} else {
|
|
18665
18930
|
crdtNodes = contents.map((content) => content && createCRDTTreeNode(this.context, content)).filter((a) => a);
|
|
18666
18931
|
}
|
|
18667
|
-
const [, pairs] = this.tree.edit(
|
|
18932
|
+
const [, pairs, diff] = this.tree.edit(
|
|
18668
18933
|
[fromPos, toPos],
|
|
18669
18934
|
crdtNodes.length ? crdtNodes.map((crdtNode) => crdtNode == null ? void 0 : crdtNode.deepcopy()) : void 0,
|
|
18670
18935
|
splitLevel,
|
|
18671
18936
|
ticket,
|
|
18672
18937
|
() => this.context.issueTimeTicket()
|
|
18673
18938
|
);
|
|
18939
|
+
this.context.acc(diff);
|
|
18674
18940
|
for (const pair of pairs) {
|
|
18675
18941
|
this.context.registerGCPair(pair);
|
|
18676
18942
|
}
|
|
@@ -19003,6 +19269,43 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
19003
19269
|
}
|
|
19004
19270
|
return element;
|
|
19005
19271
|
}
|
|
19272
|
+
class Presence {
|
|
19273
|
+
constructor(changeContext, presence) {
|
|
19274
|
+
__publicField(this, "context");
|
|
19275
|
+
__publicField(this, "presence");
|
|
19276
|
+
this.context = changeContext;
|
|
19277
|
+
this.presence = presence;
|
|
19278
|
+
}
|
|
19279
|
+
/**
|
|
19280
|
+
* `set` updates the presence based on the partial presence.
|
|
19281
|
+
*/
|
|
19282
|
+
set(presence, option) {
|
|
19283
|
+
for (const key of Object.keys(presence)) {
|
|
19284
|
+
this.presence[key] = presence[key];
|
|
19285
|
+
}
|
|
19286
|
+
this.context.setPresenceChange({
|
|
19287
|
+
type: PresenceChangeType.Put,
|
|
19288
|
+
presence: deepcopy(this.presence)
|
|
19289
|
+
});
|
|
19290
|
+
this.context.setReversePresence(presence, option);
|
|
19291
|
+
}
|
|
19292
|
+
/**
|
|
19293
|
+
* `get` returns the presence value of the given key.
|
|
19294
|
+
*/
|
|
19295
|
+
get(key) {
|
|
19296
|
+
return this.presence[key];
|
|
19297
|
+
}
|
|
19298
|
+
/**
|
|
19299
|
+
* `clear` clears the presence.
|
|
19300
|
+
* @internal
|
|
19301
|
+
*/
|
|
19302
|
+
clear() {
|
|
19303
|
+
this.presence = {};
|
|
19304
|
+
this.context.setPresenceChange({
|
|
19305
|
+
type: PresenceChangeType.Clear
|
|
19306
|
+
});
|
|
19307
|
+
}
|
|
19308
|
+
}
|
|
19006
19309
|
const MaxUndoRedoStackDepth = 50;
|
|
19007
19310
|
class History {
|
|
19008
19311
|
constructor() {
|
|
@@ -19208,6 +19511,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
19208
19511
|
__publicField(this, "changeID");
|
|
19209
19512
|
__publicField(this, "checkpoint");
|
|
19210
19513
|
__publicField(this, "localChanges");
|
|
19514
|
+
__publicField(this, "maxSizeLimit");
|
|
19211
19515
|
__publicField(this, "root");
|
|
19212
19516
|
__publicField(this, "clone");
|
|
19213
19517
|
__publicField(this, "eventStream");
|
|
@@ -19240,6 +19544,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
19240
19544
|
this.changeID = InitialChangeID;
|
|
19241
19545
|
this.checkpoint = InitialCheckpoint;
|
|
19242
19546
|
this.localChanges = [];
|
|
19547
|
+
this.maxSizeLimit = 0;
|
|
19243
19548
|
this.eventStream = createObservable((observer) => {
|
|
19244
19549
|
this.eventStreamObserver = observer;
|
|
19245
19550
|
});
|
|
@@ -19259,13 +19564,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
19259
19564
|
* `update` executes the given updater to update this document.
|
|
19260
19565
|
*/
|
|
19261
19566
|
update(updater, message) {
|
|
19567
|
+
var _a2;
|
|
19262
19568
|
if (this.getStatus() === "removed") {
|
|
19263
19569
|
throw new YorkieError(Code.ErrDocumentRemoved, `${this.key} is removed`);
|
|
19264
19570
|
}
|
|
19265
19571
|
this.ensureClone();
|
|
19266
19572
|
const actorID = this.changeID.getActorID();
|
|
19267
19573
|
const context = ChangeContext.create(
|
|
19268
|
-
this.changeID
|
|
19574
|
+
this.changeID,
|
|
19269
19575
|
this.clone.root,
|
|
19270
19576
|
this.clone.presences.get(actorID) || {},
|
|
19271
19577
|
message
|
|
@@ -19289,11 +19595,19 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
19289
19595
|
} finally {
|
|
19290
19596
|
this.isUpdating = false;
|
|
19291
19597
|
}
|
|
19598
|
+
const size = totalDocSize((_a2 = this.clone) == null ? void 0 : _a2.root.getDocSize());
|
|
19599
|
+
if (!context.isPresenceOnlyChange() && this.maxSizeLimit > 0 && this.maxSizeLimit < size) {
|
|
19600
|
+
this.clone = void 0;
|
|
19601
|
+
throw new YorkieError(
|
|
19602
|
+
Code.ErrDocumentSizeExceedsLimit,
|
|
19603
|
+
`document size exceeded: ${size} > ${this.maxSizeLimit}`
|
|
19604
|
+
);
|
|
19605
|
+
}
|
|
19292
19606
|
if (context.hasChange()) {
|
|
19293
19607
|
if (logger.isEnabled(LogLevel.Trivial)) {
|
|
19294
19608
|
logger.trivial(`trying to update a local change: ${this.toJSON()}`);
|
|
19295
19609
|
}
|
|
19296
|
-
const change = context.
|
|
19610
|
+
const change = context.toChange();
|
|
19297
19611
|
const { opInfos, reverseOps } = change.execute(
|
|
19298
19612
|
this.root,
|
|
19299
19613
|
this.presences,
|
|
@@ -19313,7 +19627,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
19313
19627
|
if (opInfos.length > 0) {
|
|
19314
19628
|
this.internalHistory.clearRedo();
|
|
19315
19629
|
}
|
|
19316
|
-
this.changeID =
|
|
19630
|
+
this.changeID = context.getNextID();
|
|
19317
19631
|
const event = [];
|
|
19318
19632
|
if (opInfos.length > 0) {
|
|
19319
19633
|
event.push({
|
|
@@ -19683,7 +19997,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
19683
19997
|
return this.status;
|
|
19684
19998
|
}
|
|
19685
19999
|
/**
|
|
19686
|
-
* `getClone`
|
|
20000
|
+
* `getClone` returns this clone.
|
|
20001
|
+
*/
|
|
20002
|
+
getClone() {
|
|
20003
|
+
return this.clone;
|
|
20004
|
+
}
|
|
20005
|
+
/**
|
|
20006
|
+
* `getCloneRoot` returns clone object.
|
|
19687
20007
|
*
|
|
19688
20008
|
* @internal
|
|
19689
20009
|
*/
|
|
@@ -19711,6 +20031,18 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
19711
20031
|
getDocSize() {
|
|
19712
20032
|
return this.root.getDocSize();
|
|
19713
20033
|
}
|
|
20034
|
+
/**
|
|
20035
|
+
* `getMaxSizePerDocument` gets the maximum size of this document.
|
|
20036
|
+
*/
|
|
20037
|
+
getMaxSizePerDocument() {
|
|
20038
|
+
return this.maxSizeLimit;
|
|
20039
|
+
}
|
|
20040
|
+
/**
|
|
20041
|
+
* `setMaxSizePerDocument` sets the maximum size of this document.
|
|
20042
|
+
*/
|
|
20043
|
+
setMaxSizePerDocument(size) {
|
|
20044
|
+
this.maxSizeLimit = size;
|
|
20045
|
+
}
|
|
19714
20046
|
/**
|
|
19715
20047
|
* `garbageCollect` purges elements that were removed before the given time.
|
|
19716
20048
|
*
|
|
@@ -20182,14 +20514,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
20182
20514
|
canUndo() {
|
|
20183
20515
|
return this.internalHistory.hasUndo() && !this.isUpdating;
|
|
20184
20516
|
}
|
|
20185
|
-
/**
|
|
20186
|
-
* 'filterVersionVector' filters detached client's lamport from version vector.
|
|
20187
|
-
*/
|
|
20188
|
-
filterVersionVector(minSyncedVersionVector) {
|
|
20189
|
-
const versionVector = this.changeID.getVersionVector();
|
|
20190
|
-
const filteredVersionVector = versionVector.filter(minSyncedVersionVector);
|
|
20191
|
-
this.changeID = this.changeID.setVersionVector(filteredVersionVector);
|
|
20192
|
-
}
|
|
20193
20517
|
/**
|
|
20194
20518
|
* `canRedo` returns whether there are any operations to redo.
|
|
20195
20519
|
*/
|
|
@@ -20216,7 +20540,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
20216
20540
|
}
|
|
20217
20541
|
this.ensureClone();
|
|
20218
20542
|
const context = ChangeContext.create(
|
|
20219
|
-
this.changeID
|
|
20543
|
+
this.changeID,
|
|
20220
20544
|
this.clone.root,
|
|
20221
20545
|
this.clone.presences.get(this.changeID.getActorID()) || {}
|
|
20222
20546
|
);
|
|
@@ -20233,7 +20557,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
20233
20557
|
undoOp.setExecutedAt(ticket);
|
|
20234
20558
|
context.push(undoOp);
|
|
20235
20559
|
}
|
|
20236
|
-
const change = context.
|
|
20560
|
+
const change = context.toChange();
|
|
20237
20561
|
change.execute(this.clone.root, this.clone.presences, OpSource.UndoRedo);
|
|
20238
20562
|
const { opInfos, reverseOps } = change.execute(
|
|
20239
20563
|
this.root,
|
|
@@ -20254,7 +20578,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
20254
20578
|
return;
|
|
20255
20579
|
}
|
|
20256
20580
|
this.localChanges.push(change);
|
|
20257
|
-
this.changeID =
|
|
20581
|
+
this.changeID = context.getNextID();
|
|
20258
20582
|
const actorID = this.changeID.getActorID();
|
|
20259
20583
|
const event = [];
|
|
20260
20584
|
if (opInfos.length > 0) {
|
|
@@ -20303,7 +20627,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
20303
20627
|
}
|
|
20304
20628
|
this.ensureClone();
|
|
20305
20629
|
const context = ChangeContext.create(
|
|
20306
|
-
this.changeID
|
|
20630
|
+
this.changeID,
|
|
20307
20631
|
this.clone.root,
|
|
20308
20632
|
this.clone.presences.get(this.changeID.getActorID()) || {}
|
|
20309
20633
|
);
|
|
@@ -20320,7 +20644,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
20320
20644
|
redoOp.setExecutedAt(ticket);
|
|
20321
20645
|
context.push(redoOp);
|
|
20322
20646
|
}
|
|
20323
|
-
const change = context.
|
|
20647
|
+
const change = context.toChange();
|
|
20324
20648
|
change.execute(this.clone.root, this.clone.presences, OpSource.UndoRedo);
|
|
20325
20649
|
const { opInfos, reverseOps } = change.execute(
|
|
20326
20650
|
this.root,
|
|
@@ -20341,7 +20665,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
20341
20665
|
return;
|
|
20342
20666
|
}
|
|
20343
20667
|
this.localChanges.push(change);
|
|
20344
|
-
this.changeID =
|
|
20668
|
+
this.changeID = context.getNextID();
|
|
20345
20669
|
const actorID = this.changeID.getActorID();
|
|
20346
20670
|
const event = [];
|
|
20347
20671
|
if (opInfos.length > 0) {
|
|
@@ -20420,7 +20744,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
20420
20744
|
};
|
|
20421
20745
|
}
|
|
20422
20746
|
const name = "@yorkie-js/sdk";
|
|
20423
|
-
const version = "0.6.
|
|
20747
|
+
const version = "0.6.13";
|
|
20424
20748
|
const pkg = {
|
|
20425
20749
|
name,
|
|
20426
20750
|
version
|
|
@@ -20578,16 +20902,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
20578
20902
|
if (this.status === "deactivated") {
|
|
20579
20903
|
return Promise.resolve();
|
|
20580
20904
|
}
|
|
20581
|
-
this.deactivateInternal();
|
|
20582
20905
|
const task = async () => {
|
|
20583
20906
|
try {
|
|
20584
20907
|
await this.rpcClient.deactivateClient(
|
|
20585
20908
|
{ clientId: this.id },
|
|
20586
20909
|
{ headers: { "x-shard-key": this.apiKey } }
|
|
20587
20910
|
);
|
|
20911
|
+
this.deactivateInternal();
|
|
20588
20912
|
logger.info(`[DC] c"${this.getKey()}" deactivated`);
|
|
20589
20913
|
} catch (err) {
|
|
20590
|
-
this.status = "activated";
|
|
20591
20914
|
logger.error(`[DC] c:"${this.getKey()}" err :`, err);
|
|
20592
20915
|
await this.handleConnectError(err);
|
|
20593
20916
|
throw err;
|
|
@@ -20651,6 +20974,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
20651
20974
|
},
|
|
20652
20975
|
{ headers: { "x-shard-key": `${this.apiKey}/${doc.getKey()}` } }
|
|
20653
20976
|
);
|
|
20977
|
+
const maxSize = res.maxSizePerDocument ?? 0;
|
|
20978
|
+
if (maxSize > 0) {
|
|
20979
|
+
doc.setMaxSizePerDocument(res.maxSizePerDocument);
|
|
20980
|
+
}
|
|
20654
20981
|
const pack = converter.fromChangePack(res.changePack);
|
|
20655
20982
|
doc.applyChangePack(pack);
|
|
20656
20983
|
if (doc.getStatus() === DocStatus.Removed) {
|
|
@@ -20671,12 +20998,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
20671
20998
|
await this.runWatchLoop(doc.getKey());
|
|
20672
20999
|
}
|
|
20673
21000
|
logger.info(`[AD] c:"${this.getKey()}" attaches d:"${doc.getKey()}"`);
|
|
20674
|
-
const
|
|
21001
|
+
const crdtObject = doc.getRootObject();
|
|
20675
21002
|
if (opts.initialRoot) {
|
|
20676
21003
|
const initialRoot = opts.initialRoot;
|
|
20677
21004
|
doc.update((root) => {
|
|
20678
21005
|
for (const [k, v] of Object.entries(initialRoot)) {
|
|
20679
|
-
if (!
|
|
21006
|
+
if (!crdtObject.has(k)) {
|
|
20680
21007
|
const key = k;
|
|
20681
21008
|
root[key] = v;
|
|
20682
21009
|
}
|
|
@@ -20699,7 +21026,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
20699
21026
|
* the changes should be applied to other replicas before GC time. For this,
|
|
20700
21027
|
* if the document is no longer used by this client, it should be detached.
|
|
20701
21028
|
*/
|
|
20702
|
-
detach(doc, opts = {
|
|
21029
|
+
detach(doc, opts = { keepalive: false }) {
|
|
20703
21030
|
if (!this.isActive()) {
|
|
20704
21031
|
throw new YorkieError(
|
|
20705
21032
|
Code.ErrClientNotActivated,
|
|
@@ -20714,14 +21041,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
20714
21041
|
);
|
|
20715
21042
|
}
|
|
20716
21043
|
doc.update((_, p) => p.clear());
|
|
20717
|
-
|
|
21044
|
+
const task = async () => {
|
|
20718
21045
|
try {
|
|
20719
21046
|
const res = await this.rpcClient.detachDocument(
|
|
20720
21047
|
{
|
|
20721
21048
|
clientId: this.id,
|
|
20722
21049
|
documentId: attachment.docID,
|
|
20723
21050
|
changePack: converter.toChangePack(doc.createChangePack()),
|
|
20724
|
-
removeIfNotAttached: opts.removeIfNotAttached
|
|
21051
|
+
removeIfNotAttached: opts.removeIfNotAttached ?? false
|
|
20725
21052
|
},
|
|
20726
21053
|
{ headers: { "x-shard-key": `${this.apiKey}/${doc.getKey()}` } }
|
|
20727
21054
|
);
|
|
@@ -20738,7 +21065,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
20738
21065
|
await this.handleConnectError(err);
|
|
20739
21066
|
throw err;
|
|
20740
21067
|
}
|
|
20741
|
-
}
|
|
21068
|
+
};
|
|
21069
|
+
if (opts.keepalive) {
|
|
21070
|
+
this.keepalive = true;
|
|
21071
|
+
const resp = task();
|
|
21072
|
+
this.keepalive = false;
|
|
21073
|
+
return resp;
|
|
21074
|
+
}
|
|
21075
|
+
return this.enqueueTask(task);
|
|
20742
21076
|
}
|
|
20743
21077
|
/**
|
|
20744
21078
|
* `changeRealtimeSync` changes the synchronization mode of the given document.
|