@fluidframework/odsp-driver 1.3.0 → 2.0.0-dev.1.4.5.105745
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/.mocharc.js +12 -0
- package/README.md +19 -0
- package/dist/ReadBufferUtils.d.ts.map +1 -1
- package/dist/ReadBufferUtils.js +1 -0
- package/dist/ReadBufferUtils.js.map +1 -1
- package/dist/WriteBufferUtils.d.ts +3 -5
- package/dist/WriteBufferUtils.d.ts.map +1 -1
- package/dist/WriteBufferUtils.js +59 -55
- package/dist/WriteBufferUtils.js.map +1 -1
- package/dist/compactSnapshotParser.d.ts +2 -2
- package/dist/compactSnapshotParser.d.ts.map +1 -1
- package/dist/compactSnapshotParser.js +93 -33
- package/dist/compactSnapshotParser.js.map +1 -1
- package/dist/compactSnapshotWriter.d.ts +1 -2
- package/dist/compactSnapshotWriter.d.ts.map +1 -1
- package/dist/compactSnapshotWriter.js +22 -16
- package/dist/compactSnapshotWriter.js.map +1 -1
- package/dist/contracts.d.ts +1 -18
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js.map +1 -1
- package/dist/createFile.d.ts +1 -1
- package/dist/createFile.d.ts.map +1 -1
- package/dist/createFile.js +53 -16
- package/dist/createFile.js.map +1 -1
- package/dist/createNewUtils.d.ts.map +1 -1
- package/dist/createNewUtils.js +0 -1
- package/dist/createNewUtils.js.map +1 -1
- package/dist/createOdspCreateContainerRequest.d.ts +4 -3
- package/dist/createOdspCreateContainerRequest.d.ts.map +1 -1
- package/dist/createOdspCreateContainerRequest.js +6 -3
- package/dist/createOdspCreateContainerRequest.js.map +1 -1
- package/dist/epochTracker.d.ts +1 -0
- package/dist/epochTracker.d.ts.map +1 -1
- package/dist/epochTracker.js +24 -5
- package/dist/epochTracker.js.map +1 -1
- package/dist/fetchSnapshot.d.ts.map +1 -1
- package/dist/fetchSnapshot.js +14 -19
- package/dist/fetchSnapshot.js.map +1 -1
- package/dist/getFileLink.d.ts +3 -6
- package/dist/getFileLink.d.ts.map +1 -1
- package/dist/getFileLink.js +11 -14
- package/dist/getFileLink.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +1 -1
- package/dist/localOdspDriver/localOdspDocumentStorageManager.js +1 -2
- package/dist/localOdspDriver/localOdspDocumentStorageManager.js.map +1 -1
- package/dist/odspDeltaStorageService.d.ts +1 -1
- package/dist/odspDeltaStorageService.d.ts.map +1 -1
- package/dist/odspDeltaStorageService.js +4 -8
- package/dist/odspDeltaStorageService.js.map +1 -1
- package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
- package/dist/odspDocumentDeltaConnection.js +3 -6
- package/dist/odspDocumentDeltaConnection.js.map +1 -1
- package/dist/odspDocumentService.d.ts +1 -0
- package/dist/odspDocumentService.d.ts.map +1 -1
- package/dist/odspDocumentService.js +10 -5
- package/dist/odspDocumentService.js.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.js +29 -6
- package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
- package/dist/odspDocumentStorageManager.d.ts +4 -3
- package/dist/odspDocumentStorageManager.d.ts.map +1 -1
- package/dist/odspDocumentStorageManager.js +73 -64
- package/dist/odspDocumentStorageManager.js.map +1 -1
- package/dist/odspDocumentStorageServiceBase.d.ts +1 -1
- package/dist/odspDocumentStorageServiceBase.d.ts.map +1 -1
- package/dist/odspDocumentStorageServiceBase.js +4 -2
- package/dist/odspDocumentStorageServiceBase.js.map +1 -1
- package/dist/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
- package/dist/odspDriverUrlResolverForShareLink.js +4 -4
- package/dist/odspDriverUrlResolverForShareLink.js.map +1 -1
- package/dist/odspFluidFileLink.js +1 -1
- package/dist/odspFluidFileLink.js.map +1 -1
- package/dist/odspLocationRedirection.d.ts +14 -0
- package/dist/odspLocationRedirection.d.ts.map +1 -0
- package/dist/odspLocationRedirection.js +24 -0
- package/dist/odspLocationRedirection.js.map +1 -0
- package/dist/odspSnapshotParser.d.ts.map +1 -1
- package/dist/odspSnapshotParser.js +1 -2
- package/dist/odspSnapshotParser.js.map +1 -1
- package/dist/odspSummaryUploadManager.d.ts +6 -3
- package/dist/odspSummaryUploadManager.d.ts.map +1 -1
- package/dist/odspSummaryUploadManager.js +18 -16
- package/dist/odspSummaryUploadManager.js.map +1 -1
- package/dist/odspUrlHelper.js +2 -1
- package/dist/odspUrlHelper.js.map +1 -1
- package/dist/odspUtils.d.ts +11 -2
- package/dist/odspUtils.d.ts.map +1 -1
- package/dist/odspUtils.js +32 -5
- package/dist/odspUtils.js.map +1 -1
- package/dist/opsCaching.d.ts.map +1 -1
- package/dist/opsCaching.js +3 -2
- package/dist/opsCaching.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/prefetchLatestSnapshot.d.ts +6 -4
- package/dist/prefetchLatestSnapshot.d.ts.map +1 -1
- package/dist/prefetchLatestSnapshot.js +6 -4
- package/dist/prefetchLatestSnapshot.js.map +1 -1
- package/dist/retryUtils.d.ts.map +1 -1
- package/dist/retryUtils.js +8 -4
- package/dist/retryUtils.js.map +1 -1
- package/dist/zipItDataRepresentationUtils.d.ts +30 -18
- package/dist/zipItDataRepresentationUtils.d.ts.map +1 -1
- package/dist/zipItDataRepresentationUtils.js +170 -76
- package/dist/zipItDataRepresentationUtils.js.map +1 -1
- package/lib/ReadBufferUtils.d.ts.map +1 -1
- package/lib/ReadBufferUtils.js +1 -0
- package/lib/ReadBufferUtils.js.map +1 -1
- package/lib/WriteBufferUtils.d.ts +3 -5
- package/lib/WriteBufferUtils.d.ts.map +1 -1
- package/lib/WriteBufferUtils.js +61 -57
- package/lib/WriteBufferUtils.js.map +1 -1
- package/lib/compactSnapshotParser.d.ts +2 -2
- package/lib/compactSnapshotParser.d.ts.map +1 -1
- package/lib/compactSnapshotParser.js +94 -34
- package/lib/compactSnapshotParser.js.map +1 -1
- package/lib/compactSnapshotWriter.d.ts +1 -2
- package/lib/compactSnapshotWriter.d.ts.map +1 -1
- package/lib/compactSnapshotWriter.js +23 -17
- package/lib/compactSnapshotWriter.js.map +1 -1
- package/lib/contracts.d.ts +1 -18
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contracts.js.map +1 -1
- package/lib/createFile.d.ts +1 -1
- package/lib/createFile.d.ts.map +1 -1
- package/lib/createFile.js +54 -17
- package/lib/createFile.js.map +1 -1
- package/lib/createNewUtils.d.ts.map +1 -1
- package/lib/createNewUtils.js +0 -1
- package/lib/createNewUtils.js.map +1 -1
- package/lib/createOdspCreateContainerRequest.d.ts +4 -3
- package/lib/createOdspCreateContainerRequest.d.ts.map +1 -1
- package/lib/createOdspCreateContainerRequest.js +6 -3
- package/lib/createOdspCreateContainerRequest.js.map +1 -1
- package/lib/epochTracker.d.ts +1 -0
- package/lib/epochTracker.d.ts.map +1 -1
- package/lib/epochTracker.js +26 -7
- package/lib/epochTracker.js.map +1 -1
- package/lib/fetchSnapshot.d.ts.map +1 -1
- package/lib/fetchSnapshot.js +14 -19
- package/lib/fetchSnapshot.js.map +1 -1
- package/lib/getFileLink.d.ts +3 -6
- package/lib/getFileLink.d.ts.map +1 -1
- package/lib/getFileLink.js +11 -14
- package/lib/getFileLink.js.map +1 -1
- package/lib/index.d.ts +1 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -3
- package/lib/index.js.map +1 -1
- package/lib/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +1 -1
- package/lib/localOdspDriver/localOdspDocumentStorageManager.js +1 -2
- package/lib/localOdspDriver/localOdspDocumentStorageManager.js.map +1 -1
- package/lib/odspDeltaStorageService.d.ts +1 -1
- package/lib/odspDeltaStorageService.d.ts.map +1 -1
- package/lib/odspDeltaStorageService.js +4 -8
- package/lib/odspDeltaStorageService.js.map +1 -1
- package/lib/odspDocumentDeltaConnection.d.ts.map +1 -1
- package/lib/odspDocumentDeltaConnection.js +3 -6
- package/lib/odspDocumentDeltaConnection.js.map +1 -1
- package/lib/odspDocumentService.d.ts +1 -0
- package/lib/odspDocumentService.d.ts.map +1 -1
- package/lib/odspDocumentService.js +11 -6
- package/lib/odspDocumentService.js.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.js +29 -6
- package/lib/odspDocumentServiceFactoryCore.js.map +1 -1
- package/lib/odspDocumentStorageManager.d.ts +4 -3
- package/lib/odspDocumentStorageManager.d.ts.map +1 -1
- package/lib/odspDocumentStorageManager.js +74 -65
- package/lib/odspDocumentStorageManager.js.map +1 -1
- package/lib/odspDocumentStorageServiceBase.d.ts +1 -1
- package/lib/odspDocumentStorageServiceBase.d.ts.map +1 -1
- package/lib/odspDocumentStorageServiceBase.js +4 -2
- package/lib/odspDocumentStorageServiceBase.js.map +1 -1
- package/lib/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
- package/lib/odspDriverUrlResolverForShareLink.js +4 -4
- package/lib/odspDriverUrlResolverForShareLink.js.map +1 -1
- package/lib/odspFluidFileLink.js +1 -1
- package/lib/odspFluidFileLink.js.map +1 -1
- package/lib/odspLocationRedirection.d.ts +14 -0
- package/lib/odspLocationRedirection.d.ts.map +1 -0
- package/lib/odspLocationRedirection.js +20 -0
- package/lib/odspLocationRedirection.js.map +1 -0
- package/lib/odspSnapshotParser.d.ts.map +1 -1
- package/lib/odspSnapshotParser.js +1 -2
- package/lib/odspSnapshotParser.js.map +1 -1
- package/lib/odspSummaryUploadManager.d.ts +6 -3
- package/lib/odspSummaryUploadManager.d.ts.map +1 -1
- package/lib/odspSummaryUploadManager.js +18 -16
- package/lib/odspSummaryUploadManager.js.map +1 -1
- package/lib/odspUrlHelper.js +2 -1
- package/lib/odspUrlHelper.js.map +1 -1
- package/lib/odspUtils.d.ts +11 -2
- package/lib/odspUtils.d.ts.map +1 -1
- package/lib/odspUtils.js +31 -5
- package/lib/odspUtils.js.map +1 -1
- package/lib/opsCaching.d.ts.map +1 -1
- package/lib/opsCaching.js +3 -2
- package/lib/opsCaching.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/prefetchLatestSnapshot.d.ts +6 -4
- package/lib/prefetchLatestSnapshot.d.ts.map +1 -1
- package/lib/prefetchLatestSnapshot.js +6 -4
- package/lib/prefetchLatestSnapshot.js.map +1 -1
- package/lib/retryUtils.d.ts.map +1 -1
- package/lib/retryUtils.js +9 -5
- package/lib/retryUtils.js.map +1 -1
- package/lib/zipItDataRepresentationUtils.d.ts +30 -18
- package/lib/zipItDataRepresentationUtils.d.ts.map +1 -1
- package/lib/zipItDataRepresentationUtils.js +166 -75
- package/lib/zipItDataRepresentationUtils.js.map +1 -1
- package/package.json +33 -20
- package/src/ReadBufferUtils.ts +1 -0
- package/src/WriteBufferUtils.ts +67 -58
- package/src/compactSnapshotParser.ts +103 -39
- package/src/compactSnapshotWriter.ts +30 -19
- package/src/contracts.ts +2 -14
- package/src/createFile.ts +75 -15
- package/src/createNewUtils.ts +2 -4
- package/src/createOdspCreateContainerRequest.ts +7 -4
- package/src/epochTracker.ts +47 -7
- package/src/fetchSnapshot.ts +19 -19
- package/src/getFileLink.ts +12 -22
- package/src/index.ts +1 -3
- package/src/localOdspDriver/localOdspDocumentStorageManager.ts +2 -2
- package/src/odspDeltaStorageService.ts +4 -7
- package/src/odspDocumentDeltaConnection.ts +3 -5
- package/src/odspDocumentService.ts +13 -11
- package/src/odspDocumentServiceFactoryCore.ts +40 -4
- package/src/odspDocumentStorageManager.ts +55 -45
- package/src/odspDocumentStorageServiceBase.ts +4 -2
- package/src/odspDriverUrlResolverForShareLink.ts +2 -5
- package/src/odspFluidFileLink.ts +1 -1
- package/src/odspLocationRedirection.ts +23 -0
- package/src/odspSnapshotParser.ts +3 -4
- package/src/odspSummaryUploadManager.ts +14 -10
- package/src/odspUrlHelper.ts +1 -1
- package/src/odspUtils.ts +40 -7
- package/src/opsCaching.ts +3 -2
- package/src/packageVersion.ts +1 -1
- package/src/prefetchLatestSnapshot.ts +6 -4
- package/src/retryUtils.ts +8 -5
- package/src/zipItDataRepresentationUtils.ts +198 -75
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
+
import { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
5
6
|
import { ReadBuffer } from "./ReadBufferUtils";
|
|
6
7
|
/**
|
|
7
8
|
* Control codes used by tree serialization / decentralization code. Same as on server. These can be found on
|
|
@@ -80,7 +81,7 @@ export declare const codeToBytesMap: {
|
|
|
80
81
|
export declare function getValueSafely(map: {
|
|
81
82
|
[index: number]: number;
|
|
82
83
|
}, key: number): number;
|
|
83
|
-
export declare function
|
|
84
|
+
export declare function getNodeProps(node: NodeCore): Record<string, NodeTypes>;
|
|
84
85
|
export declare function iteratePairs<T>(it: IterableIterator<T>): IterableIterator<[T, T]>;
|
|
85
86
|
/**
|
|
86
87
|
* Helper function that returns iterator from an object
|
|
@@ -95,24 +96,19 @@ export declare function iterate<T>(obj: {
|
|
|
95
96
|
* Note: concrete implementations (derived classes) are not exposed from this module
|
|
96
97
|
*/
|
|
97
98
|
export declare abstract class BlobCore {
|
|
98
|
-
readonly constString: boolean;
|
|
99
|
-
readonly useUtf8Code: boolean;
|
|
100
99
|
abstract get buffer(): Uint8Array;
|
|
101
|
-
get arrayBuffer(): ArrayBufferLike;
|
|
100
|
+
abstract get arrayBuffer(): ArrayBufferLike;
|
|
102
101
|
/**
|
|
103
102
|
* Represents a blob.
|
|
104
|
-
* @param constString - Whether it contains const string declaration.
|
|
105
|
-
* @param useUtf8Code - Represents if the utf8 string marker code should be used when representing.
|
|
106
103
|
*/
|
|
107
|
-
constructor(
|
|
108
|
-
toString(): string;
|
|
104
|
+
constructor();
|
|
109
105
|
}
|
|
110
106
|
/**
|
|
111
107
|
* Shallow copy blob, keeps a reference to portion of ReadBuffer
|
|
112
108
|
* it was constructed from. It takes much less memory compared to BlobDeepCopy
|
|
113
109
|
*/
|
|
114
110
|
export declare class BlobShallowCopy extends BlobCore {
|
|
115
|
-
protected data:
|
|
111
|
+
protected data: Uint8Array;
|
|
116
112
|
protected start: number;
|
|
117
113
|
protected end: number;
|
|
118
114
|
/**
|
|
@@ -120,15 +116,26 @@ export declare class BlobShallowCopy extends BlobCore {
|
|
|
120
116
|
* @param data - Data array of the blob
|
|
121
117
|
* @param start - Start point of the blob in the buffer.
|
|
122
118
|
* @param end - End point of the blob in the buffer.
|
|
123
|
-
* @param constString - Whether it contains const string declaration.
|
|
124
119
|
*/
|
|
125
|
-
constructor(data:
|
|
120
|
+
constructor(data: Uint8Array, start: number, end: number);
|
|
126
121
|
get buffer(): Uint8Array;
|
|
127
|
-
|
|
122
|
+
get arrayBuffer(): ArrayBufferLike;
|
|
123
|
+
static read(buffer: ReadBuffer, lengthLen: number): BlobCore;
|
|
128
124
|
}
|
|
129
|
-
export declare const addStringProperty: (node: NodeCore, a: string, b: string
|
|
125
|
+
export declare const addStringProperty: (node: NodeCore, a: string, b: string) => void;
|
|
126
|
+
export declare const addDictionaryStringProperty: (node: NodeCore, a: string, b: string) => void;
|
|
130
127
|
export declare const addNumberProperty: (node: NodeCore, a: string, b: number) => void;
|
|
131
128
|
export declare const addBoolProperty: (node: NodeCore, a: string, b: boolean) => void;
|
|
129
|
+
export interface IStringElement {
|
|
130
|
+
content: string;
|
|
131
|
+
dictionary: boolean;
|
|
132
|
+
_stringElement: true;
|
|
133
|
+
}
|
|
134
|
+
export interface IStringElementInternal extends Omit<IStringElement, "content"> {
|
|
135
|
+
content?: string;
|
|
136
|
+
startPos: number;
|
|
137
|
+
endPos: number;
|
|
138
|
+
}
|
|
132
139
|
/**
|
|
133
140
|
* Three leaf types supported by tree:
|
|
134
141
|
* 1. Node (sub-tree)
|
|
@@ -136,7 +143,7 @@ export declare const addBoolProperty: (node: NodeCore, a: string, b: boolean) =>
|
|
|
136
143
|
* 3. integer
|
|
137
144
|
* 4. boolean
|
|
138
145
|
*/
|
|
139
|
-
export declare type NodeTypes = NodeCore | BlobCore | number | boolean;
|
|
146
|
+
export declare type NodeTypes = NodeCore | BlobCore | number | boolean | IStringElement;
|
|
140
147
|
export declare type NodeCoreTypes = "list" | "set";
|
|
141
148
|
/**
|
|
142
149
|
* Node - node in the tree (non-leaf element of the tree)
|
|
@@ -151,28 +158,33 @@ export declare class NodeCore {
|
|
|
151
158
|
get length(): number;
|
|
152
159
|
get(index: number): NodeTypes;
|
|
153
160
|
getString(index: number): string;
|
|
161
|
+
getMaybeString(index: number): string | undefined;
|
|
154
162
|
getBlob(index: number): BlobCore;
|
|
155
163
|
getNode(index: number): NodeCore;
|
|
156
164
|
getNumber(index: number): number;
|
|
157
165
|
getBool(index: number): boolean;
|
|
158
166
|
addNode(type?: NodeCoreTypes): NodeCore;
|
|
159
|
-
addBlob(blob: Uint8Array
|
|
160
|
-
|
|
167
|
+
addBlob(blob: Uint8Array): void;
|
|
168
|
+
addDictionaryString(payload: string): void;
|
|
169
|
+
addString(payload: string): void;
|
|
161
170
|
addNumber(payload: number | undefined): void;
|
|
162
171
|
addBool(payload: boolean): void;
|
|
172
|
+
private static readString;
|
|
163
173
|
/**
|
|
164
174
|
* Load and parse the buffer into a tree.
|
|
165
175
|
* @param buffer - buffer to read from.
|
|
166
176
|
*/
|
|
167
|
-
protected load(buffer: ReadBuffer,
|
|
177
|
+
protected load(buffer: ReadBuffer, logger: ITelemetryLogger): void;
|
|
168
178
|
}
|
|
169
179
|
/**
|
|
170
180
|
* TreeBuilder - Root of the tree.
|
|
171
181
|
* Provides loading and serialization capabilities.
|
|
172
182
|
*/
|
|
173
183
|
export declare class TreeBuilder extends NodeCore {
|
|
174
|
-
static load(buffer: ReadBuffer): TreeBuilder;
|
|
184
|
+
static load(buffer: ReadBuffer, logger: ITelemetryLogger): TreeBuilder;
|
|
175
185
|
}
|
|
186
|
+
export declare function getMaybeStringInstance(node: NodeTypes): string | undefined;
|
|
187
|
+
export declare function getStringInstance(node: NodeTypes, message: string): string;
|
|
176
188
|
export declare function assertBlobCoreInstance(node: NodeTypes, message: string): asserts node is BlobCore;
|
|
177
189
|
export declare function assertNodeCoreInstance(node: NodeTypes, message: string): asserts node is NodeCore;
|
|
178
190
|
export declare function assertNumberInstance(node: NodeTypes, message: string): asserts node is number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zipItDataRepresentationUtils.d.ts","sourceRoot":"","sources":["../src/zipItDataRepresentationUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"zipItDataRepresentationUtils.d.ts","sourceRoot":"","sources":["../src/zipItDataRepresentationUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAGtE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAK/C;;;GAGG;AACH,oBAAY,WAAW;IACnB,QAAQ,KAAK;IACb,SAAS,KAAK;IAEd,WAAW,KAAK;IAChB,aAAa,KAAK;IAClB,cAAc,KAAK;IACnB,cAAc,KAAK;IAEnB,cAAc,KAAK;IACnB,eAAe,KAAK;IACpB,eAAe,KAAK;IACpB,kBAAkB,KAAK;IACvB,qBAAqB,KAAK;IAE1B,IAAI,IAAI;IACR,KAAK,IAAI;IACT,MAAM,IAAI;IACV,MAAM,IAAI;IACV,MAAM,IAAI;IACV,IAAI,IAAI;IACR,KAAK,IAAI;IACT,KAAK,IAAI;IACT,KAAK,IAAI;IAET,WAAW,KAAK;IAChB,aAAa,KAAK;IAClB,cAAc,KAAK;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
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.assertBoolInstance = exports.assertNumberInstance = exports.assertNodeCoreInstance = exports.assertBlobCoreInstance = exports.TreeBuilder = exports.NodeCore = exports.addBoolProperty = exports.addNumberProperty = exports.addStringProperty = exports.BlobShallowCopy = exports.BlobCore = exports.iterate = exports.iteratePairs = exports.
|
|
7
|
+
exports.assertBoolInstance = exports.assertNumberInstance = exports.assertNodeCoreInstance = exports.assertBlobCoreInstance = exports.getStringInstance = exports.getMaybeStringInstance = exports.TreeBuilder = exports.NodeCore = exports.addBoolProperty = exports.addNumberProperty = exports.addDictionaryStringProperty = exports.addStringProperty = exports.BlobShallowCopy = exports.BlobCore = exports.iterate = exports.iteratePairs = exports.getNodeProps = exports.getValueSafely = exports.codeToBytesMap = exports.MarkerCodesEnd = exports.MarkerCodesStart = exports.MarkerCodes = void 0;
|
|
8
8
|
/**
|
|
9
9
|
* Data representation which is followed(zipIt Protocol) here is described in this document:
|
|
10
10
|
* https://microsoft.sharepoint-df.com/:w:/t/ODSPFileStore/ER06b64K_XdDjEyAKl-UT60BJiId39SCVkYSyo_2pvH9gQ?e=KYQ0c5
|
|
@@ -101,23 +101,15 @@ function getValueSafely(map, key) {
|
|
|
101
101
|
return val;
|
|
102
102
|
}
|
|
103
103
|
exports.getValueSafely = getValueSafely;
|
|
104
|
-
function
|
|
105
|
-
const propSet = new Set(props);
|
|
104
|
+
function getNodeProps(node) {
|
|
106
105
|
const res = {};
|
|
107
106
|
for (const [keyNode, valueNode] of node.iteratePairs()) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (propSet.has(keyStr)) {
|
|
111
|
-
propSet.delete(keyStr);
|
|
112
|
-
res[keyStr] = valueNode;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
if (enforceAllProps) {
|
|
116
|
-
(0, common_utils_1.assert)(propSet.size === 0, 0x288 /* All properties should exist */);
|
|
107
|
+
const id = getStringInstance(keyNode, "keynode should be a string");
|
|
108
|
+
res[id] = valueNode;
|
|
117
109
|
}
|
|
118
110
|
return res;
|
|
119
111
|
}
|
|
120
|
-
exports.
|
|
112
|
+
exports.getNodeProps = getNodeProps;
|
|
121
113
|
function iteratePairs(it) {
|
|
122
114
|
const res = {
|
|
123
115
|
next: () => {
|
|
@@ -150,19 +142,8 @@ exports.iterate = iterate;
|
|
|
150
142
|
class BlobCore {
|
|
151
143
|
/**
|
|
152
144
|
* Represents a blob.
|
|
153
|
-
* @param constString - Whether it contains const string declaration.
|
|
154
|
-
* @param useUtf8Code - Represents if the utf8 string marker code should be used when representing.
|
|
155
145
|
*/
|
|
156
|
-
constructor(
|
|
157
|
-
this.constString = constString;
|
|
158
|
-
this.useUtf8Code = useUtf8Code;
|
|
159
|
-
}
|
|
160
|
-
get arrayBuffer() {
|
|
161
|
-
return (0, common_utils_1.Uint8ArrayToArrayBuffer)(this.buffer);
|
|
162
|
-
}
|
|
163
|
-
toString() {
|
|
164
|
-
return (0, common_utils_1.Uint8ArrayToString)(this.buffer, "utf-8");
|
|
165
|
-
}
|
|
146
|
+
constructor() { }
|
|
166
147
|
}
|
|
167
148
|
exports.BlobCore = BlobCore;
|
|
168
149
|
/**
|
|
@@ -174,23 +155,24 @@ class BlobDeepCopy extends BlobCore {
|
|
|
174
155
|
/**
|
|
175
156
|
* Represents a deep copy of the blob.
|
|
176
157
|
* @param data - Data array of the blob
|
|
177
|
-
* @param constString - Whether it contains const string declaration.
|
|
178
|
-
* @param useUtf8Code - Represents if the utf8 string marker code should be used when representing.
|
|
179
158
|
*/
|
|
180
|
-
constructor(data
|
|
181
|
-
super(
|
|
159
|
+
constructor(data) {
|
|
160
|
+
super();
|
|
182
161
|
this.data = data;
|
|
183
162
|
}
|
|
184
163
|
get buffer() {
|
|
185
164
|
return this.data;
|
|
186
165
|
}
|
|
187
|
-
|
|
166
|
+
get arrayBuffer() {
|
|
167
|
+
return (0, common_utils_1.Uint8ArrayToArrayBuffer)(this.buffer);
|
|
168
|
+
}
|
|
169
|
+
static read(buffer, lengthLen) {
|
|
188
170
|
const length = buffer.read(lengthLen);
|
|
189
171
|
const data = new Uint8Array(length);
|
|
190
172
|
for (let counter = 0; counter < length; counter++) {
|
|
191
173
|
data[counter] = buffer.read();
|
|
192
174
|
}
|
|
193
|
-
return new BlobDeepCopy(data
|
|
175
|
+
return new BlobDeepCopy(data);
|
|
194
176
|
}
|
|
195
177
|
}
|
|
196
178
|
/**
|
|
@@ -203,37 +185,46 @@ class BlobShallowCopy extends BlobCore {
|
|
|
203
185
|
* @param data - Data array of the blob
|
|
204
186
|
* @param start - Start point of the blob in the buffer.
|
|
205
187
|
* @param end - End point of the blob in the buffer.
|
|
206
|
-
* @param constString - Whether it contains const string declaration.
|
|
207
188
|
*/
|
|
208
|
-
constructor(data, start, end
|
|
209
|
-
super(
|
|
189
|
+
constructor(data, start, end) {
|
|
190
|
+
super();
|
|
210
191
|
this.data = data;
|
|
211
192
|
this.start = start;
|
|
212
193
|
this.end = end;
|
|
213
194
|
}
|
|
214
195
|
get buffer() {
|
|
215
|
-
return this.data.
|
|
196
|
+
return this.data.subarray(this.start, this.end);
|
|
197
|
+
}
|
|
198
|
+
// Equivalent to Uint8ArrayToArrayBuffer(this.buffer)
|
|
199
|
+
get arrayBuffer() {
|
|
200
|
+
const offset = this.data.byteOffset;
|
|
201
|
+
return this.data.buffer.slice(this.start + offset, this.end + offset);
|
|
216
202
|
}
|
|
217
|
-
static read(buffer, lengthLen
|
|
203
|
+
static read(buffer, lengthLen) {
|
|
218
204
|
const length = buffer.read(lengthLen);
|
|
219
205
|
const pos = buffer.pos;
|
|
220
206
|
buffer.skip(length);
|
|
221
|
-
return new BlobShallowCopy(buffer, pos, pos + length
|
|
207
|
+
return new BlobShallowCopy(buffer.buffer, pos, pos + length);
|
|
222
208
|
}
|
|
223
209
|
}
|
|
224
210
|
exports.BlobShallowCopy = BlobShallowCopy;
|
|
225
|
-
const addStringProperty = (node, a, b
|
|
226
|
-
node.
|
|
227
|
-
node.addString(b
|
|
211
|
+
const addStringProperty = (node, a, b) => {
|
|
212
|
+
node.addDictionaryString(a);
|
|
213
|
+
node.addString(b);
|
|
228
214
|
};
|
|
229
215
|
exports.addStringProperty = addStringProperty;
|
|
216
|
+
const addDictionaryStringProperty = (node, a, b) => {
|
|
217
|
+
node.addDictionaryString(a);
|
|
218
|
+
node.addString(b);
|
|
219
|
+
};
|
|
220
|
+
exports.addDictionaryStringProperty = addDictionaryStringProperty;
|
|
230
221
|
const addNumberProperty = (node, a, b) => {
|
|
231
|
-
node.
|
|
222
|
+
node.addDictionaryString(a);
|
|
232
223
|
node.addNumber(b);
|
|
233
224
|
};
|
|
234
225
|
exports.addNumberProperty = addNumberProperty;
|
|
235
226
|
const addBoolProperty = (node, a, b) => {
|
|
236
|
-
node.
|
|
227
|
+
node.addDictionaryString(a);
|
|
237
228
|
node.addBool(b);
|
|
238
229
|
};
|
|
239
230
|
exports.addBoolProperty = addBoolProperty;
|
|
@@ -260,8 +251,11 @@ class NodeCore {
|
|
|
260
251
|
get(index) { return this.children[index]; }
|
|
261
252
|
getString(index) {
|
|
262
253
|
const node = this.children[index];
|
|
263
|
-
|
|
264
|
-
|
|
254
|
+
return getStringInstance(node, "getString should return string");
|
|
255
|
+
}
|
|
256
|
+
getMaybeString(index) {
|
|
257
|
+
const node = this.children[index];
|
|
258
|
+
return getMaybeStringInstance(node);
|
|
265
259
|
}
|
|
266
260
|
getBlob(index) {
|
|
267
261
|
const node = this.children[index];
|
|
@@ -288,11 +282,22 @@ class NodeCore {
|
|
|
288
282
|
this.children.push(node);
|
|
289
283
|
return node;
|
|
290
284
|
}
|
|
291
|
-
addBlob(blob
|
|
292
|
-
this.children.push(new BlobDeepCopy(blob
|
|
285
|
+
addBlob(blob) {
|
|
286
|
+
this.children.push(new BlobDeepCopy(blob));
|
|
293
287
|
}
|
|
294
|
-
|
|
295
|
-
this.
|
|
288
|
+
addDictionaryString(payload) {
|
|
289
|
+
this.children.push({
|
|
290
|
+
content: payload,
|
|
291
|
+
dictionary: true,
|
|
292
|
+
_stringElement: true,
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
addString(payload) {
|
|
296
|
+
this.children.push({
|
|
297
|
+
content: payload,
|
|
298
|
+
dictionary: false,
|
|
299
|
+
_stringElement: true,
|
|
300
|
+
});
|
|
296
301
|
}
|
|
297
302
|
addNumber(payload) {
|
|
298
303
|
(0, common_utils_1.assert)(Number.isInteger(payload), 0x231 /* "Number should be an integer" */);
|
|
@@ -302,59 +307,88 @@ class NodeCore {
|
|
|
302
307
|
addBool(payload) {
|
|
303
308
|
this.children.push(payload);
|
|
304
309
|
}
|
|
310
|
+
// Can we do more efficiently here, without extra objects somehow??
|
|
311
|
+
static readString(buffer, code, dictionary) {
|
|
312
|
+
const lengthLen = getValueSafely(exports.codeToBytesMap, code);
|
|
313
|
+
const length = buffer.read(lengthLen);
|
|
314
|
+
const startPos = buffer.pos;
|
|
315
|
+
buffer.skip(length);
|
|
316
|
+
const result = {
|
|
317
|
+
// Note: Setting here property 'content: undefined' makes code substantially slower!
|
|
318
|
+
dictionary,
|
|
319
|
+
_stringElement: true,
|
|
320
|
+
startPos,
|
|
321
|
+
endPos: buffer.pos,
|
|
322
|
+
};
|
|
323
|
+
// We are lying here in terms of presence of `content` property.
|
|
324
|
+
// This will be addressed at the bottom of NodeCore.load() by resolving all strings at once!
|
|
325
|
+
// It's equivalent (but much slower!) to do it here via
|
|
326
|
+
// result.content = Uint8ArrayToString(buffer.buffer.subarray(startPos, buffer.pos), "utf-8");
|
|
327
|
+
return result;
|
|
328
|
+
}
|
|
305
329
|
/**
|
|
306
330
|
* Load and parse the buffer into a tree.
|
|
307
331
|
* @param buffer - buffer to read from.
|
|
308
332
|
*/
|
|
309
|
-
load(buffer,
|
|
333
|
+
load(buffer, logger) {
|
|
334
|
+
const stack = [];
|
|
335
|
+
const stringsToResolve = [];
|
|
336
|
+
const dictionary = [];
|
|
337
|
+
let children = this.children;
|
|
310
338
|
for (; !buffer.eof;) {
|
|
311
|
-
let childValue;
|
|
312
339
|
const code = buffer.read();
|
|
313
340
|
switch (code) {
|
|
314
341
|
case MarkerCodesStart.list:
|
|
315
342
|
case MarkerCodesStart.set: {
|
|
316
|
-
childValue = new NodeCore(code === MarkerCodesStart.set ? "set" : "list");
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
343
|
+
const childValue = new NodeCore(code === MarkerCodesStart.set ? "set" : "list");
|
|
344
|
+
children.push(childValue);
|
|
345
|
+
stack.push(children);
|
|
346
|
+
children = childValue.children;
|
|
347
|
+
continue;
|
|
320
348
|
}
|
|
321
349
|
case MarkerCodes.ConstStringDeclare:
|
|
322
350
|
case MarkerCodes.ConstStringDeclareBig:
|
|
323
351
|
{
|
|
324
352
|
const stringId = buffer.read(getValueSafely(exports.codeToBytesMap, code));
|
|
325
|
-
const constString =
|
|
353
|
+
const constString = NodeCore.readString(buffer, code, true /* dictionary */);
|
|
354
|
+
stringsToResolve.push(constString);
|
|
326
355
|
dictionary[stringId] = constString;
|
|
327
|
-
|
|
356
|
+
continue;
|
|
328
357
|
}
|
|
329
358
|
case MarkerCodes.ConstString8Id:
|
|
330
359
|
case MarkerCodes.ConstString16Id:
|
|
331
360
|
case MarkerCodes.ConstString32Id:
|
|
332
361
|
{
|
|
333
362
|
const stringId = buffer.read(getValueSafely(exports.codeToBytesMap, code));
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
363
|
+
const content = dictionary[stringId];
|
|
364
|
+
(0, common_utils_1.assert)(content !== undefined, 0x3de /* const string not found */);
|
|
365
|
+
children.push(content);
|
|
366
|
+
continue;
|
|
337
367
|
}
|
|
338
368
|
case MarkerCodes.StringEmpty:
|
|
339
369
|
case MarkerCodes.String8Length:
|
|
340
370
|
case MarkerCodes.String16Length:
|
|
341
371
|
case MarkerCodes.String32Length:
|
|
372
|
+
{
|
|
373
|
+
const str = NodeCore.readString(buffer, code, false /* dictionary */);
|
|
374
|
+
stringsToResolve.push(str);
|
|
375
|
+
children.push(str);
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
342
378
|
case MarkerCodes.BinaryEmpty:
|
|
343
379
|
case MarkerCodes.BinarySingle8:
|
|
344
380
|
case MarkerCodes.BinarySingle16:
|
|
345
381
|
case MarkerCodes.BinarySingle32:
|
|
346
382
|
case MarkerCodes.BinarySingle64:
|
|
347
383
|
{
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
break;
|
|
384
|
+
children.push(BlobShallowCopy.read(buffer, getValueSafely(exports.codeToBytesMap, code)));
|
|
385
|
+
continue;
|
|
351
386
|
}
|
|
352
387
|
// If integer is 0.
|
|
353
388
|
case MarkerCodes.Int0:
|
|
354
389
|
{
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
break;
|
|
390
|
+
children.push(0);
|
|
391
|
+
continue;
|
|
358
392
|
}
|
|
359
393
|
case MarkerCodes.UInt8:
|
|
360
394
|
case MarkerCodes.UInt16:
|
|
@@ -365,23 +399,66 @@ class NodeCore {
|
|
|
365
399
|
case MarkerCodes.Int32:
|
|
366
400
|
case MarkerCodes.Int64:
|
|
367
401
|
{
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
break;
|
|
402
|
+
children.push(buffer.read(getValueSafely(exports.codeToBytesMap, code)));
|
|
403
|
+
continue;
|
|
371
404
|
}
|
|
372
405
|
case MarkerCodes.BoolTrue:
|
|
373
|
-
|
|
374
|
-
|
|
406
|
+
children.push(true);
|
|
407
|
+
continue;
|
|
375
408
|
case MarkerCodes.BoolFalse:
|
|
376
|
-
|
|
377
|
-
|
|
409
|
+
children.push(false);
|
|
410
|
+
continue;
|
|
378
411
|
case MarkerCodesEnd.list:
|
|
379
412
|
case MarkerCodesEnd.set:
|
|
380
|
-
|
|
413
|
+
// Note: We are not checking that end marker matches start marker.
|
|
414
|
+
// I.e. that we do not have a case where we start a 'list' but end with a 'set'
|
|
415
|
+
// Checking it would require more state tracking that seems not very useful, given
|
|
416
|
+
// our code does not care.
|
|
417
|
+
children = stack.pop();
|
|
418
|
+
// To my surprise, checking children !== undefined adds measurable cost!
|
|
419
|
+
// We will rely on children.push() crashing in case of mismatch, and check below
|
|
420
|
+
// (outside of the loop)
|
|
421
|
+
continue;
|
|
381
422
|
default:
|
|
382
423
|
throw new Error(`Invalid code: ${code}`);
|
|
383
424
|
}
|
|
384
425
|
}
|
|
426
|
+
// This also ensures that stack.length === 0.
|
|
427
|
+
(0, common_utils_1.assert)(children === this.children, 0x3e7 /* Unpaired start/end list/set markers! */);
|
|
428
|
+
/**
|
|
429
|
+
* Process all the strings at once!
|
|
430
|
+
*/
|
|
431
|
+
let length = 0;
|
|
432
|
+
for (const el of stringsToResolve) {
|
|
433
|
+
length += el.endPos - el.startPos + 1;
|
|
434
|
+
}
|
|
435
|
+
const stringBuffer = new Uint8Array(length);
|
|
436
|
+
length = 0;
|
|
437
|
+
const input = buffer.buffer;
|
|
438
|
+
(0, common_utils_1.assert)(input.byteOffset === 0, 0x3e8 /* code below assumes no offset */);
|
|
439
|
+
for (const el of stringsToResolve) {
|
|
440
|
+
for (let it = el.startPos; it < el.endPos; it++) {
|
|
441
|
+
stringBuffer[length] = input[it];
|
|
442
|
+
length++;
|
|
443
|
+
}
|
|
444
|
+
stringBuffer[length] = 0;
|
|
445
|
+
length++;
|
|
446
|
+
}
|
|
447
|
+
if (length === stringBuffer.length) {
|
|
448
|
+
// All is good, we expect all the cases to get here
|
|
449
|
+
const result = (0, common_utils_1.Uint8ArrayToString)(stringBuffer, "utf-8").split(String.fromCharCode(0));
|
|
450
|
+
(0, common_utils_1.assert)(result.length === stringsToResolve.length + 1, 0x3e9 /* String content has \0 chars! */);
|
|
451
|
+
for (let i = 0; i < stringsToResolve.length; i++) {
|
|
452
|
+
stringsToResolve[i].content = result[i];
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
else {
|
|
456
|
+
// Recovery code
|
|
457
|
+
logger.sendErrorEvent({ eventName: "StringParsingError" });
|
|
458
|
+
for (const el of stringsToResolve) {
|
|
459
|
+
(0, common_utils_1.assert)(el.content === (0, common_utils_1.Uint8ArrayToString)(input.subarray(el.startPos, el.endPos), "utf-8"), 0x3ea /* test */);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
385
462
|
}
|
|
386
463
|
}
|
|
387
464
|
exports.NodeCore = NodeCore;
|
|
@@ -390,15 +467,29 @@ exports.NodeCore = NodeCore;
|
|
|
390
467
|
* Provides loading and serialization capabilities.
|
|
391
468
|
*/
|
|
392
469
|
class TreeBuilder extends NodeCore {
|
|
393
|
-
static load(buffer) {
|
|
470
|
+
static load(buffer, logger) {
|
|
394
471
|
const builder = new TreeBuilder();
|
|
395
|
-
|
|
396
|
-
builder.load(buffer, dictionary);
|
|
472
|
+
builder.load(buffer, logger);
|
|
397
473
|
(0, common_utils_1.assert)(buffer.eof, 0x233 /* "Unexpected data at the end of buffer" */);
|
|
398
474
|
return builder;
|
|
399
475
|
}
|
|
400
476
|
}
|
|
401
477
|
exports.TreeBuilder = TreeBuilder;
|
|
478
|
+
function getMaybeStringInstance(node) {
|
|
479
|
+
const maybeString = node;
|
|
480
|
+
if (maybeString._stringElement) {
|
|
481
|
+
return maybeString.content;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
exports.getMaybeStringInstance = getMaybeStringInstance;
|
|
485
|
+
function getStringInstance(node, message) {
|
|
486
|
+
const maybeString = node;
|
|
487
|
+
if (maybeString._stringElement) {
|
|
488
|
+
return maybeString.content;
|
|
489
|
+
}
|
|
490
|
+
throwBufferParseException(node, "BlobCore", message);
|
|
491
|
+
}
|
|
492
|
+
exports.getStringInstance = getStringInstance;
|
|
402
493
|
function assertBlobCoreInstance(node, message) {
|
|
403
494
|
if (node instanceof BlobCore) {
|
|
404
495
|
return;
|
|
@@ -447,6 +538,9 @@ function getNodeType(value) {
|
|
|
447
538
|
else if (typeof value === "boolean") {
|
|
448
539
|
return "Boolean";
|
|
449
540
|
}
|
|
541
|
+
else if (value._stringElement) {
|
|
542
|
+
return "String";
|
|
543
|
+
}
|
|
450
544
|
return "UnknownType";
|
|
451
545
|
}
|
|
452
546
|
//# sourceMappingURL=zipItDataRepresentationUtils.js.map
|