@fluid-internal/client-utils 2.0.0-dev.6.4.0.192049 → 2.0.0-dev.7.2.0.204906

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 (71) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +4 -3
  3. package/api-extractor.json +1 -13
  4. package/api-report/client-utils.api.md +127 -0
  5. package/dist/base64Encoding.d.ts.map +1 -1
  6. package/dist/base64Encoding.js +6 -3
  7. package/dist/base64Encoding.js.map +1 -1
  8. package/dist/bufferBrowser.d.ts +3 -3
  9. package/dist/bufferBrowser.d.ts.map +1 -1
  10. package/dist/bufferBrowser.js +14 -3
  11. package/dist/bufferBrowser.js.map +1 -1
  12. package/dist/bufferNode.d.ts +7 -7
  13. package/dist/bufferNode.d.ts.map +1 -1
  14. package/dist/bufferNode.js +10 -5
  15. package/dist/bufferNode.js.map +1 -1
  16. package/dist/client-utils-alpha.d.ts +46 -0
  17. package/dist/client-utils-beta.d.ts +46 -0
  18. package/dist/client-utils-public.d.ts +46 -0
  19. package/dist/client-utils-untrimmed.d.ts +241 -0
  20. package/dist/eventForwarder.d.ts.map +1 -1
  21. package/dist/eventForwarder.js +10 -10
  22. package/dist/eventForwarder.js.map +1 -1
  23. package/dist/hashFileBrowser.js +5 -1
  24. package/dist/hashFileBrowser.js.map +1 -1
  25. package/dist/index.js +5 -1
  26. package/dist/index.js.map +1 -1
  27. package/dist/performanceIsomorphic.d.ts +1 -1
  28. package/dist/performanceIsomorphic.d.ts.map +1 -1
  29. package/dist/performanceNode.d.ts.map +1 -1
  30. package/dist/performanceNode.js +2 -1
  31. package/dist/performanceNode.js.map +1 -1
  32. package/dist/trace.js +4 -4
  33. package/dist/trace.js.map +1 -1
  34. package/dist/tsdoc-metadata.json +1 -1
  35. package/dist/typedEventEmitter.d.ts +2 -2
  36. package/dist/typedEventEmitter.d.ts.map +1 -1
  37. package/dist/typedEventEmitter.js +2 -0
  38. package/dist/typedEventEmitter.js.map +1 -1
  39. package/lib/base64Encoding.d.ts.map +1 -1
  40. package/lib/base64Encoding.js +6 -3
  41. package/lib/base64Encoding.js.map +1 -1
  42. package/lib/bufferBrowser.d.ts +3 -3
  43. package/lib/bufferBrowser.d.ts.map +1 -1
  44. package/lib/bufferBrowser.js +9 -2
  45. package/lib/bufferBrowser.js.map +1 -1
  46. package/lib/bufferNode.d.ts +7 -7
  47. package/lib/bufferNode.d.ts.map +1 -1
  48. package/lib/bufferNode.js +10 -5
  49. package/lib/bufferNode.js.map +1 -1
  50. package/lib/eventForwarder.d.ts.map +1 -1
  51. package/lib/eventForwarder.js +10 -10
  52. package/lib/eventForwarder.js.map +1 -1
  53. package/lib/performanceIsomorphic.d.ts +1 -1
  54. package/lib/performanceIsomorphic.d.ts.map +1 -1
  55. package/lib/performanceNode.d.ts.map +1 -1
  56. package/lib/performanceNode.js +2 -1
  57. package/lib/performanceNode.js.map +1 -1
  58. package/lib/trace.js +4 -4
  59. package/lib/trace.js.map +1 -1
  60. package/lib/typedEventEmitter.d.ts +2 -2
  61. package/lib/typedEventEmitter.d.ts.map +1 -1
  62. package/lib/typedEventEmitter.js +2 -0
  63. package/lib/typedEventEmitter.js.map +1 -1
  64. package/package.json +15 -17
  65. package/src/base64Encoding.ts +6 -3
  66. package/src/bufferBrowser.ts +14 -4
  67. package/src/bufferNode.ts +18 -9
  68. package/src/eventForwarder.ts +2 -0
  69. package/src/performanceNode.ts +2 -1
  70. package/src/typedEventEmitter.ts +2 -0
  71. package/tsconfig.json +1 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
1
  # @fluid-internal/client-utils
2
2
 
3
+ ## 2.0.0-internal.7.1.0
4
+
5
+ Dependency updates only.
6
+
7
+ ## 2.0.0-internal.7.0.0
8
+
9
+ ### Minor Changes
10
+
11
+ - client-utils: Internal buffer encoding helpers now require 'utf8', 'utf-8', or 'base64' [871b3493dd](https://github.com/microsoft/FluidFramework/commits/871b3493dd0d7ea3a89be64998ceb6cb9021a04e)
12
+
13
+ Previously, the buffer encoding helpers 'Uint8ArrayToString', 'bufferToString', and 'IsoBuffer.toString' would accept a string argument, which was overly permissive.
14
+
15
+ The type of the 'encoding' argument has been narrow to just the supported values 'utf8', 'utf-8', or 'base64'.
16
+
17
+ ## 2.0.0-internal.6.4.0
18
+
19
+ Dependency updates only.
20
+
3
21
  ## 2.0.0-internal.6.3.0
package/README.md CHANGED
@@ -42,9 +42,10 @@ When taking a dependency on a Fluid Framework library, we recommend using a `^`
42
42
  While Fluid Framework libraries may use different ranges with interdependencies between other Fluid Framework libraries,
43
43
  library consumers should always prefer `^`.
44
44
 
45
- Note that when depending on a library version of the form 2.0.0-internal.x.y.z, called the Fluid internal version
46
- scheme, you must use a `>= <` dependency range. Standard `^` and `~` ranges will not work as expected. See the
47
- [@fluid-tools/version-tools](https://github.com/microsoft/FluidFramework/blob/main/build-tools/packages/version-tools/README.md)
45
+ Note that when depending on a library version of the form `2.0.0-internal.x.y.z`, called the Fluid internal version scheme,
46
+ you must use a `>= <` dependency range (such as `>=2.0.0-internal.x.y.z <2.0.0-internal.w.0.0` where `w` is `x+1`).
47
+ Standard `^` and `~` ranges will not work as expected.
48
+ See the [@fluid-tools/version-tools](https://github.com/microsoft/FluidFramework/blob/main/build-tools/packages/version-tools/README.md)
48
49
  package for more information including tools to convert between version schemes.
49
50
 
50
51
  <!-- prettier-ignore-end -->
@@ -1,16 +1,4 @@
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-common-report.json",
4
- "messages": {
5
- "extractorMessageReporting": {
6
- "ae-missing-release-tag": {
7
- "logLevel": "error",
8
- "addToApiReportFile": false
9
- },
10
- "ae-incompatible-release-tags": {
11
- "logLevel": "error",
12
- "addToApiReportFile": false
13
- }
14
- }
15
- }
3
+ "extends": "@fluidframework/build-common/api-extractor-base.json"
16
4
  }
@@ -0,0 +1,127 @@
1
+ ## API Report File for "@fluid-internal/client-utils"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ import { EventEmitter } from 'events';
8
+ import { IDisposable } from '@fluidframework/core-interfaces';
9
+ import { IEvent } from '@fluidframework/core-interfaces';
10
+ import { IEventProvider } from '@fluidframework/core-interfaces';
11
+ import { IEventTransformer } from '@fluidframework/core-interfaces';
12
+ import { TransformedEvent } from '@fluidframework/core-interfaces';
13
+
14
+ // @internal
15
+ export class Buffer extends Uint8Array {
16
+ static from(value: unknown, encodingOrOffset?: unknown, length?: unknown): IsoBuffer;
17
+ // (undocumented)
18
+ static isBuffer(obj: unknown): obj is Buffer;
19
+ // (undocumented)
20
+ toString(encoding?: "utf8" | "utf-8" | "base64"): string;
21
+ }
22
+
23
+ // @internal
24
+ export const bufferToString: (blob: ArrayBufferLike, encoding: "utf8" | "utf-8" | "base64") => string;
25
+
26
+ // @internal
27
+ export type EventEmitterEventType = EventEmitter extends {
28
+ on(event: infer E, listener: any): any;
29
+ } ? E : never;
30
+
31
+ // @internal
32
+ export class EventForwarder<TEvent = IEvent> extends TypedEventEmitter<TEvent> implements IDisposable {
33
+ constructor(source?: EventEmitter | IEventProvider<TEvent & IEvent>);
34
+ // (undocumented)
35
+ dispose(): void;
36
+ // (undocumented)
37
+ get disposed(): boolean;
38
+ // (undocumented)
39
+ protected forwardEvent(source: EventEmitter | IEventProvider<TEvent & IEvent>, ...events: string[]): void;
40
+ // (undocumented)
41
+ protected static isEmitterEvent(event: string): boolean;
42
+ // (undocumented)
43
+ protected unforwardEvent(source: EventEmitter | IEventProvider<TEvent & IEvent>, ...events: string[]): void;
44
+ }
45
+
46
+ // @internal
47
+ export const fromBase64ToUtf8: (input: string) => string;
48
+
49
+ // @internal
50
+ export const fromUtf8ToBase64: (input: string) => string;
51
+
52
+ // @internal
53
+ export function gitHashFile(file: IsoBuffer): Promise<string>;
54
+
55
+ // @internal
56
+ export function hashFile(file: IsoBuffer, algorithm?: "SHA-1" | "SHA-256", hashEncoding?: "hex" | "base64"): Promise<string>;
57
+
58
+ // @internal (undocumented)
59
+ export const IsoBuffer: typeof Buffer;
60
+
61
+ // @internal (undocumented)
62
+ export type IsoBuffer = Buffer;
63
+
64
+ // @internal
65
+ export type IsomorphicPerformance = Partial<Performance> & Pick<Performance, "clearMarks" | "mark" | "measure" | "now">;
66
+
67
+ // @internal
68
+ export interface ITraceEvent {
69
+ readonly duration: number;
70
+ readonly tick: number;
71
+ readonly totalTimeElapsed: number;
72
+ }
73
+
74
+ // @internal (undocumented)
75
+ const performance_2: IsomorphicPerformance;
76
+ export { performance_2 as performance }
77
+
78
+ // @internal
79
+ export function stringToBuffer(input: string, encoding: string): ArrayBufferLike;
80
+
81
+ // @internal
82
+ export const toUtf8: (input: string, encoding: string) => string;
83
+
84
+ // @internal
85
+ export class Trace {
86
+ protected constructor(startTick: number);
87
+ // (undocumented)
88
+ protected lastTick: number;
89
+ // (undocumented)
90
+ static start(): Trace;
91
+ // (undocumented)
92
+ readonly startTick: number;
93
+ // (undocumented)
94
+ trace(): ITraceEvent;
95
+ }
96
+
97
+ // @internal
98
+ export class TypedEventEmitter<TEvent> extends EventEmitter implements IEventProvider<TEvent & IEvent> {
99
+ constructor();
100
+ // (undocumented)
101
+ readonly addListener: TypedEventTransform<this, TEvent>;
102
+ // (undocumented)
103
+ readonly off: TypedEventTransform<this, TEvent>;
104
+ // (undocumented)
105
+ readonly on: TypedEventTransform<this, TEvent>;
106
+ // (undocumented)
107
+ readonly once: TypedEventTransform<this, TEvent>;
108
+ // (undocumented)
109
+ readonly prependListener: TypedEventTransform<this, TEvent>;
110
+ // (undocumented)
111
+ readonly prependOnceListener: TypedEventTransform<this, TEvent>;
112
+ // (undocumented)
113
+ readonly removeListener: TypedEventTransform<this, TEvent>;
114
+ }
115
+
116
+ // @internal (undocumented)
117
+ export type TypedEventTransform<TThis, TEvent> = TransformedEvent<TThis, "newListener" | "removeListener", Parameters<(event: string, listener: (...args: any[]) => void) => void>> & IEventTransformer<TThis, TEvent & IEvent> & TransformedEvent<TThis, EventEmitterEventType, any[]>;
118
+
119
+ // @internal
120
+ export function Uint8ArrayToArrayBuffer(array: Uint8Array): ArrayBuffer;
121
+
122
+ // @internal
123
+ export function Uint8ArrayToString(arr: Uint8Array, encoding?: "utf8" | "utf-8" | "base64"): string;
124
+
125
+ // (No @packageDocumentation comment for this package)
126
+
127
+ ```
@@ -1 +1 @@
1
- {"version":3,"file":"base64Encoding.d.ts","sourceRoot":"","sources":["../src/base64Encoding.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,UAAW,MAAM,KAAG,MACC,CAAC;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,UAAW,MAAM,KAAG,MACA,CAAC;AAElD;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,UAAW,MAAM,YAAY,MAAM,KAAG,MAQxD,CAAC"}
1
+ {"version":3,"file":"base64Encoding.d.ts","sourceRoot":"","sources":["../src/base64Encoding.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,UAAW,MAAM,KAAG,MACA,CAAC;AAElD;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,UAAW,MAAM,KAAG,MACA,CAAC;AAElD;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,UAAW,MAAM,YAAY,MAAM,KAAG,MAWxD,CAAC"}
@@ -12,7 +12,7 @@ const indexNode_1 = require("./indexNode");
12
12
  *
13
13
  * @internal
14
14
  */
15
- const fromBase64ToUtf8 = (input) => indexNode_1.IsoBuffer.from(input, "base64").toString("utf-8");
15
+ const fromBase64ToUtf8 = (input) => indexNode_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
@@ -33,10 +33,13 @@ exports.fromUtf8ToBase64 = fromUtf8ToBase64;
33
33
  const toUtf8 = (input, encoding) => {
34
34
  switch (encoding) {
35
35
  case "utf8":
36
- case "utf-8":
36
+ // eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged
37
+ case "utf-8": {
37
38
  return input;
38
- default:
39
+ }
40
+ default: {
39
41
  return indexNode_1.IsoBuffer.from(input, encoding).toString();
42
+ }
40
43
  }
41
44
  };
42
45
  exports.toUtf8 = toUtf8;
@@ -1 +1 @@
1
- {"version":3,"file":"base64Encoding.js","sourceRoot":"","sources":["../src/base64Encoding.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2CAAwC;AAExC;;;;;GAKG;AACI,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAU,EAAE,CACzD,qBAAS,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AADtC,QAAA,gBAAgB,oBACsB;AAEnD;;;;;GAKG;AACI,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAU,EAAE,CACzD,qBAAS,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,KAAK,OAAO;YACX,OAAO,KAAK,CAAC;QACd;YACC,OAAO,qBAAS,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC;KACnD;AACF,CAAC,CAAC;AARW,QAAA,MAAM,UAQjB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IsoBuffer } from \"./indexNode\";\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(\"utf-8\");\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\tcase \"utf-8\":\n\t\t\treturn input;\n\t\tdefault:\n\t\t\treturn IsoBuffer.from(input, encoding).toString();\n\t}\n};\n"]}
1
+ {"version":3,"file":"base64Encoding.js","sourceRoot":"","sources":["../src/base64Encoding.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2CAAwC;AAExC;;;;;GAKG;AACI,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAU,EAAE,CACzD,qBAAS,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,qBAAS,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,qBAAS,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\";\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"]}
@@ -13,7 +13,7 @@
13
13
  *
14
14
  * @internal
15
15
  */
16
- export declare function Uint8ArrayToString(arr: Uint8Array, encoding?: string): string;
16
+ export declare function Uint8ArrayToString(arr: Uint8Array, encoding?: "utf8" | "utf-8" | "base64"): string;
17
17
  /**
18
18
  * Converts a {@link https://en.wikipedia.org/wiki/Base64 | base64} or
19
19
  * {@link https://en.wikipedia.org/wiki/UTF-8 | utf-8} string to array buffer.
@@ -32,7 +32,7 @@ export declare const stringToBuffer: (input: string, encoding: string) => ArrayB
32
32
  *
33
33
  * @internal
34
34
  */
35
- export declare const bufferToString: (blob: ArrayBufferLike, encoding: string) => string;
35
+ export declare const bufferToString: (blob: ArrayBufferLike, encoding: "utf8" | "utf-8" | "base64") => string;
36
36
  /**
37
37
  * Determines if an object is an array buffer.
38
38
  *
@@ -61,7 +61,7 @@ export declare class IsoBuffer extends Uint8Array {
61
61
  *
62
62
  * @param encoding - The encoding to use.
63
63
  */
64
- toString(encoding?: string): string;
64
+ toString(encoding?: "utf8" | "utf-8" | "base64"): string;
65
65
  /**
66
66
  * Static constructor
67
67
  * @param value - (string | ArrayBuffer)
@@ -1 +1 @@
1
- {"version":3,"file":"bufferBrowser.d.ts","sourceRoot":"","sources":["../src/bufferBrowser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAc7E;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,UAAW,MAAM,YAAY,MAAM,KAAG,eAC1B,CAAC;AAExC;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,SAAU,eAAe,YAAY,MAAM,KAAG,MACjC,CAAC;AAEzC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,WAAW,CAW9D;AAED;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,UAAU;IACxC;;;;;;OAMG;IACI,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM;IAI1C;;;;;;;OAOG;IAEH,MAAM,CAAC,IAAI,CAAC,KAAK,E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AAG,GAAG,SAAS;IAsBxE,MAAM,CAAC,eAAe,CACrB,WAAW,EAAE,WAAW,EACxB,UAAU,CAAC,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,MAAM,GACjB,SAAS;IAeZ,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS;IAoB5D,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO;IAItC;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;CAkB7B"}
@@ -5,7 +5,11 @@
5
5
  */
6
6
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
7
  if (k2 === undefined) k2 = k;
8
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
9
13
  }) : (function(o, m, k, k2) {
10
14
  if (k2 === undefined) k2 = k;
11
15
  o[k2] = m[k];
@@ -36,12 +40,15 @@ const base64js = __importStar(require("base64-js"));
36
40
  *
37
41
  * @internal
38
42
  */
39
- function Uint8ArrayToString(arr, encoding) {
43
+ function Uint8ArrayToString(arr,
44
+ // eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged
45
+ encoding) {
40
46
  switch (encoding) {
41
47
  case "base64": {
42
48
  return base64js.fromByteArray(arr);
43
49
  }
44
50
  case "utf8":
51
+ // eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged
45
52
  case "utf-8":
46
53
  case undefined: {
47
54
  return new TextDecoder().decode(arr);
@@ -71,7 +78,9 @@ exports.stringToBuffer = stringToBuffer;
71
78
  *
72
79
  * @internal
73
80
  */
74
- const bufferToString = (blob, encoding) => IsoBuffer.from(blob).toString(encoding);
81
+ const bufferToString = (blob,
82
+ // eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged
83
+ encoding) => IsoBuffer.from(blob).toString(encoding);
75
84
  exports.bufferToString = bufferToString;
76
85
  /**
77
86
  * Determines if an object is an array buffer.
@@ -111,6 +120,7 @@ class IsoBuffer extends Uint8Array {
111
120
  *
112
121
  * @param encoding - The encoding to use.
113
122
  */
123
+ // eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged
114
124
  toString(encoding) {
115
125
  return Uint8ArrayToString(this, encoding);
116
126
  }
@@ -162,6 +172,7 @@ class IsoBuffer extends Uint8Array {
162
172
  return new IsoBuffer(encoded.buffer);
163
173
  }
164
174
  case "utf8":
175
+ // eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged
165
176
  case "utf-8":
166
177
  case undefined: {
167
178
  const encoded = new TextEncoder().encode(str);
@@ -1 +1 @@
1
- {"version":3,"file":"bufferBrowser.js","sourceRoot":"","sources":["../src/bufferBrowser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,oDAAsC;AAEtC;;;;;;;;;;GAUG;AACH,SAAgB,kBAAkB,CAAC,GAAe,EAAE,QAAiB;IACpE,QAAQ,QAAQ,EAAE;QACjB,KAAK,QAAQ,CAAC,CAAC;YACd,OAAO,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;SACnC;QACD,KAAK,MAAM,CAAC;QACZ,KAAK,OAAO,CAAC;QACb,KAAK,SAAS,CAAC,CAAC;YACf,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;SACrC;QACD,OAAO,CAAC,CAAC;YACR,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SAChD;KACD;AACF,CAAC;AAdD,gDAcC;AAED;;;;;;;GAOG;AACI,MAAM,cAAc,GAAG,CAAC,KAAa,EAAE,QAAgB,EAAmB,E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WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBAC9C,OAAO,IAAI,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;aACrC;YACD,OAAO,CAAC,CAAC;gBACR,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;aAChD;SACD;IACF,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,GAAY;QAC3B,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACK,MAAM,CAAC,cAAc,CAAC,GAAW;QACxC,IAAI,YAAY,GAAG,GAAG,CAAC;QACvB,mEAAmE;QACnE,+CAA+C;QAC/C,YAAY,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAE1C,oEAAoE;QACpE,2CAA2C;QAC3C,YAAY,GAAG,YAAY,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QAErD,oEAAoE;QACpE,6BAA6B;QAC7B,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE;YAClC,MAAM,YAAY,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;YAC5C,YAAY,IAAI,YAAY,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;SACtD;QACD,OAAO,YAAY,CAAC;IACrB,CAAC;CACD;AA5GD,8BA4GC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as base64js from \"base64-js\";\n\n/**\n * Converts a Uint8Array to a string of the provided encoding\n * Useful when the array might be an {@link IsoBuffer}.\n *\n * @param arr - The array to convert.\n * @param encoding - Optional target encoding; only \"utf8\" and \"base64\" are\n * supported, with \"utf8\" being default.\n * @returns The converted string.\n *\n * @internal\n */\nexport function Uint8ArrayToString(arr: Uint8Array, encoding?: string): string {\n\tswitch (encoding) {\n\t\tcase \"base64\": {\n\t\t\treturn base64js.fromByteArray(arr);\n\t\t}\n\t\tcase \"utf8\":\n\t\tcase \"utf-8\":\n\t\tcase undefined: {\n\t\t\treturn new TextDecoder().decode(arr);\n\t\t}\n\t\tdefault: {\n\t\t\tthrow new Error(\"invalid/unsupported encoding\");\n\t\t}\n\t}\n}\n\n/**\n * Converts a {@link https://en.wikipedia.org/wiki/Base64 | base64} or\n * {@link https://en.wikipedia.org/wiki/UTF-8 | utf-8} string to array buffer.\n *\n * @param encoding - The input string's encoding.\n *\n * @internal\n */\nexport const stringToBuffer = (input: string, encoding: string): ArrayBufferLike =>\n\tIsoBuffer.from(input, encoding).buffer;\n\n/**\n * Convert binary blob to string format\n *\n * @param blob - the binary blob\n * @param encoding - output string's encoding\n * @returns the blob in string format\n *\n * @internal\n */\nexport const bufferToString = (blob: ArrayBufferLike, encoding: string): string =>\n\tIsoBuffer.from(blob).toString(encoding);\n\n/**\n * Determines if an object is an array buffer.\n *\n * @remarks Will detect and reject TypedArrays, like Uint8Array.\n * Reason - they can be viewport into Array, they can be accepted, but caller has to deal with\n * math properly (i.e. Take into account byteOffset at minimum).\n * For example, construction of new TypedArray can be in the form of new TypedArray(typedArray) or\n * new TypedArray(buffer, byteOffset, length), but passing TypedArray will result in fist path (and\n * ignoring byteOffice, length).\n *\n * @param obj - The object to determine if it is an ArrayBuffer.\n *\n * @internal\n */\nexport function isArrayBuffer(obj: unknown): obj is ArrayBuffer {\n\tconst maybe = obj as (Partial<ArrayBuffer> & Partial<Uint8Array>) | undefined;\n\treturn (\n\t\tobj instanceof ArrayBuffer ||\n\t\t(typeof maybe === \"object\" &&\n\t\t\tmaybe !== null &&\n\t\t\ttypeof maybe.byteLength === \"number\" &&\n\t\t\ttypeof maybe.slice === \"function\" &&\n\t\t\tmaybe.byteOffset === undefined &&\n\t\t\tmaybe.buffer === undefined)\n\t);\n}\n\n/**\n * Minimal implementation of Buffer for our usages in the browser environment.\n *\n * @internal\n */\nexport class IsoBuffer extends Uint8Array {\n\t/**\n\t * Convert the buffer to a string.\n\t * Only supports encoding the whole string (unlike the Node Buffer equivalent)\n\t * and only utf8 and base64 encodings.\n\t *\n\t * @param encoding - The encoding to use.\n\t */\n\tpublic toString(encoding?: string): string {\n\t\treturn Uint8ArrayToString(this, encoding);\n\t}\n\n\t/**\n\t * Static constructor\n\t * @param value - (string | ArrayBuffer)\n\t * @param encodingOrOffset - (string | number)\n\t * @param length - (number)\n\t *\n\t * @privateRemarks TODO: Use actual types\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any\n\tstatic from(value: any, encodingOrOffset?: any, length?: any): IsoBuffer {\n\t\tif (typeof value === \"string\") {\n\t\t\treturn IsoBuffer.fromString(value, encodingOrOffset as string | undefined);\n\t\t\t// Capture any typed arrays, including Uint8Array (and thus - IsoBuffer!)\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t} else if (value !== null && typeof value === \"object\" && isArrayBuffer(value.buffer)) {\n\t\t\t// The version of the from function for the node buffer, which takes a buffer or typed array\n\t\t\t// as first parameter, does not have any offset or length parameters. Those are just silently\n\t\t\t// ignored and not taken into account\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access\n\t\t\treturn IsoBuffer.fromArrayBuffer(value.buffer, value.byteOffset, value.byteLength);\n\t\t} else if (isArrayBuffer(value)) {\n\t\t\treturn IsoBuffer.fromArrayBuffer(\n\t\t\t\tvalue,\n\t\t\t\tencodingOrOffset as number | undefined,\n\t\t\t\tlength as number,\n\t\t\t);\n\t\t} else {\n\t\t\tthrow new TypeError(\"Input value was neither a string nor an ArrayBuffer.\");\n\t\t}\n\t}\n\n\tstatic fromArrayBuffer(\n\t\tarrayBuffer: ArrayBuffer,\n\t\tbyteOffset?: number,\n\t\tbyteLength?: number,\n\t): IsoBuffer {\n\t\tconst offset = byteOffset ?? 0;\n\t\tconst validLength = byteLength ?? arrayBuffer.byteLength - offset;\n\t\tif (\n\t\t\toffset < 0 ||\n\t\t\toffset > arrayBuffer.byteLength ||\n\t\t\tvalidLength < 0 ||\n\t\t\tvalidLength + offset > arrayBuffer.byteLength\n\t\t) {\n\t\t\tthrow new RangeError(\"Invalid range specified.\");\n\t\t}\n\n\t\treturn new IsoBuffer(arrayBuffer, offset, validLength);\n\t}\n\n\tstatic fromString(str: string, encoding?: string): IsoBuffer {\n\t\tswitch (encoding) {\n\t\t\tcase \"base64\": {\n\t\t\t\tconst sanitizedString = this.sanitizeBase64(str);\n\t\t\t\tconst encoded = base64js.toByteArray(sanitizedString);\n\t\t\t\treturn new IsoBuffer(encoded.buffer);\n\t\t\t}\n\t\t\tcase \"utf8\":\n\t\t\tcase \"utf-8\":\n\t\t\tcase undefined: {\n\t\t\t\tconst encoded = new TextEncoder().encode(str);\n\t\t\t\treturn new IsoBuffer(encoded.buffer);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(\"invalid/unsupported encoding\");\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic isBuffer(obj: unknown): boolean {\n\t\tthrow new Error(\"unimplemented\");\n\t}\n\n\t/**\n\t * Sanitize a base64 string to provide to base64-js library.\n\t * {@link https://www.npmjs.com/package/base64-js} is not as tolerant of the same malformed base64 as Node'\n\t * Buffer is.\n\t */\n\tprivate static sanitizeBase64(str: string): string {\n\t\tlet sanitizedStr = str;\n\t\t// Remove everything after padding - Node buffer ignores everything\n\t\t// after any padding whereas base64-js does not\n\t\tsanitizedStr = sanitizedStr.split(\"=\")[0];\n\n\t\t// Remove invalid characters - Node buffer strips invalid characters\n\t\t// whereas base64-js replaces them with \"A\"\n\t\tsanitizedStr = sanitizedStr.replace(/[^\\w+-/]/g, \"\");\n\n\t\t// Check for missing padding - Node buffer tolerates missing padding\n\t\t// whereas base64-js does not\n\t\tif (sanitizedStr.length % 4 !== 0) {\n\t\t\tconst paddingArray = [\"\", \"===\", \"==\", \"=\"];\n\t\t\tsanitizedStr += paddingArray[sanitizedStr.length % 4];\n\t\t}\n\t\treturn sanitizedStr;\n\t}\n}\n"]}
1
+ {"version":3,"file":"bufferBrowser.js","sourceRoot":"","sources":["../src/bufferBrowser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,oDAAsC;AAEtC;;;;;;;;;;GAUG;AACH,SAAgB,kBAAkB,CACjC,GAAe;AACf,8GAA8G;AAC9G,QAAsC;IAEtC,QAAQ,QAAQ,EAAE;QACjB,KAAK,QAAQ,CAAC,CAAC;YACd,OAAO,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;SACnC;QACD,KAAK,MAAM,CAAC;QACZ,8GAA8G;QAC9G,KAAK,OAAO,CAAC;QACb,KAAK,SAAS,CAAC,CAAC;YACf,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;SACrC;QACD,OAAO,CAAC,CAAC;YACR,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SAChD;KACD;AACF,CAAC;AAnBD,gDAmBC;AAED;;;;;;;GAOG;AACI,MAAM,cAAc,GAAG,CAAC,KAAa,EAAE,QAAgB,EAAmB,EAAE,CAClF,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,MAAM,CAAC;AAD3B,QAAA,cAAc,kBACa;AAExC;;;;;;;;GAQG;AACI,MAAM,cAAc,GAAG,CAC7B,IAAqB;AACrB,8GAA8G;AAC9G,QAAqC,EAC5B,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAJxC,QAAA,cAAc,kBAI0B;AAErD;;;;;;;;;;;;;GAaG;AACH,SAAgB,aAAa,CAAC,GAAY;IACzC,MAAM,KAAK,GAAG,GAA+D,CAAC;IAC9E,OAAO,CACN,GAAG,YAAY,WAAW;QAC1B,CAA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AAmE;QACnE,+CAA+C;QAC/C,YAAY,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAE1C,oEAAoE;QACpE,2CAA2C;QAC3C,YAAY,GAAG,YAAY,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QAErD,oEAAoE;QACpE,6BAA6B;QAC7B,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE;YAClC,MAAM,YAAY,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;YAC5C,YAAY,IAAI,YAAY,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;SACtD;QACD,OAAO,YAAY,CAAC;IACrB,CAAC;CACD;AA9GD,8BA8GC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as base64js from \"base64-js\";\n\n/**\n * Converts a Uint8Array to a string of the provided encoding\n * Useful when the array might be an {@link IsoBuffer}.\n *\n * @param arr - The array to convert.\n * @param encoding - Optional target encoding; only \"utf8\" and \"base64\" are\n * supported, with \"utf8\" being default.\n * @returns The converted string.\n *\n * @internal\n */\nexport function Uint8ArrayToString(\n\tarr: Uint8Array,\n\t// eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged\n\tencoding?: \"utf8\" | \"utf-8\" | \"base64\",\n): string {\n\tswitch (encoding) {\n\t\tcase \"base64\": {\n\t\t\treturn base64js.fromByteArray(arr);\n\t\t}\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\tcase undefined: {\n\t\t\treturn new TextDecoder().decode(arr);\n\t\t}\n\t\tdefault: {\n\t\t\tthrow new Error(\"invalid/unsupported encoding\");\n\t\t}\n\t}\n}\n\n/**\n * Converts a {@link https://en.wikipedia.org/wiki/Base64 | base64} or\n * {@link https://en.wikipedia.org/wiki/UTF-8 | utf-8} string to array buffer.\n *\n * @param encoding - The input string's encoding.\n *\n * @internal\n */\nexport const stringToBuffer = (input: string, encoding: string): ArrayBufferLike =>\n\tIsoBuffer.from(input, encoding).buffer;\n\n/**\n * Convert binary blob to string format\n *\n * @param blob - the binary blob\n * @param encoding - output string's encoding\n * @returns the blob in string format\n *\n * @internal\n */\nexport const bufferToString = (\n\tblob: ArrayBufferLike,\n\t// eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged\n\tencoding: \"utf8\" | \"utf-8\" | \"base64\",\n): string => IsoBuffer.from(blob).toString(encoding);\n\n/**\n * Determines if an object is an array buffer.\n *\n * @remarks Will detect and reject TypedArrays, like Uint8Array.\n * Reason - they can be viewport into Array, they can be accepted, but caller has to deal with\n * math properly (i.e. Take into account byteOffset at minimum).\n * For example, construction of new TypedArray can be in the form of new TypedArray(typedArray) or\n * new TypedArray(buffer, byteOffset, length), but passing TypedArray will result in fist path (and\n * ignoring byteOffice, length).\n *\n * @param obj - The object to determine if it is an ArrayBuffer.\n *\n * @internal\n */\nexport function isArrayBuffer(obj: unknown): obj is ArrayBuffer {\n\tconst maybe = obj as (Partial<ArrayBuffer> & Partial<Uint8Array>) | undefined;\n\treturn (\n\t\tobj instanceof ArrayBuffer ||\n\t\t(typeof maybe === \"object\" &&\n\t\t\tmaybe !== null &&\n\t\t\ttypeof maybe.byteLength === \"number\" &&\n\t\t\ttypeof maybe.slice === \"function\" &&\n\t\t\tmaybe.byteOffset === undefined &&\n\t\t\tmaybe.buffer === undefined)\n\t);\n}\n\n/**\n * Minimal implementation of Buffer for our usages in the browser environment.\n *\n * @internal\n */\nexport class IsoBuffer extends Uint8Array {\n\t/**\n\t * Convert the buffer to a string.\n\t * Only supports encoding the whole string (unlike the Node Buffer equivalent)\n\t * and only utf8 and base64 encodings.\n\t *\n\t * @param encoding - The encoding to use.\n\t */\n\t// eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged\n\tpublic toString(encoding?: \"utf8\" | \"utf-8\" | \"base64\"): string {\n\t\treturn Uint8ArrayToString(this, encoding);\n\t}\n\n\t/**\n\t * Static constructor\n\t * @param value - (string | ArrayBuffer)\n\t * @param encodingOrOffset - (string | number)\n\t * @param length - (number)\n\t *\n\t * @privateRemarks TODO: Use actual types\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any\n\tstatic from(value: any, encodingOrOffset?: any, length?: any): IsoBuffer {\n\t\tif (typeof value === \"string\") {\n\t\t\treturn IsoBuffer.fromString(value, encodingOrOffset as string | undefined);\n\t\t\t// Capture any typed arrays, including Uint8Array (and thus - IsoBuffer!)\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t} else if (value !== null && typeof value === \"object\" && isArrayBuffer(value.buffer)) {\n\t\t\t// The version of the from function for the node buffer, which takes a buffer or typed array\n\t\t\t// as first parameter, does not have any offset or length parameters. Those are just silently\n\t\t\t// ignored and not taken into account\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access\n\t\t\treturn IsoBuffer.fromArrayBuffer(value.buffer, value.byteOffset, value.byteLength);\n\t\t} else if (isArrayBuffer(value)) {\n\t\t\treturn IsoBuffer.fromArrayBuffer(\n\t\t\t\tvalue,\n\t\t\t\tencodingOrOffset as number | undefined,\n\t\t\t\tlength as number,\n\t\t\t);\n\t\t} else {\n\t\t\tthrow new TypeError(\"Input value was neither a string nor an ArrayBuffer.\");\n\t\t}\n\t}\n\n\tstatic fromArrayBuffer(\n\t\tarrayBuffer: ArrayBuffer,\n\t\tbyteOffset?: number,\n\t\tbyteLength?: number,\n\t): IsoBuffer {\n\t\tconst offset = byteOffset ?? 0;\n\t\tconst validLength = byteLength ?? arrayBuffer.byteLength - offset;\n\t\tif (\n\t\t\toffset < 0 ||\n\t\t\toffset > arrayBuffer.byteLength ||\n\t\t\tvalidLength < 0 ||\n\t\t\tvalidLength + offset > arrayBuffer.byteLength\n\t\t) {\n\t\t\tthrow new RangeError(\"Invalid range specified.\");\n\t\t}\n\n\t\treturn new IsoBuffer(arrayBuffer, offset, validLength);\n\t}\n\n\tstatic fromString(str: string, encoding?: string): IsoBuffer {\n\t\tswitch (encoding) {\n\t\t\tcase \"base64\": {\n\t\t\t\tconst sanitizedString = this.sanitizeBase64(str);\n\t\t\t\tconst encoded = base64js.toByteArray(sanitizedString);\n\t\t\t\treturn new IsoBuffer(encoded.buffer);\n\t\t\t}\n\t\t\tcase \"utf8\":\n\t\t\t// eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged\n\t\t\tcase \"utf-8\":\n\t\t\tcase undefined: {\n\t\t\t\tconst encoded = new TextEncoder().encode(str);\n\t\t\t\treturn new IsoBuffer(encoded.buffer);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(\"invalid/unsupported encoding\");\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic isBuffer(obj: unknown): boolean {\n\t\tthrow new Error(\"unimplemented\");\n\t}\n\n\t/**\n\t * Sanitize a base64 string to provide to base64-js library.\n\t * {@link https://www.npmjs.com/package/base64-js} is not as tolerant of the same malformed base64 as Node'\n\t * Buffer is.\n\t */\n\tprivate static sanitizeBase64(str: string): string {\n\t\tlet sanitizedStr = str;\n\t\t// Remove everything after padding - Node buffer ignores everything\n\t\t// after any padding whereas base64-js does not\n\t\tsanitizedStr = sanitizedStr.split(\"=\")[0];\n\n\t\t// Remove invalid characters - Node buffer strips invalid characters\n\t\t// whereas base64-js replaces them with \"A\"\n\t\tsanitizedStr = sanitizedStr.replace(/[^\\w+-/]/g, \"\");\n\n\t\t// Check for missing padding - Node buffer tolerates missing padding\n\t\t// whereas base64-js does not\n\t\tif (sanitizedStr.length % 4 !== 0) {\n\t\t\tconst paddingArray = [\"\", \"===\", \"==\", \"=\"];\n\t\t\tsanitizedStr += paddingArray[sanitizedStr.length % 4];\n\t\t}\n\t\treturn sanitizedStr;\n\t}\n}\n"]}
@@ -7,10 +7,10 @@
7
7
  * exposing the entirely of Node's typings. This should match the public interface
8
8
  * of the browser implementation, so any changes made in one should be made in both.
9
9
  *
10
- * @public
10
+ * @internal
11
11
  */
12
12
  export declare class Buffer extends Uint8Array {
13
- toString(encoding?: string): string;
13
+ toString(encoding?: "utf8" | "utf-8" | "base64"): string;
14
14
  /**
15
15
  * Static constructor
16
16
  *
@@ -24,13 +24,13 @@ export declare class Buffer extends Uint8Array {
24
24
  static isBuffer(obj: unknown): obj is Buffer;
25
25
  }
26
26
  /**
27
- * @public
27
+ * @internal
28
28
  */
29
29
  export declare const IsoBuffer: typeof Buffer;
30
30
  /**
31
- * @public
31
+ * @internal
32
32
  */
33
- export declare type IsoBuffer = Buffer;
33
+ export type IsoBuffer = Buffer;
34
34
  /**
35
35
  * Converts a Uint8Array to a string of the provided encoding.
36
36
  * @remarks Useful when the array might be an IsoBuffer.
@@ -41,7 +41,7 @@ export declare type IsoBuffer = Buffer;
41
41
  *
42
42
  * @internal
43
43
  */
44
- export declare function Uint8ArrayToString(arr: Uint8Array, encoding?: string): string;
44
+ export declare function Uint8ArrayToString(arr: Uint8Array, encoding?: "utf8" | "utf-8" | "base64"): string;
45
45
  /**
46
46
  * Convert base64 or utf8 string to array buffer.
47
47
  * @param encoding - The input string's encoding.
@@ -58,5 +58,5 @@ export declare function stringToBuffer(input: string, encoding: string): ArrayBu
58
58
  *
59
59
  * @internal
60
60
  */
61
- export declare const bufferToString: (blob: ArrayBufferLike, encoding: string) => string;
61
+ export declare const bufferToString: (blob: ArrayBufferLike, encoding: "utf8" | "utf-8" | "base64") => string;
62
62
  //# sourceMappingURL=bufferNode.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bufferNode.d.ts","sourceRoot":"","sources":["../src/bufferNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,OAA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GAEG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAE/B;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CACjC,GAAG,EAAE,UAAU,EAEf,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GACpC,MAAM,CAIR;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,eAAe,CAQ/E;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,SACpB,eAAe,YAEX,MAAM,GAAG,OAAO,GAAG,QAAQ,KACnC,MAAiD,CAAC"}
@@ -6,7 +6,7 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.bufferToString = exports.stringToBuffer = exports.Uint8ArrayToString = exports.IsoBuffer = void 0;
8
8
  /**
9
- * @public
9
+ * @internal
10
10
  */
11
11
  exports.IsoBuffer = Buffer;
12
12
  /**
@@ -19,9 +19,12 @@ exports.IsoBuffer = Buffer;
19
19
  *
20
20
  * @internal
21
21
  */
22
- function Uint8ArrayToString(arr, encoding) {
23
- // Make this check because Buffer.from(arr) will always do a buffer copy
24
- return Buffer.isBuffer(arr) ? arr.toString(encoding) : Buffer.from(arr).toString(encoding);
22
+ function Uint8ArrayToString(arr,
23
+ // eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged
24
+ encoding) {
25
+ // Buffer extends Uint8Array. Therefore, 'arr' may already be a Buffer, in
26
+ // which case we can avoid copying the Uint8Array into a new Buffer instance.
27
+ return (Buffer.isBuffer(arr) ? arr : Buffer.from(arr)).toString(encoding);
25
28
  }
26
29
  exports.Uint8ArrayToString = Uint8ArrayToString;
27
30
  /**
@@ -49,6 +52,8 @@ exports.stringToBuffer = stringToBuffer;
49
52
  *
50
53
  * @internal
51
54
  */
52
- const bufferToString = (blob, encoding) => exports.IsoBuffer.from(blob).toString(encoding);
55
+ const bufferToString = (blob,
56
+ // eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged
57
+ encoding) => exports.IsoBuffer.from(blob).toString(encoding);
53
58
  exports.bufferToString = bufferToString;
54
59
  //# sourceMappingURL=bufferNode.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bufferNode.js","sourceRoot":"","sources":["../src/bufferNode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAyBH;;GAEG;AACU,QAAA,SAAS,GAAG,MAAM,CAAC;AAOhC;;;;;;;;;GASG;AACH,SAAgB,kBAAkB,CAAC,GAAe,EAAE,QAAiB;IACpE,wEAAwE;IACxE,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC5F,CAAC;AAHD,gDAGC;AAED;;;;;GAKG;AACH,SAAgB,cAAc,CAAC,KAAa,EAAE,QAAgB;IAC7D,MAAM,GAAG,GAAG,iBAAS,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC5C,0EAA0E;IAC1E,2EAA2E;IAC3E,uDAAuD;IACvD,OAAO,GAAG,CAAC,UAAU,KAAK,GAAG,CAAC,MAAM,CAAC,UAAU;QAC9C,CAAC,CAAC,GAAG,CAAC,MAAM;QACZ,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC;AACtE,CAAC;AARD,wCAQC;AAED;;;;;;;;GAQG;AACI,MAAM,cAAc,GAAG,CAAC,IAAqB,EAAE,QAAgB,EAAU,EAAE,CACjF,iBAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAD5B,QAAA,cAAc,kBACc","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Declare the subset of Buffer functionality we want to make available instead of\n * exposing the entirely of Node's typings. This should match the public interface\n * of the browser implementation, so any changes made in one should be made in both.\n *\n * @public\n */\nexport declare class Buffer extends Uint8Array {\n\ttoString(encoding?: string): string;\n\n\t/**\n\t * Static constructor\n\t *\n\t * @param value - (string | ArrayBuffer).\n\t * @param encodingOrOffset - (string | number).\n\t * @param length - (number).\n\t *\n\t * @privateRemarks TODO: Use actual types\n\t */\n\tstatic from(value: unknown, encodingOrOffset?: unknown, length?: unknown): IsoBuffer;\n\tstatic isBuffer(obj: unknown): obj is Buffer;\n}\n\n/**\n * @public\n */\nexport const IsoBuffer = Buffer;\n\n/**\n * @public\n */\nexport type IsoBuffer = Buffer;\n\n/**\n * Converts a Uint8Array to a string of the provided encoding.\n * @remarks Useful when the array might be an IsoBuffer.\n * @param arr - The array to convert.\n * @param encoding - Optional target encoding; only \"utf8\" and \"base64\" are\n * supported, with \"utf8\" being default.\n * @returns The converted string.\n *\n * @internal\n */\nexport function Uint8ArrayToString(arr: Uint8Array, encoding?: string): string {\n\t// Make this check because Buffer.from(arr) will always do a buffer copy\n\treturn Buffer.isBuffer(arr) ? arr.toString(encoding) : Buffer.from(arr).toString(encoding);\n}\n\n/**\n * Convert base64 or utf8 string to array buffer.\n * @param encoding - The input string's encoding.\n *\n * @internal\n */\nexport function stringToBuffer(input: string, encoding: string): ArrayBufferLike {\n\tconst iso = IsoBuffer.from(input, encoding);\n\t// In a Node environment, IsoBuffer may be a Node.js Buffer. Node.js will\n\t// pool multiple small Buffer instances into a single ArrayBuffer, in which\n\t// case we need to slice the appropriate span of bytes.\n\treturn iso.byteLength === iso.buffer.byteLength\n\t\t? iso.buffer\n\t\t: iso.buffer.slice(iso.byteOffset, iso.byteOffset + iso.byteLength);\n}\n\n/**\n * Convert binary blob to string format\n *\n * @param blob - The binary blob\n * @param encoding - Output string's encoding\n * @returns The blob in string format\n *\n * @internal\n */\nexport const bufferToString = (blob: ArrayBufferLike, encoding: string): string =>\n\tIsoBuffer.from(blob).toString(encoding);\n"]}
1
+ {"version":3,"file":"bufferNode.js","sourceRoot":"","sources":["../src/bufferNode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA0BH;;GAEG;AACU,QAAA,SAAS,GAAG,MAAM,CAAC;AAOhC;;;;;;;;;GASG;AACH,SAAgB,kBAAkB,CACjC,GAAe;AACf,8GAA8G;AAC9G,QAAsC;IAEtC,2EAA2E;IAC3E,6EAA6E;IAC7E,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC3E,CAAC;AARD,gDAQC;AAED;;;;;GAKG;AACH,SAAgB,cAAc,CAAC,KAAa,EAAE,QAAgB;IAC7D,MAAM,GAAG,GAAG,iBAAS,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC5C,0EAA0E;IAC1E,2EAA2E;IAC3E,uDAAuD;IACvD,OAAO,GAAG,CAAC,UAAU,KAAK,GAAG,CAAC,MAAM,CAAC,UAAU;QAC9C,CAAC,CAAC,GAAG,CAAC,MAAM;QACZ,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC;AACtE,CAAC;AARD,wCAQC;AAED;;;;;;;;GAQG;AACI,MAAM,cAAc,GAAG,CAC7B,IAAqB;AACrB,8GAA8G;AAC9G,QAAqC,EAC5B,EAAE,CAAC,iBAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAJxC,QAAA,cAAc,kBAI0B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Declare the subset of Buffer functionality we want to make available instead of\n * exposing the entirely of Node's typings. This should match the public interface\n * of the browser implementation, so any changes made in one should be made in both.\n *\n * @internal\n */\nexport declare class Buffer extends Uint8Array {\n\t// eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged\n\ttoString(encoding?: \"utf8\" | \"utf-8\" | \"base64\"): string;\n\n\t/**\n\t * Static constructor\n\t *\n\t * @param value - (string | ArrayBuffer).\n\t * @param encodingOrOffset - (string | number).\n\t * @param length - (number).\n\t *\n\t * @privateRemarks TODO: Use actual types\n\t */\n\tstatic from(value: unknown, encodingOrOffset?: unknown, length?: unknown): IsoBuffer;\n\tstatic isBuffer(obj: unknown): obj is Buffer;\n}\n\n/**\n * @internal\n */\nexport const IsoBuffer = Buffer;\n\n/**\n * @internal\n */\nexport type IsoBuffer = Buffer;\n\n/**\n * Converts a Uint8Array to a string of the provided encoding.\n * @remarks Useful when the array might be an IsoBuffer.\n * @param arr - The array to convert.\n * @param encoding - Optional target encoding; only \"utf8\" and \"base64\" are\n * supported, with \"utf8\" being default.\n * @returns The converted string.\n *\n * @internal\n */\nexport function Uint8ArrayToString(\n\tarr: Uint8Array,\n\t// eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged\n\tencoding?: \"utf8\" | \"utf-8\" | \"base64\",\n): string {\n\t// Buffer extends Uint8Array. Therefore, 'arr' may already be a Buffer, in\n\t// which case we can avoid copying the Uint8Array into a new Buffer instance.\n\treturn (Buffer.isBuffer(arr) ? arr : Buffer.from(arr)).toString(encoding);\n}\n\n/**\n * Convert base64 or utf8 string to array buffer.\n * @param encoding - The input string's encoding.\n *\n * @internal\n */\nexport function stringToBuffer(input: string, encoding: string): ArrayBufferLike {\n\tconst iso = IsoBuffer.from(input, encoding);\n\t// In a Node environment, IsoBuffer may be a Node.js Buffer. Node.js will\n\t// pool multiple small Buffer instances into a single ArrayBuffer, in which\n\t// case we need to slice the appropriate span of bytes.\n\treturn iso.byteLength === iso.buffer.byteLength\n\t\t? iso.buffer\n\t\t: iso.buffer.slice(iso.byteOffset, iso.byteOffset + iso.byteLength);\n}\n\n/**\n * Convert binary blob to string format\n *\n * @param blob - The binary blob\n * @param encoding - Output string's encoding\n * @returns The blob in string format\n *\n * @internal\n */\nexport const bufferToString = (\n\tblob: ArrayBufferLike,\n\t// eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged\n\tencoding: \"utf8\" | \"utf-8\" | \"base64\",\n): string => IsoBuffer.from(blob).toString(encoding);\n"]}
@@ -0,0 +1,46 @@
1
+ import { EventEmitter } from 'events';
2
+ import { IDisposable } from '@fluidframework/core-interfaces';
3
+ import { IEvent } from '@fluidframework/core-interfaces';
4
+ import { IEventProvider } from '@fluidframework/core-interfaces';
5
+ import { IEventTransformer } from '@fluidframework/core-interfaces';
6
+ import { TransformedEvent } from '@fluidframework/core-interfaces';
7
+
8
+ /* Excluded from this release type: Buffer */
9
+
10
+ /* Excluded from this release type: bufferToString */
11
+
12
+ /* Excluded from this release type: EventEmitterEventType */
13
+
14
+ /* Excluded from this release type: EventForwarder */
15
+
16
+ /* Excluded from this release type: fromBase64ToUtf8 */
17
+
18
+ /* Excluded from this release type: fromUtf8ToBase64 */
19
+
20
+ /* Excluded from this release type: gitHashFile */
21
+
22
+ /* Excluded from this release type: hashFile */
23
+
24
+ /* Excluded from this release type: IsoBuffer */
25
+
26
+ /* Excluded from this release type: IsomorphicPerformance */
27
+
28
+ /* Excluded from this release type: ITraceEvent */
29
+
30
+ /* Excluded from this release type: performance_2 */
31
+
32
+ /* Excluded from this release type: stringToBuffer */
33
+
34
+ /* Excluded from this release type: toUtf8 */
35
+
36
+ /* Excluded from this release type: Trace */
37
+
38
+ /* Excluded from this release type: TypedEventEmitter */
39
+
40
+ /* Excluded from this release type: TypedEventTransform */
41
+
42
+ /* Excluded from this release type: Uint8ArrayToArrayBuffer */
43
+
44
+ /* Excluded from this release type: Uint8ArrayToString */
45
+
46
+ export { }
@@ -0,0 +1,46 @@
1
+ import { EventEmitter } from 'events';
2
+ import { IDisposable } from '@fluidframework/core-interfaces';
3
+ import { IEvent } from '@fluidframework/core-interfaces';
4
+ import { IEventProvider } from '@fluidframework/core-interfaces';
5
+ import { IEventTransformer } from '@fluidframework/core-interfaces';
6
+ import { TransformedEvent } from '@fluidframework/core-interfaces';
7
+
8
+ /* Excluded from this release type: Buffer */
9
+
10
+ /* Excluded from this release type: bufferToString */
11
+
12
+ /* Excluded from this release type: EventEmitterEventType */
13
+
14
+ /* Excluded from this release type: EventForwarder */
15
+
16
+ /* Excluded from this release type: fromBase64ToUtf8 */
17
+
18
+ /* Excluded from this release type: fromUtf8ToBase64 */
19
+
20
+ /* Excluded from this release type: gitHashFile */
21
+
22
+ /* Excluded from this release type: hashFile */
23
+
24
+ /* Excluded from this release type: IsoBuffer */
25
+
26
+ /* Excluded from this release type: IsomorphicPerformance */
27
+
28
+ /* Excluded from this release type: ITraceEvent */
29
+
30
+ /* Excluded from this release type: performance_2 */
31
+
32
+ /* Excluded from this release type: stringToBuffer */
33
+
34
+ /* Excluded from this release type: toUtf8 */
35
+
36
+ /* Excluded from this release type: Trace */
37
+
38
+ /* Excluded from this release type: TypedEventEmitter */
39
+
40
+ /* Excluded from this release type: TypedEventTransform */
41
+
42
+ /* Excluded from this release type: Uint8ArrayToArrayBuffer */
43
+
44
+ /* Excluded from this release type: Uint8ArrayToString */
45
+
46
+ export { }
@@ -0,0 +1,46 @@
1
+ import { EventEmitter } from 'events';
2
+ import { IDisposable } from '@fluidframework/core-interfaces';
3
+ import { IEvent } from '@fluidframework/core-interfaces';
4
+ import { IEventProvider } from '@fluidframework/core-interfaces';
5
+ import { IEventTransformer } from '@fluidframework/core-interfaces';
6
+ import { TransformedEvent } from '@fluidframework/core-interfaces';
7
+
8
+ /* Excluded from this release type: Buffer */
9
+
10
+ /* Excluded from this release type: bufferToString */
11
+
12
+ /* Excluded from this release type: EventEmitterEventType */
13
+
14
+ /* Excluded from this release type: EventForwarder */
15
+
16
+ /* Excluded from this release type: fromBase64ToUtf8 */
17
+
18
+ /* Excluded from this release type: fromUtf8ToBase64 */
19
+
20
+ /* Excluded from this release type: gitHashFile */
21
+
22
+ /* Excluded from this release type: hashFile */
23
+
24
+ /* Excluded from this release type: IsoBuffer */
25
+
26
+ /* Excluded from this release type: IsomorphicPerformance */
27
+
28
+ /* Excluded from this release type: ITraceEvent */
29
+
30
+ /* Excluded from this release type: performance_2 */
31
+
32
+ /* Excluded from this release type: stringToBuffer */
33
+
34
+ /* Excluded from this release type: toUtf8 */
35
+
36
+ /* Excluded from this release type: Trace */
37
+
38
+ /* Excluded from this release type: TypedEventEmitter */
39
+
40
+ /* Excluded from this release type: TypedEventTransform */
41
+
42
+ /* Excluded from this release type: Uint8ArrayToArrayBuffer */
43
+
44
+ /* Excluded from this release type: Uint8ArrayToString */
45
+
46
+ export { }