@fluid-experimental/sequence-deprecated 2.0.0-dev.2.2.0.111723
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/.editorconfig +7 -0
- package/.eslintrc.js +17 -0
- package/.vscode/launch.json +14 -0
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/api-extractor.json +12 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/packageVersion.d.ts +9 -0
- package/dist/packageVersion.d.ts.map +1 -0
- package/dist/packageVersion.js +12 -0
- package/dist/packageVersion.js.map +1 -0
- package/dist/sequenceFactory.d.ts +95 -0
- package/dist/sequenceFactory.d.ts.map +1 -0
- package/dist/sequenceFactory.js +152 -0
- package/dist/sequenceFactory.js.map +1 -0
- package/dist/sharedNumberSequence.d.ts +50 -0
- package/dist/sharedNumberSequence.d.ts.map +1 -0
- package/dist/sharedNumberSequence.js +67 -0
- package/dist/sharedNumberSequence.js.map +1 -0
- package/dist/sharedObjectSequence.d.ts +50 -0
- package/dist/sharedObjectSequence.d.ts.map +1 -0
- package/dist/sharedObjectSequence.js +61 -0
- package/dist/sharedObjectSequence.js.map +1 -0
- package/dist/sparsematrix.d.ts +152 -0
- package/dist/sparsematrix.d.ts.map +1 -0
- package/dist/sparsematrix.js +345 -0
- package/dist/sparsematrix.js.map +1 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -0
- package/lib/packageVersion.d.ts +9 -0
- package/lib/packageVersion.d.ts.map +1 -0
- package/lib/packageVersion.js +9 -0
- package/lib/packageVersion.js.map +1 -0
- package/lib/sequenceFactory.d.ts +95 -0
- package/lib/sequenceFactory.d.ts.map +1 -0
- package/lib/sequenceFactory.js +147 -0
- package/lib/sequenceFactory.js.map +1 -0
- package/lib/sharedNumberSequence.d.ts +50 -0
- package/lib/sharedNumberSequence.d.ts.map +1 -0
- package/lib/sharedNumberSequence.js +63 -0
- package/lib/sharedNumberSequence.js.map +1 -0
- package/lib/sharedObjectSequence.d.ts +50 -0
- package/lib/sharedObjectSequence.d.ts.map +1 -0
- package/lib/sharedObjectSequence.js +57 -0
- package/lib/sharedObjectSequence.js.map +1 -0
- package/lib/sparsematrix.d.ts +152 -0
- package/lib/sparsematrix.d.ts.map +1 -0
- package/lib/sparsematrix.js +336 -0
- package/lib/sparsematrix.js.map +1 -0
- package/package.json +97 -0
- package/src/index.ts +22 -0
- package/src/packageVersion.ts +9 -0
- package/src/sequenceFactory.ts +181 -0
- package/src/sharedNumberSequence.ts +68 -0
- package/src/sharedObjectSequence.ts +62 -0
- package/src/sparsematrix.ts +434 -0
- package/tsconfig.esnext.json +7 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
6
|
+
import { BaseSegment, IJSONSegment, ISegment, PropertySet } from "@fluidframework/merge-tree";
|
|
7
|
+
import { IChannelAttributes, IFluidDataStoreRuntime, IChannelServices, IChannelFactory, Serializable, Jsonable } from "@fluidframework/datastore-definitions";
|
|
8
|
+
import { SharedSegmentSequence, SubSequence } from "@fluidframework/sequence";
|
|
9
|
+
import { ISharedObject } from "@fluidframework/shared-object-base";
|
|
10
|
+
/**
|
|
11
|
+
* An empty segment that occupies 'cachedLength' positions.
|
|
12
|
+
* {@link SparseMatrix} uses `PaddingSegment` to "pad" a run of unoccupied cells.
|
|
13
|
+
*
|
|
14
|
+
* @deprecated `PaddingSegment` is part of an abandoned prototype.
|
|
15
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
16
|
+
*/
|
|
17
|
+
export declare class PaddingSegment extends BaseSegment {
|
|
18
|
+
static readonly typeString = "PaddingSegment";
|
|
19
|
+
static is(segment: ISegment): segment is PaddingSegment;
|
|
20
|
+
static fromJSONObject(spec: any): PaddingSegment | undefined;
|
|
21
|
+
readonly type = "PaddingSegment";
|
|
22
|
+
constructor(size: number);
|
|
23
|
+
toJSONObject(): {
|
|
24
|
+
pad: number;
|
|
25
|
+
props: PropertySet | undefined;
|
|
26
|
+
};
|
|
27
|
+
clone(start?: number, end?: number): PaddingSegment;
|
|
28
|
+
canAppend(segment: ISegment): boolean;
|
|
29
|
+
toString(): string;
|
|
30
|
+
append(segment: ISegment): void;
|
|
31
|
+
removeRange(start: number, end: number): boolean;
|
|
32
|
+
protected createSplitSegmentAt(pos: number): PaddingSegment;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* @deprecated `SparseMatrixItem` is part of an abandoned prototype.
|
|
36
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
37
|
+
*/
|
|
38
|
+
export declare type SparseMatrixItem = Serializable;
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated `RunSegment` is part of an abandoned prototype.
|
|
41
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
42
|
+
*/
|
|
43
|
+
export declare class RunSegment extends SubSequence<SparseMatrixItem> {
|
|
44
|
+
items: SparseMatrixItem[];
|
|
45
|
+
static readonly typeString = "RunSegment";
|
|
46
|
+
static is(segment: ISegment): segment is RunSegment;
|
|
47
|
+
static fromJSONObject(spec: any): RunSegment | undefined;
|
|
48
|
+
readonly type = "RunSegment";
|
|
49
|
+
private tags;
|
|
50
|
+
constructor(items: SparseMatrixItem[]);
|
|
51
|
+
clone(start?: number, end?: number): RunSegment;
|
|
52
|
+
append(segment: ISegment): this;
|
|
53
|
+
removeRange(start: number, end: number): boolean;
|
|
54
|
+
getTag(pos: number): any;
|
|
55
|
+
setTag(pos: number, tag: any): void;
|
|
56
|
+
protected createSplitSegmentAt(pos: number): RunSegment | undefined;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @deprecated `MatrixSegment` is part of an abandoned prototype.
|
|
60
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
61
|
+
*/
|
|
62
|
+
export declare type MatrixSegment = RunSegment | PaddingSegment;
|
|
63
|
+
/**
|
|
64
|
+
* @deprecated `maxCol` is part of an abandoned prototype.
|
|
65
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
66
|
+
*/
|
|
67
|
+
export declare const maxCol = 2097152;
|
|
68
|
+
/**
|
|
69
|
+
* @deprecated `maxCols` is part of an abandoned prototype.
|
|
70
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
71
|
+
*/
|
|
72
|
+
export declare const maxCols: number;
|
|
73
|
+
/**
|
|
74
|
+
* @deprecated `maxRow` is part of an abandoned prototype.
|
|
75
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
76
|
+
*/
|
|
77
|
+
export declare const maxRow = 4294967295;
|
|
78
|
+
/**
|
|
79
|
+
* @deprecated `maxRows` is part of an abandoned prototype.
|
|
80
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
81
|
+
*/
|
|
82
|
+
export declare const maxRows: number;
|
|
83
|
+
/**
|
|
84
|
+
* @deprecated `maxCellPosition` is part of an abandoned prototype.
|
|
85
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
86
|
+
*/
|
|
87
|
+
export declare const maxCellPosition: number;
|
|
88
|
+
/**
|
|
89
|
+
* @deprecated `positionToRowCol` is part of an abandoned prototype.
|
|
90
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
91
|
+
*/
|
|
92
|
+
export declare const rowColToPosition: (row: number, col: number) => number;
|
|
93
|
+
/**
|
|
94
|
+
* @deprecated `positionToRowCol` is part of an abandoned prototype.
|
|
95
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
96
|
+
*/
|
|
97
|
+
export declare function positionToRowCol(position: number): {
|
|
98
|
+
row: number;
|
|
99
|
+
col: number;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* @deprecated `SparseMatrix` is an abandoned prototype.
|
|
103
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
104
|
+
*/
|
|
105
|
+
export declare class SparseMatrix extends SharedSegmentSequence<MatrixSegment> {
|
|
106
|
+
id: string;
|
|
107
|
+
/**
|
|
108
|
+
* Create a new sparse matrix
|
|
109
|
+
*
|
|
110
|
+
* @param runtime - data store runtime the new sparse matrix belongs to
|
|
111
|
+
* @param id - optional name of the sparse matrix
|
|
112
|
+
* @returns newly create sparse matrix (but not attached yet)
|
|
113
|
+
*/
|
|
114
|
+
static create(runtime: IFluidDataStoreRuntime, id?: string): SparseMatrix;
|
|
115
|
+
/**
|
|
116
|
+
* Get a factory for SharedMap to register with the data store.
|
|
117
|
+
*
|
|
118
|
+
* @returns a factory that creates and load SharedMap
|
|
119
|
+
*/
|
|
120
|
+
static getFactory(): IChannelFactory;
|
|
121
|
+
constructor(document: IFluidDataStoreRuntime, id: string, attributes: IChannelAttributes);
|
|
122
|
+
get numRows(): number;
|
|
123
|
+
setItems(row: number, col: number, values: SparseMatrixItem[], props?: PropertySet): void;
|
|
124
|
+
getItem(row: number, col: number): Jsonable<string | number | boolean | IFluidHandle> | undefined;
|
|
125
|
+
getTag(row: number, col: number): any;
|
|
126
|
+
setTag(row: number, col: number, tag: any): void;
|
|
127
|
+
insertRows(row: number, numRows: number): void;
|
|
128
|
+
removeRows(row: number, numRows: number): void;
|
|
129
|
+
insertCols(col: number, numCols: number): void;
|
|
130
|
+
removeCols(col: number, numCols: number): void;
|
|
131
|
+
annotatePosition(row: number, col: number, props: PropertySet): void;
|
|
132
|
+
getPositionProperties(row: number, col: number): PropertySet | undefined;
|
|
133
|
+
private moveAsPadding;
|
|
134
|
+
private getSegment;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* @deprecated `SparseMatrixFactory` is an abandoned prototype.
|
|
138
|
+
* Use {@link @fluidframework/matrix#SharedMatrixFactory} instead.
|
|
139
|
+
*/
|
|
140
|
+
export declare class SparseMatrixFactory implements IChannelFactory {
|
|
141
|
+
static Type: string;
|
|
142
|
+
static Attributes: IChannelAttributes;
|
|
143
|
+
static segmentFromSpec(spec: IJSONSegment): ISegment;
|
|
144
|
+
get type(): string;
|
|
145
|
+
get attributes(): IChannelAttributes;
|
|
146
|
+
/**
|
|
147
|
+
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
|
|
148
|
+
*/
|
|
149
|
+
load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<ISharedObject>;
|
|
150
|
+
create(document: IFluidDataStoreRuntime, id: string): ISharedObject;
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=sparsematrix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sparsematrix.d.ts","sourceRoot":"","sources":["../src/sparsematrix.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EACH,WAAW,EAEX,YAAY,EAEZ,QAAQ,EACR,WAAW,EACd,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACH,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,QAAQ,EACX,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAGnE;;;;;;GAMG;AACH,qBAAa,cAAe,SAAQ,WAAW;IAC3C,gBAAuB,UAAU,oBAAoB;WACvC,EAAE,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,IAAI,cAAc;WAGhD,cAAc,CAAC,IAAI,EAAE,GAAG;IAUtC,SAAgB,IAA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C,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW;IAK7D,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAOrD,OAAO,CAAC,aAAa;IAqBrB,OAAO,CAAC,UAAU;CAIrB;AAED;;;GAGG;AACH,qBAAa,mBAAoB,YAAW,eAAe;IACvD,OAAc,IAAI,SAA+D;IAEjF,OAAc,UAAU,EAAE,kBAAkB,CAI1C;WAEY,eAAe,CAAC,IAAI,EAAE,YAAY,GAAG,QAAQ;IAc3D,IAAW,IAAI,WAEd;IAED,IAAW,UAAU,uBAEpB;IAED;;OAEG;IACU,IAAI,CACb,OAAO,EAAE,sBAAsB,EAC/B,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,kBAAkB,GAC/B,OAAO,CAAC,aAAa,CAAC;IAMlB,MAAM,CAAC,QAAQ,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,GAAG,aAAa;CAK7E"}
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { assert } from "@fluidframework/common-utils";
|
|
6
|
+
import { BaseSegment, createGroupOp, } from "@fluidframework/merge-tree";
|
|
7
|
+
import { SharedSegmentSequence, SubSequence } from "@fluidframework/sequence";
|
|
8
|
+
import { pkgVersion } from "./packageVersion";
|
|
9
|
+
/**
|
|
10
|
+
* An empty segment that occupies 'cachedLength' positions.
|
|
11
|
+
* {@link SparseMatrix} uses `PaddingSegment` to "pad" a run of unoccupied cells.
|
|
12
|
+
*
|
|
13
|
+
* @deprecated `PaddingSegment` is part of an abandoned prototype.
|
|
14
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
15
|
+
*/
|
|
16
|
+
export class PaddingSegment extends BaseSegment {
|
|
17
|
+
constructor(size) {
|
|
18
|
+
super();
|
|
19
|
+
this.type = PaddingSegment.typeString;
|
|
20
|
+
this.cachedLength = size;
|
|
21
|
+
}
|
|
22
|
+
static is(segment) {
|
|
23
|
+
return segment.type === PaddingSegment.typeString;
|
|
24
|
+
}
|
|
25
|
+
static fromJSONObject(spec) {
|
|
26
|
+
if (spec && typeof spec === "object" && "pad" in spec) {
|
|
27
|
+
const segment = new PaddingSegment(spec.pad);
|
|
28
|
+
if (spec.props) {
|
|
29
|
+
segment.addProperties(spec.props);
|
|
30
|
+
}
|
|
31
|
+
return segment;
|
|
32
|
+
}
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
toJSONObject() {
|
|
36
|
+
return { pad: this.cachedLength, props: this.properties };
|
|
37
|
+
}
|
|
38
|
+
clone(start = 0, end) {
|
|
39
|
+
const b = new PaddingSegment(this.cachedLength);
|
|
40
|
+
this.cloneInto(b);
|
|
41
|
+
return b;
|
|
42
|
+
}
|
|
43
|
+
canAppend(segment) {
|
|
44
|
+
return PaddingSegment.is(segment);
|
|
45
|
+
}
|
|
46
|
+
toString() {
|
|
47
|
+
return `[padding: ${this.cachedLength}]`;
|
|
48
|
+
}
|
|
49
|
+
append(segment) {
|
|
50
|
+
assert(PaddingSegment.is(segment), "can only append padding segment");
|
|
51
|
+
super.append(segment);
|
|
52
|
+
}
|
|
53
|
+
// Returns true if entire run removed
|
|
54
|
+
removeRange(start, end) {
|
|
55
|
+
this.cachedLength -= (end - start);
|
|
56
|
+
return (this.cachedLength === 0);
|
|
57
|
+
}
|
|
58
|
+
createSplitSegmentAt(pos) {
|
|
59
|
+
const leftLength = pos;
|
|
60
|
+
const rightLength = this.cachedLength - pos;
|
|
61
|
+
this.cachedLength = leftLength;
|
|
62
|
+
return new PaddingSegment(rightLength);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
PaddingSegment.typeString = "PaddingSegment";
|
|
66
|
+
/**
|
|
67
|
+
* @deprecated `RunSegment` is part of an abandoned prototype.
|
|
68
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
69
|
+
*/
|
|
70
|
+
export class RunSegment extends SubSequence {
|
|
71
|
+
constructor(items) {
|
|
72
|
+
super(items);
|
|
73
|
+
this.items = items;
|
|
74
|
+
this.type = RunSegment.typeString;
|
|
75
|
+
this.tags = new Array(items.length).fill(undefined);
|
|
76
|
+
}
|
|
77
|
+
static is(segment) {
|
|
78
|
+
return segment.type === RunSegment.typeString;
|
|
79
|
+
}
|
|
80
|
+
static fromJSONObject(spec) {
|
|
81
|
+
if (spec && typeof spec === "object" && "items" in spec) {
|
|
82
|
+
const segment = new RunSegment(spec.items);
|
|
83
|
+
if (spec.props) {
|
|
84
|
+
segment.addProperties(spec.props);
|
|
85
|
+
}
|
|
86
|
+
return segment;
|
|
87
|
+
}
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
clone(start = 0, end) {
|
|
91
|
+
const b = new RunSegment(this.items.slice(start, end));
|
|
92
|
+
if (this.tags) {
|
|
93
|
+
b.tags = this.tags.slice(start, end);
|
|
94
|
+
}
|
|
95
|
+
this.cloneInto(b);
|
|
96
|
+
return b;
|
|
97
|
+
}
|
|
98
|
+
append(segment) {
|
|
99
|
+
super.append(segment);
|
|
100
|
+
const asRun = segment;
|
|
101
|
+
if (asRun.tags) {
|
|
102
|
+
if (this.tags) {
|
|
103
|
+
this.tags.splice(this.items.length, 0, ...asRun.tags);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
// TODO: retain removed items for undo
|
|
109
|
+
// returns true if entire run removed
|
|
110
|
+
removeRange(start, end) {
|
|
111
|
+
this.tags.splice(start, end - start);
|
|
112
|
+
return super.removeRange(start, end);
|
|
113
|
+
}
|
|
114
|
+
getTag(pos) {
|
|
115
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
116
|
+
return this.tags[pos];
|
|
117
|
+
}
|
|
118
|
+
setTag(pos, tag) {
|
|
119
|
+
this.tags[pos] = tag;
|
|
120
|
+
}
|
|
121
|
+
createSplitSegmentAt(pos) {
|
|
122
|
+
if (pos > 0) {
|
|
123
|
+
const remainingItems = this.items.slice(pos);
|
|
124
|
+
this.items = this.items.slice(0, pos);
|
|
125
|
+
this.cachedLength = this.items.length;
|
|
126
|
+
const leafSegment = new RunSegment(remainingItems);
|
|
127
|
+
leafSegment.tags = this.tags.slice(pos);
|
|
128
|
+
this.tags.length = pos;
|
|
129
|
+
return leafSegment;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
RunSegment.typeString = "RunSegment";
|
|
134
|
+
/**
|
|
135
|
+
* @deprecated `maxCol` is part of an abandoned prototype.
|
|
136
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
137
|
+
*/
|
|
138
|
+
export const maxCol = 0x200000; // X128 Excel maximum of 16,384 columns
|
|
139
|
+
/**
|
|
140
|
+
* @deprecated `maxCols` is part of an abandoned prototype.
|
|
141
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
142
|
+
*/
|
|
143
|
+
export const maxCols = maxCol + 1;
|
|
144
|
+
/**
|
|
145
|
+
* @deprecated `maxRow` is part of an abandoned prototype.
|
|
146
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
147
|
+
*/
|
|
148
|
+
export const maxRow = 0xFFFFFFFF; // X4096 Excel maximum of 1,048,576 rows
|
|
149
|
+
/**
|
|
150
|
+
* @deprecated `maxRows` is part of an abandoned prototype.
|
|
151
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
152
|
+
*/
|
|
153
|
+
export const maxRows = maxRow + 1;
|
|
154
|
+
/**
|
|
155
|
+
* @deprecated `maxCellPosition` is part of an abandoned prototype.
|
|
156
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
157
|
+
*/
|
|
158
|
+
export const maxCellPosition = maxCol * maxRow;
|
|
159
|
+
/**
|
|
160
|
+
* @deprecated `positionToRowCol` is part of an abandoned prototype.
|
|
161
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
162
|
+
*/
|
|
163
|
+
export const rowColToPosition = (row, col) => row * maxCols + col;
|
|
164
|
+
/**
|
|
165
|
+
* @deprecated `positionToRowCol` is part of an abandoned prototype.
|
|
166
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
167
|
+
*/
|
|
168
|
+
export function positionToRowCol(position) {
|
|
169
|
+
const row = Math.floor(position / maxCols);
|
|
170
|
+
const col = position - (row * maxCols);
|
|
171
|
+
return { row, col };
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* @deprecated `SparseMatrix` is an abandoned prototype.
|
|
175
|
+
* Use {@link @fluidframework/matrix#SharedMatrix} instead.
|
|
176
|
+
*/
|
|
177
|
+
export class SparseMatrix extends SharedSegmentSequence {
|
|
178
|
+
constructor(document, id, attributes) {
|
|
179
|
+
super(document, id, attributes, SparseMatrixFactory.segmentFromSpec);
|
|
180
|
+
this.id = id;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Create a new sparse matrix
|
|
184
|
+
*
|
|
185
|
+
* @param runtime - data store runtime the new sparse matrix belongs to
|
|
186
|
+
* @param id - optional name of the sparse matrix
|
|
187
|
+
* @returns newly create sparse matrix (but not attached yet)
|
|
188
|
+
*/
|
|
189
|
+
static create(runtime, id) {
|
|
190
|
+
return runtime.createChannel(id, SparseMatrixFactory.Type);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Get a factory for SharedMap to register with the data store.
|
|
194
|
+
*
|
|
195
|
+
* @returns a factory that creates and load SharedMap
|
|
196
|
+
*/
|
|
197
|
+
static getFactory() {
|
|
198
|
+
return new SparseMatrixFactory();
|
|
199
|
+
}
|
|
200
|
+
get numRows() {
|
|
201
|
+
return positionToRowCol(this.getLength()).row;
|
|
202
|
+
}
|
|
203
|
+
setItems(row, col, values, props) {
|
|
204
|
+
const start = rowColToPosition(row, col);
|
|
205
|
+
const end = start + values.length;
|
|
206
|
+
const segment = new RunSegment(values);
|
|
207
|
+
if (props) {
|
|
208
|
+
segment.addProperties(props);
|
|
209
|
+
}
|
|
210
|
+
this.replaceRange(start, end, segment);
|
|
211
|
+
}
|
|
212
|
+
getItem(row, col) {
|
|
213
|
+
const pos = rowColToPosition(row, col);
|
|
214
|
+
const { segment, offset } = this.getContainingSegment(pos);
|
|
215
|
+
if (segment && RunSegment.is(segment)) {
|
|
216
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
217
|
+
return segment.items[offset !== null && offset !== void 0 ? offset : 0];
|
|
218
|
+
}
|
|
219
|
+
else if (segment && PaddingSegment.is(segment)) {
|
|
220
|
+
return undefined;
|
|
221
|
+
}
|
|
222
|
+
throw new Error(`Unrecognized Segment type`);
|
|
223
|
+
}
|
|
224
|
+
getTag(row, col) {
|
|
225
|
+
const { segment, offset } = this.getSegment(row, col);
|
|
226
|
+
if (segment && RunSegment.is(segment)) {
|
|
227
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
228
|
+
return segment.getTag(offset !== null && offset !== void 0 ? offset : 0);
|
|
229
|
+
}
|
|
230
|
+
return undefined;
|
|
231
|
+
}
|
|
232
|
+
setTag(row, col, tag) {
|
|
233
|
+
const { segment, offset } = this.getSegment(row, col);
|
|
234
|
+
if (segment && RunSegment.is(segment)) {
|
|
235
|
+
segment.setTag(offset !== null && offset !== void 0 ? offset : 0, tag);
|
|
236
|
+
}
|
|
237
|
+
else if (tag !== undefined) {
|
|
238
|
+
throw new Error(`Must not attempt to set tags on '${segment === null || segment === void 0 ? void 0 : segment.constructor.name}'.`);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
insertRows(row, numRows) {
|
|
242
|
+
const pos = rowColToPosition(row, 0);
|
|
243
|
+
const size = maxCols * numRows;
|
|
244
|
+
const segment = new PaddingSegment(size);
|
|
245
|
+
const insertOp = this.client.insertSegmentLocal(pos, segment);
|
|
246
|
+
if (insertOp) {
|
|
247
|
+
this.submitSequenceMessage(insertOp);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
removeRows(row, numRows) {
|
|
251
|
+
const pos = rowColToPosition(row, 0);
|
|
252
|
+
const size = maxCols * numRows;
|
|
253
|
+
this.removeRange(pos, pos + size);
|
|
254
|
+
}
|
|
255
|
+
insertCols(col, numCols) {
|
|
256
|
+
this.moveAsPadding(maxCol - numCols, col, numCols);
|
|
257
|
+
}
|
|
258
|
+
removeCols(col, numCols) {
|
|
259
|
+
this.moveAsPadding(col, maxCol - numCols, numCols);
|
|
260
|
+
}
|
|
261
|
+
annotatePosition(row, col, props) {
|
|
262
|
+
const pos = rowColToPosition(row, col);
|
|
263
|
+
this.annotateRange(pos, pos + 1, props);
|
|
264
|
+
}
|
|
265
|
+
getPositionProperties(row, col) {
|
|
266
|
+
const pos = rowColToPosition(row, col);
|
|
267
|
+
return this.getPropertiesAtPosition(pos);
|
|
268
|
+
}
|
|
269
|
+
// For each row, moves 'numCols' items starting from 'srcCol' and inserts 'numCols' padding
|
|
270
|
+
// at 'destCol'. Used by insertCols and removeCols.
|
|
271
|
+
moveAsPadding(srcCol, destCol, numCols) {
|
|
272
|
+
const removeColStart = srcCol;
|
|
273
|
+
const removeColEnd = srcCol + numCols;
|
|
274
|
+
const ops = [];
|
|
275
|
+
for (let r = 0, rowStart = 0; r < this.numRows; r++, rowStart += maxCols) {
|
|
276
|
+
const removeMsg = this.client.removeRangeLocal(rowStart + removeColStart, rowStart + removeColEnd);
|
|
277
|
+
if (removeMsg) {
|
|
278
|
+
ops.push(removeMsg);
|
|
279
|
+
}
|
|
280
|
+
const insertPos = rowStart + destCol;
|
|
281
|
+
const segment = new PaddingSegment(numCols);
|
|
282
|
+
const insertMsg = this.client.insertSegmentLocal(insertPos, segment);
|
|
283
|
+
if (insertMsg) {
|
|
284
|
+
ops.push(insertMsg);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
this.submitSequenceMessage(createGroupOp(...ops));
|
|
288
|
+
}
|
|
289
|
+
getSegment(row, col) {
|
|
290
|
+
const pos = rowColToPosition(row, col);
|
|
291
|
+
return this.getContainingSegment(pos);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* @deprecated `SparseMatrixFactory` is an abandoned prototype.
|
|
296
|
+
* Use {@link @fluidframework/matrix#SharedMatrixFactory} instead.
|
|
297
|
+
*/
|
|
298
|
+
export class SparseMatrixFactory {
|
|
299
|
+
static segmentFromSpec(spec) {
|
|
300
|
+
const maybePadding = PaddingSegment.fromJSONObject(spec);
|
|
301
|
+
if (maybePadding) {
|
|
302
|
+
return maybePadding;
|
|
303
|
+
}
|
|
304
|
+
const maybeRun = RunSegment.fromJSONObject(spec);
|
|
305
|
+
if (maybeRun) {
|
|
306
|
+
return maybeRun;
|
|
307
|
+
}
|
|
308
|
+
throw new Error(`Unrecognized IJSONObject: '${JSON.stringify(spec)}'`);
|
|
309
|
+
}
|
|
310
|
+
get type() {
|
|
311
|
+
return SparseMatrixFactory.Type;
|
|
312
|
+
}
|
|
313
|
+
get attributes() {
|
|
314
|
+
return SparseMatrixFactory.Attributes;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
|
|
318
|
+
*/
|
|
319
|
+
async load(runtime, id, services, attributes) {
|
|
320
|
+
const sharedObject = new SparseMatrix(runtime, id, attributes);
|
|
321
|
+
await sharedObject.load(services);
|
|
322
|
+
return sharedObject;
|
|
323
|
+
}
|
|
324
|
+
create(document, id) {
|
|
325
|
+
const sharedObject = new SparseMatrix(document, id, this.attributes);
|
|
326
|
+
sharedObject.initializeLocal();
|
|
327
|
+
return sharedObject;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
SparseMatrixFactory.Type = "https://graph.microsoft.com/types/mergeTree/sparse-matrix";
|
|
331
|
+
SparseMatrixFactory.Attributes = {
|
|
332
|
+
type: SparseMatrixFactory.Type,
|
|
333
|
+
snapshotFormatVersion: "0.1",
|
|
334
|
+
packageVersion: pkgVersion,
|
|
335
|
+
};
|
|
336
|
+
//# sourceMappingURL=sparsematrix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sparsematrix.js","sourceRoot":"","sources":["../src/sparsematrix.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD,OAAO,EACH,WAAW,EACX,aAAa,GAKhB,MAAM,4BAA4B,CAAC;AASpC,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE9E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,OAAO,cAAe,SAAQ,WAAW;IAiB3C,YAAY,IAAY;QACpB,KAAK,EAAE,CAAC;QAHI,SAAI,GAAG,cAAc,CAAC,UAAU,CAAC;QAI7C,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;IAC7B,CAAC;IAlBM,MAAM,CAAC,EAAE,CAAC,OAAiB;QAC9B,OAAO,OAAO,CAAC,IAAI,KAAK,cAAc,CAAC,UAAU,CAAC;IACtD,CAAC;IACM,MAAM,CAAC,cAAc,CAAC,IAAS;QAClC,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,IAAI,IAAI,EAAE;YACnD,MAAM,OAAO,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC7C,IAAI,IAAI,CAAC,KAAK,EAAE;gBACZ,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACrC;YACD,OAAO,OAAO,CAAC;SAClB;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;IAQM,YAAY;QACf,OAAO,EAAE,GAAG,EA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,OAAO,EAAE,EAAE,EAAE,UAAU,CAAC,CAAC;QAC/D,MAAM,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAClC,OAAO,YAAY,CAAC;IACxB,CAAC;IAEM,MAAM,CAAC,QAAgC,EAAE,EAAU;QACtD,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC,QAAQ,EAAE,EAAE,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACrE,YAAY,CAAC,eAAe,EAAE,CAAC;QAC/B,OAAO,YAAY,CAAC;IACxB,CAAC;;AAhDa,wBAAI,GAAG,2DAA2D,CAAC;AAEnE,8BAAU,GAAuB;IAC3C,IAAI,EAAE,mBAAmB,CAAC,IAAI;IAC9B,qBAAqB,EAAE,KAAK;IAC5B,cAAc,EAAE,UAAU;CAC7B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport {\n BaseSegment,\n createGroupOp,\n IJSONSegment,\n IMergeTreeDeltaOp,\n ISegment,\n PropertySet,\n} from \"@fluidframework/merge-tree\";\nimport {\n IChannelAttributes,\n IFluidDataStoreRuntime,\n IChannelServices,\n IChannelFactory,\n Serializable,\n Jsonable,\n} from \"@fluidframework/datastore-definitions\";\nimport { SharedSegmentSequence, SubSequence } from \"@fluidframework/sequence\";\nimport { ISharedObject } from \"@fluidframework/shared-object-base\";\nimport { pkgVersion } from \"./packageVersion\";\n\n/**\n * An empty segment that occupies 'cachedLength' positions.\n * {@link SparseMatrix} uses `PaddingSegment` to \"pad\" a run of unoccupied cells.\n *\n * @deprecated `PaddingSegment` is part of an abandoned prototype.\n * Use {@link @fluidframework/matrix#SharedMatrix} instead.\n */\nexport class PaddingSegment extends BaseSegment {\n public static readonly typeString = \"PaddingSegment\";\n public static is(segment: ISegment): segment is PaddingSegment {\n return segment.type === PaddingSegment.typeString;\n }\n public static fromJSONObject(spec: any) {\n if (spec && typeof spec === \"object\" && \"pad\" in spec) {\n const segment = new PaddingSegment(spec.pad);\n if (spec.props) {\n segment.addProperties(spec.props);\n }\n return segment;\n }\n return undefined;\n }\n public readonly type = PaddingSegment.typeString;\n\n constructor(size: number) {\n super();\n this.cachedLength = size;\n }\n\n public toJSONObject() {\n return { pad: this.cachedLength, props: this.properties };\n }\n\n public clone(start = 0, end?: number) {\n const b = new PaddingSegment(this.cachedLength);\n this.cloneInto(b);\n return b;\n }\n\n public canAppend(segment: ISegment) {\n return PaddingSegment.is(segment);\n }\n\n public toString() {\n return `[padding: ${this.cachedLength}]`;\n }\n\n public append(segment: ISegment) {\n assert(PaddingSegment.is(segment), \"can only append padding segment\");\n super.append(segment);\n }\n\n // Returns true if entire run removed\n public removeRange(start: number, end: number) {\n this.cachedLength -= (end - start);\n return (this.cachedLength === 0);\n }\n\n protected createSplitSegmentAt(pos: number) {\n const leftLength = pos;\n const rightLength = this.cachedLength - pos;\n\n this.cachedLength = leftLength;\n return new PaddingSegment(rightLength);\n }\n}\n\n/**\n * @deprecated `SparseMatrixItem` is part of an abandoned prototype.\n * Use {@link @fluidframework/matrix#SharedMatrix} instead.\n */\nexport type SparseMatrixItem = Serializable;\n\n/**\n * @deprecated `RunSegment` is part of an abandoned prototype.\n * Use {@link @fluidframework/matrix#SharedMatrix} instead.\n */\nexport class RunSegment extends SubSequence<SparseMatrixItem> {\n public static readonly typeString = \"RunSegment\";\n public static is(segment: ISegment): segment is RunSegment {\n return segment.type === RunSegment.typeString;\n }\n public static fromJSONObject(spec: any) {\n if (spec && typeof spec === \"object\" && \"items\" in spec) {\n const segment = new RunSegment(spec.items);\n if (spec.props) {\n segment.addProperties(spec.props);\n }\n return segment;\n }\n return undefined;\n }\n public readonly type = RunSegment.typeString;\n\n private tags: any[];\n\n constructor(public items: SparseMatrixItem[]) {\n super(items);\n this.tags = new Array(items.length).fill(undefined);\n }\n\n public clone(start = 0, end?: number) {\n const b = new RunSegment(this.items.slice(start, end));\n if (this.tags) {\n b.tags = this.tags.slice(start, end);\n }\n this.cloneInto(b);\n return b;\n }\n\n public append(segment: ISegment) {\n super.append(segment);\n\n const asRun = segment as RunSegment;\n if (asRun.tags) {\n if (this.tags) {\n this.tags.splice(this.items.length, 0, ...asRun.tags);\n }\n }\n\n return this;\n }\n\n // TODO: retain removed items for undo\n // returns true if entire run removed\n public removeRange(start: number, end: number) {\n this.tags.splice(start, end - start);\n return super.removeRange(start, end);\n }\n\n public getTag(pos: number) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return this.tags[pos];\n }\n\n public setTag(pos: number, tag: any) {\n this.tags[pos] = tag;\n }\n\n protected createSplitSegmentAt(pos: number) {\n if (pos > 0) {\n const remainingItems = this.items.slice(pos);\n this.items = this.items.slice(0, pos);\n this.cachedLength = this.items.length;\n\n const leafSegment = new RunSegment(remainingItems);\n leafSegment.tags = this.tags.slice(pos);\n this.tags.length = pos;\n\n return leafSegment;\n }\n }\n}\n\n/**\n * @deprecated `MatrixSegment` is part of an abandoned prototype.\n * Use {@link @fluidframework/matrix#SharedMatrix} instead.\n */\nexport type MatrixSegment = RunSegment | PaddingSegment;\n\n/**\n * @deprecated `maxCol` is part of an abandoned prototype.\n * Use {@link @fluidframework/matrix#SharedMatrix} instead.\n */\nexport const maxCol = 0x200000; // X128 Excel maximum of 16,384 columns\n\n/**\n * @deprecated `maxCols` is part of an abandoned prototype.\n * Use {@link @fluidframework/matrix#SharedMatrix} instead.\n */\n export const maxCols = maxCol + 1;\n\n /**\n * @deprecated `maxRow` is part of an abandoned prototype.\n * Use {@link @fluidframework/matrix#SharedMatrix} instead.\n */\n export const maxRow = 0xFFFFFFFF; // X4096 Excel maximum of 1,048,576 rows\n\n /**\n * @deprecated `maxRows` is part of an abandoned prototype.\n * Use {@link @fluidframework/matrix#SharedMatrix} instead.\n */\n export const maxRows = maxRow + 1;\n\n /**\n * @deprecated `maxCellPosition` is part of an abandoned prototype.\n * Use {@link @fluidframework/matrix#SharedMatrix} instead.\n */\n export const maxCellPosition = maxCol * maxRow;\n\n /**\n * @deprecated `positionToRowCol` is part of an abandoned prototype.\n * Use {@link @fluidframework/matrix#SharedMatrix} instead.\n */\n export const rowColToPosition = (row: number, col: number) => row * maxCols + col;\n\n /**\n * @deprecated `positionToRowCol` is part of an abandoned prototype.\n * Use {@link @fluidframework/matrix#SharedMatrix} instead.\n */\nexport function positionToRowCol(position: number) {\n const row = Math.floor(position / maxCols);\n const col = position - (row * maxCols);\n return { row, col };\n}\n\n/**\n * @deprecated `SparseMatrix` is an abandoned prototype.\n * Use {@link @fluidframework/matrix#SharedMatrix} instead.\n */\nexport class SparseMatrix extends SharedSegmentSequence<MatrixSegment> {\n /**\n * Create a new sparse matrix\n *\n * @param runtime - data store runtime the new sparse matrix belongs to\n * @param id - optional name of the sparse matrix\n * @returns newly create sparse matrix (but not attached yet)\n */\n public static create(runtime: IFluidDataStoreRuntime, id?: string) {\n return runtime.createChannel(id, SparseMatrixFactory.Type) as SparseMatrix;\n }\n\n /**\n * Get a factory for SharedMap to register with the data store.\n *\n * @returns a factory that creates and load SharedMap\n */\n public static getFactory(): IChannelFactory {\n return new SparseMatrixFactory();\n }\n\n constructor(document: IFluidDataStoreRuntime, public id: string, attributes: IChannelAttributes) {\n super(document, id, attributes, SparseMatrixFactory.segmentFromSpec);\n }\n\n public get numRows() {\n return positionToRowCol(this.getLength()).row;\n }\n\n public setItems(\n row: number,\n col: number,\n values: SparseMatrixItem[],\n props?: PropertySet,\n ) {\n const start = rowColToPosition(row, col);\n const end = start + values.length;\n const segment = new RunSegment(values);\n if (props) {\n segment.addProperties(props);\n }\n\n this.replaceRange(start, end, segment);\n }\n\n public getItem(row: number, col: number):\n // The return type is defined explicitly here to prevent TypeScript from generating dynamic imports\n Jsonable<string | number | boolean | IFluidHandle> | undefined {\n const pos = rowColToPosition(row, col);\n const { segment, offset } = this.getContainingSegment(pos);\n if (segment && RunSegment.is(segment)) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return segment.items[offset ?? 0];\n } else if (segment && PaddingSegment.is(segment)) {\n return undefined;\n }\n\n throw new Error(`Unrecognized Segment type`);\n }\n\n public getTag(row: number, col: number) {\n const { segment, offset } = this.getSegment(row, col);\n if (segment && RunSegment.is(segment)) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return segment.getTag(offset ?? 0);\n }\n return undefined;\n }\n\n public setTag(row: number, col: number, tag: any) {\n const { segment, offset } = this.getSegment(row, col);\n if (segment && RunSegment.is(segment)) {\n segment.setTag(offset ?? 0, tag);\n } else if (tag !== undefined) {\n throw new Error(`Must not attempt to set tags on '${segment?.constructor.name}'.`);\n }\n }\n\n public insertRows(row: number, numRows: number) {\n const pos = rowColToPosition(row, 0);\n const size = maxCols * numRows;\n const segment = new PaddingSegment(size);\n\n const insertOp = this.client.insertSegmentLocal(pos, segment);\n if (insertOp) {\n this.submitSequenceMessage(insertOp);\n }\n }\n\n public removeRows(row: number, numRows: number) {\n const pos = rowColToPosition(row, 0);\n const size = maxCols * numRows;\n this.removeRange(pos, pos + size);\n }\n\n public insertCols(col: number, numCols: number) {\n this.moveAsPadding(maxCol - numCols, col, numCols);\n }\n\n public removeCols(col: number, numCols: number) {\n this.moveAsPadding(col, maxCol - numCols, numCols);\n }\n\n public annotatePosition(row: number, col: number, props: PropertySet) {\n const pos = rowColToPosition(row, col);\n this.annotateRange(pos, pos + 1, props);\n }\n\n public getPositionProperties(row: number, col: number) {\n const pos = rowColToPosition(row, col);\n return this.getPropertiesAtPosition(pos);\n }\n\n // For each row, moves 'numCols' items starting from 'srcCol' and inserts 'numCols' padding\n // at 'destCol'. Used by insertCols and removeCols.\n private moveAsPadding(srcCol: number, destCol: number, numCols: number) {\n const removeColStart = srcCol;\n const removeColEnd = srcCol + numCols;\n const ops: IMergeTreeDeltaOp[] = [];\n\n for (let r = 0, rowStart = 0; r < this.numRows; r++, rowStart += maxCols) {\n const removeMsg = this.client.removeRangeLocal(rowStart + removeColStart, rowStart + removeColEnd);\n if (removeMsg) {\n ops.push(removeMsg);\n }\n const insertPos = rowStart + destCol;\n const segment = new PaddingSegment(numCols);\n const insertMsg = this.client.insertSegmentLocal(insertPos, segment);\n if (insertMsg) {\n ops.push(insertMsg);\n }\n }\n\n this.submitSequenceMessage(createGroupOp(...ops));\n }\n\n private getSegment(row: number, col: number) {\n const pos = rowColToPosition(row, col);\n return this.getContainingSegment(pos);\n }\n}\n\n/**\n * @deprecated `SparseMatrixFactory` is an abandoned prototype.\n * Use {@link @fluidframework/matrix#SharedMatrixFactory} instead.\n */\nexport class SparseMatrixFactory implements IChannelFactory {\n public static Type = \"https://graph.microsoft.com/types/mergeTree/sparse-matrix\";\n\n public static Attributes: IChannelAttributes = {\n type: SparseMatrixFactory.Type,\n snapshotFormatVersion: \"0.1\",\n packageVersion: pkgVersion,\n };\n\n public static segmentFromSpec(spec: IJSONSegment): ISegment {\n const maybePadding = PaddingSegment.fromJSONObject(spec);\n if (maybePadding) {\n return maybePadding;\n }\n\n const maybeRun = RunSegment.fromJSONObject(spec);\n if (maybeRun) {\n return maybeRun;\n }\n\n throw new Error(`Unrecognized IJSONObject: '${JSON.stringify(spec)}'`);\n }\n\n public get type() {\n return SparseMatrixFactory.Type;\n }\n\n public get attributes() {\n return SparseMatrixFactory.Attributes;\n }\n\n /**\n * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n */\n public async load(\n runtime: IFluidDataStoreRuntime,\n id: string,\n services: IChannelServices,\n attributes: IChannelAttributes,\n ): Promise<ISharedObject> {\n const sharedObject = new SparseMatrix(runtime, id, attributes);\n await sharedObject.load(services);\n return sharedObject;\n }\n\n public create(document: IFluidDataStoreRuntime, id: string): ISharedObject {\n const sharedObject = new SparseMatrix(document, id, this.attributes);\n sharedObject.initializeLocal();\n return sharedObject;\n }\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fluid-experimental/sequence-deprecated",
|
|
3
|
+
"version": "2.0.0-dev.2.2.0.111723",
|
|
4
|
+
"description": "Deprecated distributed sequences",
|
|
5
|
+
"homepage": "https://fluidframework.com",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/microsoft/FluidFramework.git",
|
|
9
|
+
"directory": "experimental/dds/sequence-deprecated"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"author": "Microsoft and contributors",
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"main": "dist/index.js",
|
|
15
|
+
"module": "lib/index.js",
|
|
16
|
+
"types": "dist/index.d.ts",
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "npm run build:genver && concurrently npm:build:compile npm:lint && npm run build:docs",
|
|
19
|
+
"build:commonjs": "npm run tsc && npm run typetests:gen && npm run build:test",
|
|
20
|
+
"build:compile": "concurrently npm:build:commonjs npm:build:esnext",
|
|
21
|
+
"build:docs": "api-extractor run --local --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/doc-models/* ../../../_api-extractor-temp/",
|
|
22
|
+
"build:esnext": "tsc --project ./tsconfig.esnext.json",
|
|
23
|
+
"build:full": "npm run build",
|
|
24
|
+
"build:full:compile": "npm run build:compile",
|
|
25
|
+
"build:genver": "gen-version",
|
|
26
|
+
"build:test": "tsc --project ./src/test/tsconfig.json",
|
|
27
|
+
"ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
|
|
28
|
+
"clean": "rimraf dist lib *.tsbuildinfo *.build.log",
|
|
29
|
+
"eslint": "eslint --format stylish src",
|
|
30
|
+
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
31
|
+
"lint": "npm run eslint",
|
|
32
|
+
"lint:fix": "npm run eslint:fix",
|
|
33
|
+
"test": "npm run test:mocha",
|
|
34
|
+
"test:coverage": "nyc npm test -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
|
|
35
|
+
"test:mocha": "mocha --recursive dist/test/**/*.spec.js -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
|
|
36
|
+
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
37
|
+
"tsc": "tsc",
|
|
38
|
+
"typetests:gen": "flub generate typetests --generate --dir .",
|
|
39
|
+
"typetests:prepare": "flub generate typetests --prepare --dir . --pin"
|
|
40
|
+
},
|
|
41
|
+
"nyc": {
|
|
42
|
+
"all": true,
|
|
43
|
+
"cache-dir": "nyc/.cache",
|
|
44
|
+
"exclude": [
|
|
45
|
+
"src/test/**/*.ts",
|
|
46
|
+
"dist/test/**/*.js"
|
|
47
|
+
],
|
|
48
|
+
"exclude-after-remap": false,
|
|
49
|
+
"include": [
|
|
50
|
+
"src/**/*.ts",
|
|
51
|
+
"dist/**/*.js"
|
|
52
|
+
],
|
|
53
|
+
"report-dir": "nyc/report",
|
|
54
|
+
"reporter": [
|
|
55
|
+
"cobertura",
|
|
56
|
+
"html",
|
|
57
|
+
"text"
|
|
58
|
+
],
|
|
59
|
+
"temp-directory": "nyc/.nyc_output"
|
|
60
|
+
},
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"@fluidframework/common-utils": "^1.0.0",
|
|
63
|
+
"@fluidframework/core-interfaces": ">=2.0.0-dev.2.2.0.111723 <2.0.0-dev.3.0.0",
|
|
64
|
+
"@fluidframework/datastore-definitions": ">=2.0.0-dev.2.2.0.111723 <2.0.0-dev.3.0.0",
|
|
65
|
+
"@fluidframework/merge-tree": ">=2.0.0-dev.2.2.0.111723 <2.0.0-dev.3.0.0",
|
|
66
|
+
"@fluidframework/sequence": ">=2.0.0-dev.2.2.0.111723 <2.0.0-dev.3.0.0",
|
|
67
|
+
"@fluidframework/shared-object-base": ">=2.0.0-dev.2.2.0.111723 <2.0.0-dev.3.0.0"
|
|
68
|
+
},
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"@fluid-experimental/sequence-deprecated-previous": "npm:@fluid-experimental/sequence-deprecated@2.0.0-internal.2.0.0",
|
|
71
|
+
"@fluid-internal/test-dds-utils": ">=2.0.0-dev.2.2.0.111723 <2.0.0-dev.3.0.0",
|
|
72
|
+
"@fluidframework/build-common": "^1.1.0",
|
|
73
|
+
"@fluidframework/build-tools": "^0.6.0-109663",
|
|
74
|
+
"@fluidframework/eslint-config-fluid": "^1.2.0",
|
|
75
|
+
"@fluidframework/mocha-test-setup": ">=2.0.0-dev.2.2.0.111723 <2.0.0-dev.3.0.0",
|
|
76
|
+
"@fluidframework/test-runtime-utils": ">=2.0.0-dev.2.2.0.111723 <2.0.0-dev.3.0.0",
|
|
77
|
+
"@microsoft/api-extractor": "^7.22.2",
|
|
78
|
+
"@rushstack/eslint-config": "^2.5.1",
|
|
79
|
+
"@types/diff": "^3.5.1",
|
|
80
|
+
"@types/mocha": "^9.1.1",
|
|
81
|
+
"@types/node": "^14.18.0",
|
|
82
|
+
"concurrently": "^6.2.0",
|
|
83
|
+
"copyfiles": "^2.4.1",
|
|
84
|
+
"cross-env": "^7.0.2",
|
|
85
|
+
"diff": "^3.5.0",
|
|
86
|
+
"eslint": "~8.6.0",
|
|
87
|
+
"mocha": "^10.0.0",
|
|
88
|
+
"nyc": "^15.0.0",
|
|
89
|
+
"rimraf": "^2.6.2",
|
|
90
|
+
"typescript": "~4.5.5"
|
|
91
|
+
},
|
|
92
|
+
"typeValidation": {
|
|
93
|
+
"disabled": true,
|
|
94
|
+
"version": "2.0.0-internal.2.1.0",
|
|
95
|
+
"broken": {}
|
|
96
|
+
}
|
|
97
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export { SharedNumberSequence } from "./sharedNumberSequence";
|
|
7
|
+
export { SharedObjectSequence } from "./sharedObjectSequence";
|
|
8
|
+
export {
|
|
9
|
+
MatrixSegment,
|
|
10
|
+
maxCellPosition,
|
|
11
|
+
maxCol,
|
|
12
|
+
maxCols,
|
|
13
|
+
maxRow,
|
|
14
|
+
maxRows,
|
|
15
|
+
PaddingSegment,
|
|
16
|
+
positionToRowCol,
|
|
17
|
+
rowColToPosition,
|
|
18
|
+
RunSegment,
|
|
19
|
+
SparseMatrix,
|
|
20
|
+
SparseMatrixFactory,
|
|
21
|
+
SparseMatrixItem,
|
|
22
|
+
} from "./sparsematrix";
|