@fluid-internal/client-utils 2.0.0-internal.6.3.1
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 +20 -0
- package/.mocharc.js +12 -0
- package/CHANGELOG.md +3 -0
- package/LICENSE +21 -0
- package/README.md +70 -0
- package/api-extractor.json +16 -0
- package/dist/base64Encoding.d.ts +28 -0
- package/dist/base64Encoding.d.ts.map +1 -0
- package/dist/base64Encoding.js +43 -0
- package/dist/base64Encoding.js.map +1 -0
- package/dist/bufferBrowser.d.ts +81 -0
- package/dist/bufferBrowser.d.ts.map +1 -0
- package/dist/bufferBrowser.js +195 -0
- package/dist/bufferBrowser.js.map +1 -0
- package/dist/bufferNode.d.ts +58 -0
- package/dist/bufferNode.d.ts.map +1 -0
- package/dist/bufferNode.js +54 -0
- package/dist/bufferNode.js.map +1 -0
- package/dist/bufferShared.d.ts +12 -0
- package/dist/bufferShared.d.ts.map +1 -0
- package/dist/bufferShared.js +21 -0
- package/dist/bufferShared.js.map +1 -0
- package/dist/eventForwarder.d.ts +33 -0
- package/dist/eventForwarder.d.ts.map +1 -0
- package/dist/eventForwarder.js +98 -0
- package/dist/eventForwarder.js.map +1 -0
- package/dist/hashFileBrowser.d.ts +30 -0
- package/dist/hashFileBrowser.d.ts.map +1 -0
- package/dist/hashFileBrowser.js +95 -0
- package/dist/hashFileBrowser.js.map +1 -0
- package/dist/hashFileNode.d.ts +30 -0
- package/dist/hashFileNode.d.ts.map +1 -0
- package/dist/hashFileNode.js +60 -0
- package/dist/hashFileNode.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/dist/indexBrowser.d.ts +8 -0
- package/dist/indexBrowser.d.ts.map +1 -0
- package/dist/indexBrowser.js +19 -0
- package/dist/indexBrowser.js.map +1 -0
- package/dist/indexNode.d.ts +8 -0
- package/dist/indexNode.d.ts.map +1 -0
- package/dist/indexNode.js +19 -0
- package/dist/indexNode.js.map +1 -0
- package/dist/performanceBrowser.d.ts +10 -0
- package/dist/performanceBrowser.d.ts.map +1 -0
- package/dist/performanceBrowser.js +12 -0
- package/dist/performanceBrowser.js.map +1 -0
- package/dist/performanceIsomorphic.d.ts +12 -0
- package/dist/performanceIsomorphic.d.ts.map +1 -0
- package/dist/performanceIsomorphic.js +7 -0
- package/dist/performanceIsomorphic.js.map +1 -0
- package/dist/performanceNode.d.ts +10 -0
- package/dist/performanceNode.d.ts.map +1 -0
- package/dist/performanceNode.js +14 -0
- package/dist/performanceNode.js.map +1 -0
- package/dist/trace.d.ts +40 -0
- package/dist/trace.d.ts.map +1 -0
- package/dist/trace.js +36 -0
- package/dist/trace.js.map +1 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/typedEventEmitter.d.ts +37 -0
- package/dist/typedEventEmitter.d.ts.map +1 -0
- package/dist/typedEventEmitter.js +27 -0
- package/dist/typedEventEmitter.js.map +1 -0
- package/jest-puppeteer.config.js +13 -0
- package/jest.config.js +20 -0
- package/lib/base64Encoding.d.ts +28 -0
- package/lib/base64Encoding.d.ts.map +1 -0
- package/lib/base64Encoding.js +37 -0
- package/lib/base64Encoding.js.map +1 -0
- package/lib/bufferBrowser.d.ts +81 -0
- package/lib/bufferBrowser.d.ts.map +1 -0
- package/lib/bufferBrowser.js +168 -0
- package/lib/bufferBrowser.js.map +1 -0
- package/lib/bufferNode.d.ts +58 -0
- package/lib/bufferNode.d.ts.map +1 -0
- package/lib/bufferNode.js +48 -0
- package/lib/bufferNode.js.map +1 -0
- package/lib/bufferShared.d.ts +12 -0
- package/lib/bufferShared.d.ts.map +1 -0
- package/lib/bufferShared.js +17 -0
- package/lib/bufferShared.js.map +1 -0
- package/lib/eventForwarder.d.ts +33 -0
- package/lib/eventForwarder.d.ts.map +1 -0
- package/lib/eventForwarder.js +94 -0
- package/lib/eventForwarder.js.map +1 -0
- package/lib/hashFileBrowser.d.ts +30 -0
- package/lib/hashFileBrowser.d.ts.map +1 -0
- package/lib/hashFileBrowser.js +71 -0
- package/lib/hashFileBrowser.js.map +1 -0
- package/lib/hashFileNode.d.ts +30 -0
- package/lib/hashFileNode.d.ts.map +1 -0
- package/lib/hashFileNode.js +52 -0
- package/lib/hashFileNode.js.map +1 -0
- package/lib/index.d.ts +20 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +21 -0
- package/lib/index.js.map +1 -0
- package/lib/indexBrowser.d.ts +8 -0
- package/lib/indexBrowser.d.ts.map +1 -0
- package/lib/indexBrowser.js +8 -0
- package/lib/indexBrowser.js.map +1 -0
- package/lib/indexNode.d.ts +8 -0
- package/lib/indexNode.d.ts.map +1 -0
- package/lib/indexNode.js +8 -0
- package/lib/indexNode.js.map +1 -0
- package/lib/performanceBrowser.d.ts +10 -0
- package/lib/performanceBrowser.d.ts.map +1 -0
- package/lib/performanceBrowser.js +9 -0
- package/lib/performanceBrowser.js.map +1 -0
- package/lib/performanceIsomorphic.d.ts +12 -0
- package/lib/performanceIsomorphic.d.ts.map +1 -0
- package/lib/performanceIsomorphic.js +6 -0
- package/lib/performanceIsomorphic.js.map +1 -0
- package/lib/performanceNode.d.ts +10 -0
- package/lib/performanceNode.d.ts.map +1 -0
- package/lib/performanceNode.js +11 -0
- package/lib/performanceNode.js.map +1 -0
- package/lib/trace.d.ts +40 -0
- package/lib/trace.d.ts.map +1 -0
- package/lib/trace.js +32 -0
- package/lib/trace.js.map +1 -0
- package/lib/typedEventEmitter.d.ts +37 -0
- package/lib/typedEventEmitter.d.ts.map +1 -0
- package/lib/typedEventEmitter.js +23 -0
- package/lib/typedEventEmitter.js.map +1 -0
- package/package.json +140 -0
- package/prettier.config.cjs +8 -0
- package/src/base64Encoding.ts +42 -0
- package/src/bufferBrowser.ts +188 -0
- package/src/bufferNode.ts +75 -0
- package/src/bufferShared.ts +17 -0
- package/src/eventForwarder.ts +120 -0
- package/src/hashFileBrowser.ts +82 -0
- package/src/hashFileNode.ts +59 -0
- package/src/index.ts +22 -0
- package/src/indexBrowser.ts +14 -0
- package/src/indexNode.ts +14 -0
- package/src/performanceBrowser.ts +11 -0
- package/src/performanceIsomorphic.ts +13 -0
- package/src/performanceNode.ts +13 -0
- package/src/trace.ts +58 -0
- package/src/typedEventEmitter.ts +76 -0
- package/tsconfig.esnext.json +7 -0
- package/tsconfig.json +14 -0
- package/types/perf_hooks.d.ts +10 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
export { Buffer, bufferToString, IsoBuffer, stringToBuffer, Uint8ArrayToString, } from "./bufferNode";
|
|
6
|
+
export { gitHashFile, hashFile } from "./hashFileNode";
|
|
7
|
+
export { performance } from "./performanceNode";
|
|
8
|
+
//# sourceMappingURL=indexNode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexNode.d.ts","sourceRoot":"","sources":["../src/indexNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,MAAM,EACN,cAAc,EACd,SAAS,EACT,cAAc,EACd,kBAAkB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC"}
|
package/lib/indexNode.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
export { Buffer, bufferToString, IsoBuffer, stringToBuffer, Uint8ArrayToString, } from "./bufferNode";
|
|
6
|
+
export { gitHashFile, hashFile } from "./hashFileNode";
|
|
7
|
+
export { performance } from "./performanceNode";
|
|
8
|
+
//# sourceMappingURL=indexNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexNode.js","sourceRoot":"","sources":["../src/indexNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,MAAM,EACN,cAAc,EACd,SAAS,EACT,cAAc,EACd,kBAAkB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tBuffer,\n\tbufferToString,\n\tIsoBuffer,\n\tstringToBuffer,\n\tUint8ArrayToString,\n} from \"./bufferNode\";\nexport { gitHashFile, hashFile } from \"./hashFileNode\";\nexport { performance } from \"./performanceNode\";\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { IsomorphicPerformance } from "./performanceIsomorphic";
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare const performance: IsomorphicPerformance;
|
|
10
|
+
//# sourceMappingURL=performanceBrowser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"performanceBrowser.d.ts","sourceRoot":"","sources":["../src/performanceBrowser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,qBAA8C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"performanceBrowser.js","sourceRoot":"","sources":["../src/performanceBrowser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAA0B,UAAU,CAAC,WAAW,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IsomorphicPerformance } from \"./performanceIsomorphic\";\n\n/**\n * @internal\n */\nexport const performance: IsomorphicPerformance = globalThis.performance;\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* This type contains all browser performance properties as optional, and some
|
|
7
|
+
* of the intersecting properties of node and browser performance as required.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare type IsomorphicPerformance = Partial<Performance> & Pick<Performance, "clearMarks" | "mark" | "measure" | "now">;
|
|
12
|
+
//# sourceMappingURL=performanceIsomorphic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"performanceIsomorphic.d.ts","sourceRoot":"","sources":["../src/performanceIsomorphic.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AACH,oBAAY,qBAAqB,GAAG,OAAO,CAAC,WAAW,CAAC,GACvD,IAAI,CAAC,WAAW,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,GAAG,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"performanceIsomorphic.js","sourceRoot":"","sources":["../src/performanceIsomorphic.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * This type contains all browser performance properties as optional, and some\n * of the intersecting properties of node and browser performance as required.\n *\n * @internal\n */\nexport type IsomorphicPerformance = Partial<Performance> &\n\tPick<Performance, \"clearMarks\" | \"mark\" | \"measure\" | \"now\">;\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { IsomorphicPerformance } from "./performanceIsomorphic";
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare const performance: IsomorphicPerformance;
|
|
10
|
+
//# sourceMappingURL=performanceNode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"performanceNode.d.ts","sourceRoot":"","sources":["../src/performanceNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,qBAAuC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
// eslint-disable-next-line import/no-nodejs-modules
|
|
6
|
+
import { performance as nodePerformance } from "perf_hooks";
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export const performance = nodePerformance;
|
|
11
|
+
//# sourceMappingURL=performanceNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"performanceNode.js","sourceRoot":"","sources":["../src/performanceNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,oDAAoD;AACpD,OAAO,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,YAAY,CAAC;AAG5D;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAA0B,eAAe,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// eslint-disable-next-line import/no-nodejs-modules\nimport { performance as nodePerformance } from \"perf_hooks\";\nimport { IsomorphicPerformance } from \"./performanceIsomorphic\";\n\n/**\n * @internal\n */\nexport const performance: IsomorphicPerformance = nodePerformance;\n"]}
|
package/lib/trace.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Helper class for tracing performance of events
|
|
7
|
+
* Time measurements are in milliseconds as a floating point with a decimal
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare class Trace {
|
|
12
|
+
readonly startTick: number;
|
|
13
|
+
static start(): Trace;
|
|
14
|
+
protected lastTick: number;
|
|
15
|
+
protected constructor(startTick: number);
|
|
16
|
+
trace(): ITraceEvent;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Event in a performance trace including time elapsed.
|
|
20
|
+
*
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export interface ITraceEvent {
|
|
24
|
+
/**
|
|
25
|
+
* Total time elapsed since the start of the Trace.
|
|
26
|
+
* Measured in milliseconds as a floating point with a decimal
|
|
27
|
+
*/
|
|
28
|
+
readonly totalTimeElapsed: number;
|
|
29
|
+
/**
|
|
30
|
+
* Time elapsed since the last trace event.
|
|
31
|
+
* Measured in milliseconds as a floating point with a decimal
|
|
32
|
+
*/
|
|
33
|
+
readonly duration: number;
|
|
34
|
+
/**
|
|
35
|
+
* This number represents a relative time which should
|
|
36
|
+
* be consistent for all trace ticks.
|
|
37
|
+
*/
|
|
38
|
+
readonly tick: number;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=trace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../src/trace.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;GAKG;AACH,qBAAa,KAAK;aAOqB,SAAS,EAAE,MAAM;WANzC,KAAK,IAAI,KAAK;IAK5B,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC3B,SAAS,aAA6B,SAAS,EAAE,MAAM;IAIhD,KAAK,IAAI,WAAW;CAU3B;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC3B;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB"}
|
package/lib/trace.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { performance } from "./indexNode";
|
|
6
|
+
/**
|
|
7
|
+
* Helper class for tracing performance of events
|
|
8
|
+
* Time measurements are in milliseconds as a floating point with a decimal
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export class Trace {
|
|
13
|
+
constructor(startTick) {
|
|
14
|
+
this.startTick = startTick;
|
|
15
|
+
this.lastTick = startTick;
|
|
16
|
+
}
|
|
17
|
+
static start() {
|
|
18
|
+
const startTick = performance.now();
|
|
19
|
+
return new Trace(startTick);
|
|
20
|
+
}
|
|
21
|
+
trace() {
|
|
22
|
+
const tick = performance.now();
|
|
23
|
+
const event = {
|
|
24
|
+
totalTimeElapsed: tick - this.startTick,
|
|
25
|
+
duration: tick - this.lastTick,
|
|
26
|
+
tick,
|
|
27
|
+
};
|
|
28
|
+
this.lastTick = tick;
|
|
29
|
+
return event;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=trace.js.map
|
package/lib/trace.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.js","sourceRoot":"","sources":["../src/trace.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,OAAO,KAAK;IAOjB,YAAsC,SAAiB;QAAjB,cAAS,GAAT,SAAS,CAAQ;QACtD,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;IAC3B,CAAC;IARM,MAAM,CAAC,KAAK;QAClB,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QACpC,OAAO,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC;IAC7B,CAAC;IAOM,KAAK;QACX,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAC/B,MAAM,KAAK,GAAG;YACb,gBAAgB,EAAE,IAAI,GAAG,IAAI,CAAC,SAAS;YACvC,QAAQ,EAAE,IAAI,GAAG,IAAI,CAAC,QAAQ;YAC9B,IAAI;SACJ,CAAC;QACF,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,OAAO,KAAK,CAAC;IACd,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performance } from \"./indexNode\";\n\n/**\n * Helper class for tracing performance of events\n * Time measurements are in milliseconds as a floating point with a decimal\n *\n * @internal\n */\nexport class Trace {\n\tpublic static start(): Trace {\n\t\tconst startTick = performance.now();\n\t\treturn new Trace(startTick);\n\t}\n\n\tprotected lastTick: number;\n\tprotected constructor(public readonly startTick: number) {\n\t\tthis.lastTick = startTick;\n\t}\n\n\tpublic trace(): ITraceEvent {\n\t\tconst tick = performance.now();\n\t\tconst event = {\n\t\t\ttotalTimeElapsed: tick - this.startTick,\n\t\t\tduration: tick - this.lastTick,\n\t\t\ttick,\n\t\t};\n\t\tthis.lastTick = tick;\n\t\treturn event;\n\t}\n}\n\n/**\n * Event in a performance trace including time elapsed.\n *\n * @internal\n */\nexport interface ITraceEvent {\n\t/**\n\t * Total time elapsed since the start of the Trace.\n\t * Measured in milliseconds as a floating point with a decimal\n\t */\n\treadonly totalTimeElapsed: number;\n\t/**\n\t * Time elapsed since the last trace event.\n\t * Measured in milliseconds as a floating point with a decimal\n\t */\n\treadonly duration: number;\n\t/**\n\t * This number represents a relative time which should\n\t * be consistent for all trace ticks.\n\t */\n\treadonly tick: number;\n}\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { EventEmitter } from "events";
|
|
6
|
+
import { IEvent, TransformedEvent, IEventTransformer, IEventProvider } from "@fluidframework/core-interfaces";
|
|
7
|
+
/**
|
|
8
|
+
* The event emitter polyfill and the node event emitter have different event types:
|
|
9
|
+
* string | symbol vs. string | number
|
|
10
|
+
*
|
|
11
|
+
* This type allow us to correctly handle either type
|
|
12
|
+
*
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare type EventEmitterEventType = EventEmitter extends {
|
|
16
|
+
on(event: infer E, listener: any): any;
|
|
17
|
+
} ? E : never;
|
|
18
|
+
/**
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export declare type TypedEventTransform<TThis, TEvent> = TransformedEvent<TThis, "newListener" | "removeListener", Parameters<(event: string, listener: (...args: any[]) => void) => void>> & IEventTransformer<TThis, TEvent & IEvent> & TransformedEvent<TThis, EventEmitterEventType, any[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Event Emitter helper class the supports emitting typed events
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export declare class TypedEventEmitter<TEvent> extends EventEmitter implements IEventProvider<TEvent & IEvent> {
|
|
28
|
+
constructor();
|
|
29
|
+
readonly addListener: TypedEventTransform<this, TEvent>;
|
|
30
|
+
readonly on: TypedEventTransform<this, TEvent>;
|
|
31
|
+
readonly once: TypedEventTransform<this, TEvent>;
|
|
32
|
+
readonly prependListener: TypedEventTransform<this, TEvent>;
|
|
33
|
+
readonly prependOnceListener: TypedEventTransform<this, TEvent>;
|
|
34
|
+
readonly removeListener: TypedEventTransform<this, TEvent>;
|
|
35
|
+
readonly off: TypedEventTransform<this, TEvent>;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=typedEventEmitter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typedEventEmitter.d.ts","sourceRoot":"","sources":["../src/typedEventEmitter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EACN,MAAM,EACN,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,MAAM,iCAAiC,CAAC;AAEzC;;;;;;;GAOG;AACH,oBAAY,qBAAqB,GAAG,YAAY,SAAS;IAAE,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,GAAG,OAAC;CAAE,GAC3F,CAAC,GACD,KAAK,CAAC;AAET;;GAEG;AACH,oBAAY,mBAAmB,CAAC,KAAK,EAAE,MAAM,IAK5C,gBAAgB,CACf,KAAK,EACL,aAAa,GAAG,gBAAgB,EAChC,UAAU,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,KAAK,IAAI,CAAC,CACvE,GAEA,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,GAEzC,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,EAAE,GAAG,EAAE,CAAC,CAAC;AAExD;;;;GAIG;AACH,qBAAa,iBAAiB,CAAC,MAAM,CACpC,SAAQ,YACR,YAAW,cAAc,CAAC,MAAM,GAAG,MAAM,CAAC;;IAkB1C,QAAQ,CAAC,WAAW,EAAE,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACxD,QAAQ,CAAC,EAAE,EAAE,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC/C,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACjD,QAAQ,CAAC,eAAe,EAAE,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC5D,QAAQ,CAAC,mBAAmB,EAAE,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAChE,QAAQ,CAAC,cAAc,EAAE,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC3D,QAAQ,CAAC,GAAG,EAAE,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;CAChD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { EventEmitter } from "events";
|
|
6
|
+
/**
|
|
7
|
+
* Event Emitter helper class the supports emitting typed events
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export class TypedEventEmitter extends EventEmitter {
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
this.addListener = super.addListener.bind(this);
|
|
15
|
+
this.on = super.on.bind(this);
|
|
16
|
+
this.once = super.once.bind(this);
|
|
17
|
+
this.prependListener = super.prependListener.bind(this);
|
|
18
|
+
this.prependOnceListener = super.prependOnceListener.bind(this);
|
|
19
|
+
this.removeListener = super.removeListener.bind(this);
|
|
20
|
+
this.off = super.off.bind(this);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=typedEventEmitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typedEventEmitter.js","sourceRoot":"","sources":["../src/typedEventEmitter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAsCtC;;;;GAIG;AACH,MAAM,OAAO,iBACZ,SAAQ,YAAY;IAGpB;QACC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAsC,CAAC;QACrF,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAsC,CAAC;QACnE,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAsC,CAAC;QACvE,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAGrD,CAAC;QACF,IAAI,CAAC,mBAAmB,GAAG,KAAK,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAG7D,CAAC;QACF,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAsC,CAAC;QAC3F,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAsC,CAAC;IACtE,CAAC;CAQD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { EventEmitter } from \"events\";\nimport {\n\tIEvent,\n\tTransformedEvent,\n\tIEventTransformer,\n\tIEventProvider,\n} from \"@fluidframework/core-interfaces\";\n\n/**\n * The event emitter polyfill and the node event emitter have different event types:\n * string | symbol vs. string | number\n *\n * This type allow us to correctly handle either type\n *\n * @internal\n */\nexport type EventEmitterEventType = EventEmitter extends { on(event: infer E, listener: any) }\n\t? E\n\t: never;\n\n/**\n * @internal\n */\nexport type TypedEventTransform<TThis, TEvent> =\n\t// Event emitter supports some special events for the emitter itself to use\n\t// this exposes those events for the TypedEventEmitter.\n\t// Since we know what the shape of these events are, we can describe them directly via a TransformedEvent\n\t// which easier than trying to extend TEvent directly\n\tTransformedEvent<\n\t\tTThis,\n\t\t\"newListener\" | \"removeListener\",\n\t\tParameters<(event: string, listener: (...args: any[]) => void) => void>\n\t> &\n\t\t// Expose all the events provides by TEvent\n\t\tIEventTransformer<TThis, TEvent & IEvent> &\n\t\t// Add the default overload so this is covertable to EventEmitter regardless of environment\n\t\tTransformedEvent<TThis, EventEmitterEventType, any[]>;\n\n/**\n * Event Emitter helper class the supports emitting typed events\n *\n * @internal\n */\nexport class TypedEventEmitter<TEvent>\n\textends EventEmitter\n\timplements IEventProvider<TEvent & IEvent>\n{\n\tconstructor() {\n\t\tsuper();\n\t\tthis.addListener = super.addListener.bind(this) as TypedEventTransform<this, TEvent>;\n\t\tthis.on = super.on.bind(this) as TypedEventTransform<this, TEvent>;\n\t\tthis.once = super.once.bind(this) as TypedEventTransform<this, TEvent>;\n\t\tthis.prependListener = super.prependListener.bind(this) as TypedEventTransform<\n\t\t\tthis,\n\t\t\tTEvent\n\t\t>;\n\t\tthis.prependOnceListener = super.prependOnceListener.bind(this) as TypedEventTransform<\n\t\t\tthis,\n\t\t\tTEvent\n\t\t>;\n\t\tthis.removeListener = super.removeListener.bind(this) as TypedEventTransform<this, TEvent>;\n\t\tthis.off = super.off.bind(this) as TypedEventTransform<this, TEvent>;\n\t}\n\treadonly addListener: TypedEventTransform<this, TEvent>;\n\treadonly on: TypedEventTransform<this, TEvent>;\n\treadonly once: TypedEventTransform<this, TEvent>;\n\treadonly prependListener: TypedEventTransform<this, TEvent>;\n\treadonly prependOnceListener: TypedEventTransform<this, TEvent>;\n\treadonly removeListener: TypedEventTransform<this, TEvent>;\n\treadonly off: TypedEventTransform<this, TEvent>;\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fluid-internal/client-utils",
|
|
3
|
+
"version": "2.0.0-internal.6.3.1",
|
|
4
|
+
"description": "Not intended for use outside the Fluid Framework.",
|
|
5
|
+
"homepage": "https://fluidframework.com",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/microsoft/FluidFramework.git",
|
|
9
|
+
"directory": "packages/common/client-utils"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"author": "Microsoft and contributors",
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"main": "dist/index.js",
|
|
15
|
+
"module": "lib/index.js",
|
|
16
|
+
"browser": {
|
|
17
|
+
"./dist/indexNode.js": "./dist/indexBrowser.js",
|
|
18
|
+
"./lib/indexNode.js": "./lib/indexBrowser.js"
|
|
19
|
+
},
|
|
20
|
+
"types": "dist/index.d.ts",
|
|
21
|
+
"c8": {
|
|
22
|
+
"all": true,
|
|
23
|
+
"cache-dir": "nyc/.cache",
|
|
24
|
+
"exclude": [
|
|
25
|
+
"src/test/**/*.ts",
|
|
26
|
+
"dist/test/**/*.js"
|
|
27
|
+
],
|
|
28
|
+
"exclude-after-remap": false,
|
|
29
|
+
"include": [
|
|
30
|
+
"src/**/*.ts",
|
|
31
|
+
"dist/**/*.js"
|
|
32
|
+
],
|
|
33
|
+
"report-dir": "nyc/report",
|
|
34
|
+
"reporter": [
|
|
35
|
+
"cobertura",
|
|
36
|
+
"html",
|
|
37
|
+
"text"
|
|
38
|
+
],
|
|
39
|
+
"temp-directory": "nyc/.nyc_output"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@fluidframework/core-interfaces": ">=2.0.0-internal.6.3.1 <2.0.0-internal.6.4.0",
|
|
43
|
+
"@fluidframework/core-utils": ">=2.0.0-internal.6.3.1 <2.0.0-internal.6.4.0",
|
|
44
|
+
"@types/events": "^3.0.0",
|
|
45
|
+
"base64-js": "^1.5.1",
|
|
46
|
+
"buffer": "^6.0.3",
|
|
47
|
+
"events": "^3.1.0",
|
|
48
|
+
"lodash": "^4.17.21",
|
|
49
|
+
"sha.js": "^2.4.11"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@fluid-tools/build-cli": "^0.22.0",
|
|
53
|
+
"@fluidframework/build-common": "^2.0.0",
|
|
54
|
+
"@fluidframework/build-tools": "^0.22.0",
|
|
55
|
+
"@fluidframework/eslint-config-fluid": "^2.1.0",
|
|
56
|
+
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.6.3.1 <2.0.0-internal.6.4.0",
|
|
57
|
+
"@microsoft/api-extractor": "^7.34.4",
|
|
58
|
+
"@rushstack/eslint-config": "^2.5.1",
|
|
59
|
+
"@types/base64-js": "^1.3.0",
|
|
60
|
+
"@types/jest": "29.5.3",
|
|
61
|
+
"@types/jest-environment-puppeteer": "2.2.0",
|
|
62
|
+
"@types/mocha": "^9.1.1",
|
|
63
|
+
"@types/node": "^16.18.38",
|
|
64
|
+
"@types/puppeteer": "1.3.0",
|
|
65
|
+
"@types/rewire": "^2.5.28",
|
|
66
|
+
"@types/sha.js": "^2.4.0",
|
|
67
|
+
"@types/sinon": "^7.0.13",
|
|
68
|
+
"c8": "^7.7.1",
|
|
69
|
+
"concurrently": "^8.2.1",
|
|
70
|
+
"copyfiles": "^2.4.1",
|
|
71
|
+
"cross-env": "^7.0.3",
|
|
72
|
+
"eslint": "~8.6.0",
|
|
73
|
+
"eslint-config-prettier": "~8.5.0",
|
|
74
|
+
"jest": "^29.6.2",
|
|
75
|
+
"jest-junit": "^10.0.0",
|
|
76
|
+
"jest-puppeteer": "^6.2.0",
|
|
77
|
+
"mocha": "^10.2.0",
|
|
78
|
+
"mocha-json-output-reporter": "^2.0.1",
|
|
79
|
+
"mocha-multi-reporters": "^1.5.1",
|
|
80
|
+
"moment": "^2.21.0",
|
|
81
|
+
"prettier": "~2.6.2",
|
|
82
|
+
"puppeteer": "^17.1.3",
|
|
83
|
+
"rewire": "^5.0.0",
|
|
84
|
+
"rimraf": "^4.4.0",
|
|
85
|
+
"sinon": "^7.4.2",
|
|
86
|
+
"ts-jest": "^29.1.1",
|
|
87
|
+
"ts-node": "^10.9.1",
|
|
88
|
+
"typescript": "~4.5.5"
|
|
89
|
+
},
|
|
90
|
+
"fluidBuild": {
|
|
91
|
+
"tasks": {
|
|
92
|
+
"eslint": [
|
|
93
|
+
"tsc",
|
|
94
|
+
"build:test:mocha",
|
|
95
|
+
"build:test:jest",
|
|
96
|
+
"build:test:types"
|
|
97
|
+
],
|
|
98
|
+
"build:test:jest": [
|
|
99
|
+
"tsc"
|
|
100
|
+
],
|
|
101
|
+
"build:test:mocha": [
|
|
102
|
+
"tsc"
|
|
103
|
+
],
|
|
104
|
+
"build:test:types": [
|
|
105
|
+
"tsc"
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
"typeValidation": {
|
|
110
|
+
"disabled": true,
|
|
111
|
+
"broken": {}
|
|
112
|
+
},
|
|
113
|
+
"scripts": {
|
|
114
|
+
"build": "fluid-build . --task build",
|
|
115
|
+
"build:commonjs": "fluid-build . --task commonjs",
|
|
116
|
+
"build:compile": "fluid-build . --task compile",
|
|
117
|
+
"build:docs": "api-extractor run --local --typescript-compiler-folder ./node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/doc-models/* ../../../_api-extractor-temp/",
|
|
118
|
+
"build:esnext": "tsc --project ./tsconfig.esnext.json",
|
|
119
|
+
"build:test": "concurrently npm:build:test:mocha npm:build:test:jest npm:build:test:types",
|
|
120
|
+
"build:test:jest": "tsc --project ./src/test/jest/tsconfig.json",
|
|
121
|
+
"build:test:mocha": "tsc --project ./src/test/mocha/tsconfig.json",
|
|
122
|
+
"build:test:types": "tsc --project ./src/test/types/tsconfig.json",
|
|
123
|
+
"ci:build:docs": "api-extractor run --typescript-compiler-folder ./node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/doc-models/* ../../../_api-extractor-temp/",
|
|
124
|
+
"clean": "rimraf --glob '_api-extractor-temp' 'dist' 'lib' '*.tsbuildinfo' '*.build.log' 'nyc'",
|
|
125
|
+
"eslint": "eslint --format stylish src",
|
|
126
|
+
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
127
|
+
"format": "npm run prettier:fix",
|
|
128
|
+
"lint": "npm run prettier && npm run eslint",
|
|
129
|
+
"lint:fix": "npm run prettier:fix && npm run eslint:fix",
|
|
130
|
+
"prettier": "prettier --check . --ignore-path ../../../.prettierignore",
|
|
131
|
+
"prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
|
|
132
|
+
"test": "npm run test:mocha && npm run test:jest",
|
|
133
|
+
"test:coverage": "c8 npm test",
|
|
134
|
+
"test:jest": "jest",
|
|
135
|
+
"test:mocha": "mocha --recursive dist/test/mocha/**/*.spec.js --exit --project test/tsconfig.json",
|
|
136
|
+
"tsc": "tsc",
|
|
137
|
+
"typetests:gen": "fluid-type-test-generator",
|
|
138
|
+
"typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { IsoBuffer } from "./indexNode";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Converts the provided {@link https://en.wikipedia.org/wiki/Base64 | base64}-encoded string
|
|
10
|
+
* to {@link https://en.wikipedia.org/wiki/UTF-8 | utf-8}.
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export const fromBase64ToUtf8 = (input: string): string =>
|
|
15
|
+
IsoBuffer.from(input, "base64").toString("utf-8");
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Converts the provided {@link https://en.wikipedia.org/wiki/UTF-8 | utf-8}-encoded string
|
|
19
|
+
* to {@link https://en.wikipedia.org/wiki/Base64 | base64}.
|
|
20
|
+
*
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export const fromUtf8ToBase64 = (input: string): string =>
|
|
24
|
+
IsoBuffer.from(input, "utf8").toString("base64");
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Convenience function to convert unknown encoding to utf8 that avoids
|
|
28
|
+
* buffer copies/encode ops when no conversion is needed.
|
|
29
|
+
* @param input - The source string to convert.
|
|
30
|
+
* @param encoding - The source string's encoding.
|
|
31
|
+
*
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
export const toUtf8 = (input: string, encoding: string): string => {
|
|
35
|
+
switch (encoding) {
|
|
36
|
+
case "utf8":
|
|
37
|
+
case "utf-8":
|
|
38
|
+
return input;
|
|
39
|
+
default:
|
|
40
|
+
return IsoBuffer.from(input, encoding).toString();
|
|
41
|
+
}
|
|
42
|
+
};
|