@fluidframework/legacy-dds 2.50.0-345060

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.
Files changed (140) hide show
  1. package/.eslintrc.cjs +11 -0
  2. package/.mocharc.cjs +12 -0
  3. package/CHANGELOG.md +13 -0
  4. package/LICENSE +21 -0
  5. package/api-extractor/api-extractor-lint-bundle.json +5 -0
  6. package/api-extractor/api-extractor-lint-legacy.cjs.json +5 -0
  7. package/api-extractor/api-extractor-lint-legacy.esm.json +5 -0
  8. package/api-extractor/api-extractor-lint-public.cjs.json +5 -0
  9. package/api-extractor/api-extractor-lint-public.esm.json +5 -0
  10. package/api-extractor/api-extractor.current.json +5 -0
  11. package/api-extractor/api-extractor.legacy.json +4 -0
  12. package/api-extractor-lint.json +4 -0
  13. package/api-extractor.json +4 -0
  14. package/api-report/legacy-dds.beta.api.md +9 -0
  15. package/api-report/legacy-dds.legacy.alpha.api.md +140 -0
  16. package/api-report/legacy-dds.legacy.public.api.md +9 -0
  17. package/api-report/legacy-dds.public.api.md +9 -0
  18. package/biome.jsonc +4 -0
  19. package/dist/array/index.d.ts +10 -0
  20. package/dist/array/index.d.ts.map +1 -0
  21. package/dist/array/index.js +16 -0
  22. package/dist/array/index.js.map +1 -0
  23. package/dist/array/interfaces.d.ts +142 -0
  24. package/dist/array/interfaces.d.ts.map +1 -0
  25. package/dist/array/interfaces.js +7 -0
  26. package/dist/array/interfaces.js.map +1 -0
  27. package/dist/array/sharedArray.d.ts +175 -0
  28. package/dist/array/sharedArray.d.ts.map +1 -0
  29. package/dist/array/sharedArray.js +652 -0
  30. package/dist/array/sharedArray.js.map +1 -0
  31. package/dist/array/sharedArrayFactory.d.ts +31 -0
  32. package/dist/array/sharedArrayFactory.d.ts.map +1 -0
  33. package/dist/array/sharedArrayFactory.js +61 -0
  34. package/dist/array/sharedArrayFactory.js.map +1 -0
  35. package/dist/array/sharedArrayOperations.d.ts +77 -0
  36. package/dist/array/sharedArrayOperations.d.ts.map +1 -0
  37. package/dist/array/sharedArrayOperations.js +19 -0
  38. package/dist/array/sharedArrayOperations.js.map +1 -0
  39. package/dist/array/sharedArrayRevertible.d.ts +17 -0
  40. package/dist/array/sharedArrayRevertible.d.ts.map +1 -0
  41. package/dist/array/sharedArrayRevertible.js +47 -0
  42. package/dist/array/sharedArrayRevertible.js.map +1 -0
  43. package/dist/index.d.ts +14 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +20 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/legacy.d.ts +31 -0
  48. package/dist/package.json +4 -0
  49. package/dist/packageVersion.d.ts +9 -0
  50. package/dist/packageVersion.d.ts.map +1 -0
  51. package/dist/packageVersion.js +12 -0
  52. package/dist/packageVersion.js.map +1 -0
  53. package/dist/public.d.ts +12 -0
  54. package/dist/signal/index.d.ts +7 -0
  55. package/dist/signal/index.d.ts.map +1 -0
  56. package/dist/signal/index.js +11 -0
  57. package/dist/signal/index.js.map +1 -0
  58. package/dist/signal/interfaces.d.ts +36 -0
  59. package/dist/signal/interfaces.d.ts.map +1 -0
  60. package/dist/signal/interfaces.js +7 -0
  61. package/dist/signal/interfaces.js.map +1 -0
  62. package/dist/signal/sharedSignal.d.ts +68 -0
  63. package/dist/signal/sharedSignal.d.ts.map +1 -0
  64. package/dist/signal/sharedSignal.js +122 -0
  65. package/dist/signal/sharedSignal.js.map +1 -0
  66. package/dist/signal/sharedSignalFactory.d.ts +24 -0
  67. package/dist/signal/sharedSignalFactory.d.ts.map +1 -0
  68. package/dist/signal/sharedSignalFactory.js +45 -0
  69. package/dist/signal/sharedSignalFactory.js.map +1 -0
  70. package/internal.d.ts +11 -0
  71. package/legacy.d.ts +11 -0
  72. package/lib/array/index.d.ts +10 -0
  73. package/lib/array/index.d.ts.map +1 -0
  74. package/lib/array/index.js +8 -0
  75. package/lib/array/index.js.map +1 -0
  76. package/lib/array/interfaces.d.ts +142 -0
  77. package/lib/array/interfaces.d.ts.map +1 -0
  78. package/lib/array/interfaces.js +6 -0
  79. package/lib/array/interfaces.js.map +1 -0
  80. package/lib/array/sharedArray.d.ts +175 -0
  81. package/lib/array/sharedArray.d.ts.map +1 -0
  82. package/lib/array/sharedArray.js +648 -0
  83. package/lib/array/sharedArray.js.map +1 -0
  84. package/lib/array/sharedArrayFactory.d.ts +31 -0
  85. package/lib/array/sharedArrayFactory.d.ts.map +1 -0
  86. package/lib/array/sharedArrayFactory.js +56 -0
  87. package/lib/array/sharedArrayFactory.js.map +1 -0
  88. package/lib/array/sharedArrayOperations.d.ts +77 -0
  89. package/lib/array/sharedArrayOperations.d.ts.map +1 -0
  90. package/lib/array/sharedArrayOperations.js +16 -0
  91. package/lib/array/sharedArrayOperations.js.map +1 -0
  92. package/lib/array/sharedArrayRevertible.d.ts +17 -0
  93. package/lib/array/sharedArrayRevertible.d.ts.map +1 -0
  94. package/lib/array/sharedArrayRevertible.js +43 -0
  95. package/lib/array/sharedArrayRevertible.js.map +1 -0
  96. package/lib/index.d.ts +14 -0
  97. package/lib/index.d.ts.map +1 -0
  98. package/lib/index.js +10 -0
  99. package/lib/index.js.map +1 -0
  100. package/lib/legacy.d.ts +31 -0
  101. package/lib/packageVersion.d.ts +9 -0
  102. package/lib/packageVersion.d.ts.map +1 -0
  103. package/lib/packageVersion.js +9 -0
  104. package/lib/packageVersion.js.map +1 -0
  105. package/lib/public.d.ts +12 -0
  106. package/lib/signal/index.d.ts +7 -0
  107. package/lib/signal/index.d.ts.map +1 -0
  108. package/lib/signal/index.js +6 -0
  109. package/lib/signal/index.js.map +1 -0
  110. package/lib/signal/interfaces.d.ts +36 -0
  111. package/lib/signal/interfaces.d.ts.map +1 -0
  112. package/lib/signal/interfaces.js +6 -0
  113. package/lib/signal/interfaces.js.map +1 -0
  114. package/lib/signal/sharedSignal.d.ts +68 -0
  115. package/lib/signal/sharedSignal.d.ts.map +1 -0
  116. package/lib/signal/sharedSignal.js +118 -0
  117. package/lib/signal/sharedSignal.js.map +1 -0
  118. package/lib/signal/sharedSignalFactory.d.ts +24 -0
  119. package/lib/signal/sharedSignalFactory.d.ts.map +1 -0
  120. package/lib/signal/sharedSignalFactory.js +41 -0
  121. package/lib/signal/sharedSignalFactory.js.map +1 -0
  122. package/lib/tsdoc-metadata.json +11 -0
  123. package/package.json +158 -0
  124. package/src/array/README.md +32 -0
  125. package/src/array/index.ts +28 -0
  126. package/src/array/interfaces.ts +169 -0
  127. package/src/array/sharedArray.ts +835 -0
  128. package/src/array/sharedArrayFactory.ts +88 -0
  129. package/src/array/sharedArrayOperations.ts +89 -0
  130. package/src/array/sharedArrayRevertible.ts +50 -0
  131. package/src/index.ts +32 -0
  132. package/src/packageVersion.ts +9 -0
  133. package/src/signal/README.md +25 -0
  134. package/src/signal/index.ts +12 -0
  135. package/src/signal/interfaces.ts +53 -0
  136. package/src/signal/sharedSignal.ts +169 -0
  137. package/src/signal/sharedSignalFactory.ts +62 -0
  138. package/tsconfig.cjs.json +7 -0
  139. package/tsconfig.json +10 -0
  140. package/tsdoc.json +4 -0
@@ -0,0 +1,175 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { Serializable, IChannelAttributes, IFluidDataStoreRuntime, IChannelFactory, IChannelStorageService } from "@fluidframework/datastore-definitions/internal";
6
+ import type { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
7
+ import type { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions/internal";
8
+ import type { IFluidSerializer } from "@fluidframework/shared-object-base/internal";
9
+ import { SharedObject } from "@fluidframework/shared-object-base/internal";
10
+ import type { ISharedArrayEvents, ISharedArray, ISharedArrayRevertible, SerializableTypeForSharedArray } from "./interfaces.js";
11
+ /**
12
+ * Represents a shared array that allows communication between distributed clients.
13
+ *
14
+ * @internal
15
+ */
16
+ export declare class SharedArrayClass<T extends SerializableTypeForSharedArray> extends SharedObject<ISharedArrayEvents> implements ISharedArray<T>, ISharedArrayRevertible {
17
+ /**
18
+ * Stores the data held by this shared array.
19
+ */
20
+ private sharedArray;
21
+ /**
22
+ * Stores a map of entryid to entries of the sharedArray. This is meant of search optimizations and
23
+ * so shouldn't be snapshotted.
24
+ * Note: This map needs to be updated only when the sharedArray is being deserialized and when new entries are
25
+ * being added. New entries are added upon insert ops and the second leg of the move op.
26
+ * As we don't delete the entries once created, deletion or move to another position needs no special
27
+ * handling for this data structure
28
+ */
29
+ private readonly idToEntryMap;
30
+ /**
31
+ * Create a new shared array
32
+ *
33
+ * @param runtime - data store runtime the new shared array belongs to
34
+ * @param id - optional name of the shared array
35
+ * @returns newly create shared array (but not attached yet)
36
+ */
37
+ static create<T extends SerializableTypeForSharedArray>(runtime: IFluidDataStoreRuntime, id?: string): SharedArrayClass<T>;
38
+ /**
39
+ * Get a factory for SharedArray to register with the data store.
40
+ *
41
+ * @returns a factory that creates and load SharedArray
42
+ */
43
+ static getFactory<T extends SerializableTypeForSharedArray>(): IChannelFactory;
44
+ /**
45
+ * Constructs a new shared array. If the object is non-local an id and service interfaces will
46
+ * be provided
47
+ *
48
+ * @param id - optional name of the shared array
49
+ * @param runtime - data store runtime the shared array belongs to
50
+ * @param attributes - represents the attributes of a channel/DDS.
51
+ */
52
+ constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
53
+ /**
54
+ * Method that returns the ordered list of the items held in the DDS at this point in time.
55
+ * Note: This is only a snapshot of the array
56
+ */
57
+ get(): readonly T[];
58
+ protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;
59
+ insertBulkAfter<TWrite>(ref: T | undefined, values: (Serializable<TWrite> & T)[]): void;
60
+ insert<TWrite>(index: number, value: Serializable<TWrite> & T): void;
61
+ private insertCore;
62
+ delete(index: number): void;
63
+ rearrangeToFront(values: T[]): void;
64
+ /**
65
+ * Moves the DDS entry from one index to another
66
+ *
67
+ * @param fromIndex - User index of the element to be moved
68
+ * @param toIndex - User index to which the element should move to
69
+ */
70
+ move(fromIndex: number, toIndex: number): void;
71
+ private moveCore;
72
+ /**
73
+ * Method used to do undo/redo operation for the given entry id. This method is
74
+ * used for undo/redo of only insert and delete operations. Move operation is NOT handled
75
+ * by this method
76
+ *
77
+ * @param entryId - Entry Id for which the the undo/redo operation is to be applied
78
+ */
79
+ toggle(entryId: string): void;
80
+ /**
81
+ * Method to do undo/redo of move operation. All entries of the same payload/value are stored
82
+ * in the same doubly linked skip list. This skip list is updated upon every move by adding the
83
+ * new location as a new entry in the skip list and update the isDeleted flag to indicate the new
84
+ * entry is the cuurent live location for the user.
85
+ *
86
+ * @param oldEntryId - EntryId of the last live entry
87
+ * @param newEntryId - EntryId of the to be live entry
88
+ */
89
+ toggleMove(oldEntryId: string, newEntryId: string): void;
90
+ /**
91
+ * Load share array from snapshot
92
+ *
93
+ * @param storage - the storage to get the snapshot from
94
+ * @returns - promise that resolved when the load is completed
95
+ */
96
+ protected loadCore(storage: IChannelStorageService): Promise<void>;
97
+ /**
98
+ * Callback on disconnect
99
+ */
100
+ protected onDisconnect(): void;
101
+ /**
102
+ * Tracks the doubly linked skip list for the given entry to identify local pending counter attribute.
103
+ * It signifies if a local pending operation exists for the payload/value being tracked in the skip list
104
+ *
105
+ * returns true if counterAttribute's count \> 0
106
+ * @param entryId - id for which counter attribute is to be tracked in chian.
107
+ * @param counterAttribute - flag or property name from SharedArrayEntry whose counter is to be tracked.
108
+ */
109
+ private isLocalPending;
110
+ private getEntryForId;
111
+ /**
112
+ * Process a shared array operation
113
+ *
114
+ * @param message - the message to prepare
115
+ * @param local - whether the message was sent by the local client
116
+ * @param _localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
117
+ * For messages from a remote client, this will be undefined.
118
+ */
119
+ protected processCore(message: ISequencedDocumentMessage, local: boolean, _localOpMetadata: unknown): void;
120
+ private findInternalIndex;
121
+ private findInternalInsertionIndex;
122
+ private findInternalDeletionIndex;
123
+ private createAddEntry;
124
+ private addEntry;
125
+ private emitValueChangedEvent;
126
+ private emitRevertibleEvent;
127
+ private deleteCore;
128
+ private createMoveEntry;
129
+ /**
130
+ * Creates new entry of type SharedArrayEntry interface.
131
+ * @param entryId - id for which new entry is created
132
+ * @param value - value for the new entry
133
+ * @param prevEntryId - prevEntryId if exists to update the previous pointer of double ended linked list
134
+ */
135
+ private createNewEntry;
136
+ /**
137
+ * Unsets all local flags used by the DDS. This method can be used after reading from snapshott to ensure
138
+ * local flags are initialized for use by the DDS.
139
+ * @param entry - Entry for which the local flags have to be cleaned up
140
+ */
141
+ private unsetLocalFlags;
142
+ /**
143
+ * Returns the index of the first entry starting with startIndex that does not have the isAckPending flag
144
+ */
145
+ private getInternalInsertIndexByIgnoringLocalPendingInserts;
146
+ private handleInsertOp;
147
+ private findIndexOfEntryId;
148
+ private prepareToMakeEntryIdLive;
149
+ /**
150
+ * Method that returns the live entry.
151
+ * The shared array internally can store a skip list of all related entries which got created
152
+ * due to move operations for the same payload/value. However, all elements except for one element
153
+ * can have isDeleted flag as false indicating this is the live entry for the value.
154
+ * Current implementation ensures that the last element in the skip list of entries is the liveEntry/
155
+ * last live entry
156
+ *
157
+ * @param entryId - Entry id of any node in the skip list for the same payload/value
158
+ */
159
+ private getLiveEntry;
160
+ /**
161
+ * We track sequence of moves for a entry in the shared array using doubly linked skip list.
162
+ * This utility function helps us keep track of the current position of an entry.value by marking the entry
163
+ * at previous position deleted and appending the entry at the new position at the end of the double linked
164
+ * list for that entry.value.
165
+ */
166
+ private updateLiveEntry;
167
+ /**
168
+ * We track sequence of moves for a entry in the shared array using doubly linked skip list.
169
+ * This utility function helps to insert the new entry as dead entry and reconnecting the double linked list with
170
+ * existingEntry -\> deadeEntry(appended) -\> existing chain(if any).
171
+ */
172
+ private updateDeadEntry;
173
+ protected applyStashedOp(_content: unknown): void;
174
+ }
175
+ //# sourceMappingURL=sharedArray.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sharedArray.d.ts","sourceRoot":"","sources":["../../src/array/sharedArray.ts"],"names":[],"mappings":"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