@fluid-experimental/property-dds 2.0.0-dev.2.2.0.111723 → 2.0.0-dev.3.1.0.125672
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.js +5 -5
- package/README.md +1 -0
- package/api-extractor.json +2 -2
- package/dist/propertyTree.d.ts +4 -1
- package/dist/propertyTree.d.ts.map +1 -1
- package/dist/propertyTree.js +45 -13
- package/dist/propertyTree.js.map +1 -1
- package/dist/propertyTreeExt.d.ts.map +1 -1
- package/dist/propertyTreeExt.js.map +1 -1
- package/dist/propertyTreeExtFactories.d.ts +2 -7
- package/dist/propertyTreeExtFactories.d.ts.map +1 -1
- package/dist/propertyTreeExtFactories.js +14 -6
- package/dist/propertyTreeExtFactories.js.map +1 -1
- package/dist/propertyTreeFactory.d.ts.map +1 -1
- package/dist/propertyTreeFactory.js.map +1 -1
- package/lib/propertyTree.d.ts +4 -1
- package/lib/propertyTree.d.ts.map +1 -1
- package/lib/propertyTree.js +46 -14
- package/lib/propertyTree.js.map +1 -1
- package/lib/propertyTreeExt.d.ts.map +1 -1
- package/lib/propertyTreeExt.js.map +1 -1
- package/lib/propertyTreeExtFactories.d.ts +2 -7
- package/lib/propertyTreeExtFactories.d.ts.map +1 -1
- package/lib/propertyTreeExtFactories.js +14 -6
- package/lib/propertyTreeExtFactories.js.map +1 -1
- package/lib/propertyTreeFactory.d.ts.map +1 -1
- package/lib/propertyTreeFactory.js.map +1 -1
- package/package.json +28 -20
- package/prettier.config.cjs +8 -0
- package/src/propertyTree.ts +155 -58
- package/src/propertyTreeExt.ts +12 -12
- package/src/propertyTreeExtFactories.ts +203 -167
- package/src/propertyTreeFactory.ts +17 -3
- package/tsconfig.esnext.json +2 -2
- package/tsconfig.json +4 -5
|
@@ -7,182 +7,218 @@ import { deflate, inflate } from "pako";
|
|
|
7
7
|
import { compress, decompress } from "lz4js";
|
|
8
8
|
import { bufferToString, stringToBuffer } from "@fluidframework/common-utils";
|
|
9
9
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
IChannelAttributes,
|
|
11
|
+
IFluidDataStoreRuntime,
|
|
12
|
+
IChannelServices,
|
|
13
|
+
IChannelFactory,
|
|
14
14
|
} from "@fluidframework/datastore-definitions";
|
|
15
15
|
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
IPropertyTreeConfig,
|
|
17
|
+
IPropertyTreeMessage,
|
|
18
|
+
ISharedPropertyTreeEncDec,
|
|
19
|
+
ISnapshotSummary,
|
|
20
|
+
SharedPropertyTree,
|
|
21
|
+
SharedPropertyTreeOptions,
|
|
22
|
+
} from "./propertyTree";
|
|
20
23
|
import { DeflatedPropertyTree, LZ4PropertyTree } from "./propertyTreeExt";
|
|
21
24
|
|
|
22
25
|
export abstract class CompressedPropertyTreeFactory implements IChannelFactory {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
26
|
+
public abstract get attributes();
|
|
27
|
+
public abstract get type();
|
|
28
|
+
public abstract getEncodeFce();
|
|
29
|
+
public abstract getDecodeFce();
|
|
30
|
+
private createCompressionMethods(encodeFn, decodeFn): ISharedPropertyTreeEncDec {
|
|
31
|
+
return {
|
|
32
|
+
messageEncoder: {
|
|
33
|
+
encode: (change: IPropertyTreeMessage) => {
|
|
34
|
+
const changeSetStr = JSON.stringify(change.changeSet);
|
|
35
|
+
const unzipped = new TextEncoder().encode(changeSetStr);
|
|
36
|
+
const zipped: Buffer = encodeFn(unzipped);
|
|
37
|
+
const zippedStr = bufferToString(zipped, "base64");
|
|
38
|
+
if (zippedStr.length < changeSetStr.length) {
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/dot-notation
|
|
40
|
+
change["isZipped"] = "1";
|
|
41
|
+
change.changeSet = zippedStr;
|
|
42
|
+
}
|
|
43
|
+
return change;
|
|
44
|
+
},
|
|
45
|
+
decode: (transferChange: IPropertyTreeMessage) => {
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/dot-notation
|
|
47
|
+
if (transferChange["isZipped"]) {
|
|
48
|
+
const zipped = new Uint8Array(
|
|
49
|
+
stringToBuffer(transferChange.changeSet, "base64"),
|
|
50
|
+
);
|
|
51
|
+
const unzipped = decodeFn(zipped);
|
|
52
|
+
const changeSetStr = new TextDecoder().decode(unzipped);
|
|
53
|
+
transferChange.changeSet = JSON.parse(changeSetStr);
|
|
54
|
+
}
|
|
55
|
+
return transferChange;
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
summaryEncoder: {
|
|
59
|
+
encode: (snapshotSummary: ISnapshotSummary): Buffer => {
|
|
60
|
+
const summaryStr = JSON.stringify(snapshotSummary);
|
|
61
|
+
const unzipped = new TextEncoder().encode(summaryStr);
|
|
62
|
+
const serializedSummary: Buffer = encodeFn(unzipped);
|
|
63
|
+
return serializedSummary;
|
|
64
|
+
},
|
|
65
|
+
decode: (serializedSummary): ISnapshotSummary => {
|
|
66
|
+
const unzipped = decodeFn(serializedSummary);
|
|
67
|
+
const summaryStr = new TextDecoder().decode(unzipped);
|
|
68
|
+
const snapshotSummary: ISnapshotSummary = JSON.parse(summaryStr);
|
|
69
|
+
return snapshotSummary;
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
public getEncDec(): ISharedPropertyTreeEncDec {
|
|
75
|
+
return this.createCompressionMethods(this.getEncodeFce(), this.getDecodeFce());
|
|
76
|
+
}
|
|
77
|
+
public abstract newPropertyTree(
|
|
78
|
+
id: string,
|
|
79
|
+
runtime: IFluidDataStoreRuntime,
|
|
80
|
+
attributes: IChannelAttributes,
|
|
81
|
+
options: SharedPropertyTreeOptions,
|
|
82
|
+
propertyTreeConfig: IPropertyTreeConfig,
|
|
83
|
+
): SharedPropertyTree;
|
|
84
|
+
|
|
85
|
+
public async load(
|
|
86
|
+
runtime: IFluidDataStoreRuntime,
|
|
87
|
+
id: string,
|
|
88
|
+
services: IChannelServices,
|
|
89
|
+
attributes: IChannelAttributes,
|
|
90
|
+
url?: string,
|
|
91
|
+
): Promise<SharedPropertyTree> {
|
|
92
|
+
const options = {};
|
|
93
|
+
const instance = this.newPropertyTree(
|
|
94
|
+
id,
|
|
95
|
+
runtime,
|
|
96
|
+
attributes,
|
|
97
|
+
options as SharedPropertyTreeOptions,
|
|
98
|
+
{ encDec: this.getEncDec() },
|
|
99
|
+
);
|
|
100
|
+
await instance.load(services);
|
|
101
|
+
return instance;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
public create(
|
|
105
|
+
document: IFluidDataStoreRuntime,
|
|
106
|
+
id: string,
|
|
107
|
+
requestUrl?: string,
|
|
108
|
+
): SharedPropertyTree {
|
|
109
|
+
const options = {};
|
|
110
|
+
const cell = this.newPropertyTree(
|
|
111
|
+
id,
|
|
112
|
+
document,
|
|
113
|
+
this.attributes,
|
|
114
|
+
options as SharedPropertyTreeOptions,
|
|
115
|
+
{ encDec: this.getEncDec() },
|
|
116
|
+
);
|
|
117
|
+
cell.initializeLocal();
|
|
118
|
+
return cell;
|
|
119
|
+
}
|
|
102
120
|
}
|
|
103
121
|
|
|
104
122
|
export class DeflatedPropertyTreeFactory extends CompressedPropertyTreeFactory {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
123
|
+
public static readonly Type = "DeflatedPropertyTree:84534a0fe613522101f6";
|
|
124
|
+
|
|
125
|
+
public static readonly Attributes: IChannelAttributes = {
|
|
126
|
+
type: DeflatedPropertyTreeFactory.Type,
|
|
127
|
+
snapshotFormatVersion: "0.1",
|
|
128
|
+
packageVersion: "0.0.1",
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
public async load(
|
|
132
|
+
runtime: IFluidDataStoreRuntime,
|
|
133
|
+
id: string,
|
|
134
|
+
services: IChannelServices,
|
|
135
|
+
attributes: IChannelAttributes,
|
|
136
|
+
url?: string,
|
|
137
|
+
): Promise<DeflatedPropertyTree> {
|
|
138
|
+
return (await super.load(runtime, id, services, attributes, url)) as DeflatedPropertyTree;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
public create(
|
|
142
|
+
document: IFluidDataStoreRuntime,
|
|
143
|
+
id: string,
|
|
144
|
+
requestUrl?: string,
|
|
145
|
+
): DeflatedPropertyTree {
|
|
146
|
+
return super.create(document, id, requestUrl);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
public get type() {
|
|
150
|
+
return DeflatedPropertyTreeFactory.Type;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
public get attributes() {
|
|
154
|
+
return DeflatedPropertyTreeFactory.Attributes;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
public getEncodeFce() {
|
|
158
|
+
return deflate;
|
|
159
|
+
}
|
|
160
|
+
public getDecodeFce() {
|
|
161
|
+
return inflate;
|
|
162
|
+
}
|
|
163
|
+
public newPropertyTree(
|
|
164
|
+
id: string,
|
|
165
|
+
runtime: IFluidDataStoreRuntime,
|
|
166
|
+
attributes: IChannelAttributes,
|
|
167
|
+
options: SharedPropertyTreeOptions,
|
|
168
|
+
propertyTreeConfig: IPropertyTreeConfig,
|
|
169
|
+
): SharedPropertyTree {
|
|
170
|
+
return new DeflatedPropertyTree(id, runtime, attributes, options, propertyTreeConfig);
|
|
171
|
+
}
|
|
145
172
|
}
|
|
146
173
|
|
|
147
174
|
export class LZ4PropertyTreeFactory extends CompressedPropertyTreeFactory {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
175
|
+
public static readonly Type = "LZ4PropertyTree:84534a0fe613522101f6";
|
|
176
|
+
|
|
177
|
+
public static readonly Attributes: IChannelAttributes = {
|
|
178
|
+
type: LZ4PropertyTreeFactory.Type,
|
|
179
|
+
snapshotFormatVersion: "0.1",
|
|
180
|
+
packageVersion: "0.0.1",
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
public async load(
|
|
184
|
+
runtime: IFluidDataStoreRuntime,
|
|
185
|
+
id: string,
|
|
186
|
+
services: IChannelServices,
|
|
187
|
+
attributes: IChannelAttributes,
|
|
188
|
+
url?: string,
|
|
189
|
+
): Promise<LZ4PropertyTree> {
|
|
190
|
+
return (await super.load(runtime, id, services, attributes, url)) as LZ4PropertyTree;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
public create(
|
|
194
|
+
document: IFluidDataStoreRuntime,
|
|
195
|
+
id: string,
|
|
196
|
+
requestUrl?: string,
|
|
197
|
+
): LZ4PropertyTree {
|
|
198
|
+
return super.create(document, id, requestUrl);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
public get type() {
|
|
202
|
+
return LZ4PropertyTreeFactory.Type;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
public get attributes() {
|
|
206
|
+
return LZ4PropertyTreeFactory.Attributes;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
public getEncodeFce() {
|
|
210
|
+
return compress;
|
|
211
|
+
}
|
|
212
|
+
public getDecodeFce() {
|
|
213
|
+
return decompress;
|
|
214
|
+
}
|
|
215
|
+
public newPropertyTree(
|
|
216
|
+
id: string,
|
|
217
|
+
runtime: IFluidDataStoreRuntime,
|
|
218
|
+
attributes: IChannelAttributes,
|
|
219
|
+
options: SharedPropertyTreeOptions,
|
|
220
|
+
propertyTreeConfig: IPropertyTreeConfig,
|
|
221
|
+
): SharedPropertyTree {
|
|
222
|
+
return new LZ4PropertyTree(id, runtime, attributes, options, propertyTreeConfig);
|
|
223
|
+
}
|
|
188
224
|
}
|
|
@@ -40,14 +40,28 @@ export class PropertyTreeFactory implements IChannelFactory {
|
|
|
40
40
|
): Promise<SharedPropertyTree> {
|
|
41
41
|
const options = {};
|
|
42
42
|
// default object
|
|
43
|
-
const instance = new SharedPropertyTree(
|
|
43
|
+
const instance = new SharedPropertyTree(
|
|
44
|
+
id,
|
|
45
|
+
runtime,
|
|
46
|
+
attributes,
|
|
47
|
+
options as SharedPropertyTreeOptions,
|
|
48
|
+
);
|
|
44
49
|
await instance.load(services);
|
|
45
50
|
return instance;
|
|
46
51
|
}
|
|
47
52
|
|
|
48
|
-
public create(
|
|
53
|
+
public create(
|
|
54
|
+
document: IFluidDataStoreRuntime,
|
|
55
|
+
id: string,
|
|
56
|
+
requestUrl?: string,
|
|
57
|
+
): SharedPropertyTree {
|
|
49
58
|
const options = {};
|
|
50
|
-
const cell = new SharedPropertyTree(
|
|
59
|
+
const cell = new SharedPropertyTree(
|
|
60
|
+
id,
|
|
61
|
+
document,
|
|
62
|
+
this.attributes,
|
|
63
|
+
options as SharedPropertyTreeOptions,
|
|
64
|
+
);
|
|
51
65
|
|
|
52
66
|
cell.initializeLocal();
|
|
53
67
|
return cell;
|
package/tsconfig.esnext.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "@fluidframework/build-common/ts-common-config.json",
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
],
|
|
6
|
-
"compilerOptions": {
|
|
3
|
+
"exclude": ["src/test/**/*"],
|
|
4
|
+
"compilerOptions": {
|
|
7
5
|
"composite": true,
|
|
8
6
|
"downlevelIteration": true,
|
|
9
7
|
"noUnusedLocals": false,
|
|
10
8
|
"outDir": "./dist",
|
|
11
|
-
"rootDir": "./src"
|
|
9
|
+
"rootDir": "./src",
|
|
10
|
+
"types": ["node"],
|
|
12
11
|
},
|
|
13
12
|
"include": ["src/**/*"],
|
|
14
13
|
}
|