@fluid-internal/client-utils 2.0.0-internal.7.2.2 → 2.0.0-internal.7.3.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.
Files changed (82) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +7 -3
  3. package/api-extractor.json +4 -1
  4. package/api-report/client-utils.api.md +8 -5
  5. package/dist/client-utils-alpha.d.ts +48 -0
  6. package/dist/client-utils-beta.d.ts +48 -0
  7. package/dist/client-utils-public.d.ts +48 -0
  8. package/dist/client-utils-untrimmed.d.ts +249 -0
  9. package/dist/eventForwarder.d.ts +1 -0
  10. package/dist/eventForwarder.d.ts.map +1 -1
  11. package/dist/hashFileBrowser.js +2 -2
  12. package/dist/hashFileBrowser.js.map +1 -1
  13. package/dist/hashFileNode.d.ts.map +1 -1
  14. package/dist/hashFileNode.js +4 -14
  15. package/dist/hashFileNode.js.map +1 -1
  16. package/dist/indexBrowser.d.ts +1 -1
  17. package/dist/indexBrowser.d.ts.map +1 -1
  18. package/dist/indexBrowser.js +2 -2
  19. package/dist/indexBrowser.js.map +1 -1
  20. package/dist/indexNode.d.ts +1 -1
  21. package/dist/indexNode.d.ts.map +1 -1
  22. package/dist/indexNode.js +2 -2
  23. package/dist/indexNode.js.map +1 -1
  24. package/dist/performanceIsomorphic.d.ts +9 -0
  25. package/dist/performanceIsomorphic.d.ts.map +1 -1
  26. package/dist/performanceIsomorphic.js +10 -0
  27. package/dist/performanceIsomorphic.js.map +1 -1
  28. package/dist/tsdoc-metadata.json +1 -1
  29. package/dist/typedEventEmitter.d.ts +1 -0
  30. package/dist/typedEventEmitter.d.ts.map +1 -1
  31. package/lib/client-utils-alpha.d.ts +48 -0
  32. package/lib/client-utils-beta.d.ts +48 -0
  33. package/lib/client-utils-public.d.ts +48 -0
  34. package/lib/client-utils-untrimmed.d.ts +249 -0
  35. package/lib/eventForwarder.d.ts +1 -0
  36. package/lib/eventForwarder.d.ts.map +1 -1
  37. package/lib/hashFileBrowser.js +1 -1
  38. package/lib/hashFileBrowser.js.map +1 -1
  39. package/lib/hashFileNode.d.ts.map +1 -1
  40. package/lib/hashFileNode.js +1 -8
  41. package/lib/hashFileNode.js.map +1 -1
  42. package/lib/indexBrowser.d.ts +1 -1
  43. package/lib/indexBrowser.d.ts.map +1 -1
  44. package/lib/indexBrowser.js +1 -1
  45. package/lib/indexBrowser.js.map +1 -1
  46. package/lib/indexNode.d.ts +1 -1
  47. package/lib/indexNode.d.ts.map +1 -1
  48. package/lib/indexNode.js +1 -1
  49. package/lib/indexNode.js.map +1 -1
  50. package/lib/performanceIsomorphic.d.ts +9 -0
  51. package/lib/performanceIsomorphic.d.ts.map +1 -1
  52. package/lib/performanceIsomorphic.js +9 -1
  53. package/lib/performanceIsomorphic.js.map +1 -1
  54. package/lib/typedEventEmitter.d.ts +1 -0
  55. package/lib/typedEventEmitter.d.ts.map +1 -1
  56. package/package.json +24 -12
  57. package/src/hashFileBrowser.ts +1 -1
  58. package/src/hashFileNode.ts +2 -9
  59. package/src/indexBrowser.ts +1 -1
  60. package/src/indexNode.ts +1 -1
  61. package/src/performanceIsomorphic.ts +10 -0
  62. package/tsconfig.esnext.json +1 -2
  63. package/tsconfig.json +6 -8
  64. package/dist/performanceBrowser.d.ts +0 -10
  65. package/dist/performanceBrowser.d.ts.map +0 -1
  66. package/dist/performanceBrowser.js +0 -12
  67. package/dist/performanceBrowser.js.map +0 -1
  68. package/dist/performanceNode.d.ts +0 -10
  69. package/dist/performanceNode.d.ts.map +0 -1
  70. package/dist/performanceNode.js +0 -15
  71. package/dist/performanceNode.js.map +0 -1
  72. package/lib/performanceBrowser.d.ts +0 -10
  73. package/lib/performanceBrowser.d.ts.map +0 -1
  74. package/lib/performanceBrowser.js +0 -9
  75. package/lib/performanceBrowser.js.map +0 -1
  76. package/lib/performanceNode.d.ts +0 -10
  77. package/lib/performanceNode.d.ts.map +0 -1
  78. package/lib/performanceNode.js +0 -12
  79. package/lib/performanceNode.js.map +0 -1
  80. package/src/performanceBrowser.ts +0 -11
  81. package/src/performanceNode.ts +0 -14
  82. package/types/perf_hooks.d.ts +0 -10
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @fluid-internal/client-utils
2
2
 
3
+ ## 2.0.0-internal.7.3.0
4
+
5
+ Dependency updates only.
6
+
3
7
  ## 2.0.0-internal.7.2.0
4
8
 
5
9
  Dependency updates only.
package/README.md CHANGED
@@ -3,7 +3,12 @@
3
3
  This package is intended for sharing and promoting utility functions across packages in the Fluid Framework repo,
4
4
  primarily within the client release group.
5
5
 
6
- Use outside of the Fluid Framework repo is not supported or recommended.
6
+ <!-- AUTO-GENERATED-CONTENT:START (README_PACKAGE_SCOPE_NOTICE) -->
7
+
8
+ **IMPORTANT: This package is intended strictly as an implementation detail of the Fluid Framework and is not intended for public consumption.**
9
+ **We make no stability guarantees regarding its APIs.**
10
+
11
+ <!-- AUTO-GENERATED-CONTENT:END -->
7
12
 
8
13
  ## Adding code to this package
9
14
 
@@ -61,8 +66,7 @@ package for more information including tools to convert between version schemes.
61
66
 
62
67
  This project may contain Microsoft trademarks or logos for Microsoft projects, products, or services.
63
68
 
64
- Use of these trademarks or logos must follow Microsoft's [Trademark & Brand
65
- Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
69
+ Use of these trademarks or logos must follow Microsoft's [Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
66
70
 
67
71
  Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
68
72
 
@@ -1,4 +1,7 @@
1
1
  {
2
2
  "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
- "extends": "@fluidframework/build-common/api-extractor-base.json"
3
+ "extends": "@fluidframework/build-common/api-extractor-base.json",
4
+ "dtsRollup": {
5
+ "enabled": true
6
+ }
4
7
  }
@@ -4,6 +4,8 @@
4
4
 
5
5
  ```ts
6
6
 
7
+ /// <reference types="node" />
8
+
7
9
  import { EventEmitter } from 'events';
8
10
  import { IDisposable } from '@fluidframework/core-interfaces';
9
11
  import { IEvent } from '@fluidframework/core-interfaces';
@@ -12,13 +14,14 @@ import { IEventTransformer } from '@fluidframework/core-interfaces';
12
14
  import { TransformedEvent } from '@fluidframework/core-interfaces';
13
15
 
14
16
  // @internal
15
- export class Buffer extends Uint8Array {
17
+ class Buffer_2 extends Uint8Array {
16
18
  static from(value: unknown, encodingOrOffset?: unknown, length?: unknown): IsoBuffer;
17
19
  // (undocumented)
18
- static isBuffer(obj: unknown): obj is Buffer;
20
+ static isBuffer(obj: unknown): obj is Buffer_2;
19
21
  // (undocumented)
20
22
  toString(encoding?: "utf8" | "utf-8" | "base64"): string;
21
23
  }
24
+ export { Buffer_2 as Buffer }
22
25
 
23
26
  // @internal
24
27
  export const bufferToString: (blob: ArrayBufferLike, encoding: "utf8" | "utf-8" | "base64") => string;
@@ -56,10 +59,10 @@ export function gitHashFile(file: IsoBuffer): Promise<string>;
56
59
  export function hashFile(file: IsoBuffer, algorithm?: "SHA-1" | "SHA-256", hashEncoding?: "hex" | "base64"): Promise<string>;
57
60
 
58
61
  // @internal (undocumented)
59
- export const IsoBuffer: typeof Buffer;
62
+ export const IsoBuffer: typeof Buffer_2;
60
63
 
61
64
  // @internal (undocumented)
62
- export type IsoBuffer = Buffer;
65
+ export type IsoBuffer = Buffer_2;
63
66
 
64
67
  // @internal
65
68
  export type IsomorphicPerformance = Partial<Performance> & Pick<Performance, "clearMarks" | "mark" | "measure" | "now">;
@@ -71,7 +74,7 @@ export interface ITraceEvent {
71
74
  readonly totalTimeElapsed: number;
72
75
  }
73
76
 
74
- // @internal (undocumented)
77
+ // @internal
75
78
  const performance_2: IsomorphicPerformance;
76
79
  export { performance_2 as performance }
77
80
 
@@ -0,0 +1,48 @@
1
+ /// <reference types="node" />
2
+
3
+ import { EventEmitter } from 'events';
4
+ import { IDisposable } from '@fluidframework/core-interfaces';
5
+ import { IEvent } from '@fluidframework/core-interfaces';
6
+ import { IEventProvider } from '@fluidframework/core-interfaces';
7
+ import { IEventTransformer } from '@fluidframework/core-interfaces';
8
+ import { TransformedEvent } from '@fluidframework/core-interfaces';
9
+
10
+ /* Excluded from this release type: Buffer_2 */
11
+
12
+ /* Excluded from this release type: bufferToString */
13
+
14
+ /* Excluded from this release type: EventEmitterEventType */
15
+
16
+ /* Excluded from this release type: EventForwarder */
17
+
18
+ /* Excluded from this release type: fromBase64ToUtf8 */
19
+
20
+ /* Excluded from this release type: fromUtf8ToBase64 */
21
+
22
+ /* Excluded from this release type: gitHashFile */
23
+
24
+ /* Excluded from this release type: hashFile */
25
+
26
+ /* Excluded from this release type: IsoBuffer */
27
+
28
+ /* Excluded from this release type: IsomorphicPerformance */
29
+
30
+ /* Excluded from this release type: ITraceEvent */
31
+
32
+ /* Excluded from this release type: performance_2 */
33
+
34
+ /* Excluded from this release type: stringToBuffer */
35
+
36
+ /* Excluded from this release type: toUtf8 */
37
+
38
+ /* Excluded from this release type: Trace */
39
+
40
+ /* Excluded from this release type: TypedEventEmitter */
41
+
42
+ /* Excluded from this release type: TypedEventTransform */
43
+
44
+ /* Excluded from this release type: Uint8ArrayToArrayBuffer */
45
+
46
+ /* Excluded from this release type: Uint8ArrayToString */
47
+
48
+ export { }
@@ -0,0 +1,48 @@
1
+ /// <reference types="node" />
2
+
3
+ import { EventEmitter } from 'events';
4
+ import { IDisposable } from '@fluidframework/core-interfaces';
5
+ import { IEvent } from '@fluidframework/core-interfaces';
6
+ import { IEventProvider } from '@fluidframework/core-interfaces';
7
+ import { IEventTransformer } from '@fluidframework/core-interfaces';
8
+ import { TransformedEvent } from '@fluidframework/core-interfaces';
9
+
10
+ /* Excluded from this release type: Buffer_2 */
11
+
12
+ /* Excluded from this release type: bufferToString */
13
+
14
+ /* Excluded from this release type: EventEmitterEventType */
15
+
16
+ /* Excluded from this release type: EventForwarder */
17
+
18
+ /* Excluded from this release type: fromBase64ToUtf8 */
19
+
20
+ /* Excluded from this release type: fromUtf8ToBase64 */
21
+
22
+ /* Excluded from this release type: gitHashFile */
23
+
24
+ /* Excluded from this release type: hashFile */
25
+
26
+ /* Excluded from this release type: IsoBuffer */
27
+
28
+ /* Excluded from this release type: IsomorphicPerformance */
29
+
30
+ /* Excluded from this release type: ITraceEvent */
31
+
32
+ /* Excluded from this release type: performance_2 */
33
+
34
+ /* Excluded from this release type: stringToBuffer */
35
+
36
+ /* Excluded from this release type: toUtf8 */
37
+
38
+ /* Excluded from this release type: Trace */
39
+
40
+ /* Excluded from this release type: TypedEventEmitter */
41
+
42
+ /* Excluded from this release type: TypedEventTransform */
43
+
44
+ /* Excluded from this release type: Uint8ArrayToArrayBuffer */
45
+
46
+ /* Excluded from this release type: Uint8ArrayToString */
47
+
48
+ export { }
@@ -0,0 +1,48 @@
1
+ /// <reference types="node" />
2
+
3
+ import { EventEmitter } from 'events';
4
+ import { IDisposable } from '@fluidframework/core-interfaces';
5
+ import { IEvent } from '@fluidframework/core-interfaces';
6
+ import { IEventProvider } from '@fluidframework/core-interfaces';
7
+ import { IEventTransformer } from '@fluidframework/core-interfaces';
8
+ import { TransformedEvent } from '@fluidframework/core-interfaces';
9
+
10
+ /* Excluded from this release type: Buffer_2 */
11
+
12
+ /* Excluded from this release type: bufferToString */
13
+
14
+ /* Excluded from this release type: EventEmitterEventType */
15
+
16
+ /* Excluded from this release type: EventForwarder */
17
+
18
+ /* Excluded from this release type: fromBase64ToUtf8 */
19
+
20
+ /* Excluded from this release type: fromUtf8ToBase64 */
21
+
22
+ /* Excluded from this release type: gitHashFile */
23
+
24
+ /* Excluded from this release type: hashFile */
25
+
26
+ /* Excluded from this release type: IsoBuffer */
27
+
28
+ /* Excluded from this release type: IsomorphicPerformance */
29
+
30
+ /* Excluded from this release type: ITraceEvent */
31
+
32
+ /* Excluded from this release type: performance_2 */
33
+
34
+ /* Excluded from this release type: stringToBuffer */
35
+
36
+ /* Excluded from this release type: toUtf8 */
37
+
38
+ /* Excluded from this release type: Trace */
39
+
40
+ /* Excluded from this release type: TypedEventEmitter */
41
+
42
+ /* Excluded from this release type: TypedEventTransform */
43
+
44
+ /* Excluded from this release type: Uint8ArrayToArrayBuffer */
45
+
46
+ /* Excluded from this release type: Uint8ArrayToString */
47
+
48
+ export { }
@@ -0,0 +1,249 @@
1
+ /// <reference types="node" />
2
+
3
+ import { EventEmitter } from 'events';
4
+ import { IDisposable } from '@fluidframework/core-interfaces';
5
+ import { IEvent } from '@fluidframework/core-interfaces';
6
+ import { IEventProvider } from '@fluidframework/core-interfaces';
7
+ import { IEventTransformer } from '@fluidframework/core-interfaces';
8
+ import { TransformedEvent } from '@fluidframework/core-interfaces';
9
+
10
+ /**
11
+ * Declare the subset of Buffer functionality we want to make available instead of
12
+ * exposing the entirely of Node's typings. This should match the public interface
13
+ * of the browser implementation, so any changes made in one should be made in both.
14
+ *
15
+ * @internal
16
+ */
17
+ declare class Buffer_2 extends Uint8Array {
18
+ toString(encoding?: "utf8" | "utf-8" | "base64"): string;
19
+ /**
20
+ * Static constructor
21
+ *
22
+ * @param value - (string | ArrayBuffer).
23
+ * @param encodingOrOffset - (string | number).
24
+ * @param length - (number).
25
+ *
26
+ * @privateRemarks TODO: Use actual types
27
+ */
28
+ static from(value: unknown, encodingOrOffset?: unknown, length?: unknown): IsoBuffer;
29
+ static isBuffer(obj: unknown): obj is Buffer_2;
30
+ }
31
+ export { Buffer_2 as Buffer }
32
+
33
+ /**
34
+ * Convert binary blob to string format
35
+ *
36
+ * @param blob - The binary blob
37
+ * @param encoding - Output string's encoding
38
+ * @returns The blob in string format
39
+ *
40
+ * @internal
41
+ */
42
+ export declare const bufferToString: (blob: ArrayBufferLike, encoding: "utf8" | "utf-8" | "base64") => string;
43
+
44
+ /**
45
+ * The event emitter polyfill and the node event emitter have different event types:
46
+ * string | symbol vs. string | number
47
+ *
48
+ * This type allow us to correctly handle either type
49
+ *
50
+ * @internal
51
+ */
52
+ export declare type EventEmitterEventType = EventEmitter extends {
53
+ on(event: infer E, listener: any): any;
54
+ } ? E : never;
55
+
56
+ /**
57
+ * Base class used for forwarding events from a source EventEmitter.
58
+ * This can be useful when all arbitrary listeners need to be removed,
59
+ * but the primary source needs to stay intact.
60
+ *
61
+ * @internal
62
+ */
63
+ export declare class EventForwarder<TEvent = IEvent> extends TypedEventEmitter<TEvent> implements IDisposable {
64
+ protected static isEmitterEvent(event: string): boolean;
65
+ private static readonly newListenerEvent;
66
+ private static readonly removeListenerEvent;
67
+ /**
68
+ * {@inheritDoc @fluidframework/core-interfaces#IDisposable.disposed}
69
+ */
70
+ get disposed(): boolean;
71
+ private isDisposed;
72
+ private readonly forwardingEvents;
73
+ constructor(source?: EventEmitter | IEventProvider<TEvent & IEvent>);
74
+ /**
75
+ * {@inheritDoc @fluidframework/core-interfaces#IDisposable.dispose}
76
+ */
77
+ dispose(): void;
78
+ protected forwardEvent(source: EventEmitter | IEventProvider<TEvent & IEvent>, ...events: string[]): void;
79
+ protected unforwardEvent(source: EventEmitter | IEventProvider<TEvent & IEvent>, ...events: string[]): void;
80
+ }
81
+
82
+ /**
83
+ * Converts the provided {@link https://en.wikipedia.org/wiki/Base64 | base64}-encoded string
84
+ * to {@link https://en.wikipedia.org/wiki/UTF-8 | utf-8}.
85
+ *
86
+ * @internal
87
+ */
88
+ export declare const fromBase64ToUtf8: (input: string) => string;
89
+
90
+ /**
91
+ * Converts the provided {@link https://en.wikipedia.org/wiki/UTF-8 | utf-8}-encoded string
92
+ * to {@link https://en.wikipedia.org/wiki/Base64 | base64}.
93
+ *
94
+ * @internal
95
+ */
96
+ export declare const fromUtf8ToBase64: (input: string) => string;
97
+
98
+ /**
99
+ * Create a github hash (Github hashes the string with blob and size)
100
+ * Must be called under secure context for browsers
101
+ *
102
+ * @param file - The contents of the file in a buffer
103
+ * @returns The sha1 hash of the content of the buffer with the `blob` prefix and size
104
+ *
105
+ * @internal
106
+ */
107
+ export declare function gitHashFile(file: IsoBuffer): Promise<string>;
108
+
109
+ /**
110
+ * Hash a file. Consistent within a session, but should not be persisted and
111
+ * is not consistent with git.
112
+ * If called under an insecure context for a browser, this will fallback to
113
+ * using the node implementation.
114
+ *
115
+ * @param file - The contents of the file in a buffer.
116
+ * @param algorithm - The hash algorithm to use, artificially constrained by what is used internally.
117
+ * @param hashEncoding - The encoding of the returned hash, also artificially constrained.
118
+ * @returns The hash of the content of the buffer.
119
+ *
120
+ * @internal
121
+ */
122
+ export declare function hashFile(file: IsoBuffer, algorithm?: "SHA-1" | "SHA-256", hashEncoding?: "hex" | "base64"): Promise<string>;
123
+
124
+ /**
125
+ * @internal
126
+ */
127
+ export declare const IsoBuffer: typeof Buffer_2;
128
+
129
+ /**
130
+ * @internal
131
+ */
132
+ export declare type IsoBuffer = Buffer_2;
133
+
134
+ /**
135
+ * This type contains all browser performance properties as optional, and some
136
+ * of the intersecting properties of node and browser performance as required.
137
+ *
138
+ * @internal
139
+ */
140
+ export declare type IsomorphicPerformance = Partial<Performance> & Pick<Performance, "clearMarks" | "mark" | "measure" | "now">;
141
+
142
+ /**
143
+ * Event in a performance trace including time elapsed.
144
+ *
145
+ * @internal
146
+ */
147
+ export declare interface ITraceEvent {
148
+ /**
149
+ * Total time elapsed since the start of the Trace.
150
+ * Measured in milliseconds as a floating point with a decimal
151
+ */
152
+ readonly totalTimeElapsed: number;
153
+ /**
154
+ * Time elapsed since the last trace event.
155
+ * Measured in milliseconds as a floating point with a decimal
156
+ */
157
+ readonly duration: number;
158
+ /**
159
+ * This number represents a relative time which should
160
+ * be consistent for all trace ticks.
161
+ */
162
+ readonly tick: number;
163
+ }
164
+
165
+ /**
166
+ * This exported "performance" member masks the built-in globalThis.performance object
167
+ * as an IsomorphicPerformance, which hides all of its features that aren't compatible
168
+ * between Node and browser implementations. Anything exposed on this performance object
169
+ * is considered safe to use regarless of the environment it runs in.
170
+ *
171
+ * @internal
172
+ */
173
+ declare const performance_2: IsomorphicPerformance;
174
+ export { performance_2 as performance }
175
+
176
+ /**
177
+ * Convert base64 or utf8 string to array buffer.
178
+ * @param encoding - The input string's encoding.
179
+ *
180
+ * @internal
181
+ */
182
+ export declare function stringToBuffer(input: string, encoding: string): ArrayBufferLike;
183
+
184
+ /**
185
+ * Convenience function to convert unknown encoding to utf8 that avoids
186
+ * buffer copies/encode ops when no conversion is needed.
187
+ * @param input - The source string to convert.
188
+ * @param encoding - The source string's encoding.
189
+ *
190
+ * @internal
191
+ */
192
+ export declare const toUtf8: (input: string, encoding: string) => string;
193
+
194
+ /**
195
+ * Helper class for tracing performance of events
196
+ * Time measurements are in milliseconds as a floating point with a decimal
197
+ *
198
+ * @internal
199
+ */
200
+ export declare class Trace {
201
+ readonly startTick: number;
202
+ static start(): Trace;
203
+ protected lastTick: number;
204
+ protected constructor(startTick: number);
205
+ trace(): ITraceEvent;
206
+ }
207
+
208
+ /**
209
+ * Event Emitter helper class the supports emitting typed events
210
+ *
211
+ * @internal
212
+ */
213
+ export declare class TypedEventEmitter<TEvent> extends EventEmitter implements IEventProvider<TEvent & IEvent> {
214
+ constructor();
215
+ readonly addListener: TypedEventTransform<this, TEvent>;
216
+ readonly on: TypedEventTransform<this, TEvent>;
217
+ readonly once: TypedEventTransform<this, TEvent>;
218
+ readonly prependListener: TypedEventTransform<this, TEvent>;
219
+ readonly prependOnceListener: TypedEventTransform<this, TEvent>;
220
+ readonly removeListener: TypedEventTransform<this, TEvent>;
221
+ readonly off: TypedEventTransform<this, TEvent>;
222
+ }
223
+
224
+ /**
225
+ * @internal
226
+ */
227
+ 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[]>;
228
+
229
+ /**
230
+ * Converts a Uint8Array array to an ArrayBuffer.
231
+ * @param array - Array to convert to ArrayBuffer.
232
+ *
233
+ * @internal
234
+ */
235
+ export declare function Uint8ArrayToArrayBuffer(array: Uint8Array): ArrayBuffer;
236
+
237
+ /**
238
+ * Converts a Uint8Array to a string of the provided encoding.
239
+ * @remarks Useful when the array might be an IsoBuffer.
240
+ * @param arr - The array to convert.
241
+ * @param encoding - Optional target encoding; only "utf8" and "base64" are
242
+ * supported, with "utf8" being default.
243
+ * @returns The converted string.
244
+ *
245
+ * @internal
246
+ */
247
+ export declare function Uint8ArrayToString(arr: Uint8Array, encoding?: "utf8" | "utf-8" | "base64"): string;
248
+
249
+ export { }
@@ -2,6 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ /// <reference types="node" />
5
6
  import { EventEmitter } from "events";
6
7
  import { IDisposable, IEvent, IEventProvider } from "@fluidframework/core-interfaces";
7
8
  import { TypedEventEmitter } from "./typedEventEmitter";
@@ -1 +1 @@
1
- {"version":3,"file":"eventForwarder.d.ts","sourceRoot":"","sources":["../src/eventForwarder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD;;;;;;GAMG;AACH,qBAAa,cAAc,CAAC,MAAM,GAAG,MAAM,CAC1C,SAAQ,iBAAiB,CAAC,MAAM,CAChC,YAAW,WAAW;IAEtB,SAAS,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAOvD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAiB;IACzD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAoB;IAE/D;;OAEG;IACH,IAAW,QAAQ,IAAI,OAAO,CAE7B;IACD,OAAO,CAAC,UAAU,CAAkB;IAEpC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAG7B;gB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YAAY,CACrB,MAAM,EAAE,YAAY,GAAG,cAAc,CAAC,MAAM,GAAG,MAAM,CAAC,EACtD,GAAG,MAAM,EAAE,MAAM,EAAE,GACjB,IAAI;IAqBP,SAAS,CAAC,cAAc,CACvB,MAAM,EAAE,YAAY,GAAG,cAAc,CAAC,MAAM,GAAG,MAAM,CAAC,EACtD,GAAG,MAAM,EAAE,MAAM,EAAE,GACjB,IAAI;CAiBP"}
@@ -71,9 +71,9 @@ async function hashFile(file, algorithm = "SHA-1", hashEncoding = "hex") {
71
71
  // from the main chunk and will be of non-trivial size. It will not be served
72
72
  // under normal circumstances.
73
73
  if (crypto.subtle === undefined) {
74
- return Promise.resolve().then(() => __importStar(require(
74
+ return import(
75
75
  /* webpackChunkName: "FluidFramework-HashFallback" */
76
- "./hashFileNode"))).then(async (m) => m.hashFile(file, algorithm, hashEncoding));
76
+ "./hashFileNode.js").then(async (m) => m.hashFile(file, algorithm, hashEncoding));
77
77
  }
78
78
  // This is split up this way to facilitate testing (see the test for more info)
79
79
  const hashArray = await digestBuffer(file, algorithm);
@@ -1 +1 @@
1
- {"version":3,"file":"hashFileBrowser.js","sourceRoot":"","sources":["../src/hashFileBrowser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,oDAAsC;AACtC,mDAA4C;AAE5C,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,EA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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\";\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\"\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"]}
1
+ {"version":3,"file":"hashFileBrowser.js","sourceRoot":"","sources":["../src/hashFileBrowser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,oDAAsC;AACtC,mDAA4C;AAE5C,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;gBAC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,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\";\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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"hashFileNode.d.ts","sourceRoot":"","sources":["../src/hashFileNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;;;;;;;;;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,CAiBjB;AAED;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAQlE"}
1
+ {"version":3,"file":"hashFileNode.d.ts","sourceRoot":"","sources":["../src/hashFileNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;;;;;;;;;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"}
@@ -3,15 +3,9 @@
3
3
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
4
  * Licensed under the MIT License.
5
5
  */
6
- var __importDefault = (this && this.__importDefault) || function (mod) {
7
- return (mod && mod.__esModule) ? mod : { "default": mod };
8
- };
9
6
  Object.defineProperty(exports, "__esModule", { value: true });
10
7
  exports.gitHashFile = exports.hashFile = void 0;
11
- // eslint-disable-next-line import/no-internal-modules
12
- const sha1_1 = __importDefault(require("sha.js/sha1"));
13
- // eslint-disable-next-line import/no-internal-modules
14
- const sha256_1 = __importDefault(require("sha.js/sha256"));
8
+ const sha_js_1 = require("sha.js");
15
9
  /**
16
10
  * Hash a file. Consistent within a session, but should not be persisted and
17
11
  * is not consistent with git.
@@ -30,13 +24,11 @@ async function hashFile(file, algorithm = "SHA-1", hashEncoding = "hex") {
30
24
  // eslint-disable-next-line default-case
31
25
  switch (algorithm) {
32
26
  case "SHA-1": {
33
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
34
- engine = new sha1_1.default();
27
+ engine = new sha_js_1.sha1();
35
28
  break;
36
29
  }
37
30
  case "SHA-256": {
38
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
39
- engine = new sha256_1.default();
31
+ engine = new sha_js_1.sha256();
40
32
  break;
41
33
  }
42
34
  }
@@ -57,9 +49,7 @@ async function gitHashFile(file) {
57
49
  const size = file.byteLength;
58
50
  // eslint-disable-next-line unicorn/prefer-code-point
59
51
  const filePrefix = `blob ${size.toString()}${String.fromCharCode(0)}`;
60
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
61
- const engine = new sha1_1.default();
62
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
52
+ const engine = new sha_js_1.sha1();
63
53
  return engine.update(filePrefix).update(file).digest("hex");
64
54
  }
65
55
  exports.gitHashFile = gitHashFile;
@@ -1 +1 @@
1
- {"version":3,"file":"hashFileNode.js","sourceRoot":"","sources":["../src/hashFileNode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,sDAAsD;AACtD,uDAA+B;AAC/B,sDAAsD;AACtD,2DAAmC;AAInC;;;;;;;;;;;;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,sGAAsG;YACtG,MAAM,GAAG,IAAI,cAAI,EAAE,CAAC;YACpB,MAAM;SACN;QACD,KAAK,SAAS,CAAC,CAAC;YACf,sGAAsG;YACtG,MAAM,GAAG,IAAI,gBAAM,EAAE,CAAC;YACtB,MAAM;SACN;KACD;IACD,yGAAyG;IACzG,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,YAAY,CAAW,CAAC;AAC3D,CAAC;AArBD,4BAqBC;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,sGAAsG;IACtG,MAAM,MAAM,GAAG,IAAI,cAAI,EAAE,CAAC;IAC1B,yGAAyG;IACzG,OAAO,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAW,CAAC;AACvE,CAAC;AARD,kCAQC","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-internal-modules\nimport sha1 from \"sha.js/sha1\";\n// eslint-disable-next-line import/no-internal-modules\nimport sha256 from \"sha.js/sha256\";\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\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call\n\t\t\tengine = new sha1();\n\t\t\tbreak;\n\t\t}\n\t\tcase \"SHA-256\": {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call\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\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call\n\tconst engine = new sha1();\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n\treturn engine.update(filePrefix).update(file).digest(\"hex\") as string;\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\";\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"]}
@@ -4,5 +4,5 @@
4
4
  */
5
5
  export { bufferToString, isArrayBuffer, IsoBuffer, stringToBuffer, Uint8ArrayToString, } from "./bufferBrowser";
6
6
  export { gitHashFile, hashFile } from "./hashFileBrowser";
7
- export { performance } from "./performanceBrowser";
7
+ export { performance } from "./performanceIsomorphic";
8
8
  //# 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,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC"}
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,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC"}
@@ -14,6 +14,6 @@ Object.defineProperty(exports, "Uint8ArrayToString", { enumerable: true, get: fu
14
14
  var hashFileBrowser_1 = require("./hashFileBrowser");
15
15
  Object.defineProperty(exports, "gitHashFile", { enumerable: true, get: function () { return hashFileBrowser_1.gitHashFile; } });
16
16
  Object.defineProperty(exports, "hashFile", { enumerable: true, get: function () { return hashFileBrowser_1.hashFile; } });
17
- var performanceBrowser_1 = require("./performanceBrowser");
18
- Object.defineProperty(exports, "performance", { enumerable: true, get: function () { return performanceBrowser_1.performance; } });
17
+ var performanceIsomorphic_1 = require("./performanceIsomorphic");
18
+ Object.defineProperty(exports, "performance", { enumerable: true, get: function () { return performanceIsomorphic_1.performance; } });
19
19
  //# sourceMappingURL=indexBrowser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"indexBrowser.js","sourceRoot":"","sources":["../src/indexBrowser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iDAMyB;AALxB,+GAAA,cAAc,OAAA;AACd,8GAAA,aAAa,OAAA;AACb,0GAAA,SAAS,OAAA;AACT,+GAAA,cAAc,OAAA;AACd,mHAAA,kBAAkB,OAAA;AAEnB,qDAA0D;AAAjD,8GAAA,WAAW,OAAA;AAAE,2GAAA,QAAQ,OAAA;AAC9B,2DAAmD;AAA1C,iHAAA,WAAW,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tbufferToString,\n\tisArrayBuffer,\n\tIsoBuffer,\n\tstringToBuffer,\n\tUint8ArrayToString,\n} from \"./bufferBrowser\";\nexport { gitHashFile, hashFile } from \"./hashFileBrowser\";\nexport { performance } from \"./performanceBrowser\";\n"]}
1
+ {"version":3,"file":"indexBrowser.js","sourceRoot":"","sources":["../src/indexBrowser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iDAMyB;AALxB,+GAAA,cAAc,OAAA;AACd,8GAAA,aAAa,OAAA;AACb,0GAAA,SAAS,OAAA;AACT,+GAAA,cAAc,OAAA;AACd,mHAAA,kBAAkB,OAAA;AAEnB,qDAA0D;AAAjD,8GAAA,WAAW,OAAA;AAAE,2GAAA,QAAQ,OAAA;AAC9B,iEAAsD;AAA7C,oHAAA,WAAW,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tbufferToString,\n\tisArrayBuffer,\n\tIsoBuffer,\n\tstringToBuffer,\n\tUint8ArrayToString,\n} from \"./bufferBrowser\";\nexport { gitHashFile, hashFile } from \"./hashFileBrowser\";\nexport { performance } from \"./performanceIsomorphic\";\n"]}
@@ -4,5 +4,5 @@
4
4
  */
5
5
  export { Buffer, bufferToString, IsoBuffer, stringToBuffer, Uint8ArrayToString, } from "./bufferNode";
6
6
  export { gitHashFile, hashFile } from "./hashFileNode";
7
- export { performance } from "./performanceNode";
7
+ export { performance } from "./performanceIsomorphic";
8
8
  //# sourceMappingURL=indexNode.d.ts.map