@fluid-internal/client-utils 2.118.0 → 3.0.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 +1 -5
- package/README.md +13 -15
- package/dist/base64EncodingBrowser.d.ts +2 -1
- package/dist/base64EncodingBrowser.d.ts.map +1 -1
- package/dist/base64EncodingBrowser.js +1 -1
- package/dist/base64EncodingBrowser.js.map +1 -1
- package/dist/base64EncodingNode.d.ts +2 -1
- package/dist/base64EncodingNode.d.ts.map +1 -1
- package/dist/base64EncodingNode.js.map +1 -1
- package/dist/buffer.d.ts +93 -0
- package/dist/buffer.d.ts.map +1 -0
- package/dist/buffer.js +7 -0
- package/dist/buffer.js.map +1 -0
- package/dist/bufferBrowser.d.ts +18 -49
- package/dist/bufferBrowser.d.ts.map +1 -1
- package/dist/bufferBrowser.js +49 -52
- package/dist/bufferBrowser.js.map +1 -1
- package/dist/bufferNode.d.ts +67 -19
- package/dist/bufferNode.d.ts.map +1 -1
- package/dist/bufferNode.js +10 -12
- package/dist/bufferNode.js.map +1 -1
- package/dist/bufferShared.d.ts +38 -3
- package/dist/bufferShared.d.ts.map +1 -1
- package/dist/bufferShared.js +67 -5
- package/dist/bufferShared.js.map +1 -1
- package/dist/events/emitter.d.ts.map +1 -1
- package/dist/events/emitter.js +4 -3
- package/dist/events/emitter.js.map +1 -1
- package/dist/hashFileBrowser.d.ts +1 -1
- package/dist/hashFileBrowser.d.ts.map +1 -1
- package/dist/hashFileBrowser.js +23 -11
- package/dist/hashFileBrowser.js.map +1 -1
- package/dist/hashFileNode.d.ts +10 -2
- package/dist/hashFileNode.d.ts.map +1 -1
- package/dist/hashFileNode.js +10 -3
- package/dist/hashFileNode.js.map +1 -1
- package/dist/indexBrowser.d.ts +5 -3
- package/dist/indexBrowser.d.ts.map +1 -1
- package/dist/indexBrowser.js +5 -5
- package/dist/indexBrowser.js.map +1 -1
- package/dist/indexNode.d.ts +4 -3
- package/dist/indexNode.d.ts.map +1 -1
- package/dist/indexNode.js +5 -2
- package/dist/indexNode.js.map +1 -1
- package/dist/layerCompat.d.ts +37 -13
- package/dist/layerCompat.d.ts.map +1 -1
- package/dist/layerCompat.js +19 -14
- package/dist/layerCompat.js.map +1 -1
- package/dist/trace.js +2 -0
- package/dist/trace.js.map +1 -1
- package/dist/typedEventEmitter.js +7 -0
- package/dist/typedEventEmitter.js.map +1 -1
- package/eslint.config.mts +2 -2
- package/lib/base64EncodingBrowser.d.ts +2 -1
- package/lib/base64EncodingBrowser.d.ts.map +1 -1
- package/lib/base64EncodingBrowser.js +1 -1
- package/lib/base64EncodingBrowser.js.map +1 -1
- package/lib/base64EncodingNode.d.ts +2 -1
- package/lib/base64EncodingNode.d.ts.map +1 -1
- package/lib/base64EncodingNode.js.map +1 -1
- package/lib/buffer.d.ts +93 -0
- package/lib/buffer.d.ts.map +1 -0
- package/lib/buffer.js +6 -0
- package/lib/buffer.js.map +1 -0
- package/lib/bufferBrowser.d.ts +18 -49
- package/lib/bufferBrowser.d.ts.map +1 -1
- package/lib/bufferBrowser.js +29 -40
- package/lib/bufferBrowser.js.map +1 -1
- package/lib/bufferNode.d.ts +67 -19
- package/lib/bufferNode.d.ts.map +1 -1
- package/lib/bufferNode.js +7 -9
- package/lib/bufferNode.js.map +1 -1
- package/lib/bufferShared.d.ts +38 -3
- package/lib/bufferShared.d.ts.map +1 -1
- package/lib/bufferShared.js +64 -3
- package/lib/bufferShared.js.map +1 -1
- package/lib/events/emitter.d.ts.map +1 -1
- package/lib/events/emitter.js +2 -1
- package/lib/events/emitter.js.map +1 -1
- package/lib/hashFileBrowser.d.ts +1 -1
- package/lib/hashFileBrowser.d.ts.map +1 -1
- package/lib/hashFileBrowser.js +4 -1
- package/lib/hashFileBrowser.js.map +1 -1
- package/lib/hashFileNode.d.ts +10 -2
- package/lib/hashFileNode.d.ts.map +1 -1
- package/lib/hashFileNode.js +8 -0
- package/lib/hashFileNode.js.map +1 -1
- package/lib/indexBrowser.d.ts +5 -3
- package/lib/indexBrowser.d.ts.map +1 -1
- package/lib/indexBrowser.js +3 -5
- package/lib/indexBrowser.js.map +1 -1
- package/lib/indexNode.d.ts +4 -3
- package/lib/indexNode.d.ts.map +1 -1
- package/lib/indexNode.js +2 -2
- package/lib/indexNode.js.map +1 -1
- package/lib/layerCompat.d.ts +37 -13
- package/lib/layerCompat.d.ts.map +1 -1
- package/lib/layerCompat.js +17 -12
- package/lib/layerCompat.js.map +1 -1
- package/lib/trace.js +2 -0
- package/lib/trace.js.map +1 -1
- package/lib/typedEventEmitter.js +7 -0
- package/lib/typedEventEmitter.js.map +1 -1
- package/package.json +65 -62
- package/playwright.config.ts +23 -0
- package/src/base64EncodingBrowser.ts +3 -2
- package/src/base64EncodingNode.ts +2 -1
- package/src/buffer.ts +112 -0
- package/src/bufferBrowser.ts +98 -60
- package/src/bufferNode.ts +86 -30
- package/src/bufferShared.ts +74 -4
- package/src/hashFileBrowser.ts +6 -3
- package/src/hashFileNode.ts +10 -2
- package/src/indexBrowser.ts +13 -2
- package/src/indexNode.ts +13 -2
- package/src/layerCompat.ts +41 -13
- package/tsconfig.json +1 -2
- package/webpack.playwright.cjs +22 -0
- package/jest-puppeteer.config.cjs +0 -16
- package/jest.config.cjs +0 -21
package/lib/bufferNode.js
CHANGED
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
+
* The native Node.js Buffer implementation.
|
|
7
|
+
*
|
|
6
8
|
* @internal
|
|
7
9
|
*/
|
|
8
10
|
export const IsoBuffer = Buffer;
|
|
9
11
|
/**
|
|
10
|
-
* Converts a Uint8Array to a string of the provided encoding.
|
|
11
|
-
* @remarks Useful when the array might be an IsoBuffer
|
|
12
|
+
* Converts a `Uint8Array` to a string of the provided encoding.
|
|
13
|
+
* @remarks Useful when the array might be an `IsoBuffer`.
|
|
12
14
|
* @param arr - The array to convert.
|
|
13
15
|
* @param encoding - Optional target encoding; only "utf8" and "base64" are
|
|
14
16
|
* supported, with "utf8" being default.
|
|
@@ -16,12 +18,10 @@ export const IsoBuffer = Buffer;
|
|
|
16
18
|
*
|
|
17
19
|
* @internal
|
|
18
20
|
*/
|
|
19
|
-
export function Uint8ArrayToString(arr,
|
|
20
|
-
// eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged
|
|
21
|
-
encoding) {
|
|
21
|
+
export function Uint8ArrayToString(arr, encoding) {
|
|
22
22
|
// Buffer extends Uint8Array. Therefore, 'arr' may already be a Buffer, in
|
|
23
23
|
// which case we can avoid copying the Uint8Array into a new Buffer instance.
|
|
24
|
-
return (
|
|
24
|
+
return (IsoBuffer.isBuffer(arr) ? arr : IsoBuffer.from(arr)).toString(encoding);
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Convert base64 or utf8 string to array buffer.
|
|
@@ -47,7 +47,5 @@ export function stringToBuffer(input, encoding) {
|
|
|
47
47
|
*
|
|
48
48
|
* @internal
|
|
49
49
|
*/
|
|
50
|
-
export const bufferToString = (blob,
|
|
51
|
-
// eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged
|
|
52
|
-
encoding) => IsoBuffer.from(blob).toString(encoding);
|
|
50
|
+
export const bufferToString = (blob, encoding) => Uint8ArrayToString(blob instanceof Uint8Array ? blob : IsoBuffer.from(blob), encoding);
|
|
53
51
|
//# sourceMappingURL=bufferNode.js.map
|
package/lib/bufferNode.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bufferNode.js","sourceRoot":"","sources":["../src/bufferNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"bufferNode.js","sourceRoot":"","sources":["../src/bufferNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAyFH;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAyB,MAAM,CAAC;AAEtD;;;;;;;;;GASG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAe,EAAE,QAA4B;IAC/E,2EAA2E;IAC3E,6EAA6E;IAC7E,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACjF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa,EAAE,QAA2B;IACxE,MAAM,GAAG,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC5C,0EAA0E;IAC1E,2EAA2E;IAC3E,uDAAuD;IACvD,OAAO,GAAG,CAAC,UAAU,KAAK,GAAG,CAAC,MAAM,CAAC,UAAU;QAC9C,CAAC,CAAC,GAAG,CAAC,MAAM;QACZ,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC;AACtE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC7B,IAAkC,EAClC,QAA2B,EAClB,EAAE,CACX,kBAAkB,CAAC,IAAI,YAAY,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIsoBufferConstructor,\n\tIsoBufferEncoding,\n\tIsoBuffer as IsoBufferInterface,\n} from \"./buffer.js\";\n\nexport type { IsoBufferConstructor, IsoBufferEncoding } from \"./buffer.js\";\n/**\n * Minimal `Buffer` interface for our usages in the browser or Node.js environments.\n *\n * @internal\n *\n * @privateRemarks\n * This type is exported specifically from here to respect combo type+value of same name rules.\n */\nexport type IsoBuffer<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> =\n\tIsoBufferInterface<TArrayBuffer>;\n\n/**\n * Declare the subset of Buffer functionality we want to make available instead of\n * exposing the entirely of Node's typings. This should match the public interface\n * of the browser implementation -- see {@link (IsoBuffer:type)} and {@link IsoBufferConstructor}.\n *\n * @internal\n */\nexport declare class Buffer<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike>\n\textends Uint8Array<TArrayBuffer>\n\timplements IsoBuffer<TArrayBuffer>\n{\n\t/**\n\t * Creates a new `IsoBuffer` containing `string`. The `encoding` parameter identifies\n\t * the character encoding to be used when converting `string` into bytes.\n\t *\n\t * @param string - A string to encode.\n\t * @param encoding - The encoding of `string`. **Default:** `'utf8'`.\n\t *\n\t * @privateRemarks\n\t * Node buffer.buffer.d.ts declaration:\n\t * `from(string: WithImplicitCoercion<string>, encoding?: IsoBufferEncoding): Buffer<ArrayBuffer>;`\n\t */\n\tpublic static from(string: string, encoding?: IsoBufferEncoding): IsoBuffer<ArrayBuffer>;\n\t/**\n\t * Allocates a new `IsoBuffer` using an `array` of bytes in the range `0` – `255`.\n\t * Array entries outside that range will be truncated to fit into it.\n\t *\n\t * @param value - `Uint8Array`.\n\t *\n\t * @remarks\n\t * This is limited to `Uint8Array` input to match Node implementation that\n\t * takes `ArrayLike<number>` and returns `IsoBuffer<ArrayBuffer>`.\n\t *\n\t * @privateRemarks\n\t * Node buffer.buffer.d.ts declaration:\n\t * `from(array: WithImplicitCoercion<ArrayLike<number>>): IsoBuffer<ArrayBuffer>;`\n\t */\n\tpublic static from(array: Uint8Array): IsoBuffer<ArrayBuffer>;\n\t/**\n\t * This creates a view of the `ArrayBuffer` without copying the underlying\n\t * memory. For example, when passed a reference to the `.buffer` property of a\n\t * `TypedArray` instance, the newly created `Buffer` will share the same\n\t * allocated memory as the `TypedArray`'s underlying `ArrayBuffer`.\n\t *\n\t * @param arrayBuffer - An `ArrayBuffer`, `SharedArrayBuffer`, for example the\n\t * `.buffer` property of a `TypedArray`.\n\t * @param byteOffset - Index of first byte to expose. **Default:** `0`.\n\t * @param length - Number of bytes to expose. **Default:**\n\t * `arrayBuffer.byteLength - byteOffset`.\n\t *\n\t * @privateRemarks\n\t * Node buffer.buffer.d.ts declaration:\n\t * ```\n\t * public static from<TArrayBuffer extends WithImplicitCoercion<ArrayBufferLike>>(\n\t * \t\tarrayBuffer: TArrayBuffer,\n\t * \t\tbyteOffset?: number,\n\t * \t\tlength?: number,\n\t * ): Buffer<ImplicitArrayBuffer<TArrayBuffer>>;\n\t * ```\n\t */\n\tpublic static from<TArrayBuffer extends ArrayBufferLike>(\n\t\tarrayBuffer: TArrayBuffer,\n\t\tbyteOffset?: number,\n\t\tlength?: number,\n\t): IsoBuffer<TArrayBuffer>;\n\n\tpublic static isBuffer(obj: unknown): obj is Buffer;\n}\n\n/**\n * The native Node.js Buffer implementation.\n *\n * @internal\n */\nexport const IsoBuffer: IsoBufferConstructor = Buffer;\n\n/**\n * Converts a `Uint8Array` to a string of the provided encoding.\n * @remarks Useful when the array might be an `IsoBuffer`.\n * @param arr - The array to convert.\n * @param encoding - Optional target encoding; only \"utf8\" and \"base64\" are\n * supported, with \"utf8\" being default.\n * @returns The converted string.\n *\n * @internal\n */\nexport function Uint8ArrayToString(arr: Uint8Array, encoding?: IsoBufferEncoding): string {\n\t// Buffer extends Uint8Array. Therefore, 'arr' may already be a Buffer, in\n\t// which case we can avoid copying the Uint8Array into a new Buffer instance.\n\treturn (IsoBuffer.isBuffer(arr) ? arr : IsoBuffer.from(arr)).toString(encoding);\n}\n\n/**\n * Convert base64 or utf8 string to array buffer.\n * @param encoding - The input string's encoding.\n *\n * @internal\n */\nexport function stringToBuffer(input: string, encoding: IsoBufferEncoding): ArrayBuffer {\n\tconst iso = IsoBuffer.from(input, encoding);\n\t// In a Node environment, IsoBuffer may be a Node.js Buffer. Node.js will\n\t// pool multiple small Buffer instances into a single ArrayBuffer, in which\n\t// case we need to slice the appropriate span of bytes.\n\treturn iso.byteLength === iso.buffer.byteLength\n\t\t? iso.buffer\n\t\t: iso.buffer.slice(iso.byteOffset, iso.byteOffset + iso.byteLength);\n}\n\n/**\n * Convert binary blob to string format\n *\n * @param blob - The binary blob\n * @param encoding - Output string's encoding\n * @returns The blob in string format\n *\n * @internal\n */\nexport const bufferToString = (\n\tblob: ArrayBufferLike | Uint8Array,\n\tencoding: IsoBufferEncoding,\n): string =>\n\tUint8ArrayToString(blob instanceof Uint8Array ? blob : IsoBuffer.from(blob), encoding);\n"]}
|
package/lib/bufferShared.d.ts
CHANGED
|
@@ -3,10 +3,45 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Distills an `ArrayBuffer` from an `ArrayBufferLike` or creates one from `SharedArrayBuffer` if needed.
|
|
7
|
+
*
|
|
8
|
+
* @param buffer - `ArrayBuffer` or any `ArrayBufferLike` to convert to `ArrayBuffer`.
|
|
9
|
+
*
|
|
10
|
+
* @remarks The returned buffer may be the input array's backing buffer or a copy of its bytes.
|
|
11
|
+
* Callers should not mutate the returned buffer unless they own the input array and its backing
|
|
12
|
+
* storage, and should not rely on mutations being reflected in the input array.
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export declare function ArrayBufferLikeToArrayBuffer(buffer: ArrayBufferLike): ArrayBuffer;
|
|
17
|
+
/**
|
|
18
|
+
* Distills a `Uint8Array` array to an `ArrayBuffer | SharedArrayBuffer` copying
|
|
19
|
+
* data as needed per the array's `byteOffset` and `byteLength` to have a full
|
|
20
|
+
* buffer (no offset and entire length).
|
|
21
|
+
*
|
|
22
|
+
* @param array - Array to extract buffer from.
|
|
23
|
+
*
|
|
24
|
+
* @remarks The returned buffer may be the input array's backing buffer or a copy of its bytes.
|
|
25
|
+
* Callers should not mutate the returned buffer unless they own the input array and its backing
|
|
26
|
+
* storage, and should not rely on mutations being reflected in the input array.
|
|
27
|
+
*
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
export declare function Uint8ArrayToArrayBufferLike<TArrayBuffer extends ArrayBufferLike>(array: Uint8Array<TArrayBuffer>): TArrayBuffer;
|
|
31
|
+
/**
|
|
32
|
+
* Distills a `Uint8Array` array to an `ArrayBuffer` copying data as needed per the array's
|
|
33
|
+
* `byteOffset` and `byteLength` or if underlying buffer is not `ArrayBuffer`.
|
|
34
|
+
*
|
|
35
|
+
* @param array - Array to convert to `ArrayBuffer`.
|
|
36
|
+
*
|
|
37
|
+
* @remarks The returned buffer may be the input array's backing buffer or a copy of its bytes.
|
|
38
|
+
* Callers should not mutate the returned buffer unless they own the input array and its backing
|
|
39
|
+
* storage, and should not rely on mutations being reflected in the input array.
|
|
40
|
+
*
|
|
41
|
+
* Prefer to use {@link Uint8ArrayToArrayBufferLike} if the call site doesn't require
|
|
42
|
+
* an explicit `ArrayBuffer` (can also handle `SharedArrayBuffer`).
|
|
8
43
|
*
|
|
9
44
|
* @internal
|
|
10
45
|
*/
|
|
11
|
-
export declare function
|
|
46
|
+
export declare function AnyUint8ArrayToArrayBuffer(array: Uint8Array): ArrayBuffer;
|
|
12
47
|
//# sourceMappingURL=bufferShared.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bufferShared.d.ts","sourceRoot":"","sources":["../src/bufferShared.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH
|
|
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,CAgBzE"}
|
package/lib/bufferShared.js
CHANGED
|
@@ -3,15 +3,76 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Distills an `ArrayBuffer` from an `ArrayBufferLike` or creates one from `SharedArrayBuffer` if needed.
|
|
7
|
+
*
|
|
8
|
+
* @param buffer - `ArrayBuffer` or any `ArrayBufferLike` to convert to `ArrayBuffer`.
|
|
9
|
+
*
|
|
10
|
+
* @remarks The returned buffer may be the input array's backing buffer or a copy of its bytes.
|
|
11
|
+
* Callers should not mutate the returned buffer unless they own the input array and its backing
|
|
12
|
+
* storage, and should not rely on mutations being reflected in the input array.
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export function ArrayBufferLikeToArrayBuffer(buffer) {
|
|
17
|
+
if (buffer instanceof ArrayBuffer) {
|
|
18
|
+
return buffer;
|
|
19
|
+
}
|
|
20
|
+
// Use .slice to get `ArrayBuffer` backing that `Blob` requires.
|
|
21
|
+
// Note that `buffer.slice` preserves the underlying buffer type, so we
|
|
22
|
+
// need to use .slice on a `Uint8Array` to ensure we get an `ArrayBuffer`.
|
|
23
|
+
// eslint-disable-next-line unicorn/prefer-spread -- spread is not the same as slice for `Uint8Array`
|
|
24
|
+
return new Uint8Array(buffer).slice().buffer;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Distills a `Uint8Array` array to an `ArrayBuffer | SharedArrayBuffer` copying
|
|
28
|
+
* data as needed per the array's `byteOffset` and `byteLength` to have a full
|
|
29
|
+
* buffer (no offset and entire length).
|
|
30
|
+
*
|
|
31
|
+
* @param array - Array to extract buffer from.
|
|
32
|
+
*
|
|
33
|
+
* @remarks The returned buffer may be the input array's backing buffer or a copy of its bytes.
|
|
34
|
+
* Callers should not mutate the returned buffer unless they own the input array and its backing
|
|
35
|
+
* storage, and should not rely on mutations being reflected in the input array.
|
|
8
36
|
*
|
|
9
37
|
* @internal
|
|
10
38
|
*/
|
|
11
|
-
export function
|
|
39
|
+
export function Uint8ArrayToArrayBufferLike(array) {
|
|
12
40
|
if (array.byteOffset === 0 && array.byteLength === array.buffer.byteLength) {
|
|
13
41
|
return array.buffer;
|
|
14
42
|
}
|
|
43
|
+
// Both ArrayBuffer and SharedArrayBuffer have a slice method and will return
|
|
44
|
+
// their same type, but TypeScript does not correctly determine that will
|
|
45
|
+
// satisfy TArrayBuffer. Cast to TArrayBuffer to indicate that.
|
|
15
46
|
return array.buffer.slice(array.byteOffset, array.byteOffset + array.byteLength);
|
|
16
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Distills a `Uint8Array` array to an `ArrayBuffer` copying data as needed per the array's
|
|
50
|
+
* `byteOffset` and `byteLength` or if underlying buffer is not `ArrayBuffer`.
|
|
51
|
+
*
|
|
52
|
+
* @param array - Array to convert to `ArrayBuffer`.
|
|
53
|
+
*
|
|
54
|
+
* @remarks The returned buffer may be the input array's backing buffer or a copy of its bytes.
|
|
55
|
+
* Callers should not mutate the returned buffer unless they own the input array and its backing
|
|
56
|
+
* storage, and should not rely on mutations being reflected in the input array.
|
|
57
|
+
*
|
|
58
|
+
* Prefer to use {@link Uint8ArrayToArrayBufferLike} if the call site doesn't require
|
|
59
|
+
* an explicit `ArrayBuffer` (can also handle `SharedArrayBuffer`).
|
|
60
|
+
*
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
export function AnyUint8ArrayToArrayBuffer(array) {
|
|
64
|
+
// Shortcut to provider underlying buffer as-is when possible.
|
|
65
|
+
if (array.byteOffset === 0 &&
|
|
66
|
+
array.byteLength === array.buffer.byteLength &&
|
|
67
|
+
array.buffer instanceof ArrayBuffer) {
|
|
68
|
+
return array.buffer;
|
|
69
|
+
}
|
|
70
|
+
// .slice is used to ensure underlying buffer is:
|
|
71
|
+
// 1. ArrayBuffer
|
|
72
|
+
// 2. the complete data (no offset, full length)
|
|
73
|
+
// Cloning specified per https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice
|
|
74
|
+
// and ECMAScript https://tc39.es/ecma262/multipage/indexed-collections.html#sec-%typedarray%.prototype.slice.
|
|
75
|
+
// eslint-disable-next-line unicorn/prefer-spread -- spread is not the same as slice for `Uint8Array`
|
|
76
|
+
return array.slice().buffer;
|
|
77
|
+
}
|
|
17
78
|
//# 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
|
|
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,iDAAiD;IACjD,kBAAkB;IAClB,iDAAiD;IACjD,0HAA0H;IAC1H,8GAA8G;IAC9G,qGAAqG;IACrG,OAAO,KAAK,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC;AAC7B,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// .slice is used to ensure underlying buffer is:\n\t// 1. ArrayBuffer\n\t// 2. the complete data (no offset, full length)\n\t// Cloning specified per https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice\n\t// and ECMAScript https://tc39.es/ecma262/multipage/indexed-collections.html#sec-%typedarray%.prototype.slice.\n\t// eslint-disable-next-line unicorn/prefer-spread -- spread is not the same as slice for `Uint8Array`\n\treturn array.slice().buffer;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emitter.d.ts","sourceRoot":"","sources":["../../src/events/emitter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,SAAS,EAET,mBAAmB,EACnB,GAAG,EACH,MAAM,0CAA0C,CAAC;AAmBlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,qBAAa,kBAAkB,CAAC,UAAU,SAAS,SAAS,CAAC,UAAU,CAAC,CACvE,YAAW,UAAU,CAAC,UAAU,CAAC,EAAE,YAAY,CAAC,UAAU,CAAC;IASrC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;IAPnD,SAAS,CAAC,QAAQ,CAAC,SAAS,sCAEb,GAAG,EAAE,KAAK,UAAU,CAAC,MAAM,UAAU,CAAC,GACjD;IAIJ,SAAS,aAA8B,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"emitter.d.ts","sourceRoot":"","sources":["../../src/events/emitter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,SAAS,EAET,mBAAmB,EACnB,GAAG,EACH,MAAM,0CAA0C,CAAC;AAmBlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,qBAAa,kBAAkB,CAAC,UAAU,SAAS,SAAS,CAAC,UAAU,CAAC,CACvE,YAAW,UAAU,CAAC,UAAU,CAAC,EAAE,YAAY,CAAC,UAAU,CAAC;IASrC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;IAPnD,SAAS,CAAC,QAAQ,CA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|
+
noListeners;
|
|
76
|
+
listeners = new Map();
|
|
75
77
|
// Because this is protected and not public, calling this externally (not from a subclass) makes sending events to the constructed instance impossible.
|
|
76
78
|
// Instead, use the static `create` function to get an instance which allows emitting events.
|
|
77
79
|
constructor(noListeners) {
|
|
78
80
|
this.noListeners = noListeners;
|
|
79
|
-
this.listeners = new Map();
|
|
80
81
|
}
|
|
81
82
|
emit(eventName, ...args) {
|
|
82
83
|
const listeners = this.listeners.get(eventName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emitter.js","sourceRoot":"","sources":["../../src/events/emitter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH;;;;;;;GAOG;AACH,SAAS,WAAW,CAAO,GAAoB,EAAE,GAAM,EAAE,YAA2B;IACnF,IAAI,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACzB,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;QAC1B,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,MAAM,OAAO,kBAAkB;IAQ9B,uJAAuJ;IACvJ,6FAA6F;IAC7F,YAAuC,WAA6C;QAA7C,gBAAW,GAAX,WAAW,CAAkC;QAPjE,cAAS,GAAG,IAAI,GAAG,EAGnC,CAAC;IAImF,CAAC;IAE9E,IAAI,CACb,SAAY,EACZ,GAAG,IAA+B;QAElC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAChD,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC7B,8DAA8D;YAC9D,MAAM,QAAQ,GAAc,IAAI,CAAC;YACjC,qHAAqH;YACrH,KAAK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ights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tHasListeners,\n\tIEmitter,\n\tListenable,\n\tListeners,\n\tMapGetSet,\n\tNoListenersCallback,\n\tOff,\n} from \"@fluidframework/core-interfaces/internal\";\n\n/**\n * Retrieve a value from a map with the given key, or create a new entry if the key is not in the map.\n * @param map - The map to query/update\n * @param key - The key to lookup in the map\n * @param defaultValue - a function which returns a default value. This is called and used to set an initial value for the given key in the map if none exists\n * @returns either the existing value for the given key, or the newly-created value (the result of `defaultValue`)\n * @internal\n */\nfunction getOrCreate<K, V>(map: MapGetSet<K, V>, key: K, defaultValue: (key: K) => V): V {\n\tlet value = map.get(key);\n\tif (value === undefined) {\n\t\tvalue = defaultValue(key);\n\t\tmap.set(key, value);\n\t}\n\treturn value;\n}\n\n/**\n * Provides an API for subscribing to and listening to events.\n *\n * @remarks Classes wishing to emit events may either extend this class, compose over it, or expose it as a property of type {@link @fluidframework/core-interfaces#Listenable}.\n *\n * @example Extending this class\n *\n * ```typescript\n * interface MyEvents {\n * \tloaded: () => void;\n * \tcomputed: () => number;\n * }\n *\n * class MyInheritanceClass extends EventEmitter<MyEvents> {\n * \tprivate load() {\n * \t\tthis.emit(\"loaded\");\n * \t\tconst results: number[] = this.emitAndCollect(\"computed\");\n * \t}\n * }\n * ```\n *\n * @example Composing over this class\n *\n * ```typescript\n * class MyCompositionClass implements Listenable<MyEvents> {\n * \tprivate readonly events = createEmitter<MyEvents>();\n *\n * \tprivate load() {\n * \t\tthis.events.emit(\"loaded\");\n * \t\tconst results: number[] = this.events.emitAndCollect(\"computed\");\n * \t}\n *\n * \tpublic on<K extends keyof MyEvents>(eventName: K, listener: MyEvents[K]): () => void {\n * \t\treturn this.events.on(eventName, listener);\n * \t}\n * }\n * ```\n *\n * @example Exposing this class as a property\n *\n * ```typescript\n * class MyExposingClass {\n * \tprivate readonly _events = createEmitter<MyEvents>();\n * \tpublic readonly events: Listenable<MyEvents> = this._events;\n *\n * \tprivate load() {\n * \t\tthis._events.emit(\"loaded\");\n * \t\tconst results: number[] = this._events.emitAndCollect(\"computed\");\n * \t}\n * }\n * ```\n * @internal\n */\nexport class CustomEventEmitter<TListeners extends Listeners<TListeners>>\n\timplements Listenable<TListeners>, HasListeners<TListeners>\n{\n\tprotected readonly listeners = new Map<\n\t\tkeyof TListeners,\n\t\tSet<(...args: any[]) => TListeners[keyof TListeners]>\n\t>();\n\n\t// Because this is protected and not public, calling this externally (not from a subclass) makes sending events to the constructed instance impossible.\n\t// Instead, use the static `create` function to get an instance which allows emitting events.\n\tprotected constructor(private readonly noListeners?: NoListenersCallback<TListeners>) {}\n\n\tprotected emit<K extends keyof TListeners>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): void {\n\t\tconst listeners = this.listeners.get(eventName);\n\t\tif (listeners !== undefined) {\n\t\t\t// Current tsc (5.4.5) cannot spread `args` into `listener()`.\n\t\t\tconst argArray: unknown[] = args;\n\t\t\t// This explicitly copies listeners so that new listeners added during this call to emit will not receive this event.\n\t\t\tfor (const listener of [...listeners]) {\n\t\t\t\t// If listener has been unsubscribed while invoking other listeners, skip it.\n\t\t\t\tif (listeners.has(listener)) {\n\t\t\t\t\tlistener(...argArray);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected emitAndCollect<K extends keyof TListeners>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): ReturnType<TListeners[K]>[] {\n\t\tconst listeners = this.listeners.get(eventName);\n\t\tif (listeners !== undefined) {\n\t\t\tconst argArray: unknown[] = args;\n\t\t\tconst resultArray: ReturnType<TListeners[K]>[] = [];\n\t\t\tfor (const listener of [...listeners.values()]) {\n\t\t\t\tresultArray.push(listener(...argArray));\n\t\t\t}\n\t\t\treturn resultArray;\n\t\t}\n\t\treturn [];\n\t}\n\n\tpublic on<K extends keyof Listeners<TListeners>>(\n\t\teventName: K,\n\t\tlistener: TListeners[K],\n\t): Off {\n\t\tconst listeners = getOrCreate(this.listeners, eventName, () => new Set());\n\t\tif (listeners.has(listener)) {\n\t\t\tconst eventDescription =\n\t\t\t\ttypeof eventName === \"symbol\" ? eventName.description : String(eventName.toString());\n\n\t\t\tthrow new Error(\n\t\t\t\t`Attempted to register the same listener object twice for event ${eventDescription}`,\n\t\t\t);\n\t\t}\n\t\tlisteners.add(listener);\n\t\treturn () => this.off(eventName, listener);\n\t}\n\n\tpublic off<K extends keyof Listeners<TListeners>>(\n\t\teventName: K,\n\t\tlistener: TListeners[K],\n\t): void {\n\t\tconst listeners = this.listeners.get(eventName);\n\t\tif (listeners?.delete(listener) === true && listeners.size === 0) {\n\t\t\tthis.listeners.delete(eventName);\n\t\t\tthis.noListeners?.(eventName);\n\t\t}\n\t}\n\n\tpublic hasListeners(eventName?: keyof TListeners): boolean {\n\t\tif (eventName === undefined) {\n\t\t\treturn this.listeners.size > 0;\n\t\t}\n\t\treturn this.listeners.has(eventName);\n\t}\n}\n\n/**\n * This class exposes the constructor and the `emit` method of `EventEmitter`, elevating them from protected to public\n * @internal\n */\nclass ComposableEventEmitter<TListeners extends Listeners<TListeners>>\n\textends CustomEventEmitter<TListeners>\n\timplements IEmitter<TListeners>\n{\n\tpublic constructor(noListeners?: NoListenersCallback<TListeners>) {\n\t\tsuper(noListeners);\n\t}\n\n\tpublic override emit<K extends keyof TListeners>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): void {\n\t\treturn super.emit(eventName, ...args);\n\t}\n\n\tpublic override emitAndCollect<K extends keyof TListeners>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): ReturnType<TListeners[K]>[] {\n\t\treturn super.emitAndCollect(eventName, ...args);\n\t}\n}\n\n/**\n * Create a {@link @fluidframework/core-interfaces#Listenable} that can be instructed to emit events via the {@link @fluidframework/core-interfaces#IEmitter} interface.\n *\n * A class can delegate handling {@link @fluidframework/core-interfaces#Listenable} to the returned value while using it to emit the events.\n * See also CustomEventEmitter which be used as a base class to implement {@link @fluidframework/core-interfaces#Listenable} via extension.\n * @example Forwarding events to the emitter\n * ```typescript\n * interface MyEvents {\n * \tloaded(): void;\n * }\n *\n * class MyClass implements Listenable<MyEvents> {\n * \tprivate readonly events = createEmitter<MyEvents>();\n *\n * \tprivate load(): void {\n * \t\tthis.events.emit(\"loaded\");\n * \t}\n *\n * \tpublic on<K extends keyof MyEvents>(eventName: K, listener: MyEvents[K]): Off {\n * \t\treturn this.events.on(eventName, listener);\n * \t}\n *\n * \tpublic off<K extends keyof MyEvents>(eventName: K, listener: MyEvents[K]): void {\n * \t\treturn this.events.off(eventName, listener);\n * \t}\n * }\n * ```\n * @internal\n */\nexport function createEmitter<TListeners extends object>(\n\tnoListeners?: NoListenersCallback<TListeners>,\n): Listenable<TListeners> & IEmitter<TListeners> & HasListeners<TListeners> {\n\treturn new ComposableEventEmitter<TListeners>(noListeners);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"emitter.js","sourceRoot":"","sources":["../../src/events/emitter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH;;;;;;;GAOG;AACH,SAAS,WAAW,CAAO,GAAoB,EAAE,GAAM,EAAE,YAA2B;IACnF,IAAI,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACzB,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;QAC1B,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,MAAM,OAAO,kBAAkB;IAUS;IAPpB,SAAS,GAAG,IAAI,GAAG,EAGnC,CAAC;IAEJ,uJAAuJ;IACvJ,6FAA6F;IAC7F,YAAuC,WAA6C;QAA7C,gBAAW,GAAX,WAAW,CAAkC;IAAG,CAAC;IAE9E,IAAI,C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G,IAAI,CAAC,CAAC;IACjD,CAAC;CACD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,aAAa,CAC5B,WAA6C;IAE7C,OAAO,IAAI,sBAAsB,CAAa,WAAW,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tHasListeners,\n\tIEmitter,\n\tListenable,\n\tListeners,\n\tMapGetSet,\n\tNoListenersCallback,\n\tOff,\n} from \"@fluidframework/core-interfaces/internal\";\n\n/**\n * Retrieve a value from a map with the given key, or create a new entry if the key is not in the map.\n * @param map - The map to query/update\n * @param key - The key to lookup in the map\n * @param defaultValue - a function which returns a default value. This is called and used to set an initial value for the given key in the map if none exists\n * @returns either the existing value for the given key, or the newly-created value (the result of `defaultValue`)\n * @internal\n */\nfunction getOrCreate<K, V>(map: MapGetSet<K, V>, key: K, defaultValue: (key: K) => V): V {\n\tlet value = map.get(key);\n\tif (value === undefined) {\n\t\tvalue = defaultValue(key);\n\t\tmap.set(key, value);\n\t}\n\treturn value;\n}\n\n/**\n * Provides an API for subscribing to and listening to events.\n *\n * @remarks Classes wishing to emit events may either extend this class, compose over it, or expose it as a property of type {@link @fluidframework/core-interfaces#Listenable}.\n *\n * @example Extending this class\n *\n * ```typescript\n * interface MyEvents {\n * \tloaded: () => void;\n * \tcomputed: () => number;\n * }\n *\n * class MyInheritanceClass extends EventEmitter<MyEvents> {\n * \tprivate load() {\n * \t\tthis.emit(\"loaded\");\n * \t\tconst results: number[] = this.emitAndCollect(\"computed\");\n * \t}\n * }\n * ```\n *\n * @example Composing over this class\n *\n * ```typescript\n * class MyCompositionClass implements Listenable<MyEvents> {\n * \tprivate readonly events = createEmitter<MyEvents>();\n *\n * \tprivate load() {\n * \t\tthis.events.emit(\"loaded\");\n * \t\tconst results: number[] = this.events.emitAndCollect(\"computed\");\n * \t}\n *\n * \tpublic on<K extends keyof MyEvents>(eventName: K, listener: MyEvents[K]): () => void {\n * \t\treturn this.events.on(eventName, listener);\n * \t}\n * }\n * ```\n *\n * @example Exposing this class as a property\n *\n * ```typescript\n * class MyExposingClass {\n * \tprivate readonly _events = createEmitter<MyEvents>();\n * \tpublic readonly events: Listenable<MyEvents> = this._events;\n *\n * \tprivate load() {\n * \t\tthis._events.emit(\"loaded\");\n * \t\tconst results: number[] = this._events.emitAndCollect(\"computed\");\n * \t}\n * }\n * ```\n * @internal\n */\nexport class CustomEventEmitter<TListeners extends Listeners<TListeners>>\n\timplements Listenable<TListeners>, HasListeners<TListeners>\n{\n\tprotected readonly listeners = new Map<\n\t\tkeyof TListeners,\n\t\tSet<(...args: any[]) => TListeners[keyof TListeners]>\n\t>();\n\n\t// Because this is protected and not public, calling this externally (not from a subclass) makes sending events to the constructed instance impossible.\n\t// Instead, use the static `create` function to get an instance which allows emitting events.\n\tprotected constructor(private readonly noListeners?: NoListenersCallback<TListeners>) {}\n\n\tprotected emit<K extends keyof TListeners>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): void {\n\t\tconst listeners = this.listeners.get(eventName);\n\t\tif (listeners !== undefined) {\n\t\t\t// Current tsc (5.4.5) cannot spread `args` into `listener()`.\n\t\t\tconst argArray: unknown[] = args;\n\t\t\t// This explicitly copies listeners so that new listeners added during this call to emit will not receive this event.\n\t\t\tfor (const listener of [...listeners]) {\n\t\t\t\t// If listener has been unsubscribed while invoking other listeners, skip it.\n\t\t\t\tif (listeners.has(listener)) {\n\t\t\t\t\tlistener(...argArray);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected emitAndCollect<K extends keyof TListeners>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): ReturnType<TListeners[K]>[] {\n\t\tconst listeners = this.listeners.get(eventName);\n\t\tif (listeners !== undefined) {\n\t\t\tconst argArray: unknown[] = args;\n\t\t\tconst resultArray: ReturnType<TListeners[K]>[] = [];\n\t\t\tfor (const listener of [...listeners.values()]) {\n\t\t\t\tresultArray.push(listener(...argArray));\n\t\t\t}\n\t\t\treturn resultArray;\n\t\t}\n\t\treturn [];\n\t}\n\n\tpublic on<K extends keyof Listeners<TListeners>>(\n\t\teventName: K,\n\t\tlistener: TListeners[K],\n\t): Off {\n\t\tconst listeners = getOrCreate(this.listeners, eventName, () => new Set());\n\t\tif (listeners.has(listener)) {\n\t\t\tconst eventDescription =\n\t\t\t\ttypeof eventName === \"symbol\" ? eventName.description : String(eventName.toString());\n\n\t\t\tthrow new Error(\n\t\t\t\t`Attempted to register the same listener object twice for event ${eventDescription}`,\n\t\t\t);\n\t\t}\n\t\tlisteners.add(listener);\n\t\treturn () => this.off(eventName, listener);\n\t}\n\n\tpublic off<K extends keyof Listeners<TListeners>>(\n\t\teventName: K,\n\t\tlistener: TListeners[K],\n\t): void {\n\t\tconst listeners = this.listeners.get(eventName);\n\t\tif (listeners?.delete(listener) === true && listeners.size === 0) {\n\t\t\tthis.listeners.delete(eventName);\n\t\t\tthis.noListeners?.(eventName);\n\t\t}\n\t}\n\n\tpublic hasListeners(eventName?: keyof TListeners): boolean {\n\t\tif (eventName === undefined) {\n\t\t\treturn this.listeners.size > 0;\n\t\t}\n\t\treturn this.listeners.has(eventName);\n\t}\n}\n\n/**\n * This class exposes the constructor and the `emit` method of `EventEmitter`, elevating them from protected to public\n * @internal\n */\nclass ComposableEventEmitter<TListeners extends Listeners<TListeners>>\n\textends CustomEventEmitter<TListeners>\n\timplements IEmitter<TListeners>\n{\n\tpublic constructor(noListeners?: NoListenersCallback<TListeners>) {\n\t\tsuper(noListeners);\n\t}\n\n\tpublic override emit<K extends keyof TListeners>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): void {\n\t\treturn super.emit(eventName, ...args);\n\t}\n\n\tpublic override emitAndCollect<K extends keyof TListeners>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): ReturnType<TListeners[K]>[] {\n\t\treturn super.emitAndCollect(eventName, ...args);\n\t}\n}\n\n/**\n * Create a {@link @fluidframework/core-interfaces#Listenable} that can be instructed to emit events via the {@link @fluidframework/core-interfaces#IEmitter} interface.\n *\n * A class can delegate handling {@link @fluidframework/core-interfaces#Listenable} to the returned value while using it to emit the events.\n * See also CustomEventEmitter which be used as a base class to implement {@link @fluidframework/core-interfaces#Listenable} via extension.\n * @example Forwarding events to the emitter\n * ```typescript\n * interface MyEvents {\n * \tloaded(): void;\n * }\n *\n * class MyClass implements Listenable<MyEvents> {\n * \tprivate readonly events = createEmitter<MyEvents>();\n *\n * \tprivate load(): void {\n * \t\tthis.events.emit(\"loaded\");\n * \t}\n *\n * \tpublic on<K extends keyof MyEvents>(eventName: K, listener: MyEvents[K]): Off {\n * \t\treturn this.events.on(eventName, listener);\n * \t}\n *\n * \tpublic off<K extends keyof MyEvents>(eventName: K, listener: MyEvents[K]): void {\n * \t\treturn this.events.off(eventName, listener);\n * \t}\n * }\n * ```\n * @internal\n */\nexport function createEmitter<TListeners extends object>(\n\tnoListeners?: NoListenersCallback<TListeners>,\n): Listenable<TListeners> & IEmitter<TListeners> & HasListeners<TListeners> {\n\treturn new ComposableEventEmitter<TListeners>(noListeners);\n}\n"]}
|
package/lib/hashFileBrowser.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { IsoBuffer } from "./bufferBrowser.js";
|
|
|
16
16
|
*
|
|
17
17
|
* @internal
|
|
18
18
|
*/
|
|
19
|
-
export declare function hashFile(file: IsoBuffer
|
|
19
|
+
export declare function hashFile(file: IsoBuffer<ArrayBuffer>, algorithm?: "SHA-1" | "SHA-256", hashEncoding?: "hex" | "base64"): Promise<string>;
|
|
20
20
|
/**
|
|
21
21
|
* Create a github hash (Github hashes the string with blob and size)
|
|
22
22
|
* Must be called under secure context for browsers
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hashFileBrowser.d.ts","sourceRoot":"","sources":["../src/hashFileBrowser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AA4B/C;;;;;;;;;;;;GAYG;AACH,wBAAsB,QAAQ,CAC7B,IAAI,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"hashFileBrowser.d.ts","sourceRoot":"","sources":["../src/hashFileBrowser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AA4B/C;;;;;;;;;;;;GAYG;AACH,wBAAsB,QAAQ,CAC7B,IAAI,EAAE,SAAS,CAAC,WAAW,CAAC,EAC5B,SAAS,GAAE,OAAO,GAAG,SAAmB,EACxC,YAAY,GAAE,KAAK,GAAG,QAAgB,GACpC,OAAO,CAAC,MAAM,CAAC,CAgBjB;AAED;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAWlE"}
|
package/lib/hashFileBrowser.js
CHANGED
|
@@ -67,7 +67,10 @@ export async function gitHashFile(file) {
|
|
|
67
67
|
const size = file.byteLength;
|
|
68
68
|
// eslint-disable-next-line unicorn/prefer-code-point
|
|
69
69
|
const filePrefix = `blob ${size.toString()}${String.fromCharCode(0)}`;
|
|
70
|
-
const
|
|
70
|
+
const prefixBuffer = IsoBuffer.from(filePrefix);
|
|
71
|
+
const hashBuffer = new IsoBuffer(prefixBuffer.byteLength + file.byteLength);
|
|
72
|
+
hashBuffer.set(prefixBuffer);
|
|
73
|
+
hashBuffer.set(file, prefixBuffer.byteLength);
|
|
71
74
|
// hashFile uses sha1; if that changes this will need to change too
|
|
72
75
|
return hashFile(hashBuffer);
|
|
73
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hashFileBrowser.js","sourceRoot":"","sources":["../src/hashFileBrowser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,QAAQ,MAAM,WAAW,CAAC;AA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;IAC3D,gFAAgF;IAChF,8EAA8E;IAC9E,8BAA8B;IAC9B,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QACjC,OAAO,MAAM;QACZ,qDAAqD;QACrD,mBAAmB,CACnB,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;IAChE,CAAC;IAED,+EAA+E;IAC/E,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACtD,OAAO,YAAY,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;AAC9C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAAe;IAChD,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;IAC7B,qDAAqD;IACrD,MAAM,UAAU,GAAG,QAAQ,IAAI,CAAC,QAAQ,EAAE,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IACtE,MAAM,YAAY,GAAG,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAChD,MAAM,UAAU,GAAG,IAAI,SAAS,CAAC,YAAY,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;IAC5E,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC7B,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;IAE9C,mEAAmE;IACnE,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as base64js from \"base64-js\";\n\n// Note: See 'Isomorphic Code' section in the package README.md\nimport { IsoBuffer } from \"./bufferBrowser.js\";\n\nasync function digestBuffer(\n\tfile: IsoBuffer<ArrayBuffer>,\n\talgorithm: \"SHA-1\" | \"SHA-256\",\n): Promise<Uint8Array> {\n\tconst hash = await crypto.subtle.digest(algorithm, file);\n\treturn new Uint8Array(hash);\n}\n\nfunction encodeDigest(hashArray: Uint8Array, encoding: \"hex\" | \"base64\"): string {\n\t// eslint-disable-next-line default-case\n\tswitch (encoding) {\n\t\tcase \"hex\": {\n\t\t\tconst hashHex = Array.prototype.map\n\t\t\t\t.call(hashArray, (byte) => {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n\t\t\t\t\treturn byte.toString(16).padStart(2, \"0\") as string;\n\t\t\t\t})\n\t\t\t\t.join(\"\");\n\t\t\treturn hashHex;\n\t\t}\n\t\tcase \"base64\": {\n\t\t\treturn base64js.fromByteArray(hashArray);\n\t\t}\n\t}\n}\n\n/**\n * Hash a file. Consistent within a session, but should not be persisted and\n * is not consistent with git.\n * If called under an insecure context for a browser, this will fallback to\n * using the node implementation.\n *\n * @param file - The contents of the file in a buffer.\n * @param algorithm - The hash algorithm to use, artificially constrained by what is used internally.\n * @param hashEncoding - The encoding of the returned hash, also artificially constrained.\n * @returns The hash of the content of the buffer.\n *\n * @internal\n */\nexport async function hashFile(\n\tfile: IsoBuffer<ArrayBuffer>,\n\talgorithm: \"SHA-1\" | \"SHA-256\" = \"SHA-1\",\n\thashEncoding: \"hex\" | \"base64\" = \"hex\",\n): Promise<string> {\n\t// Handle insecure contexts (e.g. running with local services)\n\t// by deferring to Node version, which uses a hash polyfill\n\t// When packed, this chunk will show as \"FluidFramework-HashFallback\" separately\n\t// from the main chunk and will be of non-trivial size. It will not be served\n\t// under normal circumstances.\n\tif (crypto.subtle === undefined) {\n\t\treturn import(\n\t\t\t/* webpackChunkName: \"FluidFramework-HashFallback\" */\n\t\t\t\"./hashFileNode.js\"\n\t\t).then(async (m) => m.hashFile(file, algorithm, hashEncoding));\n\t}\n\n\t// This is split up this way to facilitate testing (see the test for more info)\n\tconst hashArray = await digestBuffer(file, algorithm);\n\treturn encodeDigest(hashArray, hashEncoding);\n}\n\n/**\n * Create a github hash (Github hashes the string with blob and size)\n * Must be called under secure context for browsers\n *\n * @param file - The contents of the file in a buffer\n * @returns The sha1 hash of the content of the buffer with the `blob` prefix and size\n *\n * @internal\n */\nexport async function gitHashFile(file: IsoBuffer): Promise<string> {\n\tconst size = file.byteLength;\n\t// eslint-disable-next-line unicorn/prefer-code-point\n\tconst filePrefix = `blob ${size.toString()}${String.fromCharCode(0)}`;\n\tconst prefixBuffer = IsoBuffer.from(filePrefix);\n\tconst hashBuffer = new IsoBuffer(prefixBuffer.byteLength + file.byteLength);\n\thashBuffer.set(prefixBuffer);\n\thashBuffer.set(file, prefixBuffer.byteLength);\n\n\t// hashFile uses sha1; if that changes this will need to change too\n\treturn hashFile(hashBuffer);\n}\n"]}
|
package/lib/hashFileNode.d.ts
CHANGED
|
@@ -15,8 +15,12 @@ import type { IsoBuffer } from "./bufferNode.js";
|
|
|
15
15
|
* @returns The hash of the content of the buffer.
|
|
16
16
|
*
|
|
17
17
|
* @internal
|
|
18
|
+
*
|
|
19
|
+
* @privateRemarks
|
|
20
|
+
* This function does not strictly require `<ArrayBuffer>` backing, but it is typed
|
|
21
|
+
* that way to match the browser implementation, which does require `<ArrayBuffer>` backing.
|
|
18
22
|
*/
|
|
19
|
-
export declare function hashFile(file: IsoBuffer
|
|
23
|
+
export declare function hashFile(file: IsoBuffer<ArrayBuffer>, algorithm?: "SHA-1" | "SHA-256", hashEncoding?: "hex" | "base64"): Promise<string>;
|
|
20
24
|
/**
|
|
21
25
|
* Create a github hash (Github hashes the string with blob and size)
|
|
22
26
|
* Must be called under secure context for browsers
|
|
@@ -25,6 +29,10 @@ export declare function hashFile(file: IsoBuffer, algorithm?: "SHA-1" | "SHA-256
|
|
|
25
29
|
* @returns The sha1 hash of the content of the buffer with the `blob` prefix and size
|
|
26
30
|
*
|
|
27
31
|
* @internal
|
|
32
|
+
*
|
|
33
|
+
* @privateRemarks
|
|
34
|
+
* This function does not strictly require `<ArrayBuffer>` backing, but it is typed
|
|
35
|
+
* that way to match the browser implementation, which does require `<ArrayBuffer>` backing.
|
|
28
36
|
*/
|
|
29
|
-
export declare function gitHashFile(file: IsoBuffer): Promise<string>;
|
|
37
|
+
export declare function gitHashFile(file: IsoBuffer<ArrayBuffer>): Promise<string>;
|
|
30
38
|
//# sourceMappingURL=hashFileNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hashFileNode.d.ts","sourceRoot":"","sources":["../src/hashFileNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD
|
|
1
|
+
{"version":3,"file":"hashFileNode.d.ts","sourceRoot":"","sources":["../src/hashFileNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,QAAQ,CAC7B,IAAI,EAAE,SAAS,CAAC,WAAW,CAAC,EAC5B,SAAS,GAAE,OAAO,GAAG,SAAmB,EACxC,YAAY,GAAE,KAAK,GAAG,QAAgB,GACpC,OAAO,CAAC,MAAM,CAAC,CAejB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,SAAS,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAM/E"}
|
package/lib/hashFileNode.js
CHANGED
|
@@ -15,6 +15,10 @@ import { sha1, sha256 } from "sha.js";
|
|
|
15
15
|
* @returns The hash of the content of the buffer.
|
|
16
16
|
*
|
|
17
17
|
* @internal
|
|
18
|
+
*
|
|
19
|
+
* @privateRemarks
|
|
20
|
+
* This function does not strictly require `<ArrayBuffer>` backing, but it is typed
|
|
21
|
+
* that way to match the browser implementation, which does require `<ArrayBuffer>` backing.
|
|
18
22
|
*/
|
|
19
23
|
export async function hashFile(file, algorithm = "SHA-1", hashEncoding = "hex") {
|
|
20
24
|
let engine;
|
|
@@ -40,6 +44,10 @@ export async function hashFile(file, algorithm = "SHA-1", hashEncoding = "hex")
|
|
|
40
44
|
* @returns The sha1 hash of the content of the buffer with the `blob` prefix and size
|
|
41
45
|
*
|
|
42
46
|
* @internal
|
|
47
|
+
*
|
|
48
|
+
* @privateRemarks
|
|
49
|
+
* This function does not strictly require `<ArrayBuffer>` backing, but it is typed
|
|
50
|
+
* that way to match the browser implementation, which does require `<ArrayBuffer>` backing.
|
|
43
51
|
*/
|
|
44
52
|
export async function gitHashFile(file) {
|
|
45
53
|
const size = file.byteLength;
|
package/lib/hashFileNode.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hashFileNode.js","sourceRoot":"","sources":["../src/hashFileNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKtC
|
|
1
|
+
{"version":3,"file":"hashFileNode.js","sourceRoot":"","sources":["../src/hashFileNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKtC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC7B,IAA4B,EAC5B,YAAiC,OAAO,EACxC,eAAiC,KAAK;IAEtC,IAAI,MAAM,CAAC;IACX,wCAAwC;IACxC,QAAQ,SAAS,EAAE,CAAC;QACnB,KAAK,OAAO,CAAC,CAAC,CAAC;YACd,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACpB,MAAM;QACP,CAAC;QACD,KAAK,SAAS,CAAC,CAAC,CAAC;YAChB,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;YACtB,MAAM;QACP,CAAC;IACF,CAAC;IACD,yGAAyG;IACzG,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,YAAY,CAAW,CAAC;AAC3D,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAA4B;IAC7D,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;IAC7B,qDAAqD;IACrD,MAAM,UAAU,GAAG,QAAQ,IAAI,CAAC,QAAQ,EAAE,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IACtE,MAAM,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;IAC1B,OAAO,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC7D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { sha1, sha256 } from \"sha.js\";\n\n// Note: See 'Isomorphic Code' section in the package README.md\nimport type { IsoBuffer } from \"./bufferNode.js\";\n\n/**\n * Hash a file. Consistent within a session, but should not be persisted and\n * is not consistent with git.\n * If called under an insecure context for a browser, this will fallback to\n * using the node implementation.\n *\n * @param file - The contents of the file in a buffer.\n * @param algorithm - The hash algorithm to use, artificially constrained by what is used internally.\n * @param hashEncoding - The encoding of the returned hash, also artificially constrained.\n * @returns The hash of the content of the buffer.\n *\n * @internal\n *\n * @privateRemarks\n * This function does not strictly require `<ArrayBuffer>` backing, but it is typed\n * that way to match the browser implementation, which does require `<ArrayBuffer>` backing.\n */\nexport async function hashFile(\n\tfile: IsoBuffer<ArrayBuffer>,\n\talgorithm: \"SHA-1\" | \"SHA-256\" = \"SHA-1\",\n\thashEncoding: \"hex\" | \"base64\" = \"hex\",\n): Promise<string> {\n\tlet engine;\n\t// eslint-disable-next-line default-case\n\tswitch (algorithm) {\n\t\tcase \"SHA-1\": {\n\t\t\tengine = new sha1();\n\t\t\tbreak;\n\t\t}\n\t\tcase \"SHA-256\": {\n\t\t\tengine = new sha256();\n\t\t\tbreak;\n\t\t}\n\t}\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n\treturn engine.update(file).digest(hashEncoding) as string;\n}\n\n/**\n * Create a github hash (Github hashes the string with blob and size)\n * Must be called under secure context for browsers\n *\n * @param file - The contents of the file in a buffer\n * @returns The sha1 hash of the content of the buffer with the `blob` prefix and size\n *\n * @internal\n *\n * @privateRemarks\n * This function does not strictly require `<ArrayBuffer>` backing, but it is typed\n * that way to match the browser implementation, which does require `<ArrayBuffer>` backing.\n */\nexport async function gitHashFile(file: IsoBuffer<ArrayBuffer>): Promise<string> {\n\tconst size = file.byteLength;\n\t// eslint-disable-next-line unicorn/prefer-code-point\n\tconst filePrefix = `blob ${size.toString()}${String.fromCharCode(0)}`;\n\tconst engine = new sha1();\n\treturn engine.update(filePrefix).update(file).digest(\"hex\");\n}\n"]}
|
package/lib/indexBrowser.d.ts
CHANGED
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export {
|
|
5
|
+
export type { IsoBuffer as IsoBufferInterface } from "./buffer.js";
|
|
6
|
+
export type { IsoBufferConstructor, IsoBufferEncoding, } from "./bufferBrowser.js";
|
|
7
|
+
export { bufferToString, IsoBuffer, stringToBuffer, Uint8ArrayToString, } from "./bufferBrowser.js";
|
|
6
8
|
export { gitHashFile, hashFile } from "./hashFileBrowser.js";
|
|
7
9
|
export { fromBase64ToUtf8, fromUtf8ToBase64, toUtf8 } from "./base64EncodingBrowser.js";
|
|
8
|
-
export {
|
|
10
|
+
export { AnyUint8ArrayToArrayBuffer, ArrayBufferLikeToArrayBuffer, Uint8ArrayToArrayBufferLike, } from "./bufferShared.js";
|
|
9
11
|
export { EventEmitter } from "./eventEmitter.cjs";
|
|
10
12
|
export { performanceNow } from "./performanceIsomorphic.js";
|
|
11
13
|
export { type ITraceEvent, Trace } from "./trace.js";
|
|
12
14
|
export { type EventEmitterEventType, TypedEventEmitter, type TypedEventTransform, } from "./typedEventEmitter.js";
|
|
13
15
|
export { createEmitter } from "./events/index.js";
|
|
14
|
-
export { type FluidLayer, checkLayerCompatibility, type LayerCompatCheckResult, type ILayerCompatDetails, type IProvideLayerCompatDetails, type ILayerCompatSupportRequirements, LayerCompatibilityPolicyWindowMonths, } from "./layerCompat.js";
|
|
16
|
+
export { type FluidLayer, checkLayerCompatibility, type LayerCompatCheckResult, type ILayerCompatDetails, type IProvideLayerCompatDetails, type ILayerCompatSupportRequirements, type IProvideLayerCompatSupportRequirements, defaultLayerCompatDetails, LayerCompatibilityPolicyWindowMonths, } from "./layerCompat.js";
|
|
15
17
|
export { generation } from "./layerGenerationState.js";
|
|
16
18
|
//# sourceMappingURL=indexBrowser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexBrowser.d.ts","sourceRoot":"","sources":["../src/indexBrowser.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"indexBrowser.d.ts","sourceRoot":"","sources":["../src/indexBrowser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,YAAY,EAAE,SAAS,IAAI,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACnE,YAAY,EACX,oBAAoB,EACpB,iBAAiB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,cAAc,EACd,SAAS,EACT,cAAc,EACd,kBAAkB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAE7D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACxF,OAAO,EACN,0BAA0B,EAC1B,4BAA4B,EAC5B,2BAA2B,GAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EACN,KAAK,qBAAqB,EAC1B,iBAAiB,EACjB,KAAK,mBAAmB,GACxB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EACN,KAAK,UAAU,EACf,uBAAuB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,+BAA+B,EACpC,KAAK,sCAAsC,EAC3C,yBAAyB,EACzB,oCAAoC,GACpC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC"}
|
package/lib/indexBrowser.js
CHANGED
|
@@ -2,17 +2,15 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
// (See 'Isomorphic Code' section in the package README.md.)
|
|
7
|
-
export { bufferToString, isArrayBuffer, IsoBuffer, stringToBuffer, Uint8ArrayToString, } from "./bufferBrowser.js";
|
|
5
|
+
export { bufferToString, IsoBuffer, stringToBuffer, Uint8ArrayToString, } from "./bufferBrowser.js";
|
|
8
6
|
export { gitHashFile, hashFile } from "./hashFileBrowser.js";
|
|
9
7
|
export { fromBase64ToUtf8, fromUtf8ToBase64, toUtf8 } from "./base64EncodingBrowser.js";
|
|
10
|
-
export {
|
|
8
|
+
export { AnyUint8ArrayToArrayBuffer, ArrayBufferLikeToArrayBuffer, Uint8ArrayToArrayBufferLike, } from "./bufferShared.js";
|
|
11
9
|
export { EventEmitter } from "./eventEmitter.cjs";
|
|
12
10
|
export { performanceNow } from "./performanceIsomorphic.js";
|
|
13
11
|
export { Trace } from "./trace.js";
|
|
14
12
|
export { TypedEventEmitter, } from "./typedEventEmitter.js";
|
|
15
13
|
export { createEmitter } from "./events/index.js";
|
|
16
|
-
export { checkLayerCompatibility, LayerCompatibilityPolicyWindowMonths, } from "./layerCompat.js";
|
|
14
|
+
export { checkLayerCompatibility, defaultLayerCompatDetails, LayerCompatibilityPolicyWindowMonths, } from "./layerCompat.js";
|
|
17
15
|
export { generation } from "./layerGenerationState.js";
|
|
18
16
|
//# sourceMappingURL=indexBrowser.js.map
|
package/lib/indexBrowser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexBrowser.js","sourceRoot":"","sources":["../src/indexBrowser.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"indexBrowser.js","sourceRoot":"","sources":["../src/indexBrowser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH,OAAO,EACN,cAAc,EACd,SAAS,EACT,cAAc,EACd,kBAAkB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAE7D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACxF,OAAO,EACN,0BAA0B,EAC1B,4BAA4B,EAC5B,2BAA2B,GAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAoB,KAAK,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAEN,iBAAiB,GAEjB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAEN,uBAAuB,EAMvB,yBAAyB,EACzB,oCAAoC,GACpC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// Entrypoint for browser-specific code in the package.\n// (See 'Isomorphic Code' section in the package README.md.)\n\n// This export is needed for api-extractor compliance.\nexport type { IsoBuffer as IsoBufferInterface } from \"./buffer.js\";\nexport type {\n\tIsoBufferConstructor,\n\tIsoBufferEncoding,\n} from \"./bufferBrowser.js\";\nexport {\n\tbufferToString,\n\tIsoBuffer,\n\tstringToBuffer,\n\tUint8ArrayToString,\n} from \"./bufferBrowser.js\";\nexport { gitHashFile, hashFile } from \"./hashFileBrowser.js\";\n\nexport { fromBase64ToUtf8, fromUtf8ToBase64, toUtf8 } from \"./base64EncodingBrowser.js\";\nexport {\n\tAnyUint8ArrayToArrayBuffer,\n\tArrayBufferLikeToArrayBuffer,\n\tUint8ArrayToArrayBufferLike,\n} from \"./bufferShared.js\";\nexport { EventEmitter } from \"./eventEmitter.cjs\";\nexport { performanceNow } from \"./performanceIsomorphic.js\";\nexport { type ITraceEvent, Trace } from \"./trace.js\";\nexport {\n\ttype EventEmitterEventType,\n\tTypedEventEmitter,\n\ttype TypedEventTransform,\n} from \"./typedEventEmitter.js\";\n\nexport { createEmitter } from \"./events/index.js\";\n\nexport {\n\ttype FluidLayer,\n\tcheckLayerCompatibility,\n\ttype LayerCompatCheckResult,\n\ttype ILayerCompatDetails,\n\ttype IProvideLayerCompatDetails,\n\ttype ILayerCompatSupportRequirements,\n\ttype IProvideLayerCompatSupportRequirements,\n\tdefaultLayerCompatDetails,\n\tLayerCompatibilityPolicyWindowMonths,\n} from \"./layerCompat.js\";\nexport { generation } from \"./layerGenerationState.js\";\n"]}
|
package/lib/indexNode.d.ts
CHANGED
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export {
|
|
5
|
+
export type { IsoBuffer as IsoBufferInterface } from "./buffer.js";
|
|
6
|
+
export type { Buffer, IsoBufferConstructor, IsoBufferEncoding, } from "./bufferNode.js";
|
|
6
7
|
export { bufferToString, IsoBuffer, stringToBuffer, Uint8ArrayToString, } from "./bufferNode.js";
|
|
7
8
|
export { gitHashFile, hashFile } from "./hashFileNode.js";
|
|
8
9
|
export { fromBase64ToUtf8, fromUtf8ToBase64, toUtf8 } from "./base64EncodingNode.js";
|
|
9
|
-
export {
|
|
10
|
+
export { AnyUint8ArrayToArrayBuffer, ArrayBufferLikeToArrayBuffer, Uint8ArrayToArrayBufferLike, } from "./bufferShared.js";
|
|
10
11
|
export { EventEmitter } from "./eventEmitter.cjs";
|
|
11
12
|
export { performanceNow } from "./performanceIsomorphic.js";
|
|
12
13
|
export { type ITraceEvent, Trace } from "./trace.js";
|
|
13
14
|
export { type EventEmitterEventType, TypedEventEmitter, type TypedEventTransform, } from "./typedEventEmitter.js";
|
|
14
15
|
export { createEmitter } from "./events/index.js";
|
|
15
|
-
export { type FluidLayer, checkLayerCompatibility, type LayerCompatCheckResult, type ILayerCompatDetails, type IProvideLayerCompatDetails, type ILayerCompatSupportRequirements, LayerCompatibilityPolicyWindowMonths, } from "./layerCompat.js";
|
|
16
|
+
export { type FluidLayer, checkLayerCompatibility, type LayerCompatCheckResult, type ILayerCompatDetails, type IProvideLayerCompatDetails, type ILayerCompatSupportRequirements, type IProvideLayerCompatSupportRequirements, defaultLayerCompatDetails, LayerCompatibilityPolicyWindowMonths, } from "./layerCompat.js";
|
|
16
17
|
export { generation } from "./layerGenerationState.js";
|
|
17
18
|
//# sourceMappingURL=indexNode.d.ts.map
|
package/lib/indexNode.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexNode.d.ts","sourceRoot":"","sources":["../src/indexNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,
|
|
1
|
+
{"version":3,"file":"indexNode.d.ts","sourceRoot":"","sources":["../src/indexNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,YAAY,EAAE,SAAS,IAAI,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACnE,YAAY,EACX,MAAM,EACN,oBAAoB,EACpB,iBAAiB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,cAAc,EACd,SAAS,EACT,cAAc,EACd,kBAAkB,GAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACrF,OAAO,EACN,0BAA0B,EAC1B,4BAA4B,EAC5B,2BAA2B,GAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EACN,KAAK,qBAAqB,EAC1B,iBAAiB,EACjB,KAAK,mBAAmB,GACxB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EACN,KAAK,UAAU,EACf,uBAAuB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,+BAA+B,EACpC,KAAK,sCAAsC,EAC3C,yBAAyB,EACzB,oCAAoC,GACpC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC"}
|
package/lib/indexNode.js
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
export { bufferToString, IsoBuffer, stringToBuffer, Uint8ArrayToString, } from "./bufferNode.js";
|
|
6
6
|
export { gitHashFile, hashFile } from "./hashFileNode.js";
|
|
7
7
|
export { fromBase64ToUtf8, fromUtf8ToBase64, toUtf8 } from "./base64EncodingNode.js";
|
|
8
|
-
export {
|
|
8
|
+
export { AnyUint8ArrayToArrayBuffer, ArrayBufferLikeToArrayBuffer, Uint8ArrayToArrayBufferLike, } from "./bufferShared.js";
|
|
9
9
|
export { EventEmitter } from "./eventEmitter.cjs";
|
|
10
10
|
export { performanceNow } from "./performanceIsomorphic.js";
|
|
11
11
|
export { Trace } from "./trace.js";
|
|
12
12
|
export { TypedEventEmitter, } from "./typedEventEmitter.js";
|
|
13
13
|
export { createEmitter } from "./events/index.js";
|
|
14
|
-
export { checkLayerCompatibility, LayerCompatibilityPolicyWindowMonths, } from "./layerCompat.js";
|
|
14
|
+
export { checkLayerCompatibility, defaultLayerCompatDetails, LayerCompatibilityPolicyWindowMonths, } from "./layerCompat.js";
|
|
15
15
|
export { generation } from "./layerGenerationState.js";
|
|
16
16
|
//# sourceMappingURL=indexNode.js.map
|
package/lib/indexNode.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexNode.js","sourceRoot":"","sources":["../src/indexNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"indexNode.js","sourceRoot":"","sources":["../src/indexNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH,OAAO,EACN,cAAc,EACd,SAAS,EACT,cAAc,EACd,kBAAkB,GAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACrF,OAAO,EACN,0BAA0B,EAC1B,4BAA4B,EAC5B,2BAA2B,GAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAoB,KAAK,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAEN,iBAAiB,GAEjB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAEN,uBAAuB,EAMvB,yBAAyB,EACzB,oCAAoC,GACpC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// Entrypoint for Node.js-specific code in the package.\n// (See 'Isomorphic Code' section in the package README.md.)\n\nexport type { IsoBuffer as IsoBufferInterface } from \"./buffer.js\";\nexport type {\n\tBuffer,\n\tIsoBufferConstructor,\n\tIsoBufferEncoding,\n} from \"./bufferNode.js\";\nexport {\n\tbufferToString,\n\tIsoBuffer,\n\tstringToBuffer,\n\tUint8ArrayToString,\n} from \"./bufferNode.js\";\nexport { gitHashFile, hashFile } from \"./hashFileNode.js\";\n\nexport { fromBase64ToUtf8, fromUtf8ToBase64, toUtf8 } from \"./base64EncodingNode.js\";\nexport {\n\tAnyUint8ArrayToArrayBuffer,\n\tArrayBufferLikeToArrayBuffer,\n\tUint8ArrayToArrayBufferLike,\n} from \"./bufferShared.js\";\nexport { EventEmitter } from \"./eventEmitter.cjs\";\nexport { performanceNow } from \"./performanceIsomorphic.js\";\nexport { type ITraceEvent, Trace } from \"./trace.js\";\nexport {\n\ttype EventEmitterEventType,\n\tTypedEventEmitter,\n\ttype TypedEventTransform,\n} from \"./typedEventEmitter.js\";\n\nexport { createEmitter } from \"./events/index.js\";\n\nexport {\n\ttype FluidLayer,\n\tcheckLayerCompatibility,\n\ttype LayerCompatCheckResult,\n\ttype ILayerCompatDetails,\n\ttype IProvideLayerCompatDetails,\n\ttype ILayerCompatSupportRequirements,\n\ttype IProvideLayerCompatSupportRequirements,\n\tdefaultLayerCompatDetails,\n\tLayerCompatibilityPolicyWindowMonths,\n} from \"./layerCompat.js\";\nexport { generation } from \"./layerGenerationState.js\";\n"]}
|