@fluid-internal/client-utils 3.6.0 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/bufferShared.d.ts.map +1 -1
- package/dist/bufferShared.js +8 -5
- package/dist/bufferShared.js.map +1 -1
- package/lib/bufferShared.d.ts.map +1 -1
- package/lib/bufferShared.js +8 -5
- package/lib/bufferShared.js.map +1 -1
- package/package.json +4 -4
- package/src/bufferShared.ts +8 -5
package/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bufferShared.d.ts","sourceRoot":"","sources":["../src/bufferShared.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;GAUG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,eAAe,GAAG,WAAW,CASjF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,2BAA2B,CAAC,YAAY,SAAS,eAAe,EAC/E,KAAK,EAAE,UAAU,CAAC,YAAY,CAAC,GAC7B,YAAY,CAWd;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,
|
|
1
|
+
{"version":3,"file":"bufferShared.d.ts","sourceRoot":"","sources":["../src/bufferShared.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;GAUG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,eAAe,GAAG,WAAW,CASjF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,2BAA2B,CAAC,YAAY,SAAS,eAAe,EAC/E,KAAK,EAAE,UAAU,CAAC,YAAY,CAAC,GAC7B,YAAY,CAWd;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,CAmBzE"}
|
package/dist/bufferShared.js
CHANGED
|
@@ -72,12 +72,15 @@ function AnyUint8ArrayToArrayBuffer(array) {
|
|
|
72
72
|
array.buffer instanceof ArrayBuffer) {
|
|
73
73
|
return array.buffer;
|
|
74
74
|
}
|
|
75
|
-
//
|
|
75
|
+
// Copy into a new `Uint8Array` so that the result's underlying buffer is:
|
|
76
76
|
// 1. ArrayBuffer
|
|
77
77
|
// 2. the complete data (no offset, full length)
|
|
78
|
-
//
|
|
79
|
-
//
|
|
80
|
-
//
|
|
81
|
-
|
|
78
|
+
// Constructing from a typed array always allocates a fresh `ArrayBuffer` of exactly
|
|
79
|
+
// `array.byteLength` bytes. See ECMAScript https://tc39.es/ecma262/multipage/indexed-collections.html#sec-initializetypedarrayfromtypedarray.
|
|
80
|
+
//
|
|
81
|
+
// `array.slice()` must not be used here: Node.js `Buffer` extends Uint8Array and overrides `slice` to
|
|
82
|
+
// return a view over the same memory (like `subarray`) rather than a copy, so `.buffer` of the result
|
|
83
|
+
// would be the entire (possibly pooled) backing buffer, including bytes outside the input view.
|
|
84
|
+
return new Uint8Array(array).buffer;
|
|
82
85
|
}
|
|
83
86
|
//# sourceMappingURL=bufferShared.js.map
|
package/dist/bufferShared.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bufferShared.js","sourceRoot":"","sources":["../src/bufferShared.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAaH,oEASC;AAeD,kEAaC;AAiBD,
|
|
1
|
+
{"version":3,"file":"bufferShared.js","sourceRoot":"","sources":["../src/bufferShared.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAaH,oEASC;AAeD,kEAaC;AAiBD,gEAmBC;AApFD;;;;;;;;;;GAUG;AACH,SAAgB,4BAA4B,CAAC,MAAuB;IACnE,IAAI,MAAM,YAAY,WAAW,EAAE,CAAC;QACnC,OAAO,MAAM,CAAC;IACf,CAAC;IACD,gEAAgE;IAChE,uEAAuE;IACvE,0EAA0E;IAC1E,qGAAqG;IACrG,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC;AAC9C,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,2BAA2B,CAC1C,KAA+B;IAE/B,IAAI,KAAK,CAAC,UAAU,KAAK,CAAC,IAAI,KAAK,CAAC,UAAU,KAAK,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;QAC5E,OAAO,KAAK,CAAC,MAAM,CAAC;IACrB,CAAC;IACD,6EAA6E;IAC7E,yEAAyE;IACzE,+DAA+D;IAC/D,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,CACxB,KAAK,CAAC,UAAU,EAChB,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CACnB,CAAC;AACnB,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAgB,0BAA0B,CAAC,KAAiB;IAC3D,8DAA8D;IAC9D,IACC,KAAK,CAAC,UAAU,KAAK,CAAC;QACtB,KAAK,CAAC,UAAU,KAAK,KAAK,CAAC,MAAM,CAAC,UAAU;QAC5C,KAAK,CAAC,MAAM,YAAY,WAAW,EAClC,CAAC;QACF,OAAO,KAAK,CAAC,MAAM,CAAC;IACrB,CAAC;IACD,0EAA0E;IAC1E,kBAAkB;IAClB,iDAAiD;IACjD,oFAAoF;IACpF,8IAA8I;IAC9I,EAAE;IACF,sGAAsG;IACtG,sGAAsG;IACtG,gGAAgG;IAChG,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC;AACrC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Distills an `ArrayBuffer` from an `ArrayBufferLike` or creates one from `SharedArrayBuffer` if needed.\n *\n * @param buffer - `ArrayBuffer` or any `ArrayBufferLike` to convert to `ArrayBuffer`.\n *\n * @remarks The returned buffer may be the input array's backing buffer or a copy of its bytes.\n * Callers should not mutate the returned buffer unless they own the input array and its backing\n * storage, and should not rely on mutations being reflected in the input array.\n *\n * @internal\n */\nexport function ArrayBufferLikeToArrayBuffer(buffer: ArrayBufferLike): ArrayBuffer {\n\tif (buffer instanceof ArrayBuffer) {\n\t\treturn buffer;\n\t}\n\t// Use .slice to get `ArrayBuffer` backing that `Blob` requires.\n\t// Note that `buffer.slice` preserves the underlying buffer type, so we\n\t// need to use .slice on a `Uint8Array` to ensure we get an `ArrayBuffer`.\n\t// eslint-disable-next-line unicorn/prefer-spread -- spread is not the same as slice for `Uint8Array`\n\treturn new Uint8Array(buffer).slice().buffer;\n}\n\n/**\n * Distills a `Uint8Array` array to an `ArrayBuffer | SharedArrayBuffer` copying\n * data as needed per the array's `byteOffset` and `byteLength` to have a full\n * buffer (no offset and entire length).\n *\n * @param array - Array to extract buffer from.\n *\n * @remarks The returned buffer may be the input array's backing buffer or a copy of its bytes.\n * Callers should not mutate the returned buffer unless they own the input array and its backing\n * storage, and should not rely on mutations being reflected in the input array.\n *\n * @internal\n */\nexport function Uint8ArrayToArrayBufferLike<TArrayBuffer extends ArrayBufferLike>(\n\tarray: Uint8Array<TArrayBuffer>,\n): TArrayBuffer {\n\tif (array.byteOffset === 0 && array.byteLength === array.buffer.byteLength) {\n\t\treturn array.buffer;\n\t}\n\t// Both ArrayBuffer and SharedArrayBuffer have a slice method and will return\n\t// their same type, but TypeScript does not correctly determine that will\n\t// satisfy TArrayBuffer. Cast to TArrayBuffer to indicate that.\n\treturn array.buffer.slice(\n\t\tarray.byteOffset,\n\t\tarray.byteOffset + array.byteLength,\n\t) as TArrayBuffer;\n}\n\n/**\n * Distills a `Uint8Array` array to an `ArrayBuffer` copying data as needed per the array's\n * `byteOffset` and `byteLength` or if underlying buffer is not `ArrayBuffer`.\n *\n * @param array - Array to convert to `ArrayBuffer`.\n *\n * @remarks The returned buffer may be the input array's backing buffer or a copy of its bytes.\n * Callers should not mutate the returned buffer unless they own the input array and its backing\n * storage, and should not rely on mutations being reflected in the input array.\n *\n * Prefer to use {@link Uint8ArrayToArrayBufferLike} if the call site doesn't require\n * an explicit `ArrayBuffer` (can also handle `SharedArrayBuffer`).\n *\n * @internal\n */\nexport function AnyUint8ArrayToArrayBuffer(array: Uint8Array): ArrayBuffer {\n\t// Shortcut to provider underlying buffer as-is when possible.\n\tif (\n\t\tarray.byteOffset === 0 &&\n\t\tarray.byteLength === array.buffer.byteLength &&\n\t\tarray.buffer instanceof ArrayBuffer\n\t) {\n\t\treturn array.buffer;\n\t}\n\t// Copy into a new `Uint8Array` so that the result's underlying buffer is:\n\t// 1. ArrayBuffer\n\t// 2. the complete data (no offset, full length)\n\t// Constructing from a typed array always allocates a fresh `ArrayBuffer` of exactly\n\t// `array.byteLength` bytes. See ECMAScript https://tc39.es/ecma262/multipage/indexed-collections.html#sec-initializetypedarrayfromtypedarray.\n\t//\n\t// `array.slice()` must not be used here: Node.js `Buffer` extends Uint8Array and overrides `slice` to\n\t// return a view over the same memory (like `subarray`) rather than a copy, so `.buffer` of the result\n\t// would be the entire (possibly pooled) backing buffer, including bytes outside the input view.\n\treturn new Uint8Array(array).buffer;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bufferShared.d.ts","sourceRoot":"","sources":["../src/bufferShared.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;GAUG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,eAAe,GAAG,WAAW,CASjF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,2BAA2B,CAAC,YAAY,SAAS,eAAe,EAC/E,KAAK,EAAE,UAAU,CAAC,YAAY,CAAC,GAC7B,YAAY,CAWd;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,
|
|
1
|
+
{"version":3,"file":"bufferShared.d.ts","sourceRoot":"","sources":["../src/bufferShared.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;GAUG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,eAAe,GAAG,WAAW,CASjF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,2BAA2B,CAAC,YAAY,SAAS,eAAe,EAC/E,KAAK,EAAE,UAAU,CAAC,YAAY,CAAC,GAC7B,YAAY,CAWd;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,CAmBzE"}
|
package/lib/bufferShared.js
CHANGED
|
@@ -67,12 +67,15 @@ export function AnyUint8ArrayToArrayBuffer(array) {
|
|
|
67
67
|
array.buffer instanceof ArrayBuffer) {
|
|
68
68
|
return array.buffer;
|
|
69
69
|
}
|
|
70
|
-
//
|
|
70
|
+
// Copy into a new `Uint8Array` so that the result's underlying buffer is:
|
|
71
71
|
// 1. ArrayBuffer
|
|
72
72
|
// 2. the complete data (no offset, full length)
|
|
73
|
-
//
|
|
74
|
-
//
|
|
75
|
-
//
|
|
76
|
-
|
|
73
|
+
// Constructing from a typed array always allocates a fresh `ArrayBuffer` of exactly
|
|
74
|
+
// `array.byteLength` bytes. See ECMAScript https://tc39.es/ecma262/multipage/indexed-collections.html#sec-initializetypedarrayfromtypedarray.
|
|
75
|
+
//
|
|
76
|
+
// `array.slice()` must not be used here: Node.js `Buffer` extends Uint8Array and overrides `slice` to
|
|
77
|
+
// return a view over the same memory (like `subarray`) rather than a copy, so `.buffer` of the result
|
|
78
|
+
// would be the entire (possibly pooled) backing buffer, including bytes outside the input view.
|
|
79
|
+
return new Uint8Array(array).buffer;
|
|
77
80
|
}
|
|
78
81
|
//# sourceMappingURL=bufferShared.js.map
|
package/lib/bufferShared.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bufferShared.js","sourceRoot":"","sources":["../src/bufferShared.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,UAAU,4BAA4B,CAAC,MAAuB;IACnE,IAAI,MAAM,YAAY,WAAW,EAAE,CAAC;QACnC,OAAO,MAAM,CAAC;IACf,CAAC;IACD,gEAAgE;IAChE,uEAAuE;IACvE,0EAA0E;IAC1E,qGAAqG;IACrG,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC;AAC9C,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,2BAA2B,CAC1C,KAA+B;IAE/B,IAAI,KAAK,CAAC,UAAU,KAAK,CAAC,IAAI,KAAK,CAAC,UAAU,KAAK,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;QAC5E,OAAO,KAAK,CAAC,MAAM,CAAC;IACrB,CAAC;IACD,6EAA6E;IAC7E,yEAAyE;IACzE,+DAA+D;IAC/D,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,CACxB,KAAK,CAAC,UAAU,EAChB,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CACnB,CAAC;AACnB,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,0BAA0B,CAAC,KAAiB;IAC3D,8DAA8D;IAC9D,IACC,KAAK,CAAC,UAAU,KAAK,CAAC;QACtB,KAAK,CAAC,UAAU,KAAK,KAAK,CAAC,MAAM,CAAC,UAAU;QAC5C,KAAK,CAAC,MAAM,YAAY,WAAW,EAClC,CAAC;QACF,OAAO,KAAK,CAAC,MAAM,CAAC;IACrB,CAAC;IACD,
|
|
1
|
+
{"version":3,"file":"bufferShared.js","sourceRoot":"","sources":["../src/bufferShared.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,UAAU,4BAA4B,CAAC,MAAuB;IACnE,IAAI,MAAM,YAAY,WAAW,EAAE,CAAC;QACnC,OAAO,MAAM,CAAC;IACf,CAAC;IACD,gEAAgE;IAChE,uEAAuE;IACvE,0EAA0E;IAC1E,qGAAqG;IACrG,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC;AAC9C,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,2BAA2B,CAC1C,KAA+B;IAE/B,IAAI,KAAK,CAAC,UAAU,KAAK,CAAC,IAAI,KAAK,CAAC,UAAU,KAAK,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;QAC5E,OAAO,KAAK,CAAC,MAAM,CAAC;IACrB,CAAC;IACD,6EAA6E;IAC7E,yEAAyE;IACzE,+DAA+D;IAC/D,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,CACxB,KAAK,CAAC,UAAU,EAChB,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CACnB,CAAC;AACnB,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,0BAA0B,CAAC,KAAiB;IAC3D,8DAA8D;IAC9D,IACC,KAAK,CAAC,UAAU,KAAK,CAAC;QACtB,KAAK,CAAC,UAAU,KAAK,KAAK,CAAC,MAAM,CAAC,UAAU;QAC5C,KAAK,CAAC,MAAM,YAAY,WAAW,EAClC,CAAC;QACF,OAAO,KAAK,CAAC,MAAM,CAAC;IACrB,CAAC;IACD,0EAA0E;IAC1E,kBAAkB;IAClB,iDAAiD;IACjD,oFAAoF;IACpF,8IAA8I;IAC9I,EAAE;IACF,sGAAsG;IACtG,sGAAsG;IACtG,gGAAgG;IAChG,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC;AACrC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Distills an `ArrayBuffer` from an `ArrayBufferLike` or creates one from `SharedArrayBuffer` if needed.\n *\n * @param buffer - `ArrayBuffer` or any `ArrayBufferLike` to convert to `ArrayBuffer`.\n *\n * @remarks The returned buffer may be the input array's backing buffer or a copy of its bytes.\n * Callers should not mutate the returned buffer unless they own the input array and its backing\n * storage, and should not rely on mutations being reflected in the input array.\n *\n * @internal\n */\nexport function ArrayBufferLikeToArrayBuffer(buffer: ArrayBufferLike): ArrayBuffer {\n\tif (buffer instanceof ArrayBuffer) {\n\t\treturn buffer;\n\t}\n\t// Use .slice to get `ArrayBuffer` backing that `Blob` requires.\n\t// Note that `buffer.slice` preserves the underlying buffer type, so we\n\t// need to use .slice on a `Uint8Array` to ensure we get an `ArrayBuffer`.\n\t// eslint-disable-next-line unicorn/prefer-spread -- spread is not the same as slice for `Uint8Array`\n\treturn new Uint8Array(buffer).slice().buffer;\n}\n\n/**\n * Distills a `Uint8Array` array to an `ArrayBuffer | SharedArrayBuffer` copying\n * data as needed per the array's `byteOffset` and `byteLength` to have a full\n * buffer (no offset and entire length).\n *\n * @param array - Array to extract buffer from.\n *\n * @remarks The returned buffer may be the input array's backing buffer or a copy of its bytes.\n * Callers should not mutate the returned buffer unless they own the input array and its backing\n * storage, and should not rely on mutations being reflected in the input array.\n *\n * @internal\n */\nexport function Uint8ArrayToArrayBufferLike<TArrayBuffer extends ArrayBufferLike>(\n\tarray: Uint8Array<TArrayBuffer>,\n): TArrayBuffer {\n\tif (array.byteOffset === 0 && array.byteLength === array.buffer.byteLength) {\n\t\treturn array.buffer;\n\t}\n\t// Both ArrayBuffer and SharedArrayBuffer have a slice method and will return\n\t// their same type, but TypeScript does not correctly determine that will\n\t// satisfy TArrayBuffer. Cast to TArrayBuffer to indicate that.\n\treturn array.buffer.slice(\n\t\tarray.byteOffset,\n\t\tarray.byteOffset + array.byteLength,\n\t) as TArrayBuffer;\n}\n\n/**\n * Distills a `Uint8Array` array to an `ArrayBuffer` copying data as needed per the array's\n * `byteOffset` and `byteLength` or if underlying buffer is not `ArrayBuffer`.\n *\n * @param array - Array to convert to `ArrayBuffer`.\n *\n * @remarks The returned buffer may be the input array's backing buffer or a copy of its bytes.\n * Callers should not mutate the returned buffer unless they own the input array and its backing\n * storage, and should not rely on mutations being reflected in the input array.\n *\n * Prefer to use {@link Uint8ArrayToArrayBufferLike} if the call site doesn't require\n * an explicit `ArrayBuffer` (can also handle `SharedArrayBuffer`).\n *\n * @internal\n */\nexport function AnyUint8ArrayToArrayBuffer(array: Uint8Array): ArrayBuffer {\n\t// Shortcut to provider underlying buffer as-is when possible.\n\tif (\n\t\tarray.byteOffset === 0 &&\n\t\tarray.byteLength === array.buffer.byteLength &&\n\t\tarray.buffer instanceof ArrayBuffer\n\t) {\n\t\treturn array.buffer;\n\t}\n\t// Copy into a new `Uint8Array` so that the result's underlying buffer is:\n\t// 1. ArrayBuffer\n\t// 2. the complete data (no offset, full length)\n\t// Constructing from a typed array always allocates a fresh `ArrayBuffer` of exactly\n\t// `array.byteLength` bytes. See ECMAScript https://tc39.es/ecma262/multipage/indexed-collections.html#sec-initializetypedarrayfromtypedarray.\n\t//\n\t// `array.slice()` must not be used here: Node.js `Buffer` extends Uint8Array and overrides `slice` to\n\t// return a view over the same memory (like `subarray`) rather than a copy, so `.buffer` of the result\n\t// would be the entire (possibly pooled) backing buffer, including bytes outside the input view.\n\treturn new Uint8Array(array).buffer;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-internal/client-utils",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.0",
|
|
4
4
|
"description": "Not intended for use outside the Fluid Framework.",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"temp-directory": "nyc/.nyc_output"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@fluidframework/core-interfaces": "~3.
|
|
66
|
+
"@fluidframework/core-interfaces": "~3.7.0",
|
|
67
67
|
"@types/events_pkg": "npm:@types/events@^3.0.0",
|
|
68
68
|
"base64-js": "^1.5.1",
|
|
69
69
|
"buffer": "^6.0.3",
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
75
75
|
"@biomejs/biome": "~2.4.5",
|
|
76
|
-
"@fluid-internal/client-utils-previous": "npm:@fluid-internal/client-utils@3.
|
|
77
|
-
"@fluid-internal/mocha-test-setup": "~3.
|
|
76
|
+
"@fluid-internal/client-utils-previous": "npm:@fluid-internal/client-utils@3.6.0",
|
|
77
|
+
"@fluid-internal/mocha-test-setup": "~3.7.0",
|
|
78
78
|
"@fluid-tools/build-cli": "^0.68.0",
|
|
79
79
|
"@fluidframework/build-common": "^2.0.3",
|
|
80
80
|
"@fluidframework/build-tools": "^0.68.0",
|
package/src/bufferShared.ts
CHANGED
|
@@ -77,11 +77,14 @@ export function AnyUint8ArrayToArrayBuffer(array: Uint8Array): ArrayBuffer {
|
|
|
77
77
|
) {
|
|
78
78
|
return array.buffer;
|
|
79
79
|
}
|
|
80
|
-
//
|
|
80
|
+
// Copy into a new `Uint8Array` so that the result's underlying buffer is:
|
|
81
81
|
// 1. ArrayBuffer
|
|
82
82
|
// 2. the complete data (no offset, full length)
|
|
83
|
-
//
|
|
84
|
-
//
|
|
85
|
-
//
|
|
86
|
-
|
|
83
|
+
// Constructing from a typed array always allocates a fresh `ArrayBuffer` of exactly
|
|
84
|
+
// `array.byteLength` bytes. See ECMAScript https://tc39.es/ecma262/multipage/indexed-collections.html#sec-initializetypedarrayfromtypedarray.
|
|
85
|
+
//
|
|
86
|
+
// `array.slice()` must not be used here: Node.js `Buffer` extends Uint8Array and overrides `slice` to
|
|
87
|
+
// return a view over the same memory (like `subarray`) rather than a copy, so `.buffer` of the result
|
|
88
|
+
// would be the entire (possibly pooled) backing buffer, including bytes outside the input view.
|
|
89
|
+
return new Uint8Array(array).buffer;
|
|
87
90
|
}
|