@fluidframework/matrix 2.50.0 → 2.51.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/.eslintrc.cjs +11 -0
- package/CHANGELOG.md +4 -0
- package/dist/handlecache.d.ts +3 -3
- package/dist/handlecache.d.ts.map +1 -1
- package/dist/handlecache.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/matrix.d.ts +9 -9
- package/dist/matrix.d.ts.map +1 -1
- package/dist/matrix.js.map +1 -1
- package/dist/ops.d.ts +2 -2
- package/dist/ops.d.ts.map +1 -1
- package/dist/ops.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/permutationvector.d.ts +7 -7
- package/dist/permutationvector.d.ts.map +1 -1
- package/dist/permutationvector.js +0 -1
- package/dist/permutationvector.js.map +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js.map +1 -1
- package/dist/serialization.d.ts +3 -3
- package/dist/serialization.d.ts.map +1 -1
- package/dist/serialization.js +0 -1
- package/dist/serialization.js.map +1 -1
- package/dist/sparsearray2d.d.ts +1 -1
- package/dist/sparsearray2d.d.ts.map +1 -1
- package/dist/sparsearray2d.js.map +1 -1
- package/dist/undoprovider.d.ts +6 -6
- package/dist/undoprovider.d.ts.map +1 -1
- package/dist/undoprovider.js.map +1 -1
- package/lib/handlecache.d.ts +3 -3
- package/lib/handlecache.d.ts.map +1 -1
- package/lib/handlecache.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/matrix.d.ts +9 -9
- package/lib/matrix.d.ts.map +1 -1
- package/lib/matrix.js.map +1 -1
- package/lib/ops.d.ts +2 -2
- package/lib/ops.d.ts.map +1 -1
- package/lib/ops.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/permutationvector.d.ts +7 -7
- package/lib/permutationvector.d.ts.map +1 -1
- package/lib/permutationvector.js +0 -1
- package/lib/permutationvector.js.map +1 -1
- package/lib/runtime.d.ts +1 -1
- package/lib/runtime.d.ts.map +1 -1
- package/lib/runtime.js.map +1 -1
- package/lib/serialization.d.ts +3 -3
- package/lib/serialization.d.ts.map +1 -1
- package/lib/serialization.js +0 -1
- package/lib/serialization.js.map +1 -1
- package/lib/sparsearray2d.d.ts +1 -1
- package/lib/sparsearray2d.d.ts.map +1 -1
- package/lib/sparsearray2d.js.map +1 -1
- package/lib/undoprovider.d.ts +6 -6
- package/lib/undoprovider.d.ts.map +1 -1
- package/lib/undoprovider.js.map +1 -1
- package/package.json +18 -18
- package/src/handlecache.ts +3 -3
- package/src/index.ts +3 -3
- package/src/matrix.ts +18 -18
- package/src/ops.ts +2 -2
- package/src/packageVersion.ts +1 -1
- package/src/permutationvector.ts +11 -12
- package/src/runtime.ts +1 -1
- package/src/serialization.ts +3 -4
- package/src/sparsearray2d.ts +1 -1
- package/src/undoprovider.ts +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permutationvector.js","sourceRoot":"","sources":["../src/permutationvector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAM7D,OAAO,EACN,WAAW,EACX,MAAM,EAMN,kBAAkB,EAClB,wBAAwB,EACxB,gBAAgB,GAGhB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EACN,sBAAsB,EACtB,kBAAkB,GAClB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAE7E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAU,WAAW,EAAE,aAAa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AAC;IACF,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC;AACzB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandle, ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tBaseSegment,\n\tClient,\n\tIJSONSegment,\n\tIMergeTreeDeltaCallbackArgs,\n\tIMergeTreeDeltaOpArgs,\n\tIMergeTreeMaintenanceCallbackArgs,\n\tISegment,\n\tMergeTreeDeltaType,\n\tMergeTreeMaintenanceType,\n\tsegmentIsRemoved,\n\ttype IMergeTreeInsertMsg,\n\ttype IMergeTreeRemoveMsg,\n} from \"@fluidframework/merge-tree/internal\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tObjectStoragePartition,\n\tSummaryTreeBuilder,\n} from \"@fluidframework/runtime-utils/internal\";\nimport { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport { createChildLogger } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { HandleCache } from \"./handlecache.js\";\nimport { Handle, HandleTable, isHandleValid } from \"./handletable.js\";\nimport { deserializeBlob } from \"./serialization.js\";\nimport { VectorUndoProvider } from \"./undoprovider.js\";\n\nconst enum SnapshotPath {\n\tsegments = \"segments\",\n\thandleTable = \"handleTable\",\n}\n\ntype PermutationSegmentSpec = [number, number];\n\nexport class PermutationSegment extends BaseSegment {\n\tpublic static readonly typeString: string = \"PermutationSegment\";\n\tprivate _start = Handle.unallocated;\n\n\tpublic static fromJSONObject(spec: IJSONSegment): PermutationSegment {\n\t\tconst [length, start] = spec as PermutationSegmentSpec;\n\t\treturn new PermutationSegment(length, start);\n\t}\n\n\tpublic readonly type = PermutationSegment.typeString;\n\n\tconstructor(length: number, start = Handle.unallocated) {\n\t\tsuper();\n\t\tthis._start = start;\n\t\tthis.cachedLength = length;\n\t}\n\n\tpublic get start(): Handle {\n\t\treturn this._start;\n\t}\n\tpublic set start(value: Handle) {\n\t\tassert(\n\t\t\tthis._start === Handle.unallocated,\n\t\t\t0x024 /* \"Start of PermutationSegment already allocated!\" */,\n\t\t);\n\t\tassert(\n\t\t\tisHandleValid(value),\n\t\t\t0x025 /* \"Trying to set start of PermutationSegment to invalid handle!\" */,\n\t\t);\n\n\t\tthis._start = value;\n\t}\n\n\tpublic reset(): void {\n\t\tthis._start = Handle.unallocated;\n\t}\n\n\tpublic toJSONObject(): number[] {\n\t\treturn [this.cachedLength, this.start];\n\t}\n\n\tpublic clone(start = 0, end = this.cachedLength): PermutationSegment {\n\t\tconst b = new PermutationSegment(\n\t\t\t/* length: */ end - start,\n\t\t\t/* start: */ this.start + start,\n\t\t);\n\t\tthis.cloneInto(b);\n\t\treturn b;\n\t}\n\n\tpublic canAppend(segment: ISegment): boolean {\n\t\tconst asPerm = segment as PermutationSegment;\n\n\t\treturn this.start === Handle.unallocated\n\t\t\t? asPerm.start === Handle.unallocated\n\t\t\t: asPerm.start === this.start + this.cachedLength;\n\t}\n\n\tprotected createSplitSegmentAt(pos: number): PermutationSegment {\n\t\tassert(\n\t\t\t0 < pos && pos < this.cachedLength,\n\t\t\t0x026 /* \"Trying to split segment at out-of-bounds position!\" */,\n\t\t);\n\n\t\tconst leafSegment = new PermutationSegment(\n\t\t\t/* length: */ this.cachedLength - pos,\n\t\t\t/* start: */ this.start === Handle.unallocated ? Handle.unallocated : this.start + pos,\n\t\t);\n\n\t\tthis.cachedLength = pos;\n\n\t\treturn leafSegment;\n\t}\n\n\tpublic toString(): string {\n\t\treturn this.start === Handle.unallocated\n\t\t\t? `<${this.cachedLength} empty>`\n\t\t\t: `<${this.cachedLength}: ${this.start}..${this.start + this.cachedLength - 1}>`;\n\t}\n}\n\n// eslint-disable-next-line import/no-deprecated\nexport class PermutationVector extends Client {\n\tprivate handleTable = new HandleTable<never>(); // Tracks available storage handles for rows.\n\tpublic readonly handleCache = new HandleCache(this);\n\tpublic undo: VectorUndoProvider | undefined;\n\n\tconstructor(\n\t\tpath: string,\n\t\tlogger: ITelemetryBaseLogger,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tprivate readonly deltaCallback: (\n\t\t\tposition: number,\n\t\t\tnumRemoved: number,\n\t\t\tnumInserted: number,\n\t\t) => void,\n\t\tprivate readonly handlesRecycledCallback: (handles: Handle[]) => void,\n\t\tgetMinInFlightRefSeq: () => number | undefined,\n\t) {\n\t\tsuper(\n\t\t\tPermutationSegment.fromJSONObject,\n\t\t\tcreateChildLogger({ logger, namespace: `Matrix.${path}.MergeTreeClient` }),\n\t\t\t{\n\t\t\t\t...runtime.options,\n\t\t\t\tnewMergeTreeSnapshotFormat: true, // Force new snapshot format as it's generally more efficient for matrices.\n\t\t\t},\n\t\t\tgetMinInFlightRefSeq,\n\t\t);\n\n\t\tthis.on(\"delta\", this.onDelta);\n\t\tthis.on(\"maintenance\", this.onMaintenance);\n\t}\n\n\tpublic insert(start: number, length: number): IMergeTreeInsertMsg | undefined {\n\t\treturn this.insertSegmentLocal(start, new PermutationSegment(length));\n\t}\n\n\tpublic remove(start: number, length: number): IMergeTreeRemoveMsg {\n\t\treturn this.removeRangeLocal(start, start + length);\n\t}\n\n\tpublic getMaybeHandle(pos: number): Handle {\n\t\tassert(\n\t\t\t0 <= pos && pos < this.getLength(),\n\t\t\t0x027 /* \"Trying to get handle of out-of-bounds position!\" */,\n\t\t);\n\n\t\treturn this.handleCache.getHandle(pos);\n\t}\n\n\tpublic getAllocatedHandle(pos: number): Handle {\n\t\tlet handle = this.getMaybeHandle(pos);\n\t\tif (isHandleValid(handle)) {\n\t\t\treturn handle;\n\t\t}\n\n\t\tthis.walkSegments(\n\t\t\t(segment) => {\n\t\t\t\tconst asPerm = segment as PermutationSegment;\n\t\t\t\tasPerm.start = handle = this.handleTable.allocate();\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tpos,\n\t\t\tpos + 1,\n\t\t\t/* accum: */ undefined,\n\t\t\t/* splitRange: */ true,\n\t\t);\n\n\t\tthis.handleCache.addHandle(pos, handle);\n\n\t\treturn handle;\n\t}\n\n\tpublic adjustPosition(\n\t\tposToAdjust: number,\n\t\top: ISequencedDocumentMessage,\n\t): { pos: number | undefined; handle: Handle } {\n\t\tconst segOff = this.getContainingSegment<PermutationSegment>(posToAdjust, {\n\t\t\treferenceSequenceNumber: op.referenceSequenceNumber,\n\t\t\tclientId: op.clientId,\n\t\t});\n\n\t\tassert(\n\t\t\tsegOff !== undefined,\n\t\t\t0xbac /* segment must be available for operations in the collab window */,\n\t\t);\n\t\tconst { segment, offset } = segOff;\n\n\t\tif (segmentIsRemoved(segment)) {\n\t\t\t// this case is tricky. the segment which the row or column data is remove\n\t\t\t// but an op before that remove references a cell. we still want to apply\n\t\t\t// the op, as the row/col could become active again in the case where\n\t\t\t// the remove was local and it get's rolled back. so we allocate a handle\n\t\t\t// for the row/col if not allocated, but don't put it in the cache\n\t\t\t// as the cache can only contain live positions.\n\t\t\tlet handle = segment.start;\n\t\t\tif (!isHandleValid(handle)) {\n\t\t\t\tthis.walkSegments(\n\t\t\t\t\t(s) => {\n\t\t\t\t\t\tconst asPerm = s as PermutationSegment;\n\t\t\t\t\t\tasPerm.start = handle = this.handleTable.allocate();\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t},\n\t\t\t\t\tposToAdjust,\n\t\t\t\t\tposToAdjust + 1,\n\t\t\t\t\t/* accum: */ undefined,\n\t\t\t\t\t/* splitRange: */ true,\n\t\t\t\t\top,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn { handle, pos: undefined };\n\t\t} else {\n\t\t\tconst pos = this.getPosition(segment) + offset;\n\t\t\treturn {\n\t\t\t\tpos,\n\t\t\t\thandle: this.getAllocatedHandle(pos),\n\t\t\t};\n\t\t}\n\t}\n\n\tpublic handleToPosition(handle: Handle, localSeq = this.getCollabWindow().localSeq): number {\n\t\tassert(\n\t\t\tlocalSeq <= this.getCollabWindow().localSeq,\n\t\t\t0x028 /* \"'localSeq' for op being resubmitted must be <= the 'localSeq' of the last submitted op.\" */,\n\t\t);\n\n\t\t// TODO: In theory, the MergeTree should be able to map the (position, refSeq, localSeq) from\n\t\t// the original operation to the current position for undo/redo scenarios. This is probably the\n\t\t// ideal solution, as we would no longer need to store row/col handles in the op metadata.\n\t\t//\n\t\t// Failing that, we could avoid the O(n) search below by building a temporary map in the\n\t\t// opposite direction from the handle to either it's current position or segment + offset\n\t\t// and reuse it for the duration of undo/redo. (Ideally, we would know when the undo/redo\n\t\t// ended so we could discard this map.)\n\t\t//\n\t\t// If we find that we frequently need a reverse handle -> position lookup, we could maintain\n\t\t// one using the Tiny-Calc adjust tree.\n\t\tlet containingSegment!: PermutationSegment;\n\t\tlet containingOffset: number;\n\n\t\tthis.walkAllSegments((segment) => {\n\t\t\tconst { start, cachedLength } = segment as PermutationSegment;\n\n\t\t\t// If the segment is unallocated, skip it.\n\t\t\tif (!isHandleValid(start)) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tconst end = start + cachedLength;\n\n\t\t\tif (start <= handle && handle < end) {\n\t\t\t\tcontainingSegment = segment as PermutationSegment;\n\t\t\t\tcontainingOffset = handle - start;\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t});\n\n\t\t// We are guaranteed to find the handle in the PermutationVector, even if the corresponding\n\t\t// row/col has been removed, because handles are not recycled until the containing segment\n\t\t// is unlinked from the MergeTree.\n\t\t//\n\t\t// Therefore, either a row/col removal has been ACKed, in which case there will be no pending\n\t\t// ops that reference the stale handle, or the removal is unACKed, in which case the handle\n\t\t// has not yet been recycled.\n\n\t\tassert(\n\t\t\tisHandleValid(containingSegment.start),\n\t\t\t0x029 /* \"Invalid handle at start of containing segment!\" */,\n\t\t);\n\n\t\t// Once we know the current position of the handle, we can use the MergeTree to get the segment\n\t\t// containing this position and use 'findReconnectionPosition' to adjust for the local ops that\n\t\t// have not yet been submitted.\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\treturn this.findReconnectionPosition(containingSegment, localSeq) + containingOffset!;\n\t}\n\n\t// Constructs an ISummaryTreeWithStats for the cell data.\n\tpublic summarize(\n\t\truntime: IFluidDataStoreRuntime,\n\t\thandle: IFluidHandle,\n\t\tserializer: IFluidSerializer,\n\t): ISummaryTreeWithStats {\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tbuilder.addWithStats(\n\t\t\tSnapshotPath.segments,\n\t\t\tsuper.summarize(runtime, handle, serializer, /* catchUpMsgs: */ []),\n\t\t);\n\t\tbuilder.addBlob(\n\t\t\tSnapshotPath.handleTable,\n\t\t\tserializer.stringify(this.handleTable.getSummaryContent(), handle),\n\t\t);\n\t\treturn builder.getSummaryTree();\n\t}\n\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tstorage: IChannelStorageService,\n\t\tserializer: IFluidSerializer,\n\t): Promise<{\n\t\tcatchupOpsP: Promise<ISequencedDocumentMessage[]>;\n\t}> {\n\t\tconst handleTableData = (await deserializeBlob(\n\t\t\tstorage,\n\t\t\tSnapshotPath.handleTable,\n\t\t\tserializer,\n\t\t\t// Cast is needed since the (de)serializer returns content of type `any`.\n\t\t)) as Handle[];\n\n\t\tthis.handleTable = HandleTable.load<never>(handleTableData);\n\n\t\treturn super.load(\n\t\t\truntime,\n\t\t\tnew ObjectStoragePartition(storage, SnapshotPath.segments),\n\t\t\tserializer,\n\t\t);\n\t}\n\n\tprivate readonly onDelta = (\n\t\topArgs: IMergeTreeDeltaOpArgs,\n\t\tdeltaArgs: IMergeTreeDeltaCallbackArgs,\n\t): void => {\n\t\t// Apply deltas in descending order to prevent positions from shifting.\n\t\tconst ranges = deltaArgs.deltaSegments\n\t\t\t.map(({ segment }) => ({\n\t\t\t\tsegment: segment as PermutationSegment,\n\t\t\t\tposition: this.getPosition(segment),\n\t\t\t}))\n\t\t\t.sort((left, right) => left.position - right.position);\n\n\t\tconst isLocal = opArgs.sequencedMessage === undefined;\n\n\t\t// Notify the undo provider, if any is attached.\n\t\tif (this.undo !== undefined && isLocal) {\n\t\t\tthis.undo.record(deltaArgs);\n\t\t}\n\n\t\tswitch (deltaArgs.operation) {\n\t\t\tcase MergeTreeDeltaType.INSERT: {\n\t\t\t\t// Pass 1: Perform any internal maintenance first to avoid reentrancy.\n\t\t\t\tfor (const { segment, position } of ranges) {\n\t\t\t\t\tif (opArgs.rollback !== true) {\n\t\t\t\t\t\t// HACK: We need to include the allocated handle in the segment's JSON representation\n\t\t\t\t\t\t// for snapshots, but need to ignore the remote client's handle allocations when\n\t\t\t\t\t\t// processing remote ops.\n\t\t\t\t\t\tsegment.reset();\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.handleCache.itemsChanged(\n\t\t\t\t\t\tposition,\n\t\t\t\t\t\t/* deleteCount: */ 0,\n\t\t\t\t\t\t/* insertCount: */ segment.cachedLength,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Pass 2: Notify the 'deltaCallback', which may involve callbacks into user code.\n\t\t\t\tfor (const { segment, position } of ranges) {\n\t\t\t\t\tthis.deltaCallback(\n\t\t\t\t\t\tposition,\n\t\t\t\t\t\t/* numRemoved: */ 0,\n\t\t\t\t\t\t/* numInserted: */ segment.cachedLength,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase MergeTreeDeltaType.REMOVE: {\n\t\t\t\t// Pass 1: Perform any internal maintenance first to avoid reentrancy.\n\t\t\t\tfor (const { segment, position } of ranges) {\n\t\t\t\t\tthis.handleCache.itemsChanged(\n\t\t\t\t\t\tposition /* deleteCount: */,\n\t\t\t\t\t\tsegment.cachedLength,\n\t\t\t\t\t\t/* insertCount: */ 0,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Pass 2: Notify the 'deltaCallback', which may involve callbacks into user code.\n\t\t\t\tfor (const { segment, position } of ranges) {\n\t\t\t\t\tthis.deltaCallback(\n\t\t\t\t\t\tposition,\n\t\t\t\t\t\t/* numRemoved: */ segment.cachedLength,\n\t\t\t\t\t\t/* numInsert: */ 0,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(\"Unhandled MergeTreeDeltaType\");\n\t\t\t}\n\t\t}\n\t};\n\n\tprivate readonly onMaintenance = (args: IMergeTreeMaintenanceCallbackArgs): void => {\n\t\tif (args.operation === MergeTreeMaintenanceType.UNLINK) {\n\t\t\tlet freed: number[] = [];\n\n\t\t\tfor (const { segment } of args.deltaSegments) {\n\t\t\t\tconst asPerm = segment as PermutationSegment;\n\t\t\t\tif (isHandleValid(asPerm.start)) {\n\t\t\t\t\t// Note: Using the spread operator with `.splice()` can exhaust the stack.\n\t\t\t\t\t// eslint-disable-next-line unicorn/prefer-spread\n\t\t\t\t\tfreed = freed.concat(\n\t\t\t\t\t\tArray.from({ length: asPerm.cachedLength })\n\t\t\t\t\t\t\t.fill(0)\n\t\t\t\t\t\t\t.map((value, index) => index + asPerm.start),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Notify matrix that handles are about to be freed. The matrix is responsible for clearing\n\t\t\t// the rows/cols prior to free to ensure recycled row/cols are initially empty.\n\t\t\tthis.handlesRecycledCallback(freed);\n\n\t\t\t// Now that the physical storage has been cleared, add the recycled handles back to the free pool.\n\t\t\tfor (const handle of freed) {\n\t\t\t\tthis.handleTable.free(handle);\n\t\t\t}\n\t\t}\n\t};\n\n\tpublic toString(): string {\n\t\tconst s: string[] = [];\n\n\t\tthis.walkSegments((segment) => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-base-to-string\n\t\t\ts.push(`${segment}`);\n\t\t\treturn true;\n\t\t});\n\n\t\treturn s.join(\"\");\n\t}\n}\n\nexport function reinsertSegmentIntoVector(\n\tvector: PermutationVector,\n\tpos: number,\n\tspec: IJSONSegment,\n): {\n\top: IMergeTreeInsertMsg | undefined;\n\tinserted: PermutationSegment;\n} {\n\tconst original = PermutationSegment.fromJSONObject(spec);\n\n\t// (Re)insert the removed number of rows at the original position.\n\tconst op = vector.insertSegmentLocal(pos, original);\n\tconst inserted = vector.getContainingSegment(pos)?.segment as PermutationSegment;\n\n\t// we reuse the original handle here\n\t// so if cells exist, they can be found, and re-inserted\n\tif (isHandleValid(original.start)) {\n\t\tinserted.start = original.start;\n\t}\n\n\t// Invalidate the handleCache in case it was populated during the 'rowsChanged'\n\t// callback, which occurs before the handle span is populated.\n\tvector.handleCache.itemsChanged(\n\t\tpos,\n\t\t/* removedCount: */ 0,\n\t\t/* insertedCount: */ inserted.cachedLength,\n\t);\n\treturn { op, inserted };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"permutationvector.js","sourceRoot":"","sources":["../src/permutationvector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAM7D,OAAO,EACN,WAAW,EACX,MAAM,EAMN,kBAAkB,EAClB,wBAAwB,EACxB,gBAAgB,GAGhB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EACN,sBAAsB,EACtB,kBAAkB,GAClB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAE7E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAU,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAUrD,MAAM,OAAO,kBAAmB,SAAQ,WAAW;IAI3C,MAAM,CAAC,cAAc,CAAC,IAAkB;QAC9C,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,IAA8B,CAAC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ACP,IAAI,sBAAsB,CAAC,OAAO,yCAAwB,EAC1D,UAAU,CACV,CAAC;IACH,CAAC;IAuGM,QAAQ;QACd,MAAM,CAAC,GAAa,EAAE,CAAC;QAEvB,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,gEAAgE;YAChE,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,EAAE,CAAC,CAAC;YACrB,OAAO,IAAI,CAAC;QACb,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACnB,CAAC;CACD;AAED,MAAM,UAAU,yBAAyB,CACxC,MAAyB,EACzB,GAAW,EACX,IAAkB;IAKlB,MAAM,QAAQ,GAAG,kBAAkB,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IAEzD,kEAAkE;IAClE,MAAM,EAAE,GAAG,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IACpD,MAAM,QAAQ,GAAG,MAAM,CAAC,oBAAoB,CAAC,GAAG,CAAC,EAAE,OAA6B,CAAC;IAEjF,oCAAoC;IACpC,wDAAwD;IACxD,IAAI,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACnC,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;IACjC,CAAC;IAED,+EAA+E;IAC/E,8DAA8D;IAC9D,MAAM,CAAC,WAAW,CAAC,YAAY,CAC9B,GAAG;IACH,mBAAmB,CAAC,CAAC;IACrB,oBAAoB,CAAC,QAAQ,CAAC,YAAY,CAC1C,CAAC;IACF,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC;AACzB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle, ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tBaseSegment,\n\tClient,\n\ttype IJSONSegment,\n\ttype IMergeTreeDeltaCallbackArgs,\n\ttype IMergeTreeDeltaOpArgs,\n\ttype IMergeTreeMaintenanceCallbackArgs,\n\ttype ISegment,\n\tMergeTreeDeltaType,\n\tMergeTreeMaintenanceType,\n\tsegmentIsRemoved,\n\ttype IMergeTreeInsertMsg,\n\ttype IMergeTreeRemoveMsg,\n} from \"@fluidframework/merge-tree/internal\";\nimport type { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tObjectStoragePartition,\n\tSummaryTreeBuilder,\n} from \"@fluidframework/runtime-utils/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport { createChildLogger } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { HandleCache } from \"./handlecache.js\";\nimport { Handle, HandleTable, isHandleValid } from \"./handletable.js\";\nimport { deserializeBlob } from \"./serialization.js\";\nimport type { VectorUndoProvider } from \"./undoprovider.js\";\n\nconst enum SnapshotPath {\n\tsegments = \"segments\",\n\thandleTable = \"handleTable\",\n}\n\ntype PermutationSegmentSpec = [number, number];\n\nexport class PermutationSegment extends BaseSegment {\n\tpublic static readonly typeString: string = \"PermutationSegment\";\n\tprivate _start = Handle.unallocated;\n\n\tpublic static fromJSONObject(spec: IJSONSegment): PermutationSegment {\n\t\tconst [length, start] = spec as PermutationSegmentSpec;\n\t\treturn new PermutationSegment(length, start);\n\t}\n\n\tpublic readonly type = PermutationSegment.typeString;\n\n\tconstructor(length: number, start = Handle.unallocated) {\n\t\tsuper();\n\t\tthis._start = start;\n\t\tthis.cachedLength = length;\n\t}\n\n\tpublic get start(): Handle {\n\t\treturn this._start;\n\t}\n\tpublic set start(value: Handle) {\n\t\tassert(\n\t\t\tthis._start === Handle.unallocated,\n\t\t\t0x024 /* \"Start of PermutationSegment already allocated!\" */,\n\t\t);\n\t\tassert(\n\t\t\tisHandleValid(value),\n\t\t\t0x025 /* \"Trying to set start of PermutationSegment to invalid handle!\" */,\n\t\t);\n\n\t\tthis._start = value;\n\t}\n\n\tpublic reset(): void {\n\t\tthis._start = Handle.unallocated;\n\t}\n\n\tpublic toJSONObject(): number[] {\n\t\treturn [this.cachedLength, this.start];\n\t}\n\n\tpublic clone(start = 0, end = this.cachedLength): PermutationSegment {\n\t\tconst b = new PermutationSegment(\n\t\t\t/* length: */ end - start,\n\t\t\t/* start: */ this.start + start,\n\t\t);\n\t\tthis.cloneInto(b);\n\t\treturn b;\n\t}\n\n\tpublic canAppend(segment: ISegment): boolean {\n\t\tconst asPerm = segment as PermutationSegment;\n\n\t\treturn this.start === Handle.unallocated\n\t\t\t? asPerm.start === Handle.unallocated\n\t\t\t: asPerm.start === this.start + this.cachedLength;\n\t}\n\n\tprotected createSplitSegmentAt(pos: number): PermutationSegment {\n\t\tassert(\n\t\t\t0 < pos && pos < this.cachedLength,\n\t\t\t0x026 /* \"Trying to split segment at out-of-bounds position!\" */,\n\t\t);\n\n\t\tconst leafSegment = new PermutationSegment(\n\t\t\t/* length: */ this.cachedLength - pos,\n\t\t\t/* start: */ this.start === Handle.unallocated ? Handle.unallocated : this.start + pos,\n\t\t);\n\n\t\tthis.cachedLength = pos;\n\n\t\treturn leafSegment;\n\t}\n\n\tpublic toString(): string {\n\t\treturn this.start === Handle.unallocated\n\t\t\t? `<${this.cachedLength} empty>`\n\t\t\t: `<${this.cachedLength}: ${this.start}..${this.start + this.cachedLength - 1}>`;\n\t}\n}\n\nexport class PermutationVector extends Client {\n\tprivate handleTable = new HandleTable<never>(); // Tracks available storage handles for rows.\n\tpublic readonly handleCache = new HandleCache(this);\n\tpublic undo: VectorUndoProvider | undefined;\n\n\tconstructor(\n\t\tpath: string,\n\t\tlogger: ITelemetryBaseLogger,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tprivate readonly deltaCallback: (\n\t\t\tposition: number,\n\t\t\tnumRemoved: number,\n\t\t\tnumInserted: number,\n\t\t) => void,\n\t\tprivate readonly handlesRecycledCallback: (handles: Handle[]) => void,\n\t\tgetMinInFlightRefSeq: () => number | undefined,\n\t) {\n\t\tsuper(\n\t\t\tPermutationSegment.fromJSONObject,\n\t\t\tcreateChildLogger({ logger, namespace: `Matrix.${path}.MergeTreeClient` }),\n\t\t\t{\n\t\t\t\t...runtime.options,\n\t\t\t\tnewMergeTreeSnapshotFormat: true, // Force new snapshot format as it's generally more efficient for matrices.\n\t\t\t},\n\t\t\tgetMinInFlightRefSeq,\n\t\t);\n\n\t\tthis.on(\"delta\", this.onDelta);\n\t\tthis.on(\"maintenance\", this.onMaintenance);\n\t}\n\n\tpublic insert(start: number, length: number): IMergeTreeInsertMsg | undefined {\n\t\treturn this.insertSegmentLocal(start, new PermutationSegment(length));\n\t}\n\n\tpublic remove(start: number, length: number): IMergeTreeRemoveMsg {\n\t\treturn this.removeRangeLocal(start, start + length);\n\t}\n\n\tpublic getMaybeHandle(pos: number): Handle {\n\t\tassert(\n\t\t\t0 <= pos && pos < this.getLength(),\n\t\t\t0x027 /* \"Trying to get handle of out-of-bounds position!\" */,\n\t\t);\n\n\t\treturn this.handleCache.getHandle(pos);\n\t}\n\n\tpublic getAllocatedHandle(pos: number): Handle {\n\t\tlet handle = this.getMaybeHandle(pos);\n\t\tif (isHandleValid(handle)) {\n\t\t\treturn handle;\n\t\t}\n\n\t\tthis.walkSegments(\n\t\t\t(segment) => {\n\t\t\t\tconst asPerm = segment as PermutationSegment;\n\t\t\t\tasPerm.start = handle = this.handleTable.allocate();\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tpos,\n\t\t\tpos + 1,\n\t\t\t/* accum: */ undefined,\n\t\t\t/* splitRange: */ true,\n\t\t);\n\n\t\tthis.handleCache.addHandle(pos, handle);\n\n\t\treturn handle;\n\t}\n\n\tpublic adjustPosition(\n\t\tposToAdjust: number,\n\t\top: ISequencedDocumentMessage,\n\t): { pos: number | undefined; handle: Handle } {\n\t\tconst segOff = this.getContainingSegment<PermutationSegment>(posToAdjust, {\n\t\t\treferenceSequenceNumber: op.referenceSequenceNumber,\n\t\t\tclientId: op.clientId,\n\t\t});\n\n\t\tassert(\n\t\t\tsegOff !== undefined,\n\t\t\t0xbac /* segment must be available for operations in the collab window */,\n\t\t);\n\t\tconst { segment, offset } = segOff;\n\n\t\tif (segmentIsRemoved(segment)) {\n\t\t\t// this case is tricky. the segment which the row or column data is remove\n\t\t\t// but an op before that remove references a cell. we still want to apply\n\t\t\t// the op, as the row/col could become active again in the case where\n\t\t\t// the remove was local and it get's rolled back. so we allocate a handle\n\t\t\t// for the row/col if not allocated, but don't put it in the cache\n\t\t\t// as the cache can only contain live positions.\n\t\t\tlet handle = segment.start;\n\t\t\tif (!isHandleValid(handle)) {\n\t\t\t\tthis.walkSegments(\n\t\t\t\t\t(s) => {\n\t\t\t\t\t\tconst asPerm = s as PermutationSegment;\n\t\t\t\t\t\tasPerm.start = handle = this.handleTable.allocate();\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t},\n\t\t\t\t\tposToAdjust,\n\t\t\t\t\tposToAdjust + 1,\n\t\t\t\t\t/* accum: */ undefined,\n\t\t\t\t\t/* splitRange: */ true,\n\t\t\t\t\top,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn { handle, pos: undefined };\n\t\t} else {\n\t\t\tconst pos = this.getPosition(segment) + offset;\n\t\t\treturn {\n\t\t\t\tpos,\n\t\t\t\thandle: this.getAllocatedHandle(pos),\n\t\t\t};\n\t\t}\n\t}\n\n\tpublic handleToPosition(handle: Handle, localSeq = this.getCollabWindow().localSeq): number {\n\t\tassert(\n\t\t\tlocalSeq <= this.getCollabWindow().localSeq,\n\t\t\t0x028 /* \"'localSeq' for op being resubmitted must be <= the 'localSeq' of the last submitted op.\" */,\n\t\t);\n\n\t\t// TODO: In theory, the MergeTree should be able to map the (position, refSeq, localSeq) from\n\t\t// the original operation to the current position for undo/redo scenarios. This is probably the\n\t\t// ideal solution, as we would no longer need to store row/col handles in the op metadata.\n\t\t//\n\t\t// Failing that, we could avoid the O(n) search below by building a temporary map in the\n\t\t// opposite direction from the handle to either it's current position or segment + offset\n\t\t// and reuse it for the duration of undo/redo. (Ideally, we would know when the undo/redo\n\t\t// ended so we could discard this map.)\n\t\t//\n\t\t// If we find that we frequently need a reverse handle -> position lookup, we could maintain\n\t\t// one using the Tiny-Calc adjust tree.\n\t\tlet containingSegment!: PermutationSegment;\n\t\tlet containingOffset: number;\n\n\t\tthis.walkAllSegments((segment) => {\n\t\t\tconst { start, cachedLength } = segment as PermutationSegment;\n\n\t\t\t// If the segment is unallocated, skip it.\n\t\t\tif (!isHandleValid(start)) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tconst end = start + cachedLength;\n\n\t\t\tif (start <= handle && handle < end) {\n\t\t\t\tcontainingSegment = segment as PermutationSegment;\n\t\t\t\tcontainingOffset = handle - start;\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t});\n\n\t\t// We are guaranteed to find the handle in the PermutationVector, even if the corresponding\n\t\t// row/col has been removed, because handles are not recycled until the containing segment\n\t\t// is unlinked from the MergeTree.\n\t\t//\n\t\t// Therefore, either a row/col removal has been ACKed, in which case there will be no pending\n\t\t// ops that reference the stale handle, or the removal is unACKed, in which case the handle\n\t\t// has not yet been recycled.\n\n\t\tassert(\n\t\t\tisHandleValid(containingSegment.start),\n\t\t\t0x029 /* \"Invalid handle at start of containing segment!\" */,\n\t\t);\n\n\t\t// Once we know the current position of the handle, we can use the MergeTree to get the segment\n\t\t// containing this position and use 'findReconnectionPosition' to adjust for the local ops that\n\t\t// have not yet been submitted.\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\treturn this.findReconnectionPosition(containingSegment, localSeq) + containingOffset!;\n\t}\n\n\t// Constructs an ISummaryTreeWithStats for the cell data.\n\tpublic summarize(\n\t\truntime: IFluidDataStoreRuntime,\n\t\thandle: IFluidHandle,\n\t\tserializer: IFluidSerializer,\n\t): ISummaryTreeWithStats {\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tbuilder.addWithStats(\n\t\t\tSnapshotPath.segments,\n\t\t\tsuper.summarize(runtime, handle, serializer, /* catchUpMsgs: */ []),\n\t\t);\n\t\tbuilder.addBlob(\n\t\t\tSnapshotPath.handleTable,\n\t\t\tserializer.stringify(this.handleTable.getSummaryContent(), handle),\n\t\t);\n\t\treturn builder.getSummaryTree();\n\t}\n\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tstorage: IChannelStorageService,\n\t\tserializer: IFluidSerializer,\n\t): Promise<{\n\t\tcatchupOpsP: Promise<ISequencedDocumentMessage[]>;\n\t}> {\n\t\tconst handleTableData = (await deserializeBlob(\n\t\t\tstorage,\n\t\t\tSnapshotPath.handleTable,\n\t\t\tserializer,\n\t\t\t// Cast is needed since the (de)serializer returns content of type `any`.\n\t\t)) as Handle[];\n\n\t\tthis.handleTable = HandleTable.load<never>(handleTableData);\n\n\t\treturn super.load(\n\t\t\truntime,\n\t\t\tnew ObjectStoragePartition(storage, SnapshotPath.segments),\n\t\t\tserializer,\n\t\t);\n\t}\n\n\tprivate readonly onDelta = (\n\t\topArgs: IMergeTreeDeltaOpArgs,\n\t\tdeltaArgs: IMergeTreeDeltaCallbackArgs,\n\t): void => {\n\t\t// Apply deltas in descending order to prevent positions from shifting.\n\t\tconst ranges = deltaArgs.deltaSegments\n\t\t\t.map(({ segment }) => ({\n\t\t\t\tsegment: segment as PermutationSegment,\n\t\t\t\tposition: this.getPosition(segment),\n\t\t\t}))\n\t\t\t.sort((left, right) => left.position - right.position);\n\n\t\tconst isLocal = opArgs.sequencedMessage === undefined;\n\n\t\t// Notify the undo provider, if any is attached.\n\t\tif (this.undo !== undefined && isLocal) {\n\t\t\tthis.undo.record(deltaArgs);\n\t\t}\n\n\t\tswitch (deltaArgs.operation) {\n\t\t\tcase MergeTreeDeltaType.INSERT: {\n\t\t\t\t// Pass 1: Perform any internal maintenance first to avoid reentrancy.\n\t\t\t\tfor (const { segment, position } of ranges) {\n\t\t\t\t\tif (opArgs.rollback !== true) {\n\t\t\t\t\t\t// HACK: We need to include the allocated handle in the segment's JSON representation\n\t\t\t\t\t\t// for snapshots, but need to ignore the remote client's handle allocations when\n\t\t\t\t\t\t// processing remote ops.\n\t\t\t\t\t\tsegment.reset();\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.handleCache.itemsChanged(\n\t\t\t\t\t\tposition,\n\t\t\t\t\t\t/* deleteCount: */ 0,\n\t\t\t\t\t\t/* insertCount: */ segment.cachedLength,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Pass 2: Notify the 'deltaCallback', which may involve callbacks into user code.\n\t\t\t\tfor (const { segment, position } of ranges) {\n\t\t\t\t\tthis.deltaCallback(\n\t\t\t\t\t\tposition,\n\t\t\t\t\t\t/* numRemoved: */ 0,\n\t\t\t\t\t\t/* numInserted: */ segment.cachedLength,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase MergeTreeDeltaType.REMOVE: {\n\t\t\t\t// Pass 1: Perform any internal maintenance first to avoid reentrancy.\n\t\t\t\tfor (const { segment, position } of ranges) {\n\t\t\t\t\tthis.handleCache.itemsChanged(\n\t\t\t\t\t\tposition /* deleteCount: */,\n\t\t\t\t\t\tsegment.cachedLength,\n\t\t\t\t\t\t/* insertCount: */ 0,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Pass 2: Notify the 'deltaCallback', which may involve callbacks into user code.\n\t\t\t\tfor (const { segment, position } of ranges) {\n\t\t\t\t\tthis.deltaCallback(\n\t\t\t\t\t\tposition,\n\t\t\t\t\t\t/* numRemoved: */ segment.cachedLength,\n\t\t\t\t\t\t/* numInsert: */ 0,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(\"Unhandled MergeTreeDeltaType\");\n\t\t\t}\n\t\t}\n\t};\n\n\tprivate readonly onMaintenance = (args: IMergeTreeMaintenanceCallbackArgs): void => {\n\t\tif (args.operation === MergeTreeMaintenanceType.UNLINK) {\n\t\t\tlet freed: number[] = [];\n\n\t\t\tfor (const { segment } of args.deltaSegments) {\n\t\t\t\tconst asPerm = segment as PermutationSegment;\n\t\t\t\tif (isHandleValid(asPerm.start)) {\n\t\t\t\t\t// Note: Using the spread operator with `.splice()` can exhaust the stack.\n\t\t\t\t\t// eslint-disable-next-line unicorn/prefer-spread\n\t\t\t\t\tfreed = freed.concat(\n\t\t\t\t\t\tArray.from({ length: asPerm.cachedLength })\n\t\t\t\t\t\t\t.fill(0)\n\t\t\t\t\t\t\t.map((value, index) => index + asPerm.start),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Notify matrix that handles are about to be freed. The matrix is responsible for clearing\n\t\t\t// the rows/cols prior to free to ensure recycled row/cols are initially empty.\n\t\t\tthis.handlesRecycledCallback(freed);\n\n\t\t\t// Now that the physical storage has been cleared, add the recycled handles back to the free pool.\n\t\t\tfor (const handle of freed) {\n\t\t\t\tthis.handleTable.free(handle);\n\t\t\t}\n\t\t}\n\t};\n\n\tpublic toString(): string {\n\t\tconst s: string[] = [];\n\n\t\tthis.walkSegments((segment) => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-base-to-string\n\t\t\ts.push(`${segment}`);\n\t\t\treturn true;\n\t\t});\n\n\t\treturn s.join(\"\");\n\t}\n}\n\nexport function reinsertSegmentIntoVector(\n\tvector: PermutationVector,\n\tpos: number,\n\tspec: IJSONSegment,\n): {\n\top: IMergeTreeInsertMsg | undefined;\n\tinserted: PermutationSegment;\n} {\n\tconst original = PermutationSegment.fromJSONObject(spec);\n\n\t// (Re)insert the removed number of rows at the original position.\n\tconst op = vector.insertSegmentLocal(pos, original);\n\tconst inserted = vector.getContainingSegment(pos)?.segment as PermutationSegment;\n\n\t// we reuse the original handle here\n\t// so if cells exist, they can be found, and re-inserted\n\tif (isHandleValid(original.start)) {\n\t\tinserted.start = original.start;\n\t}\n\n\t// Invalidate the handleCache in case it was populated during the 'rowsChanged'\n\t// callback, which occurs before the handle span is populated.\n\tvector.handleCache.itemsChanged(\n\t\tpos,\n\t\t/* removedCount: */ 0,\n\t\t/* insertedCount: */ inserted.cachedLength,\n\t);\n\treturn { op, inserted };\n}\n"]}
|
package/lib/runtime.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IChannel, IChannelAttributes, IChannelFactory, IFluidDataStoreRuntime, IChannelServices } from "@fluidframework/datastore-definitions/internal";
|
|
5
|
+
import type { IChannel, IChannelAttributes, IChannelFactory, IFluidDataStoreRuntime, IChannelServices } from "@fluidframework/datastore-definitions/internal";
|
|
6
6
|
import { type ISharedMatrix } from "./matrix.js";
|
|
7
7
|
/**
|
|
8
8
|
* {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link ISharedMatrix}.
|
package/lib/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,MAAM,gDAAgD,CAAC;AAGxD,OAAO,EAAE,KAAK,aAAa,EAAqC,MAAM,aAAa,CAAC;AAGpF;;;;;GAKG;AACH,qBAAa,mBAAoB,YAAW,eAAe,CAAC,aAAa,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AC9D,MAAM,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC5B,OAAO,MAAM,CAAC;IACf,CAAC;IAEM,MAAM,CAAC,QAAgC,EAAE,EAAU;QACzD,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,QAAQ,EAAE,EAAE,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACpE,MAAM,CAAC,eAAe,EAAE,CAAC;QACzB,OAAO,MAAM,CAAC;IACf,CAAC;;AAlCa,wBAAI,GAAG,gDAAgD,CAAC;AAE/C,8BAAU,GAAuB;IACvD,IAAI,EAAE,mBAAmB,CAAC,IAAI;IAC9B,qBAAqB,EAAE,KAAK;IAC5B,cAAc,EAAE,UAAU;CAC1B,CAAC;AA+BH;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,sBAAsB,CAAgB,mBAAmB,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIChannel,\n\tIChannelAttributes,\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n\tIChannelServices,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { createSharedObjectKind } from \"@fluidframework/shared-object-base/internal\";\n\nimport { type ISharedMatrix, SharedMatrix as SharedMatrixClass } from \"./matrix.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link ISharedMatrix}.\n * @legacy\n * @alpha\n * @deprecated - Use `SharedMatrix.getFactory` instead.\n */\nexport class SharedMatrixFactory implements IChannelFactory<ISharedMatrix> {\n\tpublic static Type = \"https://graph.microsoft.com/types/sharedmatrix\";\n\n\tpublic static readonly Attributes: IChannelAttributes = {\n\t\ttype: SharedMatrixFactory.Type,\n\t\tsnapshotFormatVersion: \"0.1\",\n\t\tpackageVersion: pkgVersion,\n\t};\n\n\tpublic get type(): string {\n\t\treturn SharedMatrixFactory.Type;\n\t}\n\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn SharedMatrixFactory.Attributes;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n\t */\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tattributes: IChannelAttributes,\n\t): Promise<ISharedMatrix & IChannel> {\n\t\tconst matrix = new SharedMatrixClass(runtime, id, attributes);\n\t\tawait matrix.load(services);\n\t\treturn matrix;\n\t}\n\n\tpublic create(document: IFluidDataStoreRuntime, id: string): ISharedMatrix & IChannel {\n\t\tconst matrix = new SharedMatrixClass(document, id, this.attributes);\n\t\tmatrix.initializeLocal();\n\t\treturn matrix;\n\t}\n}\n\n/**\n * Entrypoint for {@link ISharedMatrix} creation.\n * @legacy\n * @alpha\n */\nexport const SharedMatrix = createSharedObjectKind<ISharedMatrix>(SharedMatrixFactory);\n\n/**\n * Convenience alias for {@link ISharedMatrix}. Prefer to use {@link ISharedMatrix} when referring to\n * SharedMatrix as a type.\n * @legacy\n * @alpha\n * @privateRemarks\n * This alias is for legacy compat from when the SharedMatrix class was exported as public.\n */\n// Changing this to `unknown` would be a breaking change.\n// TODO: if possible, transition SharedMatrix to not use `any`.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type SharedMatrix<T = any> = ISharedMatrix<T>;\n"]}
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AAErF,OAAO,EAAsB,YAAY,IAAI,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,OAAO,mBAAmB;IAS/B,IAAW,IAAI;QACd,OAAO,mBAAmB,CAAC,IAAI,CAAC;IACjC,CAAC;IAED,IAAW,UAAU;QACpB,OAAO,mBAAmB,CAAC,UAAU,CAAC;IACvC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI,CAChB,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;QAE9B,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,OAAO,EAAE,EAAE,EAAE,UAAU,CAAC,CAAC;QAC9D,MAAM,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC5B,OAAO,MAAM,CAAC;IACf,CAAC;IAEM,MAAM,CAAC,QAAgC,EAAE,EAAU;QACzD,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,QAAQ,EAAE,EAAE,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACpE,MAAM,CAAC,eAAe,EAAE,CAAC;QACzB,OAAO,MAAM,CAAC;IACf,CAAC;;AAlCa,wBAAI,GAAG,gDAAgD,CAAC;AAE/C,8BAAU,GAAuB;IACvD,IAAI,EAAE,mBAAmB,CAAC,IAAI;IAC9B,qBAAqB,EAAE,KAAK;IAC5B,cAAc,EAAE,UAAU;CAC1B,CAAC;AA+BH;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,sBAAsB,CAAgB,mBAAmB,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIChannel,\n\tIChannelAttributes,\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n\tIChannelServices,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { createSharedObjectKind } from \"@fluidframework/shared-object-base/internal\";\n\nimport { type ISharedMatrix, SharedMatrix as SharedMatrixClass } from \"./matrix.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link ISharedMatrix}.\n * @legacy\n * @alpha\n * @deprecated - Use `SharedMatrix.getFactory` instead.\n */\nexport class SharedMatrixFactory implements IChannelFactory<ISharedMatrix> {\n\tpublic static Type = \"https://graph.microsoft.com/types/sharedmatrix\";\n\n\tpublic static readonly Attributes: IChannelAttributes = {\n\t\ttype: SharedMatrixFactory.Type,\n\t\tsnapshotFormatVersion: \"0.1\",\n\t\tpackageVersion: pkgVersion,\n\t};\n\n\tpublic get type(): string {\n\t\treturn SharedMatrixFactory.Type;\n\t}\n\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn SharedMatrixFactory.Attributes;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n\t */\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tattributes: IChannelAttributes,\n\t): Promise<ISharedMatrix & IChannel> {\n\t\tconst matrix = new SharedMatrixClass(runtime, id, attributes);\n\t\tawait matrix.load(services);\n\t\treturn matrix;\n\t}\n\n\tpublic create(document: IFluidDataStoreRuntime, id: string): ISharedMatrix & IChannel {\n\t\tconst matrix = new SharedMatrixClass(document, id, this.attributes);\n\t\tmatrix.initializeLocal();\n\t\treturn matrix;\n\t}\n}\n\n/**\n * Entrypoint for {@link ISharedMatrix} creation.\n * @legacy\n * @alpha\n */\nexport const SharedMatrix = createSharedObjectKind<ISharedMatrix>(SharedMatrixFactory);\n\n/**\n * Convenience alias for {@link ISharedMatrix}. Prefer to use {@link ISharedMatrix} when referring to\n * SharedMatrix as a type.\n * @legacy\n * @alpha\n * @privateRemarks\n * This alias is for legacy compat from when the SharedMatrix class was exported as public.\n */\n// Changing this to `unknown` would be a breaking change.\n// TODO: if possible, transition SharedMatrix to not use `any`.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type SharedMatrix<T = any> = ISharedMatrix<T>;\n"]}
|
package/lib/serialization.d.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
6
|
-
import { IChannelStorageService, Serializable } from "@fluidframework/datastore-definitions/internal";
|
|
5
|
+
import type { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
6
|
+
import type { IChannelStorageService, Serializable } from "@fluidframework/datastore-definitions/internal";
|
|
7
7
|
import { BlobTreeEntry } from "@fluidframework/driver-utils/internal";
|
|
8
|
-
import { IFluidSerializer } from "@fluidframework/shared-object-base/internal";
|
|
8
|
+
import type { IFluidSerializer } from "@fluidframework/shared-object-base/internal";
|
|
9
9
|
export declare const serializeBlob: <T>(handle: IFluidHandle, path: string, snapshot: Serializable<T>, serializer: IFluidSerializer) => BlobTreeEntry;
|
|
10
10
|
export declare function deserializeBlob(storage: IChannelStorageService, path: string, serializer: IFluidSerializer): Promise<any>;
|
|
11
11
|
//# sourceMappingURL=serialization.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../src/serialization.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../src/serialization.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,KAAK,EACX,sBAAsB,EACtB,YAAY,EACZ,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAEpF,eAAO,MAAM,aAAa,cACjB,YAAY,QACd,MAAM,YACF,aAAa,CAAC,CAAC,cACb,gBAAgB,KAC1B,aAAgF,CAAC;AAEpF,wBAAsB,eAAe,CACpC,OAAO,EAAE,sBAAsB,EAC/B,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,gBAAgB,GAG1B,OAAO,CAAC,GAAG,CAAC,CAId"}
|
package/lib/serialization.js
CHANGED
|
@@ -8,7 +8,6 @@ export const serializeBlob = (handle, path, snapshot, serializer) => new BlobTre
|
|
|
8
8
|
export async function deserializeBlob(storage, path, serializer) {
|
|
9
9
|
const blob = await storage.readBlob(path);
|
|
10
10
|
const utf8 = bufferToString(blob, "utf8");
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
12
11
|
return serializer.parse(utf8);
|
|
13
12
|
}
|
|
14
13
|
//# sourceMappingURL=serialization.js.map
|
package/lib/serialization.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["../src/serialization.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAM9D,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAGtE,MAAM,CAAC,MAAM,aAAa,GAAG,CAC5B,MAAoB,EACpB,IAAY,EACZ,QAAyB,EACzB,UAA4B,EACZ,EAAE,CAAC,IAAI,aAAa,CAAC,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;AAEpF,MAAM,CAAC,KAAK,UAAU,eAAe,CACpC,OAA+B,EAC/B,IAAY,EACZ,UAA4B;IAI5B,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC1C
|
|
1
|
+
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["../src/serialization.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAM9D,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAGtE,MAAM,CAAC,MAAM,aAAa,GAAG,CAC5B,MAAoB,EACpB,IAAY,EACZ,QAAyB,EACzB,UAA4B,EACZ,EAAE,CAAC,IAAI,aAAa,CAAC,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;AAEpF,MAAM,CAAC,KAAK,UAAU,eAAe,CACpC,OAA+B,EAC/B,IAAY,EACZ,UAA4B;IAI5B,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC1C,OAAO,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport type {\n\tIChannelStorageService,\n\tSerializable,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { BlobTreeEntry } from \"@fluidframework/driver-utils/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\n\nexport const serializeBlob = <T>(\n\thandle: IFluidHandle,\n\tpath: string,\n\tsnapshot: Serializable<T>,\n\tserializer: IFluidSerializer,\n): BlobTreeEntry => new BlobTreeEntry(path, serializer.stringify(snapshot, handle));\n\nexport async function deserializeBlob(\n\tstorage: IChannelStorageService,\n\tpath: string,\n\tserializer: IFluidSerializer,\n\t// Allowing parsed content to remain in its original (any) form.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n): Promise<any> {\n\tconst blob = await storage.readBlob(path);\n\tconst utf8 = bufferToString(blob, \"utf8\");\n\treturn serializer.parse(utf8);\n}\n"]}
|
package/lib/sparsearray2d.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IMatrixReader, IMatrixWriter,
|
|
5
|
+
import type { IMatrixReader, IMatrixWriter, IMatrixProducer } from "@tiny-calc/nano";
|
|
6
6
|
type RecurArrayHelper<T> = RecurArray<T> | T;
|
|
7
7
|
export type RecurArray<T> = RecurArrayHelper<T>[];
|
|
8
8
|
type UA<T> = (T | undefined)[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sparsearray2d.d.ts","sourceRoot":"","sources":["../src/sparsearray2d.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"sparsearray2d.d.ts","sourceRoot":"","sources":["../src/sparsearray2d.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAqCrF,KAAK,gBAAgB,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAC7C,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;AAWlD,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC,EAAE,CAAC;AAE/B;;GAEG;AACH,qBAAa,aAAa,CAAC,CAAC,CAC3B,YAAW,aAAa,CAAC,CAAC,GAAG,SAAS,CAAC,EAAE,aAAa,CAAC,CAAC,GAAG,SAAS,CAAC;IAEzD,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,GAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAe;IAEtE,SAAgB,QAAQ,cAAc;IACtC,SAAgB,QA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AAC,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI,KAAK,CAAgB,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAClF,CAAC;IAEM,QAAQ;QACd,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IAEM,MAAM,CAAC,IAAI,CAAI,IAAmB;QACxC,OAAO,IAAI,aAAa,CAAI,eAAe,CAAI,IAAI,CAA6B,CAAC,CAAC;IACnF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\n\nimport { IMatrixReader, IMatrixWriter, type IMatrixProducer } from \"@tiny-calc/nano\";\n\n// Build a lookup table that maps a uint8 to the corresponding uint16 where 0s\n// are interleaved between the original bits. (e.g., 1111... -> 01010101...).\n//\n// (Lookup table ~17% faster than inlining the bit-twiddling on Node v12 x64)\n// (Array<T> ~2% faster than typed array on Node v12 x64)\nconst x8ToInterlacedX16 = Array.from({ length: 256 })\n\t.fill(0)\n\t.map((value, i) => {\n\t\tlet j = i;\n\t\tj = (j | (j << 4)) & 0x0f0f; // .... 7654 .... 3210\n\t\tj = (j | (j << 2)) & 0x3333; // ..76 ..54 ..32 ..10\n\t\tj = (j | (j << 1)) & 0x5555; // .7.6 .5.4 .3.2 .1.0\n\t\treturn j;\n\t});\n\n// Selects individual bytes from a given 32b integer. The left shift are used to\n// clear upper bits (faster than using masks on Node 10 x64).\nconst byte0 = (x32: number): number => x32 >>> 24;\nconst byte1 = (x32: number): number => (x32 << 8) >>> 24;\nconst byte2 = (x32: number): number => (x32 << 16) >>> 24;\nconst byte3 = (x32: number): number => (x32 << 24) >>> 24;\n\n// Given a uint16 returns the corresponding uint32 integer where 0s are\n// interleaved between the original bits. (e.g., 1111... -> 01010101...).\nconst interlaceBitsX16 = (x16: number): number =>\n\t(x8ToInterlacedX16[byte2(x16)] << 16) | x8ToInterlacedX16[byte3(x16)];\n\nconst r0ToMorton16 = (row: number): number => (interlaceBitsX16(row) << 1) >>> 0;\nconst c0ToMorton16 = (col: number): number => interlaceBitsX16(col) >>> 0;\n\n// Given a 2D uint16 coordinate returns the corresponding unt32 Morton coded\n// coordinate. (See https://en.wikipedia.org/wiki/Z-order_curve)\nconst r0c0ToMorton2x16 = (row: number, col: number): number =>\n\t(r0ToMorton16(row) | c0ToMorton16(col)) >>> 0;\n\ntype RecurArrayHelper<T> = RecurArray<T> | T;\nexport type RecurArray<T> = RecurArrayHelper<T>[];\n\n/**\n * Undo JSON serialization's coercion of 'undefined' to null.\n */\n// eslint-disable-next-line @rushstack/no-new-null -- Private use of 'null' to preserve 'undefined'\nconst nullToUndefined = <T>(array: RecurArray<T | null>): RecurArray<T | undefined> =>\n\tarray.map((value) => {\n\t\treturn value === null ? undefined : Array.isArray(value) ? nullToUndefined(value) : value;\n\t});\n\ntype UA<T> = (T | undefined)[];\n\n/**\n * A sparse 4 billion x 4 billion array stored as 16x16 tiles.\n */\nexport class SparseArray2D<T>\n\timplements IMatrixReader<T | undefined>, IMatrixWriter<T | undefined>\n{\n\tconstructor(private readonly root: UA<UA<UA<UA<UA<T>>>>> = [undefined]) {}\n\n\tpublic readonly rowCount = 0xffffffff;\n\tpublic readonly colCount = 0xffffffff;\n\n\tpublic getCell(row: number, col: number): T | undefined {\n\t\tconst keyHi = r0c0ToMorton2x16(row >>> 16, col >>> 16);\n\t\tconst level0 = this.root[keyHi];\n\t\tif (level0 !== undefined) {\n\t\t\tconst keyLo = r0c0ToMorton2x16(row, col);\n\t\t\tconst level1 = level0[byte0(keyLo)];\n\t\t\tif (level1 !== undefined) {\n\t\t\t\tconst level2 = level1[byte1(keyLo)];\n\t\t\t\tif (level2 !== undefined) {\n\t\t\t\t\tconst level3 = level2[byte2(keyLo)];\n\t\t\t\t\tif (level3 !== undefined) {\n\t\t\t\t\t\treturn level3[byte3(keyLo)];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tpublic get matrixProducer(): IMatrixProducer<T> {\n\t\t// Cast is needed to satisfy the interface declaration while also not returning\n\t\t// an IMatrixProducer for this class.\n\t\treturn undefined as unknown as IMatrixProducer<T>;\n\t}\n\n\tpublic setCell(row: number, col: number, value: T | undefined): void {\n\t\tconst keyHi = r0c0ToMorton2x16(row >>> 16, col >>> 16);\n\t\tconst keyLo = r0c0ToMorton2x16(row, col);\n\n\t\tconst level0 = this.getLevel(this.root, keyHi);\n\t\tconst level1 = this.getLevel(level0, byte0(keyLo));\n\t\tconst level2 = this.getLevel(level1, byte1(keyLo));\n\t\tconst level3 = this.getLevel(level2, byte2(keyLo));\n\t\tlevel3[byte3(keyLo)] = value;\n\t}\n\n\t/**\n\t * Invokes the given 'callback' for each key in a 16 x 16 tile at the indicated row.\n\t *\n\t * (Note that 'rowBits' is the appropriate byte from 'r0ToMorton16' for the current\n\t * level being traversed.)\n\t */\n\tprivate forEachKeyInRow(rowBits: number, callback: (key: number) => void): void {\n\t\tfor (let col = 0; col < 16; col++) {\n\t\t\t// Perf: Potentially faster to replace 'c0ToMorton16()' with a short look up table?\n\t\t\tcallback((rowBits | c0ToMorton16(col)) >>> 0);\n\t\t}\n\t}\n\n\t/**\n\t * Invokes the given 'callback' for each key in a 16 x 16 tile at the indicated col.\n\t *\n\t * (Note that 'colBits' is the appropriate byte from 'c0ToMorton16' for the current\n\t * level being traversed.)\n\t */\n\tprivate forEachKeyInCol(col: number, callback: (key: number) => void): void {\n\t\tfor (let row = 0; row < 16; row++) {\n\t\t\t// Perf: Potentially faster to replace 'r0ToMorton16()' with a short look up table?\n\t\t\tcallback((r0ToMorton16(row) | col) >>> 0);\n\t\t}\n\t}\n\n\t/**\n\t * Invokes the give 'callback' with the next 'level' array for each populated region\n\t * of the given row in the 'currentLevel'.\n\t *\n\t * (Note that 'rowBits' is the appropriate byte from 'r0ToMorton16' for the current\n\t * level being traversed.)\n\t */\n\t// The suppression is needed because forEachInRow is called in a loop, and expected to\n\t// use various abstractions on UA<T> at each level of the loop.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tprivate forEachInRow<V extends UA<any>, U extends UA<V>>(\n\t\tcurrentLevel: U,\n\t\trowBits: number,\n\t\tcallback: (level: V) => void,\n\t): void {\n\t\tthis.forEachKeyInRow(rowBits, (key) => {\n\t\t\tconst nextLevel = currentLevel[key];\n\t\t\tif (nextLevel !== undefined) {\n\t\t\t\tcallback(nextLevel);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Invokes the give 'callback' with the next 'level' array for each populated region\n\t * of the given col in the 'currentLevel'.\n\t *\n\t * (Note that 'colBits' is the appropriate byte from 'c0ToMorton16' for the current\n\t * level being traversed.)\n\t */\n\t// The suppression is needed because forEachInRow is called in a loop, and expected to\n\t// use various abstractions on UA<T> at each level of the loop.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tprivate forEachInCol<V extends UA<any>, U extends UA<V>>(\n\t\tcurrentLevel: U,\n\t\tcolBits: number,\n\t\tcallback: (level: V) => void,\n\t): void {\n\t\tthis.forEachKeyInCol(colBits, (key) => {\n\t\t\tconst nextLevel = currentLevel[key];\n\t\t\tif (nextLevel !== undefined) {\n\t\t\t\tcallback(nextLevel);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Clears the all cells contained within the specified span of rows.\n\t */\n\tpublic clearRows(rowStart: number, rowCount: number): void {\n\t\tconst rowEnd = rowStart + rowCount;\n\t\tfor (let row = rowStart; row < rowEnd; row++) {\n\t\t\tconst rowHi = r0ToMorton16(row >>> 16);\n\n\t\t\t// The top level of tree is a 64k x 64k tile. We need to scan all 64k entries.\n\t\t\tfor (let colHi = 0; colHi < 0x10000; colHi++) {\n\t\t\t\tconst keyHi = (rowHi | c0ToMorton16(colHi)) >>> 0;\n\t\t\t\tconst level0 = this.root[keyHi];\n\t\t\t\tif (level0 !== undefined) {\n\t\t\t\t\t// The remainder of the tree is divided in 16 x 16 tiles.\n\t\t\t\t\tconst rowLo = r0ToMorton16(row);\n\t\t\t\t\tthis.forEachInRow(level0, byte0(rowLo), (level1) => {\n\t\t\t\t\t\tthis.forEachInRow(level1, byte1(rowLo), (level2) => {\n\t\t\t\t\t\t\tthis.forEachInRow(level2, byte2(rowLo), (level3) => {\n\t\t\t\t\t\t\t\tthis.forEachKeyInRow(byte3(rowLo), (key) => {\n\t\t\t\t\t\t\t\t\tlevel3[key] = undefined;\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Clears the all cells contained within the specifed span of cols.\n\t */\n\tpublic clearCols(colStart: number, colCount: number): void {\n\t\tconst colEnd = colStart + colCount;\n\t\tfor (let col = colStart; col < colEnd; col++) {\n\t\t\tconst colHi = c0ToMorton16(col >>> 16);\n\n\t\t\t// The top level of tree is a 64k x 64k tile. We need to scan all 64k entries.\n\t\t\tfor (let rowHi = 0; rowHi < 0x10000; rowHi++) {\n\t\t\t\tconst keyHi = (colHi | r0ToMorton16(rowHi)) >>> 0;\n\t\t\t\tconst level0 = this.root[keyHi];\n\t\t\t\tif (level0 !== undefined) {\n\t\t\t\t\t// The remainder of the tree is divided in 16 x 16 tiles.\n\t\t\t\t\tconst colLo = c0ToMorton16(col);\n\t\t\t\t\tthis.forEachInCol(level0, byte0(colLo), (level1) => {\n\t\t\t\t\t\tthis.forEachInCol(level1, byte1(colLo), (level2) => {\n\t\t\t\t\t\t\tthis.forEachInCol(level2, byte2(colLo), (level3) => {\n\t\t\t\t\t\t\t\tthis.forEachKeyInCol(byte3(colLo), (key) => {\n\t\t\t\t\t\t\t\t\tlevel3[key] = undefined;\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate getLevel<T>(parent: UA<UA<T>>, subKey: number): UA<T> {\n\t\tconst level = parent[subKey];\n\t\t// Using new Array is needed because the array created with Array.from does not\n\t\t// satisfy (T|undefined)[].\n\t\t// eslint-disable-next-line unicorn/no-new-array\n\t\treturn level ?? (parent[subKey] = new Array<T | undefined>(256).fill(undefined));\n\t}\n\n\tpublic snapshot(): UA<UA<UA<UA<UA<T>>>>> {\n\t\treturn this.root;\n\t}\n\n\tpublic static load<T>(data: RecurArray<T>): SparseArray2D<T> {\n\t\treturn new SparseArray2D<T>(nullToUndefined<T>(data) as SparseArray2D<T>[\"root\"]);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sparsearray2d.js","sourceRoot":"","sources":["../src/sparsearray2d.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,8EAA8E;AAC9E,6EAA6E;AAC7E,EAAE;AACF,6EAA6E;AAC7E,yDAAyD;AACzD,MAAM,iBAAiB,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;KACnD,IAAI,CAAC,CAAC,CAAC;KACP,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;IACjB,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,sBAAsB;IACnD,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,sBAAsB;IACnD,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,sBAAsB;IACnD,OAAO,CAAC,CAAC;AACV,CAAC,CAAC,CAAC;AAEJ,iFAAiF;AACjF,6DAA6D;AAC7D,MAAM,KAAK,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC;AAClD,MAAM,KAAK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,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE;wBAClD,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE;4BAClD,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE;gCAClD,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE;oCAC1C,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;gCACzB,CAAC,CAAC,CAAC;4BACJ,CAAC,CAAC,CAAC;wBACJ,CAAC,CAAC,CAAC;oBACJ,CAAC,CAAC,CAAC;gBACJ,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;IAEO,QAAQ,CAAI,MAAiB,EAAE,MAAc;QACpD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QAC7B,+EAA+E;QAC/E,2BAA2B;QAC3B,gDAAgD;QAChD,OAAO,KAAK,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI,KAAK,CAAgB,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAClF,CAAC;IAEM,QAAQ;QACd,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IAEM,MAAM,CAAC,IAAI,CAAI,IAAmB;QACxC,OAAO,IAAI,aAAa,CAAI,eAAe,CAAI,IAAI,CAA6B,CAAC,CAAC;IACnF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\n\nimport type { IMatrixReader, IMatrixWriter, IMatrixProducer } from \"@tiny-calc/nano\";\n\n// Build a lookup table that maps a uint8 to the corresponding uint16 where 0s\n// are interleaved between the original bits. (e.g., 1111... -> 01010101...).\n//\n// (Lookup table ~17% faster than inlining the bit-twiddling on Node v12 x64)\n// (Array<T> ~2% faster than typed array on Node v12 x64)\nconst x8ToInterlacedX16 = Array.from({ length: 256 })\n\t.fill(0)\n\t.map((value, i) => {\n\t\tlet j = i;\n\t\tj = (j | (j << 4)) & 0x0f0f; // .... 7654 .... 3210\n\t\tj = (j | (j << 2)) & 0x3333; // ..76 ..54 ..32 ..10\n\t\tj = (j | (j << 1)) & 0x5555; // .7.6 .5.4 .3.2 .1.0\n\t\treturn j;\n\t});\n\n// Selects individual bytes from a given 32b integer. The left shift are used to\n// clear upper bits (faster than using masks on Node 10 x64).\nconst byte0 = (x32: number): number => x32 >>> 24;\nconst byte1 = (x32: number): number => (x32 << 8) >>> 24;\nconst byte2 = (x32: number): number => (x32 << 16) >>> 24;\nconst byte3 = (x32: number): number => (x32 << 24) >>> 24;\n\n// Given a uint16 returns the corresponding uint32 integer where 0s are\n// interleaved between the original bits. (e.g., 1111... -> 01010101...).\nconst interlaceBitsX16 = (x16: number): number =>\n\t(x8ToInterlacedX16[byte2(x16)] << 16) | x8ToInterlacedX16[byte3(x16)];\n\nconst r0ToMorton16 = (row: number): number => (interlaceBitsX16(row) << 1) >>> 0;\nconst c0ToMorton16 = (col: number): number => interlaceBitsX16(col) >>> 0;\n\n// Given a 2D uint16 coordinate returns the corresponding unt32 Morton coded\n// coordinate. (See https://en.wikipedia.org/wiki/Z-order_curve)\nconst r0c0ToMorton2x16 = (row: number, col: number): number =>\n\t(r0ToMorton16(row) | c0ToMorton16(col)) >>> 0;\n\ntype RecurArrayHelper<T> = RecurArray<T> | T;\nexport type RecurArray<T> = RecurArrayHelper<T>[];\n\n/**\n * Undo JSON serialization's coercion of 'undefined' to null.\n */\n// eslint-disable-next-line @rushstack/no-new-null -- Private use of 'null' to preserve 'undefined'\nconst nullToUndefined = <T>(array: RecurArray<T | null>): RecurArray<T | undefined> =>\n\tarray.map((value) => {\n\t\treturn value === null ? undefined : Array.isArray(value) ? nullToUndefined(value) : value;\n\t});\n\ntype UA<T> = (T | undefined)[];\n\n/**\n * A sparse 4 billion x 4 billion array stored as 16x16 tiles.\n */\nexport class SparseArray2D<T>\n\timplements IMatrixReader<T | undefined>, IMatrixWriter<T | undefined>\n{\n\tconstructor(private readonly root: UA<UA<UA<UA<UA<T>>>>> = [undefined]) {}\n\n\tpublic readonly rowCount = 0xffffffff;\n\tpublic readonly colCount = 0xffffffff;\n\n\tpublic getCell(row: number, col: number): T | undefined {\n\t\tconst keyHi = r0c0ToMorton2x16(row >>> 16, col >>> 16);\n\t\tconst level0 = this.root[keyHi];\n\t\tif (level0 !== undefined) {\n\t\t\tconst keyLo = r0c0ToMorton2x16(row, col);\n\t\t\tconst level1 = level0[byte0(keyLo)];\n\t\t\tif (level1 !== undefined) {\n\t\t\t\tconst level2 = level1[byte1(keyLo)];\n\t\t\t\tif (level2 !== undefined) {\n\t\t\t\t\tconst level3 = level2[byte2(keyLo)];\n\t\t\t\t\tif (level3 !== undefined) {\n\t\t\t\t\t\treturn level3[byte3(keyLo)];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tpublic get matrixProducer(): IMatrixProducer<T> {\n\t\t// Cast is needed to satisfy the interface declaration while also not returning\n\t\t// an IMatrixProducer for this class.\n\t\treturn undefined as unknown as IMatrixProducer<T>;\n\t}\n\n\tpublic setCell(row: number, col: number, value: T | undefined): void {\n\t\tconst keyHi = r0c0ToMorton2x16(row >>> 16, col >>> 16);\n\t\tconst keyLo = r0c0ToMorton2x16(row, col);\n\n\t\tconst level0 = this.getLevel(this.root, keyHi);\n\t\tconst level1 = this.getLevel(level0, byte0(keyLo));\n\t\tconst level2 = this.getLevel(level1, byte1(keyLo));\n\t\tconst level3 = this.getLevel(level2, byte2(keyLo));\n\t\tlevel3[byte3(keyLo)] = value;\n\t}\n\n\t/**\n\t * Invokes the given 'callback' for each key in a 16 x 16 tile at the indicated row.\n\t *\n\t * (Note that 'rowBits' is the appropriate byte from 'r0ToMorton16' for the current\n\t * level being traversed.)\n\t */\n\tprivate forEachKeyInRow(rowBits: number, callback: (key: number) => void): void {\n\t\tfor (let col = 0; col < 16; col++) {\n\t\t\t// Perf: Potentially faster to replace 'c0ToMorton16()' with a short look up table?\n\t\t\tcallback((rowBits | c0ToMorton16(col)) >>> 0);\n\t\t}\n\t}\n\n\t/**\n\t * Invokes the given 'callback' for each key in a 16 x 16 tile at the indicated col.\n\t *\n\t * (Note that 'colBits' is the appropriate byte from 'c0ToMorton16' for the current\n\t * level being traversed.)\n\t */\n\tprivate forEachKeyInCol(col: number, callback: (key: number) => void): void {\n\t\tfor (let row = 0; row < 16; row++) {\n\t\t\t// Perf: Potentially faster to replace 'r0ToMorton16()' with a short look up table?\n\t\t\tcallback((r0ToMorton16(row) | col) >>> 0);\n\t\t}\n\t}\n\n\t/**\n\t * Invokes the give 'callback' with the next 'level' array for each populated region\n\t * of the given row in the 'currentLevel'.\n\t *\n\t * (Note that 'rowBits' is the appropriate byte from 'r0ToMorton16' for the current\n\t * level being traversed.)\n\t */\n\t// The suppression is needed because forEachInRow is called in a loop, and expected to\n\t// use various abstractions on UA<T> at each level of the loop.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tprivate forEachInRow<V extends UA<any>, U extends UA<V>>(\n\t\tcurrentLevel: U,\n\t\trowBits: number,\n\t\tcallback: (level: V) => void,\n\t): void {\n\t\tthis.forEachKeyInRow(rowBits, (key) => {\n\t\t\tconst nextLevel = currentLevel[key];\n\t\t\tif (nextLevel !== undefined) {\n\t\t\t\tcallback(nextLevel);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Invokes the give 'callback' with the next 'level' array for each populated region\n\t * of the given col in the 'currentLevel'.\n\t *\n\t * (Note that 'colBits' is the appropriate byte from 'c0ToMorton16' for the current\n\t * level being traversed.)\n\t */\n\t// The suppression is needed because forEachInRow is called in a loop, and expected to\n\t// use various abstractions on UA<T> at each level of the loop.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tprivate forEachInCol<V extends UA<any>, U extends UA<V>>(\n\t\tcurrentLevel: U,\n\t\tcolBits: number,\n\t\tcallback: (level: V) => void,\n\t): void {\n\t\tthis.forEachKeyInCol(colBits, (key) => {\n\t\t\tconst nextLevel = currentLevel[key];\n\t\t\tif (nextLevel !== undefined) {\n\t\t\t\tcallback(nextLevel);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Clears the all cells contained within the specified span of rows.\n\t */\n\tpublic clearRows(rowStart: number, rowCount: number): void {\n\t\tconst rowEnd = rowStart + rowCount;\n\t\tfor (let row = rowStart; row < rowEnd; row++) {\n\t\t\tconst rowHi = r0ToMorton16(row >>> 16);\n\n\t\t\t// The top level of tree is a 64k x 64k tile. We need to scan all 64k entries.\n\t\t\tfor (let colHi = 0; colHi < 0x10000; colHi++) {\n\t\t\t\tconst keyHi = (rowHi | c0ToMorton16(colHi)) >>> 0;\n\t\t\t\tconst level0 = this.root[keyHi];\n\t\t\t\tif (level0 !== undefined) {\n\t\t\t\t\t// The remainder of the tree is divided in 16 x 16 tiles.\n\t\t\t\t\tconst rowLo = r0ToMorton16(row);\n\t\t\t\t\tthis.forEachInRow(level0, byte0(rowLo), (level1) => {\n\t\t\t\t\t\tthis.forEachInRow(level1, byte1(rowLo), (level2) => {\n\t\t\t\t\t\t\tthis.forEachInRow(level2, byte2(rowLo), (level3) => {\n\t\t\t\t\t\t\t\tthis.forEachKeyInRow(byte3(rowLo), (key) => {\n\t\t\t\t\t\t\t\t\tlevel3[key] = undefined;\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Clears the all cells contained within the specifed span of cols.\n\t */\n\tpublic clearCols(colStart: number, colCount: number): void {\n\t\tconst colEnd = colStart + colCount;\n\t\tfor (let col = colStart; col < colEnd; col++) {\n\t\t\tconst colHi = c0ToMorton16(col >>> 16);\n\n\t\t\t// The top level of tree is a 64k x 64k tile. We need to scan all 64k entries.\n\t\t\tfor (let rowHi = 0; rowHi < 0x10000; rowHi++) {\n\t\t\t\tconst keyHi = (colHi | r0ToMorton16(rowHi)) >>> 0;\n\t\t\t\tconst level0 = this.root[keyHi];\n\t\t\t\tif (level0 !== undefined) {\n\t\t\t\t\t// The remainder of the tree is divided in 16 x 16 tiles.\n\t\t\t\t\tconst colLo = c0ToMorton16(col);\n\t\t\t\t\tthis.forEachInCol(level0, byte0(colLo), (level1) => {\n\t\t\t\t\t\tthis.forEachInCol(level1, byte1(colLo), (level2) => {\n\t\t\t\t\t\t\tthis.forEachInCol(level2, byte2(colLo), (level3) => {\n\t\t\t\t\t\t\t\tthis.forEachKeyInCol(byte3(colLo), (key) => {\n\t\t\t\t\t\t\t\t\tlevel3[key] = undefined;\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate getLevel<T>(parent: UA<UA<T>>, subKey: number): UA<T> {\n\t\tconst level = parent[subKey];\n\t\t// Using new Array is needed because the array created with Array.from does not\n\t\t// satisfy (T|undefined)[].\n\t\t// eslint-disable-next-line unicorn/no-new-array\n\t\treturn level ?? (parent[subKey] = new Array<T | undefined>(256).fill(undefined));\n\t}\n\n\tpublic snapshot(): UA<UA<UA<UA<UA<T>>>>> {\n\t\treturn this.root;\n\t}\n\n\tpublic static load<T>(data: RecurArray<T>): SparseArray2D<T> {\n\t\treturn new SparseArray2D<T>(nullToUndefined<T>(data) as SparseArray2D<T>[\"root\"]);\n\t}\n}\n"]}
|
package/lib/undoprovider.d.ts
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IMergeTreeDeltaCallbackArgs, MergeTreeRevertibleDriver } from "@fluidframework/merge-tree/internal";
|
|
6
|
-
import { Handle } from "./handletable.js";
|
|
7
|
-
import { SharedMatrix } from "./matrix.js";
|
|
8
|
-
import { MatrixItem } from "./ops.js";
|
|
9
|
-
import { PermutationVector } from "./permutationvector.js";
|
|
10
|
-
import { IUndoConsumer } from "./types.js";
|
|
5
|
+
import { type IMergeTreeDeltaCallbackArgs, type MergeTreeRevertibleDriver } from "@fluidframework/merge-tree/internal";
|
|
6
|
+
import { type Handle } from "./handletable.js";
|
|
7
|
+
import type { SharedMatrix } from "./matrix.js";
|
|
8
|
+
import type { MatrixItem } from "./ops.js";
|
|
9
|
+
import type { PermutationVector } from "./permutationvector.js";
|
|
10
|
+
import type { IUndoConsumer } from "./types.js";
|
|
11
11
|
export declare class VectorUndoProvider {
|
|
12
12
|
private readonly manager;
|
|
13
13
|
private readonly driver;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"undoprovider.d.ts","sourceRoot":"","sources":["../src/undoprovider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,2BAA2B,
|
|
1
|
+
{"version":3,"file":"undoprovider.d.ts","sourceRoot":"","sources":["../src/undoprovider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,KAAK,2BAA2B,EAIhC,KAAK,yBAAyB,EAK9B,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,KAAK,MAAM,EAAiB,MAAM,kBAAkB,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,EAAsB,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,qBAAa,kBAAkB;IAS7B,OAAO,CAAC,QAAQ,CAAC,OAAO;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C,CAAC;YACnC,CAAC;YACD,WAAW,CAAC,KAAK,EAAE,GAAG;gBACrB,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,CAAC,CAAC;YACvC,CAAC;SACD,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,SAAiB,EAAE,SAAiB,EAAE,QAAuB;QACpE,MAAM,CACL,aAAa,CAAC,SAAS,CAAC,IAAI,aAAa,CAAC,SAAS,CAAC,EACpD,KAAK,CAAC,wDAAwD,CAC9D,CAAC;QAEF,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAAC;gBACpC,MAAM,EAAE,GAAG,EAAE;oBACZ,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;oBAClD,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;oBAClD,6DAA6D;oBAC7D,IAAI,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;wBAC9D,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;oBACzC,CAAC;gBACF,CAAC;gBACD,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;aACjB,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIMergeTreeDeltaCallbackArgs,\n\tITrackingGroup,\n\tMergeTreeDeltaRevertible,\n\tMergeTreeDeltaType,\n\tMergeTreeRevertibleDriver,\n\tTrackingGroup,\n\tappendToMergeTreeDeltaRevertibles,\n\tdiscardMergeTreeDeltaRevertible,\n\trevertMergeTreeDeltaRevertibles,\n} from \"@fluidframework/merge-tree/internal\";\n\nimport { Handle, isHandleValid } from \"./handletable.js\";\nimport { SharedMatrix } from \"./matrix.js\";\nimport { MatrixItem } from \"./ops.js\";\nimport { PermutationSegment, PermutationVector } from \"./permutationvector.js\";\nimport { IUndoConsumer } from \"./types.js\";\n\nexport class VectorUndoProvider {\n\t// 'currentGroup' and 'currentOp' are used while applying an IRevertable.revert() to coalesce\n\t// the recorded into a single IRevertable / tracking group as they move between the undo <->\n\t// redo stacks.\n\tprivate currentGroup?: MergeTreeDeltaRevertible[];\n\tprivate currentOp?: MergeTreeDeltaType;\n\tprivate currentRemoveTrackingGroup?: TrackingGroup;\n\n\tconstructor(\n\t\tprivate readonly manager: IUndoConsumer,\n\t\tprivate readonly driver: MergeTreeRevertibleDriver,\n\t) {}\n\n\tpublic record(deltaArgs: IMergeTreeDeltaCallbackArgs): void {\n\t\tif (deltaArgs.deltaSegments.length > 0) {\n\t\t\t// If we are in the process of reverting, the `IRevertible.revert()` will provide the tracking\n\t\t\t// group so that we can preserve the original segment ranges as a single op/group as we move\n\t\t\t// ops between the undo <-> redo stacks.\n\t\t\tconst revertibles: MergeTreeDeltaRevertible[] = this.currentGroup ?? [];\n\t\t\tappendToMergeTreeDeltaRevertibles(deltaArgs, revertibles);\n\n\t\t\t// For SharedMatrix, each IRevertibles always holds a single row/col operation.\n\t\t\t// Therefore, 'currentOp' must either be undefined or equal to the current op.\n\t\t\tassert(\n\t\t\t\tthis.currentOp === undefined || this.currentOp === deltaArgs.operation,\n\t\t\t\t0x02a /* \"On vector undo, unexpected 'currentOp' type/state!\" */,\n\t\t\t);\n\t\t\tlet removeTrackingGroup: TrackingGroup | undefined;\n\t\t\tif (deltaArgs.operation === MergeTreeDeltaType.REMOVE) {\n\t\t\t\t// for removed segment we need a tracking group.\n\t\t\t\t// this is for a few reason:\n\t\t\t\t// 1. the handle for the row/column on the removed segment is still allocated,\n\t\t\t\t//\t\tand needs to be in order to process unacked ops sent before the remove.\n\t\t\t\t// 2. handles are freed on unlink(zamboni), but that also clears the row/column data.\n\t\t\t\t//\t\twhich we don't want to happen, so we can re-insert the cells when the row/col comes back.\n\t\t\t\t//\t\tthe tracking group prevents unlink.\n\t\t\t\t// 3. when we re-insert we need to find the old segment and clear their handles\n\t\t\t\t//\t\tso the new segment takes them over. there is no efficient look-up for this.\n\t\t\t\t//\t\tthe tracking group provides one.\n\t\t\t\tconst trackingGroup = (removeTrackingGroup =\n\t\t\t\t\tthis.currentRemoveTrackingGroup ?? new TrackingGroup());\n\t\t\t\tfor (const d of deltaArgs.deltaSegments)\n\t\t\t\t\td.segment.trackingCollection.link(trackingGroup);\n\t\t\t}\n\n\t\t\tswitch (deltaArgs.operation) {\n\t\t\t\tcase MergeTreeDeltaType.REMOVE:\n\t\t\t\tcase MergeTreeDeltaType.INSERT: {\n\t\t\t\t\tif (this.currentOp !== deltaArgs.operation) {\n\t\t\t\t\t\tthis.pushRevertible(revertibles, removeTrackingGroup);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tthrow new Error(\"operation type not revertible\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If we are in the process of reverting, set 'currentOp' to remind ourselves not to push\n\t\t\t// another revertible until `IRevertable.revert()` finishes the current op and clears this\n\t\t\t// field.\n\t\t\tif (this.currentGroup !== undefined) {\n\t\t\t\tthis.currentOp ??= deltaArgs.operation;\n\t\t\t\tthis.currentRemoveTrackingGroup ??= removeTrackingGroup;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate pushRevertible(\n\t\trevertibles: MergeTreeDeltaRevertible[],\n\t\tremovedTrackingGroup: ITrackingGroup | undefined,\n\t): {\n\t\trevert: () => void;\n\t\tdiscard: () => void;\n\t} {\n\t\tconst reverter = {\n\t\t\trevert: (): void => {\n\t\t\t\tassert(\n\t\t\t\t\tthis.currentGroup === undefined && this.currentOp === undefined,\n\t\t\t\t\t0x02b /* \"Must not nest calls to IRevertible.revert()\" */,\n\t\t\t\t);\n\n\t\t\t\tthis.currentGroup = [];\n\n\t\t\t\ttry {\n\t\t\t\t\tif (removedTrackingGroup !== undefined) {\n\t\t\t\t\t\twhile (removedTrackingGroup.size > 0) {\n\t\t\t\t\t\t\tconst tracked = removedTrackingGroup.tracked[0];\n\t\t\t\t\t\t\tremovedTrackingGroup.unlink(tracked);\n\t\t\t\t\t\t\t// if there are groups tracked, this in a revert of a remove.\n\t\t\t\t\t\t\t// this means we are about to re-insert the row/column\n\t\t\t\t\t\t\t// with the same handle. We reuse the handle so the row/columns cells\n\t\t\t\t\t\t\t// get re-inserted too.\n\t\t\t\t\t\t\t// since a new segment will have the handle, we need to\n\t\t\t\t\t\t\t// remove it from the removed segment which was tracked\n\t\t\t\t\t\t\t(tracked as PermutationSegment).reset();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\trevertMergeTreeDeltaRevertibles(this.driver, revertibles);\n\t\t\t\t} finally {\n\t\t\t\t\tthis.currentOp = undefined;\n\t\t\t\t\tthis.currentGroup = undefined;\n\t\t\t\t\tthis.currentRemoveTrackingGroup = undefined;\n\t\t\t\t}\n\t\t\t},\n\t\t\tdiscard: (): void => {\n\t\t\t\tif (removedTrackingGroup !== undefined) {\n\t\t\t\t\twhile (removedTrackingGroup.size > 0) {\n\t\t\t\t\t\tremovedTrackingGroup.unlink(removedTrackingGroup.tracked[0]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tdiscardMergeTreeDeltaRevertible(revertibles);\n\t\t\t},\n\t\t};\n\n\t\tthis.manager.pushToCurrentOperation(reverter);\n\n\t\treturn reverter;\n\t}\n}\n\nexport class MatrixUndoProvider<T> {\n\tconstructor(\n\t\tprivate readonly consumer: IUndoConsumer,\n\t\tprivate readonly matrix: SharedMatrix<T>,\n\t\tprivate readonly rows: PermutationVector,\n\t\tprivate readonly cols: PermutationVector,\n\t) {\n\t\trows.undo = new VectorUndoProvider(consumer, {\n\t\t\tannotateRange(): void {\n\t\t\t\tthrow new Error(\"not implemented\");\n\t\t\t},\n\t\t\tinsertFromSpec(pos, spec): void {\n\t\t\t\tmatrix._undoRemoveRows(pos, spec);\n\t\t\t},\n\t\t\tremoveRange(start, end): void {\n\t\t\t\tmatrix.removeRows(start, end - start);\n\t\t\t},\n\t\t});\n\t\tcols.undo = new VectorUndoProvider(consumer, {\n\t\t\tannotateRange(): void {\n\t\t\t\tthrow new Error(\"not implemented\");\n\t\t\t},\n\t\t\tinsertFromSpec(pos, spec): void {\n\t\t\t\tmatrix._undoRemoveCols(pos, spec);\n\t\t\t},\n\t\t\tremoveRange(start, end): void {\n\t\t\t\tmatrix.removeCols(start, end - start);\n\t\t\t},\n\t\t});\n\t}\n\n\tcellSet(rowHandle: Handle, colHandle: Handle, oldValue: MatrixItem<T>): void {\n\t\tassert(\n\t\t\tisHandleValid(rowHandle) && isHandleValid(colHandle),\n\t\t\t0x02c /* \"On cellSet(), invalid row and/or column handles!\" */,\n\t\t);\n\n\t\tif (this.consumer !== undefined) {\n\t\t\tthis.consumer.pushToCurrentOperation({\n\t\t\t\trevert: () => {\n\t\t\t\t\tconst row = this.rows.handleToPosition(rowHandle);\n\t\t\t\t\tconst col = this.cols.handleToPosition(colHandle);\n\t\t\t\t\t// if the row/column no longer exists, we cannot set the cell\n\t\t\t\t\tif (row < this.matrix.rowCount && col < this.matrix.colCount) {\n\t\t\t\t\t\tthis.matrix.setCell(row, col, oldValue);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tdiscard: () => {},\n\t\t\t});\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"undoprovider.js","sourceRoot":"","sources":["../src/undoprovider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAIN,kBAAkB,EAElB,aAAa,EACb,iCAAiC,EAC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/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\ttype IMergeTreeDeltaCallbackArgs,\n\ttype ITrackingGroup,\n\ttype MergeTreeDeltaRevertible,\n\tMergeTreeDeltaType,\n\ttype MergeTreeRevertibleDriver,\n\tTrackingGroup,\n\tappendToMergeTreeDeltaRevertibles,\n\tdiscardMergeTreeDeltaRevertible,\n\trevertMergeTreeDeltaRevertibles,\n} from \"@fluidframework/merge-tree/internal\";\n\nimport { type Handle, isHandleValid } from \"./handletable.js\";\nimport type { SharedMatrix } from \"./matrix.js\";\nimport type { MatrixItem } from \"./ops.js\";\nimport type { PermutationSegment, PermutationVector } from \"./permutationvector.js\";\nimport type { IUndoConsumer } from \"./types.js\";\n\nexport class VectorUndoProvider {\n\t// 'currentGroup' and 'currentOp' are used while applying an IRevertable.revert() to coalesce\n\t// the recorded into a single IRevertable / tracking group as they move between the undo <->\n\t// redo stacks.\n\tprivate currentGroup?: MergeTreeDeltaRevertible[];\n\tprivate currentOp?: MergeTreeDeltaType;\n\tprivate currentRemoveTrackingGroup?: TrackingGroup;\n\n\tconstructor(\n\t\tprivate readonly manager: IUndoConsumer,\n\t\tprivate readonly driver: MergeTreeRevertibleDriver,\n\t) {}\n\n\tpublic record(deltaArgs: IMergeTreeDeltaCallbackArgs): void {\n\t\tif (deltaArgs.deltaSegments.length > 0) {\n\t\t\t// If we are in the process of reverting, the `IRevertible.revert()` will provide the tracking\n\t\t\t// group so that we can preserve the original segment ranges as a single op/group as we move\n\t\t\t// ops between the undo <-> redo stacks.\n\t\t\tconst revertibles: MergeTreeDeltaRevertible[] = this.currentGroup ?? [];\n\t\t\tappendToMergeTreeDeltaRevertibles(deltaArgs, revertibles);\n\n\t\t\t// For SharedMatrix, each IRevertibles always holds a single row/col operation.\n\t\t\t// Therefore, 'currentOp' must either be undefined or equal to the current op.\n\t\t\tassert(\n\t\t\t\tthis.currentOp === undefined || this.currentOp === deltaArgs.operation,\n\t\t\t\t0x02a /* \"On vector undo, unexpected 'currentOp' type/state!\" */,\n\t\t\t);\n\t\t\tlet removeTrackingGroup: TrackingGroup | undefined;\n\t\t\tif (deltaArgs.operation === MergeTreeDeltaType.REMOVE) {\n\t\t\t\t// for removed segment we need a tracking group.\n\t\t\t\t// this is for a few reason:\n\t\t\t\t// 1. the handle for the row/column on the removed segment is still allocated,\n\t\t\t\t//\t\tand needs to be in order to process unacked ops sent before the remove.\n\t\t\t\t// 2. handles are freed on unlink(zamboni), but that also clears the row/column data.\n\t\t\t\t//\t\twhich we don't want to happen, so we can re-insert the cells when the row/col comes back.\n\t\t\t\t//\t\tthe tracking group prevents unlink.\n\t\t\t\t// 3. when we re-insert we need to find the old segment and clear their handles\n\t\t\t\t//\t\tso the new segment takes them over. there is no efficient look-up for this.\n\t\t\t\t//\t\tthe tracking group provides one.\n\t\t\t\tconst trackingGroup = (removeTrackingGroup =\n\t\t\t\t\tthis.currentRemoveTrackingGroup ?? new TrackingGroup());\n\t\t\t\tfor (const d of deltaArgs.deltaSegments)\n\t\t\t\t\td.segment.trackingCollection.link(trackingGroup);\n\t\t\t}\n\n\t\t\tswitch (deltaArgs.operation) {\n\t\t\t\tcase MergeTreeDeltaType.REMOVE:\n\t\t\t\tcase MergeTreeDeltaType.INSERT: {\n\t\t\t\t\tif (this.currentOp !== deltaArgs.operation) {\n\t\t\t\t\t\tthis.pushRevertible(revertibles, removeTrackingGroup);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tthrow new Error(\"operation type not revertible\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If we are in the process of reverting, set 'currentOp' to remind ourselves not to push\n\t\t\t// another revertible until `IRevertable.revert()` finishes the current op and clears this\n\t\t\t// field.\n\t\t\tif (this.currentGroup !== undefined) {\n\t\t\t\tthis.currentOp ??= deltaArgs.operation;\n\t\t\t\tthis.currentRemoveTrackingGroup ??= removeTrackingGroup;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate pushRevertible(\n\t\trevertibles: MergeTreeDeltaRevertible[],\n\t\tremovedTrackingGroup: ITrackingGroup | undefined,\n\t): {\n\t\trevert: () => void;\n\t\tdiscard: () => void;\n\t} {\n\t\tconst reverter = {\n\t\t\trevert: (): void => {\n\t\t\t\tassert(\n\t\t\t\t\tthis.currentGroup === undefined && this.currentOp === undefined,\n\t\t\t\t\t0x02b /* \"Must not nest calls to IRevertible.revert()\" */,\n\t\t\t\t);\n\n\t\t\t\tthis.currentGroup = [];\n\n\t\t\t\ttry {\n\t\t\t\t\tif (removedTrackingGroup !== undefined) {\n\t\t\t\t\t\twhile (removedTrackingGroup.size > 0) {\n\t\t\t\t\t\t\tconst tracked = removedTrackingGroup.tracked[0];\n\t\t\t\t\t\t\tremovedTrackingGroup.unlink(tracked);\n\t\t\t\t\t\t\t// if there are groups tracked, this in a revert of a remove.\n\t\t\t\t\t\t\t// this means we are about to re-insert the row/column\n\t\t\t\t\t\t\t// with the same handle. We reuse the handle so the row/columns cells\n\t\t\t\t\t\t\t// get re-inserted too.\n\t\t\t\t\t\t\t// since a new segment will have the handle, we need to\n\t\t\t\t\t\t\t// remove it from the removed segment which was tracked\n\t\t\t\t\t\t\t(tracked as PermutationSegment).reset();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\trevertMergeTreeDeltaRevertibles(this.driver, revertibles);\n\t\t\t\t} finally {\n\t\t\t\t\tthis.currentOp = undefined;\n\t\t\t\t\tthis.currentGroup = undefined;\n\t\t\t\t\tthis.currentRemoveTrackingGroup = undefined;\n\t\t\t\t}\n\t\t\t},\n\t\t\tdiscard: (): void => {\n\t\t\t\tif (removedTrackingGroup !== undefined) {\n\t\t\t\t\twhile (removedTrackingGroup.size > 0) {\n\t\t\t\t\t\tremovedTrackingGroup.unlink(removedTrackingGroup.tracked[0]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tdiscardMergeTreeDeltaRevertible(revertibles);\n\t\t\t},\n\t\t};\n\n\t\tthis.manager.pushToCurrentOperation(reverter);\n\n\t\treturn reverter;\n\t}\n}\n\nexport class MatrixUndoProvider<T> {\n\tconstructor(\n\t\tprivate readonly consumer: IUndoConsumer,\n\t\tprivate readonly matrix: SharedMatrix<T>,\n\t\tprivate readonly rows: PermutationVector,\n\t\tprivate readonly cols: PermutationVector,\n\t) {\n\t\trows.undo = new VectorUndoProvider(consumer, {\n\t\t\tannotateRange(): void {\n\t\t\t\tthrow new Error(\"not implemented\");\n\t\t\t},\n\t\t\tinsertFromSpec(pos, spec): void {\n\t\t\t\tmatrix._undoRemoveRows(pos, spec);\n\t\t\t},\n\t\t\tremoveRange(start, end): void {\n\t\t\t\tmatrix.removeRows(start, end - start);\n\t\t\t},\n\t\t});\n\t\tcols.undo = new VectorUndoProvider(consumer, {\n\t\t\tannotateRange(): void {\n\t\t\t\tthrow new Error(\"not implemented\");\n\t\t\t},\n\t\t\tinsertFromSpec(pos, spec): void {\n\t\t\t\tmatrix._undoRemoveCols(pos, spec);\n\t\t\t},\n\t\t\tremoveRange(start, end): void {\n\t\t\t\tmatrix.removeCols(start, end - start);\n\t\t\t},\n\t\t});\n\t}\n\n\tcellSet(rowHandle: Handle, colHandle: Handle, oldValue: MatrixItem<T>): void {\n\t\tassert(\n\t\t\tisHandleValid(rowHandle) && isHandleValid(colHandle),\n\t\t\t0x02c /* \"On cellSet(), invalid row and/or column handles!\" */,\n\t\t);\n\n\t\tif (this.consumer !== undefined) {\n\t\t\tthis.consumer.pushToCurrentOperation({\n\t\t\t\trevert: () => {\n\t\t\t\t\tconst row = this.rows.handleToPosition(rowHandle);\n\t\t\t\t\tconst col = this.cols.handleToPosition(colHandle);\n\t\t\t\t\t// if the row/column no longer exists, we cannot set the cell\n\t\t\t\t\tif (row < this.matrix.rowCount && col < this.matrix.colCount) {\n\t\t\t\t\t\tthis.matrix.setCell(row, col, oldValue);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tdiscard: () => {},\n\t\t\t});\n\t\t}\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/matrix",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.51.0",
|
|
4
4
|
"description": "Distributed matrix",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -81,17 +81,17 @@
|
|
|
81
81
|
"temp-directory": "nyc/.nyc_output"
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
|
-
"@fluid-internal/client-utils": "~2.
|
|
85
|
-
"@fluidframework/core-interfaces": "~2.
|
|
86
|
-
"@fluidframework/core-utils": "~2.
|
|
87
|
-
"@fluidframework/datastore-definitions": "~2.
|
|
88
|
-
"@fluidframework/driver-definitions": "~2.
|
|
89
|
-
"@fluidframework/driver-utils": "~2.
|
|
90
|
-
"@fluidframework/merge-tree": "~2.
|
|
91
|
-
"@fluidframework/runtime-definitions": "~2.
|
|
92
|
-
"@fluidframework/runtime-utils": "~2.
|
|
93
|
-
"@fluidframework/shared-object-base": "~2.
|
|
94
|
-
"@fluidframework/telemetry-utils": "~2.
|
|
84
|
+
"@fluid-internal/client-utils": "~2.51.0",
|
|
85
|
+
"@fluidframework/core-interfaces": "~2.51.0",
|
|
86
|
+
"@fluidframework/core-utils": "~2.51.0",
|
|
87
|
+
"@fluidframework/datastore-definitions": "~2.51.0",
|
|
88
|
+
"@fluidframework/driver-definitions": "~2.51.0",
|
|
89
|
+
"@fluidframework/driver-utils": "~2.51.0",
|
|
90
|
+
"@fluidframework/merge-tree": "~2.51.0",
|
|
91
|
+
"@fluidframework/runtime-definitions": "~2.51.0",
|
|
92
|
+
"@fluidframework/runtime-utils": "~2.51.0",
|
|
93
|
+
"@fluidframework/shared-object-base": "~2.51.0",
|
|
94
|
+
"@fluidframework/telemetry-utils": "~2.51.0",
|
|
95
95
|
"@tiny-calc/nano": "0.0.0-alpha.5",
|
|
96
96
|
"double-ended-queue": "^2.1.0-0",
|
|
97
97
|
"tslib": "^1.10.0"
|
|
@@ -99,17 +99,17 @@
|
|
|
99
99
|
"devDependencies": {
|
|
100
100
|
"@arethetypeswrong/cli": "^0.17.1",
|
|
101
101
|
"@biomejs/biome": "~1.9.3",
|
|
102
|
-
"@fluid-internal/mocha-test-setup": "~2.
|
|
103
|
-
"@fluid-private/stochastic-test-utils": "~2.
|
|
104
|
-
"@fluid-private/test-dds-utils": "~2.
|
|
102
|
+
"@fluid-internal/mocha-test-setup": "~2.51.0",
|
|
103
|
+
"@fluid-private/stochastic-test-utils": "~2.51.0",
|
|
104
|
+
"@fluid-private/test-dds-utils": "~2.51.0",
|
|
105
105
|
"@fluid-tools/benchmark": "^0.51.0",
|
|
106
106
|
"@fluid-tools/build-cli": "^0.56.0",
|
|
107
107
|
"@fluidframework/build-common": "^2.0.3",
|
|
108
108
|
"@fluidframework/build-tools": "^0.56.0",
|
|
109
|
-
"@fluidframework/container-definitions": "~2.
|
|
109
|
+
"@fluidframework/container-definitions": "~2.51.0",
|
|
110
110
|
"@fluidframework/eslint-config-fluid": "^5.7.4",
|
|
111
|
-
"@fluidframework/matrix-previous": "npm:@fluidframework/matrix@2.
|
|
112
|
-
"@fluidframework/test-runtime-utils": "~2.
|
|
111
|
+
"@fluidframework/matrix-previous": "npm:@fluidframework/matrix@2.50.0",
|
|
112
|
+
"@fluidframework/test-runtime-utils": "~2.51.0",
|
|
113
113
|
"@microsoft/api-extractor": "7.52.8",
|
|
114
114
|
"@tiny-calc/micro": "0.0.0-alpha.5",
|
|
115
115
|
"@types/double-ended-queue": "^2.1.0",
|
package/src/handlecache.ts
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
/* eslint-disable no-bitwise */
|
|
7
7
|
|
|
8
8
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
9
|
-
import { IVectorConsumer } from "@tiny-calc/nano";
|
|
9
|
+
import type { IVectorConsumer } from "@tiny-calc/nano";
|
|
10
10
|
|
|
11
|
-
import { Handle, isHandleValid } from "./handletable.js";
|
|
12
|
-
import { PermutationSegment, PermutationVector } from "./permutationvector.js";
|
|
11
|
+
import { type Handle, isHandleValid } from "./handletable.js";
|
|
12
|
+
import type { PermutationSegment, PermutationVector } from "./permutationvector.js";
|
|
13
13
|
import { ensureRange } from "./range.js";
|
|
14
14
|
|
|
15
15
|
/**
|
package/src/index.ts
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
export { ISharedMatrixEvents, ISharedMatrix } from "./matrix.js";
|
|
7
|
-
export { MatrixItem } from "./ops.js";
|
|
6
|
+
export type { ISharedMatrixEvents, ISharedMatrix } from "./matrix.js";
|
|
7
|
+
export type { MatrixItem } from "./ops.js";
|
|
8
8
|
export { SharedMatrixFactory, SharedMatrix } from "./runtime.js";
|
|
9
9
|
|
|
10
10
|
// TODO: We temporarily duplicate these contracts from 'framework/undo-redo' to unblock development
|
|
11
11
|
// of SharedMatrix undo while we decide on the correct layering for undo.
|
|
12
|
-
export { IUndoConsumer, IRevertible } from "./types.js";
|
|
12
|
+
export type { IUndoConsumer, IRevertible } from "./types.js";
|
package/src/matrix.ts
CHANGED
|
@@ -3,41 +3,41 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import type {
|
|
7
7
|
IEvent,
|
|
8
8
|
IEventThisPlaceHolder,
|
|
9
|
-
|
|
9
|
+
IEventProvider,
|
|
10
10
|
} from "@fluidframework/core-interfaces";
|
|
11
11
|
import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
|
|
12
|
-
import {
|
|
12
|
+
import type {
|
|
13
13
|
IChannelAttributes,
|
|
14
14
|
IFluidDataStoreRuntime,
|
|
15
|
-
|
|
15
|
+
IChannel,
|
|
16
16
|
IChannelStorageService,
|
|
17
17
|
} from "@fluidframework/datastore-definitions/internal";
|
|
18
|
-
import { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
|
|
18
|
+
import type { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
|
|
19
19
|
import {
|
|
20
|
-
Client,
|
|
21
|
-
IJSONSegment,
|
|
22
|
-
IMergeTreeOp,
|
|
20
|
+
type Client,
|
|
21
|
+
type IJSONSegment,
|
|
22
|
+
type IMergeTreeOp,
|
|
23
23
|
type ISegmentInternal,
|
|
24
24
|
type LocalReferencePosition,
|
|
25
25
|
MergeTreeDeltaType,
|
|
26
26
|
ReferenceType,
|
|
27
27
|
segmentIsRemoved,
|
|
28
28
|
} from "@fluidframework/merge-tree/internal";
|
|
29
|
-
import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions/internal";
|
|
29
|
+
import type { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions/internal";
|
|
30
30
|
import {
|
|
31
31
|
ObjectStoragePartition,
|
|
32
32
|
SummaryTreeBuilder,
|
|
33
33
|
} from "@fluidframework/runtime-utils/internal";
|
|
34
34
|
import {
|
|
35
|
-
IFluidSerializer,
|
|
36
|
-
ISharedObjectEvents,
|
|
35
|
+
type IFluidSerializer,
|
|
36
|
+
type ISharedObjectEvents,
|
|
37
37
|
SharedObject,
|
|
38
38
|
} from "@fluidframework/shared-object-base/internal";
|
|
39
39
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
40
|
-
import {
|
|
40
|
+
import type {
|
|
41
41
|
IMatrixConsumer,
|
|
42
42
|
IMatrixProducer,
|
|
43
43
|
IMatrixReader,
|
|
@@ -46,20 +46,20 @@ import {
|
|
|
46
46
|
import Deque from "double-ended-queue";
|
|
47
47
|
|
|
48
48
|
import type { HandleCache } from "./handlecache.js";
|
|
49
|
-
import { Handle, isHandleValid } from "./handletable.js";
|
|
49
|
+
import { type Handle, isHandleValid } from "./handletable.js";
|
|
50
50
|
import {
|
|
51
|
-
ISetOp,
|
|
52
|
-
MatrixItem,
|
|
51
|
+
type ISetOp,
|
|
52
|
+
type MatrixItem,
|
|
53
53
|
MatrixOp,
|
|
54
|
-
MatrixSetOrVectorOp,
|
|
54
|
+
type MatrixSetOrVectorOp,
|
|
55
55
|
SnapshotPath,
|
|
56
|
-
VectorOp,
|
|
56
|
+
type VectorOp,
|
|
57
57
|
} from "./ops.js";
|
|
58
58
|
import { PermutationVector, reinsertSegmentIntoVector } from "./permutationvector.js";
|
|
59
59
|
import { ensureRange } from "./range.js";
|
|
60
60
|
import { deserializeBlob } from "./serialization.js";
|
|
61
61
|
import { SparseArray2D, type RecurArray } from "./sparsearray2d.js";
|
|
62
|
-
import { IUndoConsumer } from "./types.js";
|
|
62
|
+
import type { IUndoConsumer } from "./types.js";
|
|
63
63
|
import { MatrixUndoProvider } from "./undoprovider.js";
|
|
64
64
|
|
|
65
65
|
interface ISetOpMetadata {
|
package/src/ops.ts
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* Use caustion when making changes and consider backward and forward compatibility of your changes!
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { Serializable } from "@fluidframework/datastore-definitions/internal";
|
|
12
|
-
import { IMergeTreeOp } from "@fluidframework/merge-tree/internal";
|
|
11
|
+
import type { Serializable } from "@fluidframework/datastore-definitions/internal";
|
|
12
|
+
import type { IMergeTreeOp } from "@fluidframework/merge-tree/internal";
|
|
13
13
|
|
|
14
14
|
export enum MatrixOp {
|
|
15
15
|
spliceCols,
|
package/src/packageVersion.ts
CHANGED