@yorkie-js/sdk 0.6.41-rc2 → 0.6.41

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.
@@ -281,6 +281,7 @@ export declare class Change<P extends Indexable> {
281
281
  * `execute` executes the operations of this change to the given root.
282
282
  */
283
283
  execute(root: CRDTRoot, presences: Map<ActorID, P>, source: OpSource): {
284
+ operations: Array<Operation>;
284
285
  opInfos: Array<OpInfo>;
285
286
  reverseOps: Array<HistoryOperation<P>>;
286
287
  };
@@ -1712,7 +1713,13 @@ declare class CRDTText<A extends Indexable = Indexable> extends CRDTElement {
1712
1713
  /**
1713
1714
  * `edit` edits the given range with the given value and attributes.
1714
1715
  */
1715
- edit(range: RGATreeSplitPosRange, content: string, editedAt: TimeTicket, attributes?: Record<string, string>, versionVector?: VersionVector): [Array<TextChange<A>>, Array<GCPair>, DataSize, RGATreeSplitPosRange];
1716
+ edit(range: RGATreeSplitPosRange, content: string, editedAt: TimeTicket, attributes?: Record<string, string>, versionVector?: VersionVector): [
1717
+ Array<TextChange<A>>,
1718
+ Array<GCPair>,
1719
+ DataSize,
1720
+ RGATreeSplitPosRange,
1721
+ Array<CRDTTextValue>
1722
+ ];
1716
1723
  /**
1717
1724
  * `setStyle` applies the style of the given range.
1718
1725
  * 01. split nodes with from and to
@@ -1739,6 +1746,14 @@ declare class CRDTText<A extends Indexable = Indexable> extends CRDTElement {
1739
1746
  * `getTreeByID` returns the tree by ID for debugging.
1740
1747
  */
1741
1748
  getTreeByID(): LLRBTree<RGATreeSplitNodeID, RGATreeSplitNode<CRDTTextValue>>;
1749
+ /**
1750
+ * `refinePos` refines the given RGATreeSplitPos.
1751
+ */
1752
+ refinePos(pos: RGATreeSplitPos): RGATreeSplitPos;
1753
+ /**
1754
+ * `normalizePos` normalizes the given RGATreeSplitPos.
1755
+ */
1756
+ normalizePos(pos: RGATreeSplitPos): RGATreeSplitPos;
1742
1757
  /**
1743
1758
  * `getDataSize` returns the data usage of this element.
1744
1759
  */
@@ -1780,6 +1795,10 @@ declare class CRDTText<A extends Indexable = Indexable> extends CRDTElement {
1780
1795
  * `findIndexesFromRange` returns pair of integer offsets of the given range.
1781
1796
  */
1782
1797
  findIndexesFromRange(range: RGATreeSplitPosRange): [number, number];
1798
+ /**
1799
+ * `posToIndex` converts the given position to index.
1800
+ */
1801
+ posToIndex(pos: RGATreeSplitPos, preferToLeft?: boolean): number;
1783
1802
  /**
1784
1803
  * `getGCPairs` returns the pairs of GC.
1785
1804
  */
@@ -2895,6 +2914,7 @@ declare class Document_2<R, P extends Indexable = Indexable> implements Attachab
2895
2914
  * `applySnapshot` applies the given snapshot into this document.
2896
2915
  */
2897
2916
  applySnapshot(serverSeq: bigint, snapshotVector: VersionVector, snapshot?: Uint8Array, clientSeq?: number): void;
2917
+ private clearHistory;
2898
2918
  /**
2899
2919
  * `applyChanges` applies the given changes into this document.
2900
2920
  */
@@ -4534,9 +4554,13 @@ export declare type PanelToSDKMessage =
4534
4554
  * ```typescript
4535
4555
  * const data = parse('{"content":Text([{"val":"Hi"}])}');
4536
4556
  * // { content: { type: 'Text', nodes: [{ val: 'Hi' }] } }
4557
+ *
4558
+ * // With type parameter:
4559
+ * const data = parse<{ content: YSONText }>('{"content":Text([{"val":"Hi"}])}');
4560
+ * // data.content is now typed as YSONText
4537
4561
  * ```
4538
4562
  */
4539
- declare function parse(yson: string): YSONValue {
4563
+ declare function parse<T = YSONValue>(yson: string): T {
4540
4564
  try {
4541
4565
  // Preprocess YSON string to handle special types
4542
4566
  const processed = preprocessYSON(yson);
@@ -4545,7 +4569,7 @@ declare function parse(yson: string): YSONValue {
4545
4569
  const parsed = JSON.parse(processed);
4546
4570
 
4547
4571
  // Post-process to restore type information
4548
- return postprocessValue(parsed);
4572
+ return postprocessValue(parsed) as T;
4549
4573
  } catch (err) {
4550
4574
  throw new YorkieError(
4551
4575
  Code.ErrInvalidArgument,
@@ -4940,9 +4964,15 @@ declare class RGATreeSplit<T extends RGATreeSplitValue> implements GCParent {
4940
4964
  * @param range - range of RGATreeSplitNode
4941
4965
  * @param editedAt - edited time
4942
4966
  * @param value - value
4943
- * @returns `[RGATreeSplitPos, Array<GCPair>, Array<Change>]`
4944
- */
4945
- edit(range: RGATreeSplitPosRange, editedAt: TimeTicket, value?: T, versionVector?: VersionVector): [RGATreeSplitPos, Array<GCPair>, DataSize, Array<ValueChange<T>>];
4967
+ * @returns `[RGATreeSplitPos, Array<GCPair>, DataSize, Array<ValueChange<T>>, Array<T>]`
4968
+ */
4969
+ edit(range: RGATreeSplitPosRange, editedAt: TimeTicket, value?: T, versionVector?: VersionVector): [
4970
+ RGATreeSplitPos,
4971
+ Array<GCPair>,
4972
+ DataSize,
4973
+ Array<ValueChange<T>>,
4974
+ Array<T>
4975
+ ];
4946
4976
  /**
4947
4977
  * `indexToPos` finds RGATreeSplitPos of given offset.
4948
4978
  */
@@ -4984,6 +5014,32 @@ declare class RGATreeSplit<T extends RGATreeSplitValue> implements GCParent {
4984
5014
  * `deepcopy` copies itself deeply.
4985
5015
  */
4986
5016
  deepcopy(): RGATreeSplit<T>;
5017
+ /**
5018
+ * `normalizePos` converts a local position `(id, rel)` into a single
5019
+ * absolute offset measured from the head `(0:0)` of the physical chain.
5020
+ */
5021
+ normalizePos(pos: RGATreeSplitPos): RGATreeSplitPos;
5022
+ /**
5023
+ * `refinePos` remaps the given pos to the current split chain.
5024
+ *
5025
+ * - Traverses the physical `next` chain (not `insNext`).
5026
+ * - Counts only live characters: removed nodes are treated as length 0.
5027
+ * - If the given offset exceeds the length of the current node,
5028
+ * it moves forward through `next` nodes, subtracting lengths,
5029
+ * until the offset fits in a live node.
5030
+ * - If it runs out of nodes, it snaps to the end of the last node.
5031
+ *
5032
+ * Example:
5033
+ * Before split: ["12345"](1:2:0), pos = (1:2:0, rel=5)
5034
+ * After split : ["1"](1:2:0) - ["23"](1:2:1) - ["45"](1:2:3)
5035
+ * refinePos(pos) -> (1:2:3, rel=2)
5036
+ *
5037
+ * Example:
5038
+ * ["12"](1:2:0, live) and pos = (1:2:0, rel=4)
5039
+ * refinePos(pos) -> points two chars after "12",
5040
+ * i.e. advances into following nodes, skipping removed ones.
5041
+ */
5042
+ refinePos(pos: RGATreeSplitPos): RGATreeSplitPos;
4987
5043
  /**
4988
5044
  * `toTestString` returns a String containing the meta data of the node
4989
5045
  * for debugging purpose.
@@ -6752,15 +6808,15 @@ export declare type WrappedElement<T = unknown, A extends Indexable = Indexable>
6752
6808
  declare namespace YSON {
6753
6809
  export {
6754
6810
  YSONValue,
6755
- YSONText,
6756
- YSONTree,
6757
- YSONTextNode,
6758
- YSONTreeNode,
6759
- YSONInt,
6760
- YSONLong,
6761
- YSONDate,
6762
- YSONBinData,
6763
- YSONCounter,
6811
+ YSONText as Text,
6812
+ YSONTree as Tree,
6813
+ YSONTextNode as TextNode,
6814
+ YSONTreeNode as TreeNode,
6815
+ YSONInt as Int,
6816
+ YSONLong as Long,
6817
+ YSONDate as Date,
6818
+ YSONBinData as BinData,
6819
+ YSONCounter as Counter,
6764
6820
  isText,
6765
6821
  isTree,
6766
6822
  isInt,
@@ -6774,6 +6830,7 @@ declare namespace YSON {
6774
6830
  treeToXML
6775
6831
  }
6776
6832
  }
6833
+ export { YSON }
6777
6834
 
6778
6835
  /**
6779
6836
  * `YSONBinData` represents Base64-encoded binary data.