@yorkie-js/react 0.6.12 → 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 +363 -74
- package/dist/yorkie-js-react.es.js.map +1 -1
- package/dist/yorkie-js-react.js +363 -74
- 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";
|
|
@@ -10978,6 +11130,23 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
10978
11130
|
}
|
|
10979
11131
|
return attributes;
|
|
10980
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
|
+
}
|
|
10981
11150
|
class CRDTTextValue {
|
|
10982
11151
|
constructor(content) {
|
|
10983
11152
|
__publicField(this, "attributes");
|
|
@@ -11113,7 +11282,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
11113
11282
|
crdtTextValue.setAttr(k, v, editedAt);
|
|
11114
11283
|
}
|
|
11115
11284
|
}
|
|
11116
|
-
const [caretPos, pairs, valueChanges] = this.rgaTreeSplit.edit(
|
|
11285
|
+
const [caretPos, pairs, diff, valueChanges] = this.rgaTreeSplit.edit(
|
|
11117
11286
|
range,
|
|
11118
11287
|
editedAt,
|
|
11119
11288
|
crdtTextValue,
|
|
@@ -11131,7 +11300,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
11131
11300
|
type: "content"
|
|
11132
11301
|
/* Content */
|
|
11133
11302
|
}));
|
|
11134
|
-
return [changes, pairs, [caretPos, caretPos]];
|
|
11303
|
+
return [changes, pairs, diff, [caretPos, caretPos]];
|
|
11135
11304
|
}
|
|
11136
11305
|
/**
|
|
11137
11306
|
* `setStyle` applies the style of the given range.
|
|
@@ -11144,11 +11313,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
11144
11313
|
* @internal
|
|
11145
11314
|
*/
|
|
11146
11315
|
setStyle(range, attributes, editedAt, versionVector) {
|
|
11147
|
-
const
|
|
11148
|
-
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(
|
|
11149
11322
|
range[0],
|
|
11150
11323
|
editedAt
|
|
11151
11324
|
);
|
|
11325
|
+
addDataSizes(diff, diffTo, diffFrom);
|
|
11152
11326
|
const changes = [];
|
|
11153
11327
|
const nodes = this.rgaTreeSplit.findBetween(fromRight, toRight);
|
|
11154
11328
|
const toBeStyleds = [];
|
|
@@ -11184,9 +11358,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
11184
11358
|
if (prev !== void 0) {
|
|
11185
11359
|
pairs.push({ parent: node.getValue(), child: prev });
|
|
11186
11360
|
}
|
|
11361
|
+
const curr = node.getValue().getAttrs().getNodeMapByKey().get(key);
|
|
11362
|
+
if (curr !== void 0) {
|
|
11363
|
+
addDataSizes(diff, curr.getDataSize());
|
|
11364
|
+
}
|
|
11187
11365
|
}
|
|
11188
11366
|
}
|
|
11189
|
-
return [pairs, changes];
|
|
11367
|
+
return [pairs, diff, changes];
|
|
11190
11368
|
}
|
|
11191
11369
|
/**
|
|
11192
11370
|
* `indexRangeToPosRange` returns the position range of the given index range.
|
|
@@ -11375,13 +11553,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
11375
11553
|
);
|
|
11376
11554
|
}
|
|
11377
11555
|
const text = parentObject;
|
|
11378
|
-
const [changes, pairs] = text.edit(
|
|
11556
|
+
const [changes, pairs, diff] = text.edit(
|
|
11379
11557
|
[this.fromPos, this.toPos],
|
|
11380
11558
|
this.content,
|
|
11381
11559
|
this.getExecutedAt(),
|
|
11382
11560
|
Object.fromEntries(this.attributes),
|
|
11383
11561
|
versionVector
|
|
11384
11562
|
);
|
|
11563
|
+
root.acc(diff);
|
|
11385
11564
|
for (const pair of pairs) {
|
|
11386
11565
|
root.registerGCPair(pair);
|
|
11387
11566
|
}
|
|
@@ -11478,12 +11657,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
11478
11657
|
);
|
|
11479
11658
|
}
|
|
11480
11659
|
const text = parentObject;
|
|
11481
|
-
const [pairs, changes] = text.setStyle(
|
|
11660
|
+
const [pairs, diff, changes] = text.setStyle(
|
|
11482
11661
|
[this.fromPos, this.toPos],
|
|
11483
11662
|
this.attributes ? Object.fromEntries(this.attributes) : {},
|
|
11484
11663
|
this.getExecutedAt(),
|
|
11485
11664
|
versionVector
|
|
11486
11665
|
);
|
|
11666
|
+
root.acc(diff);
|
|
11487
11667
|
for (const pair of pairs) {
|
|
11488
11668
|
root.registerGCPair(pair);
|
|
11489
11669
|
}
|
|
@@ -11637,19 +11817,23 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
11637
11817
|
* `splitText` splits the given node at the given offset.
|
|
11638
11818
|
*/
|
|
11639
11819
|
splitText(offset, absOffset) {
|
|
11820
|
+
const diff = { data: 0, meta: 0 };
|
|
11640
11821
|
if (offset === 0 || offset === this.size) {
|
|
11641
|
-
return;
|
|
11822
|
+
return [void 0, diff];
|
|
11642
11823
|
}
|
|
11643
11824
|
const leftValue = this.value.slice(0, offset);
|
|
11644
11825
|
const rightValue = this.value.slice(offset);
|
|
11645
11826
|
if (!rightValue.length) {
|
|
11646
|
-
return;
|
|
11827
|
+
return [void 0, diff];
|
|
11647
11828
|
}
|
|
11829
|
+
const prvSize = this.getDataSize();
|
|
11648
11830
|
this.value = leftValue;
|
|
11649
11831
|
const rightNode = this.cloneText(offset + absOffset);
|
|
11650
11832
|
rightNode.value = rightValue;
|
|
11651
11833
|
this.parent.insertAfterInternal(rightNode, this);
|
|
11652
|
-
|
|
11834
|
+
addDataSizes(diff, this.getDataSize(), rightNode.getDataSize());
|
|
11835
|
+
subDataSize(diff, prvSize);
|
|
11836
|
+
return [rightNode, diff];
|
|
11653
11837
|
}
|
|
11654
11838
|
/**
|
|
11655
11839
|
* `children` returns the children of the node.
|
|
@@ -11764,6 +11948,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
11764
11948
|
* `splitElement` splits the given element at the given offset.
|
|
11765
11949
|
*/
|
|
11766
11950
|
splitElement(offset, issueTimeTicket) {
|
|
11951
|
+
const diff = { data: 0, meta: 0 };
|
|
11952
|
+
const prvSize = this.getDataSize();
|
|
11767
11953
|
const clone = this.cloneElement(issueTimeTicket);
|
|
11768
11954
|
this.parent.insertAfterInternal(clone, this);
|
|
11769
11955
|
clone.updateAncestorsSize();
|
|
@@ -11782,7 +11968,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
11782
11968
|
for (const child of clone._children) {
|
|
11783
11969
|
child.parent = clone;
|
|
11784
11970
|
}
|
|
11785
|
-
|
|
11971
|
+
addDataSizes(diff, this.getDataSize(), clone.getDataSize());
|
|
11972
|
+
subDataSize(diff, prvSize);
|
|
11973
|
+
return [clone, diff];
|
|
11786
11974
|
}
|
|
11787
11975
|
/**
|
|
11788
11976
|
* `insertAfterInternal` inserts the given node after the given child.
|
|
@@ -12775,7 +12963,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
12775
12963
|
* `split` splits the given offset of this node.
|
|
12776
12964
|
*/
|
|
12777
12965
|
split(tree, offset, issueTimeTicket) {
|
|
12778
|
-
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);
|
|
12779
12967
|
if (split) {
|
|
12780
12968
|
split.insPrevID = this.id;
|
|
12781
12969
|
if (this.insNextID) {
|
|
@@ -12786,7 +12974,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
12786
12974
|
this.insNextID = split.id;
|
|
12787
12975
|
tree.registerNode(split);
|
|
12788
12976
|
}
|
|
12789
|
-
return split;
|
|
12977
|
+
return [split, diff];
|
|
12790
12978
|
}
|
|
12791
12979
|
/**
|
|
12792
12980
|
* `getCreatedAt` returns the creation time of this element.
|
|
@@ -12977,15 +13165,17 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
12977
13165
|
* for concurrent insertion.
|
|
12978
13166
|
*/
|
|
12979
13167
|
findNodesAndSplitText(pos, editedAt) {
|
|
13168
|
+
let diff = { data: 0, meta: 0 };
|
|
12980
13169
|
const [parent, leftSibling] = pos.toTreeNodePair(this);
|
|
12981
13170
|
let leftNode = leftSibling;
|
|
12982
13171
|
const isLeftMost = parent === leftNode;
|
|
12983
13172
|
const realParent = leftNode.parent && !isLeftMost ? leftNode.parent : parent;
|
|
12984
13173
|
if (leftNode.isText) {
|
|
12985
|
-
leftNode.split(
|
|
13174
|
+
const [, splitedDiff] = leftNode.split(
|
|
12986
13175
|
this,
|
|
12987
13176
|
pos.getLeftSiblingID().getOffset() - leftNode.id.getOffset()
|
|
12988
13177
|
);
|
|
13178
|
+
diff = splitedDiff;
|
|
12989
13179
|
}
|
|
12990
13180
|
if (editedAt) {
|
|
12991
13181
|
const allChildren = realParent.allChildren;
|
|
@@ -12998,17 +13188,22 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
12998
13188
|
leftNode = next;
|
|
12999
13189
|
}
|
|
13000
13190
|
}
|
|
13001
|
-
return [realParent, leftNode];
|
|
13191
|
+
return [[realParent, leftNode], diff];
|
|
13002
13192
|
}
|
|
13003
13193
|
/**
|
|
13004
13194
|
* `style` applies the given attributes of the given range.
|
|
13005
13195
|
*/
|
|
13006
13196
|
style(range, attributes, editedAt, versionVector) {
|
|
13007
|
-
const
|
|
13197
|
+
const diff = { data: 0, meta: 0 };
|
|
13198
|
+
const [[fromParent, fromLeft], diffFrom] = this.findNodesAndSplitText(
|
|
13008
13199
|
range[0],
|
|
13009
13200
|
editedAt
|
|
13010
13201
|
);
|
|
13011
|
-
const [toParent, toLeft] = this.findNodesAndSplitText(
|
|
13202
|
+
const [[toParent, toLeft], diffTo] = this.findNodesAndSplitText(
|
|
13203
|
+
range[1],
|
|
13204
|
+
editedAt
|
|
13205
|
+
);
|
|
13206
|
+
addDataSizes(diff, diffTo, diffFrom);
|
|
13012
13207
|
const changes = [];
|
|
13013
13208
|
const attrs = attributes ? parseObjectValues(attributes) : {};
|
|
13014
13209
|
const pairs = [];
|
|
@@ -13017,7 +13212,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
13017
13212
|
fromLeft,
|
|
13018
13213
|
toParent,
|
|
13019
13214
|
toLeft,
|
|
13020
|
-
([node]) => {
|
|
13215
|
+
([node, tokenType]) => {
|
|
13216
|
+
var _a2;
|
|
13021
13217
|
const actorID = node.getCreatedAt().getActorID();
|
|
13022
13218
|
let clientLamportAtChange = MaxLamport;
|
|
13023
13219
|
if (versionVector != void 0) {
|
|
@@ -13053,20 +13249,31 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
13053
13249
|
pairs.push({ parent: node, child: prev });
|
|
13054
13250
|
}
|
|
13055
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
|
+
}
|
|
13056
13258
|
}
|
|
13057
13259
|
}
|
|
13058
13260
|
);
|
|
13059
|
-
return [pairs, changes];
|
|
13261
|
+
return [pairs, changes, diff];
|
|
13060
13262
|
}
|
|
13061
13263
|
/**
|
|
13062
13264
|
* `removeStyle` removes the given attributes of the given range.
|
|
13063
13265
|
*/
|
|
13064
13266
|
removeStyle(range, attributesToRemove, editedAt, versionVector) {
|
|
13065
|
-
const
|
|
13267
|
+
const diff = { data: 0, meta: 0 };
|
|
13268
|
+
const [[fromParent, fromLeft], diffFrom] = this.findNodesAndSplitText(
|
|
13066
13269
|
range[0],
|
|
13067
13270
|
editedAt
|
|
13068
13271
|
);
|
|
13069
|
-
const [toParent, toLeft] = this.findNodesAndSplitText(
|
|
13272
|
+
const [[toParent, toLeft], diffTo] = this.findNodesAndSplitText(
|
|
13273
|
+
range[1],
|
|
13274
|
+
editedAt
|
|
13275
|
+
);
|
|
13276
|
+
addDataSizes(diff, diffTo, diffFrom);
|
|
13070
13277
|
const changes = [];
|
|
13071
13278
|
const pairs = [];
|
|
13072
13279
|
this.traverseInPosRange(
|
|
@@ -13104,18 +13311,23 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
13104
13311
|
}
|
|
13105
13312
|
}
|
|
13106
13313
|
);
|
|
13107
|
-
return [pairs, changes];
|
|
13314
|
+
return [pairs, changes, diff];
|
|
13108
13315
|
}
|
|
13109
13316
|
/**
|
|
13110
13317
|
* `edit` edits the tree with the given range and content.
|
|
13111
13318
|
* If the content is undefined, the range will be removed.
|
|
13112
13319
|
*/
|
|
13113
13320
|
edit(range, contents, splitLevel, editedAt, issueTimeTicket, versionVector) {
|
|
13114
|
-
const
|
|
13321
|
+
const diff = { data: 0, meta: 0 };
|
|
13322
|
+
const [[fromParent, fromLeft], diffFrom] = this.findNodesAndSplitText(
|
|
13115
13323
|
range[0],
|
|
13116
13324
|
editedAt
|
|
13117
13325
|
);
|
|
13118
|
-
const [toParent, toLeft] = this.findNodesAndSplitText(
|
|
13326
|
+
const [[toParent, toLeft], diffTo] = this.findNodesAndSplitText(
|
|
13327
|
+
range[1],
|
|
13328
|
+
editedAt
|
|
13329
|
+
);
|
|
13330
|
+
addDataSizes(diff, diffTo, diffFrom);
|
|
13119
13331
|
const fromIdx = this.toIndex(fromParent, fromLeft);
|
|
13120
13332
|
const fromPath = this.toPath(fromParent, fromLeft);
|
|
13121
13333
|
const nodesToBeRemoved = [];
|
|
@@ -13194,6 +13406,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
13194
13406
|
if (fromParent.isRemoved) {
|
|
13195
13407
|
node.remove(editedAt);
|
|
13196
13408
|
pairs.push({ parent: this, child: node });
|
|
13409
|
+
} else {
|
|
13410
|
+
addDataSizes(diff, node.getDataSize());
|
|
13197
13411
|
}
|
|
13198
13412
|
this.nodeMapByID.put(node.id, node);
|
|
13199
13413
|
});
|
|
@@ -13218,7 +13432,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
13218
13432
|
}
|
|
13219
13433
|
}
|
|
13220
13434
|
}
|
|
13221
|
-
return [changes, pairs];
|
|
13435
|
+
return [changes, pairs, diff];
|
|
13222
13436
|
}
|
|
13223
13437
|
/**
|
|
13224
13438
|
* `editT` edits the given range with the given value.
|
|
@@ -13497,16 +13711,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
13497
13711
|
* `posRangeToPathRange` converts the given position range to the path range.
|
|
13498
13712
|
*/
|
|
13499
13713
|
posRangeToPathRange(range) {
|
|
13500
|
-
const [fromParent, fromLeft] = this.findNodesAndSplitText(range[0]);
|
|
13501
|
-
const [toParent, toLeft] = this.findNodesAndSplitText(range[1]);
|
|
13714
|
+
const [[fromParent, fromLeft]] = this.findNodesAndSplitText(range[0]);
|
|
13715
|
+
const [[toParent, toLeft]] = this.findNodesAndSplitText(range[1]);
|
|
13502
13716
|
return [this.toPath(fromParent, fromLeft), this.toPath(toParent, toLeft)];
|
|
13503
13717
|
}
|
|
13504
13718
|
/**
|
|
13505
13719
|
* `posRangeToIndexRange` converts the given position range to the path range.
|
|
13506
13720
|
*/
|
|
13507
13721
|
posRangeToIndexRange(range) {
|
|
13508
|
-
const [fromParent, fromLeft] = this.findNodesAndSplitText(range[0]);
|
|
13509
|
-
const [toParent, toLeft] = this.findNodesAndSplitText(range[1]);
|
|
13722
|
+
const [[fromParent, fromLeft]] = this.findNodesAndSplitText(range[0]);
|
|
13723
|
+
const [[toParent, toLeft]] = this.findNodesAndSplitText(range[1]);
|
|
13510
13724
|
return [this.toIndex(fromParent, fromLeft), this.toIndex(toParent, toLeft)];
|
|
13511
13725
|
}
|
|
13512
13726
|
/**
|
|
@@ -13701,7 +13915,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
13701
13915
|
}
|
|
13702
13916
|
const editedAt = this.getExecutedAt();
|
|
13703
13917
|
const tree = parentObject;
|
|
13704
|
-
const [changes, pairs] = tree.edit(
|
|
13918
|
+
const [changes, pairs, diff] = tree.edit(
|
|
13705
13919
|
[this.fromPos, this.toPos],
|
|
13706
13920
|
(_a2 = this.contents) == null ? void 0 : _a2.map((content) => content.deepcopy()),
|
|
13707
13921
|
this.splitLevel,
|
|
@@ -13727,6 +13941,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
13727
13941
|
})(),
|
|
13728
13942
|
versionVector
|
|
13729
13943
|
);
|
|
13944
|
+
root.acc(diff);
|
|
13730
13945
|
for (const pair of pairs) {
|
|
13731
13946
|
root.registerGCPair(pair);
|
|
13732
13947
|
}
|
|
@@ -14781,8 +14996,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
14781
14996
|
* @returns `[RGATreeSplitPos, Array<GCPair>, Array<Change>]`
|
|
14782
14997
|
*/
|
|
14783
14998
|
edit(range, editedAt, value, versionVector) {
|
|
14784
|
-
const
|
|
14785
|
-
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);
|
|
14786
15009
|
const nodesToDelete = this.findBetween(fromRight, toRight);
|
|
14787
15010
|
const [changes, removedNodes] = this.deleteNodes(
|
|
14788
15011
|
nodesToDelete,
|
|
@@ -14797,6 +15020,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
14797
15020
|
fromLeft,
|
|
14798
15021
|
RGATreeSplitNode.create(RGATreeSplitNodeID.of(editedAt, 0), value)
|
|
14799
15022
|
);
|
|
15023
|
+
addDataSizes(diff, inserted.getDataSize());
|
|
14800
15024
|
if (changes.length && changes[changes.length - 1].from === idx) {
|
|
14801
15025
|
changes[changes.length - 1].value = value;
|
|
14802
15026
|
} else {
|
|
@@ -14816,7 +15040,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
14816
15040
|
for (const [, removedNode] of removedNodes) {
|
|
14817
15041
|
pairs.push({ parent: this, child: removedNode });
|
|
14818
15042
|
}
|
|
14819
|
-
return [caretPos, pairs, changes];
|
|
15043
|
+
return [caretPos, pairs, diff, changes];
|
|
14820
15044
|
}
|
|
14821
15045
|
/**
|
|
14822
15046
|
* `indexToPos` finds RGATreeSplitPos of given offset.
|
|
@@ -14955,11 +15179,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
14955
15179
|
const absoluteID = pos.getAbsoluteID();
|
|
14956
15180
|
let node = this.findFloorNodePreferToLeft(absoluteID);
|
|
14957
15181
|
const relativeOffset = absoluteID.getOffset() - node.getID().getOffset();
|
|
14958
|
-
this.splitNode(node, relativeOffset);
|
|
15182
|
+
const [, diff] = this.splitNode(node, relativeOffset);
|
|
14959
15183
|
while (node.hasNext() && node.getNext().getCreatedAt().after(editedAt)) {
|
|
14960
15184
|
node = node.getNext();
|
|
14961
15185
|
}
|
|
14962
|
-
return [node, node.getNext()];
|
|
15186
|
+
return [node, diff, node.getNext()];
|
|
14963
15187
|
}
|
|
14964
15188
|
findFloorNodePreferToLeft(id) {
|
|
14965
15189
|
let node = this.findFloorNode(id);
|
|
@@ -15000,6 +15224,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
15000
15224
|
return nodes;
|
|
15001
15225
|
}
|
|
15002
15226
|
splitNode(node, offset) {
|
|
15227
|
+
const diff = { data: 0, meta: 0 };
|
|
15003
15228
|
if (offset > node.getContentLength()) {
|
|
15004
15229
|
throw new YorkieError(
|
|
15005
15230
|
Code.ErrInvalidArgument,
|
|
@@ -15007,10 +15232,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
15007
15232
|
);
|
|
15008
15233
|
}
|
|
15009
15234
|
if (offset === 0) {
|
|
15010
|
-
return node;
|
|
15235
|
+
return [node, diff];
|
|
15011
15236
|
} else if (offset === node.getContentLength()) {
|
|
15012
|
-
return node.getNext();
|
|
15237
|
+
return [node.getNext(), diff];
|
|
15013
15238
|
}
|
|
15239
|
+
const prvSize = node.getDataSize();
|
|
15014
15240
|
const splitNode = node.split(offset);
|
|
15015
15241
|
this.treeByIndex.updateWeight(splitNode);
|
|
15016
15242
|
this.insertAfter(node, splitNode);
|
|
@@ -15019,7 +15245,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
15019
15245
|
insNext.setInsPrev(splitNode);
|
|
15020
15246
|
}
|
|
15021
15247
|
splitNode.setInsPrev(node);
|
|
15022
|
-
|
|
15248
|
+
addDataSizes(diff, node.getDataSize(), splitNode.getDataSize());
|
|
15249
|
+
subDataSize(diff, prvSize);
|
|
15250
|
+
return [splitNode, diff];
|
|
15023
15251
|
}
|
|
15024
15252
|
deleteNodes(candidates, editedAt, versionVector) {
|
|
15025
15253
|
if (!candidates.length) {
|
|
@@ -15488,10 +15716,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
15488
15716
|
const tree = parentObject;
|
|
15489
15717
|
let changes;
|
|
15490
15718
|
let pairs;
|
|
15719
|
+
let diff = { data: 0, meta: 0 };
|
|
15491
15720
|
if (this.attributes.size) {
|
|
15492
15721
|
const attributes = {};
|
|
15493
15722
|
[...this.attributes].forEach(([key, value]) => attributes[key] = value);
|
|
15494
|
-
[pairs, changes] = tree.style(
|
|
15723
|
+
[pairs, changes, diff] = tree.style(
|
|
15495
15724
|
[this.fromPos, this.toPos],
|
|
15496
15725
|
attributes,
|
|
15497
15726
|
this.getExecutedAt(),
|
|
@@ -15499,13 +15728,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
15499
15728
|
);
|
|
15500
15729
|
} else {
|
|
15501
15730
|
const attributesToRemove = this.attributesToRemove;
|
|
15502
|
-
[pairs, changes] = tree.removeStyle(
|
|
15731
|
+
[pairs, changes, diff] = tree.removeStyle(
|
|
15503
15732
|
[this.fromPos, this.toPos],
|
|
15504
15733
|
attributesToRemove,
|
|
15505
15734
|
this.getExecutedAt(),
|
|
15506
15735
|
versionVector
|
|
15507
15736
|
);
|
|
15508
15737
|
}
|
|
15738
|
+
root.acc(diff);
|
|
15509
15739
|
for (const pair of pairs) {
|
|
15510
15740
|
root.registerGCPair(pair);
|
|
15511
15741
|
}
|
|
@@ -17021,7 +17251,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17021
17251
|
* document for the next change.returns the next ID of this context.
|
|
17022
17252
|
*/
|
|
17023
17253
|
getNextID() {
|
|
17024
|
-
if (this.
|
|
17254
|
+
if (this.isPresenceOnlyChange()) {
|
|
17025
17255
|
return this.prevID.next(true).setLamport(this.prevID.getLamport()).setVersionVector(this.prevID.getVersionVector());
|
|
17026
17256
|
}
|
|
17027
17257
|
return this.nextID;
|
|
@@ -17030,7 +17260,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17030
17260
|
* `toChange` creates a new instance of Change in this context.
|
|
17031
17261
|
*/
|
|
17032
17262
|
toChange() {
|
|
17033
|
-
const id = this.
|
|
17263
|
+
const id = this.isPresenceOnlyChange() ? this.prevID.next(true) : this.nextID;
|
|
17034
17264
|
return Change.create({
|
|
17035
17265
|
id,
|
|
17036
17266
|
operations: this.operations,
|
|
@@ -17038,6 +17268,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17038
17268
|
message: this.message
|
|
17039
17269
|
});
|
|
17040
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
|
+
}
|
|
17041
17278
|
/**
|
|
17042
17279
|
* `hasChange` returns whether this context has change or not.
|
|
17043
17280
|
*/
|
|
@@ -17086,6 +17323,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17086
17323
|
getLastTimeTicket() {
|
|
17087
17324
|
return this.nextID.createTimeTicket(this.delimiter);
|
|
17088
17325
|
}
|
|
17326
|
+
/**
|
|
17327
|
+
* `acc` accumulates the given DataSize to Live size of the root.
|
|
17328
|
+
*/
|
|
17329
|
+
acc(diff) {
|
|
17330
|
+
this.root.acc(diff);
|
|
17331
|
+
}
|
|
17089
17332
|
}
|
|
17090
17333
|
class CRDTRoot {
|
|
17091
17334
|
constructor(rootObject) {
|
|
@@ -17109,10 +17352,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17109
17352
|
* element itself and its parent.
|
|
17110
17353
|
*/
|
|
17111
17354
|
__publicField(this, "gcPairMap");
|
|
17355
|
+
/**
|
|
17356
|
+
* `docSize` is a structure that represents the size of the document.
|
|
17357
|
+
*/
|
|
17358
|
+
__publicField(this, "docSize");
|
|
17112
17359
|
this.rootObject = rootObject;
|
|
17113
17360
|
this.elementPairMapByCreatedAt = /* @__PURE__ */ new Map();
|
|
17114
17361
|
this.gcElementSetByCreatedAt = /* @__PURE__ */ new Set();
|
|
17115
17362
|
this.gcPairMap = /* @__PURE__ */ new Map();
|
|
17363
|
+
this.docSize = { live: { data: 0, meta: 0 }, gc: { data: 0, meta: 0 } };
|
|
17116
17364
|
this.registerElement(rootObject, void 0);
|
|
17117
17365
|
rootObject.getDescendants((elem) => {
|
|
17118
17366
|
if (elem.getRemovedAt()) {
|
|
@@ -17189,6 +17437,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17189
17437
|
parent,
|
|
17190
17438
|
element
|
|
17191
17439
|
});
|
|
17440
|
+
addDataSizes(this.docSize.live, element.getDataSize());
|
|
17192
17441
|
if (element instanceof CRDTContainer) {
|
|
17193
17442
|
element.getDescendants((elem, parent2) => {
|
|
17194
17443
|
this.registerElement(elem, parent2);
|
|
@@ -17203,6 +17452,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17203
17452
|
let count = 0;
|
|
17204
17453
|
const deregisterElementInternal = (elem) => {
|
|
17205
17454
|
const createdAt = elem.getCreatedAt().toIDString();
|
|
17455
|
+
subDataSize(this.docSize.gc, elem.getDataSize());
|
|
17206
17456
|
this.elementPairMapByCreatedAt.delete(createdAt);
|
|
17207
17457
|
this.gcElementSetByCreatedAt.delete(createdAt);
|
|
17208
17458
|
count++;
|
|
@@ -17220,6 +17470,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17220
17470
|
* `registerRemovedElement` registers the given element to the hash set.
|
|
17221
17471
|
*/
|
|
17222
17472
|
registerRemovedElement(element) {
|
|
17473
|
+
addDataSizes(this.docSize.gc, element.getDataSize());
|
|
17474
|
+
subDataSize(this.docSize.live, element.getDataSize());
|
|
17475
|
+
this.docSize.live.meta += TimeTicketSize;
|
|
17223
17476
|
this.gcElementSetByCreatedAt.add(element.getCreatedAt().toIDString());
|
|
17224
17477
|
}
|
|
17225
17478
|
/**
|
|
@@ -17232,6 +17485,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17232
17485
|
return;
|
|
17233
17486
|
}
|
|
17234
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
|
+
}
|
|
17235
17494
|
}
|
|
17236
17495
|
/**
|
|
17237
17496
|
* `getElementMapSize` returns the size of element map.
|
|
@@ -17272,22 +17531,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17272
17531
|
* `getDocSize` returns the size of the document.
|
|
17273
17532
|
*/
|
|
17274
17533
|
getDocSize() {
|
|
17275
|
-
|
|
17276
|
-
for (const [createdAt, value] of this.elementPairMapByCreatedAt) {
|
|
17277
|
-
if (this.gcElementSetByCreatedAt.has(createdAt)) {
|
|
17278
|
-
docSize.gc.data += value.element.getDataSize().data;
|
|
17279
|
-
docSize.gc.meta += value.element.getDataSize().meta;
|
|
17280
|
-
} else {
|
|
17281
|
-
docSize.live.data += value.element.getDataSize().data;
|
|
17282
|
-
docSize.live.meta += value.element.getDataSize().meta;
|
|
17283
|
-
}
|
|
17284
|
-
}
|
|
17285
|
-
for (const pair of this.gcPairMap.values()) {
|
|
17286
|
-
const size = pair.child.getDataSize();
|
|
17287
|
-
docSize.gc.data += size.data;
|
|
17288
|
-
docSize.gc.meta += size.meta;
|
|
17289
|
-
}
|
|
17290
|
-
return docSize;
|
|
17534
|
+
return this.docSize;
|
|
17291
17535
|
}
|
|
17292
17536
|
/**
|
|
17293
17537
|
* `deepcopy` copies itself deeply.
|
|
@@ -17341,6 +17585,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17341
17585
|
gcElements: this.getGarbageElementSetSize()
|
|
17342
17586
|
};
|
|
17343
17587
|
}
|
|
17588
|
+
/**
|
|
17589
|
+
* `acc` accumulates the given DataSize to Live.
|
|
17590
|
+
*/
|
|
17591
|
+
acc(diff) {
|
|
17592
|
+
addDataSizes(this.docSize.live, diff);
|
|
17593
|
+
}
|
|
17344
17594
|
}
|
|
17345
17595
|
function createJSONObject(context, target) {
|
|
17346
17596
|
const objectProxy = new ObjectProxy(context);
|
|
@@ -17958,12 +18208,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17958
18208
|
}
|
|
17959
18209
|
const attrs = attributes ? stringifyObjectValues(attributes) : void 0;
|
|
17960
18210
|
const ticket = this.context.issueTimeTicket();
|
|
17961
|
-
const [, pairs, rangeAfterEdit] = this.text.edit(
|
|
18211
|
+
const [, pairs, diff, rangeAfterEdit] = this.text.edit(
|
|
17962
18212
|
range,
|
|
17963
18213
|
content,
|
|
17964
18214
|
ticket,
|
|
17965
18215
|
attrs
|
|
17966
18216
|
);
|
|
18217
|
+
this.context.acc(diff);
|
|
17967
18218
|
for (const pair of pairs) {
|
|
17968
18219
|
this.context.registerGCPair(pair);
|
|
17969
18220
|
}
|
|
@@ -18017,7 +18268,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
18017
18268
|
}
|
|
18018
18269
|
const attrs = stringifyObjectValues(attributes);
|
|
18019
18270
|
const ticket = this.context.issueTimeTicket();
|
|
18020
|
-
const [pairs] = this.text.setStyle(range, attrs, ticket);
|
|
18271
|
+
const [pairs, diff] = this.text.setStyle(range, attrs, ticket);
|
|
18272
|
+
this.context.acc(diff);
|
|
18021
18273
|
for (const pair of pairs) {
|
|
18022
18274
|
this.context.registerGCPair(pair);
|
|
18023
18275
|
}
|
|
@@ -18560,7 +18812,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
18560
18812
|
const [fromPos, toPos] = this.tree.pathToPosRange(path);
|
|
18561
18813
|
const ticket = this.context.issueTimeTicket();
|
|
18562
18814
|
const attrs = attributes ? stringifyObjectValues(attributes) : void 0;
|
|
18563
|
-
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);
|
|
18564
18817
|
for (const pair of pairs) {
|
|
18565
18818
|
this.context.registerGCPair(pair);
|
|
18566
18819
|
}
|
|
@@ -18594,7 +18847,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
18594
18847
|
const toPos = this.tree.findPos(toIdx);
|
|
18595
18848
|
const ticket = this.context.issueTimeTicket();
|
|
18596
18849
|
const attrs = attributes ? stringifyObjectValues(attributes) : void 0;
|
|
18597
|
-
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);
|
|
18598
18852
|
for (const pair of pairs) {
|
|
18599
18853
|
this.context.registerGCPair(pair);
|
|
18600
18854
|
}
|
|
@@ -18627,11 +18881,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
18627
18881
|
const fromPos = this.tree.findPos(fromIdx);
|
|
18628
18882
|
const toPos = this.tree.findPos(toIdx);
|
|
18629
18883
|
const ticket = this.context.issueTimeTicket();
|
|
18630
|
-
const [pairs] = this.tree.removeStyle(
|
|
18884
|
+
const [pairs, , diff] = this.tree.removeStyle(
|
|
18631
18885
|
[fromPos, toPos],
|
|
18632
18886
|
attributesToRemove,
|
|
18633
18887
|
ticket
|
|
18634
18888
|
);
|
|
18889
|
+
this.context.acc(diff);
|
|
18635
18890
|
for (const pair of pairs) {
|
|
18636
18891
|
this.context.registerGCPair(pair);
|
|
18637
18892
|
}
|
|
@@ -18674,13 +18929,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
18674
18929
|
} else {
|
|
18675
18930
|
crdtNodes = contents.map((content) => content && createCRDTTreeNode(this.context, content)).filter((a) => a);
|
|
18676
18931
|
}
|
|
18677
|
-
const [, pairs] = this.tree.edit(
|
|
18932
|
+
const [, pairs, diff] = this.tree.edit(
|
|
18678
18933
|
[fromPos, toPos],
|
|
18679
18934
|
crdtNodes.length ? crdtNodes.map((crdtNode) => crdtNode == null ? void 0 : crdtNode.deepcopy()) : void 0,
|
|
18680
18935
|
splitLevel,
|
|
18681
18936
|
ticket,
|
|
18682
18937
|
() => this.context.issueTimeTicket()
|
|
18683
18938
|
);
|
|
18939
|
+
this.context.acc(diff);
|
|
18684
18940
|
for (const pair of pairs) {
|
|
18685
18941
|
this.context.registerGCPair(pair);
|
|
18686
18942
|
}
|
|
@@ -19255,6 +19511,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
19255
19511
|
__publicField(this, "changeID");
|
|
19256
19512
|
__publicField(this, "checkpoint");
|
|
19257
19513
|
__publicField(this, "localChanges");
|
|
19514
|
+
__publicField(this, "maxSizeLimit");
|
|
19258
19515
|
__publicField(this, "root");
|
|
19259
19516
|
__publicField(this, "clone");
|
|
19260
19517
|
__publicField(this, "eventStream");
|
|
@@ -19287,6 +19544,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
19287
19544
|
this.changeID = InitialChangeID;
|
|
19288
19545
|
this.checkpoint = InitialCheckpoint;
|
|
19289
19546
|
this.localChanges = [];
|
|
19547
|
+
this.maxSizeLimit = 0;
|
|
19290
19548
|
this.eventStream = createObservable((observer) => {
|
|
19291
19549
|
this.eventStreamObserver = observer;
|
|
19292
19550
|
});
|
|
@@ -19306,6 +19564,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
19306
19564
|
* `update` executes the given updater to update this document.
|
|
19307
19565
|
*/
|
|
19308
19566
|
update(updater, message) {
|
|
19567
|
+
var _a2;
|
|
19309
19568
|
if (this.getStatus() === "removed") {
|
|
19310
19569
|
throw new YorkieError(Code.ErrDocumentRemoved, `${this.key} is removed`);
|
|
19311
19570
|
}
|
|
@@ -19336,6 +19595,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
19336
19595
|
} finally {
|
|
19337
19596
|
this.isUpdating = false;
|
|
19338
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
|
+
}
|
|
19339
19606
|
if (context.hasChange()) {
|
|
19340
19607
|
if (logger.isEnabled(LogLevel.Trivial)) {
|
|
19341
19608
|
logger.trivial(`trying to update a local change: ${this.toJSON()}`);
|
|
@@ -19730,7 +19997,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
19730
19997
|
return this.status;
|
|
19731
19998
|
}
|
|
19732
19999
|
/**
|
|
19733
|
-
* `getClone`
|
|
20000
|
+
* `getClone` returns this clone.
|
|
20001
|
+
*/
|
|
20002
|
+
getClone() {
|
|
20003
|
+
return this.clone;
|
|
20004
|
+
}
|
|
20005
|
+
/**
|
|
20006
|
+
* `getCloneRoot` returns clone object.
|
|
19734
20007
|
*
|
|
19735
20008
|
* @internal
|
|
19736
20009
|
*/
|
|
@@ -19758,6 +20031,18 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
19758
20031
|
getDocSize() {
|
|
19759
20032
|
return this.root.getDocSize();
|
|
19760
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
|
+
}
|
|
19761
20046
|
/**
|
|
19762
20047
|
* `garbageCollect` purges elements that were removed before the given time.
|
|
19763
20048
|
*
|
|
@@ -20459,7 +20744,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
20459
20744
|
};
|
|
20460
20745
|
}
|
|
20461
20746
|
const name = "@yorkie-js/sdk";
|
|
20462
|
-
const version = "0.6.
|
|
20747
|
+
const version = "0.6.13";
|
|
20463
20748
|
const pkg = {
|
|
20464
20749
|
name,
|
|
20465
20750
|
version
|
|
@@ -20689,6 +20974,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
20689
20974
|
},
|
|
20690
20975
|
{ headers: { "x-shard-key": `${this.apiKey}/${doc.getKey()}` } }
|
|
20691
20976
|
);
|
|
20977
|
+
const maxSize = res.maxSizePerDocument ?? 0;
|
|
20978
|
+
if (maxSize > 0) {
|
|
20979
|
+
doc.setMaxSizePerDocument(res.maxSizePerDocument);
|
|
20980
|
+
}
|
|
20692
20981
|
const pack = converter.fromChangePack(res.changePack);
|
|
20693
20982
|
doc.applyChangePack(pack);
|
|
20694
20983
|
if (doc.getStatus() === DocStatus.Removed) {
|