@yorkie-js/sdk 0.7.4 → 0.7.6
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/counter.html +1 -1
- package/dist/multi.html +1 -1
- package/dist/yorkie-js-sdk.d.ts +141 -40
- package/dist/yorkie-js-sdk.es.js +1856 -1300
- package/dist/yorkie-js-sdk.es.js.map +1 -1
- package/dist/yorkie-js-sdk.js +1838 -1282
- package/dist/yorkie-js-sdk.js.map +1 -1
- package/package.json +2 -4
package/dist/counter.html
CHANGED
package/dist/multi.html
CHANGED
package/dist/yorkie-js-sdk.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { default as default_2 } from 'long';
|
|
2
|
-
import { default as Long_2 } from 'long';
|
|
3
1
|
import { Message } from '@bufbuild/protobuf';
|
|
4
2
|
import { Rule } from '@yorkie-js/schema';
|
|
5
3
|
import { Timestamp } from '@bufbuild/protobuf/wkt';
|
|
@@ -166,6 +164,38 @@ declare interface AuthErrorEvent_3 {
|
|
|
166
164
|
|
|
167
165
|
declare type BaseArray<T> = JSONArray<T> | Array<T>;
|
|
168
166
|
|
|
167
|
+
/**
|
|
168
|
+
* `BaseCounter` is an internal base that holds the shared state and
|
|
169
|
+
* initialization logic for Counter and DedupCounter. Not exported.
|
|
170
|
+
*/
|
|
171
|
+
declare class BaseCounter {
|
|
172
|
+
protected valueType: CounterType;
|
|
173
|
+
protected value: number | bigint;
|
|
174
|
+
protected context?: ChangeContext;
|
|
175
|
+
protected counter?: CRDTCounter;
|
|
176
|
+
constructor(valueType: CounterType, value: number | bigint);
|
|
177
|
+
/**
|
|
178
|
+
* `initialize` links this proxy to a ChangeContext and CRDTCounter.
|
|
179
|
+
*/
|
|
180
|
+
initialize(context: ChangeContext, counter: CRDTCounter): void;
|
|
181
|
+
/**
|
|
182
|
+
* `getID` returns the ID of this counter.
|
|
183
|
+
*/
|
|
184
|
+
getID(): TimeTicket;
|
|
185
|
+
/**
|
|
186
|
+
* `getValueType` returns the value type of this counter.
|
|
187
|
+
*/
|
|
188
|
+
getValueType(): CounterType;
|
|
189
|
+
/**
|
|
190
|
+
* `toJSForTest` returns value with meta data for testing.
|
|
191
|
+
*/
|
|
192
|
+
toJSForTest(): Devtools.JSONElement;
|
|
193
|
+
/**
|
|
194
|
+
* `ensureInitialized` throws if this counter has not been initialized.
|
|
195
|
+
*/
|
|
196
|
+
protected ensureInitialized(): void;
|
|
197
|
+
}
|
|
198
|
+
|
|
169
199
|
declare interface BaseDocEvent {
|
|
170
200
|
type: DocEventType_2;
|
|
171
201
|
}
|
|
@@ -930,6 +960,7 @@ export declare class Client {
|
|
|
930
960
|
private taskQueue;
|
|
931
961
|
private processing;
|
|
932
962
|
private keepalive;
|
|
963
|
+
private deactivating;
|
|
933
964
|
/**
|
|
934
965
|
* @param rpcAddr - the address of the RPC server.
|
|
935
966
|
* @param opts - the options of the client.
|
|
@@ -1183,6 +1214,12 @@ export declare interface ClientOptions {
|
|
|
1183
1214
|
* client.
|
|
1184
1215
|
*/
|
|
1185
1216
|
userAgent?: string;
|
|
1217
|
+
/**
|
|
1218
|
+
* `useGrpcWebTransport` determines the transport protocol.
|
|
1219
|
+
* If true, uses gRPC-Web transport for backward compatibility.
|
|
1220
|
+
* If false (default), uses Connect Protocol transport.
|
|
1221
|
+
*/
|
|
1222
|
+
useGrpcWebTransport?: boolean;
|
|
1186
1223
|
}
|
|
1187
1224
|
|
|
1188
1225
|
/**
|
|
@@ -1261,38 +1298,25 @@ export declare const converter: {
|
|
|
1261
1298
|
};
|
|
1262
1299
|
|
|
1263
1300
|
/**
|
|
1264
|
-
* `Counter` is a
|
|
1301
|
+
* `Counter` is a numeric counter that supports `increase()`.
|
|
1302
|
+
* For counting unique actors, use `DedupCounter` instead.
|
|
1303
|
+
*
|
|
1304
|
+
* ```typescript
|
|
1305
|
+
* // Type is inferred from value:
|
|
1306
|
+
* root.count = new Counter(0); // Int
|
|
1307
|
+
* root.count = new Counter(0n); // Long
|
|
1308
|
+
* ```
|
|
1265
1309
|
*/
|
|
1266
|
-
export declare class Counter {
|
|
1267
|
-
|
|
1268
|
-
private value;
|
|
1269
|
-
private context?;
|
|
1270
|
-
private counter?;
|
|
1271
|
-
constructor(valueType: CounterType, value: number | default_2);
|
|
1272
|
-
/**
|
|
1273
|
-
* `initialize` initialize this text with context and internal text.
|
|
1274
|
-
*/
|
|
1275
|
-
initialize(context: ChangeContext, counter: CRDTCounter): void;
|
|
1276
|
-
/**
|
|
1277
|
-
* `getID` returns the ID of this text.
|
|
1278
|
-
*/
|
|
1279
|
-
getID(): TimeTicket;
|
|
1310
|
+
export declare class Counter extends BaseCounter {
|
|
1311
|
+
constructor(value: number | bigint);
|
|
1280
1312
|
/**
|
|
1281
|
-
* `getValue` returns the value of this counter
|
|
1313
|
+
* `getValue` returns the value of this counter.
|
|
1282
1314
|
*/
|
|
1283
|
-
getValue(): number |
|
|
1284
|
-
/**
|
|
1285
|
-
* `getValueType` returns the value type of this counter.
|
|
1286
|
-
*/
|
|
1287
|
-
getValueType(): CounterType;
|
|
1315
|
+
getValue(): number | bigint;
|
|
1288
1316
|
/**
|
|
1289
1317
|
* `increase` increases numeric data.
|
|
1290
1318
|
*/
|
|
1291
|
-
increase(v: number |
|
|
1292
|
-
/**
|
|
1293
|
-
* `toJSForTest` returns value with meta data for testing.
|
|
1294
|
-
*/
|
|
1295
|
-
toJSForTest(): Devtools.JSONElement;
|
|
1319
|
+
increase(v: number | bigint): Counter;
|
|
1296
1320
|
}
|
|
1297
1321
|
|
|
1298
1322
|
/**
|
|
@@ -1307,12 +1331,13 @@ declare type CounterOpInfo_2 = IncreaseOpInfo_2;
|
|
|
1307
1331
|
|
|
1308
1332
|
export declare enum CounterType {
|
|
1309
1333
|
Int = 0,
|
|
1310
|
-
Long = 1
|
|
1334
|
+
Long = 1,
|
|
1335
|
+
IntDedup = 2
|
|
1311
1336
|
}
|
|
1312
1337
|
|
|
1313
|
-
export declare type CounterValue = number |
|
|
1338
|
+
export declare type CounterValue = number | bigint;
|
|
1314
1339
|
|
|
1315
|
-
declare type CounterValue_2 = number |
|
|
1340
|
+
declare type CounterValue_2 = number | bigint;
|
|
1316
1341
|
|
|
1317
1342
|
/**
|
|
1318
1343
|
*
|
|
@@ -1347,6 +1372,7 @@ declare abstract class CRDTContainer extends CRDTElement {
|
|
|
1347
1372
|
declare class CRDTCounter extends CRDTElement {
|
|
1348
1373
|
private valueType;
|
|
1349
1374
|
private value;
|
|
1375
|
+
private hll?;
|
|
1350
1376
|
constructor(valueType: CounterType, value: CounterValue, createdAt: TimeTicket);
|
|
1351
1377
|
/**
|
|
1352
1378
|
* `of` creates a new instance of Counter.
|
|
@@ -1408,8 +1434,30 @@ declare class CRDTCounter extends CRDTElement {
|
|
|
1408
1434
|
* `toBytes` creates an array representing the value.
|
|
1409
1435
|
*/
|
|
1410
1436
|
toBytes(): Uint8Array;
|
|
1437
|
+
/**
|
|
1438
|
+
* `isDedup` returns whether dedup mode is enabled (derived from ValueType).
|
|
1439
|
+
*/
|
|
1440
|
+
isDedup(): boolean;
|
|
1441
|
+
/**
|
|
1442
|
+
* `increaseDedup` increases the counter using HLL-based dedup.
|
|
1443
|
+
* Only updates the value if the actor is new (not seen before).
|
|
1444
|
+
*/
|
|
1445
|
+
increaseDedup(v: Primitive, actor: string): CRDTCounter;
|
|
1446
|
+
/**
|
|
1447
|
+
* `hllBytes` returns the HLL register bytes, or undefined if not in dedup mode.
|
|
1448
|
+
*/
|
|
1449
|
+
hllBytes(): Uint8Array | undefined;
|
|
1450
|
+
/**
|
|
1451
|
+
* `restoreHLL` restores the HLL state from serialized bytes.
|
|
1452
|
+
*/
|
|
1453
|
+
restoreHLL(data: Uint8Array): void;
|
|
1454
|
+
/**
|
|
1455
|
+
* `recomputeValue` updates the counter value from the HLL cardinality estimate.
|
|
1456
|
+
*/
|
|
1457
|
+
private recomputeValue;
|
|
1411
1458
|
/**
|
|
1412
1459
|
* `increase` increases numeric data.
|
|
1460
|
+
* Dedup counters must use increaseDedup() instead.
|
|
1413
1461
|
*/
|
|
1414
1462
|
increase(v: Primitive): CRDTCounter;
|
|
1415
1463
|
}
|
|
@@ -1934,11 +1982,17 @@ declare class CRDTTree extends CRDTElement implements GCParent {
|
|
|
1934
1982
|
*/
|
|
1935
1983
|
style(range: [CRDTTreePos, CRDTTreePos], attributes: {
|
|
1936
1984
|
[key: string]: string;
|
|
1937
|
-
} | undefined, editedAt: TimeTicket, versionVector?: VersionVector): [
|
|
1985
|
+
} | undefined, editedAt: TimeTicket, versionVector?: VersionVector): [
|
|
1986
|
+
Array<GCPair>,
|
|
1987
|
+
Array<TreeChange>,
|
|
1988
|
+
DataSize,
|
|
1989
|
+
Map<string, string>,
|
|
1990
|
+
Array<string>
|
|
1991
|
+
];
|
|
1938
1992
|
/**
|
|
1939
1993
|
* `removeStyle` removes the given attributes of the given range.
|
|
1940
1994
|
*/
|
|
1941
|
-
removeStyle(range: [CRDTTreePos, CRDTTreePos], attributesToRemove: Array<string>, editedAt: TimeTicket, versionVector?: VersionVector): [Array<GCPair>, Array<TreeChange>, DataSize];
|
|
1995
|
+
removeStyle(range: [CRDTTreePos, CRDTTreePos], attributesToRemove: Array<string>, editedAt: TimeTicket, versionVector?: VersionVector): [Array<GCPair>, Array<TreeChange>, DataSize, Map<string, string>];
|
|
1942
1996
|
/**
|
|
1943
1997
|
* `edit` edits the tree with the given range and content.
|
|
1944
1998
|
* If the content is undefined, the range will be removed.
|
|
@@ -2388,6 +2442,32 @@ declare interface DeactivateOptions {
|
|
|
2388
2442
|
*/
|
|
2389
2443
|
declare type DecreasedDepthOf<Depth extends number> = Depth extends 10 ? 9 : Depth extends 9 ? 8 : Depth extends 8 ? 7 : Depth extends 7 ? 6 : Depth extends 6 ? 5 : Depth extends 5 ? 4 : Depth extends 4 ? 3 : Depth extends 3 ? 2 : Depth extends 2 ? 1 : Depth extends 1 ? 0 : -1;
|
|
2390
2444
|
|
|
2445
|
+
/**
|
|
2446
|
+
* `DedupCounter` is a Counter that uses HyperLogLog to count unique actors.
|
|
2447
|
+
* Use `add(actor)` to record a unique visitor. Provides approximate counts
|
|
2448
|
+
* with ~2% error rate.
|
|
2449
|
+
*
|
|
2450
|
+
* ```typescript
|
|
2451
|
+
* doc.update((root) => {
|
|
2452
|
+
* root.uv = new yorkie.DedupCounter();
|
|
2453
|
+
* root.uv.add(userId);
|
|
2454
|
+
* });
|
|
2455
|
+
* ```
|
|
2456
|
+
*/
|
|
2457
|
+
export declare class DedupCounter extends BaseCounter {
|
|
2458
|
+
constructor();
|
|
2459
|
+
/**
|
|
2460
|
+
* `getValue` returns the value of this counter. Always a number since
|
|
2461
|
+
* DedupCounter only supports IntDedup.
|
|
2462
|
+
*/
|
|
2463
|
+
getValue(): number;
|
|
2464
|
+
/**
|
|
2465
|
+
* `add` records a unique actor in the dedup counter. If the actor has
|
|
2466
|
+
* already been counted, the call is ignored.
|
|
2467
|
+
*/
|
|
2468
|
+
add(actor: string): DedupCounter;
|
|
2469
|
+
}
|
|
2470
|
+
|
|
2391
2471
|
/**
|
|
2392
2472
|
* The top-level yorkie namespace with additional properties.
|
|
2393
2473
|
*
|
|
@@ -2402,6 +2482,7 @@ declare const _default: {
|
|
|
2402
2482
|
Primitive: typeof Primitive;
|
|
2403
2483
|
Text: typeof Text_2;
|
|
2404
2484
|
Counter: typeof Counter;
|
|
2485
|
+
DedupCounter: typeof DedupCounter;
|
|
2405
2486
|
Tree: typeof Tree;
|
|
2406
2487
|
Devtools: typeof Devtools;
|
|
2407
2488
|
Channel: typeof Channel;
|
|
@@ -2409,8 +2490,6 @@ declare const _default: {
|
|
|
2409
2490
|
YSON: typeof YSON;
|
|
2410
2491
|
LogLevel: typeof LogLevel;
|
|
2411
2492
|
setLogLevel: typeof setLogLevel;
|
|
2412
|
-
IntType: CounterType;
|
|
2413
|
-
LongType: CounterType;
|
|
2414
2493
|
};
|
|
2415
2494
|
export default _default;
|
|
2416
2495
|
|
|
@@ -3001,6 +3080,20 @@ declare class Document_2<R, P extends Indexable = Indexable> implements Attachab
|
|
|
3001
3080
|
* `removeOnlineClient` removes the clientID from the online client set.
|
|
3002
3081
|
*/
|
|
3003
3082
|
removeOnlineClient(clientID: ActorID): void;
|
|
3083
|
+
/**
|
|
3084
|
+
* `reconcilePresence` compares the previous and current state of a client's
|
|
3085
|
+
* presence/online status and returns the appropriate event to emit.
|
|
3086
|
+
*
|
|
3087
|
+
* For remote clients, "online" means the client is in onlineClients.
|
|
3088
|
+
* For self, "online" means the document status is Attached.
|
|
3089
|
+
*
|
|
3090
|
+
* State transition table:
|
|
3091
|
+
* (!hadP || !wasOn) → (hasP && isOn) : watched (remote) or presence-changed (self)
|
|
3092
|
+
* (hadP && wasOn) → (hasP && isOn) : presence-changed
|
|
3093
|
+
* (hadP && wasOn) → (!hasP || !isOn): unwatched (remote only)
|
|
3094
|
+
* otherwise : no event (waiting)
|
|
3095
|
+
*/
|
|
3096
|
+
private reconcilePresence;
|
|
3004
3097
|
/**
|
|
3005
3098
|
* `hasPresence` returns whether the given clientID has a presence or not.
|
|
3006
3099
|
*/
|
|
@@ -3818,7 +3911,7 @@ declare type JsonArray_2 = Array<Json_2>;
|
|
|
3818
3911
|
* `JSONElement` is a wrapper for `CRDTElement` that provides users with an
|
|
3819
3912
|
* easy-to-use interface for manipulating `Document`s.
|
|
3820
3913
|
*/
|
|
3821
|
-
export declare type JSONElement<T = unknown, A extends Indexable = Indexable> = PrimitiveValue | JSONObject<T> | JSONArray<T> | Text_2<A> | Counter | Tree;
|
|
3914
|
+
export declare type JSONElement<T = unknown, A extends Indexable = Indexable> = PrimitiveValue | JSONObject<T> | JSONArray<T> | Text_2<A> | Counter | DedupCounter | Tree;
|
|
3822
3915
|
|
|
3823
3916
|
/**
|
|
3824
3917
|
* `JSONElement` represents the result of `Element.toJSForTest()`.
|
|
@@ -4350,6 +4443,10 @@ declare type Operation_Increase = Message<"yorkie.v1.Operation.Increase"> & {
|
|
|
4350
4443
|
* @generated from field: yorkie.v1.TimeTicket executed_at = 3;
|
|
4351
4444
|
*/
|
|
4352
4445
|
executedAt?: TimeTicket_2;
|
|
4446
|
+
/**
|
|
4447
|
+
* @generated from field: string actor = 4;
|
|
4448
|
+
*/
|
|
4449
|
+
actor: string;
|
|
4353
4450
|
};
|
|
4354
4451
|
|
|
4355
4452
|
/**
|
|
@@ -4893,7 +4990,7 @@ declare enum PrimitiveType {
|
|
|
4893
4990
|
* `PrimitiveValue` represents a value of primitive type. Only values of type
|
|
4894
4991
|
* included in `PrimitiveValue` can be set to the document.
|
|
4895
4992
|
*/
|
|
4896
|
-
export declare type PrimitiveValue = null | boolean | number |
|
|
4993
|
+
export declare type PrimitiveValue = null | boolean | number | bigint | string | Uint8Array | Date;
|
|
4897
4994
|
|
|
4898
4995
|
/**
|
|
4899
4996
|
* `PrimitiveValue` represents a value of primitive type. Only values of type
|
|
@@ -4901,7 +4998,7 @@ export declare type PrimitiveValue = null | boolean | number | default_2 | strin
|
|
|
4901
4998
|
*/
|
|
4902
4999
|
declare type PrimitiveValue_2 =
|
|
4903
5000
|
// eslint-disable-next-line @typescript-eslint/no-restricted-types
|
|
4904
|
-
null | boolean | number |
|
|
5001
|
+
null | boolean | number | bigint | string | Uint8Array | Date;
|
|
4905
5002
|
|
|
4906
5003
|
/**
|
|
4907
5004
|
* `RemoteChangeEvent` is an event that occurs when the document is changed
|
|
@@ -6814,7 +6911,11 @@ declare enum ValueType {
|
|
|
6814
6911
|
/**
|
|
6815
6912
|
* @generated from enum value: VALUE_TYPE_TREE = 13;
|
|
6816
6913
|
*/
|
|
6817
|
-
TREE = 13
|
|
6914
|
+
TREE = 13,
|
|
6915
|
+
/**
|
|
6916
|
+
* @generated from enum value: VALUE_TYPE_INTEGER_DEDUP_CNT = 14;
|
|
6917
|
+
*/
|
|
6918
|
+
INTEGER_DEDUP_CNT = 14
|
|
6818
6919
|
}
|
|
6819
6920
|
|
|
6820
6921
|
/**
|
|
@@ -6904,7 +7005,7 @@ declare interface WatchedEvent_2<P extends Indexable_2> extends BaseDocEvent {
|
|
|
6904
7005
|
/**
|
|
6905
7006
|
* `WrappedElement` is a wrapper of JSONElement that provides `getID()`.
|
|
6906
7007
|
*/
|
|
6907
|
-
export declare type WrappedElement<T = unknown, A extends Indexable = Indexable> = Primitive | JSONObject<T> | JSONArray<T> | Text_2<A> | Counter | Tree;
|
|
7008
|
+
export declare type WrappedElement<T = unknown, A extends Indexable = Indexable> = Primitive | JSONObject<T> | JSONArray<T> | Text_2<A> | Counter | DedupCounter | Tree;
|
|
6908
7009
|
|
|
6909
7010
|
declare namespace YSON {
|
|
6910
7011
|
export {
|