@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/dist/tableSchema.js
CHANGED
|
@@ -8,6 +8,12 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
8
8
|
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");
|
|
9
9
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
10
10
|
};
|
|
11
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
+
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");
|
|
15
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
|
+
};
|
|
11
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
18
|
exports.TableSchema = exports.System_TableSchema = void 0;
|
|
13
19
|
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
@@ -144,7 +150,7 @@ var System_TableSchema;
|
|
|
144
150
|
*/
|
|
145
151
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
|
|
146
152
|
function createTableSchema(inputSchemaFactory, _cellSchema, columnSchema, rowSchema) {
|
|
147
|
-
var _Table_instances, _a, _Table_applyEditsInBatch, _Table_tryGetColumn, _Table_getColumn, _Table_tryGetRow, _Table_getRow, _Table_validateNewColumns, _Table_validateNewRows;
|
|
153
|
+
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;
|
|
148
154
|
const schemaFactory = createTableScopedFactory(inputSchemaFactory);
|
|
149
155
|
/**
|
|
150
156
|
* {@link Table} inner fields.
|
|
@@ -186,6 +192,50 @@ var System_TableSchema;
|
|
|
186
192
|
constructor(node) {
|
|
187
193
|
super(node ?? { table: { columns: [], rows: [] } });
|
|
188
194
|
_Table_instances.add(this);
|
|
195
|
+
// #region ID lookup caches
|
|
196
|
+
// Looking up rows/columns by string ID is a hot path (every getCell / setCell / etc. call goes
|
|
197
|
+
// through #tryGetRow or #tryGetColumn). Rather than scanning the arrays linearly on every call,
|
|
198
|
+
// we maintain lazily-built Maps from ID → node.
|
|
199
|
+
//
|
|
200
|
+
// Cache invalidation:
|
|
201
|
+
// Each cache is marked stale (reset to `undefined`) by a `nodeChanged` listener registered on
|
|
202
|
+
// the corresponding array node (this.table.rows / this.table.columns). `nodeChanged` fires on
|
|
203
|
+
// an array node whenever an element is inserted, removed, or moved — exactly the set of
|
|
204
|
+
// operations that could change which ID maps to which node. The event fires after the full
|
|
205
|
+
// batch of edits has been applied (including remote edits received from collaborators), so the
|
|
206
|
+
// cache is always rebuilt from a consistent, in-schema state.
|
|
207
|
+
// TODO: Consider if we should do more fine-grained invalidation here. E.g. look at the specific deltas
|
|
208
|
+
// returned by the `nodeChanged` event and only invalidate entries as needed.
|
|
209
|
+
//
|
|
210
|
+
// Listener lifetime:
|
|
211
|
+
// The listener is registered exactly once per cache (guarded by the non-undefined check on the
|
|
212
|
+
// stored unsubscribe callback). Subsequent cache rebuilds after invalidation reuse the same
|
|
213
|
+
// listener — no additional subscriptions accumulate. The unsubscribe callback is stored so
|
|
214
|
+
// that explicit cleanup is possible in the future if needed.
|
|
215
|
+
/**
|
|
216
|
+
* Cache from row ID → row node for O(1) lookups in {@link Table.#tryGetRow}.
|
|
217
|
+
* `undefined` means the cache is stale and must be rebuilt before use.
|
|
218
|
+
*/
|
|
219
|
+
_Table_rowCache.set(this, undefined);
|
|
220
|
+
/**
|
|
221
|
+
* Unsubscribe function for the `nodeChanged` listener on `this.table.rows`.
|
|
222
|
+
* `undefined` means the listener has not yet been registered (first cache build is pending).
|
|
223
|
+
* After the first build, this is always defined and the listener remains active for the
|
|
224
|
+
* lifetime of the Table node.
|
|
225
|
+
*/
|
|
226
|
+
_Table_rowCacheUnsubscribe.set(this, undefined);
|
|
227
|
+
/**
|
|
228
|
+
* Cache from column ID → column node for O(1) lookups in {@link Table.#tryGetColumn}.
|
|
229
|
+
* `undefined` means the cache is stale and must be rebuilt before use.
|
|
230
|
+
*/
|
|
231
|
+
_Table_columnCache.set(this, undefined);
|
|
232
|
+
/**
|
|
233
|
+
* Unsubscribe function for the `nodeChanged` listener on `this.table.columns`.
|
|
234
|
+
* `undefined` means the listener has not yet been registered (first cache build is pending).
|
|
235
|
+
* After the first build, this is always defined and the listener remains active for the
|
|
236
|
+
* lifetime of the Table node.
|
|
237
|
+
*/
|
|
238
|
+
_Table_columnCacheUnsubscribe.set(this, undefined);
|
|
189
239
|
}
|
|
190
240
|
static create(initialContents) {
|
|
191
241
|
// #region Input validation
|
|
@@ -568,7 +618,7 @@ var System_TableSchema;
|
|
|
568
618
|
throw new internal_2.UsageError(`The specified row node with ID "${rowOrIdOrIndex.id}" does not exist in the table.`);
|
|
569
619
|
}
|
|
570
620
|
}
|
|
571
|
-
_a = Table, _Table_instances = new WeakSet(), _Table_applyEditsInBatch = function _Table_applyEditsInBatch(options) {
|
|
621
|
+
_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) {
|
|
572
622
|
const { applyEdits, preconditions, preconditionsOnRevert } = options;
|
|
573
623
|
const branch = index_js_2.TreeAlpha.branch(this);
|
|
574
624
|
// Ensure events are paused until all of the edits are applied.
|
|
@@ -590,6 +640,26 @@ var System_TableSchema;
|
|
|
590
640
|
}, preconditions === undefined ? undefined : { preconditions });
|
|
591
641
|
}
|
|
592
642
|
});
|
|
643
|
+
}, _Table_getColumnCache = function _Table_getColumnCache() {
|
|
644
|
+
let cache = __classPrivateFieldGet(this, _Table_columnCache, "f");
|
|
645
|
+
if (cache === undefined) {
|
|
646
|
+
cache = new Map();
|
|
647
|
+
for (const column of this.table.columns) {
|
|
648
|
+
// TypeScript is unable to narrow array element types correctly here.
|
|
649
|
+
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
650
|
+
cache.set(column.id, column);
|
|
651
|
+
}
|
|
652
|
+
__classPrivateFieldSet(this, _Table_columnCache, cache, "f");
|
|
653
|
+
// Register the invalidation listener once. The `nodeChanged` event fires on the
|
|
654
|
+
// array node itself after any structural change (insert / remove / move), which is
|
|
655
|
+
// exactly the set of changes that can alter the ID → node mapping.
|
|
656
|
+
if (__classPrivateFieldGet(this, _Table_columnCacheUnsubscribe, "f") === undefined) {
|
|
657
|
+
__classPrivateFieldSet(this, _Table_columnCacheUnsubscribe, index_js_2.Tree.on(this.columns, "nodeChanged", () => {
|
|
658
|
+
__classPrivateFieldSet(this, _Table_columnCache, undefined, "f");
|
|
659
|
+
}), "f");
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
return cache;
|
|
593
663
|
}, _Table_tryGetColumn = function _Table_tryGetColumn(columnOrIdOrIndex) {
|
|
594
664
|
if (typeof columnOrIdOrIndex === "number") {
|
|
595
665
|
if (columnOrIdOrIndex < 0 || columnOrIdOrIndex >= this.table.columns.length) {
|
|
@@ -599,23 +669,39 @@ var System_TableSchema;
|
|
|
599
669
|
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
600
670
|
return this.table.columns[columnOrIdOrIndex];
|
|
601
671
|
}
|
|
672
|
+
const columnCache = __classPrivateFieldGet(this, _Table_instances, "m", _Table_getColumnCache).call(this);
|
|
602
673
|
if (typeof columnOrIdOrIndex === "string") {
|
|
603
|
-
|
|
604
|
-
// TypeScript is unable to narrow the types correctly here, hence the casts.
|
|
605
|
-
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
606
|
-
return this.table.columns.find((col) => col.id === columnId);
|
|
674
|
+
return columnCache.get(columnOrIdOrIndex);
|
|
607
675
|
}
|
|
608
676
|
// If the user provided a node, ensure it actually exists in this table.
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
}
|
|
612
|
-
return columnOrIdOrIndex;
|
|
677
|
+
const cached = columnCache.get(columnOrIdOrIndex.id);
|
|
678
|
+
return cached === columnOrIdOrIndex ? columnOrIdOrIndex : undefined;
|
|
613
679
|
}, _Table_getColumn = function _Table_getColumn(columnOrIdOrIndex) {
|
|
614
680
|
const column = __classPrivateFieldGet(this, _Table_instances, "m", _Table_tryGetColumn).call(this, columnOrIdOrIndex);
|
|
615
681
|
if (column === undefined) {
|
|
616
682
|
_a._throwMissingColumnError(columnOrIdOrIndex);
|
|
617
683
|
}
|
|
618
684
|
return column;
|
|
685
|
+
}, _Table_getRowCache = function _Table_getRowCache() {
|
|
686
|
+
let cache = __classPrivateFieldGet(this, _Table_rowCache, "f");
|
|
687
|
+
if (cache === undefined) {
|
|
688
|
+
cache = new Map();
|
|
689
|
+
for (const row of this.table.rows) {
|
|
690
|
+
// TypeScript is unable to narrow array element types correctly here.
|
|
691
|
+
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
692
|
+
cache.set(row.id, row);
|
|
693
|
+
}
|
|
694
|
+
__classPrivateFieldSet(this, _Table_rowCache, cache, "f");
|
|
695
|
+
// Register the invalidation listener once. The `nodeChanged` event fires on the
|
|
696
|
+
// array node itself after any structural change (insert / remove / move), which is
|
|
697
|
+
// exactly the set of changes that can alter the ID → node mapping.
|
|
698
|
+
if (__classPrivateFieldGet(this, _Table_rowCacheUnsubscribe, "f") === undefined) {
|
|
699
|
+
__classPrivateFieldSet(this, _Table_rowCacheUnsubscribe, index_js_2.Tree.on(this.rows, "nodeChanged", () => {
|
|
700
|
+
__classPrivateFieldSet(this, _Table_rowCache, undefined, "f");
|
|
701
|
+
}), "f");
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
return cache;
|
|
619
705
|
}, _Table_tryGetRow = function _Table_tryGetRow(rowOrIdOrIndex) {
|
|
620
706
|
if (typeof rowOrIdOrIndex === "number") {
|
|
621
707
|
if (rowOrIdOrIndex < 0 || rowOrIdOrIndex >= this.table.rows.length) {
|
|
@@ -625,17 +711,13 @@ var System_TableSchema;
|
|
|
625
711
|
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
626
712
|
return this.table.rows[rowOrIdOrIndex];
|
|
627
713
|
}
|
|
714
|
+
const rowCache = __classPrivateFieldGet(this, _Table_instances, "m", _Table_getRowCache).call(this);
|
|
628
715
|
if (typeof rowOrIdOrIndex === "string") {
|
|
629
|
-
|
|
630
|
-
// TypeScript is unable to narrow the types correctly here, hence the casts.
|
|
631
|
-
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
632
|
-
return this.table.rows.find((row) => row.id === rowId);
|
|
716
|
+
return rowCache.get(rowOrIdOrIndex);
|
|
633
717
|
}
|
|
634
718
|
// If the user provided a node, ensure it actually exists in this table.
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
}
|
|
638
|
-
return rowOrIdOrIndex;
|
|
719
|
+
const cached = rowCache.get(rowOrIdOrIndex.id);
|
|
720
|
+
return cached === rowOrIdOrIndex ? rowOrIdOrIndex : undefined;
|
|
639
721
|
}, _Table_getRow = function _Table_getRow(rowOrIdOrIndex) {
|
|
640
722
|
const row = __classPrivateFieldGet(this, _Table_instances, "m", _Table_tryGetRow).call(this, rowOrIdOrIndex);
|
|
641
723
|
if (row === undefined) {
|
|
@@ -643,9 +725,9 @@ var System_TableSchema;
|
|
|
643
725
|
}
|
|
644
726
|
return row;
|
|
645
727
|
}, _Table_validateNewColumns = function _Table_validateNewColumns(newColumns) {
|
|
646
|
-
return _a._validateNewColumns(newColumns,
|
|
728
|
+
return _a._validateNewColumns(newColumns, __classPrivateFieldGet(this, _Table_instances, "m", _Table_getColumnCache).call(this));
|
|
647
729
|
}, _Table_validateNewRows = function _Table_validateNewRows(newRows) {
|
|
648
|
-
return _a._validateNewRows(newRows,
|
|
730
|
+
return _a._validateNewRows(newRows, __classPrivateFieldGet(this, _Table_instances, "m", _Table_getRowCache).call(this), __classPrivateFieldGet(this, _Table_instances, "m", _Table_getColumnCache).call(this));
|
|
649
731
|
};
|
|
650
732
|
// Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly "__#124291@#brand": unknown;`
|
|
651
733
|
// for the private brand field of TreeNode.
|