@fluidframework/odsp-driver 2.3.0-288113 → 2.4.0-294316
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/ReadBufferUtils.d.ts.map +1 -1
- package/dist/ReadBufferUtils.js +0 -1
- package/dist/ReadBufferUtils.js.map +1 -1
- package/dist/WriteBufferUtils.d.ts.map +1 -1
- package/dist/WriteBufferUtils.js +0 -2
- package/dist/WriteBufferUtils.js.map +1 -1
- package/dist/compactSnapshotParser.d.ts.map +1 -1
- package/dist/compactSnapshotParser.js +2 -18
- package/dist/compactSnapshotParser.js.map +1 -1
- package/dist/compactSnapshotWriter.d.ts.map +1 -1
- package/dist/compactSnapshotWriter.js +1 -3
- package/dist/compactSnapshotWriter.js.map +1 -1
- package/dist/createNewUtils.d.ts.map +1 -1
- package/dist/createNewUtils.js +0 -2
- package/dist/createNewUtils.js.map +1 -1
- package/dist/fetchSnapshot.d.ts.map +1 -1
- package/dist/fetchSnapshot.js +1 -2
- package/dist/fetchSnapshot.js.map +1 -1
- package/dist/getFileLink.d.ts +2 -2
- package/dist/getFileLink.d.ts.map +1 -1
- package/dist/getFileLink.js +54 -28
- package/dist/getFileLink.js.map +1 -1
- package/dist/localOdspDriver/localOdspDeltaStorageService.d.ts.map +1 -1
- package/dist/localOdspDriver/localOdspDeltaStorageService.js +0 -1
- package/dist/localOdspDriver/localOdspDeltaStorageService.js.map +1 -1
- package/dist/odspDelayLoadedDeltaStream.d.ts.map +1 -1
- package/dist/odspDelayLoadedDeltaStream.js +0 -2
- package/dist/odspDelayLoadedDeltaStream.js.map +1 -1
- package/dist/odspDeltaStorageService.d.ts.map +1 -1
- package/dist/odspDeltaStorageService.js +1 -4
- package/dist/odspDeltaStorageService.js.map +1 -1
- package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
- package/dist/odspDocumentDeltaConnection.js +1 -6
- package/dist/odspDocumentDeltaConnection.js.map +1 -1
- package/dist/odspDocumentStorageServiceBase.d.ts.map +1 -1
- package/dist/odspDocumentStorageServiceBase.js +0 -2
- package/dist/odspDocumentStorageServiceBase.js.map +1 -1
- package/dist/odspDriverUrlResolver.d.ts.map +1 -1
- package/dist/odspDriverUrlResolver.js +1 -2
- package/dist/odspDriverUrlResolver.js.map +1 -1
- package/dist/odspSnapshotParser.d.ts.map +1 -1
- package/dist/odspSnapshotParser.js +1 -5
- package/dist/odspSnapshotParser.js.map +1 -1
- package/dist/odspSummaryUploadManager.d.ts.map +1 -1
- package/dist/odspSummaryUploadManager.js +0 -1
- package/dist/odspSummaryUploadManager.js.map +1 -1
- package/dist/odspUrlHelper.d.ts.map +1 -1
- package/dist/odspUrlHelper.js +1 -5
- package/dist/odspUrlHelper.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/zipItDataRepresentationUtils.d.ts.map +1 -1
- package/dist/zipItDataRepresentationUtils.js +0 -9
- package/dist/zipItDataRepresentationUtils.js.map +1 -1
- package/lib/ReadBufferUtils.d.ts.map +1 -1
- package/lib/ReadBufferUtils.js +0 -1
- package/lib/ReadBufferUtils.js.map +1 -1
- package/lib/WriteBufferUtils.d.ts.map +1 -1
- package/lib/WriteBufferUtils.js +0 -2
- package/lib/WriteBufferUtils.js.map +1 -1
- package/lib/compactSnapshotParser.d.ts.map +1 -1
- package/lib/compactSnapshotParser.js +2 -18
- package/lib/compactSnapshotParser.js.map +1 -1
- package/lib/compactSnapshotWriter.d.ts.map +1 -1
- package/lib/compactSnapshotWriter.js +1 -3
- package/lib/compactSnapshotWriter.js.map +1 -1
- package/lib/createNewUtils.d.ts.map +1 -1
- package/lib/createNewUtils.js +0 -2
- package/lib/createNewUtils.js.map +1 -1
- package/lib/fetchSnapshot.d.ts.map +1 -1
- package/lib/fetchSnapshot.js +1 -2
- package/lib/fetchSnapshot.js.map +1 -1
- package/lib/getFileLink.d.ts +2 -2
- package/lib/getFileLink.d.ts.map +1 -1
- package/lib/getFileLink.js +48 -22
- package/lib/getFileLink.js.map +1 -1
- package/lib/localOdspDriver/localOdspDeltaStorageService.d.ts.map +1 -1
- package/lib/localOdspDriver/localOdspDeltaStorageService.js +0 -1
- package/lib/localOdspDriver/localOdspDeltaStorageService.js.map +1 -1
- package/lib/odspDelayLoadedDeltaStream.d.ts.map +1 -1
- package/lib/odspDelayLoadedDeltaStream.js +0 -2
- package/lib/odspDelayLoadedDeltaStream.js.map +1 -1
- package/lib/odspDeltaStorageService.d.ts.map +1 -1
- package/lib/odspDeltaStorageService.js +1 -4
- package/lib/odspDeltaStorageService.js.map +1 -1
- package/lib/odspDocumentDeltaConnection.d.ts.map +1 -1
- package/lib/odspDocumentDeltaConnection.js +1 -6
- package/lib/odspDocumentDeltaConnection.js.map +1 -1
- package/lib/odspDocumentStorageServiceBase.d.ts.map +1 -1
- package/lib/odspDocumentStorageServiceBase.js +0 -2
- package/lib/odspDocumentStorageServiceBase.js.map +1 -1
- package/lib/odspDriverUrlResolver.d.ts.map +1 -1
- package/lib/odspDriverUrlResolver.js +1 -2
- package/lib/odspDriverUrlResolver.js.map +1 -1
- package/lib/odspSnapshotParser.d.ts.map +1 -1
- package/lib/odspSnapshotParser.js +1 -5
- package/lib/odspSnapshotParser.js.map +1 -1
- package/lib/odspSummaryUploadManager.d.ts.map +1 -1
- package/lib/odspSummaryUploadManager.js +0 -1
- package/lib/odspSummaryUploadManager.js.map +1 -1
- package/lib/odspUrlHelper.d.ts.map +1 -1
- package/lib/odspUrlHelper.js +1 -5
- package/lib/odspUrlHelper.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/zipItDataRepresentationUtils.d.ts.map +1 -1
- package/lib/zipItDataRepresentationUtils.js +0 -9
- package/lib/zipItDataRepresentationUtils.js.map +1 -1
- package/package.json +18 -17
- package/src/ReadBufferUtils.ts +1 -2
- package/src/WriteBufferUtils.ts +2 -4
- package/src/compactSnapshotParser.ts +14 -28
- package/src/compactSnapshotWriter.ts +2 -4
- package/src/createNewUtils.ts +2 -4
- package/src/fetchSnapshot.ts +1 -2
- package/src/getFileLink.ts +54 -22
- package/src/localOdspDriver/localOdspDeltaStorageService.ts +1 -2
- package/src/odspDelayLoadedDeltaStream.ts +2 -4
- package/src/odspDeltaStorageService.ts +2 -4
- package/src/odspDocumentDeltaConnection.ts +3 -8
- package/src/odspDocumentStorageServiceBase.ts +2 -4
- package/src/odspDriverUrlResolver.ts +1 -2
- package/src/odspSnapshotParser.ts +4 -8
- package/src/odspSummaryUploadManager.ts +1 -2
- package/src/odspUrlHelper.ts +4 -8
- package/src/packageVersion.ts +1 -1
- package/src/zipItDataRepresentationUtils.ts +9 -18
- package/tsconfig.json +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zipItDataRepresentationUtils.js","sourceRoot":"","sources":["../src/zipItDataRepresentationUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;GAGG;AAEH,+DAA2F;AAC3F,kEAA6D;AAC7D,oEAA0E;AAC1E,+EAAkF;AAIlF,iDAAyC;AACzC,2DAAkE;AAElE,wJAAwJ;AACxJ;;;GAGG;AACH,IAAY,WA8BX;AA9BD,WAAY,WAAW;IACtB,sDAAa,CAAA;IACb,wDAAc,CAAA;IAEd,4DAAgB,CAAA;IAChB,gEAAkB,CAAA;IAClB,kEAAmB,CAAA;IACnB,kEAAmB,CAAA;IAEnB,kEAAmB,CAAA;IACnB,oEAAoB,CAAA;IACpB,oEAAoB,CAAA;IACpB,0EAAuB,CAAA;IACvB,gFAA0B,CAAA;IAE1B,6CAAQ,CAAA;IACR,+CAAS,CAAA;IACT,iDAAU,CAAA;IACV,iDAAU,CAAA;IACV,iDAAU,CAAA;IACV,6CAAQ,CAAA;IACR,+CAAS,CAAA;IACT,+CAAS,CAAA;IACT,+CAA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e;IAClE,IAAI,OAAO,IAAI,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO;IACR,CAAC;IACD,yBAAyB,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AACrD,CAAC;AALD,gDAKC;AAED,SAAS,yBAAyB,CACjC,IAAe,EACf,gBAA0B,EAC1B,OAAe;IAEf,MAAM,IAAI,4BAAiB,CAC1B,6BAA6B,OAAO,EAAE,EACtC,yBAAc,CAAC,uBAAuB,EACtC;QACC,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC;QAC3B,gBAAgB;QAChB,aAAa,EAAb,8BAAa;KACb,CACD,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,KAAgB;IACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,QAAQ,CAAC;IACjB,CAAC;SAAM,IAAI,KAAK,YAAY,QAAQ,EAAE,CAAC;QACtC,OAAO,UAAU,CAAC;IACnB,CAAC;SAAM,IAAI,KAAK,YAAY,QAAQ,EAAE,CAAC;QACtC,OAAO,UAAU,CAAC;IACnB,CAAC;SAAM,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QACvC,OAAO,SAAS,CAAC;IAClB,CAAC;SAAM,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;QACjC,OAAO,QAAQ,CAAC;IACjB,CAAC;IACD,OAAO,aAAa,CAAC;AACtB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Data representation which is followed(zipIt Protocol) here is described in this document:\n * https://microsoft.sharepoint-df.com/:w:/t/ODSPFileStore/ER06b64K_XdDjEyAKl-UT60BJiId39SCVkYSyo_2pvH9gQ?e=KYQ0c5\n */\n\nimport { Uint8ArrayToArrayBuffer, Uint8ArrayToString } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { NonRetryableError } from \"@fluidframework/driver-utils/internal\";\nimport { OdspErrorTypes } from \"@fluidframework/odsp-driver-definitions/internal\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { ReadBuffer } from \"./ReadBufferUtils.js\";\nimport { measure } from \"./odspUtils.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\n\n// https://onedrive.visualstudio.com/SharePoint%20Online/_git/SPO?path=/cobalt/Base/Property/BinaryEncodedPropertyReader.cs&version=GBmaster&_a=contents\n/**\n * Control codes used by tree serialization / decentralization code. Same as on server. These can be found on\n * filestore code on server too at above link.\n */\nexport enum MarkerCodes {\n\tBoolTrue = 11, // value = true\n\tBoolFalse = 12, // value = false\n\n\tStringEmpty = 13, // value = \"\"\n\tString8Length = 14, // unsigned-8-bit little-endian length, follows by UTF-8 bytes of length\n\tString16Length = 15, // unsigned-16-bit little-endian length, follows by UTF-8 bytes of length\n\tString32Length = 16, // unsigned-32-bit little-endian length, follows by UTF-8 bytes of length\n\n\tConstString8Id = 17, // unsigned-8-bit little-endian const string id follows\n\tConstString16Id = 18, // unsigned-16-bit little-endian const string id follows\n\tConstString32Id = 19, // unsigned-32-bit little-endian const string id follows\n\tConstStringDeclare = 20, // Code for declaring a const string with size <= 1 byte\n\tConstStringDeclareBig = 21, // Code for declaring a const string with size > 1 byte. It is represented in 4 bytes.\n\n\tInt0 = 1, // value = 0\n\tUInt8 = 3, // unsigned-8-bit little-endian follows\n\tUInt16 = 5, // unsigned-16-bit little-endian follows\n\tUInt32 = 7, // unsigned-32-bit little-endian follows\n\tUInt64 = 9, // unsigned-64-bit little-endian follows\n\tInt8 = 2, // signed-8-bit little-endian follows\n\tInt16 = 4, // signed-16-bit little-endian follows\n\tInt32 = 6, // signed-32-bit little-endian follows\n\tInt64 = 8, // signed-64-bit little-endian follows\n\n\tBinaryEmpty = 32, // value = byte[]\n\tBinarySingle8 = 33, // unsigned-8-bit little-endian length, follows by bytes of length\n\tBinarySingle16 = 34, // unsigned-16-bit little-endian length, follows by bytes of length\n\tBinarySingle32 = 35, // unsigned-32-bit little-endian length, follows by bytes of length\n\tBinarySingle64 = 36, // unsigned-64-bit little-endian length, follows by bytes of length\n}\n\n/**\n * Control codes used by tree serialization / decentralization code. They mark the start of sections.\n */\nexport enum MarkerCodesStart {\n\t\"list\" = 49,\n\t\"set\" = 51,\n}\n\n/**\n * Control codes used by tree serialization / decentralization code. They mark the end of sections.\n */\nexport enum MarkerCodesEnd {\n\t\"list\" = 50,\n\t\"set\" = 52,\n}\n\n/**\n * This contains mapping of Marker Codes to number of bytes in which the corresponding data\n * will be stored.\n */\nexport const codeToBytesMap = {\n\t// Integer code to bytes\n\t1: 0,\n\t2: 1,\n\t3: 1,\n\t4: 2,\n\t5: 2,\n\t6: 4,\n\t7: 4,\n\t8: 8,\n\t9: 8,\n\n\t// String code to Bytes\n\t13: 0,\n\t14: 1,\n\t15: 2,\n\t16: 4,\n\n\t17: 1,\n\t18: 2,\n\t19: 4,\n\n\t20: 1,\n\t21: 4,\n\n\t// Binary code to bytes\n\t32: 0,\n\t33: 1,\n\t34: 2,\n\t35: 4,\n\t36: 8,\n};\n\nexport function getValueSafely(map: { [index: number]: number }, key: number): number {\n\tconst val = map[key];\n\tassert(val !== undefined, 0x287 /* key must exist in the map */);\n\treturn val;\n}\n\nexport function getNodeProps(node: NodeCore): Record<string, NodeTypes> {\n\tconst res: Record<string, NodeTypes> = {};\n\tfor (const [keyNode, valueNode] of node.iteratePairs()) {\n\t\tconst id = getStringInstance(keyNode, \"keynode should be a string\");\n\t\tres[id] = valueNode;\n\t}\n\treturn res;\n}\n\nexport function iteratePairs<T>(it: IterableIterator<T>): IterableIterator<[T, T]> {\n\tconst res: IterableIterator<[T, T]> = {\n\t\tnext: () => {\n\t\t\tconst a = it.next();\n\t\t\tif (a.done) {\n\t\t\t\treturn { value: undefined, done: true };\n\t\t\t}\n\t\t\tconst b = it.next();\n\t\t\tassert(b.done !== true, 0x22b /* \"Should be a pair\" */);\n\t\t\treturn { value: [a.value, b.value], done: b.done };\n\t\t},\n\t\t[Symbol.iterator]: () => {\n\t\t\treturn res;\n\t\t},\n\t};\n\treturn res;\n}\n\n/**\n * Helper function that returns iterator from an object\n * @param obj - object that supports iteration\n */\nexport function iterate<T>(obj: {\n\t[Symbol.iterator]: () => IterableIterator<T>;\n}): IterableIterator<T> {\n\treturn obj[Symbol.iterator]();\n}\n\n/**\n * Base class to represent binary blob element.\n * Binary blob is one of three types supported as a leaf node of a tree.\n * Note: concrete implementations (derived classes) are not exposed from this module\n */\nexport abstract class BlobCore {\n\tpublic abstract get buffer(): Uint8Array;\n\tpublic abstract get arrayBuffer(): ArrayBufferLike;\n\n\t/**\n\t * Represents a blob.\n\t */\n\tconstructor() {}\n}\n\n/**\n * \"deep copy\" blob, holds to binary data passed in\n * It is called deep copy as a counter-part to BlobShallowCopy, which\n * is a reference to underlying binary stream (ReadBuffer).\n */\nclass BlobDeepCopy extends BlobCore {\n\t/**\n\t * Represents a deep copy of the blob.\n\t * @param data - Data array of the blob\n\t */\n\tconstructor(protected readonly data: Uint8Array) {\n\t\tsuper();\n\t}\n\n\tpublic get buffer(): Uint8Array {\n\t\treturn this.data;\n\t}\n\n\tpublic get arrayBuffer(): ArrayBufferLike {\n\t\treturn Uint8ArrayToArrayBuffer(this.buffer);\n\t}\n\n\tpublic static read(buffer: ReadBuffer, lengthLen: number): BlobCore {\n\t\tconst length = buffer.read(lengthLen);\n\t\tconst data = new Uint8Array(length);\n\t\tfor (let counter = 0; counter < length; counter++) {\n\t\t\tdata[counter] = buffer.read();\n\t\t}\n\t\treturn new BlobDeepCopy(data);\n\t}\n}\n\n/**\n * Shallow copy blob, keeps a reference to portion of ReadBuffer\n * it was constructed from. It takes much less memory compared to BlobDeepCopy\n */\nexport class BlobShallowCopy extends BlobCore {\n\t/**\n\t * Represents a shallow copy of the blob. It is not a separate blob, just reference to original blobs.\n\t * @param data - Data array of the blob\n\t * @param start - Start point of the blob in the buffer.\n\t * @param end - End point of the blob in the buffer.\n\t */\n\tconstructor(\n\t\tprotected data: Uint8Array,\n\t\tprotected start: number,\n\t\tprotected end: number,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic get buffer(): Uint8Array {\n\t\treturn this.data.subarray(this.start, this.end);\n\t}\n\n\t// Equivalent to Uint8ArrayToArrayBuffer(this.buffer)\n\tpublic get arrayBuffer(): ArrayBufferLike {\n\t\tconst offset = this.data.byteOffset;\n\t\treturn this.data.buffer.slice(this.start + offset, this.end + offset);\n\t}\n\n\tpublic static read(buffer: ReadBuffer, lengthLen: number): BlobCore {\n\t\tconst length = buffer.read(lengthLen);\n\t\tconst pos = buffer.pos;\n\t\tbuffer.skip(length);\n\t\treturn new BlobShallowCopy(buffer.buffer, pos, pos + length);\n\t}\n}\n\nexport const addStringProperty = (node: NodeCore, a: string, b: string): void => {\n\tnode.addDictionaryString(a);\n\tnode.addString(b);\n};\nexport const addDictionaryStringProperty = (node: NodeCore, a: string, b: string): void => {\n\tnode.addDictionaryString(a);\n\tnode.addString(b);\n};\nexport const addNumberProperty = (node: NodeCore, a: string, b: number): void => {\n\tnode.addDictionaryString(a);\n\tnode.addNumber(b);\n};\nexport const addBoolProperty = (node: NodeCore, a: string, b: boolean): void => {\n\tnode.addDictionaryString(a);\n\tnode.addBool(b);\n};\n\nexport interface IStringElement {\n\tcontent: string;\n\tdictionary: boolean;\n\t_stringElement: true;\n}\n\nexport interface IStringElementInternal extends Omit<IStringElement, \"content\"> {\n\tcontent?: string;\n\tstartPos: number;\n\tendPos: number;\n}\n\n/**\n * Three leaf types supported by tree:\n * 1. Node (sub-tree)\n * 2. binary blob\n * 3. integer\n * 4. boolean\n */\nexport type NodeTypes = NodeCore | BlobCore | number | boolean | IStringElement;\n\nexport type NodeCoreTypes = \"list\" | \"set\";\n\n/**\n * Node - node in the tree (non-leaf element of the tree)\n */\nexport class NodeCore {\n\t// It is an array of nodes.\n\tprivate readonly children: NodeTypes[] = [];\n\tpublic get nodes(): NodeTypes[] {\n\t\treturn this.children;\n\t}\n\n\tconstructor(public type: NodeCoreTypes = \"set\") {}\n\n\tpublic [Symbol.iterator](): IterableIterator<NodeTypes> {\n\t\treturn this.children[Symbol.iterator]();\n\t}\n\n\tpublic iteratePairs(): IterableIterator<[NodeTypes, NodeTypes]> {\n\t\tassert(this.length % 2 === 0, 0x22c /* \"reading pairs\" */);\n\t\treturn iteratePairs(iterate(this));\n\t}\n\n\tpublic get length(): number {\n\t\treturn this.children.length;\n\t}\n\n\tpublic get(index: number): NodeTypes {\n\t\t// TODO Why are we non null asserting here?\n\t\treturn this.children[index]!;\n\t}\n\n\tpublic getString(index: number): string {\n\t\t// TODO Why are we non null asserting here?\n\t\tconst node = this.children[index]!;\n\t\treturn getStringInstance(node, \"getString should return string\");\n\t}\n\n\tpublic getMaybeString(index: number): string | undefined {\n\t\t// TODO Why are we non null asserting here?\n\t\tconst node = this.children[index]!;\n\t\treturn getMaybeStringInstance(node);\n\t}\n\n\tpublic getBlob(index: number): BlobCore {\n\t\t// TODO Why are we non null asserting here?\n\t\tconst node = this.children[index]!;\n\t\tassertBlobCoreInstance(node, \"getBlob should return a blob\");\n\t\treturn node;\n\t}\n\n\tpublic getNode(index: number): NodeCore {\n\t\t// TODO Why are we non null asserting here?\n\t\tconst node = this.children[index]!;\n\t\tassertNodeCoreInstance(node, \"getNode should return a node\");\n\t\treturn node;\n\t}\n\n\tpublic getNumber(index: number): number {\n\t\t// TODO Why are we non null asserting here?\n\t\tconst node = this.children[index]!;\n\t\tassertNumberInstance(node, \"getNumber should return a number\");\n\t\treturn node;\n\t}\n\n\tpublic getBool(index: number): boolean {\n\t\t// TODO Why are we non null asserting here?\n\t\tconst node = this.children[index]!;\n\t\tassertBoolInstance(node, \"getBool should return a boolean\");\n\t\treturn node;\n\t}\n\n\tpublic addNode(type?: NodeCoreTypes): NodeCore {\n\t\tconst node = new NodeCore(type);\n\t\tthis.children.push(node);\n\t\treturn node;\n\t}\n\n\tpublic addBlob(blob: Uint8Array): void {\n\t\tthis.children.push(new BlobDeepCopy(blob));\n\t}\n\n\tpublic addDictionaryString(payload: string): void {\n\t\tthis.children.push({\n\t\t\tcontent: payload,\n\t\t\tdictionary: true,\n\t\t\t_stringElement: true,\n\t\t});\n\t}\n\n\tpublic addString(payload: string): void {\n\t\tthis.children.push({\n\t\t\tcontent: payload,\n\t\t\tdictionary: false,\n\t\t\t_stringElement: true,\n\t\t});\n\t}\n\n\tpublic addNumber(payload: number | undefined): void {\n\t\tassert(Number.isInteger(payload), 0x231 /* \"Number should be an integer\" */);\n\t\tassert(\n\t\t\tpayload !== undefined && payload >= 0,\n\t\t\t0x232 /* \"Payload should not be negative\" */,\n\t\t);\n\t\tthis.children.push(payload);\n\t}\n\n\tpublic addBool(payload: boolean): void {\n\t\tthis.children.push(payload);\n\t}\n\n\t// Can we do more efficiently here, without extra objects somehow??\n\tprivate static readString(\n\t\tbuffer: ReadBuffer,\n\t\tcode: number,\n\t\tdictionary: boolean,\n\t): IStringElementInternal & IStringElement {\n\t\tconst lengthLen = getValueSafely(codeToBytesMap, code);\n\t\tconst length = buffer.read(lengthLen);\n\t\tconst startPos = buffer.pos;\n\t\tbuffer.skip(length);\n\t\tconst result: IStringElementInternal = {\n\t\t\t// Note: Setting here property 'content: undefined' makes code substantially slower!\n\t\t\tdictionary,\n\t\t\t_stringElement: true,\n\t\t\tstartPos,\n\t\t\tendPos: buffer.pos,\n\t\t};\n\n\t\t// We are lying here in terms of presence of `content` property.\n\t\t// This will be addressed at the bottom of NodeCore.load() by resolving all strings at once!\n\t\t// It's equivalent (but much slower!) to do it here via\n\t\t// result.content = Uint8ArrayToString(buffer.buffer.subarray(startPos, buffer.pos), \"utf-8\");\n\t\treturn result as IStringElementInternal & IStringElement;\n\t}\n\n\t/**\n\t * Load and parse the buffer into a tree.\n\t * @param buffer - buffer to read from.\n\t */\n\tprotected load(\n\t\tbuffer: ReadBuffer,\n\t\tlogger: ITelemetryLoggerExt,\n\t): {\n\t\tdurationStructure: number;\n\t\tdurationStrings: number;\n\t} {\n\t\tconst [stringsToResolve, durationStructure] = measure(() =>\n\t\t\tthis.loadStructure(buffer, logger),\n\t\t);\n\t\tconst [, durationStrings] = measure(() =>\n\t\t\tthis.loadStrings(buffer, stringsToResolve, logger),\n\t\t);\n\t\treturn { durationStructure, durationStrings };\n\t}\n\n\t/**\n\t * Load and parse the buffer into a tree.\n\t * @param buffer - buffer to read from.\n\t */\n\tprotected loadStructure(\n\t\tbuffer: ReadBuffer,\n\t\tlogger: ITelemetryLoggerExt,\n\t): IStringElementInternal[] {\n\t\tconst stack: NodeTypes[][] = [];\n\t\tconst stringsToResolve: IStringElementInternal[] = [];\n\t\tconst dictionary: IStringElement[] = [];\n\n\t\tlet children = this.children;\n\t\tfor (; !buffer.eof; ) {\n\t\t\tconst code = buffer.read();\n\t\t\tswitch (code) {\n\t\t\t\tcase MarkerCodesStart.list:\n\t\t\t\tcase MarkerCodesStart.set: {\n\t\t\t\t\tconst childValue = new NodeCore(code === MarkerCodesStart.set ? \"set\" : \"list\");\n\t\t\t\t\tchildren.push(childValue);\n\t\t\t\t\tstack.push(children);\n\t\t\t\t\tchildren = childValue.children;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase MarkerCodes.ConstStringDeclare:\n\t\t\t\tcase MarkerCodes.ConstStringDeclareBig: {\n\t\t\t\t\tconst stringId = buffer.read(getValueSafely(codeToBytesMap, code));\n\t\t\t\t\tconst constString = NodeCore.readString(buffer, code, true /* dictionary */);\n\t\t\t\t\tstringsToResolve.push(constString);\n\t\t\t\t\tdictionary[stringId] = constString;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase MarkerCodes.ConstString8Id:\n\t\t\t\tcase MarkerCodes.ConstString16Id:\n\t\t\t\tcase MarkerCodes.ConstString32Id: {\n\t\t\t\t\tconst stringId = buffer.read(getValueSafely(codeToBytesMap, code));\n\t\t\t\t\tconst content = dictionary[stringId];\n\t\t\t\t\tassert(content !== undefined, 0x3de /* const string not found */);\n\t\t\t\t\tchildren.push(content);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase MarkerCodes.StringEmpty:\n\t\t\t\tcase MarkerCodes.String8Length:\n\t\t\t\tcase MarkerCodes.String16Length:\n\t\t\t\tcase MarkerCodes.String32Length: {\n\t\t\t\t\tconst str = NodeCore.readString(buffer, code, false /* dictionary */);\n\t\t\t\t\tstringsToResolve.push(str);\n\t\t\t\t\tchildren.push(str);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase MarkerCodes.BinaryEmpty:\n\t\t\t\tcase MarkerCodes.BinarySingle8:\n\t\t\t\tcase MarkerCodes.BinarySingle16:\n\t\t\t\tcase MarkerCodes.BinarySingle32:\n\t\t\t\tcase MarkerCodes.BinarySingle64: {\n\t\t\t\t\tchildren.push(BlobShallowCopy.read(buffer, getValueSafely(codeToBytesMap, code)));\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// If integer is 0.\n\t\t\t\tcase MarkerCodes.Int0: {\n\t\t\t\t\tchildren.push(0);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase MarkerCodes.UInt8:\n\t\t\t\tcase MarkerCodes.UInt16:\n\t\t\t\tcase MarkerCodes.UInt32:\n\t\t\t\tcase MarkerCodes.UInt64:\n\t\t\t\tcase MarkerCodes.Int8:\n\t\t\t\tcase MarkerCodes.Int16:\n\t\t\t\tcase MarkerCodes.Int32:\n\t\t\t\tcase MarkerCodes.Int64: {\n\t\t\t\t\tchildren.push(buffer.read(getValueSafely(codeToBytesMap, code)));\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase MarkerCodes.BoolTrue: {\n\t\t\t\t\tchildren.push(true);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase MarkerCodes.BoolFalse: {\n\t\t\t\t\tchildren.push(false);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase MarkerCodesEnd.list:\n\t\t\t\tcase MarkerCodesEnd.set: {\n\t\t\t\t\t// Note: We are not checking that end marker matches start marker.\n\t\t\t\t\t// I.e. that we do not have a case where we start a 'list' but end with a 'set'\n\t\t\t\t\t// Checking it would require more state tracking that seems not very useful, given\n\t\t\t\t\t// our code does not care.\n\t\t\t\t\tchildren = stack.pop()!;\n\n\t\t\t\t\t// To my surprise, checking children !== undefined adds measurable cost!\n\t\t\t\t\t// We will rely on children.push() crashing in case of mismatch, and check below\n\t\t\t\t\t// (outside of the loop)\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tthrow new Error(`Invalid code: ${code}`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// This also ensures that stack.length === 0.\n\t\tassert(children === this.children, 0x3e7 /* Unpaired start/end list/set markers! */);\n\n\t\treturn stringsToResolve;\n\t}\n\n\tprivate loadStrings(\n\t\tbuffer: ReadBuffer,\n\t\tstringsToResolve: IStringElementInternal[],\n\t\tlogger: ITelemetryLoggerExt,\n\t): void {\n\t\t/**\n\t\t * Process all the strings at once!\n\t\t */\n\t\tlet length = 0;\n\t\tfor (const el of stringsToResolve) {\n\t\t\tlength += el.endPos - el.startPos + 1;\n\t\t}\n\t\tconst stringBuffer = new Uint8Array(length);\n\n\t\tlength = 0;\n\t\tconst input = buffer.buffer;\n\t\tassert(input.byteOffset === 0, 0x3e8 /* code below assumes no offset */);\n\n\t\tfor (const el of stringsToResolve) {\n\t\t\tfor (let it = el.startPos; it < el.endPos; it++) {\n\t\t\t\t// Non null asserting here because we are iterating over startPos\n\t\t\t\tstringBuffer[length] = input[it]!;\n\t\t\t\tlength++;\n\t\t\t}\n\t\t\tstringBuffer[length] = 0;\n\t\t\tlength++;\n\t\t}\n\t\tassert(length === stringBuffer.length, 0x418 /* properly encoded */);\n\n\t\tconst result = Uint8ArrayToString(stringBuffer, \"utf8\").split(String.fromCodePoint(0));\n\t\tif (result.length === stringsToResolve.length + 1) {\n\t\t\t// All is good, we expect all the cases to get here\n\t\t\tfor (let i = 0; i < stringsToResolve.length; i++) {\n\t\t\t\t// Non null asserting here because we are iterating over stringsToResolve\n\t\t\t\tstringsToResolve[i]!.content = result[i];\n\t\t\t}\n\t\t} else {\n\t\t\t// String content has \\0 chars!\n\t\t\t// Recovery code\n\t\t\tlogger.sendErrorEvent({ eventName: \"StringParsingError\" });\n\t\t\tfor (const el of stringsToResolve) {\n\t\t\t\tassert(\n\t\t\t\t\tel.content === Uint8ArrayToString(input.subarray(el.startPos, el.endPos), \"utf8\"),\n\t\t\t\t\t0x3ea /* test */,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * TreeBuilder - Root of the tree.\n * Provides loading and serialization capabilities.\n */\nexport class TreeBuilder extends NodeCore {\n\tstatic load(\n\t\tbuffer: ReadBuffer,\n\t\tlogger: ITelemetryLoggerExt,\n\t): {\n\t\tbuilder: TreeBuilder;\n\t\ttelemetryProps: {\n\t\t\tdurationStructure: number;\n\t\t\tdurationStrings: number;\n\t\t};\n\t} {\n\t\tconst builder = new TreeBuilder();\n\t\tconst telemetryProps = builder.load(buffer, logger);\n\t\tassert(buffer.eof, 0x233 /* \"Unexpected data at the end of buffer\" */);\n\t\treturn { builder, telemetryProps };\n\t}\n}\n\nexport function getMaybeStringInstance(node: NodeTypes): string | undefined {\n\tconst maybeString = node as IStringElement;\n\tif (maybeString._stringElement) {\n\t\treturn maybeString.content;\n\t}\n}\n\nexport function getStringInstance(node: NodeTypes, message: string): string {\n\tconst maybeString = node as IStringElement;\n\tif (maybeString._stringElement) {\n\t\treturn maybeString.content;\n\t}\n\tthrowBufferParseException(node, \"BlobCore\", message);\n}\n\nexport function assertBlobCoreInstance(\n\tnode: NodeTypes,\n\tmessage: string,\n): asserts node is BlobCore {\n\tif (node instanceof BlobCore) {\n\t\treturn;\n\t}\n\tthrowBufferParseException(node, \"BlobCore\", message);\n}\n\nexport function assertNodeCoreInstance(\n\tnode: NodeTypes,\n\tmessage: string,\n): asserts node is NodeCore {\n\tif (node instanceof NodeCore) {\n\t\treturn;\n\t}\n\tthrowBufferParseException(node, \"NodeCore\", message);\n}\n\nexport function assertNumberInstance(\n\tnode: NodeTypes,\n\tmessage: string,\n): asserts node is number {\n\tif (typeof node === \"number\") {\n\t\treturn;\n\t}\n\tthrowBufferParseException(node, \"Number\", message);\n}\n\nexport function assertBoolInstance(node: NodeTypes, message: string): asserts node is boolean {\n\tif (typeof node === \"boolean\") {\n\t\treturn;\n\t}\n\tthrowBufferParseException(node, \"Boolean\", message);\n}\n\nfunction throwBufferParseException(\n\tnode: NodeTypes,\n\texpectedNodeType: NodeType,\n\tmessage: string,\n): never {\n\tthrow new NonRetryableError(\n\t\t`Buffer parsing exception: ${message}`,\n\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t{\n\t\t\tnodeType: getNodeType(node),\n\t\t\texpectedNodeType,\n\t\t\tdriverVersion,\n\t\t},\n\t);\n}\n\nfunction getNodeType(value: NodeTypes): NodeType {\n\tif (typeof value === \"number\") {\n\t\treturn \"Number\";\n\t} else if (value instanceof BlobCore) {\n\t\treturn \"BlobCore\";\n\t} else if (value instanceof NodeCore) {\n\t\treturn \"NodeCore\";\n\t} else if (typeof value === \"boolean\") {\n\t\treturn \"Boolean\";\n\t} else if (value._stringElement) {\n\t\treturn \"String\";\n\t}\n\treturn \"UnknownType\";\n}\n\ntype NodeType = \"Number\" | \"BlobCore\" | \"NodeCore\" | \"Boolean\" | \"UnknownType\" | \"String\";\n"]}
|
|
1
|
+
{"version":3,"file":"zipItDataRepresentationUtils.js","sourceRoot":"","sources":["../src/zipItDataRepresentationUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;GAGG;AAEH,+DAA2F;AAC3F,kEAA6D;AAC7D,oEAA0E;AAC1E,+EAAkF;AAIlF,iDAAyC;AACzC,2DAAkE;AAElE,wJAAwJ;AACxJ;;;GAGG;AACH,IAAY,WA8BX;AA9BD,WAAY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AAED,SAAgB,oBAAoB,CACnC,IAAe,EACf,OAAe;IAEf,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO;IACR,CAAC;IACD,yBAAyB,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AACpD,CAAC;AARD,oDAQC;AAED,SAAgB,kBAAkB,CAAC,IAAe,EAAE,OAAe;IAClE,IAAI,OAAO,IAAI,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO;IACR,CAAC;IACD,yBAAyB,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AACrD,CAAC;AALD,gDAKC;AAED,SAAS,yBAAyB,CACjC,IAAe,EACf,gBAA0B,EAC1B,OAAe;IAEf,MAAM,IAAI,4BAAiB,CAC1B,6BAA6B,OAAO,EAAE,EACtC,yBAAc,CAAC,uBAAuB,EACtC;QACC,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC;QAC3B,gBAAgB;QAChB,aAAa,EAAb,8BAAa;KACb,CACD,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,KAAgB;IACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,QAAQ,CAAC;IACjB,CAAC;SAAM,IAAI,KAAK,YAAY,QAAQ,EAAE,CAAC;QACtC,OAAO,UAAU,CAAC;IACnB,CAAC;SAAM,IAAI,KAAK,YAAY,QAAQ,EAAE,CAAC;QACtC,OAAO,UAAU,CAAC;IACnB,CAAC;SAAM,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QACvC,OAAO,SAAS,CAAC;IAClB,CAAC;SAAM,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;QACjC,OAAO,QAAQ,CAAC;IACjB,CAAC;IACD,OAAO,aAAa,CAAC;AACtB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Data representation which is followed(zipIt Protocol) here is described in this document:\n * https://microsoft.sharepoint-df.com/:w:/t/ODSPFileStore/ER06b64K_XdDjEyAKl-UT60BJiId39SCVkYSyo_2pvH9gQ?e=KYQ0c5\n */\n\nimport { Uint8ArrayToArrayBuffer, Uint8ArrayToString } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { NonRetryableError } from \"@fluidframework/driver-utils/internal\";\nimport { OdspErrorTypes } from \"@fluidframework/odsp-driver-definitions/internal\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { ReadBuffer } from \"./ReadBufferUtils.js\";\nimport { measure } from \"./odspUtils.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\n\n// https://onedrive.visualstudio.com/SharePoint%20Online/_git/SPO?path=/cobalt/Base/Property/BinaryEncodedPropertyReader.cs&version=GBmaster&_a=contents\n/**\n * Control codes used by tree serialization / decentralization code. Same as on server. These can be found on\n * filestore code on server too at above link.\n */\nexport enum MarkerCodes {\n\tBoolTrue = 11, // value = true\n\tBoolFalse = 12, // value = false\n\n\tStringEmpty = 13, // value = \"\"\n\tString8Length = 14, // unsigned-8-bit little-endian length, follows by UTF-8 bytes of length\n\tString16Length = 15, // unsigned-16-bit little-endian length, follows by UTF-8 bytes of length\n\tString32Length = 16, // unsigned-32-bit little-endian length, follows by UTF-8 bytes of length\n\n\tConstString8Id = 17, // unsigned-8-bit little-endian const string id follows\n\tConstString16Id = 18, // unsigned-16-bit little-endian const string id follows\n\tConstString32Id = 19, // unsigned-32-bit little-endian const string id follows\n\tConstStringDeclare = 20, // Code for declaring a const string with size <= 1 byte\n\tConstStringDeclareBig = 21, // Code for declaring a const string with size > 1 byte. It is represented in 4 bytes.\n\n\tInt0 = 1, // value = 0\n\tUInt8 = 3, // unsigned-8-bit little-endian follows\n\tUInt16 = 5, // unsigned-16-bit little-endian follows\n\tUInt32 = 7, // unsigned-32-bit little-endian follows\n\tUInt64 = 9, // unsigned-64-bit little-endian follows\n\tInt8 = 2, // signed-8-bit little-endian follows\n\tInt16 = 4, // signed-16-bit little-endian follows\n\tInt32 = 6, // signed-32-bit little-endian follows\n\tInt64 = 8, // signed-64-bit little-endian follows\n\n\tBinaryEmpty = 32, // value = byte[]\n\tBinarySingle8 = 33, // unsigned-8-bit little-endian length, follows by bytes of length\n\tBinarySingle16 = 34, // unsigned-16-bit little-endian length, follows by bytes of length\n\tBinarySingle32 = 35, // unsigned-32-bit little-endian length, follows by bytes of length\n\tBinarySingle64 = 36, // unsigned-64-bit little-endian length, follows by bytes of length\n}\n\n/**\n * Control codes used by tree serialization / decentralization code. They mark the start of sections.\n */\nexport enum MarkerCodesStart {\n\t\"list\" = 49,\n\t\"set\" = 51,\n}\n\n/**\n * Control codes used by tree serialization / decentralization code. They mark the end of sections.\n */\nexport enum MarkerCodesEnd {\n\t\"list\" = 50,\n\t\"set\" = 52,\n}\n\n/**\n * This contains mapping of Marker Codes to number of bytes in which the corresponding data\n * will be stored.\n */\nexport const codeToBytesMap = {\n\t// Integer code to bytes\n\t1: 0,\n\t2: 1,\n\t3: 1,\n\t4: 2,\n\t5: 2,\n\t6: 4,\n\t7: 4,\n\t8: 8,\n\t9: 8,\n\n\t// String code to Bytes\n\t13: 0,\n\t14: 1,\n\t15: 2,\n\t16: 4,\n\n\t17: 1,\n\t18: 2,\n\t19: 4,\n\n\t20: 1,\n\t21: 4,\n\n\t// Binary code to bytes\n\t32: 0,\n\t33: 1,\n\t34: 2,\n\t35: 4,\n\t36: 8,\n};\n\nexport function getValueSafely(map: { [index: number]: number }, key: number): number {\n\tconst val = map[key];\n\tassert(val !== undefined, 0x287 /* key must exist in the map */);\n\treturn val;\n}\n\nexport function getNodeProps(node: NodeCore): Record<string, NodeTypes> {\n\tconst res: Record<string, NodeTypes> = {};\n\tfor (const [keyNode, valueNode] of node.iteratePairs()) {\n\t\tconst id = getStringInstance(keyNode, \"keynode should be a string\");\n\t\tres[id] = valueNode;\n\t}\n\treturn res;\n}\n\nexport function iteratePairs<T>(it: IterableIterator<T>): IterableIterator<[T, T]> {\n\tconst res: IterableIterator<[T, T]> = {\n\t\tnext: () => {\n\t\t\tconst a = it.next();\n\t\t\tif (a.done) {\n\t\t\t\treturn { value: undefined, done: true };\n\t\t\t}\n\t\t\tconst b = it.next();\n\t\t\tassert(b.done !== true, 0x22b /* \"Should be a pair\" */);\n\t\t\treturn { value: [a.value, b.value], done: b.done };\n\t\t},\n\t\t[Symbol.iterator]: () => {\n\t\t\treturn res;\n\t\t},\n\t};\n\treturn res;\n}\n\n/**\n * Helper function that returns iterator from an object\n * @param obj - object that supports iteration\n */\nexport function iterate<T>(obj: {\n\t[Symbol.iterator]: () => IterableIterator<T>;\n}): IterableIterator<T> {\n\treturn obj[Symbol.iterator]();\n}\n\n/**\n * Base class to represent binary blob element.\n * Binary blob is one of three types supported as a leaf node of a tree.\n * Note: concrete implementations (derived classes) are not exposed from this module\n */\nexport abstract class BlobCore {\n\tpublic abstract get buffer(): Uint8Array;\n\tpublic abstract get arrayBuffer(): ArrayBufferLike;\n\n\t/**\n\t * Represents a blob.\n\t */\n\tconstructor() {}\n}\n\n/**\n * \"deep copy\" blob, holds to binary data passed in\n * It is called deep copy as a counter-part to BlobShallowCopy, which\n * is a reference to underlying binary stream (ReadBuffer).\n */\nclass BlobDeepCopy extends BlobCore {\n\t/**\n\t * Represents a deep copy of the blob.\n\t * @param data - Data array of the blob\n\t */\n\tconstructor(protected readonly data: Uint8Array) {\n\t\tsuper();\n\t}\n\n\tpublic get buffer(): Uint8Array {\n\t\treturn this.data;\n\t}\n\n\tpublic get arrayBuffer(): ArrayBufferLike {\n\t\treturn Uint8ArrayToArrayBuffer(this.buffer);\n\t}\n\n\tpublic static read(buffer: ReadBuffer, lengthLen: number): BlobCore {\n\t\tconst length = buffer.read(lengthLen);\n\t\tconst data = new Uint8Array(length);\n\t\tfor (let counter = 0; counter < length; counter++) {\n\t\t\tdata[counter] = buffer.read();\n\t\t}\n\t\treturn new BlobDeepCopy(data);\n\t}\n}\n\n/**\n * Shallow copy blob, keeps a reference to portion of ReadBuffer\n * it was constructed from. It takes much less memory compared to BlobDeepCopy\n */\nexport class BlobShallowCopy extends BlobCore {\n\t/**\n\t * Represents a shallow copy of the blob. It is not a separate blob, just reference to original blobs.\n\t * @param data - Data array of the blob\n\t * @param start - Start point of the blob in the buffer.\n\t * @param end - End point of the blob in the buffer.\n\t */\n\tconstructor(\n\t\tprotected data: Uint8Array,\n\t\tprotected start: number,\n\t\tprotected end: number,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic get buffer(): Uint8Array {\n\t\treturn this.data.subarray(this.start, this.end);\n\t}\n\n\t// Equivalent to Uint8ArrayToArrayBuffer(this.buffer)\n\tpublic get arrayBuffer(): ArrayBufferLike {\n\t\tconst offset = this.data.byteOffset;\n\t\treturn this.data.buffer.slice(this.start + offset, this.end + offset);\n\t}\n\n\tpublic static read(buffer: ReadBuffer, lengthLen: number): BlobCore {\n\t\tconst length = buffer.read(lengthLen);\n\t\tconst pos = buffer.pos;\n\t\tbuffer.skip(length);\n\t\treturn new BlobShallowCopy(buffer.buffer, pos, pos + length);\n\t}\n}\n\nexport const addStringProperty = (node: NodeCore, a: string, b: string): void => {\n\tnode.addDictionaryString(a);\n\tnode.addString(b);\n};\nexport const addDictionaryStringProperty = (node: NodeCore, a: string, b: string): void => {\n\tnode.addDictionaryString(a);\n\tnode.addString(b);\n};\nexport const addNumberProperty = (node: NodeCore, a: string, b: number): void => {\n\tnode.addDictionaryString(a);\n\tnode.addNumber(b);\n};\nexport const addBoolProperty = (node: NodeCore, a: string, b: boolean): void => {\n\tnode.addDictionaryString(a);\n\tnode.addBool(b);\n};\n\nexport interface IStringElement {\n\tcontent: string;\n\tdictionary: boolean;\n\t_stringElement: true;\n}\n\nexport interface IStringElementInternal extends Omit<IStringElement, \"content\"> {\n\tcontent?: string;\n\tstartPos: number;\n\tendPos: number;\n}\n\n/**\n * Three leaf types supported by tree:\n * 1. Node (sub-tree)\n * 2. binary blob\n * 3. integer\n * 4. boolean\n */\nexport type NodeTypes = NodeCore | BlobCore | number | boolean | IStringElement;\n\nexport type NodeCoreTypes = \"list\" | \"set\";\n\n/**\n * Node - node in the tree (non-leaf element of the tree)\n */\nexport class NodeCore {\n\t// It is an array of nodes.\n\tprivate readonly children: NodeTypes[] = [];\n\tpublic get nodes(): NodeTypes[] {\n\t\treturn this.children;\n\t}\n\n\tconstructor(public type: NodeCoreTypes = \"set\") {}\n\n\tpublic [Symbol.iterator](): IterableIterator<NodeTypes> {\n\t\treturn this.children[Symbol.iterator]();\n\t}\n\n\tpublic iteratePairs(): IterableIterator<[NodeTypes, NodeTypes]> {\n\t\tassert(this.length % 2 === 0, 0x22c /* \"reading pairs\" */);\n\t\treturn iteratePairs(iterate(this));\n\t}\n\n\tpublic get length(): number {\n\t\treturn this.children.length;\n\t}\n\n\tpublic get(index: number): NodeTypes {\n\t\treturn this.children[index];\n\t}\n\n\tpublic getString(index: number): string {\n\t\tconst node = this.children[index];\n\t\treturn getStringInstance(node, \"getString should return string\");\n\t}\n\n\tpublic getMaybeString(index: number): string | undefined {\n\t\tconst node = this.children[index];\n\t\treturn getMaybeStringInstance(node);\n\t}\n\n\tpublic getBlob(index: number): BlobCore {\n\t\tconst node = this.children[index];\n\t\tassertBlobCoreInstance(node, \"getBlob should return a blob\");\n\t\treturn node;\n\t}\n\n\tpublic getNode(index: number): NodeCore {\n\t\tconst node = this.children[index];\n\t\tassertNodeCoreInstance(node, \"getNode should return a node\");\n\t\treturn node;\n\t}\n\n\tpublic getNumber(index: number): number {\n\t\tconst node = this.children[index];\n\t\tassertNumberInstance(node, \"getNumber should return a number\");\n\t\treturn node;\n\t}\n\n\tpublic getBool(index: number): boolean {\n\t\tconst node = this.children[index];\n\t\tassertBoolInstance(node, \"getBool should return a boolean\");\n\t\treturn node;\n\t}\n\n\tpublic addNode(type?: NodeCoreTypes): NodeCore {\n\t\tconst node = new NodeCore(type);\n\t\tthis.children.push(node);\n\t\treturn node;\n\t}\n\n\tpublic addBlob(blob: Uint8Array): void {\n\t\tthis.children.push(new BlobDeepCopy(blob));\n\t}\n\n\tpublic addDictionaryString(payload: string): void {\n\t\tthis.children.push({\n\t\t\tcontent: payload,\n\t\t\tdictionary: true,\n\t\t\t_stringElement: true,\n\t\t});\n\t}\n\n\tpublic addString(payload: string): void {\n\t\tthis.children.push({\n\t\t\tcontent: payload,\n\t\t\tdictionary: false,\n\t\t\t_stringElement: true,\n\t\t});\n\t}\n\n\tpublic addNumber(payload: number | undefined): void {\n\t\tassert(Number.isInteger(payload), 0x231 /* \"Number should be an integer\" */);\n\t\tassert(\n\t\t\tpayload !== undefined && payload >= 0,\n\t\t\t0x232 /* \"Payload should not be negative\" */,\n\t\t);\n\t\tthis.children.push(payload);\n\t}\n\n\tpublic addBool(payload: boolean): void {\n\t\tthis.children.push(payload);\n\t}\n\n\t// Can we do more efficiently here, without extra objects somehow??\n\tprivate static readString(\n\t\tbuffer: ReadBuffer,\n\t\tcode: number,\n\t\tdictionary: boolean,\n\t): IStringElementInternal & IStringElement {\n\t\tconst lengthLen = getValueSafely(codeToBytesMap, code);\n\t\tconst length = buffer.read(lengthLen);\n\t\tconst startPos = buffer.pos;\n\t\tbuffer.skip(length);\n\t\tconst result: IStringElementInternal = {\n\t\t\t// Note: Setting here property 'content: undefined' makes code substantially slower!\n\t\t\tdictionary,\n\t\t\t_stringElement: true,\n\t\t\tstartPos,\n\t\t\tendPos: buffer.pos,\n\t\t};\n\n\t\t// We are lying here in terms of presence of `content` property.\n\t\t// This will be addressed at the bottom of NodeCore.load() by resolving all strings at once!\n\t\t// It's equivalent (but much slower!) to do it here via\n\t\t// result.content = Uint8ArrayToString(buffer.buffer.subarray(startPos, buffer.pos), \"utf-8\");\n\t\treturn result as IStringElementInternal & IStringElement;\n\t}\n\n\t/**\n\t * Load and parse the buffer into a tree.\n\t * @param buffer - buffer to read from.\n\t */\n\tprotected load(\n\t\tbuffer: ReadBuffer,\n\t\tlogger: ITelemetryLoggerExt,\n\t): {\n\t\tdurationStructure: number;\n\t\tdurationStrings: number;\n\t} {\n\t\tconst [stringsToResolve, durationStructure] = measure(() =>\n\t\t\tthis.loadStructure(buffer, logger),\n\t\t);\n\t\tconst [, durationStrings] = measure(() =>\n\t\t\tthis.loadStrings(buffer, stringsToResolve, logger),\n\t\t);\n\t\treturn { durationStructure, durationStrings };\n\t}\n\n\t/**\n\t * Load and parse the buffer into a tree.\n\t * @param buffer - buffer to read from.\n\t */\n\tprotected loadStructure(\n\t\tbuffer: ReadBuffer,\n\t\tlogger: ITelemetryLoggerExt,\n\t): IStringElementInternal[] {\n\t\tconst stack: NodeTypes[][] = [];\n\t\tconst stringsToResolve: IStringElementInternal[] = [];\n\t\tconst dictionary: IStringElement[] = [];\n\n\t\tlet children = this.children;\n\t\tfor (; !buffer.eof; ) {\n\t\t\tconst code = buffer.read();\n\t\t\tswitch (code) {\n\t\t\t\tcase MarkerCodesStart.list:\n\t\t\t\tcase MarkerCodesStart.set: {\n\t\t\t\t\tconst childValue = new NodeCore(code === MarkerCodesStart.set ? \"set\" : \"list\");\n\t\t\t\t\tchildren.push(childValue);\n\t\t\t\t\tstack.push(children);\n\t\t\t\t\tchildren = childValue.children;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase MarkerCodes.ConstStringDeclare:\n\t\t\t\tcase MarkerCodes.ConstStringDeclareBig: {\n\t\t\t\t\tconst stringId = buffer.read(getValueSafely(codeToBytesMap, code));\n\t\t\t\t\tconst constString = NodeCore.readString(buffer, code, true /* dictionary */);\n\t\t\t\t\tstringsToResolve.push(constString);\n\t\t\t\t\tdictionary[stringId] = constString;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase MarkerCodes.ConstString8Id:\n\t\t\t\tcase MarkerCodes.ConstString16Id:\n\t\t\t\tcase MarkerCodes.ConstString32Id: {\n\t\t\t\t\tconst stringId = buffer.read(getValueSafely(codeToBytesMap, code));\n\t\t\t\t\tconst content = dictionary[stringId];\n\t\t\t\t\tassert(content !== undefined, 0x3de /* const string not found */);\n\t\t\t\t\tchildren.push(content);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase MarkerCodes.StringEmpty:\n\t\t\t\tcase MarkerCodes.String8Length:\n\t\t\t\tcase MarkerCodes.String16Length:\n\t\t\t\tcase MarkerCodes.String32Length: {\n\t\t\t\t\tconst str = NodeCore.readString(buffer, code, false /* dictionary */);\n\t\t\t\t\tstringsToResolve.push(str);\n\t\t\t\t\tchildren.push(str);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase MarkerCodes.BinaryEmpty:\n\t\t\t\tcase MarkerCodes.BinarySingle8:\n\t\t\t\tcase MarkerCodes.BinarySingle16:\n\t\t\t\tcase MarkerCodes.BinarySingle32:\n\t\t\t\tcase MarkerCodes.BinarySingle64: {\n\t\t\t\t\tchildren.push(BlobShallowCopy.read(buffer, getValueSafely(codeToBytesMap, code)));\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// If integer is 0.\n\t\t\t\tcase MarkerCodes.Int0: {\n\t\t\t\t\tchildren.push(0);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase MarkerCodes.UInt8:\n\t\t\t\tcase MarkerCodes.UInt16:\n\t\t\t\tcase MarkerCodes.UInt32:\n\t\t\t\tcase MarkerCodes.UInt64:\n\t\t\t\tcase MarkerCodes.Int8:\n\t\t\t\tcase MarkerCodes.Int16:\n\t\t\t\tcase MarkerCodes.Int32:\n\t\t\t\tcase MarkerCodes.Int64: {\n\t\t\t\t\tchildren.push(buffer.read(getValueSafely(codeToBytesMap, code)));\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase MarkerCodes.BoolTrue: {\n\t\t\t\t\tchildren.push(true);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase MarkerCodes.BoolFalse: {\n\t\t\t\t\tchildren.push(false);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase MarkerCodesEnd.list:\n\t\t\t\tcase MarkerCodesEnd.set: {\n\t\t\t\t\t// Note: We are not checking that end marker matches start marker.\n\t\t\t\t\t// I.e. that we do not have a case where we start a 'list' but end with a 'set'\n\t\t\t\t\t// Checking it would require more state tracking that seems not very useful, given\n\t\t\t\t\t// our code does not care.\n\t\t\t\t\tchildren = stack.pop()!;\n\n\t\t\t\t\t// To my surprise, checking children !== undefined adds measurable cost!\n\t\t\t\t\t// We will rely on children.push() crashing in case of mismatch, and check below\n\t\t\t\t\t// (outside of the loop)\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tthrow new Error(`Invalid code: ${code}`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// This also ensures that stack.length === 0.\n\t\tassert(children === this.children, 0x3e7 /* Unpaired start/end list/set markers! */);\n\n\t\treturn stringsToResolve;\n\t}\n\n\tprivate loadStrings(\n\t\tbuffer: ReadBuffer,\n\t\tstringsToResolve: IStringElementInternal[],\n\t\tlogger: ITelemetryLoggerExt,\n\t): void {\n\t\t/**\n\t\t * Process all the strings at once!\n\t\t */\n\t\tlet length = 0;\n\t\tfor (const el of stringsToResolve) {\n\t\t\tlength += el.endPos - el.startPos + 1;\n\t\t}\n\t\tconst stringBuffer = new Uint8Array(length);\n\n\t\tlength = 0;\n\t\tconst input = buffer.buffer;\n\t\tassert(input.byteOffset === 0, 0x3e8 /* code below assumes no offset */);\n\n\t\tfor (const el of stringsToResolve) {\n\t\t\tfor (let it = el.startPos; it < el.endPos; it++) {\n\t\t\t\tstringBuffer[length] = input[it];\n\t\t\t\tlength++;\n\t\t\t}\n\t\t\tstringBuffer[length] = 0;\n\t\t\tlength++;\n\t\t}\n\t\tassert(length === stringBuffer.length, 0x418 /* properly encoded */);\n\n\t\tconst result = Uint8ArrayToString(stringBuffer, \"utf8\").split(String.fromCodePoint(0));\n\t\tif (result.length === stringsToResolve.length + 1) {\n\t\t\t// All is good, we expect all the cases to get here\n\t\t\tfor (let i = 0; i < stringsToResolve.length; i++) {\n\t\t\t\tstringsToResolve[i].content = result[i];\n\t\t\t}\n\t\t} else {\n\t\t\t// String content has \\0 chars!\n\t\t\t// Recovery code\n\t\t\tlogger.sendErrorEvent({ eventName: \"StringParsingError\" });\n\t\t\tfor (const el of stringsToResolve) {\n\t\t\t\tassert(\n\t\t\t\t\tel.content === Uint8ArrayToString(input.subarray(el.startPos, el.endPos), \"utf8\"),\n\t\t\t\t\t0x3ea /* test */,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * TreeBuilder - Root of the tree.\n * Provides loading and serialization capabilities.\n */\nexport class TreeBuilder extends NodeCore {\n\tstatic load(\n\t\tbuffer: ReadBuffer,\n\t\tlogger: ITelemetryLoggerExt,\n\t): {\n\t\tbuilder: TreeBuilder;\n\t\ttelemetryProps: {\n\t\t\tdurationStructure: number;\n\t\t\tdurationStrings: number;\n\t\t};\n\t} {\n\t\tconst builder = new TreeBuilder();\n\t\tconst telemetryProps = builder.load(buffer, logger);\n\t\tassert(buffer.eof, 0x233 /* \"Unexpected data at the end of buffer\" */);\n\t\treturn { builder, telemetryProps };\n\t}\n}\n\nexport function getMaybeStringInstance(node: NodeTypes): string | undefined {\n\tconst maybeString = node as IStringElement;\n\tif (maybeString._stringElement) {\n\t\treturn maybeString.content;\n\t}\n}\n\nexport function getStringInstance(node: NodeTypes, message: string): string {\n\tconst maybeString = node as IStringElement;\n\tif (maybeString._stringElement) {\n\t\treturn maybeString.content;\n\t}\n\tthrowBufferParseException(node, \"BlobCore\", message);\n}\n\nexport function assertBlobCoreInstance(\n\tnode: NodeTypes,\n\tmessage: string,\n): asserts node is BlobCore {\n\tif (node instanceof BlobCore) {\n\t\treturn;\n\t}\n\tthrowBufferParseException(node, \"BlobCore\", message);\n}\n\nexport function assertNodeCoreInstance(\n\tnode: NodeTypes,\n\tmessage: string,\n): asserts node is NodeCore {\n\tif (node instanceof NodeCore) {\n\t\treturn;\n\t}\n\tthrowBufferParseException(node, \"NodeCore\", message);\n}\n\nexport function assertNumberInstance(\n\tnode: NodeTypes,\n\tmessage: string,\n): asserts node is number {\n\tif (typeof node === \"number\") {\n\t\treturn;\n\t}\n\tthrowBufferParseException(node, \"Number\", message);\n}\n\nexport function assertBoolInstance(node: NodeTypes, message: string): asserts node is boolean {\n\tif (typeof node === \"boolean\") {\n\t\treturn;\n\t}\n\tthrowBufferParseException(node, \"Boolean\", message);\n}\n\nfunction throwBufferParseException(\n\tnode: NodeTypes,\n\texpectedNodeType: NodeType,\n\tmessage: string,\n): never {\n\tthrow new NonRetryableError(\n\t\t`Buffer parsing exception: ${message}`,\n\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t{\n\t\t\tnodeType: getNodeType(node),\n\t\t\texpectedNodeType,\n\t\t\tdriverVersion,\n\t\t},\n\t);\n}\n\nfunction getNodeType(value: NodeTypes): NodeType {\n\tif (typeof value === \"number\") {\n\t\treturn \"Number\";\n\t} else if (value instanceof BlobCore) {\n\t\treturn \"BlobCore\";\n\t} else if (value instanceof NodeCore) {\n\t\treturn \"NodeCore\";\n\t} else if (typeof value === \"boolean\") {\n\t\treturn \"Boolean\";\n\t} else if (value._stringElement) {\n\t\treturn \"String\";\n\t}\n\treturn \"UnknownType\";\n}\n\ntype NodeType = \"Number\" | \"BlobCore\" | \"NodeCore\" | \"Boolean\" | \"UnknownType\" | \"String\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReadBufferUtils.d.ts","sourceRoot":"","sources":["../src/ReadBufferUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;GAGG;AACH,qBAAa,UAAU;IAOV,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAU;IAN/C,SAAS,CAAC,KAAK,SAAK;IAEpB,IAAW,MAAM,IAAI,UAAU,CAE9B;gBAE8B,IAAI,EAAE,UAAU;IAO/C,IAAW,GAAG,IAAI,OAAO,CAExB;IACD,IAAW,GAAG,IAAI,MAAM,CAEvB;IACD,IAAW,MAAM,IAAI,MAAM,CAE1B;IAEM,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU;IAI7C,KAAK,IAAI,IAAI;IAIb,IAAI,CAAC,SAAS,SAAI,GAAG,MAAM;
|
|
1
|
+
{"version":3,"file":"ReadBufferUtils.d.ts","sourceRoot":"","sources":["../src/ReadBufferUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;GAGG;AACH,qBAAa,UAAU;IAOV,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAU;IAN/C,SAAS,CAAC,KAAK,SAAK;IAEpB,IAAW,MAAM,IAAI,UAAU,CAE9B;gBAE8B,IAAI,EAAE,UAAU;IAO/C,IAAW,GAAG,IAAI,OAAO,CAExB;IACD,IAAW,GAAG,IAAI,MAAM,CAEvB;IACD,IAAW,MAAM,IAAI,MAAM,CAE1B;IAEM,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU;IAI7C,KAAK,IAAI,IAAI;IAIb,IAAI,CAAC,SAAS,SAAI,GAAG,MAAM;IAc3B,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;CAKjC"}
|
package/lib/ReadBufferUtils.js
CHANGED
|
@@ -40,7 +40,6 @@ export class ReadBuffer {
|
|
|
40
40
|
let length = lengthArg;
|
|
41
41
|
while (length > 0) {
|
|
42
42
|
assert(!this.eof, 0x223 /* "unexpected end of buffer" */);
|
|
43
|
-
// TODO Why are we non null asserting here?
|
|
44
43
|
res += this.data[this.index] * multiplier;
|
|
45
44
|
this.index++;
|
|
46
45
|
multiplier *= 256;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReadBufferUtils.js","sourceRoot":"","sources":["../src/ReadBufferUtils.ts"],"names":[],"mappings":"AAAA;;;GAG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CAAC,MAAc;QACzB,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAClE,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC;QACrB,MAAM,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,kCAAkC,CAAC,CAAC;IAClF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\n/**\n * Buffer class, used to sequentially read data.\n * Used by tree code to reconstruct a tree from binary representation.\n */\nexport class ReadBuffer {\n\tprotected index = 0;\n\n\tpublic get buffer(): Uint8Array {\n\t\treturn this.data;\n\t}\n\n\tconstructor(protected readonly data: Uint8Array) {\n\t\t// BlobShallowCopy will return to users parts of this array.\n\t\t// We need to ensure that nobody can change it, as it will have\n\t\t// catastrophic result and will be really hard to investigate.\n\t\tObject.freeze(data.buffer);\n\t}\n\n\tpublic get eof(): boolean {\n\t\treturn this.index === this.data.length;\n\t}\n\tpublic get pos(): number {\n\t\treturn this.index;\n\t}\n\tpublic get length(): number {\n\t\treturn this.data.length;\n\t}\n\n\tpublic slice(start: number, end: number): Uint8Array {\n\t\treturn this.data.slice(start, end);\n\t}\n\n\tpublic reset(): void {\n\t\tthis.index = 0;\n\t}\n\n\tpublic read(lengthArg = 1): number {\n\t\tlet res = 0;\n\t\tlet multiplier = 1;\n\t\tlet length = lengthArg;\n\t\twhile (length > 0) {\n\t\t\tassert(!this.eof, 0x223 /* \"unexpected end of buffer\" */);\n\t\t\tres += this.data[this.index] * multiplier;\n\t\t\tthis.index++;\n\t\t\tmultiplier *= 256;\n\t\t\tlength--;\n\t\t}\n\t\treturn res;\n\t}\n\n\tpublic skip(length: number): void {\n\t\tassert(length >= 0, 0x224 /* \"Skip length should be positive\" */);\n\t\tthis.index += length;\n\t\tassert(this.index <= this.data.length, 0x3dc /* skipping past size of buffer */);\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WriteBufferUtils.d.ts","sourceRoot":"","sources":["../src/WriteBufferUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAKN,QAAQ,EAGR,MAAM,mCAAmC,CAAC;AAE3C;;;GAGG;AACH,qBAAa,WAAW;IACvB,SAAS,CAAC,IAAI,CAAC,EAAE,UAAU,CAAwB;IACnD,SAAS,CAAC,KAAK,SAAK;IAEpB,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"WriteBufferUtils.d.ts","sourceRoot":"","sources":["../src/WriteBufferUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAKN,QAAQ,EAGR,MAAM,mCAAmC,CAAC;AAE3C;;;GAGG;AACH,qBAAa,WAAW;IACvB,SAAS,CAAC,IAAI,CAAC,EAAE,UAAU,CAAwB;IACnD,SAAS,CAAC,KAAK,SAAK;IAEpB,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAiB3B,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,SAAI,GAAG,IAAI;IAW3C,IAAI,IAAI,UAAU;CAQzB;AAwDD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAejD;AA+HD,cAAM,kBAAmB,SAAQ,QAAQ;;IAKjC,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;CAG3C;AAED,qBAAa,qBAAsB,SAAQ,kBAAkB;;IAKrD,SAAS,IAAI,UAAU;CAK9B"}
|
package/lib/WriteBufferUtils.js
CHANGED
|
@@ -22,7 +22,6 @@ export class WriteBuffer {
|
|
|
22
22
|
let index = 0;
|
|
23
23
|
const oldData = this.data;
|
|
24
24
|
while (index < length) {
|
|
25
|
-
// TODO Why are we non null asserting here?
|
|
26
25
|
newData[index] = oldData[index];
|
|
27
26
|
index++;
|
|
28
27
|
}
|
|
@@ -213,7 +212,6 @@ function serializeNodeCore(buffer, nodeCore, dictionary) {
|
|
|
213
212
|
}
|
|
214
213
|
}
|
|
215
214
|
else if (typeof child === "boolean") {
|
|
216
|
-
// TODO Why are we non null asserting here?
|
|
217
215
|
buffer.write(boolToCodeMap[child ? 1 : 0]);
|
|
218
216
|
}
|
|
219
217
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WriteBufferUtils.js","sourceRoot":"","sources":["../src/WriteBufferUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EACN,QAAQ,EACR,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,QAAQ,EACR,cAAc,EACd,cAAc,GACd,MAAM,mCAAmC,CAAC;AAE3C;;;GAGG;AACH,MAAM,OAAO,WAAW;IAAxB;QACW,SAAI,GAAgB,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;QACzC,UAAK,GAAG,CAAC,CAAC;IAuCrB,CAAC;IArCU,IAAI,CAAC,IAAY;QAC1B,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,KAAK,CAAC,4BAA4B,CAAC,CAAC;QACpE,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;QAChC,IAAI,IAAI,CAAC,KAAK,KAAK,MAAM,EAAE,CAAC;YAC3B,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC;YACpD,IAAI,KAAK,GAAG,CAAC,CAAC;YACd,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC;YAC1B,OAAO,KAAK,GAAG,MAAM,EAAE,CAAC;gBACvB,2CA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AAK,EAAE,CAAC;IACT,CAAC;IAEM,SAAS,CAAC,MAAmB;QACnC,iBAAiB,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,EAAkB,CAAC,CAAC;IAC5D,CAAC;CACD;AAED,MAAM,OAAO,qBAAsB,SAAQ,kBAAkB;IAC5D;QACC,KAAK,EAAE,CAAC;IACT,CAAC;IAEM,SAAS;QACf,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QACjC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACxB,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IsoBuffer } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tBlobCore,\n\tMarkerCodes,\n\tMarkerCodesEnd,\n\tMarkerCodesStart,\n\tNodeCore,\n\tcodeToBytesMap,\n\tgetValueSafely,\n} from \"./zipItDataRepresentationUtils.js\";\n\n/**\n * Buffer class, used to sequentially writ data.\n * Used by tree code to serialize tree into binary representation.\n */\nexport class WriteBuffer {\n\tprotected data?: Uint8Array = new Uint8Array(4096);\n\tprotected index = 0;\n\n\tprotected push(code: number): void {\n\t\tassert(this.data !== undefined, 0x225 /* \"Data should be there\" */);\n\t\tconst length = this.data.length;\n\t\tif (this.index === length) {\n\t\t\tconst newData = new Uint8Array(length * 1.2 + 4096);\n\t\t\tlet index = 0;\n\t\t\tconst oldData = this.data;\n\t\t\twhile (index < length) {\n\t\t\t\t// TODO Why are we non null asserting here?\n\t\t\t\tnewData[index] = oldData[index]!;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\tthis.data = newData;\n\t\t}\n\t\tthis.data[this.index] = code % 256;\n\t\tthis.index++;\n\t}\n\n\tpublic write(codeArg: number, lengthArg = 1): void {\n\t\tlet code = codeArg;\n\t\tlet length = lengthArg;\n\t\twhile (length > 0) {\n\t\t\tthis.push(code % 256);\n\t\t\tcode = Math.floor(code / 256);\n\t\t\tlength--;\n\t\t}\n\t\tassert(code === 0, 0x226 /* Should write complete data */);\n\t}\n\n\tpublic done(): Uint8Array {\n\t\tassert(this.data !== undefined, 0x227 /* \"Data should be there\" */);\n\t\t// We can slice it to have smaller memory representation.\n\t\t// But it will be way more expensive in terms of CPU cycles!\n\t\tconst buffer = this.data.subarray(0, this.index);\n\t\tthis.data = undefined;\n\t\treturn buffer;\n\t}\n}\n\n// This list of maps below is reverse mapping of Marker Codes specified in zipItDataRepresentationUtils.ts file.\n// We can also found them on server filestore code.\n// https://onedrive.visualstudio.com/SharePoint%20Online/_git/SPO?path=/cobalt/Base/Property/BinaryEncodedPropertyReader.cs&version=GBmaster&_a=contents\n\n/**\n * This contains mapping of number of bytes representing the corresponding string length to Marker Codes.\n */\nconst utf8StringBytesToCodeMap = {\n\t0: 13,\n\t1: 14,\n\t2: 15,\n\t4: 16,\n};\n\n/**\n * This contains mapping of number of bytes representing the corresponding length in which actual data(base64 string)\n * will be stored to Marker Codes.\n */\nconst binaryBytesToCodeMap = {\n\t0: 32,\n\t1: 33,\n\t2: 34,\n\t4: 35,\n\t8: 16,\n};\n\n/**\n * This contains mapping of number of bytes representing the corresponding const string id to Marker Codes.\n */\nconst constStringBytesToCodeMap = {\n\t1: 17,\n\t2: 18,\n\t4: 19,\n};\n\n/**\n * This contains mapping of number of bytes to Marker Codes representing the corresponding Integer.\n */\nconst integerBytesToCodeMap = {\n\t0: 1,\n\t1: 3,\n\t2: 5,\n\t4: 7,\n\t8: 9,\n};\n\n/**\n * This contains mapping of boolean to Marker Codes representing the corresponding bool value.\n */\nconst boolToCodeMap = [\n\t12, // false\n\t11, // true\n];\n\n/**\n * Calculate how many bytes are required to encode an integer. This is always power of 2.\n * So if 6 bytes are required to store an integer than it will return 8. 0 is a special case for which we\n * return 0 as it is usually just represented by marker code and we don't store the actual data.\n * @param num - number to encode.\n */\nexport function calcLength(numArg: number): number {\n\tif (numArg === 0) {\n\t\treturn 0;\n\t}\n\tlet num = numArg;\n\tlet lengthLen = 0;\n\twhile (num > 0) {\n\t\tnum = Math.floor(num / 256);\n\t\tlengthLen++;\n\t}\n\tlet res = 1;\n\twhile (res < lengthLen) {\n\t\tres *= 2;\n\t}\n\treturn res;\n}\n\n/**\n * Implementation of serialization of blobs in buffer with Marker Codes etc.\n * @param buffer - Buffer to serialize to.\n * @param content - string to be serialized.\n * @param dictionary - Const strings dictionary to be used while serializing.\n */\nfunction serializeDictionaryString(\n\tbuffer: WriteBuffer,\n\tcontent: string,\n\tdictionary: Map<string, number>,\n): void {\n\tlet id = dictionary.get(content);\n\tlet idLength: number;\n\tif (id === undefined) {\n\t\tconst data = IsoBuffer.from(content, \"utf8\");\n\t\tconst lengthOfDataLen = calcLength(data.length);\n\n\t\tid = dictionary.size + 1;\n\t\tidLength = calcLength(id);\n\t\tdictionary.set(content, id);\n\t\tconst code =\n\t\t\tlengthOfDataLen > 1 || idLength > 1\n\t\t\t\t? MarkerCodes.ConstStringDeclareBig\n\t\t\t\t: MarkerCodes.ConstStringDeclare;\n\t\t// Write marker code for const string.\n\t\tbuffer.write(code);\n\t\tconst bytes = getValueSafely(codeToBytesMap, code);\n\t\tassert(\n\t\t\tbytes >= lengthOfDataLen,\n\t\t\t0x283 /* \"Length of data len should fit in the bytes from the map\" */,\n\t\t);\n\t\tassert(bytes >= idLength, 0x284 /* \"Length of id should fit in the bytes from the map\" */);\n\t\t// Assign and write id for const string.\n\t\tbuffer.write(id, bytes);\n\t\t// Write length of const string.\n\t\tbuffer.write(data.length, bytes);\n\t\t// Write const string data.\n\t\tfor (const element of data) {\n\t\t\tbuffer.write(element);\n\t\t}\n\t} else {\n\t\tidLength = calcLength(id);\n\t}\n\t// Write Marker Code\n\tbuffer.write(getValueSafely(constStringBytesToCodeMap, idLength));\n\t// Write id of const string\n\tbuffer.write(id, idLength);\n}\n\nfunction serializeString(\n\tbuffer: WriteBuffer,\n\tcontent: string,\n\tcodeMap = binaryBytesToCodeMap,\n): void {\n\tserializeBlob(buffer, IsoBuffer.from(content, \"utf8\"), utf8StringBytesToCodeMap);\n}\n\n/**\n * Implementation of serialization of blobs in buffer with Marker Codes etc.\n * @param buffer - Buffer to serialize to.\n * @param blob - blob to be serialized.\n * @param dictionary - Const strings dictionary to be used while serializing.\n */\nfunction serializeBlob(\n\tbuffer: WriteBuffer,\n\tdata: Uint8Array,\n\tcodeMap: Record<number, number> = binaryBytesToCodeMap,\n): void {\n\tconst lengthOfDataLen = calcLength(data.length);\n\t// Write Marker code.\n\tbuffer.write(getValueSafely(codeMap, lengthOfDataLen));\n\t// Write actual data if length greater than 0, otherwise Marker Code is enough.\n\tif (lengthOfDataLen > 0) {\n\t\tbuffer.write(data.length, lengthOfDataLen);\n\t\tfor (const element of data) {\n\t\t\tbuffer.write(element);\n\t\t}\n\t}\n}\n\n/**\n * Implementation of serialization of nodes with Marker Codes etc.\n * @param buffer - Buffer to serialize to.\n * @param nodeCore - Node to be serialized.\n * @param dictionary - Const strings dictionary to be used while serializing.\n */\nfunction serializeNodeCore(\n\tbuffer: WriteBuffer,\n\tnodeCore: NodeCore,\n\tdictionary: Map<string, number>,\n): void {\n\tfor (const child of nodeCore.nodes) {\n\t\tif (child instanceof NodeCore) {\n\t\t\t// For a tree node start and end with set/list start and end marker codes.\n\t\t\tconst startCode = MarkerCodesStart[child.type];\n\t\t\tconst endCode = MarkerCodesEnd[child.type];\n\t\t\tassert(startCode !== undefined, 0x285 /* \"Start code should not undefined\" */);\n\t\t\tassert(endCode !== undefined, 0x286 /* \"End code should not undefined\" */);\n\t\t\tbuffer.write(startCode);\n\t\t\tserializeNodeCore(buffer, child, dictionary);\n\t\t\tbuffer.write(endCode);\n\t\t} else if (child instanceof BlobCore) {\n\t\t\tserializeBlob(buffer, child.buffer);\n\t\t} else if (typeof child === \"number\") {\n\t\t\t// Calculate length in which integer will be stored\n\t\t\tconst len = calcLength(child);\n\t\t\t// Write corresponding Marker code for length of integer.\n\t\t\tbuffer.write(getValueSafely(integerBytesToCodeMap, len));\n\t\t\t// Write actual number if greater than 0, otherwise Marker Code is enough.\n\t\t\tif (len > 0) {\n\t\t\t\tbuffer.write(child, len);\n\t\t\t}\n\t\t} else if (typeof child === \"boolean\") {\n\t\t\t// TODO Why are we non null asserting here?\n\t\t\tbuffer.write(boolToCodeMap[child ? 1 : 0]!);\n\t\t} else {\n\t\t\tassert(child._stringElement, 0x3dd /* Unsupported node type */);\n\t\t\tif (child.dictionary) {\n\t\t\t\tserializeDictionaryString(buffer, child.content, dictionary);\n\t\t\t} else {\n\t\t\t\tserializeString(buffer, child.content);\n\t\t\t}\n\t\t}\n\t}\n}\n\nclass NodeCoreSerializer extends NodeCore {\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tpublic serialize(buffer: WriteBuffer): void {\n\t\tserializeNodeCore(buffer, this, new Map<string, number>());\n\t}\n}\n\nexport class TreeBuilderSerializer extends NodeCoreSerializer {\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tpublic serialize(): Uint8Array {\n\t\tconst buffer = new WriteBuffer();\n\t\tsuper.serialize(buffer);\n\t\treturn buffer.done();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"WriteBufferUtils.js","sourceRoot":"","sources":["../src/WriteBufferUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EACN,QAAQ,EACR,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,QAAQ,EACR,cAAc,EACd,cAAc,GACd,MAAM,mCAAmC,CAAC;AAE3C;;;GAGG;AACH,MAAM,OAAO,WAAW;IAAxB;QACW,SAAI,GAAgB,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;QACzC,UAAK,GAAG,CAAC,CAAC;IAsCrB,CAAC;IApC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,CAAC,CAAC,CAAC;QAC5C,CAAC;aAAM,CAAC;YACP,MAAM,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,2BAA2B,CAAC,CAAC;YAChE,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;gBACtB,yBAAyB,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;YAC9D,CAAC;iBAAM,CAAC;gBACP,eAAe,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;YACxC,CAAC;QACF,CAAC;IACF,CAAC;AACF,CAAC;AAED,MAAM,kBAAmB,SAAQ,QAAQ;IACxC;QACC,KAAK,EAAE,CAAC;IACT,CAAC;IAEM,SAAS,CAAC,MAAmB;QACnC,iBAAiB,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,EAAkB,CAAC,CAAC;IAC5D,CAAC;CACD;AAED,MAAM,OAAO,qBAAsB,SAAQ,kBAAkB;IAC5D;QACC,KAAK,EAAE,CAAC;IACT,CAAC;IAEM,SAAS;QACf,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QACjC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACxB,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IsoBuffer } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tBlobCore,\n\tMarkerCodes,\n\tMarkerCodesEnd,\n\tMarkerCodesStart,\n\tNodeCore,\n\tcodeToBytesMap,\n\tgetValueSafely,\n} from \"./zipItDataRepresentationUtils.js\";\n\n/**\n * Buffer class, used to sequentially writ data.\n * Used by tree code to serialize tree into binary representation.\n */\nexport class WriteBuffer {\n\tprotected data?: Uint8Array = new Uint8Array(4096);\n\tprotected index = 0;\n\n\tprotected push(code: number): void {\n\t\tassert(this.data !== undefined, 0x225 /* \"Data should be there\" */);\n\t\tconst length = this.data.length;\n\t\tif (this.index === length) {\n\t\t\tconst newData = new Uint8Array(length * 1.2 + 4096);\n\t\t\tlet index = 0;\n\t\t\tconst oldData = this.data;\n\t\t\twhile (index < length) {\n\t\t\t\tnewData[index] = oldData[index];\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\tthis.data = newData;\n\t\t}\n\t\tthis.data[this.index] = code % 256;\n\t\tthis.index++;\n\t}\n\n\tpublic write(codeArg: number, lengthArg = 1): void {\n\t\tlet code = codeArg;\n\t\tlet length = lengthArg;\n\t\twhile (length > 0) {\n\t\t\tthis.push(code % 256);\n\t\t\tcode = Math.floor(code / 256);\n\t\t\tlength--;\n\t\t}\n\t\tassert(code === 0, 0x226 /* Should write complete data */);\n\t}\n\n\tpublic done(): Uint8Array {\n\t\tassert(this.data !== undefined, 0x227 /* \"Data should be there\" */);\n\t\t// We can slice it to have smaller memory representation.\n\t\t// But it will be way more expensive in terms of CPU cycles!\n\t\tconst buffer = this.data.subarray(0, this.index);\n\t\tthis.data = undefined;\n\t\treturn buffer;\n\t}\n}\n\n// This list of maps below is reverse mapping of Marker Codes specified in zipItDataRepresentationUtils.ts file.\n// We can also found them on server filestore code.\n// https://onedrive.visualstudio.com/SharePoint%20Online/_git/SPO?path=/cobalt/Base/Property/BinaryEncodedPropertyReader.cs&version=GBmaster&_a=contents\n\n/**\n * This contains mapping of number of bytes representing the corresponding string length to Marker Codes.\n */\nconst utf8StringBytesToCodeMap = {\n\t0: 13,\n\t1: 14,\n\t2: 15,\n\t4: 16,\n};\n\n/**\n * This contains mapping of number of bytes representing the corresponding length in which actual data(base64 string)\n * will be stored to Marker Codes.\n */\nconst binaryBytesToCodeMap = {\n\t0: 32,\n\t1: 33,\n\t2: 34,\n\t4: 35,\n\t8: 16,\n};\n\n/**\n * This contains mapping of number of bytes representing the corresponding const string id to Marker Codes.\n */\nconst constStringBytesToCodeMap = {\n\t1: 17,\n\t2: 18,\n\t4: 19,\n};\n\n/**\n * This contains mapping of number of bytes to Marker Codes representing the corresponding Integer.\n */\nconst integerBytesToCodeMap = {\n\t0: 1,\n\t1: 3,\n\t2: 5,\n\t4: 7,\n\t8: 9,\n};\n\n/**\n * This contains mapping of boolean to Marker Codes representing the corresponding bool value.\n */\nconst boolToCodeMap = [\n\t12, // false\n\t11, // true\n];\n\n/**\n * Calculate how many bytes are required to encode an integer. This is always power of 2.\n * So if 6 bytes are required to store an integer than it will return 8. 0 is a special case for which we\n * return 0 as it is usually just represented by marker code and we don't store the actual data.\n * @param num - number to encode.\n */\nexport function calcLength(numArg: number): number {\n\tif (numArg === 0) {\n\t\treturn 0;\n\t}\n\tlet num = numArg;\n\tlet lengthLen = 0;\n\twhile (num > 0) {\n\t\tnum = Math.floor(num / 256);\n\t\tlengthLen++;\n\t}\n\tlet res = 1;\n\twhile (res < lengthLen) {\n\t\tres *= 2;\n\t}\n\treturn res;\n}\n\n/**\n * Implementation of serialization of blobs in buffer with Marker Codes etc.\n * @param buffer - Buffer to serialize to.\n * @param content - string to be serialized.\n * @param dictionary - Const strings dictionary to be used while serializing.\n */\nfunction serializeDictionaryString(\n\tbuffer: WriteBuffer,\n\tcontent: string,\n\tdictionary: Map<string, number>,\n): void {\n\tlet id = dictionary.get(content);\n\tlet idLength: number;\n\tif (id === undefined) {\n\t\tconst data = IsoBuffer.from(content, \"utf8\");\n\t\tconst lengthOfDataLen = calcLength(data.length);\n\n\t\tid = dictionary.size + 1;\n\t\tidLength = calcLength(id);\n\t\tdictionary.set(content, id);\n\t\tconst code =\n\t\t\tlengthOfDataLen > 1 || idLength > 1\n\t\t\t\t? MarkerCodes.ConstStringDeclareBig\n\t\t\t\t: MarkerCodes.ConstStringDeclare;\n\t\t// Write marker code for const string.\n\t\tbuffer.write(code);\n\t\tconst bytes = getValueSafely(codeToBytesMap, code);\n\t\tassert(\n\t\t\tbytes >= lengthOfDataLen,\n\t\t\t0x283 /* \"Length of data len should fit in the bytes from the map\" */,\n\t\t);\n\t\tassert(bytes >= idLength, 0x284 /* \"Length of id should fit in the bytes from the map\" */);\n\t\t// Assign and write id for const string.\n\t\tbuffer.write(id, bytes);\n\t\t// Write length of const string.\n\t\tbuffer.write(data.length, bytes);\n\t\t// Write const string data.\n\t\tfor (const element of data) {\n\t\t\tbuffer.write(element);\n\t\t}\n\t} else {\n\t\tidLength = calcLength(id);\n\t}\n\t// Write Marker Code\n\tbuffer.write(getValueSafely(constStringBytesToCodeMap, idLength));\n\t// Write id of const string\n\tbuffer.write(id, idLength);\n}\n\nfunction serializeString(\n\tbuffer: WriteBuffer,\n\tcontent: string,\n\tcodeMap = binaryBytesToCodeMap,\n): void {\n\tserializeBlob(buffer, IsoBuffer.from(content, \"utf8\"), utf8StringBytesToCodeMap);\n}\n\n/**\n * Implementation of serialization of blobs in buffer with Marker Codes etc.\n * @param buffer - Buffer to serialize to.\n * @param blob - blob to be serialized.\n * @param dictionary - Const strings dictionary to be used while serializing.\n */\nfunction serializeBlob(\n\tbuffer: WriteBuffer,\n\tdata: Uint8Array,\n\tcodeMap: Record<number, number> = binaryBytesToCodeMap,\n): void {\n\tconst lengthOfDataLen = calcLength(data.length);\n\t// Write Marker code.\n\tbuffer.write(getValueSafely(codeMap, lengthOfDataLen));\n\t// Write actual data if length greater than 0, otherwise Marker Code is enough.\n\tif (lengthOfDataLen > 0) {\n\t\tbuffer.write(data.length, lengthOfDataLen);\n\t\tfor (const element of data) {\n\t\t\tbuffer.write(element);\n\t\t}\n\t}\n}\n\n/**\n * Implementation of serialization of nodes with Marker Codes etc.\n * @param buffer - Buffer to serialize to.\n * @param nodeCore - Node to be serialized.\n * @param dictionary - Const strings dictionary to be used while serializing.\n */\nfunction serializeNodeCore(\n\tbuffer: WriteBuffer,\n\tnodeCore: NodeCore,\n\tdictionary: Map<string, number>,\n): void {\n\tfor (const child of nodeCore.nodes) {\n\t\tif (child instanceof NodeCore) {\n\t\t\t// For a tree node start and end with set/list start and end marker codes.\n\t\t\tconst startCode = MarkerCodesStart[child.type];\n\t\t\tconst endCode = MarkerCodesEnd[child.type];\n\t\t\tassert(startCode !== undefined, 0x285 /* \"Start code should not undefined\" */);\n\t\t\tassert(endCode !== undefined, 0x286 /* \"End code should not undefined\" */);\n\t\t\tbuffer.write(startCode);\n\t\t\tserializeNodeCore(buffer, child, dictionary);\n\t\t\tbuffer.write(endCode);\n\t\t} else if (child instanceof BlobCore) {\n\t\t\tserializeBlob(buffer, child.buffer);\n\t\t} else if (typeof child === \"number\") {\n\t\t\t// Calculate length in which integer will be stored\n\t\t\tconst len = calcLength(child);\n\t\t\t// Write corresponding Marker code for length of integer.\n\t\t\tbuffer.write(getValueSafely(integerBytesToCodeMap, len));\n\t\t\t// Write actual number if greater than 0, otherwise Marker Code is enough.\n\t\t\tif (len > 0) {\n\t\t\t\tbuffer.write(child, len);\n\t\t\t}\n\t\t} else if (typeof child === \"boolean\") {\n\t\t\tbuffer.write(boolToCodeMap[child ? 1 : 0]);\n\t\t} else {\n\t\t\tassert(child._stringElement, 0x3dd /* Unsupported node type */);\n\t\t\tif (child.dictionary) {\n\t\t\t\tserializeDictionaryString(buffer, child.content, dictionary);\n\t\t\t} else {\n\t\t\t\tserializeString(buffer, child.content);\n\t\t\t}\n\t\t}\n\t}\n}\n\nclass NodeCoreSerializer extends NodeCore {\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tpublic serialize(buffer: WriteBuffer): void {\n\t\tserializeNodeCore(buffer, this, new Map<string, number>());\n\t}\n}\n\nexport class TreeBuilderSerializer extends NodeCoreSerializer {\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tpublic serialize(): Uint8Array {\n\t\tconst buffer = new WriteBuffer();\n\t\tsuper.serialize(buffer);\n\t\treturn buffer.done();\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compactSnapshotParser.d.ts","sourceRoot":"","sources":["../src/compactSnapshotParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,SAAS,EAGT,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAgB/E,eAAO,MAAM,sBAAsB,QAAQ,CAAC;AAC5C,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AAExC;;;;GAIG;AACH,MAAM,WAAW,0BAA2B,SAAQ,SAAS;IAC5D,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;
|
|
1
|
+
{"version":3,"file":"compactSnapshotParser.d.ts","sourceRoot":"","sources":["../src/compactSnapshotParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,SAAS,EAGT,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAgB/E,eAAO,MAAM,sBAAsB,QAAQ,CAAC;AAC5C,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AAExC;;;;GAIG;AACH,MAAM,WAAW,0BAA2B,SAAQ,SAAS;IAC5D,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;AA0ND;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC3C,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,mBAAmB,GACzB,0BAA0B,CA8C5B"}
|
|
@@ -36,9 +36,7 @@ function readBlobSection(node) {
|
|
|
36
36
|
*/
|
|
37
37
|
slowBlobStructureCount += 1;
|
|
38
38
|
const records = getNodeProps(blob);
|
|
39
|
-
// TODO why are we non null asserting here?
|
|
40
39
|
assertBlobCoreInstance(records.data, "data should be of BlobCore type");
|
|
41
|
-
// TODO why are we non null asserting here?
|
|
42
40
|
const id = getStringInstance(records.id, "blob id should be string");
|
|
43
41
|
blobContents.set(id, records.data.arrayBuffer);
|
|
44
42
|
}
|
|
@@ -53,9 +51,7 @@ function readOpsSection(node) {
|
|
|
53
51
|
assertNodeCoreInstance(node, "Deltas should be of type NodeCore");
|
|
54
52
|
const ops = [];
|
|
55
53
|
const records = getNodeProps(node);
|
|
56
|
-
// TODO Why are we non null asserting here?
|
|
57
54
|
assertNumberInstance(records.firstSequenceNumber, "Seq number should be a number");
|
|
58
|
-
// TODO Why are we non null asserting here?
|
|
59
55
|
assertNodeCoreInstance(records.deltas, "Deltas should be a Node");
|
|
60
56
|
for (let i = 0; i < records.deltas.length; ++i) {
|
|
61
57
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
@@ -64,9 +60,7 @@ function readOpsSection(node) {
|
|
|
64
60
|
// Due to a bug at service side, in an edge case service was serializing deltas even
|
|
65
61
|
// when there are no ops. So just make the code resilient to that bug. Service has also
|
|
66
62
|
// fixed that bug.
|
|
67
|
-
assert(
|
|
68
|
-
// Non null asserting here because of the length check
|
|
69
|
-
ops.length === 0 || records.firstSequenceNumber.valueOf() === ops[0].sequenceNumber, 0x280 /* "Validate first op seq number" */);
|
|
63
|
+
assert(ops.length === 0 || records.firstSequenceNumber.valueOf() === ops[0].sequenceNumber, 0x280 /* "Validate first op seq number" */);
|
|
70
64
|
return ops;
|
|
71
65
|
}
|
|
72
66
|
/**
|
|
@@ -155,7 +149,6 @@ function readTreeSection(node) {
|
|
|
155
149
|
assert(records.unreferenced, 0x281 /* "Unreferenced if present should be true" */);
|
|
156
150
|
snapshotTree.unreferenced = true;
|
|
157
151
|
}
|
|
158
|
-
// TODO Why are we non null asserting here?
|
|
159
152
|
const path = getStringInstance(records.name, "Path name should be string");
|
|
160
153
|
if (records.value !== undefined) {
|
|
161
154
|
snapshotTree.blobs[path] = getStringInstance(records.value, "Blob value should be string");
|
|
@@ -167,7 +160,6 @@ function readTreeSection(node) {
|
|
|
167
160
|
trees[path] = result.snapshotTree;
|
|
168
161
|
if (records.groupId !== undefined) {
|
|
169
162
|
const groupId = getStringInstance(records.groupId, "groupId should be a string");
|
|
170
|
-
// Non null asserting since trees[path] is already created
|
|
171
163
|
trees[path].groupId = groupId;
|
|
172
164
|
treeStructureCountWithGroupId++;
|
|
173
165
|
}
|
|
@@ -187,12 +179,9 @@ function readTreeSection(node) {
|
|
|
187
179
|
function readSnapshotSection(node) {
|
|
188
180
|
assertNodeCoreInstance(node, "Snapshot should be of type NodeCore");
|
|
189
181
|
const records = getNodeProps(node);
|
|
190
|
-
// TODO Why are we non null asserting here?
|
|
191
182
|
assertNodeCoreInstance(records.treeNodes, "TreeNodes should be of type NodeCore");
|
|
192
|
-
// TODO Why are we non null asserting here?
|
|
193
183
|
assertNumberInstance(records.sequenceNumber, "sequenceNumber should be of type number");
|
|
194
184
|
const { snapshotTree, slowTreeStructureCount, treeStructureCountWithGroupId } = readTreeSection(records.treeNodes);
|
|
195
|
-
// TODO Why are we non null asserting here?
|
|
196
185
|
snapshotTree.id = getStringInstance(records.id, "snapshotId should be string");
|
|
197
186
|
const sequenceNumber = records.sequenceNumber.valueOf();
|
|
198
187
|
return {
|
|
@@ -213,9 +202,7 @@ export function parseCompactSnapshotResponse(buffer, logger) {
|
|
|
213
202
|
assert(builder.length === 1, 0x219 /* "1 root should be there" */);
|
|
214
203
|
const root = builder.getNode(0);
|
|
215
204
|
const records = getNodeProps(root);
|
|
216
|
-
// TODO Why are we non null asserting here?
|
|
217
205
|
const mrv = getStringInstance(records.mrv, "minReadVersion should be string");
|
|
218
|
-
// TODO Why are we non null asserting here?
|
|
219
206
|
const cv = getStringInstance(records.cv, "createVersion should be string");
|
|
220
207
|
if (records.lsn !== undefined) {
|
|
221
208
|
assertNumberInstance(records.lsn, "lsn should be a number");
|
|
@@ -223,10 +210,7 @@ export function parseCompactSnapshotResponse(buffer, logger) {
|
|
|
223
210
|
assert(Number.parseFloat(snapshotMinReadVersion) >= Number.parseFloat(mrv), 0x20f /* "Driver min read version should >= to server minReadVersion" */);
|
|
224
211
|
assert(Number.parseFloat(cv) >= Number.parseFloat(snapshotMinReadVersion), 0x210 /* "Snapshot should be created with minReadVersion or above" */);
|
|
225
212
|
assert(currentReadVersion === cv, 0x2c2 /* "Create Version should be equal to currentReadVersion" */);
|
|
226
|
-
const [snapshot, durationSnapshotTree] = measure(() =>
|
|
227
|
-
// TODO Why are we non null asserting here?
|
|
228
|
-
readSnapshotSection(records.snapshot));
|
|
229
|
-
// TODO Why are we non null asserting here?
|
|
213
|
+
const [snapshot, durationSnapshotTree] = measure(() => readSnapshotSection(records.snapshot));
|
|
230
214
|
const [blobContents, durationBlobs] = measure(() => readBlobSection(records.blobs));
|
|
231
215
|
return {
|
|
232
216
|
...snapshot,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compactSnapshotParser.js","sourceRoot":"","sources":["../src/compactSnapshotParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAQ7D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAGN,WAAW,EACX,sBAAsB,EACtB,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,GACjB,MAAM,mCAAmC,CAAC;AAE3C,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAC5C,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAWxC;;;GAGG;AACH,SAAS,eAAe,CAAC,IAAe;IAIvC,sBAAsB,CAAC,IAAI,EAAE,sCAAsC,CAAC,CAAC;IACrE,IAAI,sBAAsB,GAAG,CAAC,CAAC;IAC/B,MAAM,YAAY,GAA6B,IAAI,GAAG,EAAE,CAAC;IACzD,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACzB,sBAAsB,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC;QAEpD;;;;WAIG;QACH,IACC,IAAI,CAAC,MAAM,KAAK,CAAC;YACjB,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,KAA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,GAAG,OAAO,CAAC,GAAG,EAAE;IACrD,2CAA2C;IAC3C,mBAAmB,CAAC,OAAO,CAAC,QAAS,CAAC,CACtC,CAAC;IACF,2CAA2C;IAC3C,MAAM,CAAC,YAAY,EAAE,aAAa,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,KAAM,CAAC,CAAC,CAAC;IAErF,OAAO;QACN,GAAG,QAAQ;QACX,YAAY,EAAE,YAAY,CAAC,YAAY;QACvC,GAAG,EAAE,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC;QACvE,oBAAoB,EAAE,OAAO,CAAC,GAAG;QACjC,eAAe,EAAE,CAAC;QAClB,cAAc,EAAE;YACf,GAAG,cAAc;YACjB,oBAAoB;YACpB,aAAa;YACb,sBAAsB,EAAE,QAAQ,CAAC,sBAAsB;YACvD,sBAAsB,EAAE,YAAY,CAAC,sBAAsB;YAC3D,6BAA6B,EAAE,QAAQ,CAAC,6BAA6B;SACrE;KACD,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tISnapshot,\n\tISnapshotTree,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { ReadBuffer } from \"./ReadBufferUtils.js\";\nimport { measure } from \"./odspUtils.js\";\nimport {\n\tNodeCore,\n\tNodeTypes,\n\tTreeBuilder,\n\tassertBlobCoreInstance,\n\tassertBoolInstance,\n\tassertNodeCoreInstance,\n\tassertNumberInstance,\n\tgetNodeProps,\n\tgetStringInstance,\n} from \"./zipItDataRepresentationUtils.js\";\n\nexport const snapshotMinReadVersion = \"1.0\";\nexport const currentReadVersion = \"1.0\";\n\n/**\n * The parsing is significantly faster if the position of props is well known instead of dynamic. So these variables\n * represents how many times slower parsing path is executed. This will be then logged into telemetry.\n * @internal\n */\nexport interface ISnapshotContentsWithProps extends ISnapshot {\n\ttelemetryProps: Record<string, number>;\n}\n\n/**\n * Recreates blobs section of the tree.\n * @param node - tree node to read blob section from\n */\nfunction readBlobSection(node: NodeTypes): {\n\tblobContents: Map<string, ArrayBuffer>;\n\tslowBlobStructureCount: number;\n} {\n\tassertNodeCoreInstance(node, \"TreeBlobs should be of type NodeCore\");\n\tlet slowBlobStructureCount = 0;\n\tconst blobContents: Map<string, ArrayBuffer> = new Map();\n\tfor (const blob of node) {\n\t\tassertNodeCoreInstance(blob, \"blob should be node\");\n\n\t\t/**\n\t\t * Perf optimization - the most common cases!\n\t\t * This is essentially unrolling code below for faster processing\n\t\t * It speeds up tree parsing by 2-3x times!\n\t\t */\n\t\tif (\n\t\t\tblob.length === 4 &&\n\t\t\tblob.getMaybeString(0) === \"id\" &&\n\t\t\tblob.getMaybeString(2) === \"data\"\n\t\t) {\n\t\t\t// \"id\": <node name>\n\t\t\t// \"data\": <blob>\n\t\t\tblobContents.set(blob.getString(1), blob.getBlob(3).arrayBuffer);\n\t\t} else {\n\t\t\t/**\n\t\t\t * More generalized workflow\n\t\t\t */\n\t\t\tslowBlobStructureCount += 1;\n\t\t\tconst records = getNodeProps(blob);\n\t\t\t// TODO why are we non null asserting here?\n\t\t\tassertBlobCoreInstance(records.data!, \"data should be of BlobCore type\");\n\t\t\t// TODO why are we non null asserting here?\n\t\t\tconst id = getStringInstance(records.id!, \"blob id should be string\");\n\t\t\tblobContents.set(id, records.data.arrayBuffer);\n\t\t}\n\t}\n\treturn { blobContents, slowBlobStructureCount };\n}\n\n/**\n * Recreates ops section of the tree.\n * @param node - tree node to read ops section from\n */\nfunction readOpsSection(node: NodeTypes): ISequencedDocumentMessage[] {\n\tassertNodeCoreInstance(node, \"Deltas should be of type NodeCore\");\n\tconst ops: ISequencedDocumentMessage[] = [];\n\tconst records = getNodeProps(node);\n\t// TODO Why are we non null asserting here?\n\tassertNumberInstance(records.firstSequenceNumber!, \"Seq number should be a number\");\n\t// TODO Why are we non null asserting here?\n\tassertNodeCoreInstance(records.deltas!, \"Deltas should be a Node\");\n\tfor (let i = 0; i < records.deltas.length; ++i) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\tops.push(JSON.parse(records.deltas.getString(i)));\n\t}\n\t// Due to a bug at service side, in an edge case service was serializing deltas even\n\t// when there are no ops. So just make the code resilient to that bug. Service has also\n\t// fixed that bug.\n\tassert(\n\t\t// Non null asserting here because of the length check\n\t\tops.length === 0 || records.firstSequenceNumber.valueOf() === ops[0]!.sequenceNumber,\n\t\t0x280 /* \"Validate first op seq number\" */,\n\t);\n\treturn ops;\n}\n\n/**\n * Recreates snapshot tree out of tree representation.\n * @param node - tree node to de-serialize from\n */\nfunction readTreeSection(node: NodeCore): {\n\tsnapshotTree: ISnapshotTree;\n\tslowTreeStructureCount: number;\n\ttreeStructureCountWithGroupId: number;\n} {\n\tlet slowTreeStructureCount = 0;\n\tlet treeStructureCountWithGroupId = 0;\n\tconst trees: Record<string, ISnapshotTree> = {};\n\tconst snapshotTree: ISnapshotTree = {\n\t\tblobs: {},\n\t\ttrees,\n\t};\n\tfor (const treeNode of node) {\n\t\tassertNodeCoreInstance(treeNode, \"tree nodes should be nodes\");\n\n\t\t/**\n\t\t * Perf optimization - the most common cases!\n\t\t * This is essentially unrolling code below for faster processing\n\t\t * It speeds up tree parsing by 2-3x times!\n\t\t */\n\t\tconst length = treeNode.length;\n\t\tif (length > 0 && treeNode.getMaybeString(0) === \"name\") {\n\t\t\tswitch (length) {\n\t\t\t\tcase 2: {\n\t\t\t\t\t// empty tree case\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\ttrees[treeNode.getString(1)] = { blobs: {}, trees: {} };\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase 4: {\n\t\t\t\t\tconst content = treeNode.getMaybeString(2);\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"children\": <blob id>\n\t\t\t\t\tif (content === \"children\") {\n\t\t\t\t\t\tconst result = readTreeSection(treeNode.getNode(3));\n\t\t\t\t\t\ttrees[treeNode.getString(1)] = result.snapshotTree;\n\t\t\t\t\t\tslowTreeStructureCount += result.slowTreeStructureCount;\n\t\t\t\t\t\ttreeStructureCountWithGroupId += result.treeStructureCountWithGroupId;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"value\": <blob id>\n\t\t\t\t\tif (content === \"value\") {\n\t\t\t\t\t\tsnapshotTree.blobs[treeNode.getString(1)] = treeNode.getString(3);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 6: {\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"nodeType\": 3\n\t\t\t\t\t// \"value\": <blob id>\n\t\t\t\t\tif (\n\t\t\t\t\t\ttreeNode.getMaybeString(2) === \"nodeType\" &&\n\t\t\t\t\t\ttreeNode.getMaybeString(4) === \"value\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tsnapshotTree.blobs[treeNode.getString(1)] = treeNode.getString(5);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"unreferenced\": true\n\t\t\t\t\t// \"children\": <blob id>\n\t\t\t\t\tif (\n\t\t\t\t\t\ttreeNode.getMaybeString(2) === \"unreferenced\" &&\n\t\t\t\t\t\ttreeNode.getMaybeString(4) === \"children\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst result = readTreeSection(treeNode.getNode(5));\n\t\t\t\t\t\ttrees[treeNode.getString(1)] = result.snapshotTree;\n\t\t\t\t\t\tslowTreeStructureCount += result.slowTreeStructureCount;\n\t\t\t\t\t\ttreeStructureCountWithGroupId += result.treeStructureCountWithGroupId;\n\t\t\t\t\t\tassert(treeNode.getBool(3), 0x3db /* Unreferenced if present should be true */);\n\t\t\t\t\t\tsnapshotTree.unreferenced = true;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * More generalized workflow\n\t\t */\n\t\tslowTreeStructureCount++;\n\t\tconst records = getNodeProps(treeNode);\n\n\t\tif (records.unreferenced !== undefined) {\n\t\t\tassertBoolInstance(records.unreferenced, \"Unreferenced flag should be bool\");\n\t\t\tassert(records.unreferenced, 0x281 /* \"Unreferenced if present should be true\" */);\n\t\t\tsnapshotTree.unreferenced = true;\n\t\t}\n\n\t\t// TODO Why are we non null asserting here?\n\t\tconst path = getStringInstance(records.name!, \"Path name should be string\");\n\t\tif (records.value !== undefined) {\n\t\t\tsnapshotTree.blobs[path] = getStringInstance(\n\t\t\t\trecords.value,\n\t\t\t\t\"Blob value should be string\",\n\t\t\t);\n\t\t\t// eslint-disable-next-line unicorn/no-negated-condition\n\t\t} else if (records.children !== undefined) {\n\t\t\tassertNodeCoreInstance(records.children, \"Trees should be of type NodeCore\");\n\t\t\tconst result = readTreeSection(records.children);\n\t\t\ttrees[path] = result.snapshotTree;\n\t\t\tif (records.groupId !== undefined) {\n\t\t\t\tconst groupId = getStringInstance(records.groupId, \"groupId should be a string\");\n\t\t\t\t// Non null asserting since trees[path] is already created\n\t\t\t\ttrees[path]!.groupId = groupId;\n\t\t\t\ttreeStructureCountWithGroupId++;\n\t\t\t}\n\t\t\tslowTreeStructureCount += result.slowTreeStructureCount;\n\t\t\ttreeStructureCountWithGroupId += result.treeStructureCountWithGroupId;\n\t\t} else {\n\t\t\ttrees[path] = { blobs: {}, trees: {} };\n\t\t}\n\t}\n\treturn { snapshotTree, slowTreeStructureCount, treeStructureCountWithGroupId };\n}\n\n/**\n * Recreates snapshot tree out of tree representation.\n * @param node - tree node to de-serialize from\n */\nfunction readSnapshotSection(node: NodeTypes): {\n\tsequenceNumber: number;\n\tsnapshotTree: ISnapshotTree;\n\tslowTreeStructureCount: number;\n\ttreeStructureCountWithGroupId: number;\n} {\n\tassertNodeCoreInstance(node, \"Snapshot should be of type NodeCore\");\n\tconst records = getNodeProps(node);\n\n\t// TODO Why are we non null asserting here?\n\tassertNodeCoreInstance(records.treeNodes!, \"TreeNodes should be of type NodeCore\");\n\t// TODO Why are we non null asserting here?\n\tassertNumberInstance(records.sequenceNumber!, \"sequenceNumber should be of type number\");\n\tconst { snapshotTree, slowTreeStructureCount, treeStructureCountWithGroupId } =\n\t\treadTreeSection(records.treeNodes);\n\t// TODO Why are we non null asserting here?\n\tsnapshotTree.id = getStringInstance(records.id!, \"snapshotId should be string\");\n\tconst sequenceNumber = records.sequenceNumber.valueOf();\n\treturn {\n\t\tsequenceNumber,\n\t\tsnapshotTree,\n\t\tslowTreeStructureCount,\n\t\ttreeStructureCountWithGroupId,\n\t};\n}\n\n/**\n * Converts snapshot from binary compact representation to tree/blobs/ops.\n * @param buffer - Compact snapshot to be parsed into tree/blobs/ops.\n * @returns Tree, blobs and ops from the snapshot.\n * @internal\n */\nexport function parseCompactSnapshotResponse(\n\tbuffer: Uint8Array,\n\tlogger: ITelemetryLoggerExt,\n): ISnapshotContentsWithProps {\n\tconst { builder, telemetryProps } = TreeBuilder.load(new ReadBuffer(buffer), logger);\n\tassert(builder.length === 1, 0x219 /* \"1 root should be there\" */);\n\tconst root = builder.getNode(0);\n\n\tconst records = getNodeProps(root);\n\n\t// TODO Why are we non null asserting here?\n\tconst mrv = getStringInstance(records.mrv!, \"minReadVersion should be string\");\n\t// TODO Why are we non null asserting here?\n\tconst cv = getStringInstance(records.cv!, \"createVersion should be string\");\n\tif (records.lsn !== undefined) {\n\t\tassertNumberInstance(records.lsn, \"lsn should be a number\");\n\t}\n\n\tassert(\n\t\tNumber.parseFloat(snapshotMinReadVersion) >= Number.parseFloat(mrv),\n\t\t0x20f /* \"Driver min read version should >= to server minReadVersion\" */,\n\t);\n\tassert(\n\t\tNumber.parseFloat(cv) >= Number.parseFloat(snapshotMinReadVersion),\n\t\t0x210 /* \"Snapshot should be created with minReadVersion or above\" */,\n\t);\n\tassert(\n\t\tcurrentReadVersion === cv,\n\t\t0x2c2 /* \"Create Version should be equal to currentReadVersion\" */,\n\t);\n\n\tconst [snapshot, durationSnapshotTree] = measure(() =>\n\t\t// TODO Why are we non null asserting here?\n\t\treadSnapshotSection(records.snapshot!),\n\t);\n\t// TODO Why are we non null asserting here?\n\tconst [blobContents, durationBlobs] = measure(() => readBlobSection(records.blobs!));\n\n\treturn {\n\t\t...snapshot,\n\t\tblobContents: blobContents.blobContents,\n\t\tops: records.deltas === undefined ? [] : readOpsSection(records.deltas),\n\t\tlatestSequenceNumber: records.lsn,\n\t\tsnapshotFormatV: 1,\n\t\ttelemetryProps: {\n\t\t\t...telemetryProps,\n\t\t\tdurationSnapshotTree,\n\t\t\tdurationBlobs,\n\t\t\tslowTreeStructureCount: snapshot.slowTreeStructureCount,\n\t\t\tslowBlobStructureCount: blobContents.slowBlobStructureCount,\n\t\t\ttreeStructureCountWithGroupId: snapshot.treeStructureCountWithGroupId,\n\t\t},\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"compactSnapshotParser.js","sourceRoot":"","sources":["../src/compactSnapshotParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAQ7D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAGN,WAAW,EACX,sBAAsB,EACtB,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,GACjB,MAAM,mCAAmC,CAAC;AAE3C,MAA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AAC,EACnE,KAAK,CAAC,kEAAkE,CACxE,CAAC;IACF,MAAM,CACL,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,UAAU,CAAC,sBAAsB,CAAC,EAClE,KAAK,CAAC,+DAA+D,CACrE,CAAC;IACF,MAAM,CACL,kBAAkB,KAAK,EAAE,EACzB,KAAK,CAAC,4DAA4D,CAClE,CAAC;IAEF,MAAM,CAAC,QAAQ,EAAE,oBAAoB,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE,CACrD,mBAAmB,CAAC,OAAO,CAAC,QAAQ,CAAC,CACrC,CAAC;IACF,MAAM,CAAC,YAAY,EAAE,aAAa,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IAEpF,OAAO;QACN,GAAG,QAAQ;QACX,YAAY,EAAE,YAAY,CAAC,YAAY;QACvC,GAAG,EAAE,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC;QACvE,oBAAoB,EAAE,OAAO,CAAC,GAAG;QACjC,eAAe,EAAE,CAAC;QAClB,cAAc,EAAE;YACf,GAAG,cAAc;YACjB,oBAAoB;YACpB,aAAa;YACb,sBAAsB,EAAE,QAAQ,CAAC,sBAAsB;YACvD,sBAAsB,EAAE,YAAY,CAAC,sBAAsB;YAC3D,6BAA6B,EAAE,QAAQ,CAAC,6BAA6B;SACrE;KACD,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tISnapshot,\n\tISnapshotTree,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { ReadBuffer } from \"./ReadBufferUtils.js\";\nimport { measure } from \"./odspUtils.js\";\nimport {\n\tNodeCore,\n\tNodeTypes,\n\tTreeBuilder,\n\tassertBlobCoreInstance,\n\tassertBoolInstance,\n\tassertNodeCoreInstance,\n\tassertNumberInstance,\n\tgetNodeProps,\n\tgetStringInstance,\n} from \"./zipItDataRepresentationUtils.js\";\n\nexport const snapshotMinReadVersion = \"1.0\";\nexport const currentReadVersion = \"1.0\";\n\n/**\n * The parsing is significantly faster if the position of props is well known instead of dynamic. So these variables\n * represents how many times slower parsing path is executed. This will be then logged into telemetry.\n * @internal\n */\nexport interface ISnapshotContentsWithProps extends ISnapshot {\n\ttelemetryProps: Record<string, number>;\n}\n\n/**\n * Recreates blobs section of the tree.\n * @param node - tree node to read blob section from\n */\nfunction readBlobSection(node: NodeTypes): {\n\tblobContents: Map<string, ArrayBuffer>;\n\tslowBlobStructureCount: number;\n} {\n\tassertNodeCoreInstance(node, \"TreeBlobs should be of type NodeCore\");\n\tlet slowBlobStructureCount = 0;\n\tconst blobContents: Map<string, ArrayBuffer> = new Map();\n\tfor (const blob of node) {\n\t\tassertNodeCoreInstance(blob, \"blob should be node\");\n\n\t\t/**\n\t\t * Perf optimization - the most common cases!\n\t\t * This is essentially unrolling code below for faster processing\n\t\t * It speeds up tree parsing by 2-3x times!\n\t\t */\n\t\tif (\n\t\t\tblob.length === 4 &&\n\t\t\tblob.getMaybeString(0) === \"id\" &&\n\t\t\tblob.getMaybeString(2) === \"data\"\n\t\t) {\n\t\t\t// \"id\": <node name>\n\t\t\t// \"data\": <blob>\n\t\t\tblobContents.set(blob.getString(1), blob.getBlob(3).arrayBuffer);\n\t\t} else {\n\t\t\t/**\n\t\t\t * More generalized workflow\n\t\t\t */\n\t\t\tslowBlobStructureCount += 1;\n\t\t\tconst records = getNodeProps(blob);\n\t\t\tassertBlobCoreInstance(records.data, \"data should be of BlobCore type\");\n\t\t\tconst id = getStringInstance(records.id, \"blob id should be string\");\n\t\t\tblobContents.set(id, records.data.arrayBuffer);\n\t\t}\n\t}\n\treturn { blobContents, slowBlobStructureCount };\n}\n\n/**\n * Recreates ops section of the tree.\n * @param node - tree node to read ops section from\n */\nfunction readOpsSection(node: NodeTypes): ISequencedDocumentMessage[] {\n\tassertNodeCoreInstance(node, \"Deltas should be of type NodeCore\");\n\tconst ops: ISequencedDocumentMessage[] = [];\n\tconst records = getNodeProps(node);\n\tassertNumberInstance(records.firstSequenceNumber, \"Seq number should be a number\");\n\tassertNodeCoreInstance(records.deltas, \"Deltas should be a Node\");\n\tfor (let i = 0; i < records.deltas.length; ++i) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\tops.push(JSON.parse(records.deltas.getString(i)));\n\t}\n\t// Due to a bug at service side, in an edge case service was serializing deltas even\n\t// when there are no ops. So just make the code resilient to that bug. Service has also\n\t// fixed that bug.\n\tassert(\n\t\tops.length === 0 || records.firstSequenceNumber.valueOf() === ops[0].sequenceNumber,\n\t\t0x280 /* \"Validate first op seq number\" */,\n\t);\n\treturn ops;\n}\n\n/**\n * Recreates snapshot tree out of tree representation.\n * @param node - tree node to de-serialize from\n */\nfunction readTreeSection(node: NodeCore): {\n\tsnapshotTree: ISnapshotTree;\n\tslowTreeStructureCount: number;\n\ttreeStructureCountWithGroupId: number;\n} {\n\tlet slowTreeStructureCount = 0;\n\tlet treeStructureCountWithGroupId = 0;\n\tconst trees: Record<string, ISnapshotTree> = {};\n\tconst snapshotTree: ISnapshotTree = {\n\t\tblobs: {},\n\t\ttrees,\n\t};\n\tfor (const treeNode of node) {\n\t\tassertNodeCoreInstance(treeNode, \"tree nodes should be nodes\");\n\n\t\t/**\n\t\t * Perf optimization - the most common cases!\n\t\t * This is essentially unrolling code below for faster processing\n\t\t * It speeds up tree parsing by 2-3x times!\n\t\t */\n\t\tconst length = treeNode.length;\n\t\tif (length > 0 && treeNode.getMaybeString(0) === \"name\") {\n\t\t\tswitch (length) {\n\t\t\t\tcase 2: {\n\t\t\t\t\t// empty tree case\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\ttrees[treeNode.getString(1)] = { blobs: {}, trees: {} };\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase 4: {\n\t\t\t\t\tconst content = treeNode.getMaybeString(2);\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"children\": <blob id>\n\t\t\t\t\tif (content === \"children\") {\n\t\t\t\t\t\tconst result = readTreeSection(treeNode.getNode(3));\n\t\t\t\t\t\ttrees[treeNode.getString(1)] = result.snapshotTree;\n\t\t\t\t\t\tslowTreeStructureCount += result.slowTreeStructureCount;\n\t\t\t\t\t\ttreeStructureCountWithGroupId += result.treeStructureCountWithGroupId;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"value\": <blob id>\n\t\t\t\t\tif (content === \"value\") {\n\t\t\t\t\t\tsnapshotTree.blobs[treeNode.getString(1)] = treeNode.getString(3);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 6: {\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"nodeType\": 3\n\t\t\t\t\t// \"value\": <blob id>\n\t\t\t\t\tif (\n\t\t\t\t\t\ttreeNode.getMaybeString(2) === \"nodeType\" &&\n\t\t\t\t\t\ttreeNode.getMaybeString(4) === \"value\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tsnapshotTree.blobs[treeNode.getString(1)] = treeNode.getString(5);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"unreferenced\": true\n\t\t\t\t\t// \"children\": <blob id>\n\t\t\t\t\tif (\n\t\t\t\t\t\ttreeNode.getMaybeString(2) === \"unreferenced\" &&\n\t\t\t\t\t\ttreeNode.getMaybeString(4) === \"children\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst result = readTreeSection(treeNode.getNode(5));\n\t\t\t\t\t\ttrees[treeNode.getString(1)] = result.snapshotTree;\n\t\t\t\t\t\tslowTreeStructureCount += result.slowTreeStructureCount;\n\t\t\t\t\t\ttreeStructureCountWithGroupId += result.treeStructureCountWithGroupId;\n\t\t\t\t\t\tassert(treeNode.getBool(3), 0x3db /* Unreferenced if present should be true */);\n\t\t\t\t\t\tsnapshotTree.unreferenced = true;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * More generalized workflow\n\t\t */\n\t\tslowTreeStructureCount++;\n\t\tconst records = getNodeProps(treeNode);\n\n\t\tif (records.unreferenced !== undefined) {\n\t\t\tassertBoolInstance(records.unreferenced, \"Unreferenced flag should be bool\");\n\t\t\tassert(records.unreferenced, 0x281 /* \"Unreferenced if present should be true\" */);\n\t\t\tsnapshotTree.unreferenced = true;\n\t\t}\n\n\t\tconst path = getStringInstance(records.name, \"Path name should be string\");\n\t\tif (records.value !== undefined) {\n\t\t\tsnapshotTree.blobs[path] = getStringInstance(\n\t\t\t\trecords.value,\n\t\t\t\t\"Blob value should be string\",\n\t\t\t);\n\t\t\t// eslint-disable-next-line unicorn/no-negated-condition\n\t\t} else if (records.children !== undefined) {\n\t\t\tassertNodeCoreInstance(records.children, \"Trees should be of type NodeCore\");\n\t\t\tconst result = readTreeSection(records.children);\n\t\t\ttrees[path] = result.snapshotTree;\n\t\t\tif (records.groupId !== undefined) {\n\t\t\t\tconst groupId = getStringInstance(records.groupId, \"groupId should be a string\");\n\t\t\t\ttrees[path].groupId = groupId;\n\t\t\t\ttreeStructureCountWithGroupId++;\n\t\t\t}\n\t\t\tslowTreeStructureCount += result.slowTreeStructureCount;\n\t\t\ttreeStructureCountWithGroupId += result.treeStructureCountWithGroupId;\n\t\t} else {\n\t\t\ttrees[path] = { blobs: {}, trees: {} };\n\t\t}\n\t}\n\treturn { snapshotTree, slowTreeStructureCount, treeStructureCountWithGroupId };\n}\n\n/**\n * Recreates snapshot tree out of tree representation.\n * @param node - tree node to de-serialize from\n */\nfunction readSnapshotSection(node: NodeTypes): {\n\tsequenceNumber: number;\n\tsnapshotTree: ISnapshotTree;\n\tslowTreeStructureCount: number;\n\ttreeStructureCountWithGroupId: number;\n} {\n\tassertNodeCoreInstance(node, \"Snapshot should be of type NodeCore\");\n\tconst records = getNodeProps(node);\n\n\tassertNodeCoreInstance(records.treeNodes, \"TreeNodes should be of type NodeCore\");\n\tassertNumberInstance(records.sequenceNumber, \"sequenceNumber should be of type number\");\n\tconst { snapshotTree, slowTreeStructureCount, treeStructureCountWithGroupId } =\n\t\treadTreeSection(records.treeNodes);\n\tsnapshotTree.id = getStringInstance(records.id, \"snapshotId should be string\");\n\tconst sequenceNumber = records.sequenceNumber.valueOf();\n\treturn {\n\t\tsequenceNumber,\n\t\tsnapshotTree,\n\t\tslowTreeStructureCount,\n\t\ttreeStructureCountWithGroupId,\n\t};\n}\n\n/**\n * Converts snapshot from binary compact representation to tree/blobs/ops.\n * @param buffer - Compact snapshot to be parsed into tree/blobs/ops.\n * @returns Tree, blobs and ops from the snapshot.\n * @internal\n */\nexport function parseCompactSnapshotResponse(\n\tbuffer: Uint8Array,\n\tlogger: ITelemetryLoggerExt,\n): ISnapshotContentsWithProps {\n\tconst { builder, telemetryProps } = TreeBuilder.load(new ReadBuffer(buffer), logger);\n\tassert(builder.length === 1, 0x219 /* \"1 root should be there\" */);\n\tconst root = builder.getNode(0);\n\n\tconst records = getNodeProps(root);\n\n\tconst mrv = getStringInstance(records.mrv, \"minReadVersion should be string\");\n\tconst cv = getStringInstance(records.cv, \"createVersion should be string\");\n\tif (records.lsn !== undefined) {\n\t\tassertNumberInstance(records.lsn, \"lsn should be a number\");\n\t}\n\n\tassert(\n\t\tNumber.parseFloat(snapshotMinReadVersion) >= Number.parseFloat(mrv),\n\t\t0x20f /* \"Driver min read version should >= to server minReadVersion\" */,\n\t);\n\tassert(\n\t\tNumber.parseFloat(cv) >= Number.parseFloat(snapshotMinReadVersion),\n\t\t0x210 /* \"Snapshot should be created with minReadVersion or above\" */,\n\t);\n\tassert(\n\t\tcurrentReadVersion === cv,\n\t\t0x2c2 /* \"Create Version should be equal to currentReadVersion\" */,\n\t);\n\n\tconst [snapshot, durationSnapshotTree] = measure(() =>\n\t\treadSnapshotSection(records.snapshot),\n\t);\n\tconst [blobContents, durationBlobs] = measure(() => readBlobSection(records.blobs));\n\n\treturn {\n\t\t...snapshot,\n\t\tblobContents: blobContents.blobContents,\n\t\tops: records.deltas === undefined ? [] : readOpsSection(records.deltas),\n\t\tlatestSequenceNumber: records.lsn,\n\t\tsnapshotFormatV: 1,\n\t\ttelemetryProps: {\n\t\t\t...telemetryProps,\n\t\t\tdurationSnapshotTree,\n\t\t\tdurationBlobs,\n\t\t\tslowTreeStructureCount: snapshot.slowTreeStructureCount,\n\t\t\tslowBlobStructureCount: blobContents.slowBlobStructureCount,\n\t\t\ttreeStructureCountWithGroupId: snapshot.treeStructureCountWithGroupId,\n\t\t},\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compactSnapshotWriter.d.ts","sourceRoot":"","sources":["../src/compactSnapshotWriter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,SAAS,EAIT,MAAM,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"compactSnapshotWriter.d.ts","sourceRoot":"","sources":["../src/compactSnapshotWriter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,SAAS,EAIT,MAAM,6CAA6C,CAAC;AAsIrD;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,gBAAgB,EAAE,SAAS,GAAG,UAAU,CAgChF"}
|
|
@@ -101,7 +101,6 @@ function writeSnapshotSection(rootNode, snapshotTree, snapshotSequenceNumber) {
|
|
|
101
101
|
function writeOpsSection(rootNode, ops) {
|
|
102
102
|
let firstSequenceNumber;
|
|
103
103
|
if (ops.length > 0) {
|
|
104
|
-
// Non null asserting here because of the length check above
|
|
105
104
|
firstSequenceNumber = ops[0].sequenceNumber;
|
|
106
105
|
}
|
|
107
106
|
if (firstSequenceNumber !== undefined) {
|
|
@@ -129,8 +128,7 @@ export function convertToCompactSnapshot(snapshotContents) {
|
|
|
129
128
|
if (latestSequenceNumber === undefined) {
|
|
130
129
|
latestSequenceNumber =
|
|
131
130
|
snapshotContents.ops.length > 0
|
|
132
|
-
?
|
|
133
|
-
snapshotContents.ops[snapshotContents.ops.length - 1].sequenceNumber
|
|
131
|
+
? snapshotContents.ops[snapshotContents.ops.length - 1].sequenceNumber
|
|
134
132
|
: snapshotContents.sequenceNumber;
|
|
135
133
|
}
|
|
136
134
|
writeSnapshotProps(rootNode, latestSequenceNumber);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compactSnapshotWriter.js","sourceRoot":"","sources":["../src/compactSnapshotWriter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAQ7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAEN,eAAe,EACf,2BAA2B,EAC3B,iBAAiB,EACjB,iBAAiB,GACjB,MAAM,mCAAmC,CAAC;AAE3C;;;;GAIG;AACH,SAAS,kBAAkB,CAAC,IAAc,EAAE,oBAA4B;IACvE,iBAAiB,CAAC,IAAI,EAAE,KAAK,EAAE,sBAAsB,CAAC,CAAC;IACvD,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,sBAAsB,CAAC,CAAC;IACtD,iBAAiB,CAAC,IAAI,EAAE,KAAK,EAA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AED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,gBAA2B;IACnE,MAAM,OAAO,GAAG,IAAI,qBAAqB,EAAE,CAAC;IAC5C,wBAAwB;IACxB,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IACnC,MAAM,CACL,gBAAgB,CAAC,cAAc,KAAK,SAAS,EAC7C,KAAK,CAAC,qCAAqC,CAC3C,CAAC;IAEF,IAAI,oBAAoB,GAAG,gBAAgB,CAAC,oBAAoB,CAAC;IACjE,IAAI,oBAAoB,KAAK,SAAS,EAAE,CAAC;QACxC,oBAAoB;YACnB,gBAAgB,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC;gBAC9B,CAAC,CAAC,4DAA4D;oBAC7D,gBAAgB,CAAC,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC,cAAc;gBACtE,CAAC,CAAC,gBAAgB,CAAC,cAAc,CAAC;IACrC,CAAC;IAED,kBAAkB,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;IAEnD,oBAAoB,CACnB,QAAQ,EACR,gBAAgB,CAAC,YAAY,EAC7B,gBAAgB,CAAC,cAAc,CAC/B,CAAC;IAEF,YAAY;IACZ,iBAAiB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAE3D,2BAA2B;IAC3B,eAAe,CAAC,QAAQ,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAEhD,OAAO,OAAO,CAAC,SAAS,EAAE,CAAC;AAC5B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { stringToBuffer } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tISnapshot,\n\tIBlob,\n\tISnapshotTree,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\n\nimport { TreeBuilderSerializer } from \"./WriteBufferUtils.js\";\nimport { snapshotMinReadVersion } from \"./compactSnapshotParser.js\";\nimport {\n\tNodeCore,\n\taddBoolProperty,\n\taddDictionaryStringProperty,\n\taddNumberProperty,\n\taddStringProperty,\n} from \"./zipItDataRepresentationUtils.js\";\n\n/**\n * Writes header section of the snapshot.\n * @param node - snapshot node to serialize to\n * @param latestSequenceNumber - latest seq number of the container.\n */\nfunction writeSnapshotProps(node: NodeCore, latestSequenceNumber: number): void {\n\taddStringProperty(node, \"mrv\", snapshotMinReadVersion);\n\taddStringProperty(node, \"cv\", snapshotMinReadVersion);\n\taddNumberProperty(node, \"lsn\", latestSequenceNumber);\n}\n\n/**\n * Represents blobs in the tree.\n * @param snapshotNode - node to serialize to.\n * @param blobs - blobs that is being serialized\n */\nfunction writeBlobsSection(\n\tsnapshotNode: NodeCore,\n\tblobs: Map<string, IBlob | ArrayBuffer>,\n): void {\n\tsnapshotNode.addDictionaryString(\"blobs\");\n\tconst blobsNode = snapshotNode.addNode(\"list\");\n\tfor (const [storageBlobId, blob] of blobs) {\n\t\tconst blobNode = blobsNode.addNode();\n\t\taddDictionaryStringProperty(blobNode, \"id\", storageBlobId);\n\t\tblobNode.addString(\"data\");\n\t\tif (blob instanceof ArrayBuffer) {\n\t\t\tblobNode.addBlob(new Uint8Array(blob));\n\t\t} else {\n\t\t\tblobNode.addBlob(new Uint8Array(stringToBuffer(blob.contents, blob.encoding ?? \"utf8\")));\n\t\t}\n\t}\n}\n\n/**\n * Represents and serializes tree part of the snapshot\n * @param snapshotNode - tree node to serialize to\n * @param snapshotTree - snapshot tree that is being serialized\n */\nfunction writeTreeSection(snapshotNode: NodeCore, snapshotTree: ISnapshotTree): void {\n\tsnapshotNode.addDictionaryString(\"treeNodes\");\n\tconst treesNode = snapshotNode.addNode(\"list\");\n\twriteTreeSectionCore(treesNode, snapshotTree);\n}\n\nfunction writeTreeSectionCore(treesNode: NodeCore, snapshotTree: ISnapshotTree): void {\n\tfor (const [path, value] of Object.entries(snapshotTree.trees)) {\n\t\tconst treeNode = treesNode.addNode();\n\t\t// Many leaf nodes in the tree have same names like \"content\", \"body\", \"header\"\n\t\t// We could be smarter here and not use dictionary where we are sure reuse is unlikely, but\n\t\t// it does not feel like it's worth it.\n\t\taddDictionaryStringProperty(treeNode, \"name\", path);\n\t\tif (snapshotTree.unreferenced) {\n\t\t\taddBoolProperty(treeNode, \"unreferenced\", snapshotTree.unreferenced);\n\t\t}\n\t\t// Only write children prop if either blobs or trees are present.\n\t\tif (Object.keys(value.blobs).length > 0 || Object.keys(value.trees).length > 0) {\n\t\t\ttreeNode.addDictionaryString(\"children\");\n\t\t\tconst childNode = treeNode.addNode(\"list\");\n\t\t\twriteTreeSectionCore(childNode, value);\n\t\t}\n\t\tif (value.groupId !== undefined) {\n\t\t\taddDictionaryStringProperty(treeNode, \"groupId\", value.groupId);\n\t\t}\n\t}\n\n\tif (snapshotTree.blobs) {\n\t\tfor (const [path, id] of Object.entries(snapshotTree.blobs)) {\n\t\t\tconst blobNode = treesNode.addNode();\n\t\t\taddDictionaryStringProperty(blobNode, \"name\", path);\n\t\t\taddDictionaryStringProperty(blobNode, \"value\", id);\n\t\t}\n\t}\n}\n\n/**\n * Represents (serializes) snapshot tree as generalizes tree\n * @param rootNode - tree node to serialize to\n * @param snapshotTree - snapshot tree that is being serialized\n * @param blobs - blobs mapping of the snapshot\n * @param snapshotSequenceNumber - seq number at which snapshot is taken\n */\nfunction writeSnapshotSection(\n\trootNode: NodeCore,\n\tsnapshotTree: ISnapshotTree,\n\tsnapshotSequenceNumber: number,\n): void {\n\trootNode.addDictionaryString(\"snapshot\");\n\tconst snapshotNode = rootNode.addNode();\n\n\tconst snapshotId = snapshotTree.id;\n\tassert(snapshotId !== undefined, 0x21b /* \"Snapshot id should be provided\" */);\n\taddStringProperty(snapshotNode, \"id\", snapshotId);\n\taddStringProperty(snapshotNode, \"message\", `Snapshot@${snapshotSequenceNumber}`);\n\taddNumberProperty(snapshotNode, \"sequenceNumber\", snapshotSequenceNumber);\n\n\t// Add Trees\n\twriteTreeSection(snapshotNode, snapshotTree);\n}\n\n/**\n * Represents ops in the tree.\n * @param rootNode - node to serialize to.\n * @param ops - ops that is being serialized\n */\nfunction writeOpsSection(rootNode: NodeCore, ops: ISequencedDocumentMessage[]): void {\n\tlet firstSequenceNumber: number | undefined;\n\tif (ops.length > 0) {\n\t\t// Non null asserting here because of the length check above\n\t\tfirstSequenceNumber = ops[0]!.sequenceNumber;\n\t}\n\tif (firstSequenceNumber !== undefined) {\n\t\trootNode.addDictionaryString(\"deltas\");\n\t\tconst opsNode = rootNode.addNode();\n\t\taddNumberProperty(opsNode, \"firstSequenceNumber\", firstSequenceNumber);\n\t\topsNode.addDictionaryString(\"deltas\");\n\t\tconst deltaNode = opsNode.addNode(\"list\");\n\t\tfor (const op of ops) {\n\t\t\tdeltaNode.addString(JSON.stringify(op));\n\t\t}\n\t}\n}\n\n/**\n * Converts trees/blobs/ops to binary compact representation.\n * @param snapshotContents - snapshot tree contents to serialize\n * @returns ReadBuffer - binary representation of the data.\n */\nexport function convertToCompactSnapshot(snapshotContents: ISnapshot): Uint8Array {\n\tconst builder = new TreeBuilderSerializer();\n\t// Create the root node.\n\tconst rootNode = builder.addNode();\n\tassert(\n\t\tsnapshotContents.sequenceNumber !== undefined,\n\t\t0x21c /* \"Seq number should be provided\" */,\n\t);\n\n\tlet latestSequenceNumber = snapshotContents.latestSequenceNumber;\n\tif (latestSequenceNumber === undefined) {\n\t\tlatestSequenceNumber =\n\t\t\tsnapshotContents.ops.length > 0\n\t\t\t\t? // Non null asserting here because of the length check above\n\t\t\t\t\tsnapshotContents.ops[snapshotContents.ops.length - 1]!.sequenceNumber\n\t\t\t\t: snapshotContents.sequenceNumber;\n\t}\n\n\twriteSnapshotProps(rootNode, latestSequenceNumber);\n\n\twriteSnapshotSection(\n\t\trootNode,\n\t\tsnapshotContents.snapshotTree,\n\t\tsnapshotContents.sequenceNumber,\n\t);\n\n\t// Add Blobs\n\twriteBlobsSection(rootNode, snapshotContents.blobContents);\n\n\t// Then write the ops node.\n\twriteOpsSection(rootNode, snapshotContents.ops);\n\n\treturn builder.serialize();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"compactSnapshotWriter.js","sourceRoot":"","sources":["../src/compactSnapshotWriter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAQ7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAEN,eAAe,EACf,2BAA2B,EAC3B,iBAAiB,EACjB,iBAAiB,GACjB,MAAM,mCAAmC,CAAC;AAE3C;;;;GAIG;AACH,SAAS,kBAAkB,CAAC,IAAc,EAAE,oBAA4B;IACvE,iBAAiB,CAAC,IAAI,EAAE,KAAK,EAAE,sBAAsB,CAAC,CAAC;IACvD,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,sBAAsB,CAAC,CAAC;IACtD,iBAAiB,CAAC,IAAI,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC;AACtD,CAAC;AAED;;;;GAIG;AACH,SAAS,iBAAiB,CACzB,YAAsB,EACtB,KAAuC;IAEvC,YAAY,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAC1C,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/C,KAAK,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC;QAC3C,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC;QACrC,2BAA2B,CAAC,QAAQ,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;QAC3D,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC3B,IAAI,IAAI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AAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,cAAc;gBACtE,CAAC,CAAC,gBAAgB,CAAC,cAAc,CAAC;IACrC,CAAC;IAED,kBAAkB,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;IAEnD,oBAAoB,CACnB,QAAQ,EACR,gBAAgB,CAAC,YAAY,EAC7B,gBAAgB,CAAC,cAAc,CAC/B,CAAC;IAEF,YAAY;IACZ,iBAAiB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAE3D,2BAA2B;IAC3B,eAAe,CAAC,QAAQ,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAEhD,OAAO,OAAO,CAAC,SAAS,EAAE,CAAC;AAC5B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { stringToBuffer } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tISnapshot,\n\tIBlob,\n\tISnapshotTree,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\n\nimport { TreeBuilderSerializer } from \"./WriteBufferUtils.js\";\nimport { snapshotMinReadVersion } from \"./compactSnapshotParser.js\";\nimport {\n\tNodeCore,\n\taddBoolProperty,\n\taddDictionaryStringProperty,\n\taddNumberProperty,\n\taddStringProperty,\n} from \"./zipItDataRepresentationUtils.js\";\n\n/**\n * Writes header section of the snapshot.\n * @param node - snapshot node to serialize to\n * @param latestSequenceNumber - latest seq number of the container.\n */\nfunction writeSnapshotProps(node: NodeCore, latestSequenceNumber: number): void {\n\taddStringProperty(node, \"mrv\", snapshotMinReadVersion);\n\taddStringProperty(node, \"cv\", snapshotMinReadVersion);\n\taddNumberProperty(node, \"lsn\", latestSequenceNumber);\n}\n\n/**\n * Represents blobs in the tree.\n * @param snapshotNode - node to serialize to.\n * @param blobs - blobs that is being serialized\n */\nfunction writeBlobsSection(\n\tsnapshotNode: NodeCore,\n\tblobs: Map<string, IBlob | ArrayBuffer>,\n): void {\n\tsnapshotNode.addDictionaryString(\"blobs\");\n\tconst blobsNode = snapshotNode.addNode(\"list\");\n\tfor (const [storageBlobId, blob] of blobs) {\n\t\tconst blobNode = blobsNode.addNode();\n\t\taddDictionaryStringProperty(blobNode, \"id\", storageBlobId);\n\t\tblobNode.addString(\"data\");\n\t\tif (blob instanceof ArrayBuffer) {\n\t\t\tblobNode.addBlob(new Uint8Array(blob));\n\t\t} else {\n\t\t\tblobNode.addBlob(new Uint8Array(stringToBuffer(blob.contents, blob.encoding ?? \"utf8\")));\n\t\t}\n\t}\n}\n\n/**\n * Represents and serializes tree part of the snapshot\n * @param snapshotNode - tree node to serialize to\n * @param snapshotTree - snapshot tree that is being serialized\n */\nfunction writeTreeSection(snapshotNode: NodeCore, snapshotTree: ISnapshotTree): void {\n\tsnapshotNode.addDictionaryString(\"treeNodes\");\n\tconst treesNode = snapshotNode.addNode(\"list\");\n\twriteTreeSectionCore(treesNode, snapshotTree);\n}\n\nfunction writeTreeSectionCore(treesNode: NodeCore, snapshotTree: ISnapshotTree): void {\n\tfor (const [path, value] of Object.entries(snapshotTree.trees)) {\n\t\tconst treeNode = treesNode.addNode();\n\t\t// Many leaf nodes in the tree have same names like \"content\", \"body\", \"header\"\n\t\t// We could be smarter here and not use dictionary where we are sure reuse is unlikely, but\n\t\t// it does not feel like it's worth it.\n\t\taddDictionaryStringProperty(treeNode, \"name\", path);\n\t\tif (snapshotTree.unreferenced) {\n\t\t\taddBoolProperty(treeNode, \"unreferenced\", snapshotTree.unreferenced);\n\t\t}\n\t\t// Only write children prop if either blobs or trees are present.\n\t\tif (Object.keys(value.blobs).length > 0 || Object.keys(value.trees).length > 0) {\n\t\t\ttreeNode.addDictionaryString(\"children\");\n\t\t\tconst childNode = treeNode.addNode(\"list\");\n\t\t\twriteTreeSectionCore(childNode, value);\n\t\t}\n\t\tif (value.groupId !== undefined) {\n\t\t\taddDictionaryStringProperty(treeNode, \"groupId\", value.groupId);\n\t\t}\n\t}\n\n\tif (snapshotTree.blobs) {\n\t\tfor (const [path, id] of Object.entries(snapshotTree.blobs)) {\n\t\t\tconst blobNode = treesNode.addNode();\n\t\t\taddDictionaryStringProperty(blobNode, \"name\", path);\n\t\t\taddDictionaryStringProperty(blobNode, \"value\", id);\n\t\t}\n\t}\n}\n\n/**\n * Represents (serializes) snapshot tree as generalizes tree\n * @param rootNode - tree node to serialize to\n * @param snapshotTree - snapshot tree that is being serialized\n * @param blobs - blobs mapping of the snapshot\n * @param snapshotSequenceNumber - seq number at which snapshot is taken\n */\nfunction writeSnapshotSection(\n\trootNode: NodeCore,\n\tsnapshotTree: ISnapshotTree,\n\tsnapshotSequenceNumber: number,\n): void {\n\trootNode.addDictionaryString(\"snapshot\");\n\tconst snapshotNode = rootNode.addNode();\n\n\tconst snapshotId = snapshotTree.id;\n\tassert(snapshotId !== undefined, 0x21b /* \"Snapshot id should be provided\" */);\n\taddStringProperty(snapshotNode, \"id\", snapshotId);\n\taddStringProperty(snapshotNode, \"message\", `Snapshot@${snapshotSequenceNumber}`);\n\taddNumberProperty(snapshotNode, \"sequenceNumber\", snapshotSequenceNumber);\n\n\t// Add Trees\n\twriteTreeSection(snapshotNode, snapshotTree);\n}\n\n/**\n * Represents ops in the tree.\n * @param rootNode - node to serialize to.\n * @param ops - ops that is being serialized\n */\nfunction writeOpsSection(rootNode: NodeCore, ops: ISequencedDocumentMessage[]): void {\n\tlet firstSequenceNumber: number | undefined;\n\tif (ops.length > 0) {\n\t\tfirstSequenceNumber = ops[0].sequenceNumber;\n\t}\n\tif (firstSequenceNumber !== undefined) {\n\t\trootNode.addDictionaryString(\"deltas\");\n\t\tconst opsNode = rootNode.addNode();\n\t\taddNumberProperty(opsNode, \"firstSequenceNumber\", firstSequenceNumber);\n\t\topsNode.addDictionaryString(\"deltas\");\n\t\tconst deltaNode = opsNode.addNode(\"list\");\n\t\tfor (const op of ops) {\n\t\t\tdeltaNode.addString(JSON.stringify(op));\n\t\t}\n\t}\n}\n\n/**\n * Converts trees/blobs/ops to binary compact representation.\n * @param snapshotContents - snapshot tree contents to serialize\n * @returns ReadBuffer - binary representation of the data.\n */\nexport function convertToCompactSnapshot(snapshotContents: ISnapshot): Uint8Array {\n\tconst builder = new TreeBuilderSerializer();\n\t// Create the root node.\n\tconst rootNode = builder.addNode();\n\tassert(\n\t\tsnapshotContents.sequenceNumber !== undefined,\n\t\t0x21c /* \"Seq number should be provided\" */,\n\t);\n\n\tlet latestSequenceNumber = snapshotContents.latestSequenceNumber;\n\tif (latestSequenceNumber === undefined) {\n\t\tlatestSequenceNumber =\n\t\t\tsnapshotContents.ops.length > 0\n\t\t\t\t? snapshotContents.ops[snapshotContents.ops.length - 1].sequenceNumber\n\t\t\t\t: snapshotContents.sequenceNumber;\n\t}\n\n\twriteSnapshotProps(rootNode, latestSequenceNumber);\n\n\twriteSnapshotSection(\n\t\trootNode,\n\t\tsnapshotContents.snapshotTree,\n\t\tsnapshotContents.sequenceNumber,\n\t);\n\n\t// Add Blobs\n\twriteBlobsSection(rootNode, snapshotContents.blobContents);\n\n\t// Then write the ops node.\n\twriteOpsSection(rootNode, snapshotContents.ops);\n\n\treturn builder.serialize();\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNewUtils.d.ts","sourceRoot":"","sources":["../src/createNewUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEN,YAAY,EAGZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAiB,MAAM,6CAA6C,CAAC;AAMvF,OAAO,EAAE,+BAA+B,EAAE,MAAM,kDAAkD,CAAC;AACnG,OAAO,EACN,mBAAmB,EAEnB,MAAM,0CAA0C,CAAC;AAGlD,OAAO,EACN,mBAAmB,EAInB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAK5D;;GAE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