@fluid-internal/client-utils 2.0.0-internal.7.4.0 → 2.0.0-internal.7.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/dist/{base64Encoding.js → base64Encoding.cjs} +2 -2
  2. package/dist/base64Encoding.cjs.map +1 -0
  3. package/{lib/bufferBrowser.js → dist/bufferBrowser.cjs} +1 -1
  4. package/dist/bufferBrowser.cjs.map +1 -0
  5. package/dist/{bufferNode.js → bufferNode.cjs} +1 -1
  6. package/dist/bufferNode.cjs.map +1 -0
  7. package/dist/{bufferShared.js → bufferShared.cjs} +1 -1
  8. package/dist/bufferShared.cjs.map +1 -0
  9. package/{lib/eventForwarder.js → dist/eventForwarder.cjs} +2 -2
  10. package/dist/eventForwarder.cjs.map +1 -0
  11. package/{lib/hashFileBrowser.js → dist/hashFileBrowser.cjs} +3 -5
  12. package/dist/hashFileBrowser.cjs.map +1 -0
  13. package/{lib/hashFileNode.js → dist/hashFileNode.cjs} +1 -1
  14. package/dist/hashFileNode.cjs.map +1 -0
  15. package/dist/{index.js → index.cjs} +7 -7
  16. package/dist/index.cjs.map +1 -0
  17. package/{lib/indexBrowser.js → dist/indexBrowser.cjs} +4 -4
  18. package/dist/indexBrowser.cjs.map +1 -0
  19. package/dist/{indexNode.js → indexNode.cjs} +4 -4
  20. package/dist/indexNode.cjs.map +1 -0
  21. package/{lib/performanceIsomorphic.js → dist/performanceIsomorphic.cjs} +1 -1
  22. package/dist/performanceIsomorphic.cjs.map +1 -0
  23. package/{lib/trace.js → dist/trace.cjs} +2 -2
  24. package/dist/trace.cjs.map +1 -0
  25. package/dist/{typedEventEmitter.js → typedEventEmitter.cjs} +1 -1
  26. package/dist/typedEventEmitter.cjs.map +1 -0
  27. package/jest.config.js +1 -1
  28. package/lib/{base64Encoding.js → base64Encoding.mjs} +6 -12
  29. package/lib/base64Encoding.mjs.map +1 -0
  30. package/{dist/bufferBrowser.js → lib/bufferBrowser.mjs} +7 -38
  31. package/lib/bufferBrowser.mjs.map +1 -0
  32. package/lib/{bufferNode.js → bufferNode.mjs} +7 -13
  33. package/lib/bufferNode.mjs.map +1 -0
  34. package/lib/{bufferShared.js → bufferShared.mjs} +2 -6
  35. package/lib/bufferShared.mjs.map +1 -0
  36. package/lib/{eventForwarder.d.ts → eventForwarder.d.mts} +1 -1
  37. package/lib/eventForwarder.d.mts.map +1 -0
  38. package/{dist/eventForwarder.js → lib/eventForwarder.mjs} +3 -7
  39. package/{dist/eventForwarder.js.map → lib/eventForwarder.mjs.map} +1 -1
  40. package/lib/{hashFileNode.d.ts → hashFileBrowser.d.mts} +2 -2
  41. package/lib/hashFileBrowser.d.mts.map +1 -0
  42. package/{dist/hashFileBrowser.js → lib/hashFileBrowser.mjs} +7 -37
  43. package/lib/hashFileBrowser.mjs.map +1 -0
  44. package/lib/{hashFileBrowser.d.ts → hashFileNode.d.mts} +2 -2
  45. package/lib/hashFileNode.d.mts.map +1 -0
  46. package/{dist/hashFileNode.js → lib/hashFileNode.mjs} +7 -12
  47. package/lib/hashFileNode.mjs.map +1 -0
  48. package/lib/index.d.mts +12 -0
  49. package/lib/index.d.mts.map +1 -0
  50. package/lib/index.mjs +11 -0
  51. package/lib/index.mjs.map +1 -0
  52. package/lib/indexBrowser.d.mts +8 -0
  53. package/lib/indexBrowser.d.mts.map +1 -0
  54. package/lib/indexBrowser.mjs +8 -0
  55. package/lib/indexBrowser.mjs.map +1 -0
  56. package/lib/indexNode.d.mts +8 -0
  57. package/lib/indexNode.d.mts.map +1 -0
  58. package/lib/indexNode.mjs +8 -0
  59. package/lib/indexNode.mjs.map +1 -0
  60. package/{dist/performanceIsomorphic.js → lib/performanceIsomorphic.mjs} +2 -5
  61. package/lib/performanceIsomorphic.mjs.map +1 -0
  62. package/{dist/trace.js → lib/trace.mjs} +5 -9
  63. package/lib/trace.mjs.map +1 -0
  64. package/lib/typedEventEmitter.d.mts.map +1 -0
  65. package/lib/{typedEventEmitter.js → typedEventEmitter.mjs} +3 -9
  66. package/lib/typedEventEmitter.mjs.map +1 -0
  67. package/package.json +17 -32
  68. package/tsc-multi.test.json +4 -0
  69. package/dist/base64Encoding.js.map +0 -1
  70. package/dist/bufferBrowser.js.map +0 -1
  71. package/dist/bufferNode.js.map +0 -1
  72. package/dist/bufferShared.js.map +0 -1
  73. package/dist/hashFileBrowser.js.map +0 -1
  74. package/dist/hashFileNode.js.map +0 -1
  75. package/dist/index.js.map +0 -1
  76. package/dist/indexBrowser.js +0 -19
  77. package/dist/indexBrowser.js.map +0 -1
  78. package/dist/indexNode.js.map +0 -1
  79. package/dist/performanceIsomorphic.js.map +0 -1
  80. package/dist/trace.js.map +0 -1
  81. package/dist/typedEventEmitter.js.map +0 -1
  82. package/lib/base64Encoding.js.map +0 -1
  83. package/lib/bufferBrowser.js.map +0 -1
  84. package/lib/bufferNode.js.map +0 -1
  85. package/lib/bufferShared.js.map +0 -1
  86. package/lib/eventForwarder.d.ts.map +0 -1
  87. package/lib/eventForwarder.js.map +0 -1
  88. package/lib/hashFileBrowser.d.ts.map +0 -1
  89. package/lib/hashFileBrowser.js.map +0 -1
  90. package/lib/hashFileNode.d.ts.map +0 -1
  91. package/lib/hashFileNode.js.map +0 -1
  92. package/lib/index.d.ts +0 -20
  93. package/lib/index.d.ts.map +0 -1
  94. package/lib/index.js +0 -45
  95. package/lib/index.js.map +0 -1
  96. package/lib/indexBrowser.d.ts +0 -8
  97. package/lib/indexBrowser.d.ts.map +0 -1
  98. package/lib/indexBrowser.js.map +0 -1
  99. package/lib/indexNode.d.ts +0 -8
  100. package/lib/indexNode.d.ts.map +0 -1
  101. package/lib/indexNode.js +0 -19
  102. package/lib/indexNode.js.map +0 -1
  103. package/lib/performanceIsomorphic.js.map +0 -1
  104. package/lib/trace.js.map +0 -1
  105. package/lib/typedEventEmitter.d.ts.map +0 -1
  106. package/lib/typedEventEmitter.js.map +0 -1
  107. package/tsconfig.esnext.json +0 -6
  108. /package/lib/{base64Encoding.d.ts → base64Encoding.d.mts} +0 -0
  109. /package/lib/{base64Encoding.d.ts.map → base64Encoding.d.mts.map} +0 -0
  110. /package/lib/{bufferBrowser.d.ts → bufferBrowser.d.mts} +0 -0
  111. /package/lib/{bufferBrowser.d.ts.map → bufferBrowser.d.mts.map} +0 -0
  112. /package/lib/{bufferNode.d.ts → bufferNode.d.mts} +0 -0
  113. /package/lib/{bufferNode.d.ts.map → bufferNode.d.mts.map} +0 -0
  114. /package/lib/{bufferShared.d.ts → bufferShared.d.mts} +0 -0
  115. /package/lib/{bufferShared.d.ts.map → bufferShared.d.mts.map} +0 -0
  116. /package/lib/{client-utils-alpha.d.ts → client-utils-alpha.d.mts} +0 -0
  117. /package/lib/{client-utils-beta.d.ts → client-utils-beta.d.mts} +0 -0
  118. /package/lib/{client-utils-public.d.ts → client-utils-public.d.mts} +0 -0
  119. /package/lib/{client-utils-untrimmed.d.ts → client-utils-untrimmed.d.mts} +0 -0
  120. /package/lib/{performanceIsomorphic.d.ts → performanceIsomorphic.d.mts} +0 -0
  121. /package/lib/{performanceIsomorphic.d.ts.map → performanceIsomorphic.d.mts.map} +0 -0
  122. /package/lib/{trace.d.ts → trace.d.mts} +0 -0
  123. /package/lib/{trace.d.ts.map → trace.d.mts.map} +0 -0
  124. /package/lib/{typedEventEmitter.d.ts → typedEventEmitter.d.mts} +0 -0
@@ -5,7 +5,7 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.toUtf8 = exports.fromUtf8ToBase64 = exports.fromBase64ToUtf8 = void 0;
8
- const indexNode_1 = require("./indexNode");
8
+ const indexNode_1 = require("./indexNode.cjs");
9
9
  /**
10
10
  * Converts the provided {@link https://en.wikipedia.org/wiki/Base64 | base64}-encoded string
11
11
  * to {@link https://en.wikipedia.org/wiki/UTF-8 | utf-8}.
@@ -43,4 +43,4 @@ const toUtf8 = (input, encoding) => {
43
43
  }
44
44
  };
45
45
  exports.toUtf8 = toUtf8;
46
- //# sourceMappingURL=base64Encoding.js.map
46
+ //# sourceMappingURL=base64Encoding.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base64Encoding.cjs","sourceRoot":"","sources":["../src/base64Encoding.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+CAAwC;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"]}
@@ -209,4 +209,4 @@ class IsoBuffer extends Uint8Array {
209
209
  }
210
210
  }
211
211
  exports.IsoBuffer = IsoBuffer;
212
- //# sourceMappingURL=bufferBrowser.js.map
212
+ //# sourceMappingURL=bufferBrowser.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bufferBrowser.cjs","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,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BACtD,OAAO,IAAI,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;aACrC;YACD,KAAK,MAAM,CAAC;YACZ,8GAA8G;YAC9G,KAAK,OAAO,CAAC;YACb,KAAK,SAAS,CAAC,CAAC;gBACf,MAAM,OAAO,GAAG,IAAI,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;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"]}
@@ -56,4 +56,4 @@ const bufferToString = (blob,
56
56
  // eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged
57
57
  encoding) => exports.IsoBuffer.from(blob).toString(encoding);
58
58
  exports.bufferToString = bufferToString;
59
- //# sourceMappingURL=bufferNode.js.map
59
+ //# sourceMappingURL=bufferNode.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bufferNode.cjs","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"]}
@@ -18,4 +18,4 @@ function Uint8ArrayToArrayBuffer(array) {
18
18
  return array.buffer.slice(array.byteOffset, array.byteOffset + array.byteLength);
19
19
  }
20
20
  exports.Uint8ArrayToArrayBuffer = Uint8ArrayToArrayBuffer;
21
- //# sourceMappingURL=bufferShared.js.map
21
+ //# sourceMappingURL=bufferShared.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bufferShared.cjs","sourceRoot":"","sources":["../src/bufferShared.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;;GAKG;AACH,SAAgB,uBAAuB,CAAC,KAAiB;IACxD,IAAI,KAAK,CAAC,UAAU,KAAK,CAAC,IAAI,KAAK,CAAC,UAAU,KAAK,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE;QAC3E,OAAO,KAAK,CAAC,MAAM,CAAC;KACpB;IACD,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;AAClF,CAAC;AALD,0DAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Converts a Uint8Array array to an ArrayBuffer.\n * @param array - Array to convert to ArrayBuffer.\n *\n * @internal\n */\nexport function Uint8ArrayToArrayBuffer(array: Uint8Array): ArrayBuffer {\n\tif (array.byteOffset === 0 && array.byteLength === array.buffer.byteLength) {\n\t\treturn array.buffer;\n\t}\n\treturn array.buffer.slice(array.byteOffset, array.byteOffset + array.byteLength);\n}\n"]}
@@ -5,7 +5,7 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.EventForwarder = void 0;
8
- const typedEventEmitter_1 = require("./typedEventEmitter");
8
+ const typedEventEmitter_1 = require("./typedEventEmitter.cjs");
9
9
  /**
10
10
  * Base class used for forwarding events from a source EventEmitter.
11
11
  * This can be useful when all arbitrary listeners need to be removed,
@@ -95,4 +95,4 @@ class EventForwarder extends typedEventEmitter_1.TypedEventEmitter {
95
95
  exports.EventForwarder = EventForwarder;
96
96
  EventForwarder.newListenerEvent = "newListener";
97
97
  EventForwarder.removeListenerEvent = "removeListener";
98
- //# sourceMappingURL=eventForwarder.js.map
98
+ //# sourceMappingURL=eventForwarder.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eventForwarder.cjs","sourceRoot":"","sources":["../src/eventForwarder.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH,+DAAwD;AAExD;;;;;;GAMG;AACH,MAAa,cACZ,SAAQ,qCAAyB;IAGvB,MAAM,CAAC,cAAc,CAAC,KAAa;QAC5C,OAAO,CACN,KAAK,KAAK,cAAc,CAAC,gBAAgB;YACzC,KAAK,KAAK,cAAc,CAAC,mBAAmB,CAC5C,CAAC;IACH,CAAC;IAKD;;OAEG;IACH,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IAQD,YAAY,MAAuD;QAClE,KAAK,EAAE,CAAC;QARD,eAAU,GAAY,KAAK,CAAC;QAEnB,qBAAgB,GAAG,IAAI,GAAG,EAGxC,CAAC;QAIH,IAAI,MAAM,KAAK,SAAS,EAAE;YACzB,mFAAmF;YACnF,kFAAkF;YAClF,8CAA8C;YAC9C,MAAM,qBAAqB,GAAG,CAAC,KAAa,EAAQ,EAAE,CACrD,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;YACpC,MAAM,kBAAkB,GAAG,CAAC,KAAa,EAAQ,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;YACrF,IAAI,CAAC,EAAE,CAAC,cAAc,CAAC,mBAAmB,EAAE,qBAAqB,CAAC,CAAC;YACnE,IAAI,CAAC,EAAE,CAAC,cAAc,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;SAC7D;IACF,CAAC;IAED;;OAEG;IACI,OAAO;QACb,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,KA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AK,IAAI,MAAM,EAAE;YAC3B,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE;gBACjE,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBACjD,IAAI,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,IAAI,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;oBACrE,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;oBAC5C,IAAI,eAAe,KAAK,SAAS,EAAE;wBAClC,eAAe,EAAE,CAAC;qBAClB;oBACD,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;oBACvB,IAAI,OAAO,CAAC,IAAI,KAAK,CAAC,EAAE;wBACvB,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;qBACpC;iBACD;aACD;SACD;IACF,CAAC;;AAtGF,wCAuGC;AA5FwB,+BAAgB,GAAG,aAAa,AAAhB,CAAiB;AACjC,kCAAmB,GAAG,gBAAgB,AAAnB,CAAoB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// False positive: this is an import from the `events` package, not from Node.\n// eslint-disable-next-line unicorn/prefer-node-protocol\nimport { EventEmitter } from \"events\";\nimport { IDisposable, IEvent, IEventProvider } from \"@fluidframework/core-interfaces\";\nimport { TypedEventEmitter } from \"./typedEventEmitter\";\n\n/**\n * Base class used for forwarding events from a source EventEmitter.\n * This can be useful when all arbitrary listeners need to be removed,\n * but the primary source needs to stay intact.\n *\n * @internal\n */\nexport class EventForwarder<TEvent = IEvent>\n\textends TypedEventEmitter<TEvent>\n\timplements IDisposable\n{\n\tprotected static isEmitterEvent(event: string): boolean {\n\t\treturn (\n\t\t\tevent === EventForwarder.newListenerEvent ||\n\t\t\tevent === EventForwarder.removeListenerEvent\n\t\t);\n\t}\n\n\tprivate static readonly newListenerEvent = \"newListener\";\n\tprivate static readonly removeListenerEvent = \"removeListener\";\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#IDisposable.disposed}\n\t */\n\tpublic get disposed(): boolean {\n\t\treturn this.isDisposed;\n\t}\n\tprivate isDisposed: boolean = false;\n\n\tprivate readonly forwardingEvents = new Map<\n\t\tstring,\n\t\tMap<EventEmitter | IEventProvider<TEvent & IEvent>, () => void>\n\t>();\n\n\tconstructor(source?: EventEmitter | IEventProvider<TEvent & IEvent>) {\n\t\tsuper();\n\t\tif (source !== undefined) {\n\t\t\t// NewListener event is raised whenever someone starts listening to this events, so\n\t\t\t// we keep track of events being listened to, and start forwarding from the source\n\t\t\t// event emitter per event listened to on this\n\t\t\tconst removeListenerHandler = (event: string): void =>\n\t\t\t\tthis.unforwardEvent(source, event);\n\t\t\tconst newListenerHandler = (event: string): void => this.forwardEvent(source, event);\n\t\t\tthis.on(EventForwarder.removeListenerEvent, removeListenerHandler);\n\t\t\tthis.on(EventForwarder.newListenerEvent, newListenerHandler);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#IDisposable.dispose}\n\t */\n\tpublic dispose(): void {\n\t\tthis.isDisposed = true;\n\t\tfor (const listenerRemovers of this.forwardingEvents.values()) {\n\t\t\tfor (const listenerRemover of listenerRemovers.values()) {\n\t\t\t\ttry {\n\t\t\t\t\tlistenerRemover();\n\t\t\t\t} catch {\n\t\t\t\t\t// Should be fine because of removeAllListeners below\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.removeAllListeners();\n\t\tthis.forwardingEvents.clear();\n\t}\n\n\tprotected forwardEvent(\n\t\tsource: EventEmitter | IEventProvider<TEvent & IEvent>,\n\t\t...events: string[]\n\t): void {\n\t\tfor (const event of events) {\n\t\t\tif (\n\t\t\t\tsource !== undefined &&\n\t\t\t\tevent !== undefined &&\n\t\t\t\t!EventForwarder.isEmitterEvent(event)\n\t\t\t) {\n\t\t\t\tlet sources = this.forwardingEvents.get(event);\n\t\t\t\tif (sources === undefined) {\n\t\t\t\t\tsources = new Map();\n\t\t\t\t\tthis.forwardingEvents.set(event, sources);\n\t\t\t\t}\n\t\t\t\tif (!sources.has(source)) {\n\t\t\t\t\tconst listener = (...args: unknown[]): boolean => this.emit(event, ...args);\n\t\t\t\t\tsources.set(source, () => source.off(event, listener));\n\t\t\t\t\tsource.on(event, listener);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected unforwardEvent(\n\t\tsource: EventEmitter | IEventProvider<TEvent & IEvent>,\n\t\t...events: string[]\n\t): void {\n\t\tfor (const event of events) {\n\t\t\tif (event !== undefined && !EventForwarder.isEmitterEvent(event)) {\n\t\t\t\tconst sources = this.forwardingEvents.get(event);\n\t\t\t\tif (sources?.has(source) === true && this.listenerCount(event) === 0) {\n\t\t\t\t\tconst listenerRemover = sources.get(source);\n\t\t\t\t\tif (listenerRemover !== undefined) {\n\t\t\t\t\t\tlistenerRemover();\n\t\t\t\t\t}\n\t\t\t\t\tsources.delete(source);\n\t\t\t\t\tif (sources.size === 0) {\n\t\t\t\t\t\tthis.forwardingEvents.delete(event);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
@@ -29,7 +29,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
30
  exports.gitHashFile = exports.hashFile = void 0;
31
31
  const base64js = __importStar(require("base64-js"));
32
- const bufferBrowser_1 = require("./bufferBrowser");
32
+ const bufferBrowser_1 = require("./bufferBrowser.cjs");
33
33
  async function digestBuffer(file, algorithm) {
34
34
  const hash = await crypto.subtle.digest(algorithm, file);
35
35
  return new Uint8Array(hash);
@@ -71,9 +71,7 @@ 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 import(
75
- /* webpackChunkName: "FluidFramework-HashFallback" */
76
- "./hashFileNode.js").then(async (m) => m.hashFile(file, algorithm, hashEncoding));
74
+ return import("./hashFileNode.cjs").then(async (m) => m.hashFile(file, algorithm, hashEncoding));
77
75
  }
78
76
  // This is split up this way to facilitate testing (see the test for more info)
79
77
  const hashArray = await digestBuffer(file, algorithm);
@@ -98,4 +96,4 @@ async function gitHashFile(file) {
98
96
  return hashFile(hashBuffer);
99
97
  }
100
98
  exports.gitHashFile = gitHashFile;
101
- //# sourceMappingURL=hashFileBrowser.js.map
99
+ //# sourceMappingURL=hashFileBrowser.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hashFileBrowser.cjs","sourceRoot":"","sources":["../src/hashFileBrowser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,oDAAsC;AACtC,uDAA4C;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;gBACzG,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAW,CAAC;YACrD,CAAC,CAAC;iBACD,IAAI,CAAC,EAAE,CAAC,CAAC;YACX,OAAO,OAAO,CAAC;SACf;QACD,KAAK,QAAQ,CAAC,CAAC;YACd,OAAO,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;SACzC;KACD;AACF,CAAC;AAED;;;;;;;;;;;;GAYG;AACI,KAAK,UAAU,QAAQ,CAC7B,IAAe,EACf,YAAiC,OAAO,EACxC,eAAiC,KAAK;IAEtC,8DAA8D;IAC9D,2DAA2D;IAC3D,gFAAgF;IAChF,8EAA8E;IAC9E,8BAA8B;IAC9B,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE;QAChC,OAAO,MAAM,uBAGX,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;KAC/D;IAED,+EAA+E;IAC/E,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACtD,OAAO,YAAY,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;AAC9C,CAAC;AApBD,4BAoBC;AAED;;;;;;;;GAQG;AACI,KAAK,UAAU,WAAW,CAAC,IAAe;IAChD,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;IAC7B,qDAAqD;IACrD,MAAM,UAAU,GAAG,QAAQ,IAAI,CAAC,QAAQ,EAAE,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IACtE,MAAM,UAAU,GAAG,yBAAS,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IAEhE,mEAAmE;IACnE,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC;AAC7B,CAAC;AARD,kCAQC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as base64js from \"base64-js\";\nimport { IsoBuffer } from \"./bufferBrowser\";\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"]}
@@ -53,4 +53,4 @@ async function gitHashFile(file) {
53
53
  return engine.update(filePrefix).update(file).digest("hex");
54
54
  }
55
55
  exports.gitHashFile = gitHashFile;
56
- //# sourceMappingURL=hashFileNode.js.map
56
+ //# sourceMappingURL=hashFileNode.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hashFileNode.cjs","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"]}
@@ -19,13 +19,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.TypedEventEmitter = exports.Trace = exports.EventForwarder = exports.Uint8ArrayToArrayBuffer = exports.toUtf8 = exports.fromUtf8ToBase64 = exports.fromBase64ToUtf8 = void 0;
22
- var base64Encoding_1 = require("./base64Encoding");
22
+ var base64Encoding_1 = require("./base64Encoding.cjs");
23
23
  Object.defineProperty(exports, "fromBase64ToUtf8", { enumerable: true, get: function () { return base64Encoding_1.fromBase64ToUtf8; } });
24
24
  Object.defineProperty(exports, "fromUtf8ToBase64", { enumerable: true, get: function () { return base64Encoding_1.fromUtf8ToBase64; } });
25
25
  Object.defineProperty(exports, "toUtf8", { enumerable: true, get: function () { return base64Encoding_1.toUtf8; } });
26
- var bufferShared_1 = require("./bufferShared");
26
+ var bufferShared_1 = require("./bufferShared.cjs");
27
27
  Object.defineProperty(exports, "Uint8ArrayToArrayBuffer", { enumerable: true, get: function () { return bufferShared_1.Uint8ArrayToArrayBuffer; } });
28
- var eventForwarder_1 = require("./eventForwarder");
28
+ var eventForwarder_1 = require("./eventForwarder.cjs");
29
29
  Object.defineProperty(exports, "EventForwarder", { enumerable: true, get: function () { return eventForwarder_1.EventForwarder; } });
30
30
  /**
31
31
  * NOTE: This export is remapped to export from "./indexBrowser" in browser environments via package.json.
@@ -36,10 +36,10 @@ Object.defineProperty(exports, "EventForwarder", { enumerable: true, get: functi
36
36
  * desired.
37
37
  */
38
38
  // eslint-disable-next-line no-restricted-syntax
39
- __exportStar(require("./indexNode"), exports);
39
+ __exportStar(require("./indexNode.cjs"), exports);
40
40
  // export { IRange, IRangeTrackerSnapshot, RangeTracker } from "./rangeTracker";
41
- var trace_1 = require("./trace");
41
+ var trace_1 = require("./trace.cjs");
42
42
  Object.defineProperty(exports, "Trace", { enumerable: true, get: function () { return trace_1.Trace; } });
43
- var typedEventEmitter_1 = require("./typedEventEmitter");
43
+ var typedEventEmitter_1 = require("./typedEventEmitter.cjs");
44
44
  Object.defineProperty(exports, "TypedEventEmitter", { enumerable: true, get: function () { return typedEventEmitter_1.TypedEventEmitter; } });
45
- //# sourceMappingURL=index.js.map
45
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;AAEH,uDAA8E;AAArE,kHAAA,gBAAgB,OAAA;AAAE,kHAAA,gBAAgB,OAAA;AAAE,wGAAA,MAAM,OAAA;AACnD,mDAAyD;AAAhD,uHAAA,uBAAuB,OAAA;AAChC,uDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB;;;;;;;GAOG;AACH,gDAAgD;AAChD,kDAA4B;AAE5B,gFAAgF;AAChF,qCAA6C;AAAvB,8FAAA,KAAK,OAAA;AAC3B,6DAAoG;AAApE,sHAAA,iBAAiB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { fromBase64ToUtf8, fromUtf8ToBase64, toUtf8 } from \"./base64Encoding\";\nexport { Uint8ArrayToArrayBuffer } from \"./bufferShared\";\nexport { EventForwarder } from \"./eventForwarder\";\n/**\n * NOTE: This export is remapped to export from \"./indexBrowser\" in browser environments via package.json.\n * Because the two files don't have fully isomorphic exports, using named exports for the full API surface\n * is problematic if that named export includes values not in their intersection.\n *\n * In a future breaking change of client-utils, we could use a named export for their intersection if we\n * desired.\n */\n// eslint-disable-next-line no-restricted-syntax\nexport * from \"./indexNode\";\nexport { IsomorphicPerformance } from \"./performanceIsomorphic\";\n// export { IRange, IRangeTrackerSnapshot, RangeTracker } from \"./rangeTracker\";\nexport { ITraceEvent, Trace } from \"./trace\";\nexport { EventEmitterEventType, TypedEventEmitter, TypedEventTransform } from \"./typedEventEmitter\";\n"]}
@@ -5,15 +5,15 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.performance = exports.hashFile = exports.gitHashFile = exports.Uint8ArrayToString = exports.stringToBuffer = exports.IsoBuffer = exports.isArrayBuffer = exports.bufferToString = void 0;
8
- var bufferBrowser_1 = require("./bufferBrowser");
8
+ var bufferBrowser_1 = require("./bufferBrowser.cjs");
9
9
  Object.defineProperty(exports, "bufferToString", { enumerable: true, get: function () { return bufferBrowser_1.bufferToString; } });
10
10
  Object.defineProperty(exports, "isArrayBuffer", { enumerable: true, get: function () { return bufferBrowser_1.isArrayBuffer; } });
11
11
  Object.defineProperty(exports, "IsoBuffer", { enumerable: true, get: function () { return bufferBrowser_1.IsoBuffer; } });
12
12
  Object.defineProperty(exports, "stringToBuffer", { enumerable: true, get: function () { return bufferBrowser_1.stringToBuffer; } });
13
13
  Object.defineProperty(exports, "Uint8ArrayToString", { enumerable: true, get: function () { return bufferBrowser_1.Uint8ArrayToString; } });
14
- var hashFileBrowser_1 = require("./hashFileBrowser");
14
+ var hashFileBrowser_1 = require("./hashFileBrowser.cjs");
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 performanceIsomorphic_1 = require("./performanceIsomorphic");
17
+ var performanceIsomorphic_1 = require("./performanceIsomorphic.cjs");
18
18
  Object.defineProperty(exports, "performance", { enumerable: true, get: function () { return performanceIsomorphic_1.performance; } });
19
- //# sourceMappingURL=indexBrowser.js.map
19
+ //# sourceMappingURL=indexBrowser.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexBrowser.cjs","sourceRoot":"","sources":["../src/indexBrowser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qDAMyB;AALxB,+GAAA,cAAc,OAAA;AACd,8GAAA,aAAa,OAAA;AACb,0GAAA,SAAS,OAAA;AACT,+GAAA,cAAc,OAAA;AACd,mHAAA,kBAAkB,OAAA;AAEnB,yDAA0D;AAAjD,8GAAA,WAAW,OAAA;AAAE,2GAAA,QAAQ,OAAA;AAC9B,qEAAsD;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"]}
@@ -5,15 +5,15 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.performance = exports.hashFile = exports.gitHashFile = exports.Uint8ArrayToString = exports.stringToBuffer = exports.IsoBuffer = exports.bufferToString = exports.Buffer = void 0;
8
- var bufferNode_1 = require("./bufferNode");
8
+ var bufferNode_1 = require("./bufferNode.cjs");
9
9
  Object.defineProperty(exports, "Buffer", { enumerable: true, get: function () { return bufferNode_1.Buffer; } });
10
10
  Object.defineProperty(exports, "bufferToString", { enumerable: true, get: function () { return bufferNode_1.bufferToString; } });
11
11
  Object.defineProperty(exports, "IsoBuffer", { enumerable: true, get: function () { return bufferNode_1.IsoBuffer; } });
12
12
  Object.defineProperty(exports, "stringToBuffer", { enumerable: true, get: function () { return bufferNode_1.stringToBuffer; } });
13
13
  Object.defineProperty(exports, "Uint8ArrayToString", { enumerable: true, get: function () { return bufferNode_1.Uint8ArrayToString; } });
14
- var hashFileNode_1 = require("./hashFileNode");
14
+ var hashFileNode_1 = require("./hashFileNode.cjs");
15
15
  Object.defineProperty(exports, "gitHashFile", { enumerable: true, get: function () { return hashFileNode_1.gitHashFile; } });
16
16
  Object.defineProperty(exports, "hashFile", { enumerable: true, get: function () { return hashFileNode_1.hashFile; } });
17
- var performanceIsomorphic_1 = require("./performanceIsomorphic");
17
+ var performanceIsomorphic_1 = require("./performanceIsomorphic.cjs");
18
18
  Object.defineProperty(exports, "performance", { enumerable: true, get: function () { return performanceIsomorphic_1.performance; } });
19
- //# sourceMappingURL=indexNode.js.map
19
+ //# sourceMappingURL=indexNode.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexNode.cjs","sourceRoot":"","sources":["../src/indexNode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+CAMsB;AALrB,oGAAA,MAAM,OAAA;AACN,4GAAA,cAAc,OAAA;AACd,uGAAA,SAAS,OAAA;AACT,4GAAA,cAAc,OAAA;AACd,gHAAA,kBAAkB,OAAA;AAEnB,mDAAuD;AAA9C,2GAAA,WAAW,OAAA;AAAE,wGAAA,QAAQ,OAAA;AAC9B,qEAAsD;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\tBuffer,\n\tbufferToString,\n\tIsoBuffer,\n\tstringToBuffer,\n\tUint8ArrayToString,\n} from \"./bufferNode\";\nexport { gitHashFile, hashFile } from \"./hashFileNode\";\nexport { performance } from \"./performanceIsomorphic\";\n"]}
@@ -14,4 +14,4 @@ exports.performance = void 0;
14
14
  * @internal
15
15
  */
16
16
  exports.performance = globalThis.performance;
17
- //# sourceMappingURL=performanceIsomorphic.js.map
17
+ //# sourceMappingURL=performanceIsomorphic.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"performanceIsomorphic.cjs","sourceRoot":"","sources":["../src/performanceIsomorphic.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAWH;;;;;;;GAOG;AACU,QAAA,WAAW,GAA0B,UAAU,CAAC,WAAW,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * This type contains all browser performance properties as optional, and some\n * of the intersecting properties of node and browser performance as required.\n *\n * @internal\n */\nexport type IsomorphicPerformance = Partial<Performance> &\n\tPick<Performance, \"clearMarks\" | \"mark\" | \"measure\" | \"now\">;\n\n/**\n * This exported \"performance\" member masks the built-in globalThis.performance object\n * as an IsomorphicPerformance, which hides all of its features that aren't compatible\n * between Node and browser implementations. Anything exposed on this performance object\n * is considered safe to use regarless of the environment it runs in.\n *\n * @internal\n */\nexport const performance: IsomorphicPerformance = globalThis.performance;\n"]}
@@ -5,7 +5,7 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.Trace = void 0;
8
- const indexNode_1 = require("./indexNode");
8
+ const indexNode_1 = require("./indexNode.cjs");
9
9
  /**
10
10
  * Helper class for tracing performance of events
11
11
  * Time measurements are in milliseconds as a floating point with a decimal
@@ -33,4 +33,4 @@ class Trace {
33
33
  }
34
34
  }
35
35
  exports.Trace = Trace;
36
- //# sourceMappingURL=trace.js.map
36
+ //# sourceMappingURL=trace.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trace.cjs","sourceRoot":"","sources":["../src/trace.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+CAA0C;AAE1C;;;;;GAKG;AACH,MAAa,KAAK;IACV,MAAM,CAAC,KAAK;QAClB,MAAM,SAAS,GAAG,uBAAW,CAAC,GAAG,EAAE,CAAC;QACpC,OAAO,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC;IAC7B,CAAC;IAGD,YAAsC,SAAiB;QAAjB,cAAS,GAAT,SAAS,CAAQ;QACtD,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;IAC3B,CAAC;IAEM,KAAK;QACX,MAAM,IAAI,GAAG,uBAAW,CAAC,GAAG,EAAE,CAAC;QAC/B,MAAM,KAAK,GAAG;YACb,gBAAgB,EAAE,IAAI,GAAG,IAAI,CAAC,SAAS;YACvC,QAAQ,EAAE,IAAI,GAAG,IAAI,CAAC,QAAQ;YAC9B,IAAI;SACJ,CAAC;QACF,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,OAAO,KAAK,CAAC;IACd,CAAC;CACD;AArBD,sBAqBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performance } from \"./indexNode\";\n\n/**\n * Helper class for tracing performance of events\n * Time measurements are in milliseconds as a floating point with a decimal\n *\n * @internal\n */\nexport class Trace {\n\tpublic static start(): Trace {\n\t\tconst startTick = performance.now();\n\t\treturn new Trace(startTick);\n\t}\n\n\tprotected lastTick: number;\n\tprotected constructor(public readonly startTick: number) {\n\t\tthis.lastTick = startTick;\n\t}\n\n\tpublic trace(): ITraceEvent {\n\t\tconst tick = performance.now();\n\t\tconst event = {\n\t\t\ttotalTimeElapsed: tick - this.startTick,\n\t\t\tduration: tick - this.lastTick,\n\t\t\ttick,\n\t\t};\n\t\tthis.lastTick = tick;\n\t\treturn event;\n\t}\n}\n\n/**\n * Event in a performance trace including time elapsed.\n *\n * @internal\n */\nexport interface ITraceEvent {\n\t/**\n\t * Total time elapsed since the start of the Trace.\n\t * Measured in milliseconds as a floating point with a decimal\n\t */\n\treadonly totalTimeElapsed: number;\n\t/**\n\t * Time elapsed since the last trace event.\n\t * Measured in milliseconds as a floating point with a decimal\n\t */\n\treadonly duration: number;\n\t/**\n\t * This number represents a relative time which should\n\t * be consistent for all trace ticks.\n\t */\n\treadonly tick: number;\n}\n"]}
@@ -26,4 +26,4 @@ class TypedEventEmitter extends events_1.EventEmitter {
26
26
  }
27
27
  }
28
28
  exports.TypedEventEmitter = TypedEventEmitter;
29
- //# sourceMappingURL=typedEventEmitter.js.map
29
+ //# sourceMappingURL=typedEventEmitter.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typedEventEmitter.cjs","sourceRoot":"","sources":["../src/typedEventEmitter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,8EAA8E;AAC9E,wDAAwD;AACxD,mCAAsC;AAyCtC;;;;GAIG;AACH,MAAa,iBACZ,SAAQ,qBAAY;IAGpB;QACC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAsC,CAAC;QACrF,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAsC,CAAC;QACnE,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAsC,CAAC;QACvE,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAGrD,CAAC;QACF,IAAI,CAAC,mBAAmB,GAAG,KAAK,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAG7D,CAAC;QACF,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAsC,CAAC;QAC3F,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAsC,CAAC;IACtE,CAAC;CAQD;AA3BD,8CA2BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// False positive: this is an import from the `events` package, not from Node.\n// eslint-disable-next-line unicorn/prefer-node-protocol\nimport { EventEmitter } from \"events\";\nimport {\n\tIEvent,\n\tTransformedEvent,\n\tIEventTransformer,\n\tIEventProvider,\n} from \"@fluidframework/core-interfaces\";\n\n/**\n * The event emitter polyfill and the node event emitter have different event types:\n * string | symbol vs. string | number\n *\n * This type allow us to correctly handle either type\n *\n * @alpha\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type EventEmitterEventType = EventEmitter extends { on(event: infer E, listener: any) }\n\t? E\n\t: never;\n\n/**\n * @alpha\n */\nexport type TypedEventTransform<TThis, TEvent> =\n\t// Event emitter supports some special events for the emitter itself to use\n\t// this exposes those events for the TypedEventEmitter.\n\t// Since we know what the shape of these events are, we can describe them directly via a TransformedEvent\n\t// which easier than trying to extend TEvent directly\n\tTransformedEvent<\n\t\tTThis,\n\t\t\"newListener\" | \"removeListener\",\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tParameters<(event: string, listener: (...args: any[]) => void) => void>\n\t> &\n\t\t// Expose all the events provides by TEvent\n\t\tIEventTransformer<TThis, TEvent & IEvent> &\n\t\t// Add the default overload so this is covertable to EventEmitter regardless of environment\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tTransformedEvent<TThis, EventEmitterEventType, any[]>;\n\n/**\n * Event Emitter helper class the supports emitting typed events\n *\n * @alpha\n */\nexport class TypedEventEmitter<TEvent>\n\textends EventEmitter\n\timplements IEventProvider<TEvent & IEvent>\n{\n\tconstructor() {\n\t\tsuper();\n\t\tthis.addListener = super.addListener.bind(this) as TypedEventTransform<this, TEvent>;\n\t\tthis.on = super.on.bind(this) as TypedEventTransform<this, TEvent>;\n\t\tthis.once = super.once.bind(this) as TypedEventTransform<this, TEvent>;\n\t\tthis.prependListener = super.prependListener.bind(this) as TypedEventTransform<\n\t\t\tthis,\n\t\t\tTEvent\n\t\t>;\n\t\tthis.prependOnceListener = super.prependOnceListener.bind(this) as TypedEventTransform<\n\t\t\tthis,\n\t\t\tTEvent\n\t\t>;\n\t\tthis.removeListener = super.removeListener.bind(this) as TypedEventTransform<this, TEvent>;\n\t\tthis.off = super.off.bind(this) as TypedEventTransform<this, TEvent>;\n\t}\n\treadonly addListener: TypedEventTransform<this, TEvent>;\n\treadonly on: TypedEventTransform<this, TEvent>;\n\treadonly once: TypedEventTransform<this, TEvent>;\n\treadonly prependListener: TypedEventTransform<this, TEvent>;\n\treadonly prependOnceListener: TypedEventTransform<this, TEvent>;\n\treadonly removeListener: TypedEventTransform<this, TEvent>;\n\treadonly off: TypedEventTransform<this, TEvent>;\n}\n"]}
package/jest.config.js CHANGED
@@ -15,6 +15,6 @@ module.exports = {
15
15
  },
16
16
  ],
17
17
  ],
18
- testMatch: ["**/dist/test/jest/?(*.)+(spec|test).js"],
18
+ testMatch: ["**/dist/test/jest/?(*.)+(spec|test).?js"],
19
19
  testPathIgnorePatterns: ["/node_modules/"],
20
20
  };
@@ -1,27 +1,22 @@
1
- "use strict";
2
1
  /*!
3
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
3
  * Licensed under the MIT License.
5
4
  */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.toUtf8 = exports.fromUtf8ToBase64 = exports.fromBase64ToUtf8 = void 0;
8
- const indexNode_1 = require("./indexNode");
5
+ import { IsoBuffer } from "./indexNode.mjs";
9
6
  /**
10
7
  * Converts the provided {@link https://en.wikipedia.org/wiki/Base64 | base64}-encoded string
11
8
  * to {@link https://en.wikipedia.org/wiki/UTF-8 | utf-8}.
12
9
  *
13
10
  * @internal
14
11
  */
15
- const fromBase64ToUtf8 = (input) => indexNode_1.IsoBuffer.from(input, "base64").toString("utf8");
16
- exports.fromBase64ToUtf8 = fromBase64ToUtf8;
12
+ export const fromBase64ToUtf8 = (input) => IsoBuffer.from(input, "base64").toString("utf8");
17
13
  /**
18
14
  * Converts the provided {@link https://en.wikipedia.org/wiki/UTF-8 | utf-8}-encoded string
19
15
  * to {@link https://en.wikipedia.org/wiki/Base64 | base64}.
20
16
  *
21
17
  * @internal
22
18
  */
23
- const fromUtf8ToBase64 = (input) => indexNode_1.IsoBuffer.from(input, "utf8").toString("base64");
24
- exports.fromUtf8ToBase64 = fromUtf8ToBase64;
19
+ export const fromUtf8ToBase64 = (input) => IsoBuffer.from(input, "utf8").toString("base64");
25
20
  /**
26
21
  * Convenience function to convert unknown encoding to utf8 that avoids
27
22
  * buffer copies/encode ops when no conversion is needed.
@@ -30,7 +25,7 @@ exports.fromUtf8ToBase64 = fromUtf8ToBase64;
30
25
  *
31
26
  * @internal
32
27
  */
33
- const toUtf8 = (input, encoding) => {
28
+ export const toUtf8 = (input, encoding) => {
34
29
  switch (encoding) {
35
30
  case "utf8":
36
31
  // eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged
@@ -38,9 +33,8 @@ const toUtf8 = (input, encoding) => {
38
33
  return input;
39
34
  }
40
35
  default: {
41
- return indexNode_1.IsoBuffer.from(input, encoding).toString();
36
+ return IsoBuffer.from(input, encoding).toString();
42
37
  }
43
38
  }
44
39
  };
45
- exports.toUtf8 = toUtf8;
46
- //# sourceMappingURL=base64Encoding.js.map
40
+ //# sourceMappingURL=base64Encoding.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base64Encoding.mjs","sourceRoot":"","sources":["../src/base64Encoding.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,SAAS,EAAE;AAEpB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAU,EAAE,CACzD,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAElD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAU,EAAE,CACzD,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,CAAC,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,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC;SAClD;KACD;AACF,CAAC,CAAC","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"]}
@@ -1,34 +1,8 @@
1
- "use strict";
2
1
  /*!
3
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
3
  * Licensed under the MIT License.
5
4
  */
6
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
- if (k2 === undefined) k2 = 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);
13
- }) : (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- o[k2] = m[k];
16
- }));
17
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
- Object.defineProperty(o, "default", { enumerable: true, value: v });
19
- }) : function(o, v) {
20
- o["default"] = v;
21
- });
22
- var __importStar = (this && this.__importStar) || function (mod) {
23
- if (mod && mod.__esModule) return mod;
24
- var result = {};
25
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
26
- __setModuleDefault(result, mod);
27
- return result;
28
- };
29
- Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.IsoBuffer = exports.isArrayBuffer = exports.bufferToString = exports.stringToBuffer = exports.Uint8ArrayToString = void 0;
31
- const base64js = __importStar(require("base64-js"));
5
+ import * as base64js from "base64-js";
32
6
  /**
33
7
  * Converts a Uint8Array to a string of the provided encoding
34
8
  * Useful when the array might be an {@link IsoBuffer}.
@@ -40,7 +14,7 @@ const base64js = __importStar(require("base64-js"));
40
14
  *
41
15
  * @internal
42
16
  */
43
- function Uint8ArrayToString(arr,
17
+ export function Uint8ArrayToString(arr,
44
18
  // eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged
45
19
  encoding) {
46
20
  switch (encoding) {
@@ -58,7 +32,6 @@ encoding) {
58
32
  }
59
33
  }
60
34
  }
61
- exports.Uint8ArrayToString = Uint8ArrayToString;
62
35
  /**
63
36
  * Converts a {@link https://en.wikipedia.org/wiki/Base64 | base64} or
64
37
  * {@link https://en.wikipedia.org/wiki/UTF-8 | utf-8} string to array buffer.
@@ -67,8 +40,7 @@ exports.Uint8ArrayToString = Uint8ArrayToString;
67
40
  *
68
41
  * @internal
69
42
  */
70
- const stringToBuffer = (input, encoding) => IsoBuffer.from(input, encoding).buffer;
71
- exports.stringToBuffer = stringToBuffer;
43
+ export const stringToBuffer = (input, encoding) => IsoBuffer.from(input, encoding).buffer;
72
44
  /**
73
45
  * Convert binary blob to string format
74
46
  *
@@ -78,10 +50,9 @@ exports.stringToBuffer = stringToBuffer;
78
50
  *
79
51
  * @internal
80
52
  */
81
- const bufferToString = (blob,
53
+ export const bufferToString = (blob,
82
54
  // eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged
83
55
  encoding) => IsoBuffer.from(blob).toString(encoding);
84
- exports.bufferToString = bufferToString;
85
56
  /**
86
57
  * Determines if an object is an array buffer.
87
58
  *
@@ -96,7 +67,7 @@ exports.bufferToString = bufferToString;
96
67
  *
97
68
  * @internal
98
69
  */
99
- function isArrayBuffer(obj) {
70
+ export function isArrayBuffer(obj) {
100
71
  const maybe = obj;
101
72
  return (obj instanceof ArrayBuffer ||
102
73
  (typeof maybe === "object" &&
@@ -106,13 +77,12 @@ function isArrayBuffer(obj) {
106
77
  maybe.byteOffset === undefined &&
107
78
  maybe.buffer === undefined));
108
79
  }
109
- exports.isArrayBuffer = isArrayBuffer;
110
80
  /**
111
81
  * Minimal implementation of Buffer for our usages in the browser environment.
112
82
  *
113
83
  * @internal
114
84
  */
115
- class IsoBuffer extends Uint8Array {
85
+ export class IsoBuffer extends Uint8Array {
116
86
  /**
117
87
  * Convert the buffer to a string.
118
88
  * Only supports encoding the whole string (unlike the Node Buffer equivalent)
@@ -208,5 +178,4 @@ class IsoBuffer extends Uint8Array {
208
178
  return sanitizedStr;
209
179
  }
210
180
  }
211
- exports.IsoBuffer = IsoBuffer;
212
- //# sourceMappingURL=bufferBrowser.js.map
181
+ //# sourceMappingURL=bufferBrowser.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bufferBrowser.mjs","sourceRoot":"","sources":["../src/bufferBrowser.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,KAAK,QAAQ,MAAM,WAAW;AAErC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kBAAkB,CACjC,GAAe;AACf,8GAA8G;AAC9G,QAAsC;IAEtC,QAAQ,QAAQ,EAAE;QACjB,KAAK,QAA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AAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;SACtD;QACD,OAAO,YAAY,CAAC;IACrB,CAAC;CACD","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"]}
@@ -1,14 +1,11 @@
1
- "use strict";
2
1
  /*!
3
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
3
  * Licensed under the MIT License.
5
4
  */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.bufferToString = exports.stringToBuffer = exports.Uint8ArrayToString = exports.IsoBuffer = void 0;
8
5
  /**
9
6
  * @internal
10
7
  */
11
- exports.IsoBuffer = Buffer;
8
+ export const IsoBuffer = Buffer;
12
9
  /**
13
10
  * Converts a Uint8Array to a string of the provided encoding.
14
11
  * @remarks Useful when the array might be an IsoBuffer.
@@ -19,22 +16,21 @@ exports.IsoBuffer = Buffer;
19
16
  *
20
17
  * @internal
21
18
  */
22
- function Uint8ArrayToString(arr,
19
+ export function Uint8ArrayToString(arr,
23
20
  // eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged
24
21
  encoding) {
25
22
  // Buffer extends Uint8Array. Therefore, 'arr' may already be a Buffer, in
26
23
  // which case we can avoid copying the Uint8Array into a new Buffer instance.
27
24
  return (Buffer.isBuffer(arr) ? arr : Buffer.from(arr)).toString(encoding);
28
25
  }
29
- exports.Uint8ArrayToString = Uint8ArrayToString;
30
26
  /**
31
27
  * Convert base64 or utf8 string to array buffer.
32
28
  * @param encoding - The input string's encoding.
33
29
  *
34
30
  * @internal
35
31
  */
36
- function stringToBuffer(input, encoding) {
37
- const iso = exports.IsoBuffer.from(input, encoding);
32
+ export function stringToBuffer(input, encoding) {
33
+ const iso = IsoBuffer.from(input, encoding);
38
34
  // In a Node environment, IsoBuffer may be a Node.js Buffer. Node.js will
39
35
  // pool multiple small Buffer instances into a single ArrayBuffer, in which
40
36
  // case we need to slice the appropriate span of bytes.
@@ -42,7 +38,6 @@ function stringToBuffer(input, encoding) {
42
38
  ? iso.buffer
43
39
  : iso.buffer.slice(iso.byteOffset, iso.byteOffset + iso.byteLength);
44
40
  }
45
- exports.stringToBuffer = stringToBuffer;
46
41
  /**
47
42
  * Convert binary blob to string format
48
43
  *
@@ -52,8 +47,7 @@ exports.stringToBuffer = stringToBuffer;
52
47
  *
53
48
  * @internal
54
49
  */
55
- const bufferToString = (blob,
50
+ export const bufferToString = (blob,
56
51
  // eslint-disable-next-line unicorn/text-encoding-identifier-case -- this value is supported, just discouraged
57
- encoding) => exports.IsoBuffer.from(blob).toString(encoding);
58
- exports.bufferToString = bufferToString;
59
- //# sourceMappingURL=bufferNode.js.map
52
+ encoding) => IsoBuffer.from(blob).toString(encoding);
53
+ //# sourceMappingURL=bufferNode.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bufferNode.mjs","sourceRoot":"","sources":["../src/bufferNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA0BH;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC;AAOhC;;;;;;;;;GASG;AACH,MAAM,UAAU,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;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa,EAAE,QAAgB;IAC7D,MAAM,GAAG,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC5C,0EAA0E;IAC1E,2EAA2E;IAC3E,uDAAuD;IACvD,OAAO,GAAG,CAAC,UAAU,KAAK,GAAG,CAAC,MAAM,CAAC,UAAU;QAC9C,CAAC,CAAC,GAAG,CAAC,MAAM;QACZ,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC;AACtE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC7B,IAAqB;AACrB,8GAA8G;AAC9G,QAAqC,EAC5B,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC","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"]}