@fluidframework/tree 2.100.0 → 2.101.0
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/CHANGELOG.md +27 -0
- package/api-report/tree.alpha.api.md +3 -1
- package/api-report/tree.beta.api.md +3 -1
- package/api-report/tree.legacy.beta.api.md +3 -1
- package/dist/core/change-family/changeFamily.d.ts +23 -0
- package/dist/core/change-family/changeFamily.d.ts.map +1 -1
- package/dist/core/change-family/changeFamily.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV1.js +2 -0
- package/dist/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV2.js +2 -0
- package/dist/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +13 -4
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +30 -3
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +27 -0
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js +4 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +9 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +6 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js +9 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +3 -3
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +8 -8
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKindFormat.d.ts +2 -14
- package/dist/feature-libraries/modular-schema/genericFieldKindFormat.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKindFormat.js +1 -17
- package/dist/feature-libraries/modular-schema/genericFieldKindFormat.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +4 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/independentView.d.ts.map +1 -1
- package/dist/shared-tree/independentView.js +2 -0
- package/dist/shared-tree/independentView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +35 -1
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +6 -0
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.js +1 -0
- package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js +2 -0
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +2 -0
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.d.ts +3 -0
- package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsCommons.d.ts +14 -0
- package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsCommons.js +14 -0
- package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts +3 -0
- package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +3 -0
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
- package/dist/shared-tree-core/editManagerSummarizer.d.ts +9 -1
- package/dist/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerSummarizer.js +20 -5
- package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.js +4 -0
- package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
- package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecVSharedBranches.js +4 -0
- package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts +4 -0
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +3 -3
- package/dist/simple-tree/api/schemaFactory.js +3 -3
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/tableSchema.d.ts.map +1 -1
- package/dist/tableSchema.js +102 -20
- package/dist/tableSchema.js.map +1 -1
- package/lib/core/change-family/changeFamily.d.ts +23 -0
- package/lib/core/change-family/changeFamily.d.ts.map +1 -1
- package/lib/core/change-family/changeFamily.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV1.js +2 -0
- package/lib/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV2.js +2 -0
- package/lib/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +13 -4
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +30 -3
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +27 -0
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.js +4 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +9 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +6 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js +9 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +3 -3
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +8 -8
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKindFormat.d.ts +2 -14
- package/lib/feature-libraries/modular-schema/genericFieldKindFormat.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKindFormat.js +1 -17
- package/lib/feature-libraries/modular-schema/genericFieldKindFormat.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +4 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/independentView.d.ts.map +1 -1
- package/lib/shared-tree/independentView.js +2 -0
- package/lib/shared-tree/independentView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +35 -1
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +6 -0
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.js +1 -0
- package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js +2 -0
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +2 -0
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.d.ts +3 -0
- package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsCommons.d.ts +14 -0
- package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsCommons.js +14 -0
- package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts +3 -0
- package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +3 -0
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
- package/lib/shared-tree-core/editManagerSummarizer.d.ts +9 -1
- package/lib/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerSummarizer.js +20 -5
- package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.js +4 -0
- package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
- package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecVSharedBranches.js +4 -0
- package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts +4 -0
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +3 -3
- package/lib/simple-tree/api/schemaFactory.js +3 -3
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/tableSchema.d.ts.map +1 -1
- package/lib/tableSchema.js +103 -21
- package/lib/tableSchema.js.map +1 -1
- package/package.json +22 -22
- package/src/core/change-family/changeFamily.ts +25 -0
- package/src/core/tree/detachedFieldIndexCodecV1.ts +2 -0
- package/src/core/tree/detachedFieldIndexCodecV2.ts +2 -0
- package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +59 -10
- package/src/feature-libraries/chunked-forest/codec/codecs.ts +32 -0
- package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +6 -1
- package/src/feature-libraries/chunked-forest/codec/nodeEncoder.ts +9 -1
- package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +9 -1
- package/src/feature-libraries/modular-schema/genericFieldKindFormat.ts +3 -21
- package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +4 -0
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/independentView.ts +2 -0
- package/src/shared-tree/sharedTree.ts +41 -1
- package/src/shared-tree/sharedTreeChangeCodecs.ts +1 -0
- package/src/shared-tree/treeAlpha.ts +2 -0
- package/src/shared-tree/treeCheckout.ts +2 -0
- package/src/shared-tree-core/editManagerCodecs.ts +3 -0
- package/src/shared-tree-core/editManagerCodecsCommons.ts +29 -0
- package/src/shared-tree-core/editManagerCodecsV1toV4.ts +3 -0
- package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +3 -0
- package/src/shared-tree-core/editManagerSummarizer.ts +17 -5
- package/src/shared-tree-core/messageCodecV1ToV4.ts +4 -0
- package/src/shared-tree-core/messageCodecVSharedBranches.ts +5 -1
- package/src/shared-tree-core/sharedTreeCore.ts +8 -1
- package/src/simple-tree/api/schemaFactory.ts +3 -3
- package/src/tableSchema.ts +134 -35
package/lib/tableSchema.js
CHANGED
|
@@ -7,10 +7,16 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
7
7
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
8
8
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
9
9
|
};
|
|
10
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
11
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
12
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
13
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
14
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
15
|
+
};
|
|
10
16
|
import { fail } from "@fluidframework/core-utils/internal";
|
|
11
17
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
12
18
|
import { EmptyKey } from "./core/index.js";
|
|
13
|
-
import { TreeAlpha } from "./shared-tree/index.js";
|
|
19
|
+
import { Tree, TreeAlpha } from "./shared-tree/index.js";
|
|
14
20
|
import { TreeArrayNode, SchemaFactory, scoped, withBufferedTreeEvents, objectSchema, eraseSchemaDetailsSubclassable, createCustomizedFluidFrameworkScopedFactory, } from "./simple-tree/index.js";
|
|
15
21
|
import { validateIndex, validateIndexRange } from "./util/index.js";
|
|
16
22
|
/**
|
|
@@ -141,7 +147,7 @@ export var System_TableSchema;
|
|
|
141
147
|
*/
|
|
142
148
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
|
|
143
149
|
function createTableSchema(inputSchemaFactory, _cellSchema, columnSchema, rowSchema) {
|
|
144
|
-
var _Table_instances, _a, _Table_applyEditsInBatch, _Table_tryGetColumn, _Table_getColumn, _Table_tryGetRow, _Table_getRow, _Table_validateNewColumns, _Table_validateNewRows;
|
|
150
|
+
var _Table_instances, _a, _Table_rowCache, _Table_rowCacheUnsubscribe, _Table_columnCache, _Table_columnCacheUnsubscribe, _Table_applyEditsInBatch, _Table_getColumnCache, _Table_tryGetColumn, _Table_getColumn, _Table_getRowCache, _Table_tryGetRow, _Table_getRow, _Table_validateNewColumns, _Table_validateNewRows;
|
|
145
151
|
const schemaFactory = createTableScopedFactory(inputSchemaFactory);
|
|
146
152
|
/**
|
|
147
153
|
* {@link Table} inner fields.
|
|
@@ -183,6 +189,50 @@ export var System_TableSchema;
|
|
|
183
189
|
constructor(node) {
|
|
184
190
|
super(node ?? { table: { columns: [], rows: [] } });
|
|
185
191
|
_Table_instances.add(this);
|
|
192
|
+
// #region ID lookup caches
|
|
193
|
+
// Looking up rows/columns by string ID is a hot path (every getCell / setCell / etc. call goes
|
|
194
|
+
// through #tryGetRow or #tryGetColumn). Rather than scanning the arrays linearly on every call,
|
|
195
|
+
// we maintain lazily-built Maps from ID → node.
|
|
196
|
+
//
|
|
197
|
+
// Cache invalidation:
|
|
198
|
+
// Each cache is marked stale (reset to `undefined`) by a `nodeChanged` listener registered on
|
|
199
|
+
// the corresponding array node (this.table.rows / this.table.columns). `nodeChanged` fires on
|
|
200
|
+
// an array node whenever an element is inserted, removed, or moved — exactly the set of
|
|
201
|
+
// operations that could change which ID maps to which node. The event fires after the full
|
|
202
|
+
// batch of edits has been applied (including remote edits received from collaborators), so the
|
|
203
|
+
// cache is always rebuilt from a consistent, in-schema state.
|
|
204
|
+
// TODO: Consider if we should do more fine-grained invalidation here. E.g. look at the specific deltas
|
|
205
|
+
// returned by the `nodeChanged` event and only invalidate entries as needed.
|
|
206
|
+
//
|
|
207
|
+
// Listener lifetime:
|
|
208
|
+
// The listener is registered exactly once per cache (guarded by the non-undefined check on the
|
|
209
|
+
// stored unsubscribe callback). Subsequent cache rebuilds after invalidation reuse the same
|
|
210
|
+
// listener — no additional subscriptions accumulate. The unsubscribe callback is stored so
|
|
211
|
+
// that explicit cleanup is possible in the future if needed.
|
|
212
|
+
/**
|
|
213
|
+
* Cache from row ID → row node for O(1) lookups in {@link Table.#tryGetRow}.
|
|
214
|
+
* `undefined` means the cache is stale and must be rebuilt before use.
|
|
215
|
+
*/
|
|
216
|
+
_Table_rowCache.set(this, undefined);
|
|
217
|
+
/**
|
|
218
|
+
* Unsubscribe function for the `nodeChanged` listener on `this.table.rows`.
|
|
219
|
+
* `undefined` means the listener has not yet been registered (first cache build is pending).
|
|
220
|
+
* After the first build, this is always defined and the listener remains active for the
|
|
221
|
+
* lifetime of the Table node.
|
|
222
|
+
*/
|
|
223
|
+
_Table_rowCacheUnsubscribe.set(this, undefined);
|
|
224
|
+
/**
|
|
225
|
+
* Cache from column ID → column node for O(1) lookups in {@link Table.#tryGetColumn}.
|
|
226
|
+
* `undefined` means the cache is stale and must be rebuilt before use.
|
|
227
|
+
*/
|
|
228
|
+
_Table_columnCache.set(this, undefined);
|
|
229
|
+
/**
|
|
230
|
+
* Unsubscribe function for the `nodeChanged` listener on `this.table.columns`.
|
|
231
|
+
* `undefined` means the listener has not yet been registered (first cache build is pending).
|
|
232
|
+
* After the first build, this is always defined and the listener remains active for the
|
|
233
|
+
* lifetime of the Table node.
|
|
234
|
+
*/
|
|
235
|
+
_Table_columnCacheUnsubscribe.set(this, undefined);
|
|
186
236
|
}
|
|
187
237
|
static create(initialContents) {
|
|
188
238
|
// #region Input validation
|
|
@@ -565,7 +615,7 @@ export var System_TableSchema;
|
|
|
565
615
|
throw new UsageError(`The specified row node with ID "${rowOrIdOrIndex.id}" does not exist in the table.`);
|
|
566
616
|
}
|
|
567
617
|
}
|
|
568
|
-
_a = Table, _Table_instances = new WeakSet(), _Table_applyEditsInBatch = function _Table_applyEditsInBatch(options) {
|
|
618
|
+
_a = Table, _Table_rowCache = new WeakMap(), _Table_rowCacheUnsubscribe = new WeakMap(), _Table_columnCache = new WeakMap(), _Table_columnCacheUnsubscribe = new WeakMap(), _Table_instances = new WeakSet(), _Table_applyEditsInBatch = function _Table_applyEditsInBatch(options) {
|
|
569
619
|
const { applyEdits, preconditions, preconditionsOnRevert } = options;
|
|
570
620
|
const branch = TreeAlpha.branch(this);
|
|
571
621
|
// Ensure events are paused until all of the edits are applied.
|
|
@@ -587,6 +637,26 @@ export var System_TableSchema;
|
|
|
587
637
|
}, preconditions === undefined ? undefined : { preconditions });
|
|
588
638
|
}
|
|
589
639
|
});
|
|
640
|
+
}, _Table_getColumnCache = function _Table_getColumnCache() {
|
|
641
|
+
let cache = __classPrivateFieldGet(this, _Table_columnCache, "f");
|
|
642
|
+
if (cache === undefined) {
|
|
643
|
+
cache = new Map();
|
|
644
|
+
for (const column of this.table.columns) {
|
|
645
|
+
// TypeScript is unable to narrow array element types correctly here.
|
|
646
|
+
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
647
|
+
cache.set(column.id, column);
|
|
648
|
+
}
|
|
649
|
+
__classPrivateFieldSet(this, _Table_columnCache, cache, "f");
|
|
650
|
+
// Register the invalidation listener once. The `nodeChanged` event fires on the
|
|
651
|
+
// array node itself after any structural change (insert / remove / move), which is
|
|
652
|
+
// exactly the set of changes that can alter the ID → node mapping.
|
|
653
|
+
if (__classPrivateFieldGet(this, _Table_columnCacheUnsubscribe, "f") === undefined) {
|
|
654
|
+
__classPrivateFieldSet(this, _Table_columnCacheUnsubscribe, Tree.on(this.columns, "nodeChanged", () => {
|
|
655
|
+
__classPrivateFieldSet(this, _Table_columnCache, undefined, "f");
|
|
656
|
+
}), "f");
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
return cache;
|
|
590
660
|
}, _Table_tryGetColumn = function _Table_tryGetColumn(columnOrIdOrIndex) {
|
|
591
661
|
if (typeof columnOrIdOrIndex === "number") {
|
|
592
662
|
if (columnOrIdOrIndex < 0 || columnOrIdOrIndex >= this.table.columns.length) {
|
|
@@ -596,23 +666,39 @@ export var System_TableSchema;
|
|
|
596
666
|
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
597
667
|
return this.table.columns[columnOrIdOrIndex];
|
|
598
668
|
}
|
|
669
|
+
const columnCache = __classPrivateFieldGet(this, _Table_instances, "m", _Table_getColumnCache).call(this);
|
|
599
670
|
if (typeof columnOrIdOrIndex === "string") {
|
|
600
|
-
|
|
601
|
-
// TypeScript is unable to narrow the types correctly here, hence the casts.
|
|
602
|
-
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
603
|
-
return this.table.columns.find((col) => col.id === columnId);
|
|
671
|
+
return columnCache.get(columnOrIdOrIndex);
|
|
604
672
|
}
|
|
605
673
|
// If the user provided a node, ensure it actually exists in this table.
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
}
|
|
609
|
-
return columnOrIdOrIndex;
|
|
674
|
+
const cached = columnCache.get(columnOrIdOrIndex.id);
|
|
675
|
+
return cached === columnOrIdOrIndex ? columnOrIdOrIndex : undefined;
|
|
610
676
|
}, _Table_getColumn = function _Table_getColumn(columnOrIdOrIndex) {
|
|
611
677
|
const column = __classPrivateFieldGet(this, _Table_instances, "m", _Table_tryGetColumn).call(this, columnOrIdOrIndex);
|
|
612
678
|
if (column === undefined) {
|
|
613
679
|
_a._throwMissingColumnError(columnOrIdOrIndex);
|
|
614
680
|
}
|
|
615
681
|
return column;
|
|
682
|
+
}, _Table_getRowCache = function _Table_getRowCache() {
|
|
683
|
+
let cache = __classPrivateFieldGet(this, _Table_rowCache, "f");
|
|
684
|
+
if (cache === undefined) {
|
|
685
|
+
cache = new Map();
|
|
686
|
+
for (const row of this.table.rows) {
|
|
687
|
+
// TypeScript is unable to narrow array element types correctly here.
|
|
688
|
+
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
689
|
+
cache.set(row.id, row);
|
|
690
|
+
}
|
|
691
|
+
__classPrivateFieldSet(this, _Table_rowCache, cache, "f");
|
|
692
|
+
// Register the invalidation listener once. The `nodeChanged` event fires on the
|
|
693
|
+
// array node itself after any structural change (insert / remove / move), which is
|
|
694
|
+
// exactly the set of changes that can alter the ID → node mapping.
|
|
695
|
+
if (__classPrivateFieldGet(this, _Table_rowCacheUnsubscribe, "f") === undefined) {
|
|
696
|
+
__classPrivateFieldSet(this, _Table_rowCacheUnsubscribe, Tree.on(this.rows, "nodeChanged", () => {
|
|
697
|
+
__classPrivateFieldSet(this, _Table_rowCache, undefined, "f");
|
|
698
|
+
}), "f");
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
return cache;
|
|
616
702
|
}, _Table_tryGetRow = function _Table_tryGetRow(rowOrIdOrIndex) {
|
|
617
703
|
if (typeof rowOrIdOrIndex === "number") {
|
|
618
704
|
if (rowOrIdOrIndex < 0 || rowOrIdOrIndex >= this.table.rows.length) {
|
|
@@ -622,17 +708,13 @@ export var System_TableSchema;
|
|
|
622
708
|
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
623
709
|
return this.table.rows[rowOrIdOrIndex];
|
|
624
710
|
}
|
|
711
|
+
const rowCache = __classPrivateFieldGet(this, _Table_instances, "m", _Table_getRowCache).call(this);
|
|
625
712
|
if (typeof rowOrIdOrIndex === "string") {
|
|
626
|
-
|
|
627
|
-
// TypeScript is unable to narrow the types correctly here, hence the casts.
|
|
628
|
-
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
629
|
-
return this.table.rows.find((row) => row.id === rowId);
|
|
713
|
+
return rowCache.get(rowOrIdOrIndex);
|
|
630
714
|
}
|
|
631
715
|
// If the user provided a node, ensure it actually exists in this table.
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
}
|
|
635
|
-
return rowOrIdOrIndex;
|
|
716
|
+
const cached = rowCache.get(rowOrIdOrIndex.id);
|
|
717
|
+
return cached === rowOrIdOrIndex ? rowOrIdOrIndex : undefined;
|
|
636
718
|
}, _Table_getRow = function _Table_getRow(rowOrIdOrIndex) {
|
|
637
719
|
const row = __classPrivateFieldGet(this, _Table_instances, "m", _Table_tryGetRow).call(this, rowOrIdOrIndex);
|
|
638
720
|
if (row === undefined) {
|
|
@@ -640,9 +722,9 @@ export var System_TableSchema;
|
|
|
640
722
|
}
|
|
641
723
|
return row;
|
|
642
724
|
}, _Table_validateNewColumns = function _Table_validateNewColumns(newColumns) {
|
|
643
|
-
return _a._validateNewColumns(newColumns,
|
|
725
|
+
return _a._validateNewColumns(newColumns, __classPrivateFieldGet(this, _Table_instances, "m", _Table_getColumnCache).call(this));
|
|
644
726
|
}, _Table_validateNewRows = function _Table_validateNewRows(newRows) {
|
|
645
|
-
return _a._validateNewRows(newRows,
|
|
727
|
+
return _a._validateNewRows(newRows, __classPrivateFieldGet(this, _Table_instances, "m", _Table_getRowCache).call(this), __classPrivateFieldGet(this, _Table_instances, "m", _Table_getColumnCache).call(this));
|
|
646
728
|
};
|
|
647
729
|
// Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly "__#124291@#brand": unknown;`
|
|
648
730
|
// for the private brand field of TreeNode.
|