@yorkie-js/sdk 0.6.22 → 0.6.24

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.
@@ -1,7 +1,4 @@
1
- const objectDevtool = (
2
- doc,
3
- { rootHolder, opsHolder, undoOpsHolder, redoOpsHolder },
4
- ) => {
1
+ const objectDevtool = (doc, { rootHolder, undoOpsHolder, redoOpsHolder }) => {
5
2
  const displayRootObject = () => {
6
3
  const rootObj = doc.getRoot().toJSForTest();
7
4
  rootHolder.innerHTML = `
@@ -87,7 +84,7 @@ const objectDevtool = (
87
84
  <span class="type ${opType.toLowerCase()}">${opType}</span>
88
85
  ${`<span class="timeticket">${id}</span>`}${op.toTestString()}
89
86
  </span>`;
90
- } catch (e) {
87
+ } catch {
91
88
  // operation in the undo/redo stack does not yet have "executedAt" set.
92
89
  return `
93
90
  <span class="op">
@@ -1,5 +1,5 @@
1
- /* eslint-env browser */
2
- /* eslint-disable jsdoc/require-jsdoc*/
1
+ /* global document, setTimeout, clearTimeout, window -- defined by browser */
2
+ /* global panzoom -- defined by panzoom */
3
3
 
4
4
  (function (global) {
5
5
  // TODO(hackerwins): Remove direct dependency on the document.
@@ -63,7 +63,7 @@
63
63
  structureTextHolder.innerHTML = contentString;
64
64
 
65
65
  // Make textItems to blockList
66
- const textItems = [...contentString.matchAll(/(\[[^\]]*\]|\{[^\}]*})/g)];
66
+ const textItems = [...contentString.matchAll(/(\[[^\]]*\]|\{[^}]*})/g)];
67
67
  let textOffset = 0;
68
68
  for (const item of textItems) {
69
69
  let block = null;
@@ -74,7 +74,7 @@
74
74
  blockKeys[block.time] = block;
75
75
  } else {
76
76
  // deleted block
77
- block = getDeleteBlock(item[0].match(/\{([^\}]*)\}/));
77
+ block = getDeleteBlock(item[0].match(/\{([^}]*)\}/));
78
78
  }
79
79
  blockList.push(block);
80
80
  }
@@ -318,6 +318,7 @@
318
318
  }
319
319
  }
320
320
 
321
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
321
322
  function calculateAbsolutePosition(type, node, startX = 0, endX = 0) {
322
323
  if (!node) {
323
324
  return;
package/dist/util.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * `Network` is a class that manages the network status.
3
3
  */
4
- class Network {
4
+ export class Network {
5
5
  constructor(elem) {
6
6
  this.isOnline = false;
7
7
  this.elem = elem;
@@ -47,12 +47,32 @@ declare type AddOpInfo_2 = {
47
47
  /**
48
48
  * `ArrayOperationInfo` represents the OperationInfo for the JSONArray.
49
49
  */
50
- export declare type ArrayOperationInfo = AddOpInfo | RemoveOpInfo | MoveOpInfo;
50
+ export declare type ArrayOperationInfo = AddOpInfo | RemoveOpInfo | MoveOpInfo | ArraySetOpInfo_2;
51
51
 
52
52
  /**
53
53
  * `ArrayOperationInfo` represents the OperationInfo for the JSONArray.
54
54
  */
55
- declare type ArrayOperationInfo_2 = AddOpInfo_2 | RemoveOpInfo_2 | MoveOpInfo_2;
55
+ declare type ArrayOperationInfo_2 =
56
+ | AddOpInfo_2
57
+ | RemoveOpInfo_2
58
+ | MoveOpInfo_2
59
+ | ArraySetOpInfo;
60
+
61
+ /**
62
+ * `ArraySetOpInfo` represents the information of the array set operation.
63
+ */
64
+ declare type ArraySetOpInfo = {
65
+ type: 'array-set';
66
+ path: string;
67
+ };
68
+
69
+ /**
70
+ * `ArraySetOpInfo` represents the information of the array set operation.
71
+ */
72
+ declare type ArraySetOpInfo_2 = {
73
+ type: 'array-set';
74
+ path: string;
75
+ };
56
76
 
57
77
  /**
58
78
  * `AttachOptions` are user-settable options used when attaching documents.
@@ -3195,6 +3215,14 @@ export declare type JSONArray<T> = {
3195
3215
  * `getLast` returns the last element of this array.
3196
3216
  */
3197
3217
  getLast?(): WrappedElement<T>;
3218
+ /**
3219
+ * `setValue` sets the given value at the given index.
3220
+ */
3221
+ setValue?(index: number, value: unknown): WrappedElement<T>;
3222
+ /**
3223
+ * `delete` deletes the element of the given index.
3224
+ */
3225
+ delete?(index: number): WrappedElement<T>;
3198
3226
  /**
3199
3227
  * `deleteByID` deletes the element of the given ID.
3200
3228
  */
@@ -3207,6 +3235,10 @@ export declare type JSONArray<T> = {
3207
3235
  * `insertAfter` inserts a value after the given previous element.
3208
3236
  */
3209
3237
  insertAfter?(prevID: TimeTicket, value: any): WrappedElement<T>;
3238
+ /**
3239
+ * `insertIntegerAfter` inserts a value after the given index.
3240
+ */
3241
+ insertIntegerAfter?(index: number, value: number): WrappedElement<T>;
3210
3242
  /**
3211
3243
  * `moveBefore` moves the element before the given next element.
3212
3244
  */
@@ -3215,6 +3247,10 @@ export declare type JSONArray<T> = {
3215
3247
  * `moveAfter` moves the element after the given previous element.
3216
3248
  */
3217
3249
  moveAfter?(prevID: TimeTicket, id: TimeTicket): void;
3250
+ /**
3251
+ * `moveAfterByIndex` moves the element after the given index.
3252
+ */
3253
+ moveAfterByIndex?(prevIndex: number, targetIndex: number): void;
3218
3254
  /**
3219
3255
  * `moveFront` moves the element before the first element.
3220
3256
  */
@@ -3657,12 +3693,6 @@ declare class Operation_2 extends Message<Operation_2> {
3657
3693
  */
3658
3694
  value: Operation_Edit;
3659
3695
  case: "edit";
3660
- } | {
3661
- /**
3662
- * @generated from field: yorkie.v1.Operation.Select select = 6;
3663
- */
3664
- value: Operation_Select;
3665
- case: "select";
3666
3696
  } | {
3667
3697
  /**
3668
3698
  * @generated from field: yorkie.v1.Operation.Style style = 7;
@@ -3897,41 +3927,6 @@ declare class Operation_Remove extends Message<Operation_Remove> {
3897
3927
  static equals(a: Operation_Remove | PlainMessage<Operation_Remove> | undefined, b: Operation_Remove | PlainMessage<Operation_Remove> | undefined): boolean;
3898
3928
  }
3899
3929
 
3900
- /**
3901
- * NOTE(hackerwins): Select Operation is not used in the current version.
3902
- * In the previous version, it was used to represent selection of Text.
3903
- * However, it has been replaced by Presence now. It is retained for backward
3904
- * compatibility purposes.
3905
- *
3906
- * @generated from message yorkie.v1.Operation.Select
3907
- */
3908
- declare class Operation_Select extends Message<Operation_Select> {
3909
- /**
3910
- * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1;
3911
- */
3912
- parentCreatedAt?: TimeTicket_2;
3913
- /**
3914
- * @generated from field: yorkie.v1.TextNodePos from = 2;
3915
- */
3916
- from?: TextNodePos;
3917
- /**
3918
- * @generated from field: yorkie.v1.TextNodePos to = 3;
3919
- */
3920
- to?: TextNodePos;
3921
- /**
3922
- * @generated from field: yorkie.v1.TimeTicket executed_at = 4;
3923
- */
3924
- executedAt?: TimeTicket_2;
3925
- constructor(data?: PartialMessage<Operation_Select>);
3926
- static readonly runtime: typeof proto3;
3927
- static readonly typeName = "yorkie.v1.Operation.Select";
3928
- static readonly fields: FieldList;
3929
- static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Operation_Select;
3930
- static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Operation_Select;
3931
- static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Operation_Select;
3932
- static equals(a: Operation_Select | PlainMessage<Operation_Select> | undefined, b: Operation_Select | PlainMessage<Operation_Select> | undefined): boolean;
3933
- }
3934
-
3935
3930
  /**
3936
3931
  * @generated from message yorkie.v1.Operation.Set
3937
3932
  */
@@ -4420,7 +4415,7 @@ export declare type PrimitiveValue = null | boolean | number | default_2 | strin
4420
4415
  * included in `PrimitiveValue` can be set to the document.
4421
4416
  */
4422
4417
  declare type PrimitiveValue_2 =
4423
- // eslint-disable-next-line @typescript-eslint/ban-types
4418
+ // eslint-disable-next-line @typescript-eslint/no-restricted-types
4424
4419
  null | boolean | number | Long_2 | string | Uint8Array | Date;
4425
4420
 
4426
4421
  /**