@fluid-internal/client-utils 2.0.0-rc.1.0.3 → 2.0.0-rc.2.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/{.eslintrc.js → .eslintrc.cjs} +1 -1
- package/{.mocharc.js → .mocharc.cjs} +1 -1
- package/CHANGELOG.md +4 -0
- package/{api-extractor-esm.json → api-extractor-cjs.json} +5 -1
- package/api-extractor-lint.json +1 -1
- package/api-extractor.json +1 -1
- package/api-report/client-utils.api.md +8 -27
- package/dist/base64Encoding.js +4 -4
- package/dist/base64Encoding.js.map +1 -1
- package/dist/client-utils-alpha.d.ts +6 -11
- package/dist/client-utils-beta.d.ts +5 -11
- package/dist/client-utils-public.d.ts +5 -11
- package/dist/client-utils-untrimmed.d.ts +9 -39
- package/dist/eventEmitter.cjs +11 -0
- package/dist/eventEmitter.cjs.map +1 -0
- package/{lib/index.d.mts → dist/eventEmitter.d.cts} +2 -2
- package/dist/eventEmitter.d.cts.map +1 -0
- package/dist/hashFileBrowser.d.ts +1 -1
- package/dist/hashFileBrowser.d.ts.map +1 -1
- package/dist/hashFileBrowser.js +2 -2
- package/dist/hashFileBrowser.js.map +1 -1
- package/dist/hashFileNode.d.ts +1 -1
- package/dist/hashFileNode.d.ts.map +1 -1
- package/dist/hashFileNode.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/indexBrowser.d.ts +9 -9
- package/dist/indexBrowser.d.ts.map +1 -1
- package/dist/indexBrowser.js +24 -24
- package/dist/indexBrowser.js.map +1 -1
- package/dist/indexNode.d.ts +10 -10
- package/dist/indexNode.d.ts.map +1 -1
- package/dist/indexNode.js +23 -23
- package/dist/indexNode.js.map +1 -1
- package/dist/package.json +7 -0
- package/dist/trace.js +3 -3
- package/dist/trace.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/typedEventEmitter.d.ts +3 -6
- package/dist/typedEventEmitter.d.ts.map +1 -1
- package/dist/typedEventEmitter.js +2 -4
- package/dist/typedEventEmitter.js.map +1 -1
- package/{jest-puppeteer.config.js → jest-puppeteer.config.cjs} +4 -1
- package/{jest.config.js → jest.config.cjs} +1 -0
- package/lib/{base64Encoding.d.mts → base64Encoding.d.ts} +1 -1
- package/lib/base64Encoding.d.ts.map +1 -0
- package/lib/{base64Encoding.mjs → base64Encoding.js} +2 -2
- package/lib/base64Encoding.js.map +1 -0
- package/lib/{bufferBrowser.d.mts → bufferBrowser.d.ts} +1 -1
- package/lib/bufferBrowser.d.ts.map +1 -0
- package/lib/{bufferBrowser.mjs → bufferBrowser.js} +1 -1
- package/lib/bufferBrowser.js.map +1 -0
- package/lib/{bufferNode.d.mts → bufferNode.d.ts} +1 -1
- package/lib/bufferNode.d.ts.map +1 -0
- package/lib/{bufferNode.mjs → bufferNode.js} +1 -1
- package/lib/bufferNode.js.map +1 -0
- package/lib/{bufferShared.d.mts → bufferShared.d.ts} +1 -1
- package/lib/bufferShared.d.ts.map +1 -0
- package/lib/{bufferShared.mjs → bufferShared.js} +1 -1
- package/lib/bufferShared.js.map +1 -0
- package/lib/{client-utils-alpha.d.mts → client-utils-alpha.d.ts} +6 -11
- package/lib/{client-utils-public.d.mts → client-utils-beta.d.ts} +5 -11
- package/lib/{client-utils-beta.d.mts → client-utils-public.d.ts} +5 -11
- package/lib/{client-utils-untrimmed.d.mts → client-utils-untrimmed.d.ts} +9 -39
- package/lib/eventEmitter.cjs +11 -0
- package/lib/eventEmitter.cjs.map +1 -0
- package/lib/eventEmitter.d.cts +6 -0
- package/lib/eventEmitter.d.cts.map +1 -0
- package/lib/{hashFileNode.d.mts → hashFileBrowser.d.ts} +2 -2
- package/lib/hashFileBrowser.d.ts.map +1 -0
- package/lib/{hashFileBrowser.mjs → hashFileBrowser.js} +5 -3
- package/lib/{hashFileBrowser.mjs.map → hashFileBrowser.js.map} +1 -1
- package/lib/{hashFileBrowser.d.mts → hashFileNode.d.ts} +2 -2
- package/lib/hashFileNode.d.ts.map +1 -0
- package/lib/{hashFileNode.mjs → hashFileNode.js} +1 -1
- package/lib/hashFileNode.js.map +1 -0
- package/lib/{index.mjs → index.d.ts} +2 -2
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +10 -0
- package/lib/index.js.map +1 -0
- package/lib/indexBrowser.d.ts +14 -0
- package/lib/indexBrowser.d.ts.map +1 -0
- package/lib/indexBrowser.js +13 -0
- package/lib/indexBrowser.js.map +1 -0
- package/lib/indexNode.d.ts +15 -0
- package/lib/indexNode.d.ts.map +1 -0
- package/lib/indexNode.js +13 -0
- package/lib/indexNode.js.map +1 -0
- package/lib/{performanceIsomorphic.d.mts → performanceIsomorphic.d.ts} +1 -1
- package/lib/performanceIsomorphic.d.ts.map +1 -0
- package/lib/{performanceIsomorphic.mjs → performanceIsomorphic.js} +1 -1
- package/lib/performanceIsomorphic.js.map +1 -0
- package/lib/test/mocha/typedEventEmitter.spec.js +43 -0
- package/lib/test/mocha/typedEventEmitter.spec.js.map +1 -0
- package/lib/test/types/validateClientUtilsPrevious.generated.js +42 -0
- package/lib/test/types/validateClientUtilsPrevious.generated.js.map +1 -0
- package/lib/{trace.d.mts → trace.d.ts} +1 -1
- package/lib/trace.d.ts.map +1 -0
- package/lib/{trace.mjs → trace.js} +2 -2
- package/lib/trace.js.map +1 -0
- package/lib/{typedEventEmitter.d.mts → typedEventEmitter.d.ts} +4 -7
- package/lib/typedEventEmitter.d.ts.map +1 -0
- package/lib/{typedEventEmitter.mjs → typedEventEmitter.js} +2 -2
- package/lib/typedEventEmitter.js.map +1 -0
- package/package.json +50 -35
- package/src/base64Encoding.ts +1 -1
- package/src/cjs/package.json +7 -0
- package/src/eventEmitter.cts +7 -0
- package/src/hashFileBrowser.ts +1 -1
- package/src/hashFileNode.ts +1 -1
- package/src/index.ts +1 -1
- package/src/indexBrowser.ts +13 -9
- package/src/indexNode.ts +14 -10
- package/src/trace.ts +1 -1
- package/src/typedEventEmitter.ts +3 -8
- package/tsconfig.cjs.json +7 -0
- package/tsconfig.json +4 -7
- package/dist/eventForwarder.d.ts +0 -34
- package/dist/eventForwarder.d.ts.map +0 -1
- package/dist/eventForwarder.js +0 -98
- package/dist/eventForwarder.js.map +0 -1
- package/lib/base64Encoding.d.mts.map +0 -1
- package/lib/base64Encoding.mjs.map +0 -1
- package/lib/bufferBrowser.d.mts.map +0 -1
- package/lib/bufferBrowser.mjs.map +0 -1
- package/lib/bufferNode.d.mts.map +0 -1
- package/lib/bufferNode.mjs.map +0 -1
- package/lib/bufferShared.d.mts.map +0 -1
- package/lib/bufferShared.mjs.map +0 -1
- package/lib/eventForwarder.d.mts +0 -34
- package/lib/eventForwarder.d.mts.map +0 -1
- package/lib/eventForwarder.mjs +0 -94
- package/lib/eventForwarder.mjs.map +0 -1
- package/lib/hashFileBrowser.d.mts.map +0 -1
- package/lib/hashFileNode.d.mts.map +0 -1
- package/lib/hashFileNode.mjs.map +0 -1
- package/lib/index.d.mts.map +0 -1
- package/lib/index.mjs.map +0 -1
- package/lib/indexBrowser.d.mts +0 -14
- package/lib/indexBrowser.d.mts.map +0 -1
- package/lib/indexBrowser.mjs +0 -13
- package/lib/indexBrowser.mjs.map +0 -1
- package/lib/indexNode.d.mts +0 -15
- package/lib/indexNode.d.mts.map +0 -1
- package/lib/indexNode.mjs +0 -13
- package/lib/indexNode.mjs.map +0 -1
- package/lib/performanceIsomorphic.d.mts.map +0 -1
- package/lib/performanceIsomorphic.mjs.map +0 -1
- package/lib/trace.d.mts.map +0 -1
- package/lib/trace.mjs.map +0 -1
- package/lib/typedEventEmitter.d.mts.map +0 -1
- package/lib/typedEventEmitter.mjs.map +0 -1
- package/src/eventForwarder.ts +0 -122
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
const getFluidTestMochaConfig = require("@
|
|
8
|
+
const getFluidTestMochaConfig = require("@fluid-internal/mocha-test-setup/mocharc-common");
|
|
9
9
|
|
|
10
10
|
const packageDir = __dirname;
|
|
11
11
|
const config = getFluidTestMochaConfig(packageDir);
|
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
-
"extends": "../../../common/build/build-common/api-extractor-base
|
|
3
|
+
"extends": "../../../common/build/build-common/api-extractor-base.cjs.primary.json",
|
|
4
|
+
// CJS is actually secondary; so, no report.
|
|
5
|
+
"apiReport": {
|
|
6
|
+
"enabled": false
|
|
7
|
+
}
|
|
4
8
|
}
|
package/api-extractor-lint.json
CHANGED
package/api-extractor.json
CHANGED
|
@@ -4,47 +4,28 @@
|
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import { EventEmitter } from 'events';
|
|
10
|
-
import { IDisposable } from '@fluidframework/core-interfaces';
|
|
7
|
+
import { EventEmitter } from 'events_pkg';
|
|
11
8
|
import { IEvent } from '@fluidframework/core-interfaces';
|
|
12
9
|
import { IEventProvider } from '@fluidframework/core-interfaces';
|
|
13
10
|
import { IEventTransformer } from '@fluidframework/core-interfaces';
|
|
14
11
|
import { TransformedEvent } from '@fluidframework/core-interfaces';
|
|
15
12
|
|
|
16
13
|
// @internal
|
|
17
|
-
class
|
|
14
|
+
export class Buffer extends Uint8Array {
|
|
18
15
|
static from(value: unknown, encodingOrOffset?: unknown, length?: unknown): IsoBuffer;
|
|
19
16
|
// (undocumented)
|
|
20
|
-
static isBuffer(obj: unknown): obj is
|
|
17
|
+
static isBuffer(obj: unknown): obj is Buffer;
|
|
21
18
|
// (undocumented)
|
|
22
19
|
toString(encoding?: "utf8" | "utf-8" | "base64"): string;
|
|
23
20
|
}
|
|
24
|
-
export { Buffer_2 as Buffer }
|
|
25
21
|
|
|
26
22
|
// @alpha
|
|
27
23
|
export const bufferToString: (blob: ArrayBufferLike, encoding: "utf8" | "utf-8" | "base64") => string;
|
|
28
24
|
|
|
29
|
-
|
|
30
|
-
export type EventEmitterEventType = EventEmitter extends {
|
|
31
|
-
on(event: infer E, listener: any): any;
|
|
32
|
-
} ? E : never;
|
|
25
|
+
export { EventEmitter }
|
|
33
26
|
|
|
34
|
-
// @
|
|
35
|
-
export
|
|
36
|
-
constructor(source?: EventEmitter | IEventProvider<TEvent & IEvent>);
|
|
37
|
-
// (undocumented)
|
|
38
|
-
dispose(): void;
|
|
39
|
-
// (undocumented)
|
|
40
|
-
get disposed(): boolean;
|
|
41
|
-
// (undocumented)
|
|
42
|
-
protected forwardEvent(source: EventEmitter | IEventProvider<TEvent & IEvent>, ...events: string[]): void;
|
|
43
|
-
// (undocumented)
|
|
44
|
-
protected static isEmitterEvent(event: string): boolean;
|
|
45
|
-
// (undocumented)
|
|
46
|
-
protected unforwardEvent(source: EventEmitter | IEventProvider<TEvent & IEvent>, ...events: string[]): void;
|
|
47
|
-
}
|
|
27
|
+
// @public
|
|
28
|
+
export type EventEmitterEventType = string;
|
|
48
29
|
|
|
49
30
|
// @internal
|
|
50
31
|
export const fromBase64ToUtf8: (input: string) => string;
|
|
@@ -59,10 +40,10 @@ export function gitHashFile(file: IsoBuffer): Promise<string>;
|
|
|
59
40
|
export function hashFile(file: IsoBuffer, algorithm?: "SHA-1" | "SHA-256", hashEncoding?: "hex" | "base64"): Promise<string>;
|
|
60
41
|
|
|
61
42
|
// @internal (undocumented)
|
|
62
|
-
export const IsoBuffer: typeof
|
|
43
|
+
export const IsoBuffer: typeof Buffer;
|
|
63
44
|
|
|
64
45
|
// @internal (undocumented)
|
|
65
|
-
export type IsoBuffer =
|
|
46
|
+
export type IsoBuffer = Buffer;
|
|
66
47
|
|
|
67
48
|
// @internal
|
|
68
49
|
export type IsomorphicPerformance = Partial<Performance> & Pick<Performance, "clearMarks" | "mark" | "measure" | "now">;
|
package/dist/base64Encoding.js
CHANGED
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.toUtf8 = exports.fromUtf8ToBase64 = exports.fromBase64ToUtf8 = void 0;
|
|
8
|
-
const
|
|
8
|
+
const indexNode_js_1 = require("./indexNode.js");
|
|
9
9
|
/**
|
|
10
10
|
* Converts the provided {@link https://en.wikipedia.org/wiki/Base64 | base64}-encoded string
|
|
11
11
|
* to {@link https://en.wikipedia.org/wiki/UTF-8 | utf-8}.
|
|
12
12
|
*
|
|
13
13
|
* @internal
|
|
14
14
|
*/
|
|
15
|
-
const fromBase64ToUtf8 = (input) =>
|
|
15
|
+
const fromBase64ToUtf8 = (input) => indexNode_js_1.IsoBuffer.from(input, "base64").toString("utf8");
|
|
16
16
|
exports.fromBase64ToUtf8 = fromBase64ToUtf8;
|
|
17
17
|
/**
|
|
18
18
|
* Converts the provided {@link https://en.wikipedia.org/wiki/UTF-8 | utf-8}-encoded string
|
|
@@ -20,7 +20,7 @@ exports.fromBase64ToUtf8 = fromBase64ToUtf8;
|
|
|
20
20
|
*
|
|
21
21
|
* @internal
|
|
22
22
|
*/
|
|
23
|
-
const fromUtf8ToBase64 = (input) =>
|
|
23
|
+
const fromUtf8ToBase64 = (input) => indexNode_js_1.IsoBuffer.from(input, "utf8").toString("base64");
|
|
24
24
|
exports.fromUtf8ToBase64 = fromUtf8ToBase64;
|
|
25
25
|
/**
|
|
26
26
|
* Convenience function to convert unknown encoding to utf8 that avoids
|
|
@@ -38,7 +38,7 @@ const toUtf8 = (input, encoding) => {
|
|
|
38
38
|
return input;
|
|
39
39
|
}
|
|
40
40
|
default: {
|
|
41
|
-
return
|
|
41
|
+
return indexNode_js_1.IsoBuffer.from(input, encoding).toString();
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base64Encoding.js","sourceRoot":"","sources":["../src/base64Encoding.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"base64Encoding.js","sourceRoot":"","sources":["../src/base64Encoding.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iDAA2C;AAE3C;;;;;GAKG;AACI,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAU,EAAE,CACzD,wBAAS,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AADrC,QAAA,gBAAgB,oBACqB;AAElD;;;;;GAKG;AACI,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAU,EAAE,CACzD,wBAAS,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AADrC,QAAA,gBAAgB,oBACqB;AAElD;;;;;;;GAOG;AACI,MAAM,MAAM,GAAG,CAAC,KAAa,EAAE,QAAgB,EAAU,EAAE;IACjE,QAAQ,QAAQ,EAAE;QACjB,KAAK,MAAM,CAAC;QACZ,8GAA8G;QAC9G,KAAK,OAAO,CAAC,CAAC;YACb,OAAO,KAAK,CAAC;SACb;QACD,OAAO,CAAC,CAAC;YACR,OAAO,wBAAS,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC;SAClD;KACD;AACF,CAAC,CAAC;AAXW,QAAA,MAAM,UAWjB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IsoBuffer } from \"./indexNode.js\";\n\n/**\n * Converts the provided {@link https://en.wikipedia.org/wiki/Base64 | base64}-encoded string\n * to {@link https://en.wikipedia.org/wiki/UTF-8 | utf-8}.\n *\n * @internal\n */\nexport const fromBase64ToUtf8 = (input: string): string =>\n\tIsoBuffer.from(input, \"base64\").toString(\"utf8\");\n\n/**\n * Converts the provided {@link https://en.wikipedia.org/wiki/UTF-8 | utf-8}-encoded string\n * to {@link https://en.wikipedia.org/wiki/Base64 | base64}.\n *\n * @internal\n */\nexport const fromUtf8ToBase64 = (input: string): string =>\n\tIsoBuffer.from(input, \"utf8\").toString(\"base64\");\n\n/**\n * Convenience function to convert unknown encoding to utf8 that avoids\n * buffer copies/encode ops when no conversion is needed.\n * @param input - The source string to convert.\n * @param encoding - The source string's encoding.\n *\n * @internal\n */\nexport const toUtf8 = (input: string, encoding: string): string => {\n\tswitch (encoding) {\n\t\tcase \"utf8\":\n\t\t// eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged\n\t\tcase \"utf-8\": {\n\t\t\treturn input;\n\t\t}\n\t\tdefault: {\n\t\t\treturn IsoBuffer.from(input, encoding).toString();\n\t\t}\n\t}\n};\n"]}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { EventEmitter } from 'events';
|
|
4
|
-
import { IDisposable } from '@fluidframework/core-interfaces';
|
|
1
|
+
import { EventEmitter } from 'events_pkg';
|
|
5
2
|
import { IEvent } from '@fluidframework/core-interfaces';
|
|
6
3
|
import { IEventProvider } from '@fluidframework/core-interfaces';
|
|
7
4
|
import { IEventTransformer } from '@fluidframework/core-interfaces';
|
|
8
5
|
import { TransformedEvent } from '@fluidframework/core-interfaces';
|
|
9
6
|
|
|
10
|
-
/* Excluded from this release type:
|
|
7
|
+
/* Excluded from this release type: Buffer */
|
|
11
8
|
|
|
12
9
|
/**
|
|
13
10
|
* Convert binary blob to string format
|
|
@@ -20,18 +17,16 @@ import { TransformedEvent } from '@fluidframework/core-interfaces';
|
|
|
20
17
|
*/
|
|
21
18
|
export declare const bufferToString: (blob: ArrayBufferLike, encoding: "utf8" | "utf-8" | "base64") => string;
|
|
22
19
|
|
|
20
|
+
export { EventEmitter }
|
|
21
|
+
|
|
23
22
|
/**
|
|
24
23
|
* The event emitter polyfill and the node event emitter have different event types:
|
|
25
24
|
* string | symbol vs. string | number
|
|
26
25
|
*
|
|
27
|
-
*
|
|
26
|
+
* The polyfill is now always used, but string is the only event type preferred.
|
|
28
27
|
* @public
|
|
29
28
|
*/
|
|
30
|
-
export declare type EventEmitterEventType =
|
|
31
|
-
on(event: infer E, listener: any): any;
|
|
32
|
-
} ? E : never;
|
|
33
|
-
|
|
34
|
-
/* Excluded from this release type: EventForwarder */
|
|
29
|
+
export declare type EventEmitterEventType = string;
|
|
35
30
|
|
|
36
31
|
/* Excluded from this release type: fromBase64ToUtf8 */
|
|
37
32
|
|
|
@@ -1,28 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { EventEmitter } from 'events';
|
|
4
|
-
import { IDisposable } from '@fluidframework/core-interfaces';
|
|
1
|
+
import { EventEmitter } from 'events_pkg';
|
|
5
2
|
import { IEvent } from '@fluidframework/core-interfaces';
|
|
6
3
|
import { IEventProvider } from '@fluidframework/core-interfaces';
|
|
7
4
|
import { IEventTransformer } from '@fluidframework/core-interfaces';
|
|
8
5
|
import { TransformedEvent } from '@fluidframework/core-interfaces';
|
|
9
6
|
|
|
10
|
-
/* Excluded from this release type:
|
|
7
|
+
/* Excluded from this release type: Buffer */
|
|
11
8
|
|
|
12
9
|
/* Excluded from this release type: bufferToString */
|
|
10
|
+
export { EventEmitter }
|
|
13
11
|
|
|
14
12
|
/**
|
|
15
13
|
* The event emitter polyfill and the node event emitter have different event types:
|
|
16
14
|
* string | symbol vs. string | number
|
|
17
15
|
*
|
|
18
|
-
*
|
|
16
|
+
* The polyfill is now always used, but string is the only event type preferred.
|
|
19
17
|
* @public
|
|
20
18
|
*/
|
|
21
|
-
export declare type EventEmitterEventType =
|
|
22
|
-
on(event: infer E, listener: any): any;
|
|
23
|
-
} ? E : never;
|
|
24
|
-
|
|
25
|
-
/* Excluded from this release type: EventForwarder */
|
|
19
|
+
export declare type EventEmitterEventType = string;
|
|
26
20
|
|
|
27
21
|
/* Excluded from this release type: fromBase64ToUtf8 */
|
|
28
22
|
|
|
@@ -1,28 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { EventEmitter } from 'events';
|
|
4
|
-
import { IDisposable } from '@fluidframework/core-interfaces';
|
|
1
|
+
import { EventEmitter } from 'events_pkg';
|
|
5
2
|
import { IEvent } from '@fluidframework/core-interfaces';
|
|
6
3
|
import { IEventProvider } from '@fluidframework/core-interfaces';
|
|
7
4
|
import { IEventTransformer } from '@fluidframework/core-interfaces';
|
|
8
5
|
import { TransformedEvent } from '@fluidframework/core-interfaces';
|
|
9
6
|
|
|
10
|
-
/* Excluded from this release type:
|
|
7
|
+
/* Excluded from this release type: Buffer */
|
|
11
8
|
|
|
12
9
|
/* Excluded from this release type: bufferToString */
|
|
10
|
+
export { EventEmitter }
|
|
13
11
|
|
|
14
12
|
/**
|
|
15
13
|
* The event emitter polyfill and the node event emitter have different event types:
|
|
16
14
|
* string | symbol vs. string | number
|
|
17
15
|
*
|
|
18
|
-
*
|
|
16
|
+
* The polyfill is now always used, but string is the only event type preferred.
|
|
19
17
|
* @public
|
|
20
18
|
*/
|
|
21
|
-
export declare type EventEmitterEventType =
|
|
22
|
-
on(event: infer E, listener: any): any;
|
|
23
|
-
} ? E : never;
|
|
24
|
-
|
|
25
|
-
/* Excluded from this release type: EventForwarder */
|
|
19
|
+
export declare type EventEmitterEventType = string;
|
|
26
20
|
|
|
27
21
|
/* Excluded from this release type: fromBase64ToUtf8 */
|
|
28
22
|
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { EventEmitter } from 'events';
|
|
4
|
-
import { IDisposable } from '@fluidframework/core-interfaces';
|
|
1
|
+
import { EventEmitter } from 'events_pkg';
|
|
5
2
|
import { IEvent } from '@fluidframework/core-interfaces';
|
|
6
3
|
import { IEventProvider } from '@fluidframework/core-interfaces';
|
|
7
4
|
import { IEventTransformer } from '@fluidframework/core-interfaces';
|
|
@@ -14,7 +11,7 @@ import { TransformedEvent } from '@fluidframework/core-interfaces';
|
|
|
14
11
|
*
|
|
15
12
|
* @internal
|
|
16
13
|
*/
|
|
17
|
-
declare class
|
|
14
|
+
export declare class Buffer extends Uint8Array {
|
|
18
15
|
toString(encoding?: "utf8" | "utf-8" | "base64"): string;
|
|
19
16
|
/**
|
|
20
17
|
* Static constructor
|
|
@@ -26,9 +23,8 @@ declare class Buffer_2 extends Uint8Array {
|
|
|
26
23
|
* @privateRemarks TODO: Use actual types
|
|
27
24
|
*/
|
|
28
25
|
static from(value: unknown, encodingOrOffset?: unknown, length?: unknown): IsoBuffer;
|
|
29
|
-
static isBuffer(obj: unknown): obj is
|
|
26
|
+
static isBuffer(obj: unknown): obj is Buffer;
|
|
30
27
|
}
|
|
31
|
-
export { Buffer_2 as Buffer }
|
|
32
28
|
|
|
33
29
|
/**
|
|
34
30
|
* Convert binary blob to string format
|
|
@@ -41,42 +37,16 @@ export { Buffer_2 as Buffer }
|
|
|
41
37
|
*/
|
|
42
38
|
export declare const bufferToString: (blob: ArrayBufferLike, encoding: "utf8" | "utf-8" | "base64") => string;
|
|
43
39
|
|
|
40
|
+
export { EventEmitter }
|
|
41
|
+
|
|
44
42
|
/**
|
|
45
43
|
* The event emitter polyfill and the node event emitter have different event types:
|
|
46
44
|
* string | symbol vs. string | number
|
|
47
45
|
*
|
|
48
|
-
*
|
|
46
|
+
* The polyfill is now always used, but string is the only event type preferred.
|
|
49
47
|
* @public
|
|
50
48
|
*/
|
|
51
|
-
export declare type EventEmitterEventType =
|
|
52
|
-
on(event: infer E, listener: any): any;
|
|
53
|
-
} ? E : never;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Base class used for forwarding events from a source EventEmitter.
|
|
57
|
-
* This can be useful when all arbitrary listeners need to be removed,
|
|
58
|
-
* but the primary source needs to stay intact.
|
|
59
|
-
*
|
|
60
|
-
* @internal
|
|
61
|
-
*/
|
|
62
|
-
export declare class EventForwarder<TEvent = IEvent> extends TypedEventEmitter<TEvent> implements IDisposable {
|
|
63
|
-
protected static isEmitterEvent(event: string): boolean;
|
|
64
|
-
private static readonly newListenerEvent;
|
|
65
|
-
private static readonly removeListenerEvent;
|
|
66
|
-
/**
|
|
67
|
-
* {@inheritDoc @fluidframework/core-interfaces#IDisposable.disposed}
|
|
68
|
-
*/
|
|
69
|
-
get disposed(): boolean;
|
|
70
|
-
private isDisposed;
|
|
71
|
-
private readonly forwardingEvents;
|
|
72
|
-
constructor(source?: EventEmitter | IEventProvider<TEvent & IEvent>);
|
|
73
|
-
/**
|
|
74
|
-
* {@inheritDoc @fluidframework/core-interfaces#IDisposable.dispose}
|
|
75
|
-
*/
|
|
76
|
-
dispose(): void;
|
|
77
|
-
protected forwardEvent(source: EventEmitter | IEventProvider<TEvent & IEvent>, ...events: string[]): void;
|
|
78
|
-
protected unforwardEvent(source: EventEmitter | IEventProvider<TEvent & IEvent>, ...events: string[]): void;
|
|
79
|
-
}
|
|
49
|
+
export declare type EventEmitterEventType = string;
|
|
80
50
|
|
|
81
51
|
/**
|
|
82
52
|
* Converts the provided {@link https://en.wikipedia.org/wiki/Base64 | base64}-encoded string
|
|
@@ -123,12 +93,12 @@ export declare function hashFile(file: IsoBuffer, algorithm?: "SHA-1" | "SHA-256
|
|
|
123
93
|
/**
|
|
124
94
|
* @internal
|
|
125
95
|
*/
|
|
126
|
-
export declare const IsoBuffer: typeof
|
|
96
|
+
export declare const IsoBuffer: typeof Buffer;
|
|
127
97
|
|
|
128
98
|
/**
|
|
129
99
|
* @internal
|
|
130
100
|
*/
|
|
131
|
-
export declare type IsoBuffer =
|
|
101
|
+
export declare type IsoBuffer = Buffer;
|
|
132
102
|
|
|
133
103
|
/**
|
|
134
104
|
* This type contains all browser performance properties as optional, and some
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.EventEmitter = void 0;
|
|
8
|
+
// TODO AB#7377 Provide Fluid EventEmitter using support in packages/dds/tree/src/events.
|
|
9
|
+
var events_pkg_1 = require("events_pkg");
|
|
10
|
+
Object.defineProperty(exports, "EventEmitter", { enumerable: true, get: function () { return events_pkg_1.EventEmitter; } });
|
|
11
|
+
//# sourceMappingURL=eventEmitter.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventEmitter.cjs","sourceRoot":"","sources":["../src/eventEmitter.cts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yFAAyF;AACzF,yCAA0C;AAAjC,0GAAA,YAAY,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// TODO AB#7377 Provide Fluid EventEmitter using support in packages/dds/tree/src/events.\nexport { EventEmitter } from \"events_pkg\";\n"]}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
6
|
-
//# sourceMappingURL=
|
|
5
|
+
export { EventEmitter } from "events_pkg";
|
|
6
|
+
//# sourceMappingURL=eventEmitter.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventEmitter.d.cts","sourceRoot":"","sources":["../src/eventEmitter.cts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IsoBuffer } from "./bufferBrowser";
|
|
5
|
+
import { IsoBuffer } from "./bufferBrowser.js";
|
|
6
6
|
/**
|
|
7
7
|
* Hash a file. Consistent within a session, but should not be persisted and
|
|
8
8
|
* is not consistent with git.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hashFileBrowser.d.ts","sourceRoot":"","sources":["../src/hashFileBrowser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"hashFileBrowser.d.ts","sourceRoot":"","sources":["../src/hashFileBrowser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAyB/C;;;;;;;;;;;;GAYG;AACH,wBAAsB,QAAQ,CAC7B,IAAI,EAAE,SAAS,EACf,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,CAQlE"}
|
package/dist/hashFileBrowser.js
CHANGED
|
@@ -29,7 +29,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
30
|
exports.gitHashFile = exports.hashFile = void 0;
|
|
31
31
|
const base64js = __importStar(require("base64-js"));
|
|
32
|
-
const
|
|
32
|
+
const bufferBrowser_js_1 = require("./bufferBrowser.js");
|
|
33
33
|
async function digestBuffer(file, algorithm) {
|
|
34
34
|
const hash = await crypto.subtle.digest(algorithm, file);
|
|
35
35
|
return new Uint8Array(hash);
|
|
@@ -93,7 +93,7 @@ async function gitHashFile(file) {
|
|
|
93
93
|
const size = file.byteLength;
|
|
94
94
|
// eslint-disable-next-line unicorn/prefer-code-point
|
|
95
95
|
const filePrefix = `blob ${size.toString()}${String.fromCharCode(0)}`;
|
|
96
|
-
const hashBuffer =
|
|
96
|
+
const hashBuffer = bufferBrowser_js_1.IsoBuffer.from(filePrefix + file.toString());
|
|
97
97
|
// hashFile uses sha1; if that changes this will need to change too
|
|
98
98
|
return hashFile(hashBuffer);
|
|
99
99
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hashFileBrowser.js","sourceRoot":"","sources":["../src/hashFileBrowser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,oDAAsC;AACtC,
|
|
1
|
+
{"version":3,"file":"hashFileBrowser.js","sourceRoot":"","sources":["../src/hashFileBrowser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,oDAAsC;AACtC,yDAA+C;AAE/C,KAAK,UAAU,YAAY,CAAC,IAAe,EAAE,SAA8B;IAC1E,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IACzD,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAED,SAAS,YAAY,CAAC,SAAqB,EAAE,QAA0B;IACtE,wCAAwC;IACxC,QAAQ,QAAQ,EAAE;QACjB,KAAK,KAAK,CAAC,CAAC;YACX,MAAM,OAAO,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG;iBACjC,IAAI,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE;gBACzB,yGAAyG;gBACzG,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAW,CAAC;YACrD,CAAC,CAAC;iBACD,IAAI,CAAC,EAAE,CAAC,CAAC;YACX,OAAO,OAAO,CAAC;SACf;QACD,KAAK,QAAQ,CAAC,CAAC;YACd,OAAO,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;SACzC;KACD;AACF,CAAC;AAED;;;;;;;;;;;;GAYG;AACI,KAAK,UAAU,QAAQ,CAC7B,IAAe,EACf,YAAiC,OAAO,EACxC,eAAiC,KAAK;IAEtC,8DAA8D;IAC9D,2DAA2D;IAC3D,gFAAgF;IAChF,8EAA8E;IAC9E,8BAA8B;IAC9B,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE;QAChC,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;KAC/D;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;AApBD,4BAoBC;AAED;;;;;;;;GAQG;AACI,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,UAAU,GAAG,4BAAS,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IAEhE,mEAAmE;IACnE,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC;AAC7B,CAAC;AARD,kCAQC","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\";\nimport { IsoBuffer } from \"./bufferBrowser.js\";\n\nasync function digestBuffer(file: IsoBuffer, algorithm: \"SHA-1\" | \"SHA-256\"): 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,\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 hashBuffer = IsoBuffer.from(filePrefix + file.toString());\n\n\t// hashFile uses sha1; if that changes this will need to change too\n\treturn hashFile(hashBuffer);\n}\n"]}
|
package/dist/hashFileNode.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import type { IsoBuffer } from "./bufferNode";
|
|
5
|
+
import type { IsoBuffer } from "./bufferNode.js";
|
|
6
6
|
/**
|
|
7
7
|
* Hash a file. Consistent within a session, but should not be persisted and
|
|
8
8
|
* is not consistent with git.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hashFileNode.d.ts","sourceRoot":"","sources":["../src/hashFileNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"hashFileNode.d.ts","sourceRoot":"","sources":["../src/hashFileNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;;;;;;;;;;;GAYG;AACH,wBAAsB,QAAQ,CAC7B,IAAI,EAAE,SAAS,EACf,SAAS,GAAE,OAAO,GAAG,SAAmB,EACxC,YAAY,GAAE,KAAK,GAAG,QAAgB,GACpC,OAAO,CAAC,MAAM,CAAC,CAejB;AAED;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAMlE"}
|
package/dist/hashFileNode.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hashFileNode.js","sourceRoot":"","sources":["../src/hashFileNode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,mCAAsC;AAItC;;;;;;;;;;;;GAYG;AACI,KAAK,UAAU,QAAQ,CAC7B,IAAe,EACf,YAAiC,OAAO,EACxC,eAAiC,KAAK;IAEtC,IAAI,MAAM,CAAC;IACX,wCAAwC;IACxC,QAAQ,SAAS,EAAE;QAClB,KAAK,OAAO,CAAC,CAAC;YACb,MAAM,GAAG,IAAI,aAAI,EAAE,CAAC;YACpB,MAAM;SACN;QACD,KAAK,SAAS,CAAC,CAAC;YACf,MAAM,GAAG,IAAI,eAAM,EAAE,CAAC;YACtB,MAAM;SACN;KACD;IACD,yGAAyG;IACzG,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,YAAY,CAAW,CAAC;AAC3D,CAAC;AAnBD,4BAmBC;AAED;;;;;;;;GAQG;AACI,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,MAAM,GAAG,IAAI,aAAI,EAAE,CAAC;IAC1B,OAAO,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC7D,CAAC;AAND,kCAMC","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\nimport type { IsoBuffer } from \"./bufferNode\";\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,\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 */\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 engine = new sha1();\n\treturn engine.update(filePrefix).update(file).digest(\"hex\");\n}\n"]}
|
|
1
|
+
{"version":3,"file":"hashFileNode.js","sourceRoot":"","sources":["../src/hashFileNode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,mCAAsC;AAItC;;;;;;;;;;;;GAYG;AACI,KAAK,UAAU,QAAQ,CAC7B,IAAe,EACf,YAAiC,OAAO,EACxC,eAAiC,KAAK;IAEtC,IAAI,MAAM,CAAC;IACX,wCAAwC;IACxC,QAAQ,SAAS,EAAE;QAClB,KAAK,OAAO,CAAC,CAAC;YACb,MAAM,GAAG,IAAI,aAAI,EAAE,CAAC;YACpB,MAAM;SACN;QACD,KAAK,SAAS,CAAC,CAAC;YACf,MAAM,GAAG,IAAI,eAAM,EAAE,CAAC;YACtB,MAAM;SACN;KACD;IACD,yGAAyG;IACzG,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,YAAY,CAAW,CAAC;AAC3D,CAAC;AAnBD,4BAmBC;AAED;;;;;;;;GAQG;AACI,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,MAAM,GAAG,IAAI,aAAI,EAAE,CAAC;IAC1B,OAAO,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC7D,CAAC;AAND,kCAMC","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\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 */\nexport async function hashFile(\n\tfile: IsoBuffer,\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 */\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 engine = new sha1();\n\treturn engine.update(filePrefix).update(file).digest(\"hex\");\n}\n"]}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,cAAc,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -22,5 +22,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
22
22
|
// It's only here so type-test-generator doesn't fail, until we update it to support packages that don't have an
|
|
23
23
|
// index.ts file.
|
|
24
24
|
// eslint-disable-next-line no-restricted-syntax
|
|
25
|
-
__exportStar(require("./indexNode"), exports);
|
|
25
|
+
__exportStar(require("./indexNode.js"), exports);
|
|
26
26
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;AAEH,kFAAkF;AAClF,gHAAgH;AAChH,iBAAiB;AACjB,gDAAgD;AAChD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;AAEH,kFAAkF;AAClF,gHAAgH;AAChH,iBAAiB;AACjB,gDAAgD;AAChD,iDAA+B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// THIS FILE IS NOT ACTUALLY USED (see indexBrowser.ts and indexNode.ts for that).\n// It's only here so type-test-generator doesn't fail, until we update it to support packages that don't have an\n// index.ts file.\n// eslint-disable-next-line no-restricted-syntax\nexport * from \"./indexNode.js\";\n"]}
|
package/dist/indexBrowser.d.ts
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export { bufferToString, isArrayBuffer, IsoBuffer, stringToBuffer, Uint8ArrayToString, } from "./bufferBrowser";
|
|
6
|
-
export { gitHashFile, hashFile } from "./hashFileBrowser";
|
|
7
|
-
export { performance } from "./performanceIsomorphic";
|
|
8
|
-
export { fromBase64ToUtf8, fromUtf8ToBase64, toUtf8 } from "./base64Encoding";
|
|
9
|
-
export { Uint8ArrayToArrayBuffer } from "./bufferShared";
|
|
10
|
-
export {
|
|
11
|
-
export { IsomorphicPerformance } from "./performanceIsomorphic";
|
|
12
|
-
export { ITraceEvent, Trace } from "./trace";
|
|
13
|
-
export { EventEmitterEventType, TypedEventEmitter, TypedEventTransform } from "./typedEventEmitter";
|
|
5
|
+
export { bufferToString, isArrayBuffer, IsoBuffer, stringToBuffer, Uint8ArrayToString, } from "./bufferBrowser.js";
|
|
6
|
+
export { gitHashFile, hashFile } from "./hashFileBrowser.js";
|
|
7
|
+
export { performance } from "./performanceIsomorphic.js";
|
|
8
|
+
export { fromBase64ToUtf8, fromUtf8ToBase64, toUtf8 } from "./base64Encoding.js";
|
|
9
|
+
export { Uint8ArrayToArrayBuffer } from "./bufferShared.js";
|
|
10
|
+
export { EventEmitter } from "./eventEmitter.cjs";
|
|
11
|
+
export { type IsomorphicPerformance } from "./performanceIsomorphic.js";
|
|
12
|
+
export { type ITraceEvent, Trace } from "./trace.js";
|
|
13
|
+
export { type EventEmitterEventType, TypedEventEmitter, type TypedEventTransform, } from "./typedEventEmitter.js";
|
|
14
14
|
//# sourceMappingURL=indexBrowser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexBrowser.d.ts","sourceRoot":"","sources":["../src/indexBrowser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,cAAc,EACd,aAAa,EACb,SAAS,EACT,cAAc,EACd,kBAAkB,GAClB,MAAM,
|
|
1
|
+
{"version":3,"file":"indexBrowser.d.ts","sourceRoot":"","sources":["../src/indexBrowser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,cAAc,EACd,aAAa,EACb,SAAS,EACT,cAAc,EACd,kBAAkB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EACN,KAAK,qBAAqB,EAC1B,iBAAiB,EACjB,KAAK,mBAAmB,GACxB,MAAM,wBAAwB,CAAC"}
|
package/dist/indexBrowser.js
CHANGED
|
@@ -4,28 +4,28 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.TypedEventEmitter = exports.Trace = exports.
|
|
8
|
-
var
|
|
9
|
-
Object.defineProperty(exports, "bufferToString", { enumerable: true, get: function () { return
|
|
10
|
-
Object.defineProperty(exports, "isArrayBuffer", { enumerable: true, get: function () { return
|
|
11
|
-
Object.defineProperty(exports, "IsoBuffer", { enumerable: true, get: function () { return
|
|
12
|
-
Object.defineProperty(exports, "stringToBuffer", { enumerable: true, get: function () { return
|
|
13
|
-
Object.defineProperty(exports, "Uint8ArrayToString", { enumerable: true, get: function () { return
|
|
14
|
-
var
|
|
15
|
-
Object.defineProperty(exports, "gitHashFile", { enumerable: true, get: function () { return
|
|
16
|
-
Object.defineProperty(exports, "hashFile", { enumerable: true, get: function () { return
|
|
17
|
-
var
|
|
18
|
-
Object.defineProperty(exports, "performance", { enumerable: true, get: function () { return
|
|
19
|
-
var
|
|
20
|
-
Object.defineProperty(exports, "fromBase64ToUtf8", { enumerable: true, get: function () { return
|
|
21
|
-
Object.defineProperty(exports, "fromUtf8ToBase64", { enumerable: true, get: function () { return
|
|
22
|
-
Object.defineProperty(exports, "toUtf8", { enumerable: true, get: function () { return
|
|
23
|
-
var
|
|
24
|
-
Object.defineProperty(exports, "Uint8ArrayToArrayBuffer", { enumerable: true, get: function () { return
|
|
25
|
-
var
|
|
26
|
-
Object.defineProperty(exports, "
|
|
27
|
-
var
|
|
28
|
-
Object.defineProperty(exports, "Trace", { enumerable: true, get: function () { return
|
|
29
|
-
var
|
|
30
|
-
Object.defineProperty(exports, "TypedEventEmitter", { enumerable: true, get: function () { return
|
|
7
|
+
exports.TypedEventEmitter = exports.Trace = exports.EventEmitter = exports.Uint8ArrayToArrayBuffer = exports.toUtf8 = exports.fromUtf8ToBase64 = exports.fromBase64ToUtf8 = exports.performance = exports.hashFile = exports.gitHashFile = exports.Uint8ArrayToString = exports.stringToBuffer = exports.IsoBuffer = exports.isArrayBuffer = exports.bufferToString = void 0;
|
|
8
|
+
var bufferBrowser_js_1 = require("./bufferBrowser.js");
|
|
9
|
+
Object.defineProperty(exports, "bufferToString", { enumerable: true, get: function () { return bufferBrowser_js_1.bufferToString; } });
|
|
10
|
+
Object.defineProperty(exports, "isArrayBuffer", { enumerable: true, get: function () { return bufferBrowser_js_1.isArrayBuffer; } });
|
|
11
|
+
Object.defineProperty(exports, "IsoBuffer", { enumerable: true, get: function () { return bufferBrowser_js_1.IsoBuffer; } });
|
|
12
|
+
Object.defineProperty(exports, "stringToBuffer", { enumerable: true, get: function () { return bufferBrowser_js_1.stringToBuffer; } });
|
|
13
|
+
Object.defineProperty(exports, "Uint8ArrayToString", { enumerable: true, get: function () { return bufferBrowser_js_1.Uint8ArrayToString; } });
|
|
14
|
+
var hashFileBrowser_js_1 = require("./hashFileBrowser.js");
|
|
15
|
+
Object.defineProperty(exports, "gitHashFile", { enumerable: true, get: function () { return hashFileBrowser_js_1.gitHashFile; } });
|
|
16
|
+
Object.defineProperty(exports, "hashFile", { enumerable: true, get: function () { return hashFileBrowser_js_1.hashFile; } });
|
|
17
|
+
var performanceIsomorphic_js_1 = require("./performanceIsomorphic.js");
|
|
18
|
+
Object.defineProperty(exports, "performance", { enumerable: true, get: function () { return performanceIsomorphic_js_1.performance; } });
|
|
19
|
+
var base64Encoding_js_1 = require("./base64Encoding.js");
|
|
20
|
+
Object.defineProperty(exports, "fromBase64ToUtf8", { enumerable: true, get: function () { return base64Encoding_js_1.fromBase64ToUtf8; } });
|
|
21
|
+
Object.defineProperty(exports, "fromUtf8ToBase64", { enumerable: true, get: function () { return base64Encoding_js_1.fromUtf8ToBase64; } });
|
|
22
|
+
Object.defineProperty(exports, "toUtf8", { enumerable: true, get: function () { return base64Encoding_js_1.toUtf8; } });
|
|
23
|
+
var bufferShared_js_1 = require("./bufferShared.js");
|
|
24
|
+
Object.defineProperty(exports, "Uint8ArrayToArrayBuffer", { enumerable: true, get: function () { return bufferShared_js_1.Uint8ArrayToArrayBuffer; } });
|
|
25
|
+
var eventEmitter_cjs_1 = require("./eventEmitter.cjs");
|
|
26
|
+
Object.defineProperty(exports, "EventEmitter", { enumerable: true, get: function () { return eventEmitter_cjs_1.EventEmitter; } });
|
|
27
|
+
var trace_js_1 = require("./trace.js");
|
|
28
|
+
Object.defineProperty(exports, "Trace", { enumerable: true, get: function () { return trace_js_1.Trace; } });
|
|
29
|
+
var typedEventEmitter_js_1 = require("./typedEventEmitter.js");
|
|
30
|
+
Object.defineProperty(exports, "TypedEventEmitter", { enumerable: true, get: function () { return typedEventEmitter_js_1.TypedEventEmitter; } });
|
|
31
31
|
//# sourceMappingURL=indexBrowser.js.map
|